shardingsphere
shardingsphere copied to clipboard
Refactor PG/OG statement inheritance relationship
Alter rule
is not a standard SQL, it belongs to the PG dialect.
Therefore AlterRuleStatement
should not exist under the common
package.
Since ALTER RULE
is a PostgreSQL language extension (see Compatibility), I want to add a package extension
under statement/postgresql/ddl
and rename AlterRuleStatement
to PostgreSQLAlterRuleExtension
so that PostgreSQLAlterRuleStatement
and OpenGaussAlterRuleStatement
can inherit it.
Why not let OpenGaussAlterRuleStatement
directly inherit from PostgreSQLAlterRuleStatement
?
Because PostgreSQLAlterRuleStatement
implements the interface PostgreSQLStatement
, and OpenGaussAlterRuleStatement
needs to implement OpenGaussStatement
, this is in conflict.
shardingsphere-parser-sql-statement
- Before
.
├── common
│ ├── enums
│ ├── extractor
│ ├── segment
│ ├── statement
│ ├── util
│ └── value
└── dialect
├── handler
├── segment
└── statement
├── mysql
│ ├── dal
│ ├── dcl
│ ├── ddl
│ ├── dml
│ ├── rl
│ ├── segment
│ └── tcl
├── opengauss
│ ├── dal
│ ├── dcl
│ ├── ddl
│ ├── dml
│ └── tcl
├── oracle
│ ├── dal
│ ├── dcl
│ ├── ddl
│ ├── dml
│ └── tcl
├── postgresql
│ ├── dal
│ ├── dcl
│ ├── ddl
│ ├── dml
│ └── tcl
├── sql92
│ ├── dcl
│ ├── ddl
│ ├── dml
│ └── tcl
└── sqlserver
├── dal
├── dcl
├── ddl
├── dml
└── tcl
- After
.
├── common
│ ├── enums
│ ├── extractor
│ ├── segment
│ ├── statement
│ ├── util
│ └── value
└── dialect
├── handler
├── segment
└── statement
├── mysql
│ ├── dal
│ ├── dcl
│ ├── ddl
│ ├── dml
│ ├── rl
│ ├── segment
│ └── tcl
├── opengauss
│ ├── dal
│ ├── dcl
│ ├── ddl
│ ├── dml
│ └── tcl
├── oracle
│ ├── dal
│ ├── dcl
│ ├── ddl
│ ├── dml
│ └── tcl
├── postgresql
│ ├── dal
│ ├── dcl
│ ├── ddl
│ │ └── extension * (new package)
│ ├── dml
│ └── tcl
├── sql92
│ ├── dcl
│ ├── ddl
│ ├── dml
│ └── tcl
└── sqlserver
├── dal
├── dcl
├── ddl
├── dml
└── tcl
Similarly, there are other dialect extensions that can be refactored in this way.
Hi, can I take a look at this question? Thank you
Before starting to solve the problem, I have some doubts about the OpenGaussAlterRuleStatement inheriting from PostgreSQLAlterRuleExtension on the graph Alter RULE is an extension of PostgreSQL statements. Why should OpenGaussAlterRuleStatement inherit from PostgreSQLAlterRuleExtension? Does this indicate that the OpenGaussAlterRuleStatement dialect is based on an extension of PostgreSQL? Additionally, I did not find a description of the Alter RULE statement on the official OpenGauss documentation, as this SQL statement does not seem to belong to the dialect of OpenGauss
@zihaoAK47 It is in the 2.0 documentation (link)
In fact, openGauss has so many similarities with PostgreSQL (SQL protocol and syntax), so we should sort out the common parts and reuse them in ShardingSphere. At the same time, since some statements do not belong to the SQL standards, they should be placed under the PostgreSQL extension.
However, letting openGauss inherit the PostgreSQL class will also lead to a large number of duplicate Classes. It may be necessary to redesign how to reduce duplicate classes.
@zihaoAK47 It is in the 2.0 documentation (link)
In fact, openGauss has so many similarities with PostgreSQL (SQL protocol and syntax), so we should sort out the common parts and reuse them in ShardingSphere. At the same time, since some statements do not belong to the SQL standards, they should be placed under the PostgreSQL extension.
Thank you for your reply. I understand
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.