pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #14801: ECPG core dump
2+ messages / 2 participants
[nested] [flat]
* BUG #14801: ECPG core dump
@ 2017-09-06 16:12 davidr@openscg.com
0 siblings, 1 reply; 2+ messages in thread
From: davidr@openscg.com @ 2017-09-06 16:12 UTC (permalink / raw)
To: pgsql-bugs; +Cc: davidr@openscg.com
The following bug has been logged on the website:
Bug reference: 14801
Logged by: David Rader
Email address: davidr@openscg.com
PostgreSQL version: 9.6.4
Operating system: CentOS 7
Description:
Using a int* variable as a where-clause parameter in a declare cursor
construct causes ECPG to Abort (core dump). Using an int variable works
correctly (as expected), and using a pointer type in where clause in a
simple select into works.
$ /usr/pgsql-9.6/bin/ecpg bug1.pgc
Aborted (core dumped)
$ cat bug1.pgc
int main( )
{
EXEC SQL BEGIN DECLARE SECTION;
int iparm = 5, iparm2;
int *pparm = &iparm;
int *outparm = &iparm2;
EXEC SQL END DECLARE SECTION;
// this runs through ECPG with no warning
/*
EXEC SQL
select 2 into :outparm from foo
where foo.bar = :pparm;
*/
// this causes Abort (core dumped)
EXEC SQL DECLARE buggy CURSOR FOR
select 2 from foo
where foo.bar = :pparm;
return( 0 );
}
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #14801: ECPG core dump
@ 2017-09-11 19:14 Michael Meskes <meskes@postgresql.org>
parent: davidr@openscg.com
0 siblings, 0 replies; 2+ messages in thread
From: Michael Meskes @ 2017-09-11 19:14 UTC (permalink / raw)
To: davidr@openscg.com; +Cc: pgsql-bugs
On Wed, Sep 06, 2017 at 04:12:12PM +0000, davidr@openscg.com wrote:
> Using a int* variable as a where-clause parameter in a declare cursor
> construct causes ECPG to Abort (core dump). Using an int variable works
> correctly (as expected), and using a pointer type in where clause in a
> simple select into works.
Could you please try the attached little patch to see if it works with your
real life case? It does work with the test case. I will also git push as soon
as I'm back on the ground.
Thanks.
Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
ecpg.patch (text/x-diff, 930B) download
commit e39533aba0adccdff71ee259671cbe81771280a1
Author: Michael Meskes <meskes@postgresql.org>
Date: Mon Sep 11 21:10:36 2017 +0200
Fixed ECPG to correctly handle out-of-scope cursor declarations with pointers
or array variables.
diff --git a/src/interfaces/ecpg/preproc/ecpg.header b/src/interfaces/ecpg/preproc/ecpg.header
index 2562366bbe..a52da01b1f 100644
--- a/src/interfaces/ecpg/preproc/ecpg.header
+++ b/src/interfaces/ecpg/preproc/ecpg.header
@@ -352,7 +352,7 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
else
{
newvar = new_variable(cat_str(4, mm_strdup("("),
- mm_strdup(ecpg_type_name(ptr->variable->type->type)),
+ mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)),
mm_strdup(" *)(ECPGget_var("),
mm_strdup(var_text)),
ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type,
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2017-09-11 19:14 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-09-06 16:12 BUG #14801: ECPG core dump davidr@openscg.com
2017-09-11 19:14 ` Michael Meskes <meskes@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox