Skip to content

Commit

Permalink
use pg_inherits instead pg_partition_rule
Browse files Browse the repository at this point in the history
  • Loading branch information
RekGRpth committed Sep 18, 2023
1 parent f61d917 commit dd9881e
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions backup/queries_relations.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,17 @@ func getExcludedRelationOidsList(connectionPool *dbconn.DBConn, quotedIncludeRel
relList := utils.SliceToQuotedString(quotedIncludeRelations)

query := fmt.Sprintf(`
WITH root_oids AS (
SELECT c.oid AS _oid
WITH recursive cte AS (
SELECT c.oid AS string
FROM pg_class c
JOIN pg_namespace n ON c.relnamespace = n.oid
WHERE quote_ident(n.nspname) || '.' || quote_ident(c.relname) IN (%s)
)
SELECT _oid FROM root_oids
UNION
SELECT r.parchildrelid as _oid
FROM pg_partition p join pg_partition_rule r on p.oid = r.paroid
join root_oids oids on p.parrelid = oids._oid WHERE r.parchildrelid != 0
`, relList)
WHERE quote_ident(n.nspname) || '.' || quote_ident(c.relname) IN (%s)
UNION ALL
SELECT inhrelid AS strings
FROM cte
LEFT JOIN pg_inherits ON inhparent = string
WHERE inhrelid IS NOT NULL
) SELECT * FROM cte`, relList)
return dbconn.MustSelectStringSlice(connectionPool, query)
}

Expand Down

0 comments on commit dd9881e

Please sign in to comment.