agora inbox for [email protected]help / color / mirror / Atom feed
[PATCH 07/11] possibility to dump session variables by pg_dump 286+ messages / 3 participants [nested] [flat]
* [PATCH 07/11] possibility to dump session variables by pg_dump @ 2022-04-04 18:49 [email protected] <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: [email protected] @ 2022-04-04 18:49 UTC (permalink / raw) Enhancing pg_dump about session variables support --- src/bin/pg_dump/common.c | 3 +- src/bin/pg_dump/dumputils.c | 6 + src/bin/pg_dump/pg_backup.h | 2 + src/bin/pg_dump/pg_backup_archiver.c | 12 +- src/bin/pg_dump/pg_dump.c | 237 ++++++++++++++++++++++++++- src/bin/pg_dump/pg_dump.h | 25 ++- src/bin/pg_dump/pg_dump_sort.c | 6 + src/bin/pg_dump/pg_restore.c | 9 +- src/bin/pg_dump/t/002_pg_dump.pl | 65 ++++++++ 9 files changed, 360 insertions(+), 5 deletions(-) diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 794e6e7ce9..97270e0b06 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -263,7 +263,8 @@ getSchemaData(Archive *fout, int *numTablesPtr) pg_log_info("reading subscriptions"); getSubscriptions(fout); - free(inhinfo); /* not needed any longer */ + pg_log_info("reading variables"); + getVariables(fout); *numTablesPtr = numTables; return tblinfo; diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c index 6e501a5413..dc1f0e1ba8 100644 --- a/src/bin/pg_dump/dumputils.c +++ b/src/bin/pg_dump/dumputils.c @@ -504,6 +504,12 @@ do { \ CONVERT_PRIV('r', "SELECT"); CONVERT_PRIV('w', "UPDATE"); } + else if (strcmp(type, "VARIABLE") == 0 || + strcmp(type, "VARIABLES") == 0) + { + CONVERT_PRIV('r', "SELECT"); + CONVERT_PRIV('w', "UPDATE"); + } else abort(); diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h index fcc5f6bd05..9d675d669c 100644 --- a/src/bin/pg_dump/pg_backup.h +++ b/src/bin/pg_dump/pg_backup.h @@ -131,12 +131,14 @@ typedef struct _restoreOptions int selFunction; int selTrigger; int selTable; + int selVariable; SimpleStringList indexNames; SimpleStringList functionNames; SimpleStringList schemaNames; SimpleStringList schemaExcludeNames; SimpleStringList triggerNames; SimpleStringList tableNames; + SimpleStringList variableNames; int useDB; ConnParams cparams; /* parameters to use if useDB */ diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 233198afc0..8d47869ba8 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -2934,6 +2934,14 @@ _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH) !simple_string_list_member(&ropt->triggerNames, te->tag)) return 0; } + else if (strcmp(te->desc, "VARIABLE") == 0) + { + if (!ropt->selVariable) + return 0; + if (ropt->variableNames.head != NULL && + !simple_string_list_member(&ropt->variableNames, te->tag)) + return 0; + } else return 0; } @@ -3419,6 +3427,7 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te) strcmp(type, "TEXT SEARCH DICTIONARY") == 0 || strcmp(type, "TEXT SEARCH CONFIGURATION") == 0 || strcmp(type, "STATISTICS") == 0 || + strcmp(type, "VARIABLE") == 0 || /* non-schema-specified objects */ strcmp(type, "DATABASE") == 0 || strcmp(type, "PROCEDURAL LANGUAGE") == 0 || @@ -3611,7 +3620,8 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData) strcmp(te->desc, "SERVER") == 0 || strcmp(te->desc, "STATISTICS") == 0 || strcmp(te->desc, "PUBLICATION") == 0 || - strcmp(te->desc, "SUBSCRIPTION") == 0) + strcmp(te->desc, "SUBSCRIPTION") == 0 || + strcmp(te->desc, "VARIABLE") == 0) { PQExpBuffer temp = createPQExpBuffer(); diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 67b6d9079e..a60cf1aa87 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -287,6 +287,7 @@ static void dumpPolicy(Archive *fout, const PolicyInfo *polinfo); static void dumpPublication(Archive *fout, const PublicationInfo *pubinfo); static void dumpPublicationTable(Archive *fout, const PublicationRelInfo *pubrinfo); static void dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo); +static void dumpVariable(Archive *fout, const VariableInfo * varinfo); static void dumpDatabase(Archive *AH); static void dumpDatabaseConfig(Archive *AH, PQExpBuffer outbuf, const char *dbname, Oid dboid); @@ -4741,6 +4742,232 @@ get_next_possible_free_pg_type_oid(Archive *fout, PQExpBuffer upgrade_query) return next_possible_free_oid; } +/* + * getVariables + * get information about variables + */ +void +getVariables(Archive *fout) +{ + PQExpBuffer query; + PGresult *res; + VariableInfo *varinfo; + int i_tableoid; + int i_oid; + int i_varname; + int i_varnamespace; + int i_vartype; + int i_vartypname; + int i_vardefexpr; + int i_vareoxaction; + int i_varisnotnull; + int i_varisimmutable; + int i_varowner; + int i_varcollation; + int i_varacl; + int i_acldefault; + int i, + ntups; + + if (fout->remoteVersion < 160000) + return; + + query = createPQExpBuffer(); + + resetPQExpBuffer(query); + + /* Get the variables in current database. */ + appendPQExpBuffer(query, + "SELECT v.tableoid, v.oid, v.varname,\n" + "v.vareoxaction,\n" + "v.varnamespace,\n" + "v.vartype,\n" + "pg_catalog.format_type(v.vartype, v.vartypmod) as vartypname,\n" + "v.varisnotnull,\n" + "v.varisimmutable,\n" + "CASE WHEN v.varcollation <> t.typcollation " + "THEN v.varcollation ELSE 0 END AS varcollation,\n" + "pg_catalog.pg_get_expr(v.vardefexpr,0) as vardefexpr,\n" + "v.varowner,\n" + "v.varacl,\n" + "acldefault('V', v.varowner) AS acldefault\n" + "FROM pg_catalog.pg_variable v\n" + "JOIN pg_catalog.pg_type t " + "ON (v.vartype = t.oid)"); + + res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); + + ntups = PQntuples(res); + + i_tableoid = PQfnumber(res, "tableoid"); + i_oid = PQfnumber(res, "oid"); + i_varname = PQfnumber(res, "varname"); + i_varnamespace = PQfnumber(res, "varnamespace"); + i_vartype = PQfnumber(res, "vartype"); + i_vartypname = PQfnumber(res, "vartypname"); + i_vareoxaction = PQfnumber(res, "vareoxaction"); + i_vardefexpr = PQfnumber(res, "vardefexpr"); + i_varisnotnull = PQfnumber(res, "varisnotnull"); + i_varisimmutable = PQfnumber(res, "varisimmutable"); + i_varcollation = PQfnumber(res, "varcollation"); + + i_varowner = PQfnumber(res, "varowner"); + i_varacl = PQfnumber(res, "varacl"); + i_acldefault = PQfnumber(res, "acldefault"); + + varinfo = pg_malloc(ntups * sizeof(VariableInfo)); + + for (i = 0; i < ntups; i++) + { + TypeInfo *vtype; + + varinfo[i].dobj.objType = DO_VARIABLE; + varinfo[i].dobj.catId.tableoid = + atooid(PQgetvalue(res, i, i_tableoid)); + varinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); + AssignDumpId(&varinfo[i].dobj); + varinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_varname)); + varinfo[i].dobj.namespace = + findNamespace(atooid(PQgetvalue(res, i, i_varnamespace))); + + varinfo[i].vartype = atooid(PQgetvalue(res, i, i_vartype)); + varinfo[i].vartypname = pg_strdup(PQgetvalue(res, i, i_vartypname)); + varinfo[i].vareoxaction = pg_strdup(PQgetvalue(res, i, i_vareoxaction)); + varinfo[i].varisnotnull = *(PQgetvalue(res, i, i_varisnotnull)) == 't'; + varinfo[i].varisimmutable = *(PQgetvalue(res, i, i_varisimmutable)) == 't'; + varinfo[i].varcollation = atooid(PQgetvalue(res, i, i_varcollation)); + + varinfo[i].dacl.acl = pg_strdup(PQgetvalue(res, i, i_varacl)); + varinfo[i].dacl.acldefault = pg_strdup(PQgetvalue(res, i, i_acldefault)); + varinfo[i].dacl.privtype = 0; + varinfo[i].dacl.initprivs = NULL; + varinfo[i].rolname = getRoleName(PQgetvalue(res, i, i_varowner)); + + /* Decide whether we want to dump it */ + selectDumpableObject(&(varinfo[i].dobj), fout); + + /* Do not try to dump ACL if no ACL exists. */ + if (!PQgetisnull(res, i, i_varacl)) + varinfo[i].dobj.components |= DUMP_COMPONENT_ACL; + + if (PQgetisnull(res, i, i_vardefexpr)) + varinfo[i].vardefexpr = NULL; + else + varinfo[i].vardefexpr = pg_strdup(PQgetvalue(res, i, i_vardefexpr)); + + if (strlen(varinfo[i].rolname) == 0) + pg_log_warning("owner of variable \"%s\" appears to be invalid", + varinfo[i].dobj.name); + + /* Decide whether we want to dump it */ + selectDumpableObject(&(varinfo[i].dobj), fout); + + vtype = findTypeByOid(varinfo[i].vartype); + addObjectDependency(&varinfo[i].dobj, vtype->dobj.dumpId); + } + PQclear(res); + + destroyPQExpBuffer(query); +} + +/* + * dumpVariable + * dump the definition of the given variables + */ +static void +dumpVariable(Archive *fout, const VariableInfo * varinfo) +{ + DumpOptions *dopt = fout->dopt; + + PQExpBuffer delq; + PQExpBuffer query; + char *qualvarname; + const char *vartypname; + const char *vardefexpr; + const char *vareoxaction; + const char *varisimmutable; + Oid varcollation; + bool varisnotnull; + + /* Skip if not to be dumped */ + if (!varinfo->dobj.dump || dopt->dataOnly) + return; + + delq = createPQExpBuffer(); + query = createPQExpBuffer(); + + qualvarname = pg_strdup(fmtQualifiedDumpable(varinfo)); + vartypname = varinfo->vartypname; + vardefexpr = varinfo->vardefexpr; + vareoxaction = varinfo->vareoxaction; + varisnotnull = varinfo->varisnotnull; + varisimmutable = varinfo->varisimmutable ? "IMMUTABLE " : ""; + varcollation = varinfo->varcollation; + + appendPQExpBuffer(delq, "DROP VARIABLE %s;\n", + qualvarname); + + appendPQExpBuffer(query, "CREATE %sVARIABLE %s AS %s", + varisimmutable, qualvarname, vartypname); + + if (OidIsValid(varcollation)) + { + CollInfo *coll; + + coll = findCollationByOid(varcollation); + if (coll) + appendPQExpBuffer(query, " COLLATE %s", + fmtQualifiedDumpable(coll)); + } + + if (varisnotnull) + appendPQExpBuffer(query, " NOT NULL"); + + if (vardefexpr) + appendPQExpBuffer(query, " DEFAULT %s", + vardefexpr); + + if (strcmp(vareoxaction, "d") == 0) + appendPQExpBuffer(query, " ON COMMIT DROP"); + else if (strcmp(vareoxaction, "r") == 0) + appendPQExpBuffer(query, " ON TRANSACTION END RESET"); + + appendPQExpBuffer(query, ";\n"); + + if (varinfo->dobj.dump & DUMP_COMPONENT_DEFINITION) + ArchiveEntry(fout, varinfo->dobj.catId, varinfo->dobj.dumpId, + ARCHIVE_OPTS(.tag = varinfo->dobj.name, + .namespace = varinfo->dobj.namespace->dobj.name, + .owner = varinfo->rolname, + .description = "VARIABLE", + .section = SECTION_PRE_DATA, + .createStmt = query->data, + .dropStmt = delq->data)); + + /* Dump comment if any */ + if (varinfo->dobj.dump & DUMP_COMPONENT_COMMENT) + dumpComment(fout, "VARIABLE", qualvarname, + NULL, varinfo->rolname, + varinfo->dobj.catId, 0, varinfo->dobj.dumpId); + + /* Dump ACL if any */ + if (varinfo->dobj.dump & DUMP_COMPONENT_ACL) + { + char *qvarname = pg_strdup(fmtId(varinfo->dobj.name)); + + dumpACL(fout, varinfo->dobj.dumpId, InvalidDumpId, "VARIABLE", + qvarname, NULL, + varinfo->dobj.namespace->dobj.name, varinfo->rolname, &varinfo->dacl); + + free(qvarname); + } + + destroyPQExpBuffer(delq); + destroyPQExpBuffer(query); + + free(qualvarname); +} + static void binary_upgrade_set_type_oids_by_type_oid(Archive *fout, PQExpBuffer upgrade_buffer, @@ -9395,7 +9622,8 @@ getAdditionalACLs(Archive *fout) dobj->objType == DO_TABLE || dobj->objType == DO_PROCLANG || dobj->objType == DO_FDW || - dobj->objType == DO_FOREIGN_SERVER) + dobj->objType == DO_FOREIGN_SERVER || + dobj->objType == DO_VARIABLE) { DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj; @@ -9985,6 +10213,9 @@ dumpDumpableObject(Archive *fout, DumpableObject *dobj) case DO_SUBSCRIPTION: dumpSubscription(fout, (const SubscriptionInfo *) dobj); break; + case DO_VARIABLE: + dumpVariable(fout, (VariableInfo *) dobj); + break; case DO_PRE_DATA_BOUNDARY: case DO_POST_DATA_BOUNDARY: /* never dumped, nothing to do */ @@ -14361,6 +14592,9 @@ dumpDefaultACL(Archive *fout, const DefaultACLInfo *daclinfo) case DEFACLOBJ_NAMESPACE: type = "SCHEMAS"; break; + case DEFACLOBJ_VARIABLE: + type = "VARIABLES"; + break; default: /* shouldn't get here */ pg_fatal("unrecognized object type in default privileges: %d", @@ -17902,6 +18136,7 @@ addBoundaryDependencies(DumpableObject **dobjs, int numObjs, case DO_CONVERSION: case DO_TABLE: case DO_TABLE_ATTACH: + case DO_VARIABLE: case DO_ATTRDEF: case DO_PROCLANG: case DO_CAST: diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index 69ee939d44..8d719bd35e 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -52,6 +52,7 @@ typedef enum DO_TABLE, DO_TABLE_ATTACH, DO_ATTRDEF, + DO_VARIABLE, DO_INDEX, DO_INDEX_ATTACH, DO_STATSEXT, @@ -82,7 +83,7 @@ typedef enum DO_PUBLICATION, DO_PUBLICATION_REL, DO_PUBLICATION_TABLE_IN_SCHEMA, - DO_SUBSCRIPTION + DO_SUBSCRIPTION, } DumpableObjectType; /* @@ -664,6 +665,27 @@ typedef struct _SubscriptionInfo char *subpublications; } SubscriptionInfo; +/* + * The VariableInfo struct is used to represent session variables + */ +typedef struct _VariableInfo +{ + DumpableObject dobj; + DumpableAcl dacl; + Oid vartype; + char *vartypname; + char *vareoxaction; + char *vardefexpr; + char *varacl; + char *rvaracl; + char *initvaracl; + char *initrvaracl; + bool varisnotnull; + bool varisimmutable; + Oid varcollation; + const char *rolname; /* name of owner, or empty string */ +} VariableInfo; + /* * common utility functions */ @@ -746,5 +768,6 @@ extern void getPublicationNamespaces(Archive *fout); extern void getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables); extern void getSubscriptions(Archive *fout); +extern void getVariables(Archive *fout); #endif /* PG_DUMP_H */ diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c index 5de3241eb4..1a660b8a9f 100644 --- a/src/bin/pg_dump/pg_dump_sort.c +++ b/src/bin/pg_dump/pg_dump_sort.c @@ -75,6 +75,7 @@ enum dbObjectTypePriorities PRIO_TABLE_ATTACH, PRIO_DUMMY_TYPE, PRIO_ATTRDEF, + PRIO_VARIABLE, PRIO_BLOB, PRIO_PRE_DATA_BOUNDARY, /* boundary! */ PRIO_TABLE_DATA, @@ -116,6 +117,7 @@ static const int dbObjectTypePriority[] = PRIO_TABLE, /* DO_TABLE */ PRIO_TABLE_ATTACH, /* DO_TABLE_ATTACH */ PRIO_ATTRDEF, /* DO_ATTRDEF */ + PRIO_VARIABLE, /* DO_VARIABLE */ PRIO_INDEX, /* DO_INDEX */ PRIO_INDEX_ATTACH, /* DO_INDEX_ATTACH */ PRIO_STATSEXT, /* DO_STATSEXT */ @@ -1508,6 +1510,10 @@ describeDumpableObject(DumpableObject *obj, char *buf, int bufsize) "POST-DATA BOUNDARY (ID %d)", obj->dumpId); return; + case DO_VARIABLE: + snprintf(buf, bufsize, + "VARIABLE %s (ID %d OID %u)", + obj->name, obj->dumpId, obj->catId.oid); } /* shouldn't get here */ snprintf(buf, bufsize, diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c index 049a100634..830cde5421 100644 --- a/src/bin/pg_dump/pg_restore.c +++ b/src/bin/pg_dump/pg_restore.c @@ -103,6 +103,7 @@ main(int argc, char **argv) {"trigger", 1, NULL, 'T'}, {"use-list", 1, NULL, 'L'}, {"username", 1, NULL, 'U'}, + {"variable", 1, NULL, 'A'}, {"verbose", 0, NULL, 'v'}, {"single-transaction", 0, NULL, '1'}, @@ -151,7 +152,7 @@ main(int argc, char **argv) } } - while ((c = getopt_long(argc, argv, "acCd:ef:F:h:I:j:lL:n:N:Op:P:RsS:t:T:U:vwWx1", + while ((c = getopt_long(argc, argv, "A:acCd:ef:F:h:I:j:lL:n:N:Op:P:RsS:t:T:U:vwWx1", cmdopts, NULL)) != -1) { switch (c) @@ -159,6 +160,11 @@ main(int argc, char **argv) case 'a': /* Dump data only */ opts->dataOnly = 1; break; + case 'A': /* vAriable */ + opts->selTypes = 1; + opts->selVariable = 1; + simple_string_list_append(&opts->variableNames, optarg); + break; case 'c': /* clean (i.e., drop) schema prior to create */ opts->dropSchema = 1; break; @@ -444,6 +450,7 @@ usage(const char *progname) printf(_("\nOptions controlling the restore:\n")); printf(_(" -a, --data-only restore only the data, no schema\n")); + printf(_(" -A, --variable=NAME restore named session variable\n")); printf(_(" -c, --clean clean (drop) database objects before recreating\n")); printf(_(" -C, --create create the target database\n")); printf(_(" -e, --exit-on-error exit on error, default is to continue\n")); diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index 2873b662fb..747308c894 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -572,6 +572,16 @@ my %tests = ( unlike => { no_privs => 1, }, }, + 'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role GRANT SELECT ON VARIABLES TO PUBLIC' + => { + create_order => 56, + create_sql => 'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role GRANT SELECT ON VARIABLES TO PUBLIC;', + regexp => qr/^ + \QALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role GRANT SELECT ON VARIABLES TO PUBLIC;\E/xm, + like => { %full_runs, section_post_data => 1, }, + unlike => { no_privs => 1, }, + }, + 'ALTER ROLE regress_dump_test_role' => { regexp => qr/^ \QALTER ROLE regress_dump_test_role WITH \E @@ -1327,6 +1337,22 @@ my %tests = ( unlike => { exclude_dump_test_schema => 1, }, }, + 'COMMENT ON VARIABLE dump_test.variable1' => { + create_order => 71, + create_sql => 'COMMENT ON VARIABLE dump_test.variable1 + IS \'comment on variable\';', + regexp => + qr/^\QCOMMENT ON VARIABLE dump_test.variable1 IS 'comment on variable';\E/m, + like => { + %full_runs, + %dump_test_schema_runs, + section_pre_data => 1, + }, + unlike => { + exclude_dump_test_schema => 1, + }, + }, + 'COPY test_table' => { create_order => 4, create_sql => 'INSERT INTO dump_test.test_table (col1) ' @@ -3263,6 +3289,30 @@ my %tests = ( }, }, + 'CREATE VARIABLE test_variable' => { + all_runs => 1, + catch_all => 'CREATE ... commands', + create_order => 61, + create_sql => 'CREATE VARIABLE dump_test.variable1 AS integer DEFAULT 0;', + regexp => qr/^ + \QCREATE VARIABLE dump_test.variable1 AS integer DEFAULT 0;\E/xm, + like => + { %full_runs, %dump_test_schema_runs, section_pre_data => 1, }, + unlike => { exclude_dump_test_schema => 1, }, + }, + + 'CREATE IMMUTABLE VARIABLE test_variable' => { + all_runs => 1, + catch_all => 'CREATE ... commands', + create_order => 61, + create_sql => 'CREATE IMMUTABLE VARIABLE dump_test.variable2 AS integer DEFAULT 0;', + regexp => qr/^ + \QCREATE IMMUTABLE VARIABLE dump_test.variable2 AS integer DEFAULT 0;\E/xm, + like => + { %full_runs, %dump_test_schema_runs, section_pre_data => 1, }, + unlike => { exclude_dump_test_schema => 1, }, + }, + 'CREATE VIEW test_view' => { create_order => 61, create_sql => 'CREATE VIEW dump_test.test_view @@ -3702,6 +3752,21 @@ my %tests = ( like => {}, }, + 'GRANT SELECT ON VARIABLE dump_test.variable1' => { + create_order => 73, + create_sql => + 'GRANT SELECT ON VARIABLE dump_test.variable1 TO regress_dump_test_role;', + regexp => qr/^ + \QGRANT SELECT ON VARIABLE dump_test.variable1 TO regress_dump_test_role;\E + /xm, + like => + { %full_runs, %dump_test_schema_runs, section_pre_data => 1, }, + unlike => { + exclude_dump_test_schema => 1, + no_privs => 1, + }, + }, + 'REFRESH MATERIALIZED VIEW matview' => { regexp => qr/^\QREFRESH MATERIALIZED VIEW dump_test.matview;\E/m, like => -- 2.37.2 --gcms4zhgklsgym3k Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v20220906-1-0008-typedefs.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v20220922 09/13] possibility to dump session variables by pg_dump @ 2022-04-04 18:49 [email protected] <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: [email protected] @ 2022-04-04 18:49 UTC (permalink / raw) Enhancing pg_dump about session variables support --- src/bin/pg_dump/common.c | 3 +- src/bin/pg_dump/dumputils.c | 6 + src/bin/pg_dump/pg_backup.h | 2 + src/bin/pg_dump/pg_backup_archiver.c | 12 +- src/bin/pg_dump/pg_dump.c | 237 ++++++++++++++++++++++++++- src/bin/pg_dump/pg_dump.h | 25 ++- src/bin/pg_dump/pg_dump_sort.c | 6 + src/bin/pg_dump/pg_restore.c | 9 +- src/bin/pg_dump/t/002_pg_dump.pl | 65 ++++++++ src/tools/pgindent/typedefs.list | 1 + 10 files changed, 361 insertions(+), 5 deletions(-) diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 395f817fa8..6f10488c34 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -263,7 +263,8 @@ getSchemaData(Archive *fout, int *numTablesPtr) pg_log_info("reading subscriptions"); getSubscriptions(fout); - free(inhinfo); /* not needed any longer */ + pg_log_info("reading variables"); + getVariables(fout); *numTablesPtr = numTables; return tblinfo; diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c index 6e501a5413..dc1f0e1ba8 100644 --- a/src/bin/pg_dump/dumputils.c +++ b/src/bin/pg_dump/dumputils.c @@ -504,6 +504,12 @@ do { \ CONVERT_PRIV('r', "SELECT"); CONVERT_PRIV('w', "UPDATE"); } + else if (strcmp(type, "VARIABLE") == 0 || + strcmp(type, "VARIABLES") == 0) + { + CONVERT_PRIV('r', "SELECT"); + CONVERT_PRIV('w', "UPDATE"); + } else abort(); diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h index fcc5f6bd05..9d675d669c 100644 --- a/src/bin/pg_dump/pg_backup.h +++ b/src/bin/pg_dump/pg_backup.h @@ -131,12 +131,14 @@ typedef struct _restoreOptions int selFunction; int selTrigger; int selTable; + int selVariable; SimpleStringList indexNames; SimpleStringList functionNames; SimpleStringList schemaNames; SimpleStringList schemaExcludeNames; SimpleStringList triggerNames; SimpleStringList tableNames; + SimpleStringList variableNames; int useDB; ConnParams cparams; /* parameters to use if useDB */ diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 233198afc0..8d47869ba8 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -2934,6 +2934,14 @@ _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH) !simple_string_list_member(&ropt->triggerNames, te->tag)) return 0; } + else if (strcmp(te->desc, "VARIABLE") == 0) + { + if (!ropt->selVariable) + return 0; + if (ropt->variableNames.head != NULL && + !simple_string_list_member(&ropt->variableNames, te->tag)) + return 0; + } else return 0; } @@ -3419,6 +3427,7 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te) strcmp(type, "TEXT SEARCH DICTIONARY") == 0 || strcmp(type, "TEXT SEARCH CONFIGURATION") == 0 || strcmp(type, "STATISTICS") == 0 || + strcmp(type, "VARIABLE") == 0 || /* non-schema-specified objects */ strcmp(type, "DATABASE") == 0 || strcmp(type, "PROCEDURAL LANGUAGE") == 0 || @@ -3611,7 +3620,8 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData) strcmp(te->desc, "SERVER") == 0 || strcmp(te->desc, "STATISTICS") == 0 || strcmp(te->desc, "PUBLICATION") == 0 || - strcmp(te->desc, "SUBSCRIPTION") == 0) + strcmp(te->desc, "SUBSCRIPTION") == 0 || + strcmp(te->desc, "VARIABLE") == 0) { PQExpBuffer temp = createPQExpBuffer(); diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 67b6d9079e..813f3f5c7c 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -287,6 +287,7 @@ static void dumpPolicy(Archive *fout, const PolicyInfo *polinfo); static void dumpPublication(Archive *fout, const PublicationInfo *pubinfo); static void dumpPublicationTable(Archive *fout, const PublicationRelInfo *pubrinfo); static void dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo); +static void dumpVariable(Archive *fout, const VariableInfo * varinfo); static void dumpDatabase(Archive *AH); static void dumpDatabaseConfig(Archive *AH, PQExpBuffer outbuf, const char *dbname, Oid dboid); @@ -4741,6 +4742,232 @@ get_next_possible_free_pg_type_oid(Archive *fout, PQExpBuffer upgrade_query) return next_possible_free_oid; } +/* + * getVariables + * get information about variables + */ +void +getVariables(Archive *fout) +{ + PQExpBuffer query; + PGresult *res; + VariableInfo *varinfo; + int i_tableoid; + int i_oid; + int i_varname; + int i_varnamespace; + int i_vartype; + int i_vartypname; + int i_vardefexpr; + int i_vareoxaction; + int i_varisnotnull; + int i_varisimmutable; + int i_varowner; + int i_varcollation; + int i_varacl; + int i_acldefault; + int i, + ntups; + + if (fout->remoteVersion < 160000) + return; + + query = createPQExpBuffer(); + + resetPQExpBuffer(query); + + /* Get the variables in current database. */ + appendPQExpBuffer(query, + "SELECT v.tableoid, v.oid, v.varname,\n" + "v.vareoxaction,\n" + "v.varnamespace,\n" + "v.vartype,\n" + "pg_catalog.format_type(v.vartype, v.vartypmod) as vartypname,\n" + "v.varisnotnull,\n" + "v.varisimmutable,\n" + "CASE WHEN v.varcollation <> t.typcollation " + "THEN v.varcollation ELSE 0 END AS varcollation,\n" + "pg_catalog.pg_get_expr(v.vardefexpr,0) as vardefexpr,\n" + "v.varowner,\n" + "v.varacl,\n" + "acldefault('V', v.varowner) AS acldefault\n" + "FROM pg_catalog.pg_variable v\n" + "JOIN pg_catalog.pg_type t " + "ON (v.vartype = t.oid)"); + + res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); + + ntups = PQntuples(res); + + i_tableoid = PQfnumber(res, "tableoid"); + i_oid = PQfnumber(res, "oid"); + i_varname = PQfnumber(res, "varname"); + i_varnamespace = PQfnumber(res, "varnamespace"); + i_vartype = PQfnumber(res, "vartype"); + i_vartypname = PQfnumber(res, "vartypname"); + i_vareoxaction = PQfnumber(res, "vareoxaction"); + i_vardefexpr = PQfnumber(res, "vardefexpr"); + i_varisnotnull = PQfnumber(res, "varisnotnull"); + i_varisimmutable = PQfnumber(res, "varisimmutable"); + i_varcollation = PQfnumber(res, "varcollation"); + + i_varowner = PQfnumber(res, "varowner"); + i_varacl = PQfnumber(res, "varacl"); + i_acldefault = PQfnumber(res, "acldefault"); + + varinfo = pg_malloc(ntups * sizeof(VariableInfo)); + + for (i = 0; i < ntups; i++) + { + TypeInfo *vtype; + + varinfo[i].dobj.objType = DO_VARIABLE; + varinfo[i].dobj.catId.tableoid = + atooid(PQgetvalue(res, i, i_tableoid)); + varinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); + AssignDumpId(&varinfo[i].dobj); + varinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_varname)); + varinfo[i].dobj.namespace = + findNamespace(atooid(PQgetvalue(res, i, i_varnamespace))); + + varinfo[i].vartype = atooid(PQgetvalue(res, i, i_vartype)); + varinfo[i].vartypname = pg_strdup(PQgetvalue(res, i, i_vartypname)); + varinfo[i].vareoxaction = pg_strdup(PQgetvalue(res, i, i_vareoxaction)); + varinfo[i].varisnotnull = *(PQgetvalue(res, i, i_varisnotnull)) == 't'; + varinfo[i].varisimmutable = *(PQgetvalue(res, i, i_varisimmutable)) == 't'; + varinfo[i].varcollation = atooid(PQgetvalue(res, i, i_varcollation)); + + varinfo[i].dacl.acl = pg_strdup(PQgetvalue(res, i, i_varacl)); + varinfo[i].dacl.acldefault = pg_strdup(PQgetvalue(res, i, i_acldefault)); + varinfo[i].dacl.privtype = 0; + varinfo[i].dacl.initprivs = NULL; + varinfo[i].rolname = getRoleName(PQgetvalue(res, i, i_varowner)); + + /* Decide whether we want to dump it */ + selectDumpableObject(&(varinfo[i].dobj), fout); + + /* Do not try to dump ACL if no ACL exists. */ + if (!PQgetisnull(res, i, i_varacl)) + varinfo[i].dobj.components |= DUMP_COMPONENT_ACL; + + if (PQgetisnull(res, i, i_vardefexpr)) + varinfo[i].vardefexpr = NULL; + else + varinfo[i].vardefexpr = pg_strdup(PQgetvalue(res, i, i_vardefexpr)); + + if (strlen(varinfo[i].rolname) == 0) + pg_log_warning("owner of variable \"%s\" appears to be invalid", + varinfo[i].dobj.name); + + /* Decide whether we want to dump it */ + selectDumpableObject(&(varinfo[i].dobj), fout); + + vtype = findTypeByOid(varinfo[i].vartype); + addObjectDependency(&varinfo[i].dobj, vtype->dobj.dumpId); + } + PQclear(res); + + destroyPQExpBuffer(query); +} + +/* + * dumpVariable + * dump the definition of the given variables + */ +static void +dumpVariable(Archive *fout, const VariableInfo *varinfo) +{ + DumpOptions *dopt = fout->dopt; + + PQExpBuffer delq; + PQExpBuffer query; + char *qualvarname; + const char *vartypname; + const char *vardefexpr; + const char *vareoxaction; + const char *varisimmutable; + Oid varcollation; + bool varisnotnull; + + /* Skip if not to be dumped */ + if (!varinfo->dobj.dump || dopt->dataOnly) + return; + + delq = createPQExpBuffer(); + query = createPQExpBuffer(); + + qualvarname = pg_strdup(fmtQualifiedDumpable(varinfo)); + vartypname = varinfo->vartypname; + vardefexpr = varinfo->vardefexpr; + vareoxaction = varinfo->vareoxaction; + varisnotnull = varinfo->varisnotnull; + varisimmutable = varinfo->varisimmutable ? "IMMUTABLE " : ""; + varcollation = varinfo->varcollation; + + appendPQExpBuffer(delq, "DROP VARIABLE %s;\n", + qualvarname); + + appendPQExpBuffer(query, "CREATE %sVARIABLE %s AS %s", + varisimmutable, qualvarname, vartypname); + + if (OidIsValid(varcollation)) + { + CollInfo *coll; + + coll = findCollationByOid(varcollation); + if (coll) + appendPQExpBuffer(query, " COLLATE %s", + fmtQualifiedDumpable(coll)); + } + + if (varisnotnull) + appendPQExpBuffer(query, " NOT NULL"); + + if (vardefexpr) + appendPQExpBuffer(query, " DEFAULT %s", + vardefexpr); + + if (strcmp(vareoxaction, "d") == 0) + appendPQExpBuffer(query, " ON COMMIT DROP"); + else if (strcmp(vareoxaction, "r") == 0) + appendPQExpBuffer(query, " ON TRANSACTION END RESET"); + + appendPQExpBuffer(query, ";\n"); + + if (varinfo->dobj.dump & DUMP_COMPONENT_DEFINITION) + ArchiveEntry(fout, varinfo->dobj.catId, varinfo->dobj.dumpId, + ARCHIVE_OPTS(.tag = varinfo->dobj.name, + .namespace = varinfo->dobj.namespace->dobj.name, + .owner = varinfo->rolname, + .description = "VARIABLE", + .section = SECTION_PRE_DATA, + .createStmt = query->data, + .dropStmt = delq->data)); + + /* Dump comment if any */ + if (varinfo->dobj.dump & DUMP_COMPONENT_COMMENT) + dumpComment(fout, "VARIABLE", qualvarname, + NULL, varinfo->rolname, + varinfo->dobj.catId, 0, varinfo->dobj.dumpId); + + /* Dump ACL if any */ + if (varinfo->dobj.dump & DUMP_COMPONENT_ACL) + { + char *qvarname = pg_strdup(fmtId(varinfo->dobj.name)); + + dumpACL(fout, varinfo->dobj.dumpId, InvalidDumpId, "VARIABLE", + qvarname, NULL, + varinfo->dobj.namespace->dobj.name, varinfo->rolname, &varinfo->dacl); + + free(qvarname); + } + + destroyPQExpBuffer(delq); + destroyPQExpBuffer(query); + + free(qualvarname); +} + static void binary_upgrade_set_type_oids_by_type_oid(Archive *fout, PQExpBuffer upgrade_buffer, @@ -9395,7 +9622,8 @@ getAdditionalACLs(Archive *fout) dobj->objType == DO_TABLE || dobj->objType == DO_PROCLANG || dobj->objType == DO_FDW || - dobj->objType == DO_FOREIGN_SERVER) + dobj->objType == DO_FOREIGN_SERVER || + dobj->objType == DO_VARIABLE) { DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj; @@ -9985,6 +10213,9 @@ dumpDumpableObject(Archive *fout, DumpableObject *dobj) case DO_SUBSCRIPTION: dumpSubscription(fout, (const SubscriptionInfo *) dobj); break; + case DO_VARIABLE: + dumpVariable(fout, (VariableInfo *) dobj); + break; case DO_PRE_DATA_BOUNDARY: case DO_POST_DATA_BOUNDARY: /* never dumped, nothing to do */ @@ -14361,6 +14592,9 @@ dumpDefaultACL(Archive *fout, const DefaultACLInfo *daclinfo) case DEFACLOBJ_NAMESPACE: type = "SCHEMAS"; break; + case DEFACLOBJ_VARIABLE: + type = "VARIABLES"; + break; default: /* shouldn't get here */ pg_fatal("unrecognized object type in default privileges: %d", @@ -17902,6 +18136,7 @@ addBoundaryDependencies(DumpableObject **dobjs, int numObjs, case DO_CONVERSION: case DO_TABLE: case DO_TABLE_ATTACH: + case DO_VARIABLE: case DO_ATTRDEF: case DO_PROCLANG: case DO_CAST: diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index 69ee939d44..5c6acf84f6 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -52,6 +52,7 @@ typedef enum DO_TABLE, DO_TABLE_ATTACH, DO_ATTRDEF, + DO_VARIABLE, DO_INDEX, DO_INDEX_ATTACH, DO_STATSEXT, @@ -82,7 +83,7 @@ typedef enum DO_PUBLICATION, DO_PUBLICATION_REL, DO_PUBLICATION_TABLE_IN_SCHEMA, - DO_SUBSCRIPTION + DO_SUBSCRIPTION, } DumpableObjectType; /* @@ -664,6 +665,27 @@ typedef struct _SubscriptionInfo char *subpublications; } SubscriptionInfo; +/* + * The VariableInfo struct is used to represent session variables + */ +typedef struct _VariableInfo +{ + DumpableObject dobj; + DumpableAcl dacl; + Oid vartype; + char *vartypname; + char *vareoxaction; + char *vardefexpr; + char *varacl; + char *rvaracl; + char *initvaracl; + char *initrvaracl; + bool varisnotnull; + bool varisimmutable; + Oid varcollation; + const char *rolname; /* name of owner, or empty string */ +} VariableInfo; + /* * common utility functions */ @@ -746,5 +768,6 @@ extern void getPublicationNamespaces(Archive *fout); extern void getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables); extern void getSubscriptions(Archive *fout); +extern void getVariables(Archive *fout); #endif /* PG_DUMP_H */ diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c index 5de3241eb4..1a660b8a9f 100644 --- a/src/bin/pg_dump/pg_dump_sort.c +++ b/src/bin/pg_dump/pg_dump_sort.c @@ -75,6 +75,7 @@ enum dbObjectTypePriorities PRIO_TABLE_ATTACH, PRIO_DUMMY_TYPE, PRIO_ATTRDEF, + PRIO_VARIABLE, PRIO_BLOB, PRIO_PRE_DATA_BOUNDARY, /* boundary! */ PRIO_TABLE_DATA, @@ -116,6 +117,7 @@ static const int dbObjectTypePriority[] = PRIO_TABLE, /* DO_TABLE */ PRIO_TABLE_ATTACH, /* DO_TABLE_ATTACH */ PRIO_ATTRDEF, /* DO_ATTRDEF */ + PRIO_VARIABLE, /* DO_VARIABLE */ PRIO_INDEX, /* DO_INDEX */ PRIO_INDEX_ATTACH, /* DO_INDEX_ATTACH */ PRIO_STATSEXT, /* DO_STATSEXT */ @@ -1508,6 +1510,10 @@ describeDumpableObject(DumpableObject *obj, char *buf, int bufsize) "POST-DATA BOUNDARY (ID %d)", obj->dumpId); return; + case DO_VARIABLE: + snprintf(buf, bufsize, + "VARIABLE %s (ID %d OID %u)", + obj->name, obj->dumpId, obj->catId.oid); } /* shouldn't get here */ snprintf(buf, bufsize, diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c index 049a100634..830cde5421 100644 --- a/src/bin/pg_dump/pg_restore.c +++ b/src/bin/pg_dump/pg_restore.c @@ -103,6 +103,7 @@ main(int argc, char **argv) {"trigger", 1, NULL, 'T'}, {"use-list", 1, NULL, 'L'}, {"username", 1, NULL, 'U'}, + {"variable", 1, NULL, 'A'}, {"verbose", 0, NULL, 'v'}, {"single-transaction", 0, NULL, '1'}, @@ -151,7 +152,7 @@ main(int argc, char **argv) } } - while ((c = getopt_long(argc, argv, "acCd:ef:F:h:I:j:lL:n:N:Op:P:RsS:t:T:U:vwWx1", + while ((c = getopt_long(argc, argv, "A:acCd:ef:F:h:I:j:lL:n:N:Op:P:RsS:t:T:U:vwWx1", cmdopts, NULL)) != -1) { switch (c) @@ -159,6 +160,11 @@ main(int argc, char **argv) case 'a': /* Dump data only */ opts->dataOnly = 1; break; + case 'A': /* vAriable */ + opts->selTypes = 1; + opts->selVariable = 1; + simple_string_list_append(&opts->variableNames, optarg); + break; case 'c': /* clean (i.e., drop) schema prior to create */ opts->dropSchema = 1; break; @@ -444,6 +450,7 @@ usage(const char *progname) printf(_("\nOptions controlling the restore:\n")); printf(_(" -a, --data-only restore only the data, no schema\n")); + printf(_(" -A, --variable=NAME restore named session variable\n")); printf(_(" -c, --clean clean (drop) database objects before recreating\n")); printf(_(" -C, --create create the target database\n")); printf(_(" -e, --exit-on-error exit on error, default is to continue\n")); diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index 2873b662fb..747308c894 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -572,6 +572,16 @@ my %tests = ( unlike => { no_privs => 1, }, }, + 'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role GRANT SELECT ON VARIABLES TO PUBLIC' + => { + create_order => 56, + create_sql => 'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role GRANT SELECT ON VARIABLES TO PUBLIC;', + regexp => qr/^ + \QALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role GRANT SELECT ON VARIABLES TO PUBLIC;\E/xm, + like => { %full_runs, section_post_data => 1, }, + unlike => { no_privs => 1, }, + }, + 'ALTER ROLE regress_dump_test_role' => { regexp => qr/^ \QALTER ROLE regress_dump_test_role WITH \E @@ -1327,6 +1337,22 @@ my %tests = ( unlike => { exclude_dump_test_schema => 1, }, }, + 'COMMENT ON VARIABLE dump_test.variable1' => { + create_order => 71, + create_sql => 'COMMENT ON VARIABLE dump_test.variable1 + IS \'comment on variable\';', + regexp => + qr/^\QCOMMENT ON VARIABLE dump_test.variable1 IS 'comment on variable';\E/m, + like => { + %full_runs, + %dump_test_schema_runs, + section_pre_data => 1, + }, + unlike => { + exclude_dump_test_schema => 1, + }, + }, + 'COPY test_table' => { create_order => 4, create_sql => 'INSERT INTO dump_test.test_table (col1) ' @@ -3263,6 +3289,30 @@ my %tests = ( }, }, + 'CREATE VARIABLE test_variable' => { + all_runs => 1, + catch_all => 'CREATE ... commands', + create_order => 61, + create_sql => 'CREATE VARIABLE dump_test.variable1 AS integer DEFAULT 0;', + regexp => qr/^ + \QCREATE VARIABLE dump_test.variable1 AS integer DEFAULT 0;\E/xm, + like => + { %full_runs, %dump_test_schema_runs, section_pre_data => 1, }, + unlike => { exclude_dump_test_schema => 1, }, + }, + + 'CREATE IMMUTABLE VARIABLE test_variable' => { + all_runs => 1, + catch_all => 'CREATE ... commands', + create_order => 61, + create_sql => 'CREATE IMMUTABLE VARIABLE dump_test.variable2 AS integer DEFAULT 0;', + regexp => qr/^ + \QCREATE IMMUTABLE VARIABLE dump_test.variable2 AS integer DEFAULT 0;\E/xm, + like => + { %full_runs, %dump_test_schema_runs, section_pre_data => 1, }, + unlike => { exclude_dump_test_schema => 1, }, + }, + 'CREATE VIEW test_view' => { create_order => 61, create_sql => 'CREATE VIEW dump_test.test_view @@ -3702,6 +3752,21 @@ my %tests = ( like => {}, }, + 'GRANT SELECT ON VARIABLE dump_test.variable1' => { + create_order => 73, + create_sql => + 'GRANT SELECT ON VARIABLE dump_test.variable1 TO regress_dump_test_role;', + regexp => qr/^ + \QGRANT SELECT ON VARIABLE dump_test.variable1 TO regress_dump_test_role;\E + /xm, + like => + { %full_runs, %dump_test_schema_runs, section_pre_data => 1, }, + unlike => { + exclude_dump_test_schema => 1, + no_privs => 1, + }, + }, + 'REFRESH MATERIALIZED VIEW matview' => { regexp => qr/^\QREFRESH MATERIALIZED VIEW dump_test.matview;\E/m, like => diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list index 522986a730..8b7e281bcf 100644 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@ -2913,6 +2913,7 @@ Variable VariableAssignHook VariableCache VariableCacheData +VariableInfo VariableSetKind VariableSetStmt VariableShowStmt -- 2.37.0 --z3ntqfnlkpftg4xg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v20220922-0010-regress-tests-for-session-variables.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH 07/11] possibility to dump session variables by pg_dump @ 2022-04-04 18:49 [email protected] <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: [email protected] @ 2022-04-04 18:49 UTC (permalink / raw) Enhancing pg_dump about session variables support --- src/bin/pg_dump/common.c | 3 +- src/bin/pg_dump/dumputils.c | 6 + src/bin/pg_dump/pg_backup.h | 2 + src/bin/pg_dump/pg_backup_archiver.c | 12 +- src/bin/pg_dump/pg_dump.c | 237 ++++++++++++++++++++++++++- src/bin/pg_dump/pg_dump.h | 25 ++- src/bin/pg_dump/pg_dump_sort.c | 6 + src/bin/pg_dump/pg_restore.c | 9 +- src/bin/pg_dump/t/002_pg_dump.pl | 65 ++++++++ 9 files changed, 360 insertions(+), 5 deletions(-) diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 794e6e7ce9..97270e0b06 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -263,7 +263,8 @@ getSchemaData(Archive *fout, int *numTablesPtr) pg_log_info("reading subscriptions"); getSubscriptions(fout); - free(inhinfo); /* not needed any longer */ + pg_log_info("reading variables"); + getVariables(fout); *numTablesPtr = numTables; return tblinfo; diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c index 6e501a5413..dc1f0e1ba8 100644 --- a/src/bin/pg_dump/dumputils.c +++ b/src/bin/pg_dump/dumputils.c @@ -504,6 +504,12 @@ do { \ CONVERT_PRIV('r', "SELECT"); CONVERT_PRIV('w', "UPDATE"); } + else if (strcmp(type, "VARIABLE") == 0 || + strcmp(type, "VARIABLES") == 0) + { + CONVERT_PRIV('r', "SELECT"); + CONVERT_PRIV('w', "UPDATE"); + } else abort(); diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h index fcc5f6bd05..9d675d669c 100644 --- a/src/bin/pg_dump/pg_backup.h +++ b/src/bin/pg_dump/pg_backup.h @@ -131,12 +131,14 @@ typedef struct _restoreOptions int selFunction; int selTrigger; int selTable; + int selVariable; SimpleStringList indexNames; SimpleStringList functionNames; SimpleStringList schemaNames; SimpleStringList schemaExcludeNames; SimpleStringList triggerNames; SimpleStringList tableNames; + SimpleStringList variableNames; int useDB; ConnParams cparams; /* parameters to use if useDB */ diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 233198afc0..8d47869ba8 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -2934,6 +2934,14 @@ _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH) !simple_string_list_member(&ropt->triggerNames, te->tag)) return 0; } + else if (strcmp(te->desc, "VARIABLE") == 0) + { + if (!ropt->selVariable) + return 0; + if (ropt->variableNames.head != NULL && + !simple_string_list_member(&ropt->variableNames, te->tag)) + return 0; + } else return 0; } @@ -3419,6 +3427,7 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te) strcmp(type, "TEXT SEARCH DICTIONARY") == 0 || strcmp(type, "TEXT SEARCH CONFIGURATION") == 0 || strcmp(type, "STATISTICS") == 0 || + strcmp(type, "VARIABLE") == 0 || /* non-schema-specified objects */ strcmp(type, "DATABASE") == 0 || strcmp(type, "PROCEDURAL LANGUAGE") == 0 || @@ -3611,7 +3620,8 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData) strcmp(te->desc, "SERVER") == 0 || strcmp(te->desc, "STATISTICS") == 0 || strcmp(te->desc, "PUBLICATION") == 0 || - strcmp(te->desc, "SUBSCRIPTION") == 0) + strcmp(te->desc, "SUBSCRIPTION") == 0 || + strcmp(te->desc, "VARIABLE") == 0) { PQExpBuffer temp = createPQExpBuffer(); diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 67b6d9079e..a60cf1aa87 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -287,6 +287,7 @@ static void dumpPolicy(Archive *fout, const PolicyInfo *polinfo); static void dumpPublication(Archive *fout, const PublicationInfo *pubinfo); static void dumpPublicationTable(Archive *fout, const PublicationRelInfo *pubrinfo); static void dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo); +static void dumpVariable(Archive *fout, const VariableInfo * varinfo); static void dumpDatabase(Archive *AH); static void dumpDatabaseConfig(Archive *AH, PQExpBuffer outbuf, const char *dbname, Oid dboid); @@ -4741,6 +4742,232 @@ get_next_possible_free_pg_type_oid(Archive *fout, PQExpBuffer upgrade_query) return next_possible_free_oid; } +/* + * getVariables + * get information about variables + */ +void +getVariables(Archive *fout) +{ + PQExpBuffer query; + PGresult *res; + VariableInfo *varinfo; + int i_tableoid; + int i_oid; + int i_varname; + int i_varnamespace; + int i_vartype; + int i_vartypname; + int i_vardefexpr; + int i_vareoxaction; + int i_varisnotnull; + int i_varisimmutable; + int i_varowner; + int i_varcollation; + int i_varacl; + int i_acldefault; + int i, + ntups; + + if (fout->remoteVersion < 160000) + return; + + query = createPQExpBuffer(); + + resetPQExpBuffer(query); + + /* Get the variables in current database. */ + appendPQExpBuffer(query, + "SELECT v.tableoid, v.oid, v.varname,\n" + "v.vareoxaction,\n" + "v.varnamespace,\n" + "v.vartype,\n" + "pg_catalog.format_type(v.vartype, v.vartypmod) as vartypname,\n" + "v.varisnotnull,\n" + "v.varisimmutable,\n" + "CASE WHEN v.varcollation <> t.typcollation " + "THEN v.varcollation ELSE 0 END AS varcollation,\n" + "pg_catalog.pg_get_expr(v.vardefexpr,0) as vardefexpr,\n" + "v.varowner,\n" + "v.varacl,\n" + "acldefault('V', v.varowner) AS acldefault\n" + "FROM pg_catalog.pg_variable v\n" + "JOIN pg_catalog.pg_type t " + "ON (v.vartype = t.oid)"); + + res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); + + ntups = PQntuples(res); + + i_tableoid = PQfnumber(res, "tableoid"); + i_oid = PQfnumber(res, "oid"); + i_varname = PQfnumber(res, "varname"); + i_varnamespace = PQfnumber(res, "varnamespace"); + i_vartype = PQfnumber(res, "vartype"); + i_vartypname = PQfnumber(res, "vartypname"); + i_vareoxaction = PQfnumber(res, "vareoxaction"); + i_vardefexpr = PQfnumber(res, "vardefexpr"); + i_varisnotnull = PQfnumber(res, "varisnotnull"); + i_varisimmutable = PQfnumber(res, "varisimmutable"); + i_varcollation = PQfnumber(res, "varcollation"); + + i_varowner = PQfnumber(res, "varowner"); + i_varacl = PQfnumber(res, "varacl"); + i_acldefault = PQfnumber(res, "acldefault"); + + varinfo = pg_malloc(ntups * sizeof(VariableInfo)); + + for (i = 0; i < ntups; i++) + { + TypeInfo *vtype; + + varinfo[i].dobj.objType = DO_VARIABLE; + varinfo[i].dobj.catId.tableoid = + atooid(PQgetvalue(res, i, i_tableoid)); + varinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); + AssignDumpId(&varinfo[i].dobj); + varinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_varname)); + varinfo[i].dobj.namespace = + findNamespace(atooid(PQgetvalue(res, i, i_varnamespace))); + + varinfo[i].vartype = atooid(PQgetvalue(res, i, i_vartype)); + varinfo[i].vartypname = pg_strdup(PQgetvalue(res, i, i_vartypname)); + varinfo[i].vareoxaction = pg_strdup(PQgetvalue(res, i, i_vareoxaction)); + varinfo[i].varisnotnull = *(PQgetvalue(res, i, i_varisnotnull)) == 't'; + varinfo[i].varisimmutable = *(PQgetvalue(res, i, i_varisimmutable)) == 't'; + varinfo[i].varcollation = atooid(PQgetvalue(res, i, i_varcollation)); + + varinfo[i].dacl.acl = pg_strdup(PQgetvalue(res, i, i_varacl)); + varinfo[i].dacl.acldefault = pg_strdup(PQgetvalue(res, i, i_acldefault)); + varinfo[i].dacl.privtype = 0; + varinfo[i].dacl.initprivs = NULL; + varinfo[i].rolname = getRoleName(PQgetvalue(res, i, i_varowner)); + + /* Decide whether we want to dump it */ + selectDumpableObject(&(varinfo[i].dobj), fout); + + /* Do not try to dump ACL if no ACL exists. */ + if (!PQgetisnull(res, i, i_varacl)) + varinfo[i].dobj.components |= DUMP_COMPONENT_ACL; + + if (PQgetisnull(res, i, i_vardefexpr)) + varinfo[i].vardefexpr = NULL; + else + varinfo[i].vardefexpr = pg_strdup(PQgetvalue(res, i, i_vardefexpr)); + + if (strlen(varinfo[i].rolname) == 0) + pg_log_warning("owner of variable \"%s\" appears to be invalid", + varinfo[i].dobj.name); + + /* Decide whether we want to dump it */ + selectDumpableObject(&(varinfo[i].dobj), fout); + + vtype = findTypeByOid(varinfo[i].vartype); + addObjectDependency(&varinfo[i].dobj, vtype->dobj.dumpId); + } + PQclear(res); + + destroyPQExpBuffer(query); +} + +/* + * dumpVariable + * dump the definition of the given variables + */ +static void +dumpVariable(Archive *fout, const VariableInfo * varinfo) +{ + DumpOptions *dopt = fout->dopt; + + PQExpBuffer delq; + PQExpBuffer query; + char *qualvarname; + const char *vartypname; + const char *vardefexpr; + const char *vareoxaction; + const char *varisimmutable; + Oid varcollation; + bool varisnotnull; + + /* Skip if not to be dumped */ + if (!varinfo->dobj.dump || dopt->dataOnly) + return; + + delq = createPQExpBuffer(); + query = createPQExpBuffer(); + + qualvarname = pg_strdup(fmtQualifiedDumpable(varinfo)); + vartypname = varinfo->vartypname; + vardefexpr = varinfo->vardefexpr; + vareoxaction = varinfo->vareoxaction; + varisnotnull = varinfo->varisnotnull; + varisimmutable = varinfo->varisimmutable ? "IMMUTABLE " : ""; + varcollation = varinfo->varcollation; + + appendPQExpBuffer(delq, "DROP VARIABLE %s;\n", + qualvarname); + + appendPQExpBuffer(query, "CREATE %sVARIABLE %s AS %s", + varisimmutable, qualvarname, vartypname); + + if (OidIsValid(varcollation)) + { + CollInfo *coll; + + coll = findCollationByOid(varcollation); + if (coll) + appendPQExpBuffer(query, " COLLATE %s", + fmtQualifiedDumpable(coll)); + } + + if (varisnotnull) + appendPQExpBuffer(query, " NOT NULL"); + + if (vardefexpr) + appendPQExpBuffer(query, " DEFAULT %s", + vardefexpr); + + if (strcmp(vareoxaction, "d") == 0) + appendPQExpBuffer(query, " ON COMMIT DROP"); + else if (strcmp(vareoxaction, "r") == 0) + appendPQExpBuffer(query, " ON TRANSACTION END RESET"); + + appendPQExpBuffer(query, ";\n"); + + if (varinfo->dobj.dump & DUMP_COMPONENT_DEFINITION) + ArchiveEntry(fout, varinfo->dobj.catId, varinfo->dobj.dumpId, + ARCHIVE_OPTS(.tag = varinfo->dobj.name, + .namespace = varinfo->dobj.namespace->dobj.name, + .owner = varinfo->rolname, + .description = "VARIABLE", + .section = SECTION_PRE_DATA, + .createStmt = query->data, + .dropStmt = delq->data)); + + /* Dump comment if any */ + if (varinfo->dobj.dump & DUMP_COMPONENT_COMMENT) + dumpComment(fout, "VARIABLE", qualvarname, + NULL, varinfo->rolname, + varinfo->dobj.catId, 0, varinfo->dobj.dumpId); + + /* Dump ACL if any */ + if (varinfo->dobj.dump & DUMP_COMPONENT_ACL) + { + char *qvarname = pg_strdup(fmtId(varinfo->dobj.name)); + + dumpACL(fout, varinfo->dobj.dumpId, InvalidDumpId, "VARIABLE", + qvarname, NULL, + varinfo->dobj.namespace->dobj.name, varinfo->rolname, &varinfo->dacl); + + free(qvarname); + } + + destroyPQExpBuffer(delq); + destroyPQExpBuffer(query); + + free(qualvarname); +} + static void binary_upgrade_set_type_oids_by_type_oid(Archive *fout, PQExpBuffer upgrade_buffer, @@ -9395,7 +9622,8 @@ getAdditionalACLs(Archive *fout) dobj->objType == DO_TABLE || dobj->objType == DO_PROCLANG || dobj->objType == DO_FDW || - dobj->objType == DO_FOREIGN_SERVER) + dobj->objType == DO_FOREIGN_SERVER || + dobj->objType == DO_VARIABLE) { DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj; @@ -9985,6 +10213,9 @@ dumpDumpableObject(Archive *fout, DumpableObject *dobj) case DO_SUBSCRIPTION: dumpSubscription(fout, (const SubscriptionInfo *) dobj); break; + case DO_VARIABLE: + dumpVariable(fout, (VariableInfo *) dobj); + break; case DO_PRE_DATA_BOUNDARY: case DO_POST_DATA_BOUNDARY: /* never dumped, nothing to do */ @@ -14361,6 +14592,9 @@ dumpDefaultACL(Archive *fout, const DefaultACLInfo *daclinfo) case DEFACLOBJ_NAMESPACE: type = "SCHEMAS"; break; + case DEFACLOBJ_VARIABLE: + type = "VARIABLES"; + break; default: /* shouldn't get here */ pg_fatal("unrecognized object type in default privileges: %d", @@ -17902,6 +18136,7 @@ addBoundaryDependencies(DumpableObject **dobjs, int numObjs, case DO_CONVERSION: case DO_TABLE: case DO_TABLE_ATTACH: + case DO_VARIABLE: case DO_ATTRDEF: case DO_PROCLANG: case DO_CAST: diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index 69ee939d44..8d719bd35e 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -52,6 +52,7 @@ typedef enum DO_TABLE, DO_TABLE_ATTACH, DO_ATTRDEF, + DO_VARIABLE, DO_INDEX, DO_INDEX_ATTACH, DO_STATSEXT, @@ -82,7 +83,7 @@ typedef enum DO_PUBLICATION, DO_PUBLICATION_REL, DO_PUBLICATION_TABLE_IN_SCHEMA, - DO_SUBSCRIPTION + DO_SUBSCRIPTION, } DumpableObjectType; /* @@ -664,6 +665,27 @@ typedef struct _SubscriptionInfo char *subpublications; } SubscriptionInfo; +/* + * The VariableInfo struct is used to represent session variables + */ +typedef struct _VariableInfo +{ + DumpableObject dobj; + DumpableAcl dacl; + Oid vartype; + char *vartypname; + char *vareoxaction; + char *vardefexpr; + char *varacl; + char *rvaracl; + char *initvaracl; + char *initrvaracl; + bool varisnotnull; + bool varisimmutable; + Oid varcollation; + const char *rolname; /* name of owner, or empty string */ +} VariableInfo; + /* * common utility functions */ @@ -746,5 +768,6 @@ extern void getPublicationNamespaces(Archive *fout); extern void getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables); extern void getSubscriptions(Archive *fout); +extern void getVariables(Archive *fout); #endif /* PG_DUMP_H */ diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c index 5de3241eb4..1a660b8a9f 100644 --- a/src/bin/pg_dump/pg_dump_sort.c +++ b/src/bin/pg_dump/pg_dump_sort.c @@ -75,6 +75,7 @@ enum dbObjectTypePriorities PRIO_TABLE_ATTACH, PRIO_DUMMY_TYPE, PRIO_ATTRDEF, + PRIO_VARIABLE, PRIO_BLOB, PRIO_PRE_DATA_BOUNDARY, /* boundary! */ PRIO_TABLE_DATA, @@ -116,6 +117,7 @@ static const int dbObjectTypePriority[] = PRIO_TABLE, /* DO_TABLE */ PRIO_TABLE_ATTACH, /* DO_TABLE_ATTACH */ PRIO_ATTRDEF, /* DO_ATTRDEF */ + PRIO_VARIABLE, /* DO_VARIABLE */ PRIO_INDEX, /* DO_INDEX */ PRIO_INDEX_ATTACH, /* DO_INDEX_ATTACH */ PRIO_STATSEXT, /* DO_STATSEXT */ @@ -1508,6 +1510,10 @@ describeDumpableObject(DumpableObject *obj, char *buf, int bufsize) "POST-DATA BOUNDARY (ID %d)", obj->dumpId); return; + case DO_VARIABLE: + snprintf(buf, bufsize, + "VARIABLE %s (ID %d OID %u)", + obj->name, obj->dumpId, obj->catId.oid); } /* shouldn't get here */ snprintf(buf, bufsize, diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c index 049a100634..830cde5421 100644 --- a/src/bin/pg_dump/pg_restore.c +++ b/src/bin/pg_dump/pg_restore.c @@ -103,6 +103,7 @@ main(int argc, char **argv) {"trigger", 1, NULL, 'T'}, {"use-list", 1, NULL, 'L'}, {"username", 1, NULL, 'U'}, + {"variable", 1, NULL, 'A'}, {"verbose", 0, NULL, 'v'}, {"single-transaction", 0, NULL, '1'}, @@ -151,7 +152,7 @@ main(int argc, char **argv) } } - while ((c = getopt_long(argc, argv, "acCd:ef:F:h:I:j:lL:n:N:Op:P:RsS:t:T:U:vwWx1", + while ((c = getopt_long(argc, argv, "A:acCd:ef:F:h:I:j:lL:n:N:Op:P:RsS:t:T:U:vwWx1", cmdopts, NULL)) != -1) { switch (c) @@ -159,6 +160,11 @@ main(int argc, char **argv) case 'a': /* Dump data only */ opts->dataOnly = 1; break; + case 'A': /* vAriable */ + opts->selTypes = 1; + opts->selVariable = 1; + simple_string_list_append(&opts->variableNames, optarg); + break; case 'c': /* clean (i.e., drop) schema prior to create */ opts->dropSchema = 1; break; @@ -444,6 +450,7 @@ usage(const char *progname) printf(_("\nOptions controlling the restore:\n")); printf(_(" -a, --data-only restore only the data, no schema\n")); + printf(_(" -A, --variable=NAME restore named session variable\n")); printf(_(" -c, --clean clean (drop) database objects before recreating\n")); printf(_(" -C, --create create the target database\n")); printf(_(" -e, --exit-on-error exit on error, default is to continue\n")); diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index 2873b662fb..747308c894 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -572,6 +572,16 @@ my %tests = ( unlike => { no_privs => 1, }, }, + 'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role GRANT SELECT ON VARIABLES TO PUBLIC' + => { + create_order => 56, + create_sql => 'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role GRANT SELECT ON VARIABLES TO PUBLIC;', + regexp => qr/^ + \QALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role GRANT SELECT ON VARIABLES TO PUBLIC;\E/xm, + like => { %full_runs, section_post_data => 1, }, + unlike => { no_privs => 1, }, + }, + 'ALTER ROLE regress_dump_test_role' => { regexp => qr/^ \QALTER ROLE regress_dump_test_role WITH \E @@ -1327,6 +1337,22 @@ my %tests = ( unlike => { exclude_dump_test_schema => 1, }, }, + 'COMMENT ON VARIABLE dump_test.variable1' => { + create_order => 71, + create_sql => 'COMMENT ON VARIABLE dump_test.variable1 + IS \'comment on variable\';', + regexp => + qr/^\QCOMMENT ON VARIABLE dump_test.variable1 IS 'comment on variable';\E/m, + like => { + %full_runs, + %dump_test_schema_runs, + section_pre_data => 1, + }, + unlike => { + exclude_dump_test_schema => 1, + }, + }, + 'COPY test_table' => { create_order => 4, create_sql => 'INSERT INTO dump_test.test_table (col1) ' @@ -3263,6 +3289,30 @@ my %tests = ( }, }, + 'CREATE VARIABLE test_variable' => { + all_runs => 1, + catch_all => 'CREATE ... commands', + create_order => 61, + create_sql => 'CREATE VARIABLE dump_test.variable1 AS integer DEFAULT 0;', + regexp => qr/^ + \QCREATE VARIABLE dump_test.variable1 AS integer DEFAULT 0;\E/xm, + like => + { %full_runs, %dump_test_schema_runs, section_pre_data => 1, }, + unlike => { exclude_dump_test_schema => 1, }, + }, + + 'CREATE IMMUTABLE VARIABLE test_variable' => { + all_runs => 1, + catch_all => 'CREATE ... commands', + create_order => 61, + create_sql => 'CREATE IMMUTABLE VARIABLE dump_test.variable2 AS integer DEFAULT 0;', + regexp => qr/^ + \QCREATE IMMUTABLE VARIABLE dump_test.variable2 AS integer DEFAULT 0;\E/xm, + like => + { %full_runs, %dump_test_schema_runs, section_pre_data => 1, }, + unlike => { exclude_dump_test_schema => 1, }, + }, + 'CREATE VIEW test_view' => { create_order => 61, create_sql => 'CREATE VIEW dump_test.test_view @@ -3702,6 +3752,21 @@ my %tests = ( like => {}, }, + 'GRANT SELECT ON VARIABLE dump_test.variable1' => { + create_order => 73, + create_sql => + 'GRANT SELECT ON VARIABLE dump_test.variable1 TO regress_dump_test_role;', + regexp => qr/^ + \QGRANT SELECT ON VARIABLE dump_test.variable1 TO regress_dump_test_role;\E + /xm, + like => + { %full_runs, %dump_test_schema_runs, section_pre_data => 1, }, + unlike => { + exclude_dump_test_schema => 1, + no_privs => 1, + }, + }, + 'REFRESH MATERIALIZED VIEW matview' => { regexp => qr/^\QREFRESH MATERIALIZED VIEW dump_test.matview;\E/m, like => -- 2.37.2 --gcms4zhgklsgym3k Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v20220906-1-0008-typedefs.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v20220916 09/13] possibility to dump session variables by pg_dump @ 2022-04-04 18:49 [email protected] <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: [email protected] @ 2022-04-04 18:49 UTC (permalink / raw) Enhancing pg_dump about session variables support --- src/bin/pg_dump/common.c | 3 +- src/bin/pg_dump/dumputils.c | 6 + src/bin/pg_dump/pg_backup.h | 2 + src/bin/pg_dump/pg_backup_archiver.c | 12 +- src/bin/pg_dump/pg_dump.c | 237 ++++++++++++++++++++++++++- src/bin/pg_dump/pg_dump.h | 25 ++- src/bin/pg_dump/pg_dump_sort.c | 6 + src/bin/pg_dump/pg_restore.c | 9 +- src/bin/pg_dump/t/002_pg_dump.pl | 65 ++++++++ src/tools/pgindent/typedefs.list | 1 + 10 files changed, 361 insertions(+), 5 deletions(-) diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 395f817fa8..6f10488c34 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -263,7 +263,8 @@ getSchemaData(Archive *fout, int *numTablesPtr) pg_log_info("reading subscriptions"); getSubscriptions(fout); - free(inhinfo); /* not needed any longer */ + pg_log_info("reading variables"); + getVariables(fout); *numTablesPtr = numTables; return tblinfo; diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c index 6e501a5413..dc1f0e1ba8 100644 --- a/src/bin/pg_dump/dumputils.c +++ b/src/bin/pg_dump/dumputils.c @@ -504,6 +504,12 @@ do { \ CONVERT_PRIV('r', "SELECT"); CONVERT_PRIV('w', "UPDATE"); } + else if (strcmp(type, "VARIABLE") == 0 || + strcmp(type, "VARIABLES") == 0) + { + CONVERT_PRIV('r', "SELECT"); + CONVERT_PRIV('w', "UPDATE"); + } else abort(); diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h index fcc5f6bd05..9d675d669c 100644 --- a/src/bin/pg_dump/pg_backup.h +++ b/src/bin/pg_dump/pg_backup.h @@ -131,12 +131,14 @@ typedef struct _restoreOptions int selFunction; int selTrigger; int selTable; + int selVariable; SimpleStringList indexNames; SimpleStringList functionNames; SimpleStringList schemaNames; SimpleStringList schemaExcludeNames; SimpleStringList triggerNames; SimpleStringList tableNames; + SimpleStringList variableNames; int useDB; ConnParams cparams; /* parameters to use if useDB */ diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 233198afc0..8d47869ba8 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -2934,6 +2934,14 @@ _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH) !simple_string_list_member(&ropt->triggerNames, te->tag)) return 0; } + else if (strcmp(te->desc, "VARIABLE") == 0) + { + if (!ropt->selVariable) + return 0; + if (ropt->variableNames.head != NULL && + !simple_string_list_member(&ropt->variableNames, te->tag)) + return 0; + } else return 0; } @@ -3419,6 +3427,7 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te) strcmp(type, "TEXT SEARCH DICTIONARY") == 0 || strcmp(type, "TEXT SEARCH CONFIGURATION") == 0 || strcmp(type, "STATISTICS") == 0 || + strcmp(type, "VARIABLE") == 0 || /* non-schema-specified objects */ strcmp(type, "DATABASE") == 0 || strcmp(type, "PROCEDURAL LANGUAGE") == 0 || @@ -3611,7 +3620,8 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData) strcmp(te->desc, "SERVER") == 0 || strcmp(te->desc, "STATISTICS") == 0 || strcmp(te->desc, "PUBLICATION") == 0 || - strcmp(te->desc, "SUBSCRIPTION") == 0) + strcmp(te->desc, "SUBSCRIPTION") == 0 || + strcmp(te->desc, "VARIABLE") == 0) { PQExpBuffer temp = createPQExpBuffer(); diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 67b6d9079e..813f3f5c7c 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -287,6 +287,7 @@ static void dumpPolicy(Archive *fout, const PolicyInfo *polinfo); static void dumpPublication(Archive *fout, const PublicationInfo *pubinfo); static void dumpPublicationTable(Archive *fout, const PublicationRelInfo *pubrinfo); static void dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo); +static void dumpVariable(Archive *fout, const VariableInfo * varinfo); static void dumpDatabase(Archive *AH); static void dumpDatabaseConfig(Archive *AH, PQExpBuffer outbuf, const char *dbname, Oid dboid); @@ -4741,6 +4742,232 @@ get_next_possible_free_pg_type_oid(Archive *fout, PQExpBuffer upgrade_query) return next_possible_free_oid; } +/* + * getVariables + * get information about variables + */ +void +getVariables(Archive *fout) +{ + PQExpBuffer query; + PGresult *res; + VariableInfo *varinfo; + int i_tableoid; + int i_oid; + int i_varname; + int i_varnamespace; + int i_vartype; + int i_vartypname; + int i_vardefexpr; + int i_vareoxaction; + int i_varisnotnull; + int i_varisimmutable; + int i_varowner; + int i_varcollation; + int i_varacl; + int i_acldefault; + int i, + ntups; + + if (fout->remoteVersion < 160000) + return; + + query = createPQExpBuffer(); + + resetPQExpBuffer(query); + + /* Get the variables in current database. */ + appendPQExpBuffer(query, + "SELECT v.tableoid, v.oid, v.varname,\n" + "v.vareoxaction,\n" + "v.varnamespace,\n" + "v.vartype,\n" + "pg_catalog.format_type(v.vartype, v.vartypmod) as vartypname,\n" + "v.varisnotnull,\n" + "v.varisimmutable,\n" + "CASE WHEN v.varcollation <> t.typcollation " + "THEN v.varcollation ELSE 0 END AS varcollation,\n" + "pg_catalog.pg_get_expr(v.vardefexpr,0) as vardefexpr,\n" + "v.varowner,\n" + "v.varacl,\n" + "acldefault('V', v.varowner) AS acldefault\n" + "FROM pg_catalog.pg_variable v\n" + "JOIN pg_catalog.pg_type t " + "ON (v.vartype = t.oid)"); + + res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); + + ntups = PQntuples(res); + + i_tableoid = PQfnumber(res, "tableoid"); + i_oid = PQfnumber(res, "oid"); + i_varname = PQfnumber(res, "varname"); + i_varnamespace = PQfnumber(res, "varnamespace"); + i_vartype = PQfnumber(res, "vartype"); + i_vartypname = PQfnumber(res, "vartypname"); + i_vareoxaction = PQfnumber(res, "vareoxaction"); + i_vardefexpr = PQfnumber(res, "vardefexpr"); + i_varisnotnull = PQfnumber(res, "varisnotnull"); + i_varisimmutable = PQfnumber(res, "varisimmutable"); + i_varcollation = PQfnumber(res, "varcollation"); + + i_varowner = PQfnumber(res, "varowner"); + i_varacl = PQfnumber(res, "varacl"); + i_acldefault = PQfnumber(res, "acldefault"); + + varinfo = pg_malloc(ntups * sizeof(VariableInfo)); + + for (i = 0; i < ntups; i++) + { + TypeInfo *vtype; + + varinfo[i].dobj.objType = DO_VARIABLE; + varinfo[i].dobj.catId.tableoid = + atooid(PQgetvalue(res, i, i_tableoid)); + varinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); + AssignDumpId(&varinfo[i].dobj); + varinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_varname)); + varinfo[i].dobj.namespace = + findNamespace(atooid(PQgetvalue(res, i, i_varnamespace))); + + varinfo[i].vartype = atooid(PQgetvalue(res, i, i_vartype)); + varinfo[i].vartypname = pg_strdup(PQgetvalue(res, i, i_vartypname)); + varinfo[i].vareoxaction = pg_strdup(PQgetvalue(res, i, i_vareoxaction)); + varinfo[i].varisnotnull = *(PQgetvalue(res, i, i_varisnotnull)) == 't'; + varinfo[i].varisimmutable = *(PQgetvalue(res, i, i_varisimmutable)) == 't'; + varinfo[i].varcollation = atooid(PQgetvalue(res, i, i_varcollation)); + + varinfo[i].dacl.acl = pg_strdup(PQgetvalue(res, i, i_varacl)); + varinfo[i].dacl.acldefault = pg_strdup(PQgetvalue(res, i, i_acldefault)); + varinfo[i].dacl.privtype = 0; + varinfo[i].dacl.initprivs = NULL; + varinfo[i].rolname = getRoleName(PQgetvalue(res, i, i_varowner)); + + /* Decide whether we want to dump it */ + selectDumpableObject(&(varinfo[i].dobj), fout); + + /* Do not try to dump ACL if no ACL exists. */ + if (!PQgetisnull(res, i, i_varacl)) + varinfo[i].dobj.components |= DUMP_COMPONENT_ACL; + + if (PQgetisnull(res, i, i_vardefexpr)) + varinfo[i].vardefexpr = NULL; + else + varinfo[i].vardefexpr = pg_strdup(PQgetvalue(res, i, i_vardefexpr)); + + if (strlen(varinfo[i].rolname) == 0) + pg_log_warning("owner of variable \"%s\" appears to be invalid", + varinfo[i].dobj.name); + + /* Decide whether we want to dump it */ + selectDumpableObject(&(varinfo[i].dobj), fout); + + vtype = findTypeByOid(varinfo[i].vartype); + addObjectDependency(&varinfo[i].dobj, vtype->dobj.dumpId); + } + PQclear(res); + + destroyPQExpBuffer(query); +} + +/* + * dumpVariable + * dump the definition of the given variables + */ +static void +dumpVariable(Archive *fout, const VariableInfo *varinfo) +{ + DumpOptions *dopt = fout->dopt; + + PQExpBuffer delq; + PQExpBuffer query; + char *qualvarname; + const char *vartypname; + const char *vardefexpr; + const char *vareoxaction; + const char *varisimmutable; + Oid varcollation; + bool varisnotnull; + + /* Skip if not to be dumped */ + if (!varinfo->dobj.dump || dopt->dataOnly) + return; + + delq = createPQExpBuffer(); + query = createPQExpBuffer(); + + qualvarname = pg_strdup(fmtQualifiedDumpable(varinfo)); + vartypname = varinfo->vartypname; + vardefexpr = varinfo->vardefexpr; + vareoxaction = varinfo->vareoxaction; + varisnotnull = varinfo->varisnotnull; + varisimmutable = varinfo->varisimmutable ? "IMMUTABLE " : ""; + varcollation = varinfo->varcollation; + + appendPQExpBuffer(delq, "DROP VARIABLE %s;\n", + qualvarname); + + appendPQExpBuffer(query, "CREATE %sVARIABLE %s AS %s", + varisimmutable, qualvarname, vartypname); + + if (OidIsValid(varcollation)) + { + CollInfo *coll; + + coll = findCollationByOid(varcollation); + if (coll) + appendPQExpBuffer(query, " COLLATE %s", + fmtQualifiedDumpable(coll)); + } + + if (varisnotnull) + appendPQExpBuffer(query, " NOT NULL"); + + if (vardefexpr) + appendPQExpBuffer(query, " DEFAULT %s", + vardefexpr); + + if (strcmp(vareoxaction, "d") == 0) + appendPQExpBuffer(query, " ON COMMIT DROP"); + else if (strcmp(vareoxaction, "r") == 0) + appendPQExpBuffer(query, " ON TRANSACTION END RESET"); + + appendPQExpBuffer(query, ";\n"); + + if (varinfo->dobj.dump & DUMP_COMPONENT_DEFINITION) + ArchiveEntry(fout, varinfo->dobj.catId, varinfo->dobj.dumpId, + ARCHIVE_OPTS(.tag = varinfo->dobj.name, + .namespace = varinfo->dobj.namespace->dobj.name, + .owner = varinfo->rolname, + .description = "VARIABLE", + .section = SECTION_PRE_DATA, + .createStmt = query->data, + .dropStmt = delq->data)); + + /* Dump comment if any */ + if (varinfo->dobj.dump & DUMP_COMPONENT_COMMENT) + dumpComment(fout, "VARIABLE", qualvarname, + NULL, varinfo->rolname, + varinfo->dobj.catId, 0, varinfo->dobj.dumpId); + + /* Dump ACL if any */ + if (varinfo->dobj.dump & DUMP_COMPONENT_ACL) + { + char *qvarname = pg_strdup(fmtId(varinfo->dobj.name)); + + dumpACL(fout, varinfo->dobj.dumpId, InvalidDumpId, "VARIABLE", + qvarname, NULL, + varinfo->dobj.namespace->dobj.name, varinfo->rolname, &varinfo->dacl); + + free(qvarname); + } + + destroyPQExpBuffer(delq); + destroyPQExpBuffer(query); + + free(qualvarname); +} + static void binary_upgrade_set_type_oids_by_type_oid(Archive *fout, PQExpBuffer upgrade_buffer, @@ -9395,7 +9622,8 @@ getAdditionalACLs(Archive *fout) dobj->objType == DO_TABLE || dobj->objType == DO_PROCLANG || dobj->objType == DO_FDW || - dobj->objType == DO_FOREIGN_SERVER) + dobj->objType == DO_FOREIGN_SERVER || + dobj->objType == DO_VARIABLE) { DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj; @@ -9985,6 +10213,9 @@ dumpDumpableObject(Archive *fout, DumpableObject *dobj) case DO_SUBSCRIPTION: dumpSubscription(fout, (const SubscriptionInfo *) dobj); break; + case DO_VARIABLE: + dumpVariable(fout, (VariableInfo *) dobj); + break; case DO_PRE_DATA_BOUNDARY: case DO_POST_DATA_BOUNDARY: /* never dumped, nothing to do */ @@ -14361,6 +14592,9 @@ dumpDefaultACL(Archive *fout, const DefaultACLInfo *daclinfo) case DEFACLOBJ_NAMESPACE: type = "SCHEMAS"; break; + case DEFACLOBJ_VARIABLE: + type = "VARIABLES"; + break; default: /* shouldn't get here */ pg_fatal("unrecognized object type in default privileges: %d", @@ -17902,6 +18136,7 @@ addBoundaryDependencies(DumpableObject **dobjs, int numObjs, case DO_CONVERSION: case DO_TABLE: case DO_TABLE_ATTACH: + case DO_VARIABLE: case DO_ATTRDEF: case DO_PROCLANG: case DO_CAST: diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index 69ee939d44..5c6acf84f6 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -52,6 +52,7 @@ typedef enum DO_TABLE, DO_TABLE_ATTACH, DO_ATTRDEF, + DO_VARIABLE, DO_INDEX, DO_INDEX_ATTACH, DO_STATSEXT, @@ -82,7 +83,7 @@ typedef enum DO_PUBLICATION, DO_PUBLICATION_REL, DO_PUBLICATION_TABLE_IN_SCHEMA, - DO_SUBSCRIPTION + DO_SUBSCRIPTION, } DumpableObjectType; /* @@ -664,6 +665,27 @@ typedef struct _SubscriptionInfo char *subpublications; } SubscriptionInfo; +/* + * The VariableInfo struct is used to represent session variables + */ +typedef struct _VariableInfo +{ + DumpableObject dobj; + DumpableAcl dacl; + Oid vartype; + char *vartypname; + char *vareoxaction; + char *vardefexpr; + char *varacl; + char *rvaracl; + char *initvaracl; + char *initrvaracl; + bool varisnotnull; + bool varisimmutable; + Oid varcollation; + const char *rolname; /* name of owner, or empty string */ +} VariableInfo; + /* * common utility functions */ @@ -746,5 +768,6 @@ extern void getPublicationNamespaces(Archive *fout); extern void getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables); extern void getSubscriptions(Archive *fout); +extern void getVariables(Archive *fout); #endif /* PG_DUMP_H */ diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c index 5de3241eb4..1a660b8a9f 100644 --- a/src/bin/pg_dump/pg_dump_sort.c +++ b/src/bin/pg_dump/pg_dump_sort.c @@ -75,6 +75,7 @@ enum dbObjectTypePriorities PRIO_TABLE_ATTACH, PRIO_DUMMY_TYPE, PRIO_ATTRDEF, + PRIO_VARIABLE, PRIO_BLOB, PRIO_PRE_DATA_BOUNDARY, /* boundary! */ PRIO_TABLE_DATA, @@ -116,6 +117,7 @@ static const int dbObjectTypePriority[] = PRIO_TABLE, /* DO_TABLE */ PRIO_TABLE_ATTACH, /* DO_TABLE_ATTACH */ PRIO_ATTRDEF, /* DO_ATTRDEF */ + PRIO_VARIABLE, /* DO_VARIABLE */ PRIO_INDEX, /* DO_INDEX */ PRIO_INDEX_ATTACH, /* DO_INDEX_ATTACH */ PRIO_STATSEXT, /* DO_STATSEXT */ @@ -1508,6 +1510,10 @@ describeDumpableObject(DumpableObject *obj, char *buf, int bufsize) "POST-DATA BOUNDARY (ID %d)", obj->dumpId); return; + case DO_VARIABLE: + snprintf(buf, bufsize, + "VARIABLE %s (ID %d OID %u)", + obj->name, obj->dumpId, obj->catId.oid); } /* shouldn't get here */ snprintf(buf, bufsize, diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c index 049a100634..830cde5421 100644 --- a/src/bin/pg_dump/pg_restore.c +++ b/src/bin/pg_dump/pg_restore.c @@ -103,6 +103,7 @@ main(int argc, char **argv) {"trigger", 1, NULL, 'T'}, {"use-list", 1, NULL, 'L'}, {"username", 1, NULL, 'U'}, + {"variable", 1, NULL, 'A'}, {"verbose", 0, NULL, 'v'}, {"single-transaction", 0, NULL, '1'}, @@ -151,7 +152,7 @@ main(int argc, char **argv) } } - while ((c = getopt_long(argc, argv, "acCd:ef:F:h:I:j:lL:n:N:Op:P:RsS:t:T:U:vwWx1", + while ((c = getopt_long(argc, argv, "A:acCd:ef:F:h:I:j:lL:n:N:Op:P:RsS:t:T:U:vwWx1", cmdopts, NULL)) != -1) { switch (c) @@ -159,6 +160,11 @@ main(int argc, char **argv) case 'a': /* Dump data only */ opts->dataOnly = 1; break; + case 'A': /* vAriable */ + opts->selTypes = 1; + opts->selVariable = 1; + simple_string_list_append(&opts->variableNames, optarg); + break; case 'c': /* clean (i.e., drop) schema prior to create */ opts->dropSchema = 1; break; @@ -444,6 +450,7 @@ usage(const char *progname) printf(_("\nOptions controlling the restore:\n")); printf(_(" -a, --data-only restore only the data, no schema\n")); + printf(_(" -A, --variable=NAME restore named session variable\n")); printf(_(" -c, --clean clean (drop) database objects before recreating\n")); printf(_(" -C, --create create the target database\n")); printf(_(" -e, --exit-on-error exit on error, default is to continue\n")); diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index 2873b662fb..747308c894 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -572,6 +572,16 @@ my %tests = ( unlike => { no_privs => 1, }, }, + 'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role GRANT SELECT ON VARIABLES TO PUBLIC' + => { + create_order => 56, + create_sql => 'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role GRANT SELECT ON VARIABLES TO PUBLIC;', + regexp => qr/^ + \QALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role GRANT SELECT ON VARIABLES TO PUBLIC;\E/xm, + like => { %full_runs, section_post_data => 1, }, + unlike => { no_privs => 1, }, + }, + 'ALTER ROLE regress_dump_test_role' => { regexp => qr/^ \QALTER ROLE regress_dump_test_role WITH \E @@ -1327,6 +1337,22 @@ my %tests = ( unlike => { exclude_dump_test_schema => 1, }, }, + 'COMMENT ON VARIABLE dump_test.variable1' => { + create_order => 71, + create_sql => 'COMMENT ON VARIABLE dump_test.variable1 + IS \'comment on variable\';', + regexp => + qr/^\QCOMMENT ON VARIABLE dump_test.variable1 IS 'comment on variable';\E/m, + like => { + %full_runs, + %dump_test_schema_runs, + section_pre_data => 1, + }, + unlike => { + exclude_dump_test_schema => 1, + }, + }, + 'COPY test_table' => { create_order => 4, create_sql => 'INSERT INTO dump_test.test_table (col1) ' @@ -3263,6 +3289,30 @@ my %tests = ( }, }, + 'CREATE VARIABLE test_variable' => { + all_runs => 1, + catch_all => 'CREATE ... commands', + create_order => 61, + create_sql => 'CREATE VARIABLE dump_test.variable1 AS integer DEFAULT 0;', + regexp => qr/^ + \QCREATE VARIABLE dump_test.variable1 AS integer DEFAULT 0;\E/xm, + like => + { %full_runs, %dump_test_schema_runs, section_pre_data => 1, }, + unlike => { exclude_dump_test_schema => 1, }, + }, + + 'CREATE IMMUTABLE VARIABLE test_variable' => { + all_runs => 1, + catch_all => 'CREATE ... commands', + create_order => 61, + create_sql => 'CREATE IMMUTABLE VARIABLE dump_test.variable2 AS integer DEFAULT 0;', + regexp => qr/^ + \QCREATE IMMUTABLE VARIABLE dump_test.variable2 AS integer DEFAULT 0;\E/xm, + like => + { %full_runs, %dump_test_schema_runs, section_pre_data => 1, }, + unlike => { exclude_dump_test_schema => 1, }, + }, + 'CREATE VIEW test_view' => { create_order => 61, create_sql => 'CREATE VIEW dump_test.test_view @@ -3702,6 +3752,21 @@ my %tests = ( like => {}, }, + 'GRANT SELECT ON VARIABLE dump_test.variable1' => { + create_order => 73, + create_sql => + 'GRANT SELECT ON VARIABLE dump_test.variable1 TO regress_dump_test_role;', + regexp => qr/^ + \QGRANT SELECT ON VARIABLE dump_test.variable1 TO regress_dump_test_role;\E + /xm, + like => + { %full_runs, %dump_test_schema_runs, section_pre_data => 1, }, + unlike => { + exclude_dump_test_schema => 1, + no_privs => 1, + }, + }, + 'REFRESH MATERIALIZED VIEW matview' => { regexp => qr/^\QREFRESH MATERIALIZED VIEW dump_test.matview;\E/m, like => diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list index 522986a730..8b7e281bcf 100644 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@ -2913,6 +2913,7 @@ Variable VariableAssignHook VariableCache VariableCacheData +VariableInfo VariableSetKind VariableSetStmt VariableShowStmt -- 2.37.0 --w2in66fnadvggvsb Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v20220916-0010-regress-tests-for-session-variables.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v20220916 09/13] possibility to dump session variables by pg_dump @ 2022-04-04 18:49 [email protected] <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: [email protected] @ 2022-04-04 18:49 UTC (permalink / raw) Enhancing pg_dump about session variables support --- src/bin/pg_dump/common.c | 3 +- src/bin/pg_dump/dumputils.c | 6 + src/bin/pg_dump/pg_backup.h | 2 + src/bin/pg_dump/pg_backup_archiver.c | 12 +- src/bin/pg_dump/pg_dump.c | 237 ++++++++++++++++++++++++++- src/bin/pg_dump/pg_dump.h | 25 ++- src/bin/pg_dump/pg_dump_sort.c | 6 + src/bin/pg_dump/pg_restore.c | 9 +- src/bin/pg_dump/t/002_pg_dump.pl | 65 ++++++++ src/tools/pgindent/typedefs.list | 1 + 10 files changed, 361 insertions(+), 5 deletions(-) diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 395f817fa8..6f10488c34 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -263,7 +263,8 @@ getSchemaData(Archive *fout, int *numTablesPtr) pg_log_info("reading subscriptions"); getSubscriptions(fout); - free(inhinfo); /* not needed any longer */ + pg_log_info("reading variables"); + getVariables(fout); *numTablesPtr = numTables; return tblinfo; diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c index 6e501a5413..dc1f0e1ba8 100644 --- a/src/bin/pg_dump/dumputils.c +++ b/src/bin/pg_dump/dumputils.c @@ -504,6 +504,12 @@ do { \ CONVERT_PRIV('r', "SELECT"); CONVERT_PRIV('w', "UPDATE"); } + else if (strcmp(type, "VARIABLE") == 0 || + strcmp(type, "VARIABLES") == 0) + { + CONVERT_PRIV('r', "SELECT"); + CONVERT_PRIV('w', "UPDATE"); + } else abort(); diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h index fcc5f6bd05..9d675d669c 100644 --- a/src/bin/pg_dump/pg_backup.h +++ b/src/bin/pg_dump/pg_backup.h @@ -131,12 +131,14 @@ typedef struct _restoreOptions int selFunction; int selTrigger; int selTable; + int selVariable; SimpleStringList indexNames; SimpleStringList functionNames; SimpleStringList schemaNames; SimpleStringList schemaExcludeNames; SimpleStringList triggerNames; SimpleStringList tableNames; + SimpleStringList variableNames; int useDB; ConnParams cparams; /* parameters to use if useDB */ diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 233198afc0..8d47869ba8 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -2934,6 +2934,14 @@ _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH) !simple_string_list_member(&ropt->triggerNames, te->tag)) return 0; } + else if (strcmp(te->desc, "VARIABLE") == 0) + { + if (!ropt->selVariable) + return 0; + if (ropt->variableNames.head != NULL && + !simple_string_list_member(&ropt->variableNames, te->tag)) + return 0; + } else return 0; } @@ -3419,6 +3427,7 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te) strcmp(type, "TEXT SEARCH DICTIONARY") == 0 || strcmp(type, "TEXT SEARCH CONFIGURATION") == 0 || strcmp(type, "STATISTICS") == 0 || + strcmp(type, "VARIABLE") == 0 || /* non-schema-specified objects */ strcmp(type, "DATABASE") == 0 || strcmp(type, "PROCEDURAL LANGUAGE") == 0 || @@ -3611,7 +3620,8 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData) strcmp(te->desc, "SERVER") == 0 || strcmp(te->desc, "STATISTICS") == 0 || strcmp(te->desc, "PUBLICATION") == 0 || - strcmp(te->desc, "SUBSCRIPTION") == 0) + strcmp(te->desc, "SUBSCRIPTION") == 0 || + strcmp(te->desc, "VARIABLE") == 0) { PQExpBuffer temp = createPQExpBuffer(); diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 67b6d9079e..813f3f5c7c 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -287,6 +287,7 @@ static void dumpPolicy(Archive *fout, const PolicyInfo *polinfo); static void dumpPublication(Archive *fout, const PublicationInfo *pubinfo); static void dumpPublicationTable(Archive *fout, const PublicationRelInfo *pubrinfo); static void dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo); +static void dumpVariable(Archive *fout, const VariableInfo * varinfo); static void dumpDatabase(Archive *AH); static void dumpDatabaseConfig(Archive *AH, PQExpBuffer outbuf, const char *dbname, Oid dboid); @@ -4741,6 +4742,232 @@ get_next_possible_free_pg_type_oid(Archive *fout, PQExpBuffer upgrade_query) return next_possible_free_oid; } +/* + * getVariables + * get information about variables + */ +void +getVariables(Archive *fout) +{ + PQExpBuffer query; + PGresult *res; + VariableInfo *varinfo; + int i_tableoid; + int i_oid; + int i_varname; + int i_varnamespace; + int i_vartype; + int i_vartypname; + int i_vardefexpr; + int i_vareoxaction; + int i_varisnotnull; + int i_varisimmutable; + int i_varowner; + int i_varcollation; + int i_varacl; + int i_acldefault; + int i, + ntups; + + if (fout->remoteVersion < 160000) + return; + + query = createPQExpBuffer(); + + resetPQExpBuffer(query); + + /* Get the variables in current database. */ + appendPQExpBuffer(query, + "SELECT v.tableoid, v.oid, v.varname,\n" + "v.vareoxaction,\n" + "v.varnamespace,\n" + "v.vartype,\n" + "pg_catalog.format_type(v.vartype, v.vartypmod) as vartypname,\n" + "v.varisnotnull,\n" + "v.varisimmutable,\n" + "CASE WHEN v.varcollation <> t.typcollation " + "THEN v.varcollation ELSE 0 END AS varcollation,\n" + "pg_catalog.pg_get_expr(v.vardefexpr,0) as vardefexpr,\n" + "v.varowner,\n" + "v.varacl,\n" + "acldefault('V', v.varowner) AS acldefault\n" + "FROM pg_catalog.pg_variable v\n" + "JOIN pg_catalog.pg_type t " + "ON (v.vartype = t.oid)"); + + res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); + + ntups = PQntuples(res); + + i_tableoid = PQfnumber(res, "tableoid"); + i_oid = PQfnumber(res, "oid"); + i_varname = PQfnumber(res, "varname"); + i_varnamespace = PQfnumber(res, "varnamespace"); + i_vartype = PQfnumber(res, "vartype"); + i_vartypname = PQfnumber(res, "vartypname"); + i_vareoxaction = PQfnumber(res, "vareoxaction"); + i_vardefexpr = PQfnumber(res, "vardefexpr"); + i_varisnotnull = PQfnumber(res, "varisnotnull"); + i_varisimmutable = PQfnumber(res, "varisimmutable"); + i_varcollation = PQfnumber(res, "varcollation"); + + i_varowner = PQfnumber(res, "varowner"); + i_varacl = PQfnumber(res, "varacl"); + i_acldefault = PQfnumber(res, "acldefault"); + + varinfo = pg_malloc(ntups * sizeof(VariableInfo)); + + for (i = 0; i < ntups; i++) + { + TypeInfo *vtype; + + varinfo[i].dobj.objType = DO_VARIABLE; + varinfo[i].dobj.catId.tableoid = + atooid(PQgetvalue(res, i, i_tableoid)); + varinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); + AssignDumpId(&varinfo[i].dobj); + varinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_varname)); + varinfo[i].dobj.namespace = + findNamespace(atooid(PQgetvalue(res, i, i_varnamespace))); + + varinfo[i].vartype = atooid(PQgetvalue(res, i, i_vartype)); + varinfo[i].vartypname = pg_strdup(PQgetvalue(res, i, i_vartypname)); + varinfo[i].vareoxaction = pg_strdup(PQgetvalue(res, i, i_vareoxaction)); + varinfo[i].varisnotnull = *(PQgetvalue(res, i, i_varisnotnull)) == 't'; + varinfo[i].varisimmutable = *(PQgetvalue(res, i, i_varisimmutable)) == 't'; + varinfo[i].varcollation = atooid(PQgetvalue(res, i, i_varcollation)); + + varinfo[i].dacl.acl = pg_strdup(PQgetvalue(res, i, i_varacl)); + varinfo[i].dacl.acldefault = pg_strdup(PQgetvalue(res, i, i_acldefault)); + varinfo[i].dacl.privtype = 0; + varinfo[i].dacl.initprivs = NULL; + varinfo[i].rolname = getRoleName(PQgetvalue(res, i, i_varowner)); + + /* Decide whether we want to dump it */ + selectDumpableObject(&(varinfo[i].dobj), fout); + + /* Do not try to dump ACL if no ACL exists. */ + if (!PQgetisnull(res, i, i_varacl)) + varinfo[i].dobj.components |= DUMP_COMPONENT_ACL; + + if (PQgetisnull(res, i, i_vardefexpr)) + varinfo[i].vardefexpr = NULL; + else + varinfo[i].vardefexpr = pg_strdup(PQgetvalue(res, i, i_vardefexpr)); + + if (strlen(varinfo[i].rolname) == 0) + pg_log_warning("owner of variable \"%s\" appears to be invalid", + varinfo[i].dobj.name); + + /* Decide whether we want to dump it */ + selectDumpableObject(&(varinfo[i].dobj), fout); + + vtype = findTypeByOid(varinfo[i].vartype); + addObjectDependency(&varinfo[i].dobj, vtype->dobj.dumpId); + } + PQclear(res); + + destroyPQExpBuffer(query); +} + +/* + * dumpVariable + * dump the definition of the given variables + */ +static void +dumpVariable(Archive *fout, const VariableInfo *varinfo) +{ + DumpOptions *dopt = fout->dopt; + + PQExpBuffer delq; + PQExpBuffer query; + char *qualvarname; + const char *vartypname; + const char *vardefexpr; + const char *vareoxaction; + const char *varisimmutable; + Oid varcollation; + bool varisnotnull; + + /* Skip if not to be dumped */ + if (!varinfo->dobj.dump || dopt->dataOnly) + return; + + delq = createPQExpBuffer(); + query = createPQExpBuffer(); + + qualvarname = pg_strdup(fmtQualifiedDumpable(varinfo)); + vartypname = varinfo->vartypname; + vardefexpr = varinfo->vardefexpr; + vareoxaction = varinfo->vareoxaction; + varisnotnull = varinfo->varisnotnull; + varisimmutable = varinfo->varisimmutable ? "IMMUTABLE " : ""; + varcollation = varinfo->varcollation; + + appendPQExpBuffer(delq, "DROP VARIABLE %s;\n", + qualvarname); + + appendPQExpBuffer(query, "CREATE %sVARIABLE %s AS %s", + varisimmutable, qualvarname, vartypname); + + if (OidIsValid(varcollation)) + { + CollInfo *coll; + + coll = findCollationByOid(varcollation); + if (coll) + appendPQExpBuffer(query, " COLLATE %s", + fmtQualifiedDumpable(coll)); + } + + if (varisnotnull) + appendPQExpBuffer(query, " NOT NULL"); + + if (vardefexpr) + appendPQExpBuffer(query, " DEFAULT %s", + vardefexpr); + + if (strcmp(vareoxaction, "d") == 0) + appendPQExpBuffer(query, " ON COMMIT DROP"); + else if (strcmp(vareoxaction, "r") == 0) + appendPQExpBuffer(query, " ON TRANSACTION END RESET"); + + appendPQExpBuffer(query, ";\n"); + + if (varinfo->dobj.dump & DUMP_COMPONENT_DEFINITION) + ArchiveEntry(fout, varinfo->dobj.catId, varinfo->dobj.dumpId, + ARCHIVE_OPTS(.tag = varinfo->dobj.name, + .namespace = varinfo->dobj.namespace->dobj.name, + .owner = varinfo->rolname, + .description = "VARIABLE", + .section = SECTION_PRE_DATA, + .createStmt = query->data, + .dropStmt = delq->data)); + + /* Dump comment if any */ + if (varinfo->dobj.dump & DUMP_COMPONENT_COMMENT) + dumpComment(fout, "VARIABLE", qualvarname, + NULL, varinfo->rolname, + varinfo->dobj.catId, 0, varinfo->dobj.dumpId); + + /* Dump ACL if any */ + if (varinfo->dobj.dump & DUMP_COMPONENT_ACL) + { + char *qvarname = pg_strdup(fmtId(varinfo->dobj.name)); + + dumpACL(fout, varinfo->dobj.dumpId, InvalidDumpId, "VARIABLE", + qvarname, NULL, + varinfo->dobj.namespace->dobj.name, varinfo->rolname, &varinfo->dacl); + + free(qvarname); + } + + destroyPQExpBuffer(delq); + destroyPQExpBuffer(query); + + free(qualvarname); +} + static void binary_upgrade_set_type_oids_by_type_oid(Archive *fout, PQExpBuffer upgrade_buffer, @@ -9395,7 +9622,8 @@ getAdditionalACLs(Archive *fout) dobj->objType == DO_TABLE || dobj->objType == DO_PROCLANG || dobj->objType == DO_FDW || - dobj->objType == DO_FOREIGN_SERVER) + dobj->objType == DO_FOREIGN_SERVER || + dobj->objType == DO_VARIABLE) { DumpableObjectWithAcl *daobj = (DumpableObjectWithAcl *) dobj; @@ -9985,6 +10213,9 @@ dumpDumpableObject(Archive *fout, DumpableObject *dobj) case DO_SUBSCRIPTION: dumpSubscription(fout, (const SubscriptionInfo *) dobj); break; + case DO_VARIABLE: + dumpVariable(fout, (VariableInfo *) dobj); + break; case DO_PRE_DATA_BOUNDARY: case DO_POST_DATA_BOUNDARY: /* never dumped, nothing to do */ @@ -14361,6 +14592,9 @@ dumpDefaultACL(Archive *fout, const DefaultACLInfo *daclinfo) case DEFACLOBJ_NAMESPACE: type = "SCHEMAS"; break; + case DEFACLOBJ_VARIABLE: + type = "VARIABLES"; + break; default: /* shouldn't get here */ pg_fatal("unrecognized object type in default privileges: %d", @@ -17902,6 +18136,7 @@ addBoundaryDependencies(DumpableObject **dobjs, int numObjs, case DO_CONVERSION: case DO_TABLE: case DO_TABLE_ATTACH: + case DO_VARIABLE: case DO_ATTRDEF: case DO_PROCLANG: case DO_CAST: diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index 69ee939d44..5c6acf84f6 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -52,6 +52,7 @@ typedef enum DO_TABLE, DO_TABLE_ATTACH, DO_ATTRDEF, + DO_VARIABLE, DO_INDEX, DO_INDEX_ATTACH, DO_STATSEXT, @@ -82,7 +83,7 @@ typedef enum DO_PUBLICATION, DO_PUBLICATION_REL, DO_PUBLICATION_TABLE_IN_SCHEMA, - DO_SUBSCRIPTION + DO_SUBSCRIPTION, } DumpableObjectType; /* @@ -664,6 +665,27 @@ typedef struct _SubscriptionInfo char *subpublications; } SubscriptionInfo; +/* + * The VariableInfo struct is used to represent session variables + */ +typedef struct _VariableInfo +{ + DumpableObject dobj; + DumpableAcl dacl; + Oid vartype; + char *vartypname; + char *vareoxaction; + char *vardefexpr; + char *varacl; + char *rvaracl; + char *initvaracl; + char *initrvaracl; + bool varisnotnull; + bool varisimmutable; + Oid varcollation; + const char *rolname; /* name of owner, or empty string */ +} VariableInfo; + /* * common utility functions */ @@ -746,5 +768,6 @@ extern void getPublicationNamespaces(Archive *fout); extern void getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables); extern void getSubscriptions(Archive *fout); +extern void getVariables(Archive *fout); #endif /* PG_DUMP_H */ diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c index 5de3241eb4..1a660b8a9f 100644 --- a/src/bin/pg_dump/pg_dump_sort.c +++ b/src/bin/pg_dump/pg_dump_sort.c @@ -75,6 +75,7 @@ enum dbObjectTypePriorities PRIO_TABLE_ATTACH, PRIO_DUMMY_TYPE, PRIO_ATTRDEF, + PRIO_VARIABLE, PRIO_BLOB, PRIO_PRE_DATA_BOUNDARY, /* boundary! */ PRIO_TABLE_DATA, @@ -116,6 +117,7 @@ static const int dbObjectTypePriority[] = PRIO_TABLE, /* DO_TABLE */ PRIO_TABLE_ATTACH, /* DO_TABLE_ATTACH */ PRIO_ATTRDEF, /* DO_ATTRDEF */ + PRIO_VARIABLE, /* DO_VARIABLE */ PRIO_INDEX, /* DO_INDEX */ PRIO_INDEX_ATTACH, /* DO_INDEX_ATTACH */ PRIO_STATSEXT, /* DO_STATSEXT */ @@ -1508,6 +1510,10 @@ describeDumpableObject(DumpableObject *obj, char *buf, int bufsize) "POST-DATA BOUNDARY (ID %d)", obj->dumpId); return; + case DO_VARIABLE: + snprintf(buf, bufsize, + "VARIABLE %s (ID %d OID %u)", + obj->name, obj->dumpId, obj->catId.oid); } /* shouldn't get here */ snprintf(buf, bufsize, diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c index 049a100634..830cde5421 100644 --- a/src/bin/pg_dump/pg_restore.c +++ b/src/bin/pg_dump/pg_restore.c @@ -103,6 +103,7 @@ main(int argc, char **argv) {"trigger", 1, NULL, 'T'}, {"use-list", 1, NULL, 'L'}, {"username", 1, NULL, 'U'}, + {"variable", 1, NULL, 'A'}, {"verbose", 0, NULL, 'v'}, {"single-transaction", 0, NULL, '1'}, @@ -151,7 +152,7 @@ main(int argc, char **argv) } } - while ((c = getopt_long(argc, argv, "acCd:ef:F:h:I:j:lL:n:N:Op:P:RsS:t:T:U:vwWx1", + while ((c = getopt_long(argc, argv, "A:acCd:ef:F:h:I:j:lL:n:N:Op:P:RsS:t:T:U:vwWx1", cmdopts, NULL)) != -1) { switch (c) @@ -159,6 +160,11 @@ main(int argc, char **argv) case 'a': /* Dump data only */ opts->dataOnly = 1; break; + case 'A': /* vAriable */ + opts->selTypes = 1; + opts->selVariable = 1; + simple_string_list_append(&opts->variableNames, optarg); + break; case 'c': /* clean (i.e., drop) schema prior to create */ opts->dropSchema = 1; break; @@ -444,6 +450,7 @@ usage(const char *progname) printf(_("\nOptions controlling the restore:\n")); printf(_(" -a, --data-only restore only the data, no schema\n")); + printf(_(" -A, --variable=NAME restore named session variable\n")); printf(_(" -c, --clean clean (drop) database objects before recreating\n")); printf(_(" -C, --create create the target database\n")); printf(_(" -e, --exit-on-error exit on error, default is to continue\n")); diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index 2873b662fb..747308c894 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -572,6 +572,16 @@ my %tests = ( unlike => { no_privs => 1, }, }, + 'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role GRANT SELECT ON VARIABLES TO PUBLIC' + => { + create_order => 56, + create_sql => 'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role GRANT SELECT ON VARIABLES TO PUBLIC;', + regexp => qr/^ + \QALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role GRANT SELECT ON VARIABLES TO PUBLIC;\E/xm, + like => { %full_runs, section_post_data => 1, }, + unlike => { no_privs => 1, }, + }, + 'ALTER ROLE regress_dump_test_role' => { regexp => qr/^ \QALTER ROLE regress_dump_test_role WITH \E @@ -1327,6 +1337,22 @@ my %tests = ( unlike => { exclude_dump_test_schema => 1, }, }, + 'COMMENT ON VARIABLE dump_test.variable1' => { + create_order => 71, + create_sql => 'COMMENT ON VARIABLE dump_test.variable1 + IS \'comment on variable\';', + regexp => + qr/^\QCOMMENT ON VARIABLE dump_test.variable1 IS 'comment on variable';\E/m, + like => { + %full_runs, + %dump_test_schema_runs, + section_pre_data => 1, + }, + unlike => { + exclude_dump_test_schema => 1, + }, + }, + 'COPY test_table' => { create_order => 4, create_sql => 'INSERT INTO dump_test.test_table (col1) ' @@ -3263,6 +3289,30 @@ my %tests = ( }, }, + 'CREATE VARIABLE test_variable' => { + all_runs => 1, + catch_all => 'CREATE ... commands', + create_order => 61, + create_sql => 'CREATE VARIABLE dump_test.variable1 AS integer DEFAULT 0;', + regexp => qr/^ + \QCREATE VARIABLE dump_test.variable1 AS integer DEFAULT 0;\E/xm, + like => + { %full_runs, %dump_test_schema_runs, section_pre_data => 1, }, + unlike => { exclude_dump_test_schema => 1, }, + }, + + 'CREATE IMMUTABLE VARIABLE test_variable' => { + all_runs => 1, + catch_all => 'CREATE ... commands', + create_order => 61, + create_sql => 'CREATE IMMUTABLE VARIABLE dump_test.variable2 AS integer DEFAULT 0;', + regexp => qr/^ + \QCREATE IMMUTABLE VARIABLE dump_test.variable2 AS integer DEFAULT 0;\E/xm, + like => + { %full_runs, %dump_test_schema_runs, section_pre_data => 1, }, + unlike => { exclude_dump_test_schema => 1, }, + }, + 'CREATE VIEW test_view' => { create_order => 61, create_sql => 'CREATE VIEW dump_test.test_view @@ -3702,6 +3752,21 @@ my %tests = ( like => {}, }, + 'GRANT SELECT ON VARIABLE dump_test.variable1' => { + create_order => 73, + create_sql => + 'GRANT SELECT ON VARIABLE dump_test.variable1 TO regress_dump_test_role;', + regexp => qr/^ + \QGRANT SELECT ON VARIABLE dump_test.variable1 TO regress_dump_test_role;\E + /xm, + like => + { %full_runs, %dump_test_schema_runs, section_pre_data => 1, }, + unlike => { + exclude_dump_test_schema => 1, + no_privs => 1, + }, + }, + 'REFRESH MATERIALIZED VIEW matview' => { regexp => qr/^\QREFRESH MATERIALIZED VIEW dump_test.matview;\E/m, like => diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list index 522986a730..8b7e281bcf 100644 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@ -2913,6 +2913,7 @@ Variable VariableAssignHook VariableCache VariableCacheData +VariableInfo VariableSetKind VariableSetStmt VariableShowStmt -- 2.37.0 --w2in66fnadvggvsb Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v20220916-0010-regress-tests-for-session-variables.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- src/include/catalog/pg_retired.dat | 1 + 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d8b8d7b4d38..4f2c93f1ee2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index fee5efca41e..ffec11c5539 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat index 768ce980a1d..90928a9cb00 100644 --- a/src/include/catalog/pg_retired.dat +++ b/src/include/catalog/pg_retired.dat @@ -17,6 +17,7 @@ # At the same time, it may be good to be reminded what procedure was associated # with it. +{ oid => '1387', proname => 'pg_get_constraintdef' }, { oid => '1573', proname => 'pg_get_ruledef' }, { oid => '1640', proname => 'pg_get_viewdef' }, { oid => '1641', proname => 'pg_get_viewdef' }, -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0006-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index d39852c8323..e610a6213ec 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --AcCatzXgbvyipyEy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8.1-0005-Handle-pg_get_expr-default-args-in-system_funct.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 55926ec15e0..2d39bce7fd7 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index dfedf5c2851..39139fd9e3b 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8604,9 +8601,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '8760', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f', provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text', -- 2.52.0 --GzYugJnip6WHHvTk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index f7b9d26089a..1f89dcc7908 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 92e2f987074..416144c49f5 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 62b997a1653..a9431ea4037 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3977,9 +3977,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8501,7 +8498,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.51.2 --IRGsBYp1UN8d6WrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 77a7b0ca769..1afa2531f30 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 1dc0d01cc85..e148b1ad8e3 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4000,9 +4000,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8593,7 +8590,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.52.0 --m23X5uHFNxthGTU3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use CREATE OR REPLACE FUNCTION to handle the optional pretty argument. --- src/backend/catalog/system_functions.sql | 7 +++++++ src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 5 +---- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 72f5fdc06f9..1824faab231 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -685,6 +685,13 @@ LANGUAGE INTERNAL PARALLEL SAFE AS 'pg_get_indexdef'; +CREATE OR REPLACE FUNCTION + pg_get_constraintdef("constraint" oid, pretty bool DEFAULT false) +RETURNS TEXT +LANGUAGE INTERNAL +PARALLEL SAFE +AS 'pg_get_constraintdef'; + -- -- The default permissions for functions mean that anyone can execute them. -- A number of functions shouldn't be executable by just anyone, but rather diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index bb5863212cd..9faf340f0c6 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2061,23 +2061,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 56f68cee830..96eb7baf8e0 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3986,9 +3986,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8517,7 +8514,7 @@ proargtypes => 'oid int4 bool', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --3/nz5wg6+DYwHsLU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 6 ++---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b40158d30bb..03550f0d80b 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2062,23 +2062,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 7e45cbcb93d..1d1b24a8f4c 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3987,9 +3987,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8529,7 +8526,8 @@ proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, { oid => '2508', descr => 'constraint description with pretty-print option', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '2509', descr => 'deparse an encoded expression with pretty-print option', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', -- 2.43.0 --eEEy3EHc57lA8spa Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0005-Handle-pg_get_expr-default-args-in-system_functio.patch" ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql @ 2025-12-09 18:59 Mark Wong <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Mark Wong @ 2025-12-09 18:59 UTC (permalink / raw) Modernize pg_get_constraintdef to use proargdefaults to handle the optional pretty argument. --- src/backend/utils/adt/ruleutils.c | 17 ----------------- src/include/catalog/pg_proc.dat | 8 +++----- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index f2edf61f9a0..d83be8cf77d 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname) */ Datum pg_get_constraintdef(PG_FUNCTION_ARGS) -{ - Oid constraintId = PG_GETARG_OID(0); - int prettyFlags; - char *res; - - prettyFlags = PRETTYFLAG_INDENT; - - res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true); - - if (res == NULL) - PG_RETURN_NULL(); - - PG_RETURN_TEXT_P(string_to_text(res)); -} - -Datum -pg_get_constraintdef_ext(PG_FUNCTION_ARGS) { Oid constraintId = PG_GETARG_OID(0); bool pretty = PG_GETARG_BOOL(1); diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 6bf78edf535..7e452aa8c27 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -4006,9 +4006,6 @@ { oid => '1662', descr => 'trigger description', proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_triggerdef' }, -{ oid => '1387', descr => 'constraint description', - proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid', prosrc => 'pg_get_constraintdef' }, { oid => '1716', descr => 'deparse an encoded expression', proname => 'pg_get_expr', provolatile => 's', prorettype => 'text', proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' }, @@ -8578,9 +8575,10 @@ proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text', proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}', proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' }, -{ oid => '2508', descr => 'constraint description with pretty-print option', +{ oid => '2508', descr => 'constraint description', proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text', - proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' }, + proargtypes => 'oid bool', proargnames => '{constraint,pretty}', + proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' }, { oid => '6501', descr => 'get DDL to recreate a role', proname => 'pg_get_role_ddl', prorows => '10', provariadic => 'text', proisstrict => 'f', proretset => 't', provolatile => 's', -- 2.53.0 --iWwo79nqhOvOs5kf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v8-0005-Handle-pg_get_expr-default-args-in-system_functio.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 286+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 286+ messages in thread
end of thread, other threads:[~2026-04-17 18:34 UTC | newest] Thread overview: 286+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2022-04-04 18:49 [PATCH 07/11] possibility to dump session variables by pg_dump [email protected] <[email protected]> 2022-04-04 18:49 [PATCH v20220922 09/13] possibility to dump session variables by pg_dump [email protected] <[email protected]> 2022-04-04 18:49 [PATCH 07/11] possibility to dump session variables by pg_dump [email protected] <[email protected]> 2022-04-04 18:49 [PATCH v20220916 09/13] possibility to dump session variables by pg_dump [email protected] <[email protected]> 2022-04-04 18:49 [PATCH v20220916 09/13] possibility to dump session variables by pg_dump [email protected] <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v3 5/7] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8.1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v1 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v5 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v2 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v4 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2025-12-09 18:59 [PATCH v8 4/6] Handle pg_get_constraintdef default args in system_functions.sql Mark Wong <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox