tkhurana commented on code in PR #1967:
URL: https://github.com/apache/phoenix/pull/1967#discussion_r1746149265


##########
phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java:
##########
@@ -2376,17 +2394,42 @@ public ResultSet executeQuery(String sql) throws 
SQLException {
 
     @Override
     public int executeUpdate(String sql) throws SQLException {
+        CompilableStatement stmt = preExecuteUpdate(sql);
+        int updateCount = executeMutation(stmt, createAuditQueryLogger(stmt, 
sql));
+        flushIfNecessary();
+        return updateCount;
+    }
+
+    /**
+     * Executes the given SQL statement similar to JDBC API executeUpdate() 
but also returns the
+     * updated or non-updated row as Result object back to the client. This 
must be used with
+     * auto-commit Connection. This makes the operation atomic.
+     * If the row is successfully updated, return the updated row, otherwise 
if the row
+     * cannot be updated, return non-updated row.
+     *
+     * @param sql The SQL DML statement, UPSERT or DELETE for Phoenix.
+     * @return The pair of int and Tuple, where int represents value 1 for 
successful row
+     * update and 0 for non-successful row update, and Tuple represents the 
state of the row.
+     * @throws SQLException If the statement cannot be executed.
+     */
+    public Pair<Integer, Tuple> executeUpdateReturnRow(String sql) throws 
SQLException {

Review Comment:
   I think we should add an auto-commit check here.



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