diff options
-rw-r--r-- | src/bin/pg_dump/pg_dump.c | 47 | ||||
-rw-r--r-- | src/bin/pg_dump/pg_dump.h | 1 | ||||
-rw-r--r-- | src/bin/pg_dump/pg_dump_sort.c | 23 |
3 files changed, 22 insertions, 49 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index d8284375bb2..31b86bb315d 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -3951,7 +3951,6 @@ getAggregates(Archive *fout, int *numAggs) int i_proargtypes; int i_rolname; int i_aggacl; - int i_proiargs; /* Make sure we are in proper schema */ selectSourceSchema(fout, "pg_catalog"); @@ -3961,12 +3960,11 @@ getAggregates(Archive *fout, int *numAggs) * rationale behind the filtering logic. */ - if (fout->remoteVersion >= 80400) + if (fout->remoteVersion >= 80200) { appendPQExpBuffer(query, "SELECT tableoid, oid, proname AS aggname, " "pronamespace AS aggnamespace, " "pronargs, proargtypes, " - "pg_catalog.pg_get_function_identity_arguments(oid) AS proiargs," "(%s proowner) AS rolname, " "proacl AS aggacl " "FROM pg_proc p " @@ -3984,28 +3982,12 @@ getAggregates(Archive *fout, int *numAggs) "deptype = 'e')"); appendPQExpBufferChar(query, ')'); } - else if (fout->remoteVersion >= 80200) - { - appendPQExpBuffer(query, "SELECT tableoid, oid, proname AS aggname, " - "pronamespace AS aggnamespace, " - "pronargs, proargtypes, " - "NULL::text AS proiargs," - "(%s proowner) AS rolname, " - "proacl AS aggacl " - "FROM pg_proc p " - "WHERE proisagg AND (" - "pronamespace != " - "(SELECT oid FROM pg_namespace " - "WHERE nspname = 'pg_catalog'))", - username_subquery); - } else if (fout->remoteVersion >= 70300) { appendPQExpBuffer(query, "SELECT tableoid, oid, proname AS aggname, " "pronamespace AS aggnamespace, " "CASE WHEN proargtypes[0] = 'pg_catalog.\"any\"'::pg_catalog.regtype THEN 0 ELSE 1 END AS pronargs, " "proargtypes, " - "NULL::text AS proiargs, " "(%s proowner) AS rolname, " "proacl AS aggacl " "FROM pg_proc " @@ -4020,7 +4002,6 @@ getAggregates(Archive *fout, int *numAggs) "0::oid AS aggnamespace, " "CASE WHEN aggbasetype = 0 THEN 0 ELSE 1 END AS pronargs, " "aggbasetype AS proargtypes, " - "NULL::text AS proiargs, " "(%s aggowner) AS rolname, " "'{=X}' AS aggacl " "FROM pg_aggregate " @@ -4036,7 +4017,6 @@ getAggregates(Archive *fout, int *numAggs) "0::oid AS aggnamespace, " "CASE WHEN aggbasetype = 0 THEN 0 ELSE 1 END AS pronargs, " "aggbasetype AS proargtypes, " - "NULL::text AS proiargs, " "(%s aggowner) AS rolname, " "'{=X}' AS aggacl " "FROM pg_aggregate " @@ -4060,7 +4040,6 @@ getAggregates(Archive *fout, int *numAggs) i_proargtypes = PQfnumber(res, "proargtypes"); i_rolname = PQfnumber(res, "rolname"); i_aggacl = PQfnumber(res, "aggacl"); - i_proiargs = PQfnumber(res, "proiargs"); for (i = 0; i < ntups; i++) { @@ -4080,7 +4059,6 @@ getAggregates(Archive *fout, int *numAggs) agginfo[i].aggfn.lang = InvalidOid; /* not currently interesting */ agginfo[i].aggfn.prorettype = InvalidOid; /* not saved */ agginfo[i].aggfn.proacl = pg_strdup(PQgetvalue(res, i, i_aggacl)); - agginfo[i].aggfn.proiargs = pg_strdup(PQgetvalue(res, i, i_proiargs)); agginfo[i].aggfn.nargs = atoi(PQgetvalue(res, i, i_pronargs)); if (agginfo[i].aggfn.nargs == 0) agginfo[i].aggfn.argtypes = NULL; @@ -4132,7 +4110,6 @@ getFuncs(Archive *fout, int *numFuncs) int i_proargtypes; int i_prorettype; int i_proacl; - int i_proiargs; /* Make sure we are in proper schema */ selectSourceSchema(fout, "pg_catalog"); @@ -4153,13 +4130,12 @@ getFuncs(Archive *fout, int *numFuncs) * doesn't have; otherwise we might not get creation ordering correct. */ - if (fout->remoteVersion >= 80400) + if (fout->remoteVersion >= 70300) { appendPQExpBuffer(query, "SELECT tableoid, oid, proname, prolang, " "pronargs, proargtypes, prorettype, proacl, " "pronamespace, " - "pg_catalog.pg_get_function_identity_arguments(oid) AS proiargs," "(%s proowner) AS rolname " "FROM pg_proc p " "WHERE NOT proisagg AND (" @@ -4181,21 +4157,6 @@ getFuncs(Archive *fout, int *numFuncs) "deptype = 'e')"); appendPQExpBufferChar(query, ')'); } - else if (fout->remoteVersion >= 70300) - { - appendPQExpBuffer(query, - "SELECT tableoid, oid, proname, prolang, " - "pronargs, proargtypes, prorettype, proacl, " - "pronamespace, " - "NULL::text AS proiargs," - "(%s proowner) AS rolname " - "FROM pg_proc p " - "WHERE NOT proisagg AND (" - "pronamespace != " - "(SELECT oid FROM pg_namespace " - "WHERE nspname = 'pg_catalog'))", - username_subquery); - } else if (fout->remoteVersion >= 70100) { appendPQExpBuffer(query, @@ -4203,7 +4164,6 @@ getFuncs(Archive *fout, int *numFuncs) "pronargs, proargtypes, prorettype, " "'{=X}' AS proacl, " "0::oid AS pronamespace, " - "NULL::text AS proiargs," "(%s proowner) AS rolname " "FROM pg_proc " "WHERE pg_proc.oid > '%u'::oid", @@ -4220,7 +4180,6 @@ getFuncs(Archive *fout, int *numFuncs) "pronargs, proargtypes, prorettype, " "'{=X}' AS proacl, " "0::oid AS pronamespace, " - "NULL::text AS proiargs," "(%s proowner) AS rolname " "FROM pg_proc " "where pg_proc.oid > '%u'::oid", @@ -4246,7 +4205,6 @@ getFuncs(Archive *fout, int *numFuncs) i_proargtypes = PQfnumber(res, "proargtypes"); i_prorettype = PQfnumber(res, "prorettype"); i_proacl = PQfnumber(res, "proacl"); - i_proiargs = PQfnumber(res, "proiargs"); for (i = 0; i < ntups; i++) { @@ -4262,7 +4220,6 @@ getFuncs(Archive *fout, int *numFuncs) finfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname)); finfo[i].lang = atooid(PQgetvalue(res, i, i_prolang)); finfo[i].prorettype = atooid(PQgetvalue(res, i, i_prorettype)); - finfo[i].proiargs = pg_strdup(PQgetvalue(res, i, i_proiargs)); finfo[i].proacl = pg_strdup(PQgetvalue(res, i, i_proacl)); finfo[i].nargs = atoi(PQgetvalue(res, i, i_pronargs)); if (finfo[i].nargs == 0) diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index d1841875807..da603744847 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -184,7 +184,6 @@ typedef struct _funcInfo Oid *argtypes; Oid prorettype; char *proacl; - char *proiargs; } FuncInfo; /* AggInfo is a superset of FuncInfo */ diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c index f0caa6b6599..6d970dd8999 100644 --- a/src/bin/pg_dump/pg_dump_sort.c +++ b/src/bin/pg_dump/pg_dump_sort.c @@ -287,13 +287,30 @@ DOTypeNameCompare(const void *p1, const void *p2) { FuncInfo *fobj1 = *(FuncInfo *const *) p1; FuncInfo *fobj2 = *(FuncInfo *const *) p2; + int i; cmpval = fobj1->nargs - fobj2->nargs; if (cmpval != 0) return cmpval; - cmpval = strcmp(fobj1->proiargs, fobj2->proiargs); - if (cmpval != 0) - return cmpval; + for (i = 0; i < fobj1->nargs; i++) + { + TypeInfo *argtype1 = findTypeByOid(fobj1->argtypes[i]); + TypeInfo *argtype2 = findTypeByOid(fobj2->argtypes[i]); + + if (argtype1 && argtype2) + { + if (argtype1->dobj.namespace && argtype2->dobj.namespace) + { + cmpval = strcmp(argtype1->dobj.namespace->dobj.name, + argtype2->dobj.namespace->dobj.name); + if (cmpval != 0) + return cmpval; + } + cmpval = strcmp(argtype1->dobj.name, argtype2->dobj.name); + if (cmpval != 0) + return cmpval; + } + } } else if (obj1->objType == DO_OPERATOR) { |