8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/catalog/dependency.c,v 1.3 2002/07/16 05:53:33 tgl Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/catalog/dependency.c,v 1.4 2002/07/18 16:47:22 tgl Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
25
25
#include "catalog/pg_constraint.h"
26
26
#include "catalog/pg_depend.h"
27
27
#include "catalog/pg_language.h"
28
+ #include "catalog/pg_namespace.h"
28
29
#include "catalog/pg_rewrite.h"
29
30
#include "catalog/pg_trigger.h"
30
31
#include "catalog/pg_type.h"
31
32
#include "commands/comment.h"
32
33
#include "commands/defrem.h"
33
34
#include "commands/proclang.h"
35
+ #include "commands/schemacmds.h"
34
36
#include "commands/trigger.h"
35
37
#include "lib/stringinfo.h"
36
38
#include "miscadmin.h"
@@ -54,6 +56,7 @@ typedef enum ObjectClasses
54
56
OCLASS_OPERATOR , /* pg_operator */
55
57
OCLASS_REWRITE , /* pg_rewrite */
56
58
OCLASS_TRIGGER , /* pg_trigger */
59
+ OCLASS_SCHEMA , /* pg_namespace */
57
60
MAX_OCLASS /* MUST BE LAST */
58
61
} ObjectClasses ;
59
62
@@ -597,6 +600,10 @@ doDeletion(const ObjectAddress *object)
597
600
RemoveTriggerById (object -> objectId );
598
601
break ;
599
602
603
+ case OCLASS_SCHEMA :
604
+ RemoveSchemaById (object -> objectId );
605
+ break ;
606
+
600
607
default :
601
608
elog (ERROR , "doDeletion: Unsupported object class %u" ,
602
609
object -> classId );
@@ -981,6 +988,7 @@ init_object_classes(void)
981
988
object_classes [OCLASS_OPERATOR ] = get_system_catalog_relid (OperatorRelationName );
982
989
object_classes [OCLASS_REWRITE ] = get_system_catalog_relid (RewriteRelationName );
983
990
object_classes [OCLASS_TRIGGER ] = get_system_catalog_relid (TriggerRelationName );
991
+ object_classes [OCLASS_SCHEMA ] = get_system_catalog_relid (NamespaceRelationName );
984
992
object_classes_initialized = true;
985
993
}
986
994
@@ -1045,6 +1053,11 @@ getObjectClass(const ObjectAddress *object)
1045
1053
Assert (object -> objectSubId == 0 );
1046
1054
return OCLASS_TRIGGER ;
1047
1055
}
1056
+ if (object -> classId == object_classes [OCLASS_SCHEMA ])
1057
+ {
1058
+ Assert (object -> objectSubId == 0 );
1059
+ return OCLASS_SCHEMA ;
1060
+ }
1048
1061
1049
1062
elog (ERROR , "getObjectClass: Unknown object class %u" ,
1050
1063
object -> classId );
@@ -1265,6 +1278,22 @@ getObjectDescription(const ObjectAddress *object)
1265
1278
break ;
1266
1279
}
1267
1280
1281
+ case OCLASS_SCHEMA :
1282
+ {
1283
+ HeapTuple schemaTup ;
1284
+
1285
+ schemaTup = SearchSysCache (NAMESPACEOID ,
1286
+ ObjectIdGetDatum (object -> objectId ),
1287
+ 0 , 0 , 0 );
1288
+ if (!HeapTupleIsValid (schemaTup ))
1289
+ elog (ERROR , "getObjectDescription: Schema %u does not exist" ,
1290
+ object -> objectId );
1291
+ appendStringInfo (& buffer , "schema %s" ,
1292
+ NameStr (((Form_pg_namespace ) GETSTRUCT (schemaTup ))-> nspname ));
1293
+ ReleaseSysCache (schemaTup );
1294
+ break ;
1295
+ }
1296
+
1268
1297
default :
1269
1298
appendStringInfo (& buffer , "unknown object %u %u %d" ,
1270
1299
object -> classId ,
0 commit comments