On Wed, Aug 07, 2019 at 10:17:25AM -0400, Tom Lane wrote:
> Not objecting to the patch, exactly, just feeling like there's
> more here than meets the eye.  Not quite sure if it's worth
> investigating closer, or what we'd even need to do to do so.

Yes, something's weird here.  I'd think that the index only scan
ensures a proper ordering in this case, so it could be possible that a
different plan got selected here?  That would mean that the plan
selected would not be an index-only scan or an index scan.  So perhaps
that was a bitmap scan?

> BTW, I realize from looking at the plan that LIKE is interpreting the
> underscores as wildcards.  Maybe it's worth s/_/\_/ while you're

Right.  Looking around there are much more tests which have the same
problem.  This could become a problem if other tests running in
parallel use relation names with the same pattern, which is not a
issue as of HEAD, so I'd rather just back-patch the ORDER BY part of
it (temp.sql is the only test missing that).  What do you think about
the attached?
--
Michael
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index e5407bbf0f..577210e1ad 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -2067,7 +2067,7 @@ insert into at_partitioned values(1, 'foo');
 insert into at_partitioned values(3, 'bar');
 create temp table old_oids as
   select relname, oid as oldoid, relfilenode as oldfilenode
-  from pg_class where relname like 'at_partitioned%';
+  from pg_class where relname like 'at\_partitioned%';
 select relname,
   c.oid = oldoid as orig_oid,
   case relfilenode
@@ -2078,7 +2078,7 @@ select relname,
     end as storage,
   obj_description(c.oid, 'pg_class') as desc
   from pg_class c left join old_oids using (relname)
-  where relname like 'at_partitioned%'
+  where relname like 'at\_partitioned%'
   order by relname;
            relname            | orig_oid | storage |     desc      
 ------------------------------+----------+---------+---------------
@@ -2091,7 +2091,7 @@ select relname,
 (6 rows)
 
 select conname, obj_description(oid, 'pg_constraint') as desc
-  from pg_constraint where conname like 'at_partitioned%'
+  from pg_constraint where conname like 'at\_partitioned%'
   order by conname;
            conname            |        desc        
 ------------------------------+--------------------
@@ -2112,7 +2112,7 @@ select relname,
     end as storage,
   obj_description(c.oid, 'pg_class') as desc
   from pg_class c left join old_oids using (relname)
-  where relname like 'at_partitioned%'
+  where relname like 'at\_partitioned%'
   order by relname;
            relname            | orig_oid | storage |     desc     
 ------------------------------+----------+---------+--------------
@@ -2125,7 +2125,7 @@ select relname,
 (6 rows)
 
 select conname, obj_description(oid, 'pg_constraint') as desc
-  from pg_constraint where conname like 'at_partitioned%'
+  from pg_constraint where conname like 'at\_partitioned%'
   order by conname;
            conname            |       desc        
 ------------------------------+-------------------
@@ -2189,7 +2189,7 @@ Inherits: test_inh_check
 
 select relname, conname, coninhcount, conislocal, connoinherit
   from pg_constraint c, pg_class r
-  where relname like 'test_inh_check%' and c.conrelid = r.oid
+  where relname like 'test\_inh\_check%' and c.conrelid = r.oid
   order by 1, 2;
        relname        |        conname         | coninhcount | conislocal | connoinherit 
 ----------------------+------------------------+-------------+------------+--------------
@@ -2220,7 +2220,7 @@ Inherits: test_inh_check
 
 select relname, conname, coninhcount, conislocal, connoinherit
   from pg_constraint c, pg_class r
-  where relname like 'test_inh_check%' and c.conrelid = r.oid
+  where relname like 'test\_inh\_check%' and c.conrelid = r.oid
   order by 1, 2;
        relname        |        conname         | coninhcount | conislocal | connoinherit 
 ----------------------+------------------------+-------------+------------+--------------
@@ -2260,7 +2260,7 @@ Inherits: test_inh_check
 
 select relname, conname, coninhcount, conislocal, connoinherit
   from pg_constraint c, pg_class r
-  where relname like 'test_inh_check%' and c.conrelid = r.oid
+  where relname like 'test\_inh\_check%' and c.conrelid = r.oid
   order by 1, 2;
        relname        |        conname         | coninhcount | conislocal | connoinherit 
 ----------------------+------------------------+-------------+------------+--------------
@@ -2300,7 +2300,7 @@ Inherits: test_inh_check
 
 select relname, conname, coninhcount, conislocal, connoinherit
   from pg_constraint c, pg_class r
-  where relname like 'test_inh_check%' and c.conrelid = r.oid
+  where relname like 'test\_inh\_check%' and c.conrelid = r.oid
   order by 1, 2;
        relname        |        conname         | coninhcount | conislocal | connoinherit 
 ----------------------+------------------------+-------------+------------+--------------
@@ -2455,7 +2455,7 @@ create type lockmodes as enum (
 drop view my_locks;
 ERROR:  view "my_locks" does not exist
 create or replace view my_locks as
-select case when c.relname like 'pg_toast%' then 'pg_toast' else c.relname end, max(mode::lockmodes) as max_lockmode
+select case when c.relname like 'pg\_toast%' then 'pg_toast' else c.relname end, max(mode::lockmodes) as max_lockmode
 from pg_locks l join pg_class c on l.relation = c.oid
 where virtualtransaction = (
         select virtualtransaction
@@ -2618,7 +2618,7 @@ select * from my_locks order by 1;
 
 rollback;
 create or replace view my_locks as
-select case when c.relname like 'pg_toast%' then 'pg_toast' else c.relname end, max(mode::lockmodes) as max_lockmode
+select case when c.relname like 'pg\_toast%' then 'pg_toast' else c.relname end, max(mode::lockmodes) as max_lockmode
 from pg_locks l join pg_class c on l.relation = c.oid
 where virtualtransaction = (
         select virtualtransaction
diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out
index 2bb62212ea..7263b3008e 100644
--- a/src/test/regress/expected/cluster.out
+++ b/src/test/regress/expected/cluster.out
@@ -255,7 +255,7 @@ ORDER BY 1;
 
 SELECT relname, relkind,
     EXISTS(SELECT 1 FROM pg_class WHERE oid = c.reltoastrelid) AS hastoast
-FROM pg_class c WHERE relname LIKE 'clstr_tst%' ORDER BY relname;
+FROM pg_class c WHERE relname LIKE 'clstr\_tst%' ORDER BY relname;
        relname        | relkind | hastoast 
 ----------------------+---------+----------
  clstr_tst            | r       | t
diff --git a/src/test/regress/expected/collate.out b/src/test/regress/expected/collate.out
index 0dee7d783a..247a20130f 100644
--- a/src/test/regress/expected/collate.out
+++ b/src/test/regress/expected/collate.out
@@ -586,7 +586,7 @@ CREATE INDEX collate_test1_idx6 ON collate_test1 ((a COLLATE "POSIX")); -- fail
 ERROR:  collations are not supported by type integer
 LINE 1: ...ATE INDEX collate_test1_idx6 ON collate_test1 ((a COLLATE "P...
                                                              ^
-SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate_test%_idx%' ORDER BY 1;
+SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate\_test%\_idx%' ORDER BY 1;
       relname       |                                                  pg_get_indexdef                                                  
 --------------------+-------------------------------------------------------------------------------------------------------------------
  collate_test1_idx1 | CREATE INDEX collate_test1_idx1 ON collate_tests.collate_test1 USING btree (b)
diff --git a/src/test/regress/expected/create_am.out b/src/test/regress/expected/create_am.out
index 84da403afc..04a109756a 100644
--- a/src/test/regress/expected/create_am.out
+++ b/src/test/regress/expected/create_am.out
@@ -256,7 +256,7 @@ SELECT
     END COLLATE "C" AS relname
 FROM pg_class AS pc
     LEFT JOIN pg_am AS pa ON (pa.oid = pc.relam)
-WHERE pc.relname LIKE 'tableam_%_heapx'
+WHERE pc.relname LIKE 'tableam\_%\_heapx'
 ORDER BY 3, 1, 2;
  relkind | amname |           relname           
 ---------+--------+-----------------------------
diff --git a/src/test/regress/expected/create_view.out b/src/test/regress/expected/create_view.out
index 2fd36ca9a1..9d0c52224c 100644
--- a/src/test/regress/expected/create_view.out
+++ b/src/test/regress/expected/create_view.out
@@ -161,7 +161,7 @@ SELECT relname FROM pg_class
 
 SELECT relname FROM pg_class
     WHERE relname LIKE 'v%'
-    AND relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname LIKE 'pg_temp%')
+    AND relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname LIKE 'pg\_temp%')
     ORDER BY relname;
  relname  
 ----------
@@ -210,7 +210,7 @@ SELECT relname FROM pg_class
 
 SELECT relname FROM pg_class
     WHERE relname LIKE 'temporal%'
-    AND relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname LIKE 'pg_temp%')
+    AND relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname LIKE 'pg\_temp%')
     ORDER BY relname;
   relname  
 -----------
@@ -243,7 +243,7 @@ AND EXISTS (SELECT g FROM tbl4 LEFT JOIN tbl3 ON tbl4.h = tbl3.f)
 AND NOT EXISTS (SELECT g FROM tbl4 LEFT JOIN tmptbl ON tbl4.h = tmptbl.j);
 NOTICE:  view "mytempview" will be a temporary view
 SELECT count(*) FROM pg_class where relname LIKE 'mytempview'
-And relnamespace IN (SELECT OID FROM pg_namespace WHERE nspname LIKE 'pg_temp%');
+And relnamespace IN (SELECT OID FROM pg_namespace WHERE nspname LIKE 'pg\_temp%');
  count 
 -------
      1
diff --git a/src/test/regress/expected/lock.out b/src/test/regress/expected/lock.out
index 185fd2f879..3ed90dd57a 100644
--- a/src/test/regress/expected/lock.out
+++ b/src/test/regress/expected/lock.out
@@ -42,7 +42,7 @@ BEGIN TRANSACTION;
 LOCK TABLE lock_view1 IN EXCLUSIVE MODE;
 -- lock_view1 and lock_tbl1 are locked.
 select relname from pg_locks l, pg_class c
- where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock'
+ where l.relation = c.oid and relname like '%lock\_%' and mode = 'ExclusiveLock'
  order by relname;
   relname   
 ------------
@@ -55,7 +55,7 @@ BEGIN TRANSACTION;
 LOCK TABLE lock_view2 IN EXCLUSIVE MODE;
 -- lock_view1, lock_tbl1, and lock_tbl1a are locked.
 select relname from pg_locks l, pg_class c
- where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock'
+ where l.relation = c.oid and relname like '%lock\_%' and mode = 'ExclusiveLock'
  order by relname;
   relname   
 ------------
@@ -69,7 +69,7 @@ BEGIN TRANSACTION;
 LOCK TABLE lock_view3 IN EXCLUSIVE MODE;
 -- lock_view3, lock_view2, lock_tbl1, and lock_tbl1a are locked recursively.
 select relname from pg_locks l, pg_class c
- where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock'
+ where l.relation = c.oid and relname like '%lock\_%' and mode = 'ExclusiveLock'
  order by relname;
   relname   
 ------------
@@ -84,7 +84,7 @@ BEGIN TRANSACTION;
 LOCK TABLE lock_view4 IN EXCLUSIVE MODE;
 -- lock_view4, lock_tbl1, and lock_tbl1a are locked.
 select relname from pg_locks l, pg_class c
- where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock'
+ where l.relation = c.oid and relname like '%lock\_%' and mode = 'ExclusiveLock'
  order by relname;
   relname   
 ------------
@@ -98,7 +98,7 @@ BEGIN TRANSACTION;
 LOCK TABLE lock_view5 IN EXCLUSIVE MODE;
 -- lock_view5, lock_tbl1, and lock_tbl1a are locked.
 select relname from pg_locks l, pg_class c
- where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock'
+ where l.relation = c.oid and relname like '%lock\_%' and mode = 'ExclusiveLock'
  order by relname;
   relname   
 ------------
@@ -112,7 +112,7 @@ BEGIN TRANSACTION;
 LOCK TABLE lock_view6 IN EXCLUSIVE MODE;
 -- lock_view6 an lock_tbl1 are locked.
 select relname from pg_locks l, pg_class c
- where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock'
+ where l.relation = c.oid and relname like '%lock\_%' and mode = 'ExclusiveLock'
  order by relname;
   relname   
 ------------
diff --git a/src/test/regress/expected/stats.out b/src/test/regress/expected/stats.out
index 61fbf7e41e..fb44f1dcd3 100644
--- a/src/test/regress/expected/stats.out
+++ b/src/test/regress/expected/stats.out
@@ -162,7 +162,7 @@ SELECT wait_for_stats();
 -- check effects
 SELECT relname, n_tup_ins, n_tup_upd, n_tup_del, n_live_tup, n_dead_tup
   FROM pg_stat_user_tables
- WHERE relname like 'trunc_stats_test%' order by relname;
+ WHERE relname like 'trunc\_stats\_test%' order by relname;
       relname      | n_tup_ins | n_tup_upd | n_tup_del | n_live_tup | n_dead_tup 
 -------------------+-----------+-----------+-----------+------------+------------
  trunc_stats_test  |         3 |         0 |         0 |          0 |          0
diff --git a/src/test/regress/expected/temp.out b/src/test/regress/expected/temp.out
index eab75dbe2c..515c6b1b95 100644
--- a/src/test/regress/expected/temp.out
+++ b/src/test/regress/expected/temp.out
@@ -246,7 +246,7 @@ create temp table temp_parted_oncommit_test2
 insert into temp_parted_oncommit_test values (1), (2);
 commit;
 -- no relations remain in this case.
-select relname from pg_class where relname like 'temp_parted_oncommit_test%';
+select relname from pg_class where relname like 'temp\_parted\_oncommit\_test%';
  relname 
 ---------
 (0 rows)
@@ -273,7 +273,8 @@ select * from temp_parted_oncommit_test;
 (1 row)
 
 -- two relations remain in this case.
-select relname from pg_class where relname like 'temp_parted_oncommit_test%';
+select relname from pg_class where relname like 'temp\_parted\_oncommit\_test%'
+  order by relname;
           relname           
 ----------------------------
  temp_parted_oncommit_test
@@ -290,7 +291,7 @@ create temp table temp_inh_oncommit_test1 ()
 insert into temp_inh_oncommit_test1 values (1);
 commit;
 -- no relations remain in this case
-select relname from pg_class where relname like 'temp_inh_oncommit_test%';
+select relname from pg_class where relname like 'temp\_inh\_oncommit\_test%';
  relname 
 ---------
 (0 rows)
@@ -309,7 +310,7 @@ select * from temp_inh_oncommit_test;
 (0 rows)
 
 -- one relation remains
-select relname from pg_class where relname like 'temp_inh_oncommit_test%';
+select relname from pg_class where relname like 'temp\_inh\_oncommit\_test%';
         relname         
 ------------------------
  temp_inh_oncommit_test
diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql
index 99af0b851b..0e734520e7 100644
--- a/src/test/regress/sql/alter_table.sql
+++ b/src/test/regress/sql/alter_table.sql
@@ -1399,7 +1399,7 @@ insert into at_partitioned values(3, 'bar');
 
 create temp table old_oids as
   select relname, oid as oldoid, relfilenode as oldfilenode
-  from pg_class where relname like 'at_partitioned%';
+  from pg_class where relname like 'at\_partitioned%';
 
 select relname,
   c.oid = oldoid as orig_oid,
@@ -1411,11 +1411,11 @@ select relname,
     end as storage,
   obj_description(c.oid, 'pg_class') as desc
   from pg_class c left join old_oids using (relname)
-  where relname like 'at_partitioned%'
+  where relname like 'at\_partitioned%'
   order by relname;
 
 select conname, obj_description(oid, 'pg_constraint') as desc
-  from pg_constraint where conname like 'at_partitioned%'
+  from pg_constraint where conname like 'at\_partitioned%'
   order by conname;
 
 alter table at_partitioned alter column name type varchar(127);
@@ -1432,11 +1432,11 @@ select relname,
     end as storage,
   obj_description(c.oid, 'pg_class') as desc
   from pg_class c left join old_oids using (relname)
-  where relname like 'at_partitioned%'
+  where relname like 'at\_partitioned%'
   order by relname;
 
 select conname, obj_description(oid, 'pg_constraint') as desc
-  from pg_constraint where conname like 'at_partitioned%'
+  from pg_constraint where conname like 'at\_partitioned%'
   order by conname;
 
 -- Don't remove this DROP, it exposes bug #15672
@@ -1470,14 +1470,14 @@ CREATE TABLE test_inh_check_child() INHERITS(test_inh_check);
 \d test_inh_check_child
 select relname, conname, coninhcount, conislocal, connoinherit
   from pg_constraint c, pg_class r
-  where relname like 'test_inh_check%' and c.conrelid = r.oid
+  where relname like 'test\_inh\_check%' and c.conrelid = r.oid
   order by 1, 2;
 ALTER TABLE test_inh_check ALTER COLUMN a TYPE numeric;
 \d test_inh_check
 \d test_inh_check_child
 select relname, conname, coninhcount, conislocal, connoinherit
   from pg_constraint c, pg_class r
-  where relname like 'test_inh_check%' and c.conrelid = r.oid
+  where relname like 'test\_inh\_check%' and c.conrelid = r.oid
   order by 1, 2;
 -- also try noinherit, local, and local+inherited cases
 ALTER TABLE test_inh_check ADD CONSTRAINT bnoinherit CHECK (b > 100) NO INHERIT;
@@ -1488,14 +1488,14 @@ ALTER TABLE test_inh_check ADD CONSTRAINT bmerged CHECK (b > 1);
 \d test_inh_check_child
 select relname, conname, coninhcount, conislocal, connoinherit
   from pg_constraint c, pg_class r
-  where relname like 'test_inh_check%' and c.conrelid = r.oid
+  where relname like 'test\_inh\_check%' and c.conrelid = r.oid
   order by 1, 2;
 ALTER TABLE test_inh_check ALTER COLUMN b TYPE numeric;
 \d test_inh_check
 \d test_inh_check_child
 select relname, conname, coninhcount, conislocal, connoinherit
   from pg_constraint c, pg_class r
-  where relname like 'test_inh_check%' and c.conrelid = r.oid
+  where relname like 'test\_inh\_check%' and c.conrelid = r.oid
   order by 1, 2;
 
 -- ALTER COLUMN TYPE with different schema in children
@@ -1568,7 +1568,7 @@ create type lockmodes as enum (
 
 drop view my_locks;
 create or replace view my_locks as
-select case when c.relname like 'pg_toast%' then 'pg_toast' else c.relname end, max(mode::lockmodes) as max_lockmode
+select case when c.relname like 'pg\_toast%' then 'pg_toast' else c.relname end, max(mode::lockmodes) as max_lockmode
 from pg_locks l join pg_class c on l.relation = c.oid
 where virtualtransaction = (
         select virtualtransaction
@@ -1655,7 +1655,7 @@ select * from my_locks order by 1;
 rollback;
 
 create or replace view my_locks as
-select case when c.relname like 'pg_toast%' then 'pg_toast' else c.relname end, max(mode::lockmodes) as max_lockmode
+select case when c.relname like 'pg\_toast%' then 'pg_toast' else c.relname end, max(mode::lockmodes) as max_lockmode
 from pg_locks l join pg_class c on l.relation = c.oid
 where virtualtransaction = (
         select virtualtransaction
diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql
index 522bfeead4..d20d136708 100644
--- a/src/test/regress/sql/cluster.sql
+++ b/src/test/regress/sql/cluster.sql
@@ -79,7 +79,7 @@ ORDER BY 1;
 
 SELECT relname, relkind,
     EXISTS(SELECT 1 FROM pg_class WHERE oid = c.reltoastrelid) AS hastoast
-FROM pg_class c WHERE relname LIKE 'clstr_tst%' ORDER BY relname;
+FROM pg_class c WHERE relname LIKE 'clstr\_tst%' ORDER BY relname;
 
 -- Verify that indisclustered is correctly set
 SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2
diff --git a/src/test/regress/sql/collate.sql b/src/test/regress/sql/collate.sql
index 89de26a227..056c8fbf20 100644
--- a/src/test/regress/sql/collate.sql
+++ b/src/test/regress/sql/collate.sql
@@ -199,7 +199,7 @@ CREATE INDEX collate_test1_idx4 ON collate_test1 (((b||'foo') COLLATE "POSIX"));
 CREATE INDEX collate_test1_idx5 ON collate_test1 (a COLLATE "POSIX"); -- fail
 CREATE INDEX collate_test1_idx6 ON collate_test1 ((a COLLATE "POSIX")); -- fail
 
-SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate_test%_idx%' ORDER BY 1;
+SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate\_test%\_idx%' ORDER BY 1;
 
 
 -- foreign keys
diff --git a/src/test/regress/sql/create_am.sql b/src/test/regress/sql/create_am.sql
index a7f6de7e9b..e9e1deae01 100644
--- a/src/test/regress/sql/create_am.sql
+++ b/src/test/regress/sql/create_am.sql
@@ -192,7 +192,7 @@ SELECT
     END COLLATE "C" AS relname
 FROM pg_class AS pc
     LEFT JOIN pg_am AS pa ON (pa.oid = pc.relam)
-WHERE pc.relname LIKE 'tableam_%_heapx'
+WHERE pc.relname LIKE 'tableam\_%\_heapx'
 ORDER BY 3, 1, 2;
 
 -- don't want to keep those tables, nor the default
diff --git a/src/test/regress/sql/create_view.sql b/src/test/regress/sql/create_view.sql
index 8c0f45cc52..9ca5875318 100644
--- a/src/test/regress/sql/create_view.sql
+++ b/src/test/regress/sql/create_view.sql
@@ -152,7 +152,7 @@ SELECT relname FROM pg_class
     ORDER BY relname;
 SELECT relname FROM pg_class
     WHERE relname LIKE 'v%'
-    AND relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname LIKE 'pg_temp%')
+    AND relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname LIKE 'pg\_temp%')
     ORDER BY relname;
 
 CREATE SCHEMA testviewschm2;
@@ -177,7 +177,7 @@ SELECT relname FROM pg_class
     ORDER BY relname;
 SELECT relname FROM pg_class
     WHERE relname LIKE 'temporal%'
-    AND relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname LIKE 'pg_temp%')
+    AND relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname LIKE 'pg\_temp%')
     ORDER BY relname;
 
 CREATE TABLE tbl1 ( a int, b int);
@@ -201,7 +201,7 @@ AND EXISTS (SELECT g FROM tbl4 LEFT JOIN tbl3 ON tbl4.h = tbl3.f)
 AND NOT EXISTS (SELECT g FROM tbl4 LEFT JOIN tmptbl ON tbl4.h = tmptbl.j);
 
 SELECT count(*) FROM pg_class where relname LIKE 'mytempview'
-And relnamespace IN (SELECT OID FROM pg_namespace WHERE nspname LIKE 'pg_temp%');
+And relnamespace IN (SELECT OID FROM pg_namespace WHERE nspname LIKE 'pg\_temp%');
 
 --
 -- CREATE VIEW and WITH(...) clause
diff --git a/src/test/regress/sql/lock.sql b/src/test/regress/sql/lock.sql
index 26a7e59a13..a486fb3085 100644
--- a/src/test/regress/sql/lock.sql
+++ b/src/test/regress/sql/lock.sql
@@ -46,42 +46,42 @@ BEGIN TRANSACTION;
 LOCK TABLE lock_view1 IN EXCLUSIVE MODE;
 -- lock_view1 and lock_tbl1 are locked.
 select relname from pg_locks l, pg_class c
- where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock'
+ where l.relation = c.oid and relname like '%lock\_%' and mode = 'ExclusiveLock'
  order by relname;
 ROLLBACK;
 BEGIN TRANSACTION;
 LOCK TABLE lock_view2 IN EXCLUSIVE MODE;
 -- lock_view1, lock_tbl1, and lock_tbl1a are locked.
 select relname from pg_locks l, pg_class c
- where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock'
+ where l.relation = c.oid and relname like '%lock\_%' and mode = 'ExclusiveLock'
  order by relname;
 ROLLBACK;
 BEGIN TRANSACTION;
 LOCK TABLE lock_view3 IN EXCLUSIVE MODE;
 -- lock_view3, lock_view2, lock_tbl1, and lock_tbl1a are locked recursively.
 select relname from pg_locks l, pg_class c
- where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock'
+ where l.relation = c.oid and relname like '%lock\_%' and mode = 'ExclusiveLock'
  order by relname;
 ROLLBACK;
 BEGIN TRANSACTION;
 LOCK TABLE lock_view4 IN EXCLUSIVE MODE;
 -- lock_view4, lock_tbl1, and lock_tbl1a are locked.
 select relname from pg_locks l, pg_class c
- where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock'
+ where l.relation = c.oid and relname like '%lock\_%' and mode = 'ExclusiveLock'
  order by relname;
 ROLLBACK;
 BEGIN TRANSACTION;
 LOCK TABLE lock_view5 IN EXCLUSIVE MODE;
 -- lock_view5, lock_tbl1, and lock_tbl1a are locked.
 select relname from pg_locks l, pg_class c
- where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock'
+ where l.relation = c.oid and relname like '%lock\_%' and mode = 'ExclusiveLock'
  order by relname;
 ROLLBACK;
 BEGIN TRANSACTION;
 LOCK TABLE lock_view6 IN EXCLUSIVE MODE;
 -- lock_view6 an lock_tbl1 are locked.
 select relname from pg_locks l, pg_class c
- where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock'
+ where l.relation = c.oid and relname like '%lock\_%' and mode = 'ExclusiveLock'
  order by relname;
 ROLLBACK;
 -- detecting infinite recursions in view definitions
diff --git a/src/test/regress/sql/stats.sql b/src/test/regress/sql/stats.sql
index 9defd4b7a9..5cd27ffd4f 100644
--- a/src/test/regress/sql/stats.sql
+++ b/src/test/regress/sql/stats.sql
@@ -157,7 +157,7 @@ SELECT wait_for_stats();
 -- check effects
 SELECT relname, n_tup_ins, n_tup_upd, n_tup_del, n_live_tup, n_dead_tup
   FROM pg_stat_user_tables
- WHERE relname like 'trunc_stats_test%' order by relname;
+ WHERE relname like 'trunc\_stats\_test%' order by relname;
 
 SELECT st.seq_scan >= pr.seq_scan + 1,
        st.seq_tup_read >= pr.seq_tup_read + cl.reltuples,
diff --git a/src/test/regress/sql/temp.sql b/src/test/regress/sql/temp.sql
index 761955bfe6..a71191d0b4 100644
--- a/src/test/regress/sql/temp.sql
+++ b/src/test/regress/sql/temp.sql
@@ -192,7 +192,7 @@ create temp table temp_parted_oncommit_test2
 insert into temp_parted_oncommit_test values (1), (2);
 commit;
 -- no relations remain in this case.
-select relname from pg_class where relname like 'temp_parted_oncommit_test%';
+select relname from pg_class where relname like 'temp\_parted\_oncommit\_test%';
 -- Using ON COMMIT DELETE on a partitioned table does not remove
 -- all rows if partitions preserve their data.
 begin;
@@ -210,7 +210,8 @@ commit;
 -- preserved.
 select * from temp_parted_oncommit_test;
 -- two relations remain in this case.
-select relname from pg_class where relname like 'temp_parted_oncommit_test%';
+select relname from pg_class where relname like 'temp\_parted\_oncommit\_test%'
+  order by relname;
 drop table temp_parted_oncommit_test;
 
 -- Check dependencies between ON COMMIT actions with inheritance trees.
@@ -222,7 +223,7 @@ create temp table temp_inh_oncommit_test1 ()
 insert into temp_inh_oncommit_test1 values (1);
 commit;
 -- no relations remain in this case
-select relname from pg_class where relname like 'temp_inh_oncommit_test%';
+select relname from pg_class where relname like 'temp\_inh\_oncommit\_test%';
 -- Data on the parent is removed, and the child goes away.
 begin;
 create temp table temp_inh_oncommit_test (a int) on commit delete rows;
@@ -233,7 +234,7 @@ insert into temp_inh_oncommit_test values (1);
 commit;
 select * from temp_inh_oncommit_test;
 -- one relation remains
-select relname from pg_class where relname like 'temp_inh_oncommit_test%';
+select relname from pg_class where relname like 'temp\_inh\_oncommit\_test%';
 drop table temp_inh_oncommit_test;
 
 -- Tests with two-phase commit

Attachment: signature.asc
Description: PGP signature

Reply via email to