@ -572,6 +572,10 @@ CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind,
* are reliably identifiable only within a session , since the identity info
* are reliably identifiable only within a session , since the identity info
* may use a typmod that is only locally assigned . The caller is expected
* may use a typmod that is only locally assigned . The caller is expected
* to know whether these cases are safe . )
* to know whether these cases are safe . )
*
* flags can also control the phrasing of the error messages . If
* CHKATYPE_IS_PARTKEY is specified , " attname " should be a partition key
* column number as text , not a real column name .
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
*/
void
void
@ -598,10 +602,19 @@ CheckAttributeType(const char *attname,
if ( ! ( ( atttypid = = ANYARRAYOID & & ( flags & CHKATYPE_ANYARRAY ) ) | |
if ( ! ( ( atttypid = = ANYARRAYOID & & ( flags & CHKATYPE_ANYARRAY ) ) | |
( atttypid = = RECORDOID & & ( flags & CHKATYPE_ANYRECORD ) ) | |
( atttypid = = RECORDOID & & ( flags & CHKATYPE_ANYRECORD ) ) | |
( atttypid = = RECORDARRAYOID & & ( flags & CHKATYPE_ANYRECORD ) ) ) )
( atttypid = = RECORDARRAYOID & & ( flags & CHKATYPE_ANYRECORD ) ) ) )
ereport ( ERROR ,
{
( errcode ( ERRCODE_INVALID_TABLE_DEFINITION ) ,
if ( flags & CHKATYPE_IS_PARTKEY )
errmsg ( " column \" %s \" has pseudo-type %s " ,
ereport ( ERROR ,
attname , format_type_be ( atttypid ) ) ) ) ;
( errcode ( ERRCODE_INVALID_TABLE_DEFINITION ) ,
/* translator: first %s is an integer not a name */
errmsg ( " partition key column %s has pseudo-type %s " ,
attname , format_type_be ( atttypid ) ) ) ) ;
else
ereport ( ERROR ,
( errcode ( ERRCODE_INVALID_TABLE_DEFINITION ) ,
errmsg ( " column \" %s \" has pseudo-type %s " ,
attname , format_type_be ( atttypid ) ) ) ) ;
}
}
}
else if ( att_typtype = = TYPTYPE_DOMAIN )
else if ( att_typtype = = TYPTYPE_DOMAIN )
{
{
@ -648,7 +661,7 @@ CheckAttributeType(const char *attname,
CheckAttributeType ( NameStr ( attr - > attname ) ,
CheckAttributeType ( NameStr ( attr - > attname ) ,
attr - > atttypid , attr - > attcollation ,
attr - > atttypid , attr - > attcollation ,
containing_rowtypes ,
containing_rowtypes ,
flags ) ;
flags & ~ CHKATYPE_IS_PARTKEY ) ;
}
}
relation_close ( relation , AccessShareLock ) ;
relation_close ( relation , AccessShareLock ) ;
@ -679,11 +692,21 @@ CheckAttributeType(const char *attname,
* useless , and it cannot be dumped , so we must disallow it .
* useless , and it cannot be dumped , so we must disallow it .
*/
*/
if ( ! OidIsValid ( attcollation ) & & type_is_collatable ( atttypid ) )
if ( ! OidIsValid ( attcollation ) & & type_is_collatable ( atttypid ) )
ereport ( ERROR ,
{
( errcode ( ERRCODE_INVALID_TABLE_DEFINITION ) ,
if ( flags & CHKATYPE_IS_PARTKEY )
errmsg ( " no collation was derived for column \" %s \" with collatable type %s " ,
ereport ( ERROR ,
attname , format_type_be ( atttypid ) ) ,
( errcode ( ERRCODE_INVALID_TABLE_DEFINITION ) ,
errhint ( " Use the COLLATE clause to set the collation explicitly. " ) ) ) ;
/* translator: first %s is an integer not a name */
errmsg ( " no collation was derived for partition key column %s with collatable type %s " ,
attname , format_type_be ( atttypid ) ) ,
errhint ( " Use the COLLATE clause to set the collation explicitly. " ) ) ) ;
else
ereport ( ERROR ,
( errcode ( ERRCODE_INVALID_TABLE_DEFINITION ) ,
errmsg ( " no collation was derived for column \" %s \" with collatable type %s " ,
attname , format_type_be ( atttypid ) ) ,
errhint ( " Use the COLLATE clause to set the collation explicitly. " ) ) ) ;
}
}
}
/*
/*