From a0093353d5fad21e044468825a9f321289d75dd0 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 v2] Avoid a potential unstable testcase.

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

diff --git a/src/test/regress/expected/xmlmap.out b/src/test/regress/expected/xmlmap.out
index ccc54606630..d186b260e73 100644
--- a/src/test/regress/expected/xmlmap.out
+++ b/src/test/regress/expected/xmlmap.out
@@ -809,6 +809,11 @@ 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;
 SELECT schema_to_xml('testxmlschema', false, true, '');
                              schema_to_xml                             
 -----------------------------------------------------------------------
@@ -1276,6 +1281,7 @@ SELECT schema_to_xml_and_xmlschema('testxmlschema', true, true, 'foo');
  
 (1 row)
 
+reset enable_seqscan;
 -- 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..4aaba5a0b49 100644
--- a/src/test/regress/sql/xmlmap.sql
+++ b/src/test/regress/sql/xmlmap.sql
@@ -41,12 +41,18 @@ 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;
 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;
 
 -- test that domains are transformed like their base types
 
-- 
2.21.0

