diff options
| author | Simon Riggs | 2012-01-23 23:25:04 +0000 |
|---|---|---|
| committer | Simon Riggs | 2012-01-23 23:25:04 +0000 |
| commit | b8a91d9d1c7ec75aaecf13df687ec7b5b0ed35a6 (patch) | |
| tree | f49bd1ea95c2e141cb8fadd0495f682134053d38 /src/backend/tcop | |
| parent | 4993a49b7cf1d23dfe1f9e1a85d9411b8ff57454 (diff) | |
ALTER <thing> [IF EXISTS] ... allows silent DDL if required,
e.g. ALTER FOREIGN TABLE IF EXISTS foo RENAME TO bar
Pavel Stehule
Diffstat (limited to 'src/backend/tcop')
| -rw-r--r-- | src/backend/tcop/utility.c | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index de16a61454b..5b81c0bbedc 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -714,34 +714,41 @@ standard_ProcessUtility(Node *parsetree, lockmode = AlterTableGetLockLevel(atstmt->cmds); relid = AlterTableLookupRelation(atstmt, lockmode); - /* Run parse analysis ... */ - stmts = transformAlterTableStmt(atstmt, queryString); - - /* ... and do it */ - foreach(l, stmts) + if (OidIsValid(relid)) { - Node *stmt = (Node *) lfirst(l); + /* Run parse analysis ... */ + stmts = transformAlterTableStmt(atstmt, queryString); - if (IsA(stmt, AlterTableStmt)) - { - /* Do the table alteration proper */ - AlterTable(relid, lockmode, (AlterTableStmt *) stmt); - } - else + /* ... and do it */ + foreach(l, stmts) { - /* Recurse for anything else */ - ProcessUtility(stmt, - queryString, - params, - false, - None_Receiver, - NULL); - } + Node *stmt = (Node *) lfirst(l); - /* Need CCI between commands */ - if (lnext(l) != NULL) - CommandCounterIncrement(); + if (IsA(stmt, AlterTableStmt)) + { + /* Do the table alteration proper */ + AlterTable(relid, lockmode, (AlterTableStmt *) stmt); + } + else + { + /* Recurse for anything else */ + ProcessUtility(stmt, + queryString, + params, + false, + None_Receiver, + NULL); + } + + /* Need CCI between commands */ + if (lnext(l) != NULL) + CommandCounterIncrement(); + } } + else + ereport(NOTICE, + (errmsg("relation \"%s\" does not exist, skipping", + atstmt->relation->relname))); } break; |
