Henson Choi <[email protected]> writes:
> The parser reads "ROW(..) op ROW(..)" as a column-by-column row
> comparison, and "ROW(..) op (SELECT ..)" as a row comparison sublink
> (transformAExprOp).  Casting a ROW() to record makes the record
> operator apply, but the cast does nothing and leaves no trace in the
> tree.

Indeed.  I think this is a parser bug and you're trying to band-aid
around it in the wrong place.  get_rule_expr() would already do the
right thing if the RowExpr had row_format == COERCE_EXPLICIT_CAST,
but it does not, which seems like it could fool more things than
only deparsing.  I'd blame that on coerce_type(), which silently
does nothing if the expression already has the right type; but
it should also worry about whether the expression is correctly
labeled as to coercion format.  So roughly speaking, I think
we want something that's like hide_coercion_node() but can install
a cformat other than COERCE_IMPLICIT_CAST, and then invoke that
in the coerce_type() paths that don't build a new node.

It might be easier to move the existing coerce_type() logic into
a new subroutine, and then make coerce_type() be a wrapper that
calls that subroutine and then fixes up the coercion format.
Not sure about that part.

                        regards, tom lane


Reply via email to