@@ -12996,7 +12996,6 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
1299612996 * existConstraint ;
1299712997 SysScanDesc scan ;
1299812998 ScanKeyData skey ;
12999- HeapTuple tuple ;
1300012999 AttrNumber attno ;
1300113000 int natts ;
1300213001 TupleDesc tupleDesc ;
@@ -13018,7 +13017,7 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
1301813017 errmsg ("\"%s\" is already a partition" ,
1301913018 RelationGetRelationName (attachRel ))));
1302013019
13021- if (attachRel -> rd_rel -> reloftype )
13020+ if (OidIsValid ( attachRel -> rd_rel -> reloftype ) )
1302213021 ereport (ERROR ,
1302313022 (errcode (ERRCODE_WRONG_OBJECT_TYPE ),
1302413023 errmsg ("cannot attach a typed table as partition" )));
@@ -13119,9 +13118,10 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
1311913118 if (attribute -> attisdropped )
1312013119 continue ;
1312113120
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 )))
1312513125 ereport (ERROR ,
1312613126 (errcode (ERRCODE_DATATYPE_MISMATCH ),
1312713127 errmsg ("table \"%s\" contains column \"%s\" not found in parent \"%s\"" ,
@@ -13167,7 +13167,6 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd)
1316713167 * There is a case in which we cannot rely on just the result of the
1316813168 * proof.
1316913169 */
13170- tupleDesc = RelationGetDescr (attachRel );
1317113170 attachRel_constr = tupleDesc -> constr ;
1317213171 existConstraint = NIL ;
1317313172 if (attachRel_constr != NULL )
0 commit comments