Re: python patch - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: python patch
Date
Msg-id 200208150331.g7F3VuN21473@candle.pha.pa.us
Whole thread Raw
In response to python patch  (Greg Copeland <greg@CopelandConsulting.Net>)
List pgsql-hackers
Patch applied.  Thanks.

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



Greg Copeland wrote:

Checking application/pgp-signature: FAILURE
-- Start of PGP signed section.
> Okay, I read
> http://archives.postgresql.org/pgsql-bugs/2002-06/msg00086.php and never
> saw a fix offered up.  Since I'm gearing up to use Postgres and Python
> soon, I figured I'd have a hand at trying to get this sucker addressed. 
> Apologies if this has already been plugged.  I looked in the archives
> and never saw a response.
> 
> At any rate, I must admit I don't think I fully understand the
> implications of some of the changes I made even though they appear to be
> straight forward.  We all know the devil is in the details.  Anyone more
> knowledgeable is requested to review my changes. :(
> 
> I also updated the advanced.py script in a somewhat nonsensical fashion
> to make use of an int8 field in an effort to test this change.  It seems
> to run okay, however, this is by no means an all exhaustive test.  So,
> it's possible that a bumpy road may lay ahead for some.  On the other
> hand...overflows (hopefully) previously lurked (long -> int conversion).
> 
> This is my first submission.  Please be kind if I submitted to the wrong
> list.  ;)
> 
> Thank you,
>     Greg Copeland
> 

[ text/x-diff is unsupported, treating like TEXT/PLAIN ]

> ? lib_pgmodule.so.0.0
> ? postgres-python.patch
> ? tutorial/advanced.pyc
> Index: pgmodule.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/python/pgmodule.c,v
> retrieving revision 1.38
> diff -u -r1.38 pgmodule.c
> --- pgmodule.c    2002/03/29 07:45:39    1.38
> +++ pgmodule.c    2002/08/08 02:46:12
> @@ -289,23 +289,26 @@
>          {
>              case INT2OID:
>              case INT4OID:
> -            case INT8OID:
>              case OIDOID:
>                  typ[j] = 1;
>                  break;
>  
> +            case INT8OID:
> +                typ[j] = 2;
> +                break;
> +
>              case FLOAT4OID:
>              case FLOAT8OID:
>              case NUMERICOID:
> -                typ[j] = 2;
> +                typ[j] = 3;
>                  break;
>  
>              case CASHOID:
> -                typ[j] = 3;
> +                typ[j] = 4;
>                  break;
>  
>              default:
> -                typ[j] = 4;
> +                typ[j] = 5;
>                  break;
>          }
>      }
> @@ -1797,23 +1800,26 @@
>          {
>              case INT2OID:
>              case INT4OID:
> -            case INT8OID:
>              case OIDOID:
>                  typ[j] = 1;
>                  break;
>  
> +            case INT8OID:
> +                typ[j] = 2;
> +                break;
> +
>              case FLOAT4OID:
>              case FLOAT8OID:
>              case NUMERICOID:
> -                typ[j] = 2;
> +                typ[j] = 3;
>                  break;
>  
>              case CASHOID:
> -                typ[j] = 3;
> +                typ[j] = 4;
>                  break;
>  
>              default:
> -                typ[j] = 4;
> +                typ[j] = 5;
>                  break;
>          }
>      }
> @@ -1846,10 +1852,14 @@
>                          break;
>  
>                      case 2:
> -                        val = PyFloat_FromDouble(strtod(s, NULL));
> +                        val = PyLong_FromLong(strtol(s, NULL, 10));
>                          break;
>  
>                      case 3:
> +                        val = PyFloat_FromDouble(strtod(s, NULL));
> +                        break;
> +
> +                    case 4:
>                          {
>                              int            mult = 1;
>  
> @@ -1946,11 +1956,14 @@
>          {
>              case INT2OID:
>              case INT4OID:
> -            case INT8OID:
>              case OIDOID:
>                  typ[j] = 1;
>                  break;
>  
> +            case INT8OID:
> +                typ[j] = 2;
> +                break;
> +
>              case FLOAT4OID:
>              case FLOAT8OID:
>              case NUMERICOID:
> @@ -1995,10 +2008,14 @@
>                          break;
>  
>                      case 2:
> -                        val = PyFloat_FromDouble(strtod(s, NULL));
> +                        val = PyLong_FromLong(strtol(s, NULL, 10));
>                          break;
>  
>                      case 3:
> +                        val = PyFloat_FromDouble(strtod(s, NULL));
> +                        break;
> +
> +                    case 4:
>                          {
>                              int            mult = 1;
>  
> Index: tutorial/advanced.py
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/python/tutorial/advanced.py,v
> retrieving revision 1.5
> diff -u -r1.5 advanced.py
> --- tutorial/advanced.py    2000/10/02 03:46:24    1.5
> +++ tutorial/advanced.py    2002/08/08 02:46:12
> @@ -109,11 +109,13 @@
>      print "CREATE TABLE sal_emp ("
>      print "    name            text,"
>      print "    pay_by_quarter  int4[],"
> +    print "    pay_by_extra_quarter  int8[],"
>      print "    schedule        text[][]"
>      print ")"
>      pgcnx.query("""CREATE TABLE sal_emp (
>          name              text,
>          pay_by_quarter    int4[],
> +        pay_by_extra_quarter    int8[],
>          schedule          text[][])""")
>      wait_key()
>      print
> @@ -123,18 +125,22 @@
>      print "INSERT INTO sal_emp VALUES ("
>      print "    'Bill',"
>      print "    '{10000,10000,10000,10000}',"
> +    print "    '{9223372036854775800,9223372036854775800,9223372036854775800}',"
>      print "    '{{\"meeting\", \"lunch\"}, {}}')"
>      print
>      print "INSERT INTO sal_emp VALUES ("
>      print "    'Carol',"
>      print "    '{20000,25000,25000,25000}',"
> +    print "    '{9223372036854775807,9223372036854775807,9223372036854775807}',"
>      print "    '{{\"talk\", \"consult\"}, {\"meeting\"}}')"
>      print
>      pgcnx.query("""INSERT INTO sal_emp VALUES (
>          'Bill', '{10000,10000,10000,10000}',
> +    '{9223372036854775800,9223372036854775800,9223372036854775800}',
>          '{{\"meeting\", \"lunch\"}, {}}')""")
>      pgcnx.query("""INSERT INTO sal_emp VALUES (
>          'Carol', '{20000,25000,25000,25000}',
> +    '{9223372036854775807,9223372036854775807,9223372036854775807}',
>          '{{\"talk\", \"consult\"}, {\"meeting\"}}')""")
>      wait_key()
>      print
> @@ -148,11 +154,25 @@
>      print pgcnx.query("""SELECT name FROM sal_emp WHERE
>          sal_emp.pay_by_quarter[1] <> sal_emp.pay_by_quarter[2]""")
>      print
> +    print pgcnx.query("""SELECT name FROM sal_emp WHERE
> +        sal_emp.pay_by_extra_quarter[1] <> sal_emp.pay_by_extra_quarter[2]""")
> +    print
>      print "-- retrieve third quarter pay of all employees"
>      print 
>      print "SELECT sal_emp.pay_by_quarter[3] FROM sal_emp"
>      print
>      print pgcnx.query("SELECT sal_emp.pay_by_quarter[3] FROM sal_emp")
> +    print
> +    print "-- retrieve third quarter extra pay of all employees"
> +    print 
> +    print "SELECT sal_emp.pay_by_extra_quarter[3] FROM sal_emp"
> +    print pgcnx.query("SELECT sal_emp.pay_by_extra_quarter[3] FROM sal_emp")
> +    print 
> +    print "-- retrieve first two quarters of extra quarter pay of all employees"
> +    print 
> +    print "SELECT sal_emp.pay_by_extra_quarter[1:2] FROM sal_emp"
> +    print
> +    print pgcnx.query("SELECT sal_emp.pay_by_extra_quarter[1:2] FROM sal_emp")
>      print
>      print "-- select subarrays"
>      print 
-- End of PGP section, PGP failed!

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


pgsql-hackers by date:

Previous
From: Greg Copeland
Date:
Subject: Standard replication interface?
Next
From: Bruce Momjian
Date:
Subject: Re: python patch