Re: Backend crash in expanded_record_info functions

From: Joao Rito <joaovictor(dot)rito(at)gmail(dot)com>
To: Tender Wang <tndrwang(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Backend crash in expanded_record_info functions
Date: 2026-11-18 23:58:32
Message-ID: 20261118235832.1976-1-joaovictor.rito@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2026-11-19 00:07:44 Re: [PATCH v1] Fix initial sync of zero-column published tables
Previous Message Chao Li 2026-11-18 23:51:07 Re: [PATCH] Reject duplicate SQL/JSON PASSING argument names