[PATCH] ECPG bug fix in preproc when indicator struct is shorter than record struct

From: "Rader, David" <davidr(at)openscg(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: [PATCH] ECPG bug fix in preproc when indicator struct is shorter than record struct
Date: 2018-01-11 16:47:52
Message-ID: CAABt7R5qCGtzQe=suioG5OVWOA5jw2mvRx41VnxhBLgAvY6vKA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
0001-Fix-generated-code-to-avoid-core-dump-when-indicator.patch text/x-patch 1.3 KB
indrecs.c text/x-csrc 8.9 KB
indrecs.c.fix application/octet-stream 7.3 KB
indrecs.pgc application/octet-stream 2.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-01-11 16:54:54 Re: Minor code improvement to estimate_path_cost_size in postgres_fdw
Previous Message Chapman Flack 2018-01-11 16:30:53 Re: numeric regression test passes, but why?