2011-11-13 17:27 keltezéssel, Tom Lane írta:
> Boszormenyi Zoltan <z...@cybertec.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/

--- postgresql-9.1.1/src/interfaces/ecpg/ecpglib/sqlda.c.orig   2011-11-14 
08:59:15.118711180 +0100
+++ postgresql-9.1.1/src/interfaces/ecpg/ecpglib/sqlda.c        2011-11-14 
09:02:53.787803059 +0100
@@ -127,10 +127,10 @@ sqlda_common_total_size(const PGresult *
                                ecpg_sqlda_align_add_size(offset, sizeof(date), 
sizeof(date), &offset, &next_offset);
                                break;
                        case ECPGt_timestamp:
-                               ecpg_sqlda_align_add_size(offset, sizeof(int), 
sizeof(timestamp), &offset, &next_offset);
+                               ecpg_sqlda_align_add_size(offset, 
sizeof(int64), sizeof(timestamp), &offset, &next_offset);
                                break;
                        case ECPGt_interval:
-                               ecpg_sqlda_align_add_size(offset, sizeof(int), 
sizeof(interval), &offset, &next_offset);
+                               ecpg_sqlda_align_add_size(offset, 
sizeof(int64), sizeof(interval), &offset, &next_offset);
                                break;
                        case ECPGt_char:
                        case ECPGt_unsigned_char:
@@ -359,7 +359,7 @@ ecpg_set_compat_sqlda(int lineno, struct
                                sqlda->sqlvar[i].sqllen = sizeof(date);
                                break;
                        case ECPGt_timestamp:
-                               ecpg_sqlda_align_add_size(offset, 
sizeof(timestamp), sizeof(timestamp), &offset, &next_offset);
+                               ecpg_sqlda_align_add_size(offset, 
sizeof(int64), sizeof(timestamp), &offset, &next_offset);
                                sqlda->sqlvar[i].sqldata = (char *) sqlda + 
offset;
                                sqlda->sqlvar[i].sqllen = sizeof(timestamp);
                                break;
@@ -545,7 +545,7 @@ ecpg_set_native_sqlda(int lineno, struct
                                sqlda->sqlvar[i].sqllen = sizeof(date);
                                break;
                        case ECPGt_timestamp:
-                               ecpg_sqlda_align_add_size(offset, 
sizeof(timestamp), sizeof(timestamp), &offset, &next_offset);
+                               ecpg_sqlda_align_add_size(offset, 
sizeof(int64), sizeof(timestamp), &offset, &next_offset);
                                sqlda->sqlvar[i].sqldata = (char *) sqlda + 
offset;
                                sqlda->sqlvar[i].sqllen = sizeof(timestamp);
                                break;
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to