Re: BUG #19382: Server crash at __nss_database_lookup - Mailing list pgsql-bugs

From surya poondla
Subject Re: BUG #19382: Server crash at __nss_database_lookup
Date
Msg-id CAOVWO5oH37CETZuxxXw3dhCMOHPMA0xFoJBWTpfJ06OV7sGzTQ@mail.gmail.com
Whole thread
In response to Re: BUG #19382: Server crash at __nss_database_lookup  ("songjinzhou" <tsinghualucky912@foxmail.com>)
Responses Re: BUG #19382: Server crash at __nss_database_lookup
List pgsql-bugs
Hi Songjinzhou,

Thank you for reviewing the patch.

You're correct that there is a minor inefficiency, once a tupDesc_identifier version mismatch is detected, the patch allocates 
new_values/new_nulls arrays and calls deconstruct_expanded_record() before knowing whether any field types actually differ. 
If the version changed but no field types changed (e.g., a constraint-only ALTER), we do unnecessary work and hit the if (!need_conversion) return late.

That said, your suggestion is clean and correct. I can restructure the code to do a first pass over the TupleDesc attributes (which is pure metadata, no deconstruction needed) to set need_conversion, 
and only proceed with deconstruct_expanded_record() and array allocation if that returns true. This avoids any unnecessary memory allocation in that intermediate case.

I'll post an updated patch with this improvement.

Thanks again for the careful review!

Regards, 
Surya Poondla

pgsql-bugs by date:

Previous
From: surya poondla
Date:
Subject: Re: Two issues with REFRESH MATERIALIZED VIEW CONCURRENTLY
Next
From: Tom Lane
Date:
Subject: Re: BUG #19435: Error: "No relation entry for relid 2" Triggered by Complex Join with Self-Referencing Tables