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

Commitd656e02

Browse files
committed
Fix index_create for multi-column indices
1 parent8157c83 commitd656e02

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

‎src/backend/catalog/index.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.11 1997/01/10 09:51:38 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.12 1997/03/19 07:44:45 vadim Exp $
1111
*
1212
*
1313
* INTERFACE ROUTINES
@@ -68,7 +68,7 @@ static Oid RelationNameGetObjectId(char *relationName, Relation pg_class,
6868
staticOidGetHeapRelationOid(char*heapRelationName,char*indexRelationName);
6969
staticTupleDescBuildFuncTupleDesc(FuncIndexInfo*funcInfo);
7070
staticTupleDescConstructTupleDescriptor(Oidheapoid,RelationheapRelation,
71-
TypeName*IndexKeyType,
71+
List*attributeList,
7272
intnumatts,AttrNumberattNums[]);
7373

7474
staticvoidConstructIndexReldesc(RelationindexRelation,Oidamoid);
@@ -81,7 +81,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts);
8181
staticvoidUpdateIndexRelation(Oidindexoid,Oidheapoid,
8282
FuncIndexInfo*funcInfo,intnatts,
8383
AttrNumberattNums[],OidclassOids[],Node*predicate,
84-
TypeName*indexKeyType,boolislossy,boolunique);
84+
List*attributeList,boolislossy,boolunique);
8585
staticvoidDefaultBuild(RelationheapRelation,RelationindexRelation,
8686
intnumberOfAttributes,AttrNumberattributeNumber[],
8787
IndexStrategyindexStrategy,uint16parameterCount,
@@ -325,12 +325,14 @@ BuildFuncTupleDesc(FuncIndexInfo *funcInfo)
325325
staticTupleDesc
326326
ConstructTupleDescriptor(Oidheapoid,
327327
RelationheapRelation,
328-
TypeName*IndexKeyType,
328+
List*attributeList,
329329
intnumatts,
330330
AttrNumberattNums[])
331331
{
332332
TupleDescheapTupDesc;
333333
TupleDescindexTupDesc;
334+
IndexElem*IndexKey;
335+
TypeName*IndexKeyType;
334336
AttrNumberatnum;/* attributeNumber[attributeOffset] */
335337
AttrNumberatind;
336338
intnatts;/* RelationTupleForm->relnatts */
@@ -367,6 +369,9 @@ ConstructTupleDescriptor(Oid heapoid,
367369
if (atnum>natts)
368370
elog(WARN,"Cannot create index: attribute %d does not exist",
369371
atnum);
372+
IndexKey= (IndexElem*)lfirst(attributeList);
373+
attributeList=lnext(attributeList);
374+
IndexKeyType=IndexKey->tname;
370375

371376
indexTupDesc->attrs[i]= (AttributeTupleForm)palloc(ATTRIBUTE_TUPLE_SIZE);
372377

@@ -693,7 +698,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
693698
*/
694699
memmove(GETSTRUCT(tuple),
695700
(char*)indexTupDesc->attrs[i],
696-
sizeof (AttributeTupleForm));
701+
sizeof (FormData_pg_attribute));
697702

698703
value[Anum_pg_attribute_attnum-1 ]=Int16GetDatum(i+1);
699704

@@ -741,11 +746,12 @@ UpdateIndexRelation(Oid indexoid,
741746
AttrNumberattNums[],
742747
OidclassOids[],
743748
Node*predicate,
744-
TypeName*indexKeyType,
749+
List*attributeList,
745750
boolislossy,
746751
boolunique)
747752
{
748753
IndexTupleFormindexForm;
754+
IndexElem*IndexKey;
749755
char*predString;
750756
text*predText;
751757
intpredLen,itupLen;
@@ -781,10 +787,18 @@ UpdateIndexRelation(Oid indexoid,
781787
FIgetProcOid(funcInfo) :InvalidOid;
782788
indexForm->indislossy=islossy;
783789
indexForm->indisunique=unique;
784-
if (indexKeyType!=NULL)
785-
indexForm->indhaskeytype=1;
786-
else
787-
indexForm->indhaskeytype=0;
790+
791+
indexForm->indhaskeytype=0;
792+
while (attributeList!=NIL )
793+
{
794+
IndexKey= (IndexElem*)lfirst(attributeList);
795+
if (IndexKey->tname!=NULL )
796+
{
797+
indexForm->indhaskeytype=1;
798+
break;
799+
}
800+
attributeList=lnext(attributeList);
801+
}
788802

789803
memset((char*)&indexForm->indkey[0],0,sizeofindexForm->indkey);
790804
memset((char*)&indexForm->indclass[0],0,sizeofindexForm->indclass);
@@ -1002,7 +1016,7 @@ void
10021016
index_create(char*heapRelationName,
10031017
char*indexRelationName,
10041018
FuncIndexInfo*funcInfo,
1005-
TypeName*IndexKeyType,
1019+
List*attributeList,
10061020
OidaccessMethodObjectId,
10071021
intnumatts,
10081022
AttrNumberattNums[],
@@ -1052,7 +1066,7 @@ index_create(char *heapRelationName,
10521066
else
10531067
indexTupDesc=ConstructTupleDescriptor(heapoid,
10541068
heapRelation,
1055-
IndexKeyType,
1069+
attributeList,
10561070
numatts,
10571071
attNums);
10581072

@@ -1125,7 +1139,7 @@ index_create(char *heapRelationName,
11251139
*/
11261140
UpdateIndexRelation(indexoid,heapoid,funcInfo,
11271141
numatts,attNums,classObjectId,predicate,
1128-
IndexKeyType,islossy,unique);
1142+
attributeList,islossy,unique);
11291143

11301144
predInfo= (PredInfo*)palloc(sizeof(PredInfo));
11311145
predInfo->pred=predicate;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp