Skip site navigation (1) Skip section navigation (2)

strange array insertion

From: "Bernie Huang" <bernieyth(at)hotmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: strange array insertion
Date: 2000-10-31 18:57:23
Message-ID: F197dOgl4rhYQYx3G5a00006d81@hotmail.com (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-general
Hello,

This is directly out of PostgreSQL User's Guide.

regression=# CREATE TABLE sal_emp (
regression(#     name            text,
regression(#     pay_by_quarter  int4[],
regression(#     schedule        text[][]
regression(# );
CREATE

regression=# INSERT INTO sal_emp
regression-#     VALUES ('Bill',
regression(#     '{10000, 10000, 10000, 10000}',
regression(#     '{{"meeting", "lunch"}, {}}');
INSERT 48043 1

regression=# select * from sal_emp ;
name |      pay_by_quarter       |      schedule
------+---------------------------+--------------------
Bill | {10000,10000,10000,10000} | {{"meeting"},{""}}
(1 row)

regression=# INSERT INTO sal_emp
regression-#     VALUES ('Carol',
regression(#     '{20000, 25000, 25000, 25000}',
regression(#     '{{"talk", "consult"}, {"meeting"}}');
INSERT 48044 1

regression=# select * from sal_emp ;
name  |      pay_by_quarter       |        schedule
-------+---------------------------+------------------------
Bill  | {10000,10000,10000,10000} | {{"meeting"},{""}}
Carol | {20000,25000,25000,25000} | {{"talk"},{"meeting"}}
(2 rows)

************
Strange enough, it seems like the 2-d text array size depends on the last 
element size.

regression=# INSERT INTO sal_emp
regression-#     VALUES ('Carol',
regression(#     '{20000, 25000, 25000, 25000}',
regression(#     '{{"talk", "consult"}, {"meeting",""}}');
INSERT 48045 1
regression=# select * from sal_emp ;
name  |      pay_by_quarter       |              schedule
-------+---------------------------+-------------------------------------
Bill  | {10000,10000,10000,10000} | {{"meeting"},{""}}
Carol | {20000,25000,25000,25000} | {{"talk"},{"meeting"}}
Carol | {20000,25000,25000,25000} | {{"talk","consult"},{"meeting",""}}
(3 rows)

regression=# INSERT INTO sal_emp
regression-#     VALUES ('Carol',
regression(#     '{20000, 25000, 25000, 25000}',
regression(#     '{{"talk", "consult"}, {"meeting","",""}}');
INSERT 48046 1
regression=# select * from sal_emp ;
name  |      pay_by_quarter       |                 schedule
-------+---------------------------+-------------------------------------------
Bill  | {10000,10000,10000,10000} | {{"meeting"},{""}}
Carol | {20000,25000,25000,25000} | {{"talk"},{"meeting"}}
Carol | {20000,25000,25000,25000} | {{"talk","consult"},{"meeting",""}}
Carol | {20000,25000,25000,25000} | 
{{"talk","consult",""},{"meeting","",""}}
(4 rows)

*******
See. So, am I doing anything wrong or is it a bug?  Btw, I was informed that 
rollback is not possible if array is involved (it auto-commits before you 
issue "commit" or "rollback" comands).
eg; "begin;", "update tb1 set arr[1]='something';", "rollback;"

This will not be able to rollback.  Any suggestions? coz I am using array A 
LOT!  =)

Thanks very much.


- Bernie
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at 
http://profiles.msn.com.


Responses

pgsql-bugs by date

Next:From: The Hermit HackerDate: 2000-10-31 22:31:23
Subject: Re: webmaster@postgres.org gives user unknown
Previous:From: Stephan SzaboDate: 2000-10-31 18:52:51
Subject: Re: bug

pgsql-general by date

Next:From: markwDate: 2000-10-31 19:02:01
Subject: Re: how good is PostgreSQL
Previous:From: Mark LaneDate: 2000-10-31 18:39:23
Subject: I tried to increase the block size

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group