Lists: | pgsql-hackers |
---|
From: | Boszormenyi Zoltan <zb(at)cybertec(dot)at> |
---|---|
To: | PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>, Michael Meskes <meskes(at)postgresql(dot)org> |
Subject: | SQLDA fix for ECPG |
Date: | 2011-11-11 13:36:39 |
Message-ID: | 4EBD24E7.3010702@cybertec.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
I had a report about ECPG code crashing which involved
a query using a date field. Attached is a one liner fix to make
the date type's offset computed consistently across
sqlda_common_total_size(), sqlda_compat_total_size() and
sqlda_native_total_size().
This must have been a cut and paste bug and is incorrect
in 9.0.x, 9.1.x and GIT HEAD. It would be nice to have it
applied before the next point releases come out.
Best regards,
Zoltán Böszörményi
--
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de
http://www.postgresql.at/
Attachment | Content-Type | Size |
---|---|---|
ecpg-sqlda.patch | text/plain | 728 bytes |
From: | Michael Meskes <meskes(at)postgresql(dot)org> |
---|---|
To: | Boszormenyi Zoltan <zb(at)cybertec(dot)at> |
Cc: | PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: SQLDA fix for ECPG |
Date: | 2011-11-13 13:12:45 |
Message-ID: | 4EBFC24D.1020800@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
> This must have been a cut and paste bug and is incorrect
> in 9.0.x, 9.1.x and GIT HEAD. It would be nice to have it
> applied before the next point releases come out.
Applied, thanks for the patch.
Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
Jabber: michael.meskes at googlemail dot com
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Boszormenyi Zoltan <zb(at)cybertec(dot)at> |
Cc: | PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>, Michael Meskes <meskes(at)postgresql(dot)org> |
Subject: | Re: SQLDA fix for ECPG |
Date: | 2011-11-13 16:27:11 |
Message-ID: | 6624.1321201631@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Boszormenyi Zoltan <zb(at)cybertec(dot)at> writes:
> I had a report about ECPG code crashing which involved
> a query using a date field. Attached is a one liner fix to make
> the date type's offset computed consistently across
> sqlda_common_total_size(), sqlda_compat_total_size() and
> sqlda_native_total_size().
Is this really the only issue there? I notice discrepancies among those
three routines for some other types too, notably ECPGt_timestamp and
ECPGt_interval.
regards, tom lane
From: | Boszormenyi Zoltan <zb(at)cybertec(dot)at> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>, Michael Meskes <meskes(at)postgresql(dot)org> |
Subject: | Re: SQLDA fix for ECPG |
Date: | 2011-11-14 08:06:30 |
Message-ID: | 4EC0CC06.30506@cybertec.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
2011-11-13 17:27 keltezéssel, Tom Lane írta:
> Boszormenyi Zoltan <zb(at)cybertec(dot)at> writes:
>> I had a report about ECPG code crashing which involved
>> a query using a date field. Attached is a one liner fix to make
>> the date type's offset computed consistently across
>> sqlda_common_total_size(), sqlda_compat_total_size() and
>> sqlda_native_total_size().
> Is this really the only issue there? I notice discrepancies among those
> three routines for some other types too, notably ECPGt_timestamp and
> ECPGt_interval.
>
> regards, tom lane
Yes, you are right. For timestamp and interval, the safe alignment is int64.
Patch is attached.
Best regards,
Zoltán Böszörményi
--
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de
http://www.postgresql.at/
Attachment | Content-Type | Size |
---|---|---|
ecpg-sqlda-part2.patch | text/plain | 1.7 KB |
From: | Michael Meskes <meskes(at)postgresql(dot)org> |
---|---|
To: | Boszormenyi Zoltan <zb(at)cybertec(dot)at> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>, Michael Meskes <meskes(at)postgresql(dot)org> |
Subject: | Re: SQLDA fix for ECPG |
Date: | 2011-11-17 13:53:42 |
Message-ID: | 20111117135342.GA26136@feivel.credativ.lan |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Mon, Nov 14, 2011 at 09:06:30AM +0100, Boszormenyi Zoltan wrote:
> Yes, you are right. For timestamp and interval, the safe alignment is int64.
> Patch is attached.
Applied, thanks.
Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
Jabber: michael.meskes at googlemail dot com
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL
From: | Boszormenyi Zoltan <zb(at)cybertec(dot)at> |
---|---|
To: | PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>, Michael Meskes <meskes(at)postgresql(dot)org> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: SQLDA fix for ECPG |
Date: | 2011-11-19 21:56:03 |
Message-ID: | 4EC825F3.5080504@cybertec.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
2011-11-17 14:53 keltezéssel, Michael Meskes írta:
> On Mon, Nov 14, 2011 at 09:06:30AM +0100, Boszormenyi Zoltan wrote:
>> Yes, you are right. For timestamp and interval, the safe alignment is int64.
>> Patch is attached.
> Applied, thanks.
>
> Michael
thanks.
Hopefully last turn in this topic. For NUMERIC types, the safe minimum
alignment is a pointer because there are 5 int members followed by
two pointer members in this struct. I got a crash from this with a lucky
query and dataset. The DECIMAL struct is safe because the digits[] array
is embedded there.
After fixing this, I got another one at an innocent looking memcpy():
memcpy((char *) sqlda + offset, num->buf, num->ndigits + 1);
It turned out that when the server sends "0.00", PGTYPESnumeric_from_asc()
constructs a numeric structure with:
ndigits == 0
buf == NULL
digits == NULL.
This makes memcpy() crash and burn. Let's also fix this case.
Best regards,
Zoltán Böszörményi
--
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de
http://www.postgresql.at/
Attachment | Content-Type | Size |
---|---|---|
ecpg-sqlda-part3.patch | text/plain | 3.4 KB |
From: | Michael Meskes <meskes(at)postgresql(dot)org> |
---|---|
To: | Boszormenyi Zoltan <zb(at)cybertec(dot)at> |
Cc: | PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>, Michael Meskes <meskes(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: SQLDA fix for ECPG |
Date: | 2011-12-03 20:49:25 |
Message-ID: | 20111203204925.GA10338@feivel.credativ.lan |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Sat, Nov 19, 2011 at 10:56:03PM +0100, Boszormenyi Zoltan wrote:
> Hopefully last turn in this topic. For NUMERIC types, the safe minimum
> alignment is a pointer because there are 5 int members followed by
> two pointer members in this struct. I got a crash from this with a lucky
> query and dataset. The DECIMAL struct is safe because the digits[] array
> is embedded there.
> ...
Applied, thanks.
Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
Jabber: michael.meskes at googlemail dot com
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL