Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-7411

Atomic Delete: PhoenixStatement API to return row if single row is atomically deleted

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 5.3.0
    • None
    • None

    Description

      PHOENIX-7398 introduces new PhoenixStatement API to return row for Atomic/Conditional Upserts. Phoenix already supports Upserts as Atomic operation by using ON DUPLICATE KEY clause. However, Deletes are not supported as atomic and single Delete query can also delete multiple rows based on the WHERE clause used.

      HBase does not provide API to return row state for atomic updates with Put and Delete mutations. HBase API checkAndMutate() also supports returning Result for Append and Increment mutations only, not for Put and Delete mutations.

      The purpose of this Jira is to introduce support for atomic delete of single row that can return the row only if it existed before executing the Delete mutation. If the row is already deleted, the API support is not expected to return any row. For single row delete to be atomic, IndexRegionObserver needs to take row lock for to be deleted row and also scan the row, similar to Atomic Put mutation(s).

       

      PhoenixStatement API signature is same as of PHOENIX-7398:

      /**
       * 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 {

      Attachments

        Issue Links

          Activity

            People

              vjasani Viraj Jasani
              vjasani Viraj Jasani
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: