Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
c59839ac
Commit
c59839ac
authored
Oct 22, 2001
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consolidate tables of known system attributes into one table.
parent
b00c6c84
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
70 deletions
+47
-70
src/backend/catalog/heap.c
src/backend/catalog/heap.c
+30
-11
src/backend/parser/parse_relation.c
src/backend/parser/parse_relation.c
+12
-56
src/include/catalog/heap.h
src/include/catalog/heap.h
+5
-3
No files found.
src/backend/catalog/heap.c
View file @
c59839ac
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.17
7 2001/10/06 23:21:43
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.17
8 2001/10/22 22:47:57
tgl Exp $
*
*
*
*
* INTERFACE ROUTINES
* INTERFACE ROUTINES
...
@@ -151,6 +151,7 @@ static Form_pg_attribute SysAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6, &a7};
...
@@ -151,6 +151,7 @@ static Form_pg_attribute SysAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6, &a7};
/*
/*
* This function returns a Form_pg_attribute pointer for a system attribute.
* This function returns a Form_pg_attribute pointer for a system attribute.
* Note that we elog if the presented attno is invalid.
*/
*/
Form_pg_attribute
Form_pg_attribute
SystemAttributeDefinition
(
AttrNumber
attno
,
bool
relhasoids
)
SystemAttributeDefinition
(
AttrNumber
attno
,
bool
relhasoids
)
...
@@ -164,6 +165,30 @@ SystemAttributeDefinition(AttrNumber attno, bool relhasoids)
...
@@ -164,6 +165,30 @@ SystemAttributeDefinition(AttrNumber attno, bool relhasoids)
return
SysAtt
[
-
attno
-
1
];
return
SysAtt
[
-
attno
-
1
];
}
}
/*
* If the given name is a system attribute name, return a Form_pg_attribute
* pointer for a prototype definition. If not, return NULL.
*/
Form_pg_attribute
SystemAttributeByName
(
const
char
*
attname
,
bool
relhasoids
)
{
int
j
;
for
(
j
=
0
;
j
<
(
int
)
lengthof
(
SysAtt
);
j
++
)
{
Form_pg_attribute
att
=
SysAtt
[
j
];
if
(
relhasoids
||
att
->
attnum
!=
ObjectIdAttributeNumber
)
{
if
(
strcmp
(
NameStr
(
att
->
attname
),
attname
)
==
0
)
return
att
;
}
}
return
NULL
;
}
/* ----------------------------------------------------------------
/* ----------------------------------------------------------------
* XXX END OF UGLY HARD CODED BADNESS XXX
* XXX END OF UGLY HARD CODED BADNESS XXX
* ---------------------------------------------------------------- */
* ---------------------------------------------------------------- */
...
@@ -350,16 +375,10 @@ CheckAttributeNames(TupleDesc tupdesc, bool relhasoids)
...
@@ -350,16 +375,10 @@ CheckAttributeNames(TupleDesc tupdesc, bool relhasoids)
*/
*/
for
(
i
=
0
;
i
<
natts
;
i
++
)
for
(
i
=
0
;
i
<
natts
;
i
++
)
{
{
for
(
j
=
0
;
j
<
(
int
)
lengthof
(
SysAtt
);
j
++
)
if
(
SystemAttributeByName
(
NameStr
(
tupdesc
->
attrs
[
i
]
->
attname
),
{
relhasoids
)
!=
NULL
)
if
(
relhasoids
||
SysAtt
[
j
]
->
attnum
!=
ObjectIdAttributeNumber
)
{
if
(
strcmp
(
NameStr
(
SysAtt
[
j
]
->
attname
),
NameStr
(
tupdesc
->
attrs
[
i
]
->
attname
))
==
0
)
elog
(
ERROR
,
"name of column
\"
%s
\"
conflicts with an existing system column"
,
elog
(
ERROR
,
"name of column
\"
%s
\"
conflicts with an existing system column"
,
NameStr
(
SysAtt
[
j
]
->
attname
));
NameStr
(
tupdesc
->
attrs
[
i
]
->
attname
));
}
}
if
(
tupdesc
->
attrs
[
i
]
->
atttypid
==
UNKNOWNOID
)
if
(
tupdesc
->
attrs
[
i
]
->
atttypid
==
UNKNOWNOID
)
elog
(
NOTICE
,
"Attribute '%s' has an unknown type"
elog
(
NOTICE
,
"Attribute '%s' has an unknown type"
"
\n\t
Proceeding with relation creation anyway"
,
"
\n\t
Proceeding with relation creation anyway"
,
...
...
src/backend/parser/parse_relation.c
View file @
c59839ac
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.5
6 2001/08/10 18:57:3
7 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.5
7 2001/10/22 22:47:5
7 tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include "access/heapam.h"
#include "access/heapam.h"
#include "access/htup.h"
#include "access/htup.h"
#include "catalog/heap.h"
#include "catalog/pg_type.h"
#include "catalog/pg_type.h"
#include "nodes/makefuncs.h"
#include "nodes/makefuncs.h"
#include "parser/parsetree.h"
#include "parser/parsetree.h"
...
@@ -43,43 +44,6 @@ static int specialAttNum(char *a);
...
@@ -43,43 +44,6 @@ static int specialAttNum(char *a);
static
void
warnAutoRange
(
ParseState
*
pstate
,
char
*
refname
);
static
void
warnAutoRange
(
ParseState
*
pstate
,
char
*
refname
);
/*
* Information defining the "system" attributes of every relation.
*/
static
struct
{
char
*
attrname
;
/* name of system attribute */
int
attrnum
;
/* its attribute number (always < 0) */
Oid
attrtype
;
/* its type id */
}
special_attr
[]
=
{
{
"ctid"
,
SelfItemPointerAttributeNumber
,
TIDOID
},
{
"oid"
,
ObjectIdAttributeNumber
,
OIDOID
},
{
"xmin"
,
MinTransactionIdAttributeNumber
,
XIDOID
},
{
"cmin"
,
MinCommandIdAttributeNumber
,
CIDOID
},
{
"xmax"
,
MaxTransactionIdAttributeNumber
,
XIDOID
},
{
"cmax"
,
MaxCommandIdAttributeNumber
,
CIDOID
},
{
"tableoid"
,
TableOidAttributeNumber
,
OIDOID
}
};
#define SPECIALS ((int) lengthof(special_attr))
/*
/*
* refnameRangeOrJoinEntry
* refnameRangeOrJoinEntry
* Given a refname, look to see if it matches any RTE or join table.
* Given a refname, look to see if it matches any RTE or join table.
...
@@ -1001,39 +965,31 @@ attnameAttNum(Relation rd, char *a)
...
@@ -1001,39 +965,31 @@ attnameAttNum(Relation rd, char *a)
static
int
static
int
specialAttNum
(
char
*
a
)
specialAttNum
(
char
*
a
)
{
{
int
i
;
Form_pg_attribute
sysatt
;
for
(
i
=
0
;
i
<
SPECIALS
;
i
++
)
if
(
strcmp
(
special_attr
[
i
].
attrname
,
a
)
==
0
)
return
special_attr
[
i
].
attrnum
;
sysatt
=
SystemAttributeByName
(
a
,
true
/* "oid" will be accepted */
);
if
(
sysatt
!=
NULL
)
return
sysatt
->
attnum
;
return
InvalidAttrNumber
;
return
InvalidAttrNumber
;
}
}
/* given attribute id, return type of that attribute */
/*
/*
* given attribute id, return type of that attribute
*
* This should only be used if the relation is already
* This should only be used if the relation is already
* heap_open()'ed. Use the cache version get_atttype()
* heap_open()'ed. Use the cache version get_atttype()
* for access to non-opened relations.
* for access to non-opened relations.
*
* Note: we don't bother to check rd->rd_rel->relhasoids; we assume that
* the caller will only ask about OID if that column has been found valid.
*/
*/
Oid
Oid
attnumTypeId
(
Relation
rd
,
int
attid
)
attnumTypeId
(
Relation
rd
,
int
attid
)
{
{
if
(
attid
<
0
)
if
(
attid
<
=
0
)
{
{
int
i
;
Form_pg_attribute
sysatt
;
for
(
i
=
0
;
i
<
SPECIALS
;
i
++
)
sysatt
=
SystemAttributeDefinition
(
attid
,
rd
->
rd_rel
->
relhasoids
);
{
return
sysatt
->
atttypid
;
if
(
special_attr
[
i
].
attrnum
==
attid
)
return
special_attr
[
i
].
attrtype
;
}
/* negative but not a valid system attr? */
elog
(
ERROR
,
"attnumTypeId: bogus attribute number %d"
,
attid
);
}
}
/*
/*
...
...
src/include/catalog/heap.h
View file @
c59839ac
/*-------------------------------------------------------------------------
/*-------------------------------------------------------------------------
*
*
* heap.h
* heap.h
* prototypes for functions in
lib
/catalog/heap.c
* prototypes for functions in
backend
/catalog/heap.c
*
*
*
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: heap.h,v 1.3
7 2001/08/10 18:57:39
tgl Exp $
* $Id: heap.h,v 1.3
8 2001/10/22 22:47:57
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -47,8 +47,10 @@ extern void AddRelationRawConstraints(Relation rel,
...
@@ -47,8 +47,10 @@ extern void AddRelationRawConstraints(Relation rel,
extern
int
RemoveCheckConstraint
(
Relation
rel
,
const
char
*
constrName
,
bool
inh
);
extern
int
RemoveCheckConstraint
(
Relation
rel
,
const
char
*
constrName
,
bool
inh
);
extern
Form_pg_attribute
SystemAttributeDefinition
(
AttrNumber
attno
,
extern
Form_pg_attribute
SystemAttributeDefinition
(
AttrNumber
attno
,
bool
relhasoids
);
bool
relhasoids
);
extern
Form_pg_attribute
SystemAttributeByName
(
const
char
*
attname
,
bool
relhasoids
);
#endif
/* HEAP_H */
#endif
/* HEAP_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment