Skip to content
Merged
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
16 changes: 15 additions & 1 deletion backup/queries_operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,21 @@ func GetOperatorClasses(connectionPool *dbconn.DBConn) []OperatorClass {
(SELECT amname FROM pg_catalog.pg_am WHERE oid = opcmethod) AS indexmethod,
opcintype::pg_catalog.regtype AS type,
opcdefault AS default,
opckeytype::pg_catalog.regtype AS storagetype
/*
* GPDB7 (PG12) and CBDB (PG14) have different behaviors when casting
* opckeytype to a regtype when the STORAGE type is the same as the
* FOR TYPE and the opckeytype is not 0.
*
* In GPDB7, the expression opckeytype::regtype evaluates to "-"
* in this case.
*
* In CBDB, the same expression evaluates to the type name (e.g., "integer").
*
* This CASE statement explicitly checks if the types are the same to
* normalize this behavior, ensuring the output is always "-" when the
* storage type is the same as the input type.
*/
CASE WHEN opcintype = opckeytype THEN '-' ELSE opckeytype::pg_catalog.regtype END AS storagetype
FROM pg_catalog.pg_opclass c
LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = opcfamily
JOIN pg_catalog.pg_namespace cls_ns ON cls_ns.oid = opcnamespace
Expand Down