@ -379,7 +379,7 @@ static void ATExecCheckNotNull(AlteredTableInfo *tab, Relation rel,
const char * colName , LOCKMODE lockmode ) ;
static bool NotNullImpliedByRelConstraints ( Relation rel , Form_pg_attribute attr ) ;
static bool ConstraintImpliedByRelConstraint ( Relation scanrel ,
List * partConstraint , List * existedConstraints ) ;
List * partConstraint , List * existedConstraints ) ;
static ObjectAddress ATExecColumnDefault ( Relation rel , const char * colName ,
Node * newDefault , LOCKMODE lockmode ) ;
static ObjectAddress ATExecAddIdentity ( Relation rel , const char * colName ,
@ -1099,9 +1099,9 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
}
/*
* Now add any newly specified CHECK constraints to the new relation .
* Same as for defaults above , but these need to come after partitioning
* is set up .
* Now add any newly specified CHECK constraints to the new relation . Same
* as for defaults above , but these need to come after partitioning is set
* up .
*/
if ( stmt - > constraints )
AddRelationNewConstraints ( rel , NIL , stmt - > constraints ,
@ -1401,9 +1401,9 @@ RangeVarCallbackForDropRelation(const RangeVar *rel, Oid relOid, Oid oldRelOid,
*/
if ( IsSystemClass ( relOid , classform ) & & relkind = = RELKIND_INDEX )
{
HeapTuple locTuple ;
Form_pg_index indexform ;
bool indisvalid ;
HeapTuple locTuple ;
Form_pg_index indexform ;
bool indisvalid ;
locTuple = SearchSysCache1 ( INDEXRELID , ObjectIdGetDatum ( relOid ) ) ;
if ( ! HeapTupleIsValid ( locTuple ) )
@ -1786,6 +1786,7 @@ ExecuteTruncateGuts(List *explicit_rels, List *relids, List *relids_logged,
{
Relation toastrel = relation_open ( toast_relid ,
AccessExclusiveLock ) ;
RelationSetNewRelfilenode ( toastrel ,
toastrel - > rd_rel - > relpersistence ) ;
table_close ( toastrel , NoLock ) ;
@ -4336,6 +4337,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
/* nothing to do here, oid columns don't exist anymore */
break ;
case AT_SetTableSpace : /* SET TABLESPACE */
/*
* Only do this for partitioned tables and indexes , for which this
* is just a catalog change . Other relation types which have
@ -4626,8 +4628,8 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode)
{
/*
* If required , test the current data within the table against new
* constraints generated by ALTER TABLE commands , but don ' t rebuild
* data .
* constraints generated by ALTER TABLE commands , but don ' t
* rebuild data .
*/
if ( tab - > constraints ! = NIL | | tab - > verify_new_notnull | |
tab - > partition_constraint ! = NULL )
@ -4798,8 +4800,8 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
{
/*
* If we are rebuilding the tuples OR if we added any new but not
* verified NOT NULL constraints , check all not - null constraints .
* This is a bit of overkill but it minimizes risk of bugs , and
* verified NOT NULL constraints , check all not - null constraints . This
* is a bit of overkill but it minimizes risk of bugs , and
* heap_attisnull is a pretty cheap test anyway .
*/
for ( i = 0 ; i < newTupDesc - > natts ; i + + )
@ -4941,8 +4943,8 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
{
/*
* If there ' s no rewrite , old and new table are guaranteed to
* have the same AM , so we can just use the old slot to
* verify new constraints etc .
* have the same AM , so we can just use the old slot to verify
* new constraints etc .
*/
insertslot = oldslot ;
}
@ -6209,9 +6211,8 @@ ATExecSetNotNull(AlteredTableInfo *tab, Relation rel,
/*
* Ordinarily phase 3 must ensure that no NULLs exist in columns that
* are set NOT NULL ; however , if we can find a constraint which proves
* this then we can skip that . We needn ' t bother looking if
* we ' ve already found that we must verify some other NOT NULL
* constraint .
* this then we can skip that . We needn ' t bother looking if we ' ve
* already found that we must verify some other NOT NULL constraint .
*/
if ( ! tab - > verify_new_notnull & &
! NotNullImpliedByRelConstraints ( rel , ( Form_pg_attribute ) GETSTRUCT ( tuple ) ) )
@ -10503,7 +10504,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
*/
if ( tab - > rewrite )
{
Relation newrel ;
Relation newrel ;
newrel = table_open ( RelationGetRelid ( rel ) , NoLock ) ;
RelationClearMissing ( newrel ) ;
@ -10657,8 +10658,8 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
{
/*
* Changing the type of a column that is used by a
* generated column is not allowed by SQL standard .
* It might be doable with some thinking and effort .
* generated column is not allowed by SQL standard . It
* might be doable with some thinking and effort .
*/
ereport ( ERROR ,
( errcode ( ERRCODE_SYNTAX_ERROR ) ,
@ -10862,13 +10863,13 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
/*
* Here we go - - - change the recorded column type and collation . ( Note
* heapTup is a copy of the syscache entry , so okay to scribble on . )
* First fix up the missing value if any .
* heapTup is a copy of the syscache entry , so okay to scribble on . ) First
* fix up the missing value if any .
*/
if ( attTup - > atthasmissing )
{
Datum missingval ;
bool missingNull ;
Datum missingval ;
bool missingNull ;
/* if rewrite is true the missing value should already be cleared */
Assert ( tab - > rewrite = = 0 ) ;
@ -10881,7 +10882,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
/* if it's a null array there is nothing to do */
if ( ! missingNull )
if ( ! missingNull )
{
/*
* Get the datum out of the array and repack it in a new array
@ -10890,12 +10891,12 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
* changed , only the array metadata .
*/
int one = 1 ;
bool isNull ;
Datum valuesAtt [ Natts_pg_attribute ] ;
bool nullsAtt [ Natts_pg_attribute ] ;
bool replacesAtt [ Natts_pg_attribute ] ;
HeapTuple newTup ;
int one = 1 ;
bool isNull ;
Datum valuesAtt [ Natts_pg_attribute ] ;
bool nullsAtt [ Natts_pg_attribute ] ;
bool replacesAtt [ Natts_pg_attribute ] ;
HeapTuple newTup ;
MemSet ( valuesAtt , 0 , sizeof ( valuesAtt ) ) ;
MemSet ( nullsAtt , false , sizeof ( nullsAtt ) ) ;
@ -10910,12 +10911,12 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
attTup - > attalign ,
& isNull ) ;
missingval = PointerGetDatum (
construct_array ( & missingval ,
1 ,
targettype ,
tform - > typlen ,
tform - > typbyval ,
tform - > typalign ) ) ;
construct_array ( & missingval ,
1 ,
targettype ,
tform - > typlen ,
tform - > typbyval ,
tform - > typalign ) ) ;
valuesAtt [ Anum_pg_attribute_attmissingval - 1 ] = missingval ;
replacesAtt [ Anum_pg_attribute_attmissingval - 1 ] = true ;
@ -12311,16 +12312,16 @@ ATExecSetTableSpaceNoStorage(Relation rel, Oid newTableSpace)
Oid reloid = RelationGetRelid ( rel ) ;
/*
* Shouldn ' t be called on relations having storage ; these are processed
* in phase 3.
* Shouldn ' t be called on relations having storage ; these are processed in
* phase 3.
*/
Assert ( ! RELKIND_HAS_STORAGE ( rel - > rd_rel - > relkind ) ) ;
/* Can't allow a non-shared relation in pg_global */
if ( newTableSpace = = GLOBALTABLESPACE_OID )
ereport ( ERROR ,
( errcode ( ERRCODE_INVALID_PARAMETER_VALUE ) ,
errmsg ( " only shared relations can be placed in pg_global tablespace " ) ) ) ;
( errcode ( ERRCODE_INVALID_PARAMETER_VALUE ) ,
errmsg ( " only shared relations can be placed in pg_global tablespace " ) ) ) ;
/*
* No work if no change in tablespace .
@ -15044,7 +15045,7 @@ ComputePartitionAttrs(ParseState *pstate, Relation rel, List *partParams, AttrNu
i = - 1 ;
while ( ( i = bms_next_member ( expr_attrs , i ) ) > = 0 )
{
AttrNumber attno = i + FirstLowInvalidHeapAttributeNumber ;
AttrNumber attno = i + FirstLowInvalidHeapAttributeNumber ;
if ( TupleDescAttr ( RelationGetDescr ( rel ) , attno - 1 ) - > attgenerated )
ereport ( ERROR ,
@ -15202,7 +15203,7 @@ PartConstraintImpliedByRelConstraint(Relation scanrel,
bool
ConstraintImpliedByRelConstraint ( Relation scanrel , List * testConstraint , List * provenConstraint )
{
List * existConstraint = list_copy ( provenConstraint ) ;
List * existConstraint = list_copy ( provenConstraint ) ;
TupleConstr * constr = RelationGetDescr ( scanrel ) - > constr ;
int num_check ,
i ;
@ -15240,8 +15241,8 @@ ConstraintImpliedByRelConstraint(Relation scanrel, List *testConstraint, List *p
* not - false and try to prove the same for testConstraint .
*
* Note that predicate_implied_by assumes its first argument is known
* immutable . That should always be true for both NOT NULL and
* partition constraints , so we don ' t test it here .
* immutable . That should always be true for both NOT NULL and partition
* constraints , so we don ' t test it here .
*/
return predicate_implied_by ( testConstraint , existConstraint , true ) ;
}