Throw a more on-point error for publications depending on columns.
authorTom Lane <[email protected]>
Thu, 2 May 2024 21:36:31 +0000 (17:36 -0400)
committerTom Lane <[email protected]>
Thu, 2 May 2024 21:36:31 +0000 (17:36 -0400)
Same as 42b041243, except that the trouble case is a publication
WHERE clause that depends on a column.

Again reported by Alexander Lakhin.  Back-patch to v15 where
we added publication WHERE clauses.

Discussion: https://postgr.es/m/548a47bc-87ae-b3df-c6a2-60b9966f808b@gmail.com

src/backend/commands/tablecmds.c

index c31783373f0f4b408adc04731dd38d7fe1161eba..3309332f1ae6217f25fba5109dc73ff6374ac5aa 100644 (file)
@@ -46,6 +46,7 @@
 #include "catalog/pg_opclass.h"
 #include "catalog/pg_policy.h"
 #include "catalog/pg_proc.h"
+#include "catalog/pg_publication_rel.h"
 #include "catalog/pg_rewrite.h"
 #include "catalog/pg_statistic_ext.h"
 #include "catalog/pg_tablespace.h"
@@ -14227,6 +14228,21 @@ RememberAllDependentForRebuilding(AlteredTableInfo *tab, AlterTableType subtype,
                RememberStatisticsForRebuilding(foundObject.objectId, tab);
                break;
 
+           case PublicationRelRelationId:
+
+               /*
+                * Column reference in a PUBLICATION ... FOR TABLE ... WHERE
+                * clause.  Same issues as above.  FIXME someday.
+                */
+               if (subtype == AT_AlterColumnType)
+                   ereport(ERROR,
+                           (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+                            errmsg("cannot alter type of a column used by a publication WHERE clause"),
+                            errdetail("%s depends on column \"%s\"",
+                                      getObjectDescription(&foundObject, false),
+                                      colName)));
+               break;
+
            default:
 
                /*