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

Commit5cfba1a

Browse files
committed
Fix vacuumdb to pass buffer-usage-limit with analyze-only mode
ae78cae added the --buffer-usage-limit to vacuumdb to allow it toinclude the BUFFER_USAGE_LIMIT option in the VACUUM command.Unfortunately, that commit forgot to adjust the code so the option wasadded to the ANALYZE command when the -Z command line argument wasspecified.There were no issues with the -z command as that option just addsANALYZE to the VACUUM command.In passing adjust the code to escape the --buffer-usage-limit optionbefore passing it to the server. It seems nothing beyond a confusingerror message could become this lack of escaping as VACUUM cannot bespecified in a multi-command string.Reported-by: Ryoga YoshidaAuthor: Ryoga Yoshida, David RowleyDiscussion:https://postgr.es/m/08930c0b541700a5264e5fbf3a685f5a%40oss.nttdata.comBackpatch-through: 16, whereae78cae was introduced.
1 parente5975c2 commit5cfba1a

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

‎src/bin/scripts/vacuumdb.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ static void help(const char *progname);
8585

8686
voidcheck_objfilter(void);
8787

88+
staticchar*escape_quotes(constchar*src);
89+
8890
/* For analyze-in-stages mode */
8991
#defineANALYZE_NO_STAGE-1
9092
#defineANALYZE_NUM_STAGES3
@@ -270,7 +272,7 @@ main(int argc, char *argv[])
270272
vacopts.process_main= false;
271273
break;
272274
case13:
273-
vacopts.buffer_usage_limit=pg_strdup(optarg);
275+
vacopts.buffer_usage_limit=escape_quotes(optarg);
274276
break;
275277
default:
276278
/* getopt_long already emitted a complaint */
@@ -452,6 +454,20 @@ check_objfilter(void)
452454
pg_fatal("cannot vacuum all tables in schema(s) and exclude schema(s) at the same time");
453455
}
454456

457+
/*
458+
* Returns a newly malloc'd version of 'src' with escaped single quotes and
459+
* backslashes.
460+
*/
461+
staticchar*
462+
escape_quotes(constchar*src)
463+
{
464+
char*result=escape_single_quotes_ascii(src);
465+
466+
if (!result)
467+
pg_fatal("out of memory");
468+
returnresult;
469+
}
470+
455471
/*
456472
* vacuum_one_database
457473
*
@@ -964,6 +980,13 @@ prepare_vacuum_command(PQExpBuffer sql, int serverVersion,
964980
appendPQExpBuffer(sql,"%sVERBOSE",sep);
965981
sep=comma;
966982
}
983+
if (vacopts->buffer_usage_limit)
984+
{
985+
Assert(serverVersion >=160000);
986+
appendPQExpBuffer(sql,"%sBUFFER_USAGE_LIMIT '%s'",sep,
987+
vacopts->buffer_usage_limit);
988+
sep=comma;
989+
}
967990
if (sep!=paren)
968991
appendPQExpBufferChar(sql,')');
969992
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp