Bug #693: python interface doesn't handle int8 correctly.

Lists: pgsql-bugs
From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: Bug #693: python interface doesn't handle int8 correctly.
Date: 2002-06-18 11:14:50
Message-ID: 20020618111450.2C13B4762B0@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Ragnar Kjrstad (postgresql(at)ragnark(dot)vesdtata(dot)no) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
python interface doesn't handle int8 correctly.

Long Description
This applies to postgresql 7.2.1 on linux x86 (32 bit)

getresult() and dictresult() return int4 data in a python int object, but it should use a python long object, or it will overflow.

From postgresql-7.2.1/src/interfaces/python:pgquery_dictresult :
switch (PQftype(self->last_result, j)) {
case INT2OID:
case INT4OID:
case INT8OID:
case OIDOID:
typ[j] = 1;
break;
}
...
switch (typ[j]) {
case 1:
val = PyInt_FromLong(strtol(s, NULL, 10));
break;
}

clearly this is wrong....

Sample Code

No file was uploaded with this report


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: postgresql(at)ragnark(dot)vesdtata(dot)no, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug #693: python interface doesn't handle int8 correctly.
Date: 2002-06-25 17:42:19
Message-ID: 200206251742.g5PHgJb00430@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


OK, can you suggest a patch?

---------------------------------------------------------------------------

pgsql-bugs(at)postgresql(dot)org wrote:
> Ragnar Kjrstad (postgresql(at)ragnark(dot)vesdtata(dot)no) reports a bug with a severity of 3
> The lower the number the more severe it is.
>
> Short Description
> python interface doesn't handle int8 correctly.
>
> Long Description
> This applies to postgresql 7.2.1 on linux x86 (32 bit)
>
> getresult() and dictresult() return int4 data in a python int object, but it should use a python long object, or it will overflow.
>
> >From postgresql-7.2.1/src/interfaces/python:pgquery_dictresult :
> switch (PQftype(self->last_result, j)) {
> case INT2OID:
> case INT4OID:
> case INT8OID:
> case OIDOID:
> typ[j] = 1;
> break;
> }
> ...
> switch (typ[j]) {
> case 1:
> val = PyInt_FromLong(strtol(s, NULL, 10));
> break;
> }
>
>
> clearly this is wrong....
>
>
> Sample Code
>
>
> No file was uploaded with this report
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: postgresql(at)ragnark(dot)vesdtata(dot)no, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug #693: python interface doesn't handle int8 correctly.
Date: 2002-08-26 22:57:36
Message-ID: 200208262257.g7QMvaF24054@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


Could you supply a patch?

---------------------------------------------------------------------------

pgsql-bugs(at)postgresql(dot)org wrote:
> Ragnar Kjrstad (postgresql(at)ragnark(dot)vesdtata(dot)no) reports a bug with a severity of 3
> The lower the number the more severe it is.
>
> Short Description
> python interface doesn't handle int8 correctly.
>
> Long Description
> This applies to postgresql 7.2.1 on linux x86 (32 bit)
>
> getresult() and dictresult() return int4 data in a python int object, but it should use a python long object, or it will overflow.
>
> >From postgresql-7.2.1/src/interfaces/python:pgquery_dictresult :
> switch (PQftype(self->last_result, j)) {
> case INT2OID:
> case INT4OID:
> case INT8OID:
> case OIDOID:
> typ[j] = 1;
> break;
> }
> ...
> switch (typ[j]) {
> case 1:
> val = PyInt_FromLong(strtol(s, NULL, 10));
> break;
> }
>
>
> clearly this is wrong....
>
>
> Sample Code
>
>
> No file was uploaded with this report
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

--
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: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: postgresql(at)ragnark(dot)vesdtata(dot)no, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug #693: python interface doesn't handle int8 correctly.
Date: 2002-08-27 00:37:42
Message-ID: 14984.1030408662@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> Could you supply a patch?

Seems to be fixed already; at least INT8 is treated differently from
INT4 in CVS tip...

regards, tom lane