sandynz commented on a change in pull request #12749:
URL: https://github.com/apache/shardingsphere/pull/12749#discussion_r716560919



##########
File path: 
shardingsphere-scaling/shardingsphere-scaling-dialect/shardingsphere-scaling-opengauss/src/main/java/org/apache/shardingsphere/scaling/opengauss/component/OpenGaussWalDumper.java
##########
@@ -123,6 +131,21 @@ private void dump() {
         }
     }
 
+    private void updateRecordOldValue(final Record record) {
+        if (!(record instanceof DataRecord)) {
+            return;
+        }
+        DataRecord dataRecord = (DataRecord) record;
+        if (!ScalingConstant.UPDATE.equals(dataRecord.getType())) {
+            return;
+        }
+        for (Column col: dataRecord.getColumns()) {
+            if (col.isPrimaryKey() && col.isUpdated()) {
+                col.setOldValue(col.getValue());
+            }

Review comment:
       Seems PostgreSQL and openGauss could not get `beforeRows` from 
`UpdateRowsEvent`, not like MySQL binlog. And update event include all columns.
   ```
   scaling1=# update t_order_0 set status='ok1' where order_id=1;
   UPDATE 1
   scaling1=# SELECT * FROM pg_logical_slot_get_changes('regression_slot', 
NULL, NULL);
       lsn    | xid |                                                  data
   
-----------+-----+--------------------------------------------------------------------------------------------------------
    0/17B18A8 | 599 | BEGIN 599
    0/17B18A8 | 599 | table public.t_order_0: UPDATE: order_id[integer]:1 
user_id[integer]:2 status[character varying]:'ok1'
    0/17B1CB8 | 599 | COMMIT 599
   (3 rows)
   ```
   
   We'll make `Column.oldValue` not final for now.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to