You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/07/08 05:54:01 UTC

[shardingsphere] branch master updated: fix parsing column name is path (#18950)

This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new aaa4508695b fix parsing column name is path (#18950)
aaa4508695b is described below

commit aaa4508695b528c6e420350e98d4fdb84264d145
Author: Chuxin Chen <ch...@qq.com>
AuthorDate: Fri Jul 8 13:53:56 2022 +0800

    fix parsing column name is path (#18950)
    
    * fix column name is path
    
    * fix column name is path
---
 .../src/main/antlr4/imports/postgresql/BaseRule.g4                 | 1 +
 .../src/main/resources/case/ddl/create-table.xml                   | 7 +++++++
 .../src/main/resources/sql/supported/ddl/create-table.xml          | 2 +-
 .../src/main/resources/sql/supported/ddl/drop-table.xml            | 1 +
 .../src/main/resources/sql/unsupported/unsupported.xml             | 5 -----
 5 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
index 30794464fc5..c622e5b78c0 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
@@ -307,6 +307,7 @@ unreservedWord
     | PARTITION
     | PASSING
     | PASSWORD
+    | PATH
     | PLAIN
     | PLANS
     | POLICY
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/create-table.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/create-table.xml
index 4b092453ef9..7505c008d07 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/create-table.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/create-table.xml
@@ -1744,4 +1744,11 @@
             <column name="a" />
         </column-definition>
     </create-table>
+
+    <create-table sql-case-id="create_table_path">
+        <table name="files" start-index="13" stop-index="17" />
+        <column-definition type="PATH" start-index="20" stop-index="28">
+            <column name="path" />
+        </column-definition>
+    </create-table>
 </sql-parser-test-cases>
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/create-table.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/create-table.xml
index 8b69dac0e85..96cbc101d96 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/create-table.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/create-table.xml
@@ -123,5 +123,5 @@
     <sql-case id="create_table_with_chinese_word_with_quote" value="CREATE TABLE &quot;测试表&quot;(id int PRIMARY KEY, status varchar(10))" db-types="Oracle,PostgreSQL,openGauss,SQLServer,SQL92" />
     <sql-case id="create_bit_xor_table" value="create table BIT_XOR(a int)" db-types="MySQL" />
     <sql-case id="create_bit_xor_table_with_space" value="create table BIT_XOR (a int)" db-types="MySQL" />
-    <sql-case id="drop_bit_xor_table" value="drop table BIT_XOR" db-types="MySQL" />
+    <sql-case id="create_table_path" value="CREATE TABLE files (path PATH);" db-types="PostgreSQL" />
 </sql-cases>
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-table.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-table.xml
index abea94ce0e2..95110efb833 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-table.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-table.xml
@@ -32,4 +32,5 @@
     <sql-case id="drop_table_with_quota" value="DROP TABLE &quot;t_order&quot;" db-types="Oracle" />
     <sql-case id="drop_table_with_double_quota" value="DROP TABLE &quot;t_order&quot;" db-types="PostgreSQL,openGauss" />
     <sql-case id="drop_table_with_bracket" value="DROP TABLE [t_order]" db-types="SQLServer" />
+    <sql-case id="drop_bit_xor_table" value="drop table BIT_XOR" db-types="MySQL" />
 </sql-cases>
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/unsupported/unsupported.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/unsupported/unsupported.xml
index e8c11ba77a3..69495505b64 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/unsupported/unsupported.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/unsupported/unsupported.xml
@@ -5401,7 +5401,6 @@
     <sql-case id="select_by_postgresql_source_test_case820" value="SELECT f1,     date_part(&apos;microsecond&apos;, f1) AS microsecond,     date_part(&apos;millisecond&apos;, f1) AS millisecond,     date_part(&apos;second&apos;, f1) AS second,     date_part(&apos;epoch&apos;, f1) AS epoch     FROM INTERVAL_TBL;" db-types="PostgreSQL" />
     <sql-case id="select_by_postgresql_source_test_case821" value="SELECT f1, @-@ f1 FROM PATH_TBL;" db-types="PostgreSQL" />
     <sql-case id="select_by_postgresql_source_test_case823" value="SELECT f1, f1::box FROM POLYGON_TBL;" db-types="PostgreSQL" />
-    <sql-case id="select_by_postgresql_source_test_case824" value="SELECT f1, f1::path FROM POLYGON_TBL;" db-types="PostgreSQL" />
     <sql-case id="select_by_postgresql_source_test_case825" value="SELECT f1, f1::polygon FROM CIRCLE_TBL WHERE f1 &gt;= &apos;&lt;(0,0),1&gt;&apos;;" db-types="PostgreSQL" />
     <sql-case id="select_by_postgresql_source_test_case826" value="SELECT f1, f1::polygon FROM PATH_TBL WHERE isclosed(f1);" db-types="PostgreSQL" />
     <sql-case id="select_by_postgresql_source_test_case827" value="SELECT f1, f1::polygon FROM PATH_TBL WHERE isopen(f1);" db-types="PostgreSQL" />
@@ -5901,7 +5900,6 @@
     <sql-case id="with_by_postgresql_source_test_case1" value="WITH RECURSIVE outermost(x) AS (   WITH innermost as (SELECT 2 FROM outermos     SELECT * FROM innermost     UNION SELECT * from outermost ) SELECT * FROM outermost ORDER BY 1;" db-types="PostgreSQL" />
     <sql-case id="with_by_postgresql_source_test_case2" value="WITH RECURSIVE t(id, path) AS (     VALUES(1,ARRAY[]::integer[]) UNION ALL     SELECT tree.id, t.path || tree.id     FROM tree JOIN t ON (tree.parent_id = t.id) ) SELECT t1.*, t2.* FROM t AS t1 JOIN t AS t2 ON 	(t1.path[1] = t2.path[1] AND 	array_upper(t1.path,1) = 1 AND 	array_upper(t2.path,1) &gt; 1) 	ORDER BY t1.id, t2.id;" db-types="PostgreSQL" />
     <sql-case id="with_by_postgresql_source_test_case3" value="WITH RECURSIVE t(id, path) AS (     VALUES(1,ARRAY[]::integer[]) UNION ALL     SELECT tree.id, t.path || tree.id     FROM tree JOIN t ON (tree.parent_id = t.id) ) SELECT t1.id, count(t2.*) FROM t AS t1 JOIN t AS t2 ON 	(t1.path[1] = t2.path[1] AND 	array_upper(t1.path,1) = 1 AND 	array_upper(t2.path,1) &gt; 1) 	GROUP BY t1.id 	ORDER BY t1.id;" db-types="PostgreSQL" />
-    <sql-case id="with_by_postgresql_source_test_case4" value="WITH RECURSIVE t(id, path) AS (     VALUES(1,ARRAY[]::integer[]) UNION ALL     SELECT tree.id, t.path || tree.id     FROM tree JOIN t ON (tree.parent_id = t.id) ) SELECT t1.id, t2.path, t2 FROM t AS t1 JOIN t AS t2 ON (t1.id=t2.id);" db-types="PostgreSQL" />
     <sql-case id="with_by_postgresql_source_test_case5" value="WITH RECURSIVE t(n) AS (     VALUES (1::money) UNION     SELECT n+1::money FROM t WHERE n &lt; 100::money ) SELECT sum(n) FROM t;" db-types="PostgreSQL" />
     <sql-case id="with_by_postgresql_source_test_case7" value="WITH objects (classid, objid, objsubid) AS (VALUES     (&apos;pg_class&apos;::regclass, 0,     (&apos;pg_class&apos;::regclass, &apos;pg_class&apos;::regclass, 1     (&apos;pg_proc&apos;::regclass, 0,     (&apos;pg_type&apos;::regclass, 0,     (&apos;pg_cast&apos;::regclass, 0,     (&apos;pg_collation&apos;::regclass, 0,     (&apos;pg_constraint&apos;::regclass, 0,     (&apos;pg_conversion&apos;::regclass, 0,     (&apos;pg_at [...]
     <sql-case id="with_by_postgresql_source_test_case8" value="WITH objects (type, name, args) AS (VALUES 				(&apos;table&apos;, &apos;{addr_nsp, gentable}&apos;::text[], &apos;{}&apos;::text[]), 				(&apos;table&apos;, &apos;{addr_nsp, parttable}&apos;::text[], &apos;{}&apos;::text[]), 				(&apos;index&apos;, &apos;{addr_nsp, gentable_pkey}&apos;, &apos;{}&apos;), 				(&apos;index&apos;, &apos;{addr_nsp, parttable_pkey}&apos;, &apos;{}&apos;), 				(&apos;sequence&apos;, &apos;{addr_nsp [...]
@@ -7271,9 +7269,6 @@
     <sql-case id="low_with_by_postgresql_source_test_case24" value="with recursive search_graph(f, t, label) as ( 	select * from graph0 g 	union all 	select g.* 	from graph0 g, search_graph sg 	where g.f = sg.t ) search depth first by foo, tar set seq select * from search_graph;" db-types="PostgreSQL" />
     <sql-case id="low_with_by_postgresql_source_test_case25" value="with recursive search_graph(f, t, label) as ( 	select * from graph0 g 	union distinct 	select g.* 	from graph0 g, search_graph sg 	where g.f = sg.t ) search breadth first by f, t set seq select * from search_graph order by seq;" db-types="PostgreSQL" />
     <sql-case id="low_with_by_postgresql_source_test_case26" value="with recursive search_graph(f, t, label) as ( 	select * from graph0 g 	union distinct 	select g.* 	from graph0 g, search_graph sg 	where g.f = sg.t ) search depth first by f, t set seq select * from search_graph order by seq;" db-types="PostgreSQL" />
-    <sql-case id="low_with_by_postgresql_source_test_case27" value="with recursive search_graph(f, t, label, is_cycle, path) as ( 	select *, false, array[row(g.f, g.t)] from graph g 	union all 	select g.*, row(g.f, g.t) = any(path), path || row(g.f, g.t) 	from graph g, search_graph sg 	where g.f = sg.t and not is_cycle ) select * from search_graph order by path;" db-types="PostgreSQL" />
-    <sql-case id="low_with_by_postgresql_source_test_case28" value="with recursive search_graph(f, t, label, is_cycle, path) as ( 	select *, false, array[row(g.f, g.t)] from graph g 	union all 	select g.*, row(g.f, g.t) = any(path), path || row(g.f, g.t) 	from graph g, search_graph sg 	where g.f = sg.t and not is_cycle ) select * from search_graph;" db-types="PostgreSQL" />
-    <sql-case id="low_with_by_postgresql_source_test_case29" value="with recursive search_graph(f, t, label, is_cycle, path) as ( 	select *, false, array[row(g.f, g.t)] from graph g 	union distinct 	select g.*, row(g.f, g.t) = any(path), path || row(g.f, g.t) 	from graph g, search_graph sg 	where g.f = sg.t and not is_cycle ) select * from search_graph;" db-types="PostgreSQL" />
     <sql-case id="low_with_by_postgresql_source_test_case32" value="with testdata(bits) as (values   (x&apos;00000000&apos;),   (x&apos;00800000&apos;), (x&apos;00800001&apos;), (x&apos;00800004&apos;), (x&apos;00800005&apos;),   (x&apos;00800006&apos;),   (x&apos;008002f1&apos;), (x&apos;008002f2&apos;), (x&apos;008002f3&apos;),   (x&apos;00800e17&apos;), (x&apos;00800e18&apos;), (x&apos;00800e19&apos;),   (x&apos;01000001&apos;), (x&apos;01102843&apos;), (x&apos;01a52c98&apos;),   (x&a [...]
     <sql-case id="low_with_by_postgresql_source_test_case33" value="with testdata(bits) as (values   (x&apos;00000001&apos;),   (x&apos;00000002&apos;), (x&apos;00000003&apos;),   (x&apos;00000010&apos;), (x&apos;00000011&apos;), (x&apos;00000100&apos;), (x&apos;00000101&apos;),   (x&apos;00004000&apos;), (x&apos;00004001&apos;), (x&apos;00080000&apos;), (x&apos;00080001&apos;),   (x&apos;0053c4f4&apos;)   (x&apos;006c85c4&apos;)   (x&apos;0041ca76&apos;)   (x&apos;004b7678&apos;)   (x&a [...]
     <sql-case id="assertDistSQLShowRuleParseConflict" value="SHOW READWRITE_SPLITTING RULE FROM schema_name" db-types="PostgreSQL,openGauss" />