mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
The following patch finishes primary key support. Previously, when
a field was labelled as a primary key, the system automatically
created a unique index on the field. This patch extends it so
that the index has the indisprimary field set. You can pull a list
of primary keys with the followiing select.
SELECT pg_class.relname, pg_attribute.attname
FROM pg_class, pg_attribute, pg_index
WHERE pg_class.oid = pg_attribute.attrelid AND
pg_class.oid = pg_index.indrelid AND
pg_index.indkey[0] = pg_attribute.attnum AND
pg_index.indisunique = 't';
There is nothing in this patch that modifies the template database to
set the indisprimary attribute for system tables. Should they be
changed or should we only be concerned with user tables?
D'Arcy
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.66 1998/12/15 12:45:43 vadim Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.67 1999/01/21 22:48:05 momjian Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@@ -82,7 +82,7 @@ static void
|
||||
static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
|
||||
FuncIndexInfo *funcInfo, int natts,
|
||||
AttrNumber *attNums, Oid *classOids, Node *predicate,
|
||||
List *attributeList, bool islossy, bool unique);
|
||||
List *attributeList, bool islossy, bool unique, bool primary);
|
||||
static void DefaultBuild(Relation heapRelation, Relation indexRelation,
|
||||
int numberOfAttributes, AttrNumber *attributeNumber,
|
||||
IndexStrategy indexStrategy, uint16 parameterCount,
|
||||
@@ -734,7 +734,8 @@ UpdateIndexRelation(Oid indexoid,
|
||||
Node *predicate,
|
||||
List *attributeList,
|
||||
bool islossy,
|
||||
bool unique)
|
||||
bool unique,
|
||||
bool primary)
|
||||
{
|
||||
Form_pg_index indexForm;
|
||||
IndexElem *IndexKey;
|
||||
@@ -775,6 +776,7 @@ UpdateIndexRelation(Oid indexoid,
|
||||
indexForm->indproc = (PointerIsValid(funcInfo)) ?
|
||||
FIgetProcOid(funcInfo) : InvalidOid;
|
||||
indexForm->indislossy = islossy;
|
||||
indexForm->indisprimary = primary;
|
||||
indexForm->indisunique = unique;
|
||||
|
||||
indexForm->indhaskeytype = 0;
|
||||
@@ -1014,7 +1016,8 @@ index_create(char *heapRelationName,
|
||||
Datum *parameter,
|
||||
Node *predicate,
|
||||
bool islossy,
|
||||
bool unique)
|
||||
bool unique,
|
||||
bool primary)
|
||||
{
|
||||
Relation heapRelation;
|
||||
Relation indexRelation;
|
||||
@@ -1126,7 +1129,7 @@ index_create(char *heapRelationName,
|
||||
*/
|
||||
UpdateIndexRelation(indexoid, heapoid, funcInfo,
|
||||
numatts, attNums, classObjectId, predicate,
|
||||
attributeList, islossy, unique);
|
||||
attributeList, islossy, unique, primary);
|
||||
|
||||
predInfo = (PredInfo *) palloc(sizeof(PredInfo));
|
||||
predInfo->pred = predicate;
|
||||
|
||||
Reference in New Issue
Block a user