8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.167 2001/06/12 05:55:49 tgl Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.168 2001/06/18 16:13:21 momjian Exp $
12
12
*
13
13
*
14
14
* INTERFACE ROUTINES
@@ -281,8 +281,8 @@ heap_create(char *relname,
281
281
* replace relname of caller with a unique name for a temp
282
282
* relation
283
283
*/
284
- snprintf (relname , NAMEDATALEN , "pg_temp.%d. %u" ,
285
- (int ) MyProcPid , uniqueId ++ );
284
+ snprintf (relname , NAMEDATALEN , "%s_%d_ %u" ,
285
+ PG_TEMP_REL_PREFIX , (int ) MyProcPid , uniqueId ++ );
286
286
}
287
287
288
288
/*
@@ -874,37 +874,6 @@ heap_create_with_catalog(char *relname,
874
874
}
875
875
876
876
877
- /* ----------------------------------------------------------------
878
- * heap_drop_with_catalog - removes all record of named relation from catalogs
879
- *
880
- * 1) open relation, check for existence, etc.
881
- * 2) remove inheritance information
882
- * 3) remove indexes
883
- * 4) remove pg_class tuple
884
- * 5) remove pg_attribute tuples and related descriptions
885
- * 6) remove pg_description tuples
886
- * 7) remove pg_type tuples
887
- * 8) RemoveConstraints ()
888
- * 9) unlink relation
889
- *
890
- * old comments
891
- * Except for vital relations, removes relation from
892
- * relation catalog, and related attributes from
893
- * attribute catalog (needed?). (Anything else?)
894
- *
895
- * get proper relation from relation catalog (if not arg)
896
- * scan attribute catalog deleting attributes of reldesc
897
- * (necessary?)
898
- * delete relation from relation catalog
899
- * (How are the tuples of the relation discarded?)
900
- *
901
- * XXX Must fix to work with indexes.
902
- * There may be a better order for doing things.
903
- * Problems with destroying a deleted database--cannot create
904
- * a struct reldesc without having an open file descriptor.
905
- * ----------------------------------------------------------------
906
- */
907
-
908
877
/* --------------------------------
909
878
* RelationRemoveInheritance
910
879
*
@@ -1334,10 +1303,35 @@ DeleteTypeTuple(Relation rel)
1334
1303
heap_close (pg_type_desc , RowExclusiveLock );
1335
1304
}
1336
1305
1337
- /* --------------------------------
1338
- * heap_drop_with_catalog
1306
+ /* ----------------------------------------------------------------
1307
+ * heap_drop_with_catalog - removes all record of named relation from catalogs
1339
1308
*
1340
- * --------------------------------
1309
+ * 1) open relation, check for existence, etc.
1310
+ * 2) remove inheritance information
1311
+ * 3) remove indexes
1312
+ * 4) remove pg_class tuple
1313
+ * 5) remove pg_attribute tuples and related descriptions
1314
+ * 6) remove pg_description tuples
1315
+ * 7) remove pg_type tuples
1316
+ * 8) RemoveConstraints ()
1317
+ * 9) unlink relation
1318
+ *
1319
+ * old comments
1320
+ * Except for vital relations, removes relation from
1321
+ * relation catalog, and related attributes from
1322
+ * attribute catalog (needed?). (Anything else?)
1323
+ *
1324
+ * get proper relation from relation catalog (if not arg)
1325
+ * scan attribute catalog deleting attributes of reldesc
1326
+ * (necessary?)
1327
+ * delete relation from relation catalog
1328
+ * (How are the tuples of the relation discarded?)
1329
+ *
1330
+ * XXX Must fix to work with indexes.
1331
+ * There may be a better order for doing things.
1332
+ * Problems with destroying a deleted database--cannot create
1333
+ * a struct reldesc without having an open file descriptor.
1334
+ * ----------------------------------------------------------------
1341
1335
*/
1342
1336
void
1343
1337
heap_drop_with_catalog (const char * relname ,
@@ -1360,8 +1354,10 @@ heap_drop_with_catalog(const char *relname,
1360
1354
* prevent deletion of system relations
1361
1355
*/
1362
1356
/* allow temp of pg_class? Guess so. */
1363
- if (!istemp && !allow_system_table_mods &&
1364
- IsSystemRelationName (RelationGetRelationName (rel )))
1357
+ if (!istemp &&
1358
+ !allow_system_table_mods &&
1359
+ IsSystemRelationName (RelationGetRelationName (rel )) &&
1360
+ !is_temp_relname (RelationGetRelationName (rel )))
1365
1361
elog (ERROR , "System relation \"%s\" may not be dropped" ,
1366
1362
RelationGetRelationName (rel ));
1367
1363
0 commit comments