* strings are the work of aclitemout(), it should be OK in practice.
* Besides, a false mismatch will just cause the output to be a little
* more verbose than it really needed to be.
- *
- * (If we weren't given a base ACL, this stanza winds up with all the
- * ACL's items in grantitems and nothing in revokeitems. It's not worth
- * special-casing that.)
*/
grantitems = (char **) pg_malloc(naclitems * sizeof(char *));
for (i = 0; i < naclitems; i++)
secondsql = createPQExpBuffer();
/*
- * If we weren't given baseacls information, we just revoke everything and
- * then grant what's listed in the ACL. This avoids having to embed
- * detailed knowledge about what the defaults are/were, and it's not very
- * expensive since servers lacking acldefault() are now rare.
- *
- * Otherwise, we need only revoke what's listed in revokeitems.
+ * Build REVOKE statements for ACLs listed in revokeitems[].
*/
- if (baseacls == NULL || *baseacls == '\0')
+ for (i = 0; i < nrevokeitems; i++)
{
- /* We assume the old defaults only involved the owner and PUBLIC */
- appendPQExpBuffer(firstsql, "%sREVOKE ALL", prefix);
- if (subname)
- appendPQExpBuffer(firstsql, "(%s)", subname);
- appendPQExpBuffer(firstsql, " ON %s ", type);
- if (nspname && *nspname)
- appendPQExpBuffer(firstsql, "%s.", fmtId(nspname));
- appendPQExpBuffer(firstsql, "%s FROM PUBLIC;\n", name);
- if (owner)
+ if (!parseAclItem(revokeitems[i],
+ type, name, subname, remoteVersion,
+ grantee, grantor, privs, NULL))
{
- appendPQExpBuffer(firstsql, "%sREVOKE ALL", prefix);
- if (subname)
- appendPQExpBuffer(firstsql, "(%s)", subname);
- appendPQExpBuffer(firstsql, " ON %s ", type);
- if (nspname && *nspname)
- appendPQExpBuffer(firstsql, "%s.", fmtId(nspname));
- appendPQExpBuffer(firstsql, "%s FROM %s;\n", name, fmtId(owner));
+ ok = false;
+ break;
}
- }
- else
- {
- /* Scan individual REVOKE ACL items */
- for (i = 0; i < nrevokeitems; i++)
- {
- if (!parseAclItem(revokeitems[i],
- type, name, subname, remoteVersion,
- grantee, grantor, privs, NULL))
- {
- ok = false;
- break;
- }
- if (privs->len > 0)
- {
- appendPQExpBuffer(firstsql, "%sREVOKE %s ON %s ",
- prefix, privs->data, type);
- if (nspname && *nspname)
- appendPQExpBuffer(firstsql, "%s.", fmtId(nspname));
- appendPQExpBuffer(firstsql, "%s FROM ", name);
- if (grantee->len == 0)
- appendPQExpBufferStr(firstsql, "PUBLIC;\n");
- else
- appendPQExpBuffer(firstsql, "%s;\n",
- fmtId(grantee->data));
- }
+ if (privs->len > 0)
+ {
+ appendPQExpBuffer(firstsql, "%sREVOKE %s ON %s ",
+ prefix, privs->data, type);
+ if (nspname && *nspname)
+ appendPQExpBuffer(firstsql, "%s.", fmtId(nspname));
+ appendPQExpBuffer(firstsql, "%s FROM ", name);
+ if (grantee->len == 0)
+ appendPQExpBufferStr(firstsql, "PUBLIC;\n");
+ else
+ appendPQExpBuffer(firstsql, "%s;\n",
+ fmtId(grantee->data));
}
}
char *funcargs;
char *funciargs;
char *funcresult;
- char *proallargtypes;
- char *proargmodes;
- char *proargnames;
char *protrftypes;
char *prokind;
char *provolatile;
char *prosupport;
char *proparallel;
char *lanname;
- int nallargs;
- char **allargtypes = NULL;
- char **argmodes = NULL;
- char **argnames = NULL;
char **configitems = NULL;
int nconfigitems = 0;
const char *keyword;
if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query,
"array_to_string(protrftypes, ' ') AS protrftypes,\n");
+ else
+ appendPQExpBufferStr(query,
+ "NULL AS protrftypes,\n");
if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query,
funcargs = PQgetvalue(res, 0, PQfnumber(res, "funcargs"));
funciargs = PQgetvalue(res, 0, PQfnumber(res, "funciargs"));
funcresult = PQgetvalue(res, 0, PQfnumber(res, "funcresult"));
- proallargtypes = proargmodes = proargnames = NULL;
- if (PQfnumber(res, "protrftypes") != -1)
- protrftypes = PQgetvalue(res, 0, PQfnumber(res, "protrftypes"));
- else
- protrftypes = NULL;
+ protrftypes = PQgetvalue(res, 0, PQfnumber(res, "protrftypes"));
prokind = PQgetvalue(res, 0, PQfnumber(res, "prokind"));
provolatile = PQgetvalue(res, 0, PQfnumber(res, "provolatile"));
proisstrict = PQgetvalue(res, 0, PQfnumber(res, "proisstrict"));
appendStringLiteralDQ(asPart, prosrc, NULL);
}
- nallargs = finfo->nargs; /* unless we learn different from allargs */
-
- if (proallargtypes && *proallargtypes)
- {
- int nitems = 0;
-
- if (!parsePGArray(proallargtypes, &allargtypes, &nitems) ||
- nitems < finfo->nargs)
- {
- pg_log_warning("could not parse %s array", "proallargtypes");
- if (allargtypes)
- free(allargtypes);
- allargtypes = NULL;
- }
- else
- nallargs = nitems;
- }
-
- if (proargmodes && *proargmodes)
- {
- int nitems = 0;
-
- if (!parsePGArray(proargmodes, &argmodes, &nitems) ||
- nitems != nallargs)
- {
- pg_log_warning("could not parse %s array", "proargmodes");
- if (argmodes)
- free(argmodes);
- argmodes = NULL;
- }
- }
-
- if (proargnames && *proargnames)
- {
- int nitems = 0;
-
- if (!parsePGArray(proargnames, &argnames, &nitems) ||
- nitems != nallargs)
- {
- pg_log_warning("could not parse %s array", "proargnames");
- if (argnames)
- free(argnames);
- argnames = NULL;
- }
- }
-
- if (proconfig && *proconfig)
+ if (*proconfig)
{
if (!parsePGArray(proconfig, &configitems, &nconfigitems))
fatal("could not parse %s array", "proconfig");
appendPQExpBuffer(q, "\n LANGUAGE %s", fmtId(lanname));
- if (protrftypes != NULL && strcmp(protrftypes, "") != 0)
+ if (*protrftypes)
{
Oid *typeids = palloc(FUNC_MAX_ARGS * sizeof(Oid));
int i;
free(funcfullsig);
free(funcsig_tag);
free(qual_funcsig);
- if (allargtypes)
- free(allargtypes);
- if (argmodes)
- free(argmodes);
- if (argnames)
- free(argnames);
if (configitems)
free(configitems);
}