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.
This commit is contained in:
Tom Lane 2019-08-21 10:43:23 -04:00
parent 3f0f99125e
commit bbd93667bd
4 changed files with 39 additions and 23 deletions

View File

@ -384,13 +384,17 @@ SELECT row_to_json(row((select array_agg(x) as d from generate_series(5,10) x)),
(1 row)
-- anyarray column
select to_json(histogram_bounds) histogram_bounds
analyze rows;
select attname, to_json(histogram_bounds) histogram_bounds
from pg_stats
where attname = 'tmplname' and tablename = 'pg_pltemplate';
histogram_bounds
---------------------------------------------------------------------------------------
["plperl","plperlu","plpgsql","plpython2u","plpython3u","plpythonu","pltcl","pltclu"]
(1 row)
where tablename = 'rows' and
schemaname = pg_my_temp_schema()::regnamespace::text
order by 1;
attname | histogram_bounds
---------+------------------------
x | [1,2,3]
y | ["txt1","txt2","txt3"]
(2 rows)
-- to_json, timestamps
select to_json(timestamp '2014-05-28 12:22:35.614298');

View File

@ -280,13 +280,20 @@ SELECT array_to_json(ARRAY [jsonb '{"a":1}', jsonb '{"b":[2,3]}']);
(1 row)
-- anyarray column
select to_jsonb(histogram_bounds) histogram_bounds
CREATE TEMP TABLE rows AS
SELECT x, 'txt' || x as y
FROM generate_series(1,3) AS x;
analyze rows;
select attname, to_jsonb(histogram_bounds) histogram_bounds
from pg_stats
where attname = 'tmplname' and tablename = 'pg_pltemplate';
histogram_bounds
----------------------------------------------------------------------------------------------
["plperl", "plperlu", "plpgsql", "plpython2u", "plpython3u", "plpythonu", "pltcl", "pltclu"]
(1 row)
where tablename = 'rows' and
schemaname = pg_my_temp_schema()::regnamespace::text
order by 1;
attname | histogram_bounds
---------+--------------------------
x | [1, 2, 3]
y | ["txt1", "txt2", "txt3"]
(2 rows)
-- to_jsonb, timestamps
select to_jsonb(timestamp '2014-05-28 12:22:35.614298');
@ -354,9 +361,6 @@ select to_jsonb(timestamptz '-Infinity');
(1 row)
--jsonb_agg
CREATE TEMP TABLE rows AS
SELECT x, 'txt' || x as y
FROM generate_series(1,3) AS x;
SELECT jsonb_agg(q)
FROM ( SELECT $$a$$ || x AS b, y AS c,
ARRAY[ROW(x.*,ARRAY[1,2,3]),

View File

@ -104,9 +104,13 @@ SELECT row_to_json(row((select array_agg(x) as d from generate_series(5,10) x)),
-- anyarray column
select to_json(histogram_bounds) histogram_bounds
analyze rows;
select attname, to_json(histogram_bounds) histogram_bounds
from pg_stats
where attname = 'tmplname' and tablename = 'pg_pltemplate';
where tablename = 'rows' and
schemaname = pg_my_temp_schema()::regnamespace::text
order by 1;
-- to_json, timestamps

View File

@ -64,9 +64,17 @@ SELECT array_to_json(ARRAY [jsonb '{"a":1}', jsonb '{"b":[2,3]}']);
-- anyarray column
select to_jsonb(histogram_bounds) histogram_bounds
CREATE TEMP TABLE rows AS
SELECT x, 'txt' || x as y
FROM generate_series(1,3) AS x;
analyze rows;
select attname, to_jsonb(histogram_bounds) histogram_bounds
from pg_stats
where attname = 'tmplname' and tablename = 'pg_pltemplate';
where tablename = 'rows' and
schemaname = pg_my_temp_schema()::regnamespace::text
order by 1;
-- to_jsonb, timestamps
@ -90,10 +98,6 @@ select to_jsonb(timestamptz '-Infinity');
--jsonb_agg
CREATE TEMP TABLE rows AS
SELECT x, 'txt' || x as y
FROM generate_series(1,3) AS x;
SELECT jsonb_agg(q)
FROM ( SELECT $$a$$ || x AS b, y AS c,
ARRAY[ROW(x.*,ARRAY[1,2,3]),