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/01/14 08:03:48 UTC

[GitHub] [shardingsphere] ReyYang opened a new pull request #14767: For #14733:Fix PostgreSQL 14 money data type are abnormal during full migration

ReyYang opened a new pull request #14767:
URL: https://github.com/apache/shardingsphere/pull/14767


   Fixes #14733.
   
   Changes proposed in this pull request:
   - Add PostgreSQL money type judgment for AbstractInventoryDumper
   -
   -
   


-- 
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] sandynz commented on a change in pull request #14767: For #14733:Fix PostgreSQL 14 money data type are abnormal during full migration

Posted by GitBox <gi...@apache.org>.
sandynz commented on a change in pull request #14767:
URL: https://github.com/apache/shardingsphere/pull/14767#discussion_r784647303



##########
File path: shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLInventoryDumper.java
##########
@@ -41,4 +43,16 @@ protected PreparedStatement createPreparedStatement(final Connection connection,
         result.setFetchSize(1);
         return result;
     }
+    
+    @Override
+    protected Object readValue(final ResultSet resultSet, final int index) throws SQLException {
+        if (isPgMoneyType(resultSet, index)) {
+            return resultSet.getBigDecimal(index);
+        }

Review comment:
       Return `java.lang.Double` later, and translate to `java.math.BigDecimal` on write into target. Refactor it later.




-- 
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] sandynz merged pull request #14767: For #14733:Fix PostgreSQL 14 money data type are abnormal during full migration

Posted by GitBox <gi...@apache.org>.
sandynz merged pull request #14767:
URL: https://github.com/apache/shardingsphere/pull/14767


   


-- 
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] ReyYang commented on pull request #14767: For #14733:Fix PostgreSQL 14 money data type are abnormal during full migration

Posted by GitBox <gi...@apache.org>.
ReyYang commented on pull request #14767:
URL: https://github.com/apache/shardingsphere/pull/14767#issuecomment-1012907871


   During debugging, it was found that the Java Type returned by PgResultSet is java.lang.Double, and the type needed to insert into PostgreSQL is java.math.BigDecimal
   
   - test case
   ```groovy
   import java.sql.Connection
   import java.sql.Driver
   import java.sql.PreparedStatement
   
   Class clazz = Class.forName("org.postgresql.Driver");
   Driver driver = clazz.newInstance() as Driver;
   
   String url = "jdbc:postgresql://127.0.0.1:5432/demo_ds_0";
   Properties info = new Properties();
   info.setProperty("user", "postgres");
   info.setProperty("password", "123456");
   
   Connection conn = driver.connect(url, info);
   
   PreparedStatement ps = conn.prepareStatement("insert into table_mix_test (id, shard_id, t_money) values (?, ?, ?);")
   
   ps.setObject(1, 1);
   ps.setObject(2, 1);
   ps.setObject(4, new BigDecimal(100.4));
   
   def execute = ps.execute()
   
   println execute
   ```


-- 
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] sandynz commented on a change in pull request #14767: For #14733:Fix PostgreSQL 14 money data type are abnormal during full migration

Posted by GitBox <gi...@apache.org>.
sandynz commented on a change in pull request #14767:
URL: https://github.com/apache/shardingsphere/pull/14767#discussion_r784636425



##########
File path: shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/AbstractInventoryDumper.java
##########
@@ -183,9 +186,20 @@ private long getPositionEndValue(final IngestPosition<?> position) {
     protected abstract PreparedStatement createPreparedStatement(Connection connection, String sql) throws SQLException;
     
     protected Object readValue(final ResultSet resultSet, final int index) throws SQLException {
+        if (isPgMoneyType(resultSet, index)) {
+            return resultSet.getBigDecimal(index);
+        }

Review comment:
       It's better to put this snippet into `PostgreSQLInventoryDumper`




-- 
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] ReyYang commented on pull request #14767: For #14733:Fix PostgreSQL 14 money data type are abnormal during full migration

Posted by GitBox <gi...@apache.org>.
ReyYang commented on pull request #14767:
URL: https://github.com/apache/shardingsphere/pull/14767#issuecomment-1012895825


   The bit type has not been processed for the time being


-- 
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