Skip to content

Fix Publication for partitioned tables #550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions postgresql/resource_postgresql_publication.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,15 @@ func resourcePostgreSQLPublicationReadImpl(db *DBConnection, d *schema.ResourceD
return fmt.Errorf("Error reading publication info: %w", err)
}

query = `SELECT CONCAT(schemaname,'.',tablename) as fulltablename ` +
`FROM pg_catalog.pg_publication_tables ` +
`WHERE pubname = $1`
query = `SELECT DISTINCT ` +
`COALESCE(parent_ns.nspname || '.' || parent_class.relname, ` +
`pt.schemaname || '.' || pt.tablename) AS fulltablename ` +
`FROM pg_publication_tables pt ` +
`LEFT JOIN pg_class child ON pt.tablename = child.relname ` +
`LEFT JOIN pg_inherits i ON i.inhrelid = child.oid ` +
`LEFT JOIN pg_class parent_class ON i.inhparent = parent_class.oid ` +
`LEFT JOIN pg_namespace parent_ns ON parent_class.relnamespace = parent_ns.oid ` +
`WHERE pt.pubname = $1`

rows, err := txn.Query(query, pqQuoteLiteral(PublicationName))
if err != nil {
Expand Down