From 5546ec289bc75eac0be689d9a36950f702b4c5f6 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Mon, 21 May 2001 16:54:46 +0000 Subject: Make char(n) and varchar(n) types raise an error if the inserted string is too long. While I was adjusting the regression tests I moved the array things all into array.sql, to make things more manageable. --- src/test/regress/sql/arrays.sql | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/test/regress/sql/arrays.sql') diff --git a/src/test/regress/sql/arrays.sql b/src/test/regress/sql/arrays.sql index 3b02acf642..a3300eae12 100644 --- a/src/test/regress/sql/arrays.sql +++ b/src/test/regress/sql/arrays.sql @@ -2,6 +2,40 @@ -- ARRAYS -- +CREATE TABLE arrtest ( + a int2[], + b int4[][][], + c name[], + d text[][], + e float8[], + f char(5)[], + g varchar(5)[] +); + +-- +-- only this array as a 0-based 'e', the others are 1-based. +-- 'e' is also a large object. +-- + +INSERT INTO arrtest (a[5], b[2][1][2], c, d, f, g) + VALUES ('{1,2,3,4,5}', '{{{},{1,2}}}', '{}', '{}', '{}', '{}'); + +UPDATE arrtest SET e[0] = '1.1'; + +UPDATE arrtest SET e[1] = '2.2'; + +INSERT INTO arrtest (f) + VALUES ('{"too long"}'); + +INSERT INTO arrtest (a, b[2][2][1], c, d, e, f, g) + VALUES ('{11,12,23}', '{{3,4},{4,5}}', '{"foobar"}', + '{{"elt1", "elt2"}}', '{"3.4", "6.7"}', + '{"abc","abcde"}', '{"abc","abcde"}'); + +INSERT INTO arrtest (a, b[1][2][2], c, d[2][1]) + VALUES ('{}', '{3,4}', '{foo,bar}', '{bar,foo}'); + + SELECT * FROM arrtest; SELECT arrtest.a[1], -- cgit v1.2.1