pgsql-server/src/interfaces/python pg.py - Mailing list pgsql-committers

From momjian@svr1.postgresql.org (Bruce Momjian)
Subject pgsql-server/src/interfaces/python pg.py
Date
Msg-id 20030625010924.0EFEF30F9EE@svr1.postgresql.org
Whole thread Raw
List pgsql-committers
CVSROOT:    /cvsroot
Module name:    pgsql-server
Changes by:    momjian@svr1.postgresql.org    03/06/24 22:09:24

Modified files:
    src/interfaces/python: pg.py

Log message:
    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:

    Chih-Hao Huang


pgsql-committers by date:

Previous
From: momjian@svr1.postgresql.org (Bruce Momjian)
Date:
Subject: pgsql-server/src/backend/utils adt/inet_net_nt ...
Next
From: momjian@svr1.postgresql.org (Bruce Momjian)
Date:
Subject: pgsql-server/contrib/dblink README.dblink dbli ...