2323#include "catalog/heap.h"
2424#include "catalog/namespace.h"
2525#include "catalog/pg_class.h"
26+ #include "catalog/pg_inherits.h"
2627#include "catalog/pg_type.h"
2728#include "commands/defrem.h"
2829#include "commands/tablecmds.h"
@@ -113,6 +114,7 @@ typedef struct PgLakeDDL
113114static bool Allowed (Node * arg );
114115static bool Disallowed (Node * arg );
115116static bool DisallowedAddColumnWithUnsupportedConstraints (Node * arg );
117+ static void PropagateSchemaChangesToChildren (Oid parentRelationId , List * schemaDDLOperations );
116118
117119PgLakeAlterTableHookType PgLakeAlterTableHook = NULL ;
118120PgLakeAlterTableRenameColumnHookType PgLakeAlterTableRenameColumnHook = NULL ;
@@ -327,6 +329,9 @@ ProcessAlterTable(ProcessUtilityParams * processUtilityParams, void *arg)
327329
328330 ApplyDDLChanges (relationId , schemaDDLOperations );
329331
332+ if (list_length (schemaDDLOperations ) > 0 )
333+ PropagateSchemaChangesToChildren (relationId , schemaDDLOperations );
334+
330335 if (PgLakeAlterTableHook )
331336 PgLakeAlterTableHook (relationId , alterStmt );
332337
@@ -335,6 +340,27 @@ ProcessAlterTable(ProcessUtilityParams * processUtilityParams, void *arg)
335340}
336341
337342
343+ static void
344+ PropagateSchemaChangesToChildren (Oid parentRelationId , List * schemaDDLOperations )
345+ {
346+ List * children = find_all_inheritors (parentRelationId , NoLock , NULL );
347+ ListCell * lc ;
348+
349+ foreach (lc , children )
350+ {
351+ Oid childOid = lfirst_oid (lc );
352+
353+ if (childOid == parentRelationId )
354+ continue ;
355+
356+ if (!IsPgLakeIcebergForeignTableById (childOid ))
357+ continue ;
358+
359+ ApplyDDLChanges (childOid , schemaDDLOperations );
360+ }
361+ }
362+
363+
338364/*
339365* CreateDDLOperationsForAlterTable is used to create column operations
340366* for an ALTER TABLE command. The operation is used to update the column mappings
0 commit comments