From bbd93667bde56d3900add55479759f33d20ece1e Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 21 Aug 2019 10:43:23 -0400 Subject: [PATCH] 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. --- src/test/regress/expected/json.out | 16 ++++++++++------ src/test/regress/expected/jsonb.out | 22 +++++++++++++--------- src/test/regress/sql/json.sql | 8 ++++++-- src/test/regress/sql/jsonb.sql | 16 ++++++++++------ 4 files changed, 39 insertions(+), 23 deletions(-) diff --git a/src/test/regress/expected/json.out b/src/test/regress/expected/json.out index 69b0a6ee6d..c4156cf2a6 100644 --- a/src/test/regress/expected/json.out +++ b/src/test/regress/expected/json.out @@ -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'); diff --git a/src/test/regress/expected/jsonb.out b/src/test/regress/expected/jsonb.out index 0f91755794..a2a19f8104 100644 --- a/src/test/regress/expected/jsonb.out +++ b/src/test/regress/expected/jsonb.out @@ -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]), diff --git a/src/test/regress/sql/json.sql b/src/test/regress/sql/json.sql index e021664592..20354f04e3 100644 --- a/src/test/regress/sql/json.sql +++ b/src/test/regress/sql/json.sql @@ -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 diff --git a/src/test/regress/sql/jsonb.sql b/src/test/regress/sql/jsonb.sql index 58703a90b7..efd4c45185 100644 --- a/src/test/regress/sql/jsonb.sql +++ b/src/test/regress/sql/jsonb.sql @@ -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]), -- 2.40.0