When dumping function, append callback function attribute if needed.
Attribute 'DESCRIBE' is added by gpdb to describe
the name of a callback function. Currently pg_dump
does not handle this attribute.
@@ -8259,6 +8259,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
char *procost;
char *prorows;
char *lanname;
+ char *callbackfunc;
char *prodataaccess;
char *proexeclocation;
char *rettypename;
@@ -8298,7 +8299,8 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
"proiswindow, provolatile, proisstrict, prosecdef, "
"proconfig, procost, prorows, prodataaccess, "
"proexeclocation, "
- "(SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) as lanname "
+ "(SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) as lanname, "
+ "(SELECT procallback FROM pg_catalog.pg_proc_callback WHERE profnoid::pg_catalog.oid = oid) as callbackfunc "
"FROM pg_catalog.pg_proc "
"WHERE oid = '%u'::pg_catalog.oid",
finfo->dobj.catId.oid);
@@ -8317,7 +8319,8 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
"proiswindow, provolatile, proisstrict, prosecdef, "
"proconfig, procost, prorows, prodataaccess, "
"'a' as proexeclocation, "
- "(SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) as lanname "
+ "(SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) as lanname, "
+ "(SELECT procallback FROM pg_catalog.pg_proc_callback WHERE profnoid::pg_catalog.oid = oid) as callbackfunc "
"FROM pg_catalog.pg_proc "
"WHERE oid = '%u'::pg_catalog.oid",
finfo->dobj.catId.oid);
@@ -8331,7 +8334,8 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
"provolatile, proisstrict, prosecdef, "
"null as proconfig, 0 as procost, 0 as prorows, %s"
"'a' as proexeclocation, "
- "(SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) as lanname "
+ "(SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) as lanname, "
+ "(SELECT procallback FROM pg_catalog.pg_proc_callback WHERE profnoid::pg_catalog.oid = oid) as callbackfunc "
"FROM pg_catalog.pg_proc "
"WHERE oid = '%u'::pg_catalog.oid",
(isGE43 ? "prodataaccess, " : ""),
@@ -8377,6 +8381,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
procost = PQgetvalue(res, 0, PQfnumber(res, "procost"));
prorows = PQgetvalue(res, 0, PQfnumber(res, "prorows"));
lanname = PQgetvalue(res, 0, PQfnumber(res, "lanname"));
+ callbackfunc = PQgetvalue(res, 0, PQfnumber(res, "callbackfunc"));
prodataaccess = PQgetvalue(res, 0, PQfnumber(res, "prodataaccess"));
proexeclocation = PQgetvalue(res, 0, PQfnumber(res, "proexeclocation"));
@@ -8618,7 +8623,13 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
appendStringLiteralAH(q, pos, fout);
}
- appendPQExpBuffer(q, "\n %s;\n", asPart->data);
+ appendPQExpBuffer(q, "\n %s", asPart->data);
+
+ /* Append callback function */
+ if (callbackfunc && callbackfunc[0] != '\0')
+ appendPQExpBuffer(q, "\n WITH (describe = %s)", callbackfunc);
+
+ appendPQExpBuffer(q, ";\n");
appendPQExpBuffer(labelq, "FUNCTION %s", funcsig);
