Hi Tender,

Thank you for the patch and for the clear report. I may be wrong on some 
points, so please correct me.

I tested this on current master (commit 8303f2e, cassert and debug enabled, in 
a container). The patch applied cleanly.

Without the patch, `SELECT expanded_record_info(2);` terminated the backend 
("server closed the connection unexpectedly"). With the patch, the same 
statement returns:

    ERROR:  argument must be of a composite type

and the session stays alive. `make check` passes with the patch (243 tests).

I also tried a few other calls with the patch. `expanded_record_identity(2)`, 
`expanded_record_field_text(2,1)`, a text argument, and an integer array return 
the same error. A table row type and a domain over a composite type give the 
same output with and without the patch. `ROW(1,'a')` also works with the patch 
(I did not run it without the patch). NULL input of a non-composite type 
returns NULL, because the function is STRICT in my setup.

One small question. The error message could mention the function name, or use 
ereport with ERRCODE_DATATYPE_MISMATCH. This is only a test helper, so elog may 
be fine. I do not have a strong opinion.

What I did not test:
- I did not run this against the real regression database. I created the three 
functions by hand in an empty database, so their declarations may differ a 
little from test_setup.sql.
- On unpatched master I confirmed the crash only for `expanded_record_info(2)`. 
I did not run `expanded_record_identity(2)` and 
`expanded_record_field_text(2,1)` on unpatched master. I only read the code, 
which uses the same macro, so I did not see them crash.
- I did not run make check on unpatched master, run other test suites, or test 
other platforms or build options (no non-cassert build).
- I did not check whether other test functions in regress.c have the same issue.

Thanks again for your work on this.

Best regards,
Joao Rito


Reply via email to