@@ -12996,7 +12996,6 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
12996
12996
* existConstraint ;
12997
12997
SysScanDesc scan ;
12998
12998
ScanKeyData skey ;
12999
- HeapTuple tuple ;
13000
12999
AttrNumber attno ;
13001
13000
int natts ;
13002
13001
TupleDesc tupleDesc ;
@@ -13018,7 +13017,7 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
13018
13017
errmsg ("\"%s\" is already a partition" ,
13019
13018
RelationGetRelationName (attachRel ))));
13020
13019
13021
- if (attachRel -> rd_rel -> reloftype )
13020
+ if (OidIsValid ( attachRel -> rd_rel -> reloftype ) )
13022
13021
ereport (ERROR ,
13023
13022
(errcode (ERRCODE_WRONG_OBJECT_TYPE ),
13024
13023
errmsg ("cannot attach a typed table as partition" )));
@@ -13119,9 +13118,10 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
13119
13118
if (attribute -> attisdropped )
13120
13119
continue ;
13121
13120
13122
- /* Find same column in parent (matching on column name). */
13123
- tuple = SearchSysCacheCopyAttName (RelationGetRelid (rel ), attributeName );
13124
- if (!HeapTupleIsValid (tuple ))
13121
+ /* Try to find the column in parent (matching on column name) */
13122
+ if (!SearchSysCacheExists2 (ATTNAME ,
13123
+ ObjectIdGetDatum (RelationGetRelid (rel )),
13124
+ CStringGetDatum (attributeName )))
13125
13125
ereport (ERROR ,
13126
13126
(errcode (ERRCODE_DATATYPE_MISMATCH ),
13127
13127
errmsg ("table \"%s\" contains column \"%s\" not found in parent \"%s\"" ,
@@ -13167,7 +13167,6 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
13167
13167
* There is a case in which we cannot rely on just the result of the
13168
13168
* proof.
13169
13169
*/
13170
- tupleDesc = RelationGetDescr (attachRel );
13171
13170
attachRel_constr = tupleDesc -> constr ;
13172
13171
existConstraint = NIL ;
13173
13172
if (attachRel_constr != NULL )
0 commit comments