mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
DROP objecttype IF EXISTS for the following objects:
table view index sequence schema type domain conversion
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/conversioncmds.c,v 1.23 2005/10/15 02:49:15 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/conversioncmds.c,v 1.24 2005/11/19 17:39:44 adunstan Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -98,16 +98,29 @@ CreateConversionCommand(CreateConversionStmt *stmt)
|
||||
* DROP CONVERSION
|
||||
*/
|
||||
void
|
||||
DropConversionCommand(List *name, DropBehavior behavior)
|
||||
DropConversionCommand(List *name, DropBehavior behavior, bool missing_ok)
|
||||
{
|
||||
Oid conversionOid;
|
||||
|
||||
conversionOid = FindConversionByName(name);
|
||||
if (!OidIsValid(conversionOid))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("conversion \"%s\" does not exist",
|
||||
NameListToString(name))));
|
||||
{
|
||||
if (! missing_ok)
|
||||
{
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("conversion \"%s\" does not exist",
|
||||
NameListToString(name))));
|
||||
}
|
||||
else
|
||||
{
|
||||
ereport(NOTICE,
|
||||
(errmsg("conversion \"%s\" does not exist, skipping",
|
||||
NameListToString(name))));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ConversionDrop(conversionOid, behavior);
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/schemacmds.c,v 1.35 2005/10/15 02:49:15 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/schemacmds.c,v 1.36 2005/11/19 17:39:44 adunstan Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -147,7 +147,7 @@ CreateSchemaCommand(CreateSchemaStmt *stmt)
|
||||
* Removes a schema.
|
||||
*/
|
||||
void
|
||||
RemoveSchema(List *names, DropBehavior behavior)
|
||||
RemoveSchema(List *names, DropBehavior behavior, bool missing_ok)
|
||||
{
|
||||
char *namespaceName;
|
||||
Oid namespaceId;
|
||||
@@ -163,9 +163,22 @@ RemoveSchema(List *names, DropBehavior behavior)
|
||||
CStringGetDatum(namespaceName),
|
||||
0, 0, 0);
|
||||
if (!OidIsValid(namespaceId))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_SCHEMA),
|
||||
errmsg("schema \"%s\" does not exist", namespaceName)));
|
||||
{
|
||||
if (!missing_ok)
|
||||
{
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_SCHEMA),
|
||||
errmsg("schema \"%s\" does not exist", namespaceName)));
|
||||
}
|
||||
else
|
||||
{
|
||||
ereport(NOTICE,
|
||||
(errmsg("schema \"%s\" does not exist, skipping",
|
||||
namespaceName)));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Permission check */
|
||||
if (!pg_namespace_ownercheck(namespaceId, GetUserId()))
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.82 2005/10/18 01:06:24 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.83 2005/11/19 17:39:44 adunstan Exp $
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The "DefineFoo" routines take the parse tree and pick out the
|
||||
@@ -398,7 +398,7 @@ DefineType(List *names, List *parameters)
|
||||
* Removes a datatype.
|
||||
*/
|
||||
void
|
||||
RemoveType(List *names, DropBehavior behavior)
|
||||
RemoveType(List *names, DropBehavior behavior, bool missing_ok)
|
||||
{
|
||||
TypeName *typename;
|
||||
Oid typeoid;
|
||||
@@ -414,10 +414,23 @@ RemoveType(List *names, DropBehavior behavior)
|
||||
/* Use LookupTypeName here so that shell types can be removed. */
|
||||
typeoid = LookupTypeName(typename);
|
||||
if (!OidIsValid(typeoid))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("type \"%s\" does not exist",
|
||||
TypeNameToString(typename))));
|
||||
{
|
||||
if (!missing_ok)
|
||||
{
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("type \"%s\" does not exist",
|
||||
TypeNameToString(typename))));
|
||||
}
|
||||
else
|
||||
{
|
||||
ereport(NOTICE,
|
||||
(errmsg("type \"%s\" does not exist, skipping",
|
||||
TypeNameToString(typename))));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
tup = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typeoid),
|
||||
@@ -779,7 +792,7 @@ DefineDomain(CreateDomainStmt *stmt)
|
||||
* This is identical to RemoveType except we insist it be a domain.
|
||||
*/
|
||||
void
|
||||
RemoveDomain(List *names, DropBehavior behavior)
|
||||
RemoveDomain(List *names, DropBehavior behavior, bool missing_ok)
|
||||
{
|
||||
TypeName *typename;
|
||||
Oid typeoid;
|
||||
@@ -796,10 +809,23 @@ RemoveDomain(List *names, DropBehavior behavior)
|
||||
/* Use LookupTypeName here so that shell types can be removed. */
|
||||
typeoid = LookupTypeName(typename);
|
||||
if (!OidIsValid(typeoid))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("type \"%s\" does not exist",
|
||||
TypeNameToString(typename))));
|
||||
{
|
||||
if (!missing_ok)
|
||||
{
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("type \"%s\" does not exist",
|
||||
TypeNameToString(typename))));
|
||||
}
|
||||
else
|
||||
{
|
||||
ereport(NOTICE,
|
||||
(errmsg("type \"%s\" does not exist, skipping",
|
||||
TypeNameToString(typename))));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
tup = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typeoid),
|
||||
|
Reference in New Issue
Block a user