From 30463655f6959686e7344119044226530b50e628 Mon Sep 17 00:00:00 2001
From: Andy Fan <zhihui.fan1213@gmail.com>
Date: Tue, 15 Aug 2023 18:50:00 +0800
Subject: [PATCH v1] Avoid a potential unstable testcase.

---
 src/test/regress/expected/xmlmap.out |  8 ++++++++
 src/test/regress/sql/xmlmap.sql      | 10 +++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/test/regress/expected/xmlmap.out b/src/test/regress/expected/xmlmap.out
index ccc54606630..8ea1293c3fa 100644
--- a/src/test/regress/expected/xmlmap.out
+++ b/src/test/regress/expected/xmlmap.out
@@ -809,6 +809,12 @@ SELECT cursor_to_xmlschema('xc'::refcursor, true, false, '');
  </xsd:schema>
 (1 row)
 
+-- In order to not scan the relation which not belongs to
+-- the given schema, it is better to make sure the filter
+-- on relnamespace is executed as the first qual. Index
+-- scan can grantee that while SeqScan will just break it.
+set enable_seqscan to off;
+set enable_bitmapscan to off;
 SELECT schema_to_xml('testxmlschema', false, true, '');
                              schema_to_xml                             
 -----------------------------------------------------------------------
@@ -1276,6 +1282,8 @@ SELECT schema_to_xml_and_xmlschema('testxmlschema', true, true, 'foo');
  
 (1 row)
 
+reset enable_seqscan;
+reset enable_bitmapscan;
 -- test that domains are transformed like their base types
 CREATE DOMAIN testboolxmldomain AS bool;
 CREATE DOMAIN testdatexmldomain AS date;
diff --git a/src/test/regress/sql/xmlmap.sql b/src/test/regress/sql/xmlmap.sql
index 16582bf6abd..89dfcf89fb7 100644
--- a/src/test/regress/sql/xmlmap.sql
+++ b/src/test/regress/sql/xmlmap.sql
@@ -41,12 +41,20 @@ MOVE BACKWARD ALL IN xc;
 SELECT cursor_to_xml('xc'::refcursor, 5, true, false, '');
 SELECT cursor_to_xmlschema('xc'::refcursor, true, false, '');
 
+-- In order to not scan the relation which not belongs to
+-- the given schema, it is better to make sure the filter
+-- on relnamespace is executed as the first qual. Index
+-- scan can grantee that while SeqScan will just break it.
+
+set enable_seqscan to off;
+set enable_bitmapscan to off;
 SELECT schema_to_xml('testxmlschema', false, true, '');
 SELECT schema_to_xml('testxmlschema', true, false, '');
 SELECT schema_to_xmlschema('testxmlschema', false, true, '');
 SELECT schema_to_xmlschema('testxmlschema', true, false, '');
 SELECT schema_to_xml_and_xmlschema('testxmlschema', true, true, 'foo');
-
+reset enable_seqscan;
+reset enable_bitmapscan;
 
 -- test that domains are transformed like their base types
 
-- 
2.21.0

