On 2020-07-08 06:42, Fabien COELHO wrote:
What do you think about this patch to reorganize the existing code from that
old commit?
I think it is a definite further improvement.
Patch applies cleanly, compiles, global & pg_dump tap test ok, looks ok to
me.
Thanks. I have committed that, and attached is my original patch
adjusted to this newer style.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From cce4e241c12e3719f1f98703079eaf119452f20f Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Thu, 9 Jul 2020 16:03:30 +0200
Subject: [PATCH v3] pg_dump: Reorganize dumpFunc() and dumpAgg()
Similar to daa9fe8a5264a3f192efa5ddee8fb011ad9da365, instead of
repeating the almost same large query in each version branch, use one
query and add a few columns to the SELECT list depending on the
version. This saves a lot of duplication.
---
src/bin/pg_dump/pg_dump.c | 496 ++++++++++++--------------------------
1 file changed, 159 insertions(+), 337 deletions(-)
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 8bca147a33..370a9a77a9 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -11794,171 +11794,88 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
asPart = createPQExpBuffer();
/* Fetch function-specific details */
- if (fout->remoteVersion >= 120000)
- {
- /*
- * prosupport was added in 12
- */
+ appendPQExpBuffer(query,
+ "SELECT\n"
+ "proretset,\n"
+ "prosrc,\n"
+ "probin,\n"
+ "provolatile,\n"
+ "proisstrict,\n"
+ "prosecdef,\n"
+ "(SELECT lanname FROM
pg_catalog.pg_language WHERE oid = prolang) AS lanname,\n");
+
+ if (fout->remoteVersion >= 80300)
appendPQExpBuffer(query,
- "SELECT proretset, prosrc,
probin, "
-
"pg_catalog.pg_get_function_arguments(oid) AS funcargs, "
-
"pg_catalog.pg_get_function_identity_arguments(oid) AS funciargs, "
-
"pg_catalog.pg_get_function_result(oid) AS funcresult, "
- "array_to_string(protrftypes,
' ') AS protrftypes, "
- "prokind, provolatile,
proisstrict, prosecdef, "
- "proleakproof, proconfig,
procost, prorows, "
- "prosupport, proparallel, "
- "(SELECT lanname FROM
pg_catalog.pg_language WHERE oid = prolang) AS lanname "
- "FROM pg_catalog.pg_proc "
- "WHERE oid =
'%u'::pg_catalog.oid",
- finfo->dobj.catId.oid);
- }
- else if (fout->remoteVersion >= 110000)
- {
- /*
- * prokind was added in 11
- */
+ "proconfig,\n"
+ "procost,\n"
+ "prorows,\n");
+ else
appendPQExpBuffer(query,
- "SELECT proretset, prosrc,
probin, "
-
"pg_catalog.pg_get_function_arguments(oid) AS funcargs, "
-
"pg_catalog.pg_get_function_identity_arguments(oid) AS funciargs, "
-
"pg_catalog.pg_get_function_result(oid) AS funcresult, "
- "array_to_string(protrftypes,
' ') AS protrftypes, "
- "prokind, provolatile,
proisstrict, prosecdef, "
- "proleakproof, proconfig,
procost, prorows, "
- "'-' AS prosupport,
proparallel, "
- "(SELECT lanname FROM
pg_catalog.pg_language WHERE oid = prolang) AS lanname "
- "FROM pg_catalog.pg_proc "
- "WHERE oid =
'%u'::pg_catalog.oid",
- finfo->dobj.catId.oid);
- }
- else if (fout->remoteVersion >= 90600)
+ "null AS proconfig,\n"
+ "0 AS procost,\n"
+ "0 AS prorows,\n");
+
+ if (fout->remoteVersion >= 80400)
{
/*
- * proparallel was added in 9.6
+ * In 8.4 and up we rely on pg_get_function_arguments and
+ * pg_get_function_result instead of examining proallargtypes
etc.
*/
appendPQExpBuffer(query,
- "SELECT proretset, prosrc,
probin, "
-
"pg_catalog.pg_get_function_arguments(oid) AS funcargs, "
-
"pg_catalog.pg_get_function_identity_arguments(oid) AS funciargs, "
-
"pg_catalog.pg_get_function_result(oid) AS funcresult, "
- "array_to_string(protrftypes,
' ') AS protrftypes, "
- "CASE WHEN proiswindow THEN
'w' ELSE 'f' END AS prokind, "
- "provolatile, proisstrict,
prosecdef, "
- "proleakproof, proconfig,
procost, prorows, "
- "'-' AS prosupport,
proparallel, "
- "(SELECT lanname FROM
pg_catalog.pg_language WHERE oid = prolang) AS lanname "
- "FROM pg_catalog.pg_proc "
- "WHERE oid =
'%u'::pg_catalog.oid",
- finfo->dobj.catId.oid);
+
"pg_catalog.pg_get_function_arguments(oid) AS funcargs,\n"
+
"pg_catalog.pg_get_function_identity_arguments(oid) AS funciargs,\n"
+
"pg_catalog.pg_get_function_result(oid) AS funcresult,\n");
}
- else if (fout->remoteVersion >= 90500)
- {
- /*
- * protrftypes was added in 9.5
- */
+ else if (fout->remoteVersion >= 80100)
appendPQExpBuffer(query,
- "SELECT proretset, prosrc,
probin, "
-
"pg_catalog.pg_get_function_arguments(oid) AS funcargs, "
-
"pg_catalog.pg_get_function_identity_arguments(oid) AS funciargs, "
-
"pg_catalog.pg_get_function_result(oid) AS funcresult, "
- "array_to_string(protrftypes,
' ') AS protrftypes, "
- "CASE WHEN proiswindow THEN
'w' ELSE 'f' END AS prokind, "
- "provolatile, proisstrict,
prosecdef, "
- "proleakproof, proconfig,
procost, prorows, "
- "'-' AS prosupport, "
- "(SELECT lanname FROM
pg_catalog.pg_language WHERE oid = prolang) AS lanname "
- "FROM pg_catalog.pg_proc "
- "WHERE oid =
'%u'::pg_catalog.oid",
- finfo->dobj.catId.oid);
- }
- else if (fout->remoteVersion >= 90200)
- {
- /*
- * proleakproof was added in 9.2
- */
+ "proallargtypes,\n"
+ "proargmodes,\n"
+ "proargnames,\n");
+ else
appendPQExpBuffer(query,
- "SELECT proretset, prosrc,
probin, "
-
"pg_catalog.pg_get_function_arguments(oid) AS funcargs, "
-
"pg_catalog.pg_get_function_identity_arguments(oid) AS funciargs, "
-
"pg_catalog.pg_get_function_result(oid) AS funcresult, "
- "CASE WHEN proiswindow THEN
'w' ELSE 'f' END AS prokind, "
- "provolatile, proisstrict,
prosecdef, "
- "proleakproof, proconfig,
procost, prorows, "
- "'-' AS prosupport, "
- "(SELECT lanname FROM
pg_catalog.pg_language WHERE oid = prolang) AS lanname "
- "FROM pg_catalog.pg_proc "
- "WHERE oid =
'%u'::pg_catalog.oid",
- finfo->dobj.catId.oid);
- }
+ "null AS proallargtypes,\n"
+ "null AS proargmodes,\n"
+ "proargnames,\n");
+
+ if (fout->remoteVersion >= 90200)
+ appendPQExpBuffer(query,
+ "proleakproof,\n");
+ else
+ appendPQExpBuffer(query,
+ "false AS proleakproof,\n");
+
+ if (fout->remoteVersion >= 90500)
+ appendPQExpBuffer(query,
+ "array_to_string(protrftypes,
' ') AS protrftypes,\n");
+
+ if (fout->remoteVersion >= 90600)
+ appendPQExpBuffer(query,
+ "proparallel,\n");
+ else
+ appendPQExpBuffer(query,
+ "'u' AS proparallel,\n");
+
+ if (fout->remoteVersion >= 110000)
+ appendPQExpBuffer(query,
+ "prokind,\n");
else if (fout->remoteVersion >= 80400)
- {
- /*
- * In 8.4 and up we rely on pg_get_function_arguments and
- * pg_get_function_result instead of examining proallargtypes
etc.
- */
appendPQExpBuffer(query,
- "SELECT proretset, prosrc,
probin, "
-
"pg_catalog.pg_get_function_arguments(oid) AS funcargs, "
-
"pg_catalog.pg_get_function_identity_arguments(oid) AS funciargs, "
-
"pg_catalog.pg_get_function_result(oid) AS funcresult, "
- "CASE WHEN proiswindow THEN
'w' ELSE 'f' END AS prokind, "
- "provolatile, proisstrict,
prosecdef, "
- "false AS proleakproof, "
- " proconfig, procost,
prorows, "
- "'-' AS prosupport, "
- "(SELECT lanname FROM
pg_catalog.pg_language WHERE oid = prolang) AS lanname "
- "FROM pg_catalog.pg_proc "
- "WHERE oid =
'%u'::pg_catalog.oid",
- finfo->dobj.catId.oid);
- }
- else if (fout->remoteVersion >= 80300)
- {
+ "CASE WHEN proiswindow THEN
'w' ELSE 'f' END AS prokind,\n");
+ else
appendPQExpBuffer(query,
- "SELECT proretset, prosrc,
probin, "
- "proallargtypes, proargmodes,
proargnames, "
- "'f' AS prokind, "
- "provolatile, proisstrict,
prosecdef, "
- "false AS proleakproof, "
- "proconfig, procost, prorows,
"
- "'-' AS prosupport, "
- "(SELECT lanname FROM
pg_catalog.pg_language WHERE oid = prolang) AS lanname "
- "FROM pg_catalog.pg_proc "
- "WHERE oid =
'%u'::pg_catalog.oid",
- finfo->dobj.catId.oid);
- }
- else if (fout->remoteVersion >= 80100)
- {
+ "'f' AS prokind,\n");
+
+ if (fout->remoteVersion >= 120000)
appendPQExpBuffer(query,
- "SELECT proretset, prosrc,
probin, "
- "proallargtypes, proargmodes,
proargnames, "
- "'f' AS prokind, "
- "provolatile, proisstrict,
prosecdef, "
- "false AS proleakproof, "
- "null AS proconfig, 0 AS
procost, 0 AS prorows, "
- "'-' AS prosupport, "
- "(SELECT lanname FROM
pg_catalog.pg_language WHERE oid = prolang) AS lanname "
- "FROM pg_catalog.pg_proc "
- "WHERE oid =
'%u'::pg_catalog.oid",
- finfo->dobj.catId.oid);
- }
+ "prosupport\n");
else
- {
appendPQExpBuffer(query,
- "SELECT proretset, prosrc,
probin, "
- "null AS proallargtypes, "
- "null AS proargmodes, "
- "proargnames, "
- "'f' AS prokind, "
- "provolatile, proisstrict,
prosecdef, "
- "false AS proleakproof, "
- "null AS proconfig, 0 AS
procost, 0 AS prorows, "
- "'-' AS prosupport, "
- "(SELECT lanname FROM
pg_catalog.pg_language WHERE oid = prolang) AS lanname "
- "FROM pg_catalog.pg_proc "
- "WHERE oid =
'%u'::pg_catalog.oid",
- finfo->dobj.catId.oid);
- }
+ "'-' AS prosupport\n");
+
+ appendPQExpBuffer(query,
+ "FROM pg_catalog.pg_proc "
+ "WHERE oid = '%u'::pg_catalog.oid",
+ finfo->dobj.catId.oid);
res = ExecuteSqlQueryForSingleRow(fout, query->data);
@@ -11992,12 +11909,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
procost = PQgetvalue(res, 0, PQfnumber(res, "procost"));
prorows = PQgetvalue(res, 0, PQfnumber(res, "prorows"));
prosupport = PQgetvalue(res, 0, PQfnumber(res, "prosupport"));
-
- if (PQfnumber(res, "proparallel") != -1)
- proparallel = PQgetvalue(res, 0, PQfnumber(res, "proparallel"));
- else
- proparallel = NULL;
-
+ proparallel = PQgetvalue(res, 0, PQfnumber(res, "proparallel"));
lanname = PQgetvalue(res, 0, PQfnumber(res, "lanname"));
/*
@@ -12211,7 +12123,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
appendPQExpBuffer(q, " SUPPORT %s", prosupport);
}
- if (proparallel != NULL && proparallel[0] != PROPARALLEL_UNSAFE)
+ if (proparallel[0] != PROPARALLEL_UNSAFE)
{
if (proparallel[0] == PROPARALLEL_SAFE)
appendPQExpBufferStr(q, " PARALLEL SAFE");
@@ -13886,27 +13798,8 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
char *aggfullsig = NULL; /* full signature */
char *aggsig_tag;
PGresult *res;
- int i_aggtransfn;
- int i_aggfinalfn;
- int i_aggcombinefn;
- int i_aggserialfn;
- int i_aggdeserialfn;
- int i_aggmtransfn;
- int i_aggminvtransfn;
- int i_aggmfinalfn;
- int i_aggfinalextra;
- int i_aggmfinalextra;
- int i_aggfinalmodify;
- int i_aggmfinalmodify;
- int i_aggsortop;
- int i_aggkind;
- int i_aggtranstype;
- int i_aggtransspace;
- int i_aggmtranstype;
- int i_aggmtransspace;
int i_agginitval;
int i_aggminitval;
- int i_proparallel;
const char *aggtransfn;
const char *aggfinalfn;
const char *aggcombinefn;
@@ -13941,170 +13834,104 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
details = createPQExpBuffer();
/* Get aggregate-specific details */
+ appendPQExpBuffer(query,
+ "SELECT\n"
+ "aggtransfn,\n"
+ "aggfinalfn,\n"
+ "aggtranstype::pg_catalog.regtype,\n"
+ "agginitval,\n");
+
+ if (fout->remoteVersion >= 80100)
+ appendPQExpBuffer(query,
+ "aggsortop,\n");
+ else
+ appendPQExpBuffer(query,
+ "0 AS aggsortop,\n");
+
+ if (fout->remoteVersion >= 80400)
+ appendPQExpBuffer(query,
+
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
+
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
+
+ if (fout->remoteVersion >= 90400)
+ appendPQExpBuffer(query,
+ "aggkind,\n"
+ "aggmtransfn,\n"
+ "aggminvtransfn,\n"
+ "aggmfinalfn,\n"
+
"aggmtranstype::pg_catalog.regtype,\n"
+ "aggfinalextra,\n"
+ "aggmfinalextra,\n"
+ "aggtransspace,\n"
+ "aggmtransspace,\n"
+ "aggminitval,\n");
+ else
+ appendPQExpBuffer(query,
+ "'n' AS aggkind,\n"
+ "'-' AS aggmtransfn,\n"
+ "'-' AS aggminvtransfn,\n"
+ "'-' AS aggmfinalfn,\n"
+ "0 AS aggmtranstype,\n"
+ "false AS aggfinalextra,\n"
+ "false AS aggmfinalextra,\n"
+ "0 AS aggtransspace,\n"
+ "0 AS aggmtransspace,\n"
+ "NULL AS aggminitval,\n");
+
+ if (fout->remoteVersion >= 90600)
+ appendPQExpBuffer(query,
+ "aggcombinefn,\n"
+ "aggserialfn,\n"
+ "aggdeserialfn,\n"
+ "proparallel,\n");
+ else
+ appendPQExpBuffer(query,
+ "'-' AS aggcombinefn,\n"
+ "'-' AS aggserialfn,\n"
+ "'-' AS aggdeserialfn,\n"
+ "'u' AS proparallel,\n");
+
if (fout->remoteVersion >= 110000)
- {
- appendPQExpBuffer(query, "SELECT aggtransfn, "
- "aggfinalfn,
aggtranstype::pg_catalog.regtype, "
- "aggcombinefn, aggserialfn,
aggdeserialfn, aggmtransfn, "
- "aggminvtransfn, aggmfinalfn,
aggmtranstype::pg_catalog.regtype, "
- "aggfinalextra,
aggmfinalextra, "
- "aggfinalmodify,
aggmfinalmodify, "
- "aggsortop, "
- "aggkind, "
- "aggtransspace, agginitval, "
- "aggmtransspace, aggminitval,
"
-
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs, "
-
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs, "
- "p.proparallel "
- "FROM pg_catalog.pg_aggregate
a, pg_catalog.pg_proc p "
- "WHERE a.aggfnoid = p.oid "
- "AND p.oid =
'%u'::pg_catalog.oid",
-
agginfo->aggfn.dobj.catId.oid);
- }
- else if (fout->remoteVersion >= 90600)
- {
- appendPQExpBuffer(query, "SELECT aggtransfn, "
- "aggfinalfn,
aggtranstype::pg_catalog.regtype, "
- "aggcombinefn, aggserialfn,
aggdeserialfn, aggmtransfn, "
- "aggminvtransfn, aggmfinalfn,
aggmtranstype::pg_catalog.regtype, "
- "aggfinalextra,
aggmfinalextra, "
- "'0' AS aggfinalmodify, '0'
AS aggmfinalmodify, "
- "aggsortop, "
- "aggkind, "
- "aggtransspace, agginitval, "
- "aggmtransspace, aggminitval,
"
-
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs, "
-
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs, "
- "p.proparallel "
- "FROM pg_catalog.pg_aggregate
a, pg_catalog.pg_proc p "
- "WHERE a.aggfnoid = p.oid "
- "AND p.oid =
'%u'::pg_catalog.oid",
-
agginfo->aggfn.dobj.catId.oid);
- }
- else if (fout->remoteVersion >= 90400)
- {
- appendPQExpBuffer(query, "SELECT aggtransfn, "
- "aggfinalfn,
aggtranstype::pg_catalog.regtype, "
- "'-' AS aggcombinefn, '-' AS
aggserialfn, "
- "'-' AS aggdeserialfn,
aggmtransfn, aggminvtransfn, "
- "aggmfinalfn,
aggmtranstype::pg_catalog.regtype, "
- "aggfinalextra,
aggmfinalextra, "
- "'0' AS aggfinalmodify, '0'
AS aggmfinalmodify, "
- "aggsortop, "
- "aggkind, "
- "aggtransspace, agginitval, "
- "aggmtransspace, aggminitval,
"
-
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs, "
-
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs "
- "FROM pg_catalog.pg_aggregate
a, pg_catalog.pg_proc p "
- "WHERE a.aggfnoid = p.oid "
- "AND p.oid =
'%u'::pg_catalog.oid",
-
agginfo->aggfn.dobj.catId.oid);
- }
- else if (fout->remoteVersion >= 80400)
- {
- appendPQExpBuffer(query, "SELECT aggtransfn, "
- "aggfinalfn,
aggtranstype::pg_catalog.regtype, "
- "'-' AS aggcombinefn, '-' AS
aggserialfn, "
- "'-' AS aggdeserialfn, '-' AS
aggmtransfn, "
- "'-' AS aggminvtransfn, '-'
AS aggmfinalfn, "
- "0 AS aggmtranstype, false AS
aggfinalextra, "
- "false AS aggmfinalextra, "
- "'0' AS aggfinalmodify, '0'
AS aggmfinalmodify, "
- "aggsortop, "
- "'n' AS aggkind, "
- "0 AS aggtransspace,
agginitval, "
- "0 AS aggmtransspace, NULL AS
aggminitval, "
-
"pg_catalog.pg_get_function_arguments(p.oid) AS funcargs, "
-
"pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs "
- "FROM pg_catalog.pg_aggregate
a, pg_catalog.pg_proc p "
- "WHERE a.aggfnoid = p.oid "
- "AND p.oid =
'%u'::pg_catalog.oid",
-
agginfo->aggfn.dobj.catId.oid);
- }
- else if (fout->remoteVersion >= 80100)
- {
- appendPQExpBuffer(query, "SELECT aggtransfn, "
- "aggfinalfn,
aggtranstype::pg_catalog.regtype, "
- "'-' AS aggcombinefn, '-' AS
aggserialfn, "
- "'-' AS aggdeserialfn, '-' AS
aggmtransfn, "
- "'-' AS aggminvtransfn, '-'
AS aggmfinalfn, "
- "0 AS aggmtranstype, false AS
aggfinalextra, "
- "false AS aggmfinalextra, "
- "'0' AS aggfinalmodify, '0'
AS aggmfinalmodify, "
- "aggsortop, "
- "'n' AS aggkind, "
- "0 AS aggtransspace,
agginitval, "
- "0 AS aggmtransspace, NULL AS
aggminitval "
- "FROM pg_catalog.pg_aggregate
a, pg_catalog.pg_proc p "
- "WHERE a.aggfnoid = p.oid "
- "AND p.oid =
'%u'::pg_catalog.oid",
-
agginfo->aggfn.dobj.catId.oid);
- }
+ appendPQExpBuffer(query,
+ "aggfinalmodify,\n"
+ "aggmfinalmodify\n");
else
- {
- appendPQExpBuffer(query, "SELECT aggtransfn, "
- "aggfinalfn,
aggtranstype::pg_catalog.regtype, "
- "'-' AS aggcombinefn, '-' AS
aggserialfn, "
- "'-' AS aggdeserialfn, '-' AS
aggmtransfn, "
- "'-' AS aggminvtransfn, '-'
AS aggmfinalfn, "
- "0 AS aggmtranstype, false AS
aggfinalextra, "
- "false AS aggmfinalextra, "
- "'0' AS aggfinalmodify, '0'
AS aggmfinalmodify, "
- "0 AS aggsortop, "
- "'n' AS aggkind, "
- "0 AS aggtransspace,
agginitval, "
- "0 AS aggmtransspace, NULL AS
aggminitval "
- "FROM pg_catalog.pg_aggregate
a, pg_catalog.pg_proc p "
- "WHERE a.aggfnoid = p.oid "
- "AND p.oid =
'%u'::pg_catalog.oid",
-
agginfo->aggfn.dobj.catId.oid);
- }
+ appendPQExpBuffer(query,
+ "'0' AS aggfinalmodify,\n"
+ "'0' AS aggmfinalmodify\n");
+
+ appendPQExpBuffer(query,
+ "FROM pg_catalog.pg_aggregate a,
pg_catalog.pg_proc p "
+ "WHERE a.aggfnoid = p.oid "
+ "AND p.oid = '%u'::pg_catalog.oid",
+ agginfo->aggfn.dobj.catId.oid);
res = ExecuteSqlQueryForSingleRow(fout, query->data);
- i_aggtransfn = PQfnumber(res, "aggtransfn");
- i_aggfinalfn = PQfnumber(res, "aggfinalfn");
- i_aggcombinefn = PQfnumber(res, "aggcombinefn");
- i_aggserialfn = PQfnumber(res, "aggserialfn");
- i_aggdeserialfn = PQfnumber(res, "aggdeserialfn");
- i_aggmtransfn = PQfnumber(res, "aggmtransfn");
- i_aggminvtransfn = PQfnumber(res, "aggminvtransfn");
- i_aggmfinalfn = PQfnumber(res, "aggmfinalfn");
- i_aggfinalextra = PQfnumber(res, "aggfinalextra");
- i_aggmfinalextra = PQfnumber(res, "aggmfinalextra");
- i_aggfinalmodify = PQfnumber(res, "aggfinalmodify");
- i_aggmfinalmodify = PQfnumber(res, "aggmfinalmodify");
- i_aggsortop = PQfnumber(res, "aggsortop");
- i_aggkind = PQfnumber(res, "aggkind");
- i_aggtranstype = PQfnumber(res, "aggtranstype");
- i_aggtransspace = PQfnumber(res, "aggtransspace");
- i_aggmtranstype = PQfnumber(res, "aggmtranstype");
- i_aggmtransspace = PQfnumber(res, "aggmtransspace");
i_agginitval = PQfnumber(res, "agginitval");
i_aggminitval = PQfnumber(res, "aggminitval");
- i_proparallel = PQfnumber(res, "proparallel");
-
- aggtransfn = PQgetvalue(res, 0, i_aggtransfn);
- aggfinalfn = PQgetvalue(res, 0, i_aggfinalfn);
- aggcombinefn = PQgetvalue(res, 0, i_aggcombinefn);
- aggserialfn = PQgetvalue(res, 0, i_aggserialfn);
- aggdeserialfn = PQgetvalue(res, 0, i_aggdeserialfn);
- aggmtransfn = PQgetvalue(res, 0, i_aggmtransfn);
- aggminvtransfn = PQgetvalue(res, 0, i_aggminvtransfn);
- aggmfinalfn = PQgetvalue(res, 0, i_aggmfinalfn);
- aggfinalextra = (PQgetvalue(res, 0, i_aggfinalextra)[0] == 't');
- aggmfinalextra = (PQgetvalue(res, 0, i_aggmfinalextra)[0] == 't');
- aggfinalmodify = PQgetvalue(res, 0, i_aggfinalmodify)[0];
- aggmfinalmodify = PQgetvalue(res, 0, i_aggmfinalmodify)[0];
- aggsortop = PQgetvalue(res, 0, i_aggsortop);
- aggkind = PQgetvalue(res, 0, i_aggkind)[0];
- aggtranstype = PQgetvalue(res, 0, i_aggtranstype);
- aggtransspace = PQgetvalue(res, 0, i_aggtransspace);
- aggmtranstype = PQgetvalue(res, 0, i_aggmtranstype);
- aggmtransspace = PQgetvalue(res, 0, i_aggmtransspace);
+
+ aggtransfn = PQgetvalue(res, 0, PQfnumber(res, "aggtransfn"));
+ aggfinalfn = PQgetvalue(res, 0, PQfnumber(res, "aggfinalfn"));
+ aggcombinefn = PQgetvalue(res, 0, PQfnumber(res, "aggcombinefn"));
+ aggserialfn = PQgetvalue(res, 0, PQfnumber(res, "aggserialfn"));
+ aggdeserialfn = PQgetvalue(res, 0, PQfnumber(res, "aggdeserialfn"));
+ aggmtransfn = PQgetvalue(res, 0, PQfnumber(res, "aggmtransfn"));
+ aggminvtransfn = PQgetvalue(res, 0, PQfnumber(res, "aggminvtransfn"));
+ aggmfinalfn = PQgetvalue(res, 0, PQfnumber(res, "aggmfinalfn"));
+ aggfinalextra = (PQgetvalue(res, 0, PQfnumber(res, "aggfinalextra"))[0]
== 't');
+ aggmfinalextra = (PQgetvalue(res, 0, PQfnumber(res,
"aggmfinalextra"))[0] == 't');
+ aggfinalmodify = PQgetvalue(res, 0, PQfnumber(res,
"aggfinalmodify"))[0];
+ aggmfinalmodify = PQgetvalue(res, 0, PQfnumber(res,
"aggmfinalmodify"))[0];
+ aggsortop = PQgetvalue(res, 0, PQfnumber(res, "aggsortop"));
+ aggkind = PQgetvalue(res, 0, PQfnumber(res, "aggkind"))[0];
+ aggtranstype = PQgetvalue(res, 0, PQfnumber(res, "aggtranstype"));
+ aggtransspace = PQgetvalue(res, 0, PQfnumber(res, "aggtransspace"));
+ aggmtranstype = PQgetvalue(res, 0, PQfnumber(res, "aggmtranstype"));
+ aggmtransspace = PQgetvalue(res, 0, PQfnumber(res, "aggmtransspace"));
agginitval = PQgetvalue(res, 0, i_agginitval);
aggminitval = PQgetvalue(res, 0, i_aggminitval);
+ proparallel = PQgetvalue(res, 0, PQfnumber(res, "proparallel"));
if (fout->remoteVersion >= 80400)
{
@@ -14123,11 +13950,6 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
aggsig_tag = format_aggregate_signature(agginfo, fout, false);
- if (i_proparallel != -1)
- proparallel = PQgetvalue(res, 0, PQfnumber(res, "proparallel"));
- else
- proparallel = NULL;
-
/* identify default modify flag for aggkind (must match
DefineAggregate) */
defaultfinalmodify = (aggkind == AGGKIND_NORMAL) ? AGGMODIFY_READ_ONLY
: AGGMODIFY_READ_WRITE;
/* replace omitted flags for old versions */
@@ -14246,7 +14068,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
if (aggkind == AGGKIND_HYPOTHETICAL)
appendPQExpBufferStr(details, ",\n HYPOTHETICAL");
- if (proparallel != NULL && proparallel[0] != PROPARALLEL_UNSAFE)
+ if (proparallel[0] != PROPARALLEL_UNSAFE)
{
if (proparallel[0] == PROPARALLEL_SAFE)
appendPQExpBufferStr(details, ",\n PARALLEL = safe");
--
2.27.0