Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdab708e

Browse files
committed
Cause transformIndexConstraints() to do the right thing with requests
for indexes on system columns. Per complaint from Peter.
1 parentc59839a commitdab708e

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

‎src/backend/parser/analyze.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
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 $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -15,6 +15,7 @@
1515

1616
#include"access/heapam.h"
1717
#include"catalog/catname.h"
18+
#include"catalog/heap.h"
1819
#include"catalog/pg_index.h"
1920
#include"catalog/pg_type.h"
2021
#include"nodes/makefuncs.h"
@@ -50,6 +51,7 @@ typedef struct
5051
char*relname;/* name of relation */
5152
List*inhRelnames;/* names of relations to inherit from */
5253
boolistemp;/* is it to be a temp relation? */
54+
boolhasoids;/* does relation have an OID column? */
5355
OidrelOid;/* OID of table, if ALTER TABLE case */
5456
List*columns;/* ColumnDef items */
5557
List*ckconstraints;/* CHECK constraints */
@@ -720,6 +722,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
720722
cxt.relname=stmt->relname;
721723
cxt.inhRelnames=stmt->inhRelnames;
722724
cxt.istemp=stmt->istemp;
725+
cxt.hasoids=stmt->hasoids;
723726
cxt.relOid=InvalidOid;
724727
cxt.columns=NIL;
725728
cxt.ckconstraints=NIL;
@@ -1106,6 +1109,15 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt)
11061109
if (constraint->contype==CONSTR_PRIMARY)
11071110
column->is_not_null= TRUE;
11081111
}
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+
}
11091121
elseif (cxt->inhRelnames)
11101122
{
11111123
/* try inherited tables */
@@ -2520,6 +2532,10 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt)
25202532
cxt.relOid=GetSysCacheOid(RELNAME,
25212533
PointerGetDatum(stmt->relname),
25222534
0,0,0);
2535+
cxt.hasoids=SearchSysCacheExists(ATTNUM,
2536+
ObjectIdGetDatum(cxt.relOid),
2537+
Int16GetDatum(ObjectIdAttributeNumber),
2538+
0,0);
25232539
cxt.columns=NIL;
25242540
cxt.ckconstraints=NIL;
25252541
cxt.fkconstraints=NIL;
@@ -2548,6 +2564,10 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt)
25482564
cxt.relOid=GetSysCacheOid(RELNAME,
25492565
PointerGetDatum(stmt->relname),
25502566
0,0,0);
2567+
cxt.hasoids=SearchSysCacheExists(ATTNUM,
2568+
ObjectIdGetDatum(cxt.relOid),
2569+
Int16GetDatum(ObjectIdAttributeNumber),
2570+
0,0);
25512571
cxt.columns=NIL;
25522572
cxt.ckconstraints=NIL;
25532573
cxt.fkconstraints=NIL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp