Lists: | pgsql-bugspgsql-patches |
---|
From: | Chih-Hao Huang <huangch(at)woodlawn(dot)fnal(dot)gov> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org |
Subject: | bug in pg.py and the fix |
Date: | 2003-06-13 21:32:43 |
Message-ID: | 200306132132.h5DLWhI03049@woodlawn.fnal.gov |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs pgsql-patches |
If PostgreSQL failed to compile on your computer or you found a bug that
is likely to be specific to one platform then please fill out this form
and e-mail it to pgsql-ports(at)postgresql(dot)org(dot)
To report any other bug, fill out the form below and e-mail it to
pgsql-bugs(at)postgresql(dot)org(dot)
If you not only found the problem but solved it and generated a patch
then e-mail it to pgsql-patches(at)postgresql(dot)org instead. Please use the
command "diff -c" to generate the patch.
You may also enter a bug report at http://www.postgresql.org/ instead of
e-mail-ing this form.
============================================================================
POSTGRESQL BUG REPORT TEMPLATE
============================================================================
Your name : Chih-Hao Huang
Your email address : huangch(at)fnal(dot)gov
System Configuration
---------------------
Architecture (example: Intel Pentium) : Intel Pentium
Operating System (example: Linux 2.0.26 ELF) : Linux 2.4.3-12
PostgreSQL version (example: PostgreSQL-7.3.3): PostgreSQL-7.3.3
Compiler used (example: gcc 2.95.2) : gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-85)
Please enter a FULL description of your problem:
------------------------------------------------
This is a bug in python interface module,
postgresql-7.3.3/src/interfaces/python/pg.py.
_quote() function fails due to integer overflow if input d is larger
than max integer.
In the case where the column type is "BIGINT", the input d may very well
be larger than max integer while its type, t, is labeled 'int'.
The conversion on line 19, return "%d" % int(d), will fail due to
"OverflowError: long int too large to convert to int".
Please describe a way to repeat the problem. Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------
[1] create a table with a column type 'BIGINT'.
[2] use pg.DB.insert() to insert a value that is larger than max integer
If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------
Just changing the conversion at line 19 of pg.py to long(d) instead of
int(d) should fix it. The following is a patch:
*** pg.py Fri Jun 13 15:15:57 2003
--- pg.py.new Fri Jun 13 15:16:59 2003
***************
*** 16,22 ****
if t in ['int', 'seq']:
if d == "": return "NULL"
! return "%d" % int(d)
if t == 'decimal':
if d == "": return "NULL"
--- 16,22 ----
if t in ['int', 'seq']:
if d == "": return "NULL"
! return "%d" % long(d)
if t == 'decimal':
if d == "": return "NULL"
From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Chih-Hao Huang <huangch(at)woodlawn(dot)fnal(dot)gov> |
Cc: | pgsql-bugs(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org |
Subject: | Re: bug in pg.py and the fix |
Date: | 2003-06-16 18:10:51 |
Message-ID: | 200306161810.h5GIAp112948@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs pgsql-patches |
Your patch has been added to the PostgreSQL unapplied patches list at:
http://momjian.postgresql.org/cgi-bin/pgpatches
I will try to apply it within the next 48 hours.
---------------------------------------------------------------------------
Chih-Hao Huang wrote:
> If PostgreSQL failed to compile on your computer or you found a bug that
> is likely to be specific to one platform then please fill out this form
> and e-mail it to pgsql-ports(at)postgresql(dot)org(dot)
>
> To report any other bug, fill out the form below and e-mail it to
> pgsql-bugs(at)postgresql(dot)org(dot)
>
> If you not only found the problem but solved it and generated a patch
> then e-mail it to pgsql-patches(at)postgresql(dot)org instead. Please use the
> command "diff -c" to generate the patch.
>
> You may also enter a bug report at http://www.postgresql.org/ instead of
> e-mail-ing this form.
>
> ============================================================================
> POSTGRESQL BUG REPORT TEMPLATE
> ============================================================================
>
>
> Your name : Chih-Hao Huang
> Your email address : huangch(at)fnal(dot)gov
>
>
> System Configuration
> ---------------------
> Architecture (example: Intel Pentium) : Intel Pentium
>
> Operating System (example: Linux 2.0.26 ELF) : Linux 2.4.3-12
>
> PostgreSQL version (example: PostgreSQL-7.3.3): PostgreSQL-7.3.3
>
> Compiler used (example: gcc 2.95.2) : gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-85)
>
>
> Please enter a FULL description of your problem:
> ------------------------------------------------
>
> This is a bug in python interface module,
> postgresql-7.3.3/src/interfaces/python/pg.py.
>
> _quote() function fails due to integer overflow if input d is larger
> than max integer.
>
> In the case where the column type is "BIGINT", the input d may very well
> be larger than max integer while its type, t, is labeled 'int'.
> The conversion on line 19, return "%d" % int(d), will fail due to
> "OverflowError: long int too large to convert to int".
>
>
>
> Please describe a way to repeat the problem. Please try to provide a
> concise reproducible example, if at all possible:
> ----------------------------------------------------------------------
>
> [1] create a table with a column type 'BIGINT'.
> [2] use pg.DB.insert() to insert a value that is larger than max integer
>
> If you know how this problem might be fixed, list the solution below:
> ---------------------------------------------------------------------
>
> Just changing the conversion at line 19 of pg.py to long(d) instead of
> int(d) should fix it. The following is a patch:
>
> *** pg.py Fri Jun 13 15:15:57 2003
> --- pg.py.new Fri Jun 13 15:16:59 2003
> ***************
> *** 16,22 ****
>
> if t in ['int', 'seq']:
> if d == "": return "NULL"
> ! return "%d" % int(d)
>
> if t == 'decimal':
> if d == "": return "NULL"
> --- 16,22 ----
>
> if t in ['int', 'seq']:
> if d == "": return "NULL"
> ! return "%d" % long(d)
>
> if t == 'decimal':
> if d == "": return "NULL"
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Chih-Hao Huang <huangch(at)woodlawn(dot)fnal(dot)gov> |
Cc: | pgsql-bugs(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org |
Subject: | Re: bug in pg.py and the fix |
Date: | 2003-06-25 01:09:31 |
Message-ID: | 200306250109.h5P19V325164@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs pgsql-patches |
Patch applied. Thanks.
---------------------------------------------------------------------------
Chih-Hao Huang wrote:
> If PostgreSQL failed to compile on your computer or you found a bug that
> is likely to be specific to one platform then please fill out this form
> and e-mail it to pgsql-ports(at)postgresql(dot)org(dot)
>
> To report any other bug, fill out the form below and e-mail it to
> pgsql-bugs(at)postgresql(dot)org(dot)
>
> If you not only found the problem but solved it and generated a patch
> then e-mail it to pgsql-patches(at)postgresql(dot)org instead. Please use the
> command "diff -c" to generate the patch.
>
> You may also enter a bug report at http://www.postgresql.org/ instead of
> e-mail-ing this form.
>
> ============================================================================
> POSTGRESQL BUG REPORT TEMPLATE
> ============================================================================
>
>
> Your name : Chih-Hao Huang
> Your email address : huangch(at)fnal(dot)gov
>
>
> System Configuration
> ---------------------
> Architecture (example: Intel Pentium) : Intel Pentium
>
> Operating System (example: Linux 2.0.26 ELF) : Linux 2.4.3-12
>
> PostgreSQL version (example: PostgreSQL-7.3.3): PostgreSQL-7.3.3
>
> Compiler used (example: gcc 2.95.2) : gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-85)
>
>
> Please enter a FULL description of your problem:
> ------------------------------------------------
>
> This is a bug in python interface module,
> postgresql-7.3.3/src/interfaces/python/pg.py.
>
> _quote() function fails due to integer overflow if input d is larger
> than max integer.
>
> In the case where the column type is "BIGINT", the input d may very well
> be larger than max integer while its type, t, is labeled 'int'.
> The conversion on line 19, return "%d" % int(d), will fail due to
> "OverflowError: long int too large to convert to int".
>
>
>
> Please describe a way to repeat the problem. Please try to provide a
> concise reproducible example, if at all possible:
> ----------------------------------------------------------------------
>
> [1] create a table with a column type 'BIGINT'.
> [2] use pg.DB.insert() to insert a value that is larger than max integer
>
> If you know how this problem might be fixed, list the solution below:
> ---------------------------------------------------------------------
>
> Just changing the conversion at line 19 of pg.py to long(d) instead of
> int(d) should fix it. The following is a patch:
>
> *** pg.py Fri Jun 13 15:15:57 2003
> --- pg.py.new Fri Jun 13 15:16:59 2003
> ***************
> *** 16,22 ****
>
> if t in ['int', 'seq']:
> if d == "": return "NULL"
> ! return "%d" % int(d)
>
> if t == 'decimal':
> if d == "": return "NULL"
> --- 16,22 ----
>
> if t in ['int', 'seq']:
> if d == "": return "NULL"
> ! return "%d" % long(d)
>
> if t == 'decimal':
> if d == "": return "NULL"
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073