Skip to content

Commit 0e0832b

Browse files
committed
Back-patch fix to make pg_dump dump 'iscachable' flag for functions.
1 parent de3e018 commit 0e0832b

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
*
2424
* IDENTIFICATION
25-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.147 2000/04/14 01:34:24 tgl Exp $
25+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.147.2.1 2000/09/23 23:36:17 tgl Exp $
2626
*
2727
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
2828
*
@@ -1456,13 +1456,15 @@ getFuncs(int *numFuncs)
14561456
int i_proretset;
14571457
int i_prosrc;
14581458
int i_probin;
1459+
int i_iscachable;
14591460
int i_usename;
14601461

14611462
/* find all user-defined funcs */
14621463

14631464
appendPQExpBuffer(query,
14641465
"SELECT pg_proc.oid, proname, prolang, pronargs, prorettype, "
1465-
"proretset, proargtypes, prosrc, probin, usename "
1466+
"proretset, proargtypes, prosrc, probin, usename, "
1467+
"proiscachable "
14661468
"from pg_proc, pg_user "
14671469
"where pg_proc.oid > '%u'::oid and proowner = usesysid",
14681470
g_last_builtin_oid);
@@ -1492,6 +1494,7 @@ getFuncs(int *numFuncs)
14921494
i_proretset = PQfnumber(res, "proretset");
14931495
i_prosrc = PQfnumber(res, "prosrc");
14941496
i_probin = PQfnumber(res, "probin");
1497+
i_iscachable = PQfnumber(res, "proiscachable");
14951498
i_usename = PQfnumber(res, "usename");
14961499

14971500
for (i = 0; i < ntups; i++)
@@ -1507,6 +1510,7 @@ getFuncs(int *numFuncs)
15071510
finfo[i].nargs = atoi(PQgetvalue(res, i, i_pronargs));
15081511
finfo[i].lang = atoi(PQgetvalue(res, i, i_prolang));
15091512
finfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
1513+
finfo[i].iscachable = (strcmp(PQgetvalue(res, i, i_iscachable),"t") == 0);
15101514
if (finfo[i].nargs < 0 || finfo[i].nargs > FUNC_MAX_ARGS)
15111515
{
15121516
fprintf(stderr, "failed sanity check: %s has %d args\n",
@@ -2663,11 +2667,18 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i,
26632667
(j > 0) ? "," : "",
26642668
fmtId(typname, false));
26652669
}
2666-
appendPQExpBuffer(q, " ) RETURNS %s%s AS '%s' LANGUAGE '%s';\n",
2670+
appendPQExpBuffer(q, " ) RETURNS %s%s AS '%s' LANGUAGE '%s'",
26672671
(finfo[i].retset) ? " SETOF " : "",
26682672
fmtId(findTypeByOid(tinfo, numTypes, finfo[i].prorettype), false),
26692673
func_def, func_lang);
26702674

2675+
if (finfo[i].iscachable) /* OR in new attrs here */
2676+
{
2677+
appendPQExpBuffer(q, " WITH (iscachable)");
2678+
}
2679+
2680+
appendPQExpBuffer(q, ";\n");
2681+
26712682
fputs(q->data, fout);
26722683

26732684
/*** Dump Function Comments ***/

src/bin/pg_dump/pg_dump.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: pg_dump.h,v 1.48 2000/04/12 17:16:15 momjian Exp $
9+
* $Id: pg_dump.h,v 1.48.2.1 2000/09/23 23:36:17 tgl Exp $
1010
*
1111
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
1212
*
@@ -61,6 +61,7 @@ typedef struct _funcInfo
6161
char *prosrc;
6262
char *probin;
6363
char *usename;
64+
int iscachable; /* Attr */
6465
int dumped; /* 1 if already dumped */
6566
} FuncInfo;
6667

0 commit comments

Comments
 (0)