Skip to content

Commit 5d5cf91

Browse files
committed
I have two patches for 6.5.0:
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
1 parent 81ff516 commit 5d5cf91

File tree

6 files changed

+31
-19
lines changed

6 files changed

+31
-19
lines changed

src/backend/utils/adt/arrayfuncs.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.40 1999/05/03 23:48:26 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.41 1999/05/05 21:38:37 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1336,10 +1336,16 @@ array_map(ArrayType *v,
13361336
system_cache_lookup(retType, false, &typlen, &typbyval,
13371337
&typdelim, &typelem, &proc, &typalign);
13381338

1339-
/* Allocate temporary array for new values */
13401339
ndim = ARR_NDIM(v);
13411340
dim = ARR_DIMS(v);
13421341
nitems = getNitems(ndim, dim);
1342+
1343+
/* Check for empty array */
1344+
if (nitems <= 0) {
1345+
return v;
1346+
}
1347+
1348+
/* Allocate temporary array for new values */
13431349
values = (char **) palloc(nitems * sizeof(char *));
13441350
MemSet(values, 0, nitems * sizeof(char *));
13451351

src/test/regress/expected/arrays.out

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
QUERY: SELECT * FROM arrtest;
2-
a |b |c |d |e
3-
-----------+---------------+-------------+-----------------+-------------
4-
{1,2,3,4,5}|{{{0,0},{1,2}}}|{} |{} |
5-
{11,12,23} |{{3,4},{4,5}} |{"foobar"} |{{"elt1","elt2"}}|{"3.4","6.7"}
6-
{} |{3,4} |{"foo","bar"}|{"bar","foo"} |
2+
a |b |c |d |e |f |g
3+
-----------+---------------+-------------+-----------------+-------------+-----------------+---------------
4+
{1,2,3,4,5}|{{{0,0},{1,2}}}|{} |{} | |{} |{}
5+
{11,12,23} |{{3,4},{4,5}} |{"foobar"} |{{"elt1","elt2"}}|{"3.4","6.7"}|{"abc ","abcde"}|{"abc","abcde"}
6+
{} |{3,4} |{"foo","bar"}|{"bar","foo"} | | |
77
(3 rows)
88

99
QUERY: SELECT arrtest.a[1],
@@ -43,8 +43,8 @@ QUERY: SELECT *
4343
FROM arrtest
4444
WHERE arrtest.a[1] < 5 and
4545
arrtest.c = '{"foobar"}'::_name;
46-
a|b|c|d|e
47-
-+-+-+-+-
46+
a|b|c|d|e|f|g
47+
-+-+-+-+-+-+-
4848
(0 rows)
4949

5050
QUERY: SELECT arrtest.a[1:3],

src/test/regress/expected/create_misc.out

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,14 @@ QUERY: INSERT INTO f_star (class, e) VALUES ('f', '-12'::int2);
114114
QUERY: INSERT INTO f_star (class, f)
115115
VALUES ('f', '(11111111,33333333),(22222222,44444444)'::polygon);
116116
QUERY: INSERT INTO f_star (class) VALUES ('f');
117-
QUERY: INSERT INTO arrtest (a[5], b[2][1][2], c, d)
118-
VALUES ('{1,2,3,4,5}', '{{{},{1,2}}}', '{}', '{}');
117+
QUERY: INSERT INTO arrtest (a[5], b[2][1][2], c, d, f, g)
118+
VALUES ('{1,2,3,4,5}', '{{{},{1,2}}}', '{}', '{}', '{}', '{}');
119119
QUERY: UPDATE arrtest SET e[0] = '1.1';
120120
QUERY: UPDATE arrtest SET e[1] = '2.2';
121-
QUERY: INSERT INTO arrtest (a, b[2][2][1], c, d, e)
121+
QUERY: INSERT INTO arrtest (a, b[2][2][1], c, d, e, f, g)
122122
VALUES ('{11,12,23}', '{{3,4},{4,5}}', '{"foobar"}',
123-
'{{"elt1", "elt2"}}', '{"3.4", "6.7"}');
123+
'{{"elt1", "elt2"}}', '{"3.4", "6.7"}',
124+
'{"abc","abcdefgh"}', '{"abc","abcdefgh"}');
124125
QUERY: INSERT INTO arrtest (a, b[1][2][2], c, d[2][1])
125126
VALUES ('{}', '{3,4}', '{foo,bar}', '{bar,foo}');
126127
QUERY: CREATE TABLE iportaltest (

src/test/regress/expected/create_table.out

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ QUERY: CREATE TABLE arrtest (
131131
b int4[][][],
132132
c name[],
133133
d text[][],
134-
e float8[]
134+
e float8[],
135+
f char(5)[],
136+
g varchar(5)[]
135137
);
136138
QUERY: CREATE TABLE hash_i4_heap (
137139
seqno int4,

src/test/regress/sql/create_misc.sql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,17 @@ INSERT INTO f_star (class) VALUES ('f');
198198
-- 'e' is also a large object.
199199
--
200200

201-
INSERT INTO arrtest (a[5], b[2][1][2], c, d)
202-
VALUES ('{1,2,3,4,5}', '{{{},{1,2}}}', '{}', '{}');
201+
INSERT INTO arrtest (a[5], b[2][1][2], c, d, f, g)
202+
VALUES ('{1,2,3,4,5}', '{{{},{1,2}}}', '{}', '{}', '{}', '{}');
203203

204204
UPDATE arrtest SET e[0] = '1.1';
205205

206206
UPDATE arrtest SET e[1] = '2.2';
207207

208-
INSERT INTO arrtest (a, b[2][2][1], c, d, e)
208+
INSERT INTO arrtest (a, b[2][2][1], c, d, e, f, g)
209209
VALUES ('{11,12,23}', '{{3,4},{4,5}}', '{"foobar"}',
210-
'{{"elt1", "elt2"}}', '{"3.4", "6.7"}');
210+
'{{"elt1", "elt2"}}', '{"3.4", "6.7"}',
211+
'{"abc","abcdefgh"}', '{"abc","abcdefgh"}');
211212

212213
INSERT INTO arrtest (a, b[1][2][2], c, d[2][1])
213214
VALUES ('{}', '{3,4}', '{foo,bar}', '{bar,foo}');

src/test/regress/sql/create_table.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ CREATE TABLE arrtest (
178178
b int4[][][],
179179
c name[],
180180
d text[][],
181-
e float8[]
181+
e float8[],
182+
f char(5)[],
183+
g varchar(5)[]
182184
);
183185

184186
CREATE TABLE hash_i4_heap (

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy