Hi Zsolt,

> Function-like cast syntax has the same problem, even with v4:
>
> create view v as select record(row(1, null::int)) = record(row(1,
> null::int)) as r;
> select r from v;
> select pg_get_viewdef('v');
> -- SELECT (ROW(1, NULL::integer) = ROW(1, NULL::integer)) AS r;

Thanks for testing this.  A function-style cast reaches coerce_type()
with COERCE_EXPLICIT_CALL, and v4 only recorded COERCE_EXPLICIT_CAST.

As with ::record, it also matters in WHERE:

  create view v2 as select x from t
    where record(row(x, null::int)) = record(row(1, null::int));

That view was dumped as

  WHERE (ROW(x, NULL::integer) = ROW(1, NULL::integer))

so after restore it returns no rows instead of the row with x = 1.

Attached is v5.  The only functional change is the condition in
0002's coerce_type():

  -    cformat == COERCE_EXPLICIT_CAST &&
  +    (cformat == COERCE_EXPLICIT_CAST ||
  +     cformat == COERCE_EXPLICIT_CALL) &&

0001 adds a view with the function-style cast in the target list and
in WHERE, and 0002 prints it with ::record.  0003 is unchanged.

Best regards,
Henson

Attachment: v5-0001-Add-tests-for-deparsing-record-comparisons-of-ROW.patch
Description: Binary data

Attachment: v5-0002-Record-explicit-casts-of-ROW-constructors-in-the-.patch
Description: Binary data

Attachment: v5-0003-Show-casts-of-ROW-constructors-made-by-the-parser.patch
Description: Binary data

Reply via email to