-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support PostgreSQL Open statement parse and small ANTLR change for Po…
…stgreSQL Declare statement (#31396) * Support PostgreSQL OPEN and small ANTLR change for DECLARE * Fix checkstyle issues
- Loading branch information
1 parent
2a9dabb
commit 0a4f183
Showing
15 changed files
with
264 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1460,3 +1460,7 @@ NOBYPASSRLS | |
ASENSITIVE | ||
: A S E N S I T I V E | ||
; | ||
|
||
DESCRIPTOR | ||
: D E S C R I P T O R | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -181,5 +181,6 @@ execute | |
| alterTrigger | ||
| createPublication | ||
| emptyStatement | ||
| open | ||
) SEMI_? EOF | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...ain/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/OpenStatement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.shardingsphere.sql.parser.sql.common.statement.ddl; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.cursor.CursorNameSegment; | ||
import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement; | ||
|
||
/** | ||
* Open statement. | ||
*/ | ||
@Getter | ||
@Setter | ||
public abstract class OpenStatement extends AbstractSQLStatement implements DDLStatement { | ||
|
||
private CursorNameSegment cursorName; | ||
} |
27 changes: 27 additions & 0 deletions
27
...ardingsphere/sql/parser/sql/dialect/statement/postgresql/ddl/PostgreSQLOpenStatement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl; | ||
|
||
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.OpenStatement; | ||
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.PostgreSQLStatement; | ||
|
||
/** | ||
* PostgreSQL open statement. | ||
*/ | ||
public final class PostgreSQLOpenStatement extends OpenStatement implements PostgreSQLStatement { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...ingsphere/test/it/sql/parser/internal/asserts/statement/ddl/impl/OpenStatementAssert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ddl.impl; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.OpenStatement; | ||
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext; | ||
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.SQLSegmentAssert; | ||
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.identifier.IdentifierValueAssert; | ||
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.OpenStatementTestCase; | ||
|
||
/** | ||
* Open statement assert. | ||
*/ | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public final class OpenStatementAssert { | ||
|
||
/** | ||
* Assert open statement is correct with expected parser result. | ||
* | ||
* @param assertContext assert context | ||
* @param actual actual declare statement | ||
* @param expected expected declare statement test case | ||
*/ | ||
public static void assertIs(final SQLCaseAssertContext assertContext, final OpenStatement actual, final OpenStatementTestCase expected) { | ||
assertCursorName(assertContext, actual, expected); | ||
} | ||
|
||
private static void assertCursorName(final SQLCaseAssertContext assertContext, final OpenStatement actual, final OpenStatementTestCase expected) { | ||
IdentifierValueAssert.assertIs(assertContext, actual.getCursorName().getIdentifier(), expected.getCursorName(), "Cursor"); | ||
SQLSegmentAssert.assertIs(assertContext, actual.getCursorName(), expected.getCursorName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...re/test/it/sql/parser/internal/cases/parser/jaxb/statement/ddl/OpenStatementTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.cursor.ExpectedCursorName; | ||
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase; | ||
|
||
import javax.xml.bind.annotation.XmlElement; | ||
|
||
/** | ||
* Open statement test case. | ||
*/ | ||
@Getter | ||
@Setter | ||
public final class OpenStatementTestCase extends SQLParserTestCase { | ||
|
||
@XmlElement(name = "cursor-name") | ||
private ExpectedCursorName cursorName; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one or more | ||
~ contributor license agreements. See the NOTICE file distributed with | ||
~ this work for additional information regarding copyright ownership. | ||
~ The ASF licenses this file to You under the Apache License, Version 2.0 | ||
~ (the "License"); you may not use this file except in compliance with | ||
~ the License. You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<sql-parser-test-cases> | ||
<open sql-case-id="open_cursor"> | ||
<cursor-name name="t_order_cursor" start-index="5" stop-index="18" /> | ||
</open> | ||
|
||
<open sql-case-id="open_cursor_using"> | ||
<cursor-name name="t_order_cursor" start-index="5" stop-index="18" /> | ||
</open> | ||
|
||
<open sql-case-id="open_cursor_using_sql"> | ||
<cursor-name name="t_order_cursor" start-index="5" stop-index="18" /> | ||
</open> | ||
|
||
<open sql-case-id="open_cursor_with_host_variable"> | ||
<cursor-name name="t_order_cursor" start-index="5" stop-index="19" /> | ||
</open> | ||
</sql-parser-test-cases> |
Oops, something went wrong.