7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.23 1998/08/26 05:22:36 momjian Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.24 1998/08/26 16:43:41 momjian Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -468,7 +468,7 @@ NormIndexAttrs(List *attList, /* list of IndexElem's */
468
468
Oid relId )
469
469
{
470
470
List * rest ;
471
- HeapTuple tuple ;
471
+ HeapTuple atttuple , tuple ;
472
472
473
473
/*
474
474
* process attributeList
@@ -484,20 +484,34 @@ NormIndexAttrs(List *attList, /* list of IndexElem's */
484
484
if (attribute -> name == NULL )
485
485
elog (ERROR , "missing attribute for define index" );
486
486
487
- tuple = SearchSysCacheTuple (ATTNAME ,
487
+ atttuple = SearchSysCacheTupleCopy (ATTNAME ,
488
488
ObjectIdGetDatum (relId ),
489
489
PointerGetDatum (attribute -> name ),
490
490
0 , 0 );
491
- if (!HeapTupleIsValid (tuple ))
491
+ if (!HeapTupleIsValid (atttuple ))
492
492
{
493
493
elog (ERROR ,
494
494
"DefineIndex: attribute \"%s\" not found" ,
495
495
attribute -> name );
496
496
}
497
497
498
- attform = (AttributeTupleForm ) GETSTRUCT (tuple );
498
+ attform = (AttributeTupleForm ) GETSTRUCT (atttuple );
499
499
* attNumP ++ = attform -> attnum ;
500
500
501
+ /* we want the type so we can set the proper alignment, etc. */
502
+ if (attribute -> typename == NULL )
503
+ {
504
+ tuple = SearchSysCacheTuple (TYPOID ,
505
+ ObjectIdGetDatum (attform -> atttypid ),
506
+ 0 , 0 , 0 );
507
+ if (!HeapTupleIsValid (tuple ))
508
+ elog (ERROR , "create index: type for attribute '%s' undefined" ,
509
+ attribute -> name );
510
+ /* we just set the type name because that is all we need */
511
+ attribute -> typename = makeNode (TypeName );
512
+ attribute -> typename -> name = nameout (& ((TypeTupleForm ) GETSTRUCT (tuple ))-> typname );
513
+ }
514
+
501
515
if (attribute -> class == NULL )
502
516
{
503
517
/* no operator class specified, so find the default */
@@ -520,21 +534,7 @@ NormIndexAttrs(List *attList, /* list of IndexElem's */
520
534
attribute -> class );
521
535
}
522
536
* classOidP ++ = tuple -> t_oid ;
523
- /* we want the type so we can set the proper alignment, etc. */
524
- if (attribute -> typename == NULL )
525
- {
526
- Oid typoid = ((Form_pg_opclass ) GETSTRUCT (tuple ))-> opcdeftype ;
527
-
528
- tuple = SearchSysCacheTuple (TYPOID ,
529
- ObjectIdGetDatum (typoid ),
530
- 0 , 0 , 0 );
531
- if (!HeapTupleIsValid (tuple ))
532
- elog (ERROR , "create index: type for class '%s' undefined" ,
533
- attribute -> class );
534
- /* we just set the name because that is all we need */
535
- attribute -> typename = makeNode (TypeName );
536
- attribute -> typename -> name = nameout (& ((TypeTupleForm ) GETSTRUCT (tuple ))-> typname );
537
- }
537
+ pfree (atttuple );
538
538
}
539
539
}
540
540
0 commit comments