|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.68 2000/12/14 00:41:09 tgl Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.69 2000/12/22 23:12:05 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
|
24 | 24 | #include "catalog/pg_type.h"
|
25 | 25 | #include "commands/creatinh.h"
|
26 | 26 | #include "miscadmin.h"
|
27 |
| -#include "utils/syscache.h" |
28 | 27 | #include "optimizer/clauses.h"
|
| 28 | +#include "utils/syscache.h" |
| 29 | +#include "utils/temprel.h" |
29 | 30 |
|
30 | 31 | /* ----------------
|
31 | 32 | * local stuff
|
|
34 | 35 |
|
35 | 36 | static int checkAttrExists(const char *attributeName,
|
36 | 37 | const char *attributeType, List *schema);
|
37 |
| -static List *MergeAttributes(List *schema, List *supers, |
| 38 | +static List *MergeAttributes(List *schema, List *supers, bool istemp, |
38 | 39 | List **supOids, List **supconstr);
|
39 | 40 | static void StoreCatalogInheritance(Oid relationId, List *supers);
|
40 | 41 | static void setRelhassubclassInRelation(Oid relationId, bool relhassubclass);
|
@@ -71,7 +72,7 @@ DefineRelation(CreateStmt *stmt, char relkind)
|
71 | 72 | * including inherited attributes.
|
72 | 73 | * ----------------
|
73 | 74 | */
|
74 |
| - schema = MergeAttributes(schema, stmt->inhRelnames, |
| 75 | + schema = MergeAttributes(schema, stmt->inhRelnames, stmt->istemp, |
75 | 76 | &inheritOids, &old_constraints);
|
76 | 77 |
|
77 | 78 | numberOfAttributes = length(schema);
|
@@ -283,6 +284,7 @@ change_varattnos_of_a_node(Node *node, const AttrNumber *newattno)
|
283 | 284 | * 'schema' is the column/attribute definition for the table. (It's a list
|
284 | 285 | * of ColumnDef's.) It is destructively changed.
|
285 | 286 | * 'supers' is a list of names (as Value objects) of parent relations.
|
| 287 | + * 'istemp' is TRUE if we are creating a temp relation. |
286 | 288 | *
|
287 | 289 | * Output arguments:
|
288 | 290 | * 'supOids' receives an integer list of the OIDs of the parent relations.
|
@@ -311,7 +313,7 @@ change_varattnos_of_a_node(Node *node, const AttrNumber *newattno)
|
311 | 313 | * stud_emp {7:percent}
|
312 | 314 | */
|
313 | 315 | static List *
|
314 |
| -MergeAttributes(List *schema, List *supers, |
| 316 | +MergeAttributes(List *schema, List *supers, bool istemp, |
315 | 317 | List **supOids, List **supconstr)
|
316 | 318 | {
|
317 | 319 | List *entry;
|
@@ -378,6 +380,9 @@ MergeAttributes(List *schema, List *supers,
|
378 | 380 |
|
379 | 381 | if (relation->rd_rel->relkind != RELKIND_RELATION)
|
380 | 382 | elog(ERROR, "CREATE TABLE: inherited relation \"%s\" is not a table", name);
|
| 383 | + /* Permanent rels cannot inherit from temporary ones */ |
| 384 | + if (!istemp && is_temp_rel_name(name)) |
| 385 | + elog(ERROR, "CREATE TABLE: cannot inherit from temp relation \"%s\"", name); |
381 | 386 |
|
382 | 387 | parentOids = lappendi(parentOids, relation->rd_id);
|
383 | 388 | setRelhassubclassInRelation(relation->rd_id, true);
|
|
0 commit comments