|
6 | 6 | * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group |
7 | 7 | * Portions Copyright (c) 1994, Regents of the University of California |
8 | 8 | * |
9 | | - *$Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.201 2001/10/12 00:07:14 tgl Exp $ |
| 9 | + *$Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.202 2001/10/22 22:49:02 tgl Exp $ |
10 | 10 | * |
11 | 11 | *------------------------------------------------------------------------- |
12 | 12 | */ |
|
15 | 15 |
|
16 | 16 | #include"access/heapam.h" |
17 | 17 | #include"catalog/catname.h" |
| 18 | +#include"catalog/heap.h" |
18 | 19 | #include"catalog/pg_index.h" |
19 | 20 | #include"catalog/pg_type.h" |
20 | 21 | #include"nodes/makefuncs.h" |
@@ -50,6 +51,7 @@ typedef struct |
50 | 51 | char*relname;/* name of relation */ |
51 | 52 | List*inhRelnames;/* names of relations to inherit from */ |
52 | 53 | boolistemp;/* is it to be a temp relation? */ |
| 54 | +boolhasoids;/* does relation have an OID column? */ |
53 | 55 | OidrelOid;/* OID of table, if ALTER TABLE case */ |
54 | 56 | List*columns;/* ColumnDef items */ |
55 | 57 | List*ckconstraints;/* CHECK constraints */ |
@@ -720,6 +722,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt) |
720 | 722 | cxt.relname=stmt->relname; |
721 | 723 | cxt.inhRelnames=stmt->inhRelnames; |
722 | 724 | cxt.istemp=stmt->istemp; |
| 725 | +cxt.hasoids=stmt->hasoids; |
723 | 726 | cxt.relOid=InvalidOid; |
724 | 727 | cxt.columns=NIL; |
725 | 728 | cxt.ckconstraints=NIL; |
@@ -1106,6 +1109,15 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) |
1106 | 1109 | if (constraint->contype==CONSTR_PRIMARY) |
1107 | 1110 | column->is_not_null= TRUE; |
1108 | 1111 | } |
| 1112 | +elseif (SystemAttributeByName(key->name,cxt->hasoids)!=NULL) |
| 1113 | +{ |
| 1114 | +/* |
| 1115 | + * column will be a system column in the new table, |
| 1116 | + * so accept it. System columns can't ever be null, |
| 1117 | + * so no need to worry about PRIMARY/NOT NULL constraint. |
| 1118 | + */ |
| 1119 | +found= true; |
| 1120 | +} |
1109 | 1121 | elseif (cxt->inhRelnames) |
1110 | 1122 | { |
1111 | 1123 | /* try inherited tables */ |
@@ -2520,6 +2532,10 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt) |
2520 | 2532 | cxt.relOid=GetSysCacheOid(RELNAME, |
2521 | 2533 | PointerGetDatum(stmt->relname), |
2522 | 2534 | 0,0,0); |
| 2535 | +cxt.hasoids=SearchSysCacheExists(ATTNUM, |
| 2536 | +ObjectIdGetDatum(cxt.relOid), |
| 2537 | +Int16GetDatum(ObjectIdAttributeNumber), |
| 2538 | +0,0); |
2523 | 2539 | cxt.columns=NIL; |
2524 | 2540 | cxt.ckconstraints=NIL; |
2525 | 2541 | cxt.fkconstraints=NIL; |
@@ -2548,6 +2564,10 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt) |
2548 | 2564 | cxt.relOid=GetSysCacheOid(RELNAME, |
2549 | 2565 | PointerGetDatum(stmt->relname), |
2550 | 2566 | 0,0,0); |
| 2567 | +cxt.hasoids=SearchSysCacheExists(ATTNUM, |
| 2568 | +ObjectIdGetDatum(cxt.relOid), |
| 2569 | +Int16GetDatum(ObjectIdAttributeNumber), |
| 2570 | +0,0); |
2551 | 2571 | cxt.columns=NIL; |
2552 | 2572 | cxt.ckconstraints=NIL; |
2553 | 2573 | cxt.fkconstraints=NIL; |
|