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

Commit13b58f8

Browse files
committed
Improve failure detection with array parsing in pg_dump
Similarly to3636efa, the checks done in pg_dump when parsing arrayvalues from catalogs have been too lax. Under memory pressure, it couldbe possible, though very unlikely, to finish with dumps that miss somedata like:- Statistics for indexes- Run-time configuration of functions- Configuration of extensions- Publication list for a subscriptionNo backpatch is done as this is not going to be a problem in practice.For example, if an OOM causes an array parsing to fail, a follow-up codepath of pg_dump would most likely complain with an allocation failuredue to the memory pressure.Author: Michael PaquierReviewed-by: Daniel GustafssonDiscussion:https://postgr.es/m/20201111061319.GE2276@paquier.xyz
1 parent2783898 commit13b58f8

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4357,13 +4357,7 @@ dumpSubscription(Archive *fout, SubscriptionInfo *subinfo)
43574357

43584358
/* Build list of quoted publications and append them to query. */
43594359
if (!parsePGArray(subinfo->subpublications, &pubnames, &npubnames))
4360-
{
4361-
pg_log_warning("could not parse subpublications array");
4362-
if (pubnames)
4363-
free(pubnames);
4364-
pubnames = NULL;
4365-
npubnames = 0;
4366-
}
4360+
fatal("could not parse subpublications array");
43674361

43684362
publications = createPQExpBuffer();
43694363
for (i = 0; i < npubnames; i++)
@@ -12128,13 +12122,12 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
1212812122
if (proconfig && *proconfig)
1212912123
{
1213012124
if (!parsePGArray(proconfig, &configitems, &nconfigitems))
12131-
{
12132-
pg_log_warning("could not parse proconfig array");
12133-
if (configitems)
12134-
free(configitems);
12135-
configitems = NULL;
12136-
nconfigitems = 0;
12137-
}
12125+
fatal("could not parse proconfig array");
12126+
}
12127+
else
12128+
{
12129+
configitems = NULL;
12130+
nconfigitems = 0;
1213812131
}
1213912132

1214012133
if (funcargs)
@@ -16453,8 +16446,8 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
1645316446
char *indstatvals = indxinfo->indstatvals;
1645416447
char **indstatcolsarray = NULL;
1645516448
char **indstatvalsarray = NULL;
16456-
intnstatcols;
16457-
intnstatvals;
16449+
intnstatcols = 0;
16450+
intnstatvals = 0;
1645816451

1645916452
if (dopt->binary_upgrade)
1646016453
binary_upgrade_set_pg_class_oids(fout, q,
@@ -16483,12 +16476,17 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
1648316476
* If the index has any statistics on some of its columns, generate
1648416477
* the associated ALTER INDEX queries.
1648516478
*/
16486-
if (parsePGArray(indstatcols, &indstatcolsarray, &nstatcols) &&
16487-
parsePGArray(indstatvals, &indstatvalsarray, &nstatvals) &&
16488-
nstatcols == nstatvals)
16479+
if (strlen(indstatcols) != 0 || strlen(indstatvals) != 0)
1648916480
{
1649016481
intj;
1649116482

16483+
if (!parsePGArray(indstatcols, &indstatcolsarray, &nstatcols))
16484+
fatal("could not parse index statistic columns");
16485+
if (!parsePGArray(indstatvals, &indstatvalsarray, &nstatvals))
16486+
fatal("could not parse index statistic values");
16487+
if (nstatcols != nstatvals)
16488+
fatal("mismatched number of columns and values for index stats");
16489+
1649216490
for (j = 0; j < nstatcols; j++)
1649316491
{
1649416492
appendPQExpBuffer(q, "ALTER INDEX %s ", qqindxname);
@@ -17938,15 +17936,20 @@ processExtensionTables(Archive *fout, ExtensionInfo extinfo[],
1793817936
char *extcondition = curext->extcondition;
1793917937
char **extconfigarray = NULL;
1794017938
char **extconditionarray = NULL;
17941-
intnconfigitems;
17942-
intnconditionitems;
17939+
intnconfigitems = 0;
17940+
intnconditionitems = 0;
1794317941

17944-
if (parsePGArray(extconfig, &extconfigarray, &nconfigitems) &&
17945-
parsePGArray(extcondition, &extconditionarray, &nconditionitems) &&
17946-
nconfigitems == nconditionitems)
17942+
if (strlen(extconfig) != 0 || strlen(extcondition) != 0)
1794717943
{
1794817944
intj;
1794917945

17946+
if (!parsePGArray(extconfig, &extconfigarray, &nconfigitems))
17947+
fatal("could not parse extension configuration array");
17948+
if (!parsePGArray(extcondition, &extconditionarray, &nconditionitems))
17949+
fatal("could not parse extension condition array");
17950+
if (nconfigitems != nconditionitems)
17951+
fatal("mismatched number of configurations and conditions for extension");
17952+
1795017953
for (j = 0; j < nconfigitems; j++)
1795117954
{
1795217955
TableInfo *configtbl;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp