On Fri, Nov 5, 2021 1:14 PM Peter Smith <smithpb2...@gmail.com> wrote: > PSA new set of v37* patches.
Thanks for updating the patches. Few comments: 1) v37-0001 I think it might be better to also show the filter expression in '\d+ tablename' command after publication description. 2) v37-0004 + /* Scan the expression tree for referenceable objects */ + find_expr_references_walker(expr, &context); + + /* Remove any duplicates */ + eliminate_duplicate_dependencies(context.addrs); + The 0004 patch currently use find_expr_references_walker to get all the reference objects. I am thinking do we only need get the columns in the expression ? I think maybe we can check the replica indentity like[1]. 3) v37-0005 - no parse nodes of any kind other than Var, OpExpr, Const, BoolExpr, FuncExpr I think there could be other node type which can also be considered as simple expression, for exmaple T_NullIfExpr. Personally, I think it's natural to only check the IMMUTABLE and whether-user-defined in the new function rowfilter_walker. We can keep the other row-filter errors which were thrown for EXPR_KIND_PUBLICATION_WHERE in the 0001 patch. [1] rowfilter_expr_checker ... if (replica_identity == REPLICA_IDENTITY_DEFAULT) context.bms_replident = RelationGetIndexAttrBitmap(rel, INDEX_ATTR_BITMAP_PRIMARY_KEY); else context.bms_replident = RelationGetIndexAttrBitmap(rel, INDEX_ATTR_BITMAP_IDENTITY_KEY); (void) rowfilter_expr_replident_walker(rfnode, &context); ... static bool rowfilter_expr_replident_walker(Node *node, rf_context *context) { if (node == NULL) return false; if (IsA(node, Var)) { Oid relid = RelationGetRelid(context->rel); Var *var = (Var *) node; AttrNumber attnum = var->varattno - FirstLowInvalidHeapAttributeNumber; if (!bms_is_member(attnum, context->bms_replident)) { const char *colname = get_attname(relid, attnum, false); ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), errmsg("cannot add relation \"%s\" to publication", RelationGetRelationName(context->rel)), errdetail("Row filter column \"%s\" is not part of the REPLICA IDENTITY", colname))); return false; } return true; } return expression_tree_walker(node, rowfilter_expr_replident_walker, (void *) context); } Best regards, Hou zj