1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-03 22:24:49 +03:00

Remove some more dead code in pg_dump.

Coverity complained that parts of dumpFunc() and buildACLCommands()
were now unreachable, as indeed they are.  Remove 'em.

In passing, make dumpFunc's handling of protrftypes less gratuitously
different from other fields.
This commit is contained in:
Tom Lane 2021-12-19 17:18:34 -05:00
parent 22592e10b4
commit b1c169caf0
2 changed files with 25 additions and 119 deletions

View File

@ -122,10 +122,6 @@ buildACLCommands(const char *name, const char *subname, const char *nspname,
* strings are the work of aclitemout(), it should be OK in practice. * 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 * Besides, a false mismatch will just cause the output to be a little
* more verbose than it really needed to be. * 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 *)); grantitems = (char **) pg_malloc(naclitems * sizeof(char *));
for (i = 0; i < naclitems; i++) for (i = 0; i < naclitems; i++)
@ -173,37 +169,8 @@ buildACLCommands(const char *name, const char *subname, const char *nspname,
secondsql = createPQExpBuffer(); secondsql = createPQExpBuffer();
/* /*
* If we weren't given baseacls information, we just revoke everything and * Build REVOKE statements for ACLs listed in revokeitems[].
* 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.
*/ */
if (baseacls == NULL || *baseacls == '\0')
{
/* 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)
{
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));
}
}
else
{
/* Scan individual REVOKE ACL items */
for (i = 0; i < nrevokeitems; i++) for (i = 0; i < nrevokeitems; i++)
{ {
if (!parseAclItem(revokeitems[i], if (!parseAclItem(revokeitems[i],
@ -228,7 +195,6 @@ buildACLCommands(const char *name, const char *subname, const char *nspname,
fmtId(grantee->data)); fmtId(grantee->data));
} }
} }
}
/* /*
* At this point we have issued REVOKE statements for all initial and * At this point we have issued REVOKE statements for all initial and

View File

@ -11305,9 +11305,6 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
char *funcargs; char *funcargs;
char *funciargs; char *funciargs;
char *funcresult; char *funcresult;
char *proallargtypes;
char *proargmodes;
char *proargnames;
char *protrftypes; char *protrftypes;
char *prokind; char *prokind;
char *provolatile; char *provolatile;
@ -11320,10 +11317,6 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
char *prosupport; char *prosupport;
char *proparallel; char *proparallel;
char *lanname; char *lanname;
int nallargs;
char **allargtypes = NULL;
char **argmodes = NULL;
char **argnames = NULL;
char **configitems = NULL; char **configitems = NULL;
int nconfigitems = 0; int nconfigitems = 0;
const char *keyword; const char *keyword;
@ -11364,6 +11357,9 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
if (fout->remoteVersion >= 90500) if (fout->remoteVersion >= 90500)
appendPQExpBufferStr(query, appendPQExpBufferStr(query,
"array_to_string(protrftypes, ' ') AS protrftypes,\n"); "array_to_string(protrftypes, ' ') AS protrftypes,\n");
else
appendPQExpBufferStr(query,
"NULL AS protrftypes,\n");
if (fout->remoteVersion >= 90600) if (fout->remoteVersion >= 90600)
appendPQExpBufferStr(query, appendPQExpBufferStr(query,
@ -11425,11 +11421,7 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
funcargs = PQgetvalue(res, 0, PQfnumber(res, "funcargs")); funcargs = PQgetvalue(res, 0, PQfnumber(res, "funcargs"));
funciargs = PQgetvalue(res, 0, PQfnumber(res, "funciargs")); funciargs = PQgetvalue(res, 0, PQfnumber(res, "funciargs"));
funcresult = PQgetvalue(res, 0, PQfnumber(res, "funcresult")); funcresult = PQgetvalue(res, 0, PQfnumber(res, "funcresult"));
proallargtypes = proargmodes = proargnames = NULL;
if (PQfnumber(res, "protrftypes") != -1)
protrftypes = PQgetvalue(res, 0, PQfnumber(res, "protrftypes")); protrftypes = PQgetvalue(res, 0, PQfnumber(res, "protrftypes"));
else
protrftypes = NULL;
prokind = PQgetvalue(res, 0, PQfnumber(res, "prokind")); prokind = PQgetvalue(res, 0, PQfnumber(res, "prokind"));
provolatile = PQgetvalue(res, 0, PQfnumber(res, "provolatile")); provolatile = PQgetvalue(res, 0, PQfnumber(res, "provolatile"));
proisstrict = PQgetvalue(res, 0, PQfnumber(res, "proisstrict")); proisstrict = PQgetvalue(res, 0, PQfnumber(res, "proisstrict"));
@ -11479,53 +11471,7 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
appendStringLiteralDQ(asPart, prosrc, NULL); appendStringLiteralDQ(asPart, prosrc, NULL);
} }
nallargs = finfo->nargs; /* unless we learn different from allargs */ if (*proconfig)
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 (!parsePGArray(proconfig, &configitems, &nconfigitems)) if (!parsePGArray(proconfig, &configitems, &nconfigitems))
fatal("could not parse %s array", "proconfig"); fatal("could not parse %s array", "proconfig");
@ -11571,7 +11517,7 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
appendPQExpBuffer(q, "\n LANGUAGE %s", fmtId(lanname)); appendPQExpBuffer(q, "\n LANGUAGE %s", fmtId(lanname));
if (protrftypes != NULL && strcmp(protrftypes, "") != 0) if (*protrftypes)
{ {
Oid *typeids = palloc(FUNC_MAX_ARGS * sizeof(Oid)); Oid *typeids = palloc(FUNC_MAX_ARGS * sizeof(Oid));
int i; int i;
@ -11749,12 +11695,6 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
free(funcfullsig); free(funcfullsig);
free(funcsig_tag); free(funcsig_tag);
free(qual_funcsig); free(qual_funcsig);
if (allargtypes)
free(allargtypes);
if (argmodes)
free(argmodes);
if (argnames)
free(argnames);
if (configitems) if (configitems)
free(configitems); free(configitems);
} }