[PATCH] ECPG bug fix in preproc when indicator struct is shorter thanrecord struct - Mailing list pgsql-hackers

From Rader, David
Subject [PATCH] ECPG bug fix in preproc when indicator struct is shorter thanrecord struct
Date
Msg-id CAABt7R5qCGtzQe=suioG5OVWOA5jw2mvRx41VnxhBLgAvY6vKA@mail.gmail.com
Whole thread Raw
Responses Re: [PATCH] ECPG bug fix in preproc when indicator struct isshorter than record struct
List pgsql-hackers
Hello -

Attached is a proposed patch to fix a bug in the ECPG preprocessor that generates application code that core dumps at run-time. When the input pgc code uses a record struct for returning query results and uses an indicator struct that has fewer fields than the record struct, the generated .c code will compile with no warning but core dump. This situation comes up when a developer adds a field to an existing query, adds the field to the record struct and forgets to add the field to the indicator struct.

The patch fixes the generated code to use ECPGt_NO_INDICATOR in the call to ecpglib for indicator members that are not present and issues a compiler warning for either too few indicator members or too many indicator members.

The attached sample files are a simple sample of pgc code that can be used to see the difference in before and after generation and the before and after generated code.

If accepted, this bug fix can be back ported to earlier versions of ecpg as well.

Thanks
Dave


Attachment

pgsql-hackers by date:

Previous
From: Chapman Flack
Date:
Subject: Re: numeric regression test passes, but why?
Next
From: Tom Lane
Date:
Subject: Re: Minor code improvement to estimate_path_cost_size in postgres_fdw