You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/05/05 08:24:26 UTC

[GitHub] [shardingsphere] tuichenchuxin opened a new pull request, #17334: support get logic ddl sql for mysql

tuichenchuxin opened a new pull request, #17334:
URL: https://github.com/apache/shardingsphere/pull/17334

   For #17137.
   
   Changes proposed in this pull request:
   - support get logic ddl sql for mysql
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] tuichenchuxin commented on a diff in pull request #17334: support get logic ddl sql for mysql

Posted by GitBox <gi...@apache.org>.
tuichenchuxin commented on code in PR #17334:
URL: https://github.com/apache/shardingsphere/pull/17334#discussion_r865714484


##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ddlgenerator/MySqlDDLSQLGenerator.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.data.pipeline.mysql.ddlgenerator;
+
+import org.apache.shardingsphere.data.pipeline.spi.ddlgenerator.DialectDDLSQLGenerator;
+import org.apache.shardingsphere.infra.exception.ShardingSphereException;
+
+import javax.sql.DataSource;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * DDL SQL generator for MySql.
+ */
+public final class MySqlDDLSQLGenerator implements DialectDDLSQLGenerator {

Review Comment:
   Thank you. Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] codecov-commenter commented on pull request #17334: support get logic ddl sql for mysql

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #17334:
URL: https://github.com/apache/shardingsphere/pull/17334#issuecomment-1118771081

   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/17334?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#17334](https://codecov.io/gh/apache/shardingsphere/pull/17334?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (fde8bed) into [master](https://codecov.io/gh/apache/shardingsphere/commit/3dad03db46cddc1ea657a261be7d24ed0d97f2d0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3dad03d) will **decrease** coverage by `0.01%`.
   > The diff coverage is `0.00%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #17334      +/-   ##
   ============================================
   - Coverage     59.24%   59.22%   -0.02%     
     Complexity     2115     2115              
   ============================================
     Files          3543     3544       +1     
     Lines         52838    52847       +9     
     Branches       9015     9016       +1     
   ============================================
   - Hits          31303    31300       -3     
   - Misses        18897    18909      +12     
     Partials       2638     2638              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/17334?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...pi/ddlgenerator/DialectDDLSQLGeneratorFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/17334/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUvc2hhcmRpbmdzcGhlcmUtZGF0YS1waXBlbGluZS1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RhdGEvcGlwZWxpbmUvc3BpL2RkbGdlbmVyYXRvci9EaWFsZWN0RERMU1FMR2VuZXJhdG9yRmFjdG9yeS5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...pipeline/mysql/ddlgenerator/MySQLDDLGenerator.java](https://codecov.io/gh/apache/shardingsphere/pull/17334/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUvc2hhcmRpbmdzcGhlcmUtZGF0YS1waXBlbGluZS1kaWFsZWN0L3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUtbXlzcWwvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RhdGEvcGlwZWxpbmUvbXlzcWwvZGRsZ2VuZXJhdG9yL015U1FMRERMR2VuZXJhdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...e/postgresql/ddlgenerator/PostgreDDLGenerator.java](https://codecov.io/gh/apache/shardingsphere/pull/17334/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUvc2hhcmRpbmdzcGhlcmUtZGF0YS1waXBlbGluZS1kaWFsZWN0L3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUtcG9zdGdyZXNxbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZGF0YS9waXBlbGluZS9wb3N0Z3Jlc3FsL2RkbGdlbmVyYXRvci9Qb3N0Z3JlRERMR2VuZXJhdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...d/text/distsql/ral/common/hint/HintSourceType.java](https://codecov.io/gh/apache/shardingsphere/pull/17334/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmFsL2NvbW1vbi9oaW50L0hpbnRTb3VyY2VUeXBlLmphdmE=) | `0.00% <0.00%> (-42.86%)` | :arrow_down: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/17334?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/17334?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [3dad03d...fde8bed](https://codecov.io/gh/apache/shardingsphere/pull/17334?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] strongduanmu commented on a diff in pull request #17334: support get logic ddl sql for mysql

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on code in PR #17334:
URL: https://github.com/apache/shardingsphere/pull/17334#discussion_r865703732


##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ddlgenerator/MySqlDDLSQLGenerator.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.data.pipeline.mysql.ddlgenerator;
+
+import org.apache.shardingsphere.data.pipeline.spi.ddlgenerator.DialectDDLSQLGenerator;
+import org.apache.shardingsphere.infra.exception.ShardingSphereException;
+
+import javax.sql.DataSource;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * DDL SQL generator for MySql.
+ */
+public final class MySqlDDLSQLGenerator implements DialectDDLSQLGenerator {

Review Comment:
   @tuichenchuxin Please rename it to MySQLDDLSQLGenerator.



##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ddlgenerator/MySqlDDLSQLGenerator.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.data.pipeline.mysql.ddlgenerator;
+
+import org.apache.shardingsphere.data.pipeline.spi.ddlgenerator.DialectDDLSQLGenerator;
+import org.apache.shardingsphere.infra.exception.ShardingSphereException;
+
+import javax.sql.DataSource;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * DDL SQL generator for MySql.
+ */
+public final class MySqlDDLSQLGenerator implements DialectDDLSQLGenerator {
+    
+    private static final String SHOW_CREATE_SQL = "SHOW CREATE TABLE %s";
+    
+    @Override
+    public String generateDDLSQL(final String tableName, final String schemaName, final DataSource dataSource) throws SQLException {
+        try (
+                Statement statement = dataSource.getConnection().createStatement();
+                ResultSet resultSet = statement.executeQuery(String.format(SHOW_CREATE_SQL, tableName))) {
+            if (resultSet.next()) {
+                return resultSet.getString(2);
+            }
+        }
+        throw new ShardingSphereException(String.format("Failed to get ddl sql for table %s", tableName));

Review Comment:
   Please remove String.format here.



##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ddlgenerator/MySqlDDLSQLGenerator.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.data.pipeline.mysql.ddlgenerator;
+
+import org.apache.shardingsphere.data.pipeline.spi.ddlgenerator.DialectDDLSQLGenerator;
+import org.apache.shardingsphere.infra.exception.ShardingSphereException;
+
+import javax.sql.DataSource;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * DDL SQL generator for MySql.
+ */
+public final class MySqlDDLSQLGenerator implements DialectDDLSQLGenerator {
+    
+    private static final String SHOW_CREATE_SQL = "SHOW CREATE TABLE %s";
+    
+    @Override
+    public String generateDDLSQL(final String tableName, final String schemaName, final DataSource dataSource) throws SQLException {
+        try (
+                Statement statement = dataSource.getConnection().createStatement();
+                ResultSet resultSet = statement.executeQuery(String.format(SHOW_CREATE_SQL, tableName))) {
+            if (resultSet.next()) {
+                return resultSet.getString(2);

Review Comment:
   Can we use resultSet.getString(columnName)?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] strongduanmu merged pull request #17334: support get logic ddl sql for mysql

Posted by GitBox <gi...@apache.org>.
strongduanmu merged PR #17334:
URL: https://github.com/apache/shardingsphere/pull/17334


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] tuichenchuxin commented on a diff in pull request #17334: support get logic ddl sql for mysql

Posted by GitBox <gi...@apache.org>.
tuichenchuxin commented on code in PR #17334:
URL: https://github.com/apache/shardingsphere/pull/17334#discussion_r865712141


##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ddlgenerator/MySqlDDLSQLGenerator.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.data.pipeline.mysql.ddlgenerator;
+
+import org.apache.shardingsphere.data.pipeline.spi.ddlgenerator.DialectDDLSQLGenerator;
+import org.apache.shardingsphere.infra.exception.ShardingSphereException;
+
+import javax.sql.DataSource;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * DDL SQL generator for MySql.
+ */
+public final class MySqlDDLSQLGenerator implements DialectDDLSQLGenerator {
+    
+    private static final String SHOW_CREATE_SQL = "SHOW CREATE TABLE %s";
+    
+    @Override
+    public String generateDDLSQL(final String tableName, final String schemaName, final DataSource dataSource) throws SQLException {
+        try (
+                Statement statement = dataSource.getConnection().createStatement();
+                ResultSet resultSet = statement.executeQuery(String.format(SHOW_CREATE_SQL, tableName))) {
+            if (resultSet.next()) {
+                return resultSet.getString(2);

Review Comment:
   Thank you. Done.



##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ddlgenerator/MySqlDDLSQLGenerator.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.data.pipeline.mysql.ddlgenerator;
+
+import org.apache.shardingsphere.data.pipeline.spi.ddlgenerator.DialectDDLSQLGenerator;
+import org.apache.shardingsphere.infra.exception.ShardingSphereException;
+
+import javax.sql.DataSource;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * DDL SQL generator for MySql.
+ */
+public final class MySqlDDLSQLGenerator implements DialectDDLSQLGenerator {
+    
+    private static final String SHOW_CREATE_SQL = "SHOW CREATE TABLE %s";
+    
+    @Override
+    public String generateDDLSQL(final String tableName, final String schemaName, final DataSource dataSource) throws SQLException {
+        try (
+                Statement statement = dataSource.getConnection().createStatement();
+                ResultSet resultSet = statement.executeQuery(String.format(SHOW_CREATE_SQL, tableName))) {
+            if (resultSet.next()) {
+                return resultSet.getString(2);
+            }
+        }
+        throw new ShardingSphereException(String.format("Failed to get ddl sql for table %s", tableName));

Review Comment:
   Thank you. Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org