Remove unnecessary test dependency on the contents of pg_pltemplate.
authorTom Lane
Wed, 21 Aug 2019 14:43:23 +0000 (10:43 -0400)
committerTom Lane
Wed, 21 Aug 2019 14:43:23 +0000 (10:43 -0400)
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
src/test/regress/expected/jsonb.out
src/test/regress/sql/json.sql
src/test/regress/sql/jsonb.sql

index 69b0a6ee6d6e1baaa911b172c9d301cbae29acae..c4156cf2a66f96cb495b347d5fa37818ad02f188 100644 (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');
index 0f9175579428e7a40d40b52023a141b9f08263f9..a2a19f81041b6114aa1b99fb69583d6cacab3332 100644 (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]),
index e02166459232b3ec304a8a871912115bd60e9a18..20354f04e3745d80be8b1317797df191b55c5528 100644 (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
 
index 58703a90b70a9813cb446c348a5f617e37439349..efd4c45185394f349329cd7a60ddd790e3db7689 100644 (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]),