Postgres doesn't seem to enforce array dimensions
От | Joseph S |
---|---|
Тема | Postgres doesn't seem to enforce array dimensions |
Дата | |
Msg-id | hpl3rj$1t8j$1@news.hub.org обсуждение исходный текст |
Ответы |
Re: Postgres doesn't seem to enforce array dimensions
|
Список | pgsql-general |
What's up with Postgres and array dimensions? The table definition doesn't even store how many dimensions the array should be. [local]:playpen=> create table arrtest( playpen(> id SERIAL PRIMARY KEY, playpen(> arrone int[], playpen(> arrtwo int[][] playpen(> ); NOTICE: CREATE TABLE will create implicit sequence "arrtest_id_seq" for serial column "arrtest.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "arrtest_pkey" for table "arrtest" CREATE TABLE Time: 22.688 ms [local]:playpen=> INSERT into arrtest (arrone) VALUES (null); --should work, and does INSERT 0 1 Time: 3.798 ms [local]:playpen=> INSERT into arrtest (arrone) VALUES ( ARRAY[1,2]); INSERT 0 1 Time: 0.668 ms [local]:playpen=> INSERT into arrtest (arrone) VALUES ( ARRAY[[3,4]]); --should not work INSERT 0 1 Time: 0.715 ms [local]:playpen=> INSERT into arrtest (arrtwo) VALUES ( ARRAY[5,6]); --should not work INSERT 0 1 Time: 0.671 ms [local]:playpen=> INSERT into arrtest (arrtwo) VALUES ( ARRAY[[7,8]]); INSERT 0 1 Time: 0.704 ms [local]:playpen=> select * from arrtest; id | arrone | arrtwo ----+---------+--------- 1 | | 2 | {1,2} | 3 | {{3,4}} | 4 | | {5,6} 5 | | {{7,8}} (5 rows) Time: 1.217 ms [local]:playpen=> \d arrtest Table "public.arrtest" Column | Type | Modifiers --------+-----------+------------------------------------------------------ id | integer | not null default nextval('arrtest_id_seq'::regclass) arrone | integer[] | arrtwo | integer[] | Indexes: "arrtest_pkey" PRIMARY KEY, btree (id) [local]:playpen=> select version(); version ----------------------------------------------------------------------------------------------------------- PostgreSQL 8.4.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-9), 32-bit
В списке pgsql-general по дате отправления: