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

Commitc81e63d

Browse files
committed
Fix pg_restore's processing of old-style BLOB COMMENTS data.
Prior to 9.0, pg_dump handled comments on large objects by dumping a bunchof COMMENT commands into a single BLOB COMMENTS archive object. Withsufficiently many such comments, some of the commands would likely getsplit across bufferloads when restoring, causing failures indirect-to-database restores (though no problem would be evident in textoutput). This is the same type of issue we have with table data dumped asINSERT commands, and it can be fixed in the same way, by using a mini SQLlexer to figure out where the command boundaries are. Fortunately, theCOMMENT commands are no more complex to lex than INSERTs, so we can justre-use the existing lexer for INSERTs.Per bug #10611 from Jacek Zalewski. Back-patch to all active branches.
1 parent6554656 commitc81e63d

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,13 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
696696

697697
_selectOutputSchema(AH,"pg_catalog");
698698

699+
/* Send BLOB COMMENTS data to ExecuteSimpleCommands() */
700+
if (strcmp(te->desc,"BLOB COMMENTS")==0)
701+
AH->outputKind=OUTPUT_OTHERDATA;
702+
699703
(*AH->PrintTocDataPtr) (AH,te,ropt);
704+
705+
AH->outputKind=OUTPUT_SQLCMDS;
700706
}
701707
else
702708
{

‎src/bin/pg_dump/pg_backup_db.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,14 @@ ExecuteSqlCommand(ArchiveHandle *AH, const char *qry, const char *desc)
428428
* identifiers, so that we can recognize statement-terminating semicolons.
429429
* We assume that INSERT data will not contain SQL comments, E'' literals,
430430
* or dollar-quoted strings, so this is much simpler than a full SQL lexer.
431+
*
432+
* Note: when restoring from a pre-9.0 dump file, this code is also used to
433+
* process BLOB COMMENTS data, which has the same problem of containing
434+
* multiple SQL commands that might be split across bufferloads. Fortunately,
435+
* that data won't contain anything complicated to lex either.
431436
*/
432437
staticvoid
433-
ExecuteInsertCommands(ArchiveHandle*AH,constchar*buf,size_tbufLen)
438+
ExecuteSimpleCommands(ArchiveHandle*AH,constchar*buf,size_tbufLen)
434439
{
435440
constchar*qry=buf;
436441
constchar*eos=buf+bufLen;
@@ -514,9 +519,10 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, const char *buf, size_t bufLen)
514519
elseif (AH->outputKind==OUTPUT_OTHERDATA)
515520
{
516521
/*
517-
* Table data expressed as INSERT commands.
522+
* Table data expressed as INSERT commands; or, in old dump files,
523+
* BLOB COMMENTS data (which is expressed as COMMENT ON commands).
518524
*/
519-
ExecuteInsertCommands(AH,buf,bufLen);
525+
ExecuteSimpleCommands(AH,buf,bufLen);
520526
}
521527
else
522528
{

‎src/bin/pg_dump/pg_dump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,7 @@ dumpTableData_copy(Archive *fout, void *dcontext)
15491549
*
15501550
* Caution: when we restore from an archive file direct to database, the
15511551
* INSERT commands emitted by this function have to be parsed by
1552-
* pg_backup_db.c'sExecuteInsertCommands(), which will not handle comments,
1552+
* pg_backup_db.c'sExecuteSimpleCommands(), which will not handle comments,
15531553
* E'' strings, or dollar-quoted strings. So don't emit anything like that.
15541554
*/
15551555
staticint

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp