Hello!

Sorry for the late reply, somehow I missed the previous updates.

I found one more problematic scenario, I think the patch should ignore
INSTEAD OF triggers:

CREATE TABLE base (id int, val text);
CREATE VIEW v_instead AS SELECT id, val FROM base;
CREATE FUNCTION v_instead_ins() RETURNS trigger LANGUAGE plpgsql AS $$
BEGIN
  INSERT INTO base VALUES (NEW.id, NEW.val);
  RETURN NEW;
END;
$$;
CREATE TRIGGER v_instead_trg
  INSTEAD OF INSERT ON v_instead
  FOR EACH ROW EXECUTE FUNCTION v_instead_ins();
-- currently fails
-- ERROR:  "t_all" is a table
-- DETAIL:  Tables cannot have INSTEAD OF triggers.
CREATE TABLE t_all (LIKE v_instead INCLUDING ALL);

And also, either I don't understand something here, or the diff can be
simplified a bit:

-               /* Transform expression.  Copy to be sure we don't modify 
original */
-               whenClause = transformWhereClause(pstate,
-                                                                               
  copyObject(stmt->whenClause),
-                                                                               
  EXPR_KIND_TRIGGER_WHEN,
-                                                                               
  "WHEN");
-               /* we have to fix its collations too */
-               assign_expr_collations(pstate, whenClause);
+               if (stmt->transformed)
+                       whenClause = stmt->whenClause;
+               else
+               {
+                       /* Transform expression.  Copy to be sure we don't 
modify original */
+                       whenClause = transformWhereClause(pstate,
+                                                                               
          copyObject(stmt->whenClause),
+                                                                               
          EXPR_KIND_TRIGGER_WHEN,
+                                                                               
          "WHEN");
+
+                       /* we have to fix its collations too */
+                       assign_expr_collations(pstate, whenClause);
+
+                       stmt->transformed = true;
+               }


Do we need the last assignment in this diff? It sets
stmt->transformed, but we don't actually transform the statement, we
create a copy. The flag also doesn't seem to be used after that.
Everything seems to work fine if I remove this assignment, and we
don't need the const related function signature changes without it.


Reply via email to