- Support for iscachable when dumping functions
authorPhilip Warner <pjw@rhyme.com.au>
Mon, 7 Aug 2000 12:32:54 +0000 (12:32 +0000)
committerPhilip Warner <pjw@rhyme.com.au>
Mon, 7 Aug 2000 12:32:54 +0000 (12:32 +0000)
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.h

index 6054fafd6d2e5cebdee7d09edf4e17b3a763bfb9..24d6d11044c70b18504ac62575a0e0091970aa0c 100644 (file)
@@ -1714,13 +1714,15 @@ getFuncs(int *numFuncs)
        int                     i_proretset;
        int                     i_prosrc;
        int                     i_probin;
+       int                     i_iscachable;
        int                     i_usename;
 
        /* find all user-defined funcs */
 
        appendPQExpBuffer(query,
                   "SELECT pg_proc.oid, proname, prolang, pronargs, prorettype, "
-                                         "proretset, proargtypes, prosrc, probin, usename "
+                                         "proretset, proargtypes, prosrc, probin, usename, "
+                                         "proiscachable "
                                          "from pg_proc, pg_user "
                                 "where pg_proc.oid > '%u'::oid and proowner = usesysid",
                                          g_last_builtin_oid);
@@ -1751,6 +1753,7 @@ getFuncs(int *numFuncs)
        i_proretset = PQfnumber(res, "proretset");
        i_prosrc = PQfnumber(res, "prosrc");
        i_probin = PQfnumber(res, "probin");
+       i_iscachable = PQfnumber(res, "proiscachable");
        i_usename = PQfnumber(res, "usename");
 
        for (i = 0; i < ntups; i++)
@@ -1766,6 +1769,7 @@ getFuncs(int *numFuncs)
                finfo[i].nargs = atoi(PQgetvalue(res, i, i_pronargs));
                finfo[i].lang = atoi(PQgetvalue(res, i, i_prolang));
                finfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
+               finfo[i].iscachable = (strcmp(PQgetvalue(res, i, i_iscachable),"t") == 0);
                if (finfo[i].nargs < 0 || finfo[i].nargs > FUNC_MAX_ARGS)
                {
                        fprintf(stderr, "failed sanity check: %s has %d args\n",
@@ -2923,11 +2927,18 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i,
 
        resetPQExpBuffer(q);
        appendPQExpBuffer(q, "CREATE FUNCTION %s ", fn->data );
-       appendPQExpBuffer(q, "RETURNS %s%s %s LANGUAGE '%s';\n",
+       appendPQExpBuffer(q, "RETURNS %s%s %s LANGUAGE '%s'",
                                          (finfo[i].retset) ? " SETOF " : "",
                                          fmtId(findTypeByOid(tinfo, numTypes, finfo[i].prorettype), false),
                                          asPart->data, func_lang);
 
+       if (finfo[i].iscachable) /* OR in new attrs here */
+       {
+               appendPQExpBuffer(q, " WITH (iscachable)");
+       }
+
+       appendPQExpBuffer(q, ";\n");
+
        ArchiveEntry(fout, finfo[i].oid, fn->data, "FUNCTION", NULL, q->data, delqry->data,
                                        "", finfo[i].usename, NULL, NULL);
 
index 7edb9d9c599b149373a81a65f6774e9b5dcdec07..ee4db31a51d433648456964ce72451f97e5b636e 100644 (file)
@@ -62,6 +62,7 @@ typedef struct _funcInfo
        char       *prosrc;
        char       *probin;
        char       *usename;
+       int                     iscachable;             /* Attr */
        int                     dumped;                 /* 1 if already dumped */
 } FuncInfo;