@ -342,6 +342,7 @@ DefineIndex(Oid relationId,
Oid tablespaceId ;
Oid tablespaceId ;
Oid createdConstraintId = InvalidOid ;
Oid createdConstraintId = InvalidOid ;
List * indexColNames ;
List * indexColNames ;
List * allIndexParams ;
Relation rel ;
Relation rel ;
Relation indexRelation ;
Relation indexRelation ;
HeapTuple tuple ;
HeapTuple tuple ;
@ -378,16 +379,16 @@ DefineIndex(Oid relationId,
numberOfKeyAttributes = list_length ( stmt - > indexParams ) ;
numberOfKeyAttributes = list_length ( stmt - > indexParams ) ;
/*
/*
* We append any INCLUDE columns onto the indexParams list so that we have
* Calculate the new list of index columns including both key columns and
* one list with all columns . Later we can determine which of these are
* INCLUDE columns . Later we can determine which of these are key columns ,
* key columns , and which are just part of the INCLUDE list by checking
* and which are just part of the INCLUDE list by checking the list
* the list position . A list item in a position less than
* position . A list item in a position less than ii_NumIndexKeyAttrs is
* ii_NumIndexKeyAttrs is part of the key columns , and anything equal to
* part of the key columns , and anything equal to and over is part of the
* and over is part of the INCLUDE columns .
* INCLUDE columns .
*/
*/
stmt - > indexParams = list_concat ( stmt - > indexParams ,
allIndexParams = list_concat ( list_copy ( stmt - > indexParams ) ,
stmt - > indexIncludingParams ) ;
list_copy ( stmt - > indexIncludingParams ) ) ;
numberOfAttributes = list_length ( stmt - > i ndexParams) ;
numberOfAttributes = list_length ( allI ndexParams) ;
if ( numberOfAttributes < = 0 )
if ( numberOfAttributes < = 0 )
ereport ( ERROR ,
ereport ( ERROR ,
@ -544,7 +545,7 @@ DefineIndex(Oid relationId,
/*
/*
* Choose the index column names .
* Choose the index column names .
*/
*/
indexColNames = ChooseIndexColumnNames ( stmt - > i ndexParams) ;
indexColNames = ChooseIndexColumnNames ( allI ndexParams) ;
/*
/*
* Select name for index if caller didn ' t specify
* Select name for index if caller didn ' t specify
@ -658,7 +659,7 @@ DefineIndex(Oid relationId,
coloptions = ( int16 * ) palloc ( numberOfAttributes * sizeof ( int16 ) ) ;
coloptions = ( int16 * ) palloc ( numberOfAttributes * sizeof ( int16 ) ) ;
ComputeIndexAttrs ( indexInfo ,
ComputeIndexAttrs ( indexInfo ,
typeObjectId , collationObjectId , classObjectId ,
typeObjectId , collationObjectId , classObjectId ,
coloptions , stmt - > i ndexParams,
coloptions , allI ndexParams,
stmt - > excludeOpNames , relationId ,
stmt - > excludeOpNames , relationId ,
accessMethodName , accessMethodId ,
accessMethodName , accessMethodId ,
amcanorder , stmt - > isconstraint ) ;
amcanorder , stmt - > isconstraint ) ;
@ -886,8 +887,8 @@ DefineIndex(Oid relationId,
memcpy ( part_oids , partdesc - > oids , sizeof ( Oid ) * nparts ) ;
memcpy ( part_oids , partdesc - > oids , sizeof ( Oid ) * nparts ) ;
parentDesc = CreateTupleDescCopy ( RelationGetDescr ( rel ) ) ;
parentDesc = CreateTupleDescCopy ( RelationGetDescr ( rel ) ) ;
opfamOids = palloc ( sizeof ( Oid ) * numberOfAttributes ) ;
opfamOids = palloc ( sizeof ( Oid ) * numberOfKey Attributes ) ;
for ( i = 0 ; i < numberOfAttributes ; i + + )
for ( i = 0 ; i < numberOfKey Attributes ; i + + )
opfamOids [ i ] = get_opclass_family ( classObjectId [ i ] ) ;
opfamOids [ i ] = get_opclass_family ( classObjectId [ i ] ) ;
heap_close ( rel , NoLock ) ;
heap_close ( rel , NoLock ) ;