diff options
author | Bruce Momjian <bruce@momjian.us> | 2002-08-15 03:31:45 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2002-08-15 03:31:45 +0000 |
commit | 147aa84c1a0c4ed6444696e04881e938f38c3c20 (patch) | |
tree | 58d9827e6324f7d85e686fc15c6d9c8cb268a8fa /src/interfaces/python/tutorial/advanced.py | |
parent | db147006c103b67a23fb63a2d5ed08c92a6c2a80 (diff) | |
download | postgresql-147aa84c1a0c4ed6444696e04881e938f38c3c20.tar.gz postgresql-147aa84c1a0c4ed6444696e04881e938f38c3c20.zip |
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).
Greg Copeland
Diffstat (limited to 'src/interfaces/python/tutorial/advanced.py')
-rwxr-xr-x | src/interfaces/python/tutorial/advanced.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/interfaces/python/tutorial/advanced.py b/src/interfaces/python/tutorial/advanced.py index 49e6e436e8c..41a5bc457a3 100755 --- a/src/interfaces/python/tutorial/advanced.py +++ b/src/interfaces/python/tutorial/advanced.py @@ -109,11 +109,13 @@ def array_demo(pgcnx): 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 @@ def array_demo(pgcnx): 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,12 +154,26 @@ def array_demo(pgcnx): 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 print "SELECT sal_emp.schedule[1:2][1:1] FROM sal_emp WHERE" |