Skip to content

Commit bbd9366

Browse files
committed
Remove unnecessary test dependency on the contents of pg_pltemplate.
Using pg_pltemplate as test data was probably not very forward-looking, considering we've had many discussions around removing that catalog altogether. Use a nearby temp table instead, to make these two test scripts more self-contained. This is a better test case anyway, since it exercises the scenario where the entries in the anyarray column actually vary in type intra-query.
1 parent 3f0f991 commit bbd9366

File tree

4 files changed

+39
-23
lines changed

4 files changed

+39
-23
lines changed

src/test/regress/expected/json.out

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -384,13 +384,17 @@ SELECT row_to_json(row((select array_agg(x) as d from generate_series(5,10) x)),
384384
(1 row)
385385

386386
-- anyarray column
387-
select to_json(histogram_bounds) histogram_bounds
387+
analyze rows;
388+
select attname, to_json(histogram_bounds) histogram_bounds
388389
from pg_stats
389-
where attname = 'tmplname' and tablename = 'pg_pltemplate';
390-
histogram_bounds
391-
---------------------------------------------------------------------------------------
392-
["plperl","plperlu","plpgsql","plpython2u","plpython3u","plpythonu","pltcl","pltclu"]
393-
(1 row)
390+
where tablename = 'rows' and
391+
schemaname = pg_my_temp_schema()::regnamespace::text
392+
order by 1;
393+
attname | histogram_bounds
394+
---------+------------------------
395+
x | [1,2,3]
396+
y | ["txt1","txt2","txt3"]
397+
(2 rows)
394398

395399
-- to_json, timestamps
396400
select to_json(timestamp '2014-05-28 12:22:35.614298');

src/test/regress/expected/jsonb.out

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,20 @@ SELECT array_to_json(ARRAY [jsonb '{"a":1}', jsonb '{"b":[2,3]}']);
280280
(1 row)
281281

282282
-- anyarray column
283-
select to_jsonb(histogram_bounds) histogram_bounds
283+
CREATE TEMP TABLE rows AS
284+
SELECT x, 'txt' || x as y
285+
FROM generate_series(1,3) AS x;
286+
analyze rows;
287+
select attname, to_jsonb(histogram_bounds) histogram_bounds
284288
from pg_stats
285-
where attname = 'tmplname' and tablename = 'pg_pltemplate';
286-
histogram_bounds
287-
----------------------------------------------------------------------------------------------
288-
["plperl", "plperlu", "plpgsql", "plpython2u", "plpython3u", "plpythonu", "pltcl", "pltclu"]
289-
(1 row)
289+
where tablename = 'rows' and
290+
schemaname = pg_my_temp_schema()::regnamespace::text
291+
order by 1;
292+
attname | histogram_bounds
293+
---------+--------------------------
294+
x | [1, 2, 3]
295+
y | ["txt1", "txt2", "txt3"]
296+
(2 rows)
290297

291298
-- to_jsonb, timestamps
292299
select to_jsonb(timestamp '2014-05-28 12:22:35.614298');
@@ -354,9 +361,6 @@ select to_jsonb(timestamptz '-Infinity');
354361
(1 row)
355362

356363
--jsonb_agg
357-
CREATE TEMP TABLE rows AS
358-
SELECT x, 'txt' || x as y
359-
FROM generate_series(1,3) AS x;
360364
SELECT jsonb_agg(q)
361365
FROM ( SELECT $$a$$ || x AS b, y AS c,
362366
ARRAY[ROW(x.*,ARRAY[1,2,3]),

src/test/regress/sql/json.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,13 @@ SELECT row_to_json(row((select array_agg(x) as d from generate_series(5,10) x)),
104104

105105
-- anyarray column
106106

107-
select to_json(histogram_bounds) histogram_bounds
107+
analyze rows;
108+
109+
select attname, to_json(histogram_bounds) histogram_bounds
108110
from pg_stats
109-
where attname = 'tmplname' and tablename = 'pg_pltemplate';
111+
where tablename = 'rows' and
112+
schemaname = pg_my_temp_schema()::regnamespace::text
113+
order by 1;
110114

111115
-- to_json, timestamps
112116

src/test/regress/sql/jsonb.sql

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,17 @@ SELECT array_to_json(ARRAY [jsonb '{"a":1}', jsonb '{"b":[2,3]}']);
6464

6565
-- anyarray column
6666

67-
select to_jsonb(histogram_bounds) histogram_bounds
67+
CREATE TEMP TABLE rows AS
68+
SELECT x, 'txt' || x as y
69+
FROM generate_series(1,3) AS x;
70+
71+
analyze rows;
72+
73+
select attname, to_jsonb(histogram_bounds) histogram_bounds
6874
from pg_stats
69-
where attname = 'tmplname' and tablename = 'pg_pltemplate';
75+
where tablename = 'rows' and
76+
schemaname = pg_my_temp_schema()::regnamespace::text
77+
order by 1;
7078

7179
-- to_jsonb, timestamps
7280

@@ -90,10 +98,6 @@ select to_jsonb(timestamptz '-Infinity');
9098

9199
--jsonb_agg
92100

93-
CREATE TEMP TABLE rows AS
94-
SELECT x, 'txt' || x as y
95-
FROM generate_series(1,3) AS x;
96-
97101
SELECT jsonb_agg(q)
98102
FROM ( SELECT $$a$$ || x AS b, y AS c,
99103
ARRAY[ROW(x.*,ARRAY[1,2,3]),

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