mirror of
https://github.com/postgres/postgres.git
synced 2025-05-01 01:04:50 +03:00
Fix pg_dump's --if-exists for large objects
This was born broken in 9067310cc5dd590e36c2c3219dbf3961d7c9f8cb. Per trouble report from Joachim Wieland. Pavel Stěhule and Álvaro Herrera
This commit is contained in:
parent
6f1310024d
commit
5f4f66f671
@ -427,6 +427,20 @@ RestoreArchive(Archive *AHX)
|
|||||||
ahprintf(AH, "%s", te->dropStmt);
|
ahprintf(AH, "%s", te->dropStmt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Inject an appropriate spelling of "if exists". For
|
||||||
|
* large objects, we have a separate routine that
|
||||||
|
* knows how to do it, without depending on
|
||||||
|
* te->dropStmt; use that. For other objects we need
|
||||||
|
* to parse the command.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if (strncmp(te->desc, "BLOB", 4) == 0)
|
||||||
|
{
|
||||||
|
DropBlobIfExists(AH, te->catalogId.oid);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
char buffer[40];
|
char buffer[40];
|
||||||
char *mark;
|
char *mark;
|
||||||
@ -435,8 +449,8 @@ RestoreArchive(Archive *AHX)
|
|||||||
PQExpBuffer ftStmt = createPQExpBuffer();
|
PQExpBuffer ftStmt = createPQExpBuffer();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Need to inject IF EXISTS clause after ALTER TABLE
|
* Need to inject IF EXISTS clause after ALTER
|
||||||
* part in ALTER TABLE .. DROP statement
|
* TABLE part in ALTER TABLE .. DROP statement
|
||||||
*/
|
*/
|
||||||
if (strncmp(dropStmt, "ALTER TABLE", 11) == 0)
|
if (strncmp(dropStmt, "ALTER TABLE", 11) == 0)
|
||||||
{
|
{
|
||||||
@ -446,15 +460,15 @@ RestoreArchive(Archive *AHX)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ALTER TABLE..ALTER COLUMN..DROP DEFAULT does not
|
* ALTER TABLE..ALTER COLUMN..DROP DEFAULT does
|
||||||
* support the IF EXISTS clause, and therefore we
|
* not support the IF EXISTS clause, and therefore
|
||||||
* simply emit the original command for such objects.
|
* we simply emit the original command for such
|
||||||
* For other objects, we need to extract the first
|
* objects. For other objects, we need to extract
|
||||||
* part of the DROP which includes the object type.
|
* the first part of the DROP which includes the
|
||||||
* Most of the time this matches te->desc, so search
|
* object type. Most of the time this matches
|
||||||
* for that; however for the different kinds of
|
* te->desc, so search for that; however for the
|
||||||
* CONSTRAINTs, we know to search for hardcoded "DROP
|
* different kinds of CONSTRAINTs, we know to
|
||||||
* CONSTRAINT" instead.
|
* search for hardcoded "DROP CONSTRAINT" instead.
|
||||||
*/
|
*/
|
||||||
if (strcmp(te->desc, "DEFAULT") == 0)
|
if (strcmp(te->desc, "DEFAULT") == 0)
|
||||||
appendPQExpBuffer(ftStmt, "%s", dropStmt);
|
appendPQExpBuffer(ftStmt, "%s", dropStmt);
|
||||||
@ -486,6 +500,7 @@ RestoreArchive(Archive *AHX)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _selectOutputSchema may have set currSchema to reflect the effect
|
* _selectOutputSchema may have set currSchema to reflect the effect
|
||||||
|
Loading…
x
Reference in New Issue
Block a user