Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb1c169c

Browse files
committed
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 gratuitouslydifferent from other fields.
1 parent22592e1 commitb1c169c

File tree

2 files changed

+25
-119
lines changed

2 files changed

+25
-119
lines changed

‎src/bin/pg_dump/dumputils.c

Lines changed: 19 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,6 @@ buildACLCommands(const char *name, const char *subname, const char *nspname,
122122
* strings are the work of aclitemout(), it should be OK in practice.
123123
* Besides, a false mismatch will just cause the output to be a little
124124
* more verbose than it really needed to be.
125-
*
126-
* (If we weren't given a base ACL, this stanza winds up with all the
127-
* ACL's items in grantitems and nothing in revokeitems. It's not worth
128-
* special-casing that.)
129125
*/
130126
grantitems= (char**)pg_malloc(naclitems*sizeof(char*));
131127
for (i=0;i<naclitems;i++)
@@ -173,60 +169,30 @@ buildACLCommands(const char *name, const char *subname, const char *nspname,
173169
secondsql=createPQExpBuffer();
174170

175171
/*
176-
* If we weren't given baseacls information, we just revoke everything and
177-
* then grant what's listed in the ACL. This avoids having to embed
178-
* detailed knowledge about what the defaults are/were, and it's not very
179-
* expensive since servers lacking acldefault() are now rare.
180-
*
181-
* Otherwise, we need only revoke what's listed in revokeitems.
172+
* Build REVOKE statements for ACLs listed in revokeitems[].
182173
*/
183-
if (baseacls==NULL||*baseacls=='\0')
174+
for (i=0;i<nrevokeitems;i++)
184175
{
185-
/* We assume the old defaults only involved the owner and PUBLIC */
186-
appendPQExpBuffer(firstsql,"%sREVOKE ALL",prefix);
187-
if (subname)
188-
appendPQExpBuffer(firstsql,"(%s)",subname);
189-
appendPQExpBuffer(firstsql," ON %s ",type);
190-
if (nspname&&*nspname)
191-
appendPQExpBuffer(firstsql,"%s.",fmtId(nspname));
192-
appendPQExpBuffer(firstsql,"%s FROM PUBLIC;\n",name);
193-
if (owner)
176+
if (!parseAclItem(revokeitems[i],
177+
type,name,subname,remoteVersion,
178+
grantee,grantor,privs,NULL))
194179
{
195-
appendPQExpBuffer(firstsql,"%sREVOKE ALL",prefix);
196-
if (subname)
197-
appendPQExpBuffer(firstsql,"(%s)",subname);
198-
appendPQExpBuffer(firstsql," ON %s ",type);
199-
if (nspname&&*nspname)
200-
appendPQExpBuffer(firstsql,"%s.",fmtId(nspname));
201-
appendPQExpBuffer(firstsql,"%s FROM %s;\n",name,fmtId(owner));
180+
ok= false;
181+
break;
202182
}
203-
}
204-
else
205-
{
206-
/* Scan individual REVOKE ACL items */
207-
for (i=0;i<nrevokeitems;i++)
208-
{
209-
if (!parseAclItem(revokeitems[i],
210-
type,name,subname,remoteVersion,
211-
grantee,grantor,privs,NULL))
212-
{
213-
ok= false;
214-
break;
215-
}
216183

217-
if (privs->len>0)
218-
{
219-
appendPQExpBuffer(firstsql,"%sREVOKE %s ON %s ",
220-
prefix,privs->data,type);
221-
if (nspname&&*nspname)
222-
appendPQExpBuffer(firstsql,"%s.",fmtId(nspname));
223-
appendPQExpBuffer(firstsql,"%s FROM ",name);
224-
if (grantee->len==0)
225-
appendPQExpBufferStr(firstsql,"PUBLIC;\n");
226-
else
227-
appendPQExpBuffer(firstsql,"%s;\n",
228-
fmtId(grantee->data));
229-
}
184+
if (privs->len>0)
185+
{
186+
appendPQExpBuffer(firstsql,"%sREVOKE %s ON %s ",
187+
prefix,privs->data,type);
188+
if (nspname&&*nspname)
189+
appendPQExpBuffer(firstsql,"%s.",fmtId(nspname));
190+
appendPQExpBuffer(firstsql,"%s FROM ",name);
191+
if (grantee->len==0)
192+
appendPQExpBufferStr(firstsql,"PUBLIC;\n");
193+
else
194+
appendPQExpBuffer(firstsql,"%s;\n",
195+
fmtId(grantee->data));
230196
}
231197
}
232198

‎src/bin/pg_dump/pg_dump.c

Lines changed: 6 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -11305,9 +11305,6 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
1130511305
char *funcargs;
1130611306
char *funciargs;
1130711307
char *funcresult;
11308-
char *proallargtypes;
11309-
char *proargmodes;
11310-
char *proargnames;
1131111308
char *protrftypes;
1131211309
char *prokind;
1131311310
char *provolatile;
@@ -11320,10 +11317,6 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
1132011317
char *prosupport;
1132111318
char *proparallel;
1132211319
char *lanname;
11323-
intnallargs;
11324-
char **allargtypes = NULL;
11325-
char **argmodes = NULL;
11326-
char **argnames = NULL;
1132711320
char **configitems = NULL;
1132811321
intnconfigitems = 0;
1132911322
const char *keyword;
@@ -11364,6 +11357,9 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
1136411357
if (fout->remoteVersion >= 90500)
1136511358
appendPQExpBufferStr(query,
1136611359
"array_to_string(protrftypes, ' ') AS protrftypes,\n");
11360+
else
11361+
appendPQExpBufferStr(query,
11362+
"NULL AS protrftypes,\n");
1136711363

1136811364
if (fout->remoteVersion >= 90600)
1136911365
appendPQExpBufferStr(query,
@@ -11425,11 +11421,7 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
1142511421
funcargs = PQgetvalue(res, 0, PQfnumber(res, "funcargs"));
1142611422
funciargs = PQgetvalue(res, 0, PQfnumber(res, "funciargs"));
1142711423
funcresult = PQgetvalue(res, 0, PQfnumber(res, "funcresult"));
11428-
proallargtypes = proargmodes = proargnames = NULL;
11429-
if (PQfnumber(res, "protrftypes") != -1)
11430-
protrftypes = PQgetvalue(res, 0, PQfnumber(res, "protrftypes"));
11431-
else
11432-
protrftypes = NULL;
11424+
protrftypes = PQgetvalue(res, 0, PQfnumber(res, "protrftypes"));
1143311425
prokind = PQgetvalue(res, 0, PQfnumber(res, "prokind"));
1143411426
provolatile = PQgetvalue(res, 0, PQfnumber(res, "provolatile"));
1143511427
proisstrict = PQgetvalue(res, 0, PQfnumber(res, "proisstrict"));
@@ -11479,53 +11471,7 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
1147911471
appendStringLiteralDQ(asPart, prosrc, NULL);
1148011472
}
1148111473

11482-
nallargs = finfo->nargs;/* unless we learn different from allargs */
11483-
11484-
if (proallargtypes && *proallargtypes)
11485-
{
11486-
intnitems = 0;
11487-
11488-
if (!parsePGArray(proallargtypes, &allargtypes, &nitems) ||
11489-
nitems < finfo->nargs)
11490-
{
11491-
pg_log_warning("could not parse %s array", "proallargtypes");
11492-
if (allargtypes)
11493-
free(allargtypes);
11494-
allargtypes = NULL;
11495-
}
11496-
else
11497-
nallargs = nitems;
11498-
}
11499-
11500-
if (proargmodes && *proargmodes)
11501-
{
11502-
intnitems = 0;
11503-
11504-
if (!parsePGArray(proargmodes, &argmodes, &nitems) ||
11505-
nitems != nallargs)
11506-
{
11507-
pg_log_warning("could not parse %s array", "proargmodes");
11508-
if (argmodes)
11509-
free(argmodes);
11510-
argmodes = NULL;
11511-
}
11512-
}
11513-
11514-
if (proargnames && *proargnames)
11515-
{
11516-
intnitems = 0;
11517-
11518-
if (!parsePGArray(proargnames, &argnames, &nitems) ||
11519-
nitems != nallargs)
11520-
{
11521-
pg_log_warning("could not parse %s array", "proargnames");
11522-
if (argnames)
11523-
free(argnames);
11524-
argnames = NULL;
11525-
}
11526-
}
11527-
11528-
if (proconfig && *proconfig)
11474+
if (*proconfig)
1152911475
{
1153011476
if (!parsePGArray(proconfig, &configitems, &nconfigitems))
1153111477
fatal("could not parse %s array", "proconfig");
@@ -11571,7 +11517,7 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
1157111517

1157211518
appendPQExpBuffer(q, "\n LANGUAGE %s", fmtId(lanname));
1157311519

11574-
if (protrftypes != NULL && strcmp(protrftypes, "") != 0)
11520+
if (*protrftypes)
1157511521
{
1157611522
Oid *typeids = palloc(FUNC_MAX_ARGS * sizeof(Oid));
1157711523
inti;
@@ -11749,12 +11695,6 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
1174911695
free(funcfullsig);
1175011696
free(funcsig_tag);
1175111697
free(qual_funcsig);
11752-
if (allargtypes)
11753-
free(allargtypes);
11754-
if (argmodes)
11755-
free(argmodes);
11756-
if (argnames)
11757-
free(argnames);
1175811698
if (configitems)
1175911699
free(configitems);
1176011700
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp