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

Commit3636efa

Browse files
committed
Fix parsePGArray() error checking in pg_dump.
Coverity complained about a defect in commit257836a: Calling "parsePGArray" without checking return value (as is done elsewhere 11 out of 13 times).Fix, and also check for empty strings explicitly (NULL as represented byPQgetvalue()). That worked correctly before only because parsePGArray()happens to set *nitems = 0 when it fails on an empty string. Alsoconvert a sanity check assertion to an error to be more paranoid, andpgindent a nearby line.Reported-by: Michael Paquier <michael@paquier.xyz>
1 parent8b39345 commit3636efa

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18573,13 +18573,25 @@ appendIndexCollationVersion(PQExpBuffer buffer, IndxInfo *indxinfo, int enc,
1857318573
}
1857418574

1857518575
/* Restore the versions that were recorded by the old cluster (if any). */
18576-
parsePGArray(inddependcollnames,
18577-
&inddependcollnamesarray,
18578-
&ninddependcollnames);
18579-
parsePGArray(inddependcollversions,
18580-
&inddependcollversionsarray,
18581-
&ninddependcollversions);
18582-
Assert(ninddependcollnames == ninddependcollversions);
18576+
if (strlen(inddependcollnames) == 0 && strlen(inddependcollversions) == 0)
18577+
{
18578+
ninddependcollnames = ninddependcollversions = 0;
18579+
inddependcollnamesarray = inddependcollversionsarray = NULL;
18580+
}
18581+
else
18582+
{
18583+
if (!parsePGArray(inddependcollnames,
18584+
&inddependcollnamesarray,
18585+
&ninddependcollnames))
18586+
fatal("could not parse index collation name array");
18587+
if (!parsePGArray(inddependcollversions,
18588+
&inddependcollversionsarray,
18589+
&ninddependcollversions))
18590+
fatal("could not parse index collation version array");
18591+
}
18592+
18593+
if (ninddependcollnames != ninddependcollversions)
18594+
fatal("mismatched number of collation names and versions for index");
1858318595

1858418596
if (ninddependcollnames > 0)
1858518597
appendPQExpBufferStr(buffer,
@@ -18594,7 +18606,7 @@ appendIndexCollationVersion(PQExpBuffer buffer, IndxInfo *indxinfo, int enc,
1859418606
"UPDATE pg_catalog.pg_depend SET refobjversion = %s WHERE objid = '%u'::pg_catalog.oid AND refclassid = 'pg_catalog.pg_collation'::regclass AND refobjversion IS NOT NULL AND refobjid = ",
1859518607
inddependcollversionsarray[i],
1859618608
indxinfo->dobj.catId.oid);
18597-
appendStringLiteralAH(buffer,inddependcollnamesarray[i], fout);
18609+
appendStringLiteralAH(buffer,inddependcollnamesarray[i], fout);
1859818610
appendPQExpBuffer(buffer, "::regcollation;\n");
1859918611
}
1860018612

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp