From 093beb3560e403c0c8bd726d1f1b0b916bbb7a67 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Wed, 26 Aug 1998 05:22:58 +0000 Subject: Make attalign match type alignment. --- src/backend/commands/defind.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/backend/commands/defind.c') diff --git a/src/backend/commands/defind.c b/src/backend/commands/defind.c index 7a0676a7738..ee4678372e0 100644 --- a/src/backend/commands/defind.c +++ b/src/backend/commands/defind.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.22 1998/08/19 02:01:48 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.23 1998/08/26 05:22:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -195,9 +196,8 @@ DefineIndex(char *heapRelationName, } else { - attributeNumberA = - (AttrNumber *) palloc(numberOfAttributes * - sizeof attributeNumberA[0]); + attributeNumberA = (AttrNumber *) palloc(numberOfAttributes * + sizeof attributeNumberA[0]); classObjectId = (Oid *) palloc(numberOfAttributes * sizeof classObjectId[0]); @@ -464,7 +464,7 @@ FuncIndexArgs(IndexElem *funcIndex, static void NormIndexAttrs(List *attList, /* list of IndexElem's */ AttrNumber *attNumP, - Oid *opOidP, + Oid *classOidP, Oid relId) { List *rest; @@ -519,7 +519,22 @@ NormIndexAttrs(List *attList, /* list of IndexElem's */ elog(ERROR, "DefineIndex: %s class not found", attribute->class); } - *opOidP++ = tuple->t_oid; + *classOidP++ = tuple->t_oid; + /* we want the type so we can set the proper alignment, etc. */ + if (attribute->typename == NULL) + { + Oid typoid = ((Form_pg_opclass) GETSTRUCT(tuple))->opcdeftype; + + tuple = SearchSysCacheTuple(TYPOID, + ObjectIdGetDatum(typoid), + 0, 0, 0); + if (!HeapTupleIsValid(tuple)) + elog(ERROR, "create index: type for class '%s' undefined", + attribute->class); + /* we just set the name because that is all we need */ + attribute->typename = makeNode(TypeName); + attribute->typename->name = nameout(&((TypeTupleForm) GETSTRUCT(tuple))->typname); + } } } -- cgit v1.2.3