Skip to content

Commit

Permalink
source-postgres: exclude temp tables from discovery
Browse files Browse the repository at this point in the history
Filters out temporary and unlogged tables during discovery. These tables cause
validation to fail because they cannot be added to publications. The filtering
is done based on the `pg_class.relpersistence` values, described in the docs:
https://www.postgresql.org/docs/current/catalog-pg-class.html#CATALOG-PG-CLASS
  • Loading branch information
psFried committed Nov 8, 2024
1 parent a492d45 commit 7087fec
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions source-postgres/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ const queryDiscoverTables = `
JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace)
WHERE n.nspname NOT IN ('pg_catalog', 'pg_internal', 'information_schema', 'catalog_history', 'cron', 'pglogical')
AND NOT c.relispartition
-- exclude temporary tables ('t') and unlogged tables ('u')
AND c.relpersistence = 'p'
AND c.relkind IN ('r', 'p');` // 'r' means "Ordinary Table" and 'p' means "Partitioned Table"

func getTables(ctx context.Context, conn *pgx.Conn, selectedSchemas []string) ([]*sqlcapture.DiscoveryInfo, error) {
Expand Down

0 comments on commit 7087fec

Please sign in to comment.