88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.202 2002/05/2207:46:58 inoue Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.203 2002/05/2215:35:43 tgl Exp $
1212 *
1313 *
1414 * INTERFACE ROUTINES
@@ -353,7 +353,7 @@ heap_storage_create(Relation rel)
353353 * --------------------------------
354354 */
355355static void
356- CheckAttributeNames (TupleDesc tupdesc ,bool relhasoids ,int relkind )
356+ CheckAttributeNames (TupleDesc tupdesc ,bool relhasoids ,char relkind )
357357{
358358int i ;
359359int j ;
@@ -362,21 +362,30 @@ CheckAttributeNames(TupleDesc tupdesc, bool relhasoids, int relkind)
362362/*
363363 * first check for collision with system attribute names
364364 *
365- * also, warn user if attribute to be created has an unknown typid
366- * (usually as a result of a 'retrieve into' - jolly
365+ * Skip this for a view, since it doesn't have system attributes.
367366 */
368367if (relkind != RELKIND_VIEW )
368+ {
369369for (i = 0 ;i < natts ;i ++ )
370370{
371371if (SystemAttributeByName (NameStr (tupdesc -> attrs [i ]-> attname ),
372- relhasoids )!= NULL )
372+ relhasoids )!= NULL )
373373elog (ERROR ,"name of column \"%s\" conflicts with an existing system column" ,
374- NameStr (tupdesc -> attrs [i ]-> attname ));
375- if (tupdesc -> attrs [i ]-> atttypid == UNKNOWNOID )
376- elog (WARNING ,"Attribute '%s' has an unknown type"
374+ NameStr (tupdesc -> attrs [i ]-> attname ));
375+ }
376+ }
377+
378+ /*
379+ * also, warn user if attribute to be created has an unknown typid
380+ * (usually as a result of a 'retrieve into' - jolly
381+ */
382+ for (i = 0 ;i < natts ;i ++ )
383+ {
384+ if (tupdesc -> attrs [i ]-> atttypid == UNKNOWNOID )
385+ elog (WARNING ,"Attribute '%s' has an unknown type"
377386"\n\tProceeding with relation creation anyway" ,
378387NameStr (tupdesc -> attrs [i ]-> attname ));
379- }
388+ }
380389
381390/*
382391 * next check for repeated attribute names
@@ -404,7 +413,7 @@ static void
404413AddNewAttributeTuples (Oid new_rel_oid ,
405414TupleDesc tupdesc ,
406415bool relhasoids ,
407- int relkind )
416+ char relkind )
408417{
409418Form_pg_attribute * dpp ;
410419int i ;
@@ -454,17 +463,18 @@ AddNewAttributeTuples(Oid new_rel_oid,
454463/*
455464 * next we add the system attributes. Skip OID if rel has no OIDs.
456465 */
457- dpp = SysAtt ;
458466if (relkind != RELKIND_VIEW )
467+ {
468+ dpp = SysAtt ;
459469for (i = 0 ;i < -1 - FirstLowInvalidHeapAttributeNumber ;i ++ )
460470{
461471if (relhasoids || (* dpp )-> attnum != ObjectIdAttributeNumber )
462472{
463473Form_pg_attribute attStruct ;
464474
465475tup = heap_addheader (Natts_pg_attribute ,
466- ATTRIBUTE_TUPLE_SIZE ,
467- (void * )* dpp );
476+ ATTRIBUTE_TUPLE_SIZE ,
477+ (void * )* dpp );
468478
469479/* Fill in the correct relation OID in the copied tuple */
470480attStruct = (Form_pg_attribute )GETSTRUCT (tup );
@@ -484,7 +494,9 @@ AddNewAttributeTuples(Oid new_rel_oid,
484494
485495heap_freetuple (tup );
486496}
497+ dpp ++ ;
487498}
499+ }
488500
489501/*
490502 * close pg_attribute indices
@@ -719,7 +731,8 @@ heap_create_with_catalog(const char *relname,
719731 * now add tuples to pg_attribute for the attributes in our new
720732 * relation.
721733 */
722- AddNewAttributeTuples (new_rel_oid ,new_rel_desc -> rd_att ,relhasoids ,relkind );
734+ AddNewAttributeTuples (new_rel_oid ,new_rel_desc -> rd_att ,
735+ relhasoids ,relkind );
723736
724737/*
725738 * store constraints and defaults passed in the tupdesc, if any.