]> granicus.if.org Git - postgresql/commitdiff
I have two patches for 6.5.0:
authorBruce Momjian <bruce@momjian.us>
Wed, 5 May 1999 21:38:40 +0000 (21:38 +0000)
committerBruce Momjian <bruce@momjian.us>
Wed, 5 May 1999 21:38:40 +0000 (21:38 +0000)
arrayfuncs.patch        fixes a small bug in my previous patches for
arrays

array-regress.patch     adds _bpchar and _varchar to regression tests

--
Massimo Dal Zotto

src/backend/utils/adt/arrayfuncs.c
src/test/regress/expected/arrays.out
src/test/regress/expected/create_misc.out
src/test/regress/expected/create_table.out
src/test/regress/sql/create_misc.sql
src/test/regress/sql/create_table.sql

index 8c5518bda396b65655d9df21a2a1c33a3087f3f1..948b7092753ef1b11ba6f603122fb2e780216cbe 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.40 1999/05/03 23:48:26 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.41 1999/05/05 21:38:37 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1336,10 +1336,16 @@ array_map(ArrayType *v,
        system_cache_lookup(retType, false, &typlen, &typbyval,
                                                &typdelim, &typelem, &proc, &typalign);
 
-       /* Allocate temporary array for new values */
        ndim   = ARR_NDIM(v);
        dim    = ARR_DIMS(v);
        nitems = getNitems(ndim, dim);
+
+       /* Check for empty array */
+       if (nitems <= 0) {
+               return v;
+       }
+
+       /* Allocate temporary array for new values */
        values = (char **) palloc(nitems * sizeof(char *));
        MemSet(values, 0, nitems * sizeof(char *));
 
index 92cfc94d2139b592fac1f5aab2eeb5f5b6c2e065..b0869a9495065e80989e407f406b71b1c3222105 100644 (file)
@@ -1,9 +1,9 @@
 QUERY: SELECT * FROM arrtest;
-a          |b              |c            |d                |e            
------------+---------------+-------------+-----------------+-------------
-{1,2,3,4,5}|{{{0,0},{1,2}}}|{}           |{}               |             
-{11,12,23} |{{3,4},{4,5}}  |{"foobar"}   |{{"elt1","elt2"}}|{"3.4","6.7"}
-{}         |{3,4}          |{"foo","bar"}|{"bar","foo"}    |             
+a          |b              |c            |d                |e            |f                |g              
+-----------+---------------+-------------+-----------------+-------------+-----------------+---------------
+{1,2,3,4,5}|{{{0,0},{1,2}}}|{}           |{}               |             |{}               |{}             
+{11,12,23} |{{3,4},{4,5}}  |{"foobar"}   |{{"elt1","elt2"}}|{"3.4","6.7"}|{"abc  ","abcde"}|{"abc","abcde"}
+{}         |{3,4}          |{"foo","bar"}|{"bar","foo"}    |             |                 |               
 (3 rows)
 
 QUERY: SELECT arrtest.a[1],
@@ -43,8 +43,8 @@ QUERY: SELECT *
    FROM arrtest
    WHERE arrtest.a[1] < 5 and
          arrtest.c = '{"foobar"}'::_name;
-a|b|c|d|e
--+-+-+-+-
+a|b|c|d|e|f|g
+-+-+-+-+-+-+-
 (0 rows)
 
 QUERY: SELECT arrtest.a[1:3],
index 3382c8566971b35c61bfc1a32be3dbdd5cfebc8a..b64aac65cb46409829f37497304e824d60f58a16 100644 (file)
@@ -114,13 +114,14 @@ QUERY: INSERT INTO f_star (class, e) VALUES ('f', '-12'::int2);
 QUERY: INSERT INTO f_star (class, f)
    VALUES ('f', '(11111111,33333333),(22222222,44444444)'::polygon);
 QUERY: INSERT INTO f_star (class) VALUES ('f');
-QUERY: INSERT INTO arrtest (a[5], b[2][1][2], c, d)
-   VALUES ('{1,2,3,4,5}', '{{{},{1,2}}}', '{}', '{}');
+QUERY: INSERT INTO arrtest (a[5], b[2][1][2], c, d, f, g)
+   VALUES ('{1,2,3,4,5}', '{{{},{1,2}}}', '{}', '{}', '{}', '{}');
 QUERY: UPDATE arrtest SET e[0] = '1.1';
 QUERY: UPDATE arrtest SET e[1] = '2.2';
-QUERY: INSERT INTO arrtest (a, b[2][2][1], c, d, e)
+QUERY: 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"}');
+           '{{"elt1", "elt2"}}', '{"3.4", "6.7"}',
+           '{"abc","abcdefgh"}', '{"abc","abcdefgh"}');
 QUERY: INSERT INTO arrtest (a, b[1][2][2], c, d[2][1])
    VALUES ('{}', '{3,4}', '{foo,bar}', '{bar,foo}');
 QUERY: CREATE TABLE iportaltest (
index 7f3859da5d0e2b79eecdadaf3df6beba6ad8f095..91c1445475605f1c71a6541da89d378ae6b14def 100644 (file)
@@ -131,7 +131,9 @@ QUERY: CREATE TABLE arrtest (
        b               int4[][][],
        c               name[],
        d               text[][],
-       e               float8[]
+       e               float8[],
+       f               char(5)[],
+       g               varchar(5)[]
 );
 QUERY: CREATE TABLE hash_i4_heap (
        seqno           int4,
index 495f94506f84aae8056cbc0fe4c4d71569171ab6..6431614a30b8a67c37e7f8fe7b0fb81da62fd64e 100644 (file)
@@ -198,16 +198,17 @@ INSERT INTO f_star (class) VALUES ('f');
 -- 'e' is also a large object.
 --
 
-INSERT INTO arrtest (a[5], b[2][1][2], c, d)
-   VALUES ('{1,2,3,4,5}', '{{{},{1,2}}}', '{}', '{}');
+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 (a, b[2][2][1], c, d, e)
+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"}');
+           '{{"elt1", "elt2"}}', '{"3.4", "6.7"}',
+           '{"abc","abcdefgh"}', '{"abc","abcdefgh"}');
 
 INSERT INTO arrtest (a, b[1][2][2], c, d[2][1])
    VALUES ('{}', '{3,4}', '{foo,bar}', '{bar,foo}');
index 7bf244b2bc11d756d769356c961326b6aca78696..ad955290fadeb14672fe7ccf7642d79b73b7c0fa 100644 (file)
@@ -178,7 +178,9 @@ CREATE TABLE arrtest (
        b               int4[][][],
        c               name[],
        d               text[][], 
-       e               float8[]
+       e               float8[],
+       f               char(5)[],
+       g               varchar(5)[]
 );
 
 CREATE TABLE hash_i4_heap (