|
15 | 15 | *
|
16 | 16 | *
|
17 | 17 | * IDENTIFICATION
|
18 |
| - * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.173 2005/10/15 02:49:15 momjian Exp $ |
| 18 | + * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.174 2005/11/22 15:24:17 adunstan Exp $ |
19 | 19 | *
|
20 | 20 | *-------------------------------------------------------------------------
|
21 | 21 | */
|
@@ -551,7 +551,7 @@ createdb(const CreatedbStmt *stmt)
|
551 | 551 | * DROP DATABASE
|
552 | 552 | */
|
553 | 553 | void
|
554 |
| -dropdb(const char *dbname) |
| 554 | +dropdb(const char *dbname, bool missing_ok) |
555 | 555 | {
|
556 | 556 | Oid db_id;
|
557 | 557 | bool db_istemplate;
|
@@ -585,9 +585,25 @@ dropdb(const char *dbname)
|
585 | 585 |
|
586 | 586 | if (!get_db_info(dbname, &db_id, NULL, NULL,
|
587 | 587 | &db_istemplate, NULL, NULL, NULL, NULL, NULL))
|
588 |
| - ereport(ERROR, |
| 588 | + { |
| 589 | + if (! missing_ok) |
| 590 | + { |
| 591 | + ereport(ERROR, |
589 | 592 | (errcode(ERRCODE_UNDEFINED_DATABASE),
|
590 | 593 | errmsg("database \"%s\" does not exist", dbname)));
|
| 594 | + } |
| 595 | + else |
| 596 | + { |
| 597 | + |
| 598 | + /* Close pg_database, release the lock, since we changed nothing */ |
| 599 | + heap_close(pgdbrel, ExclusiveLock); |
| 600 | + ereport(NOTICE, |
| 601 | + (errmsg("database \"%s\" does not exist, skipping", |
| 602 | + dbname))); |
| 603 | + |
| 604 | + return; |
| 605 | + } |
| 606 | + } |
591 | 607 |
|
592 | 608 | if (!pg_database_ownercheck(db_id, GetUserId()))
|
593 | 609 | aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE,
|
|
0 commit comments