Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-30737

REPLACE...RETURNING should provide access to the old row data

    XMLWordPrintable

Details

    Description

      Given the schema:

      CREATE TABLE test (
        id INT PRIMARY KEY,
        ordinal VARCHAR(10)
      );
      INSERT INTO test (id, ordinal) VALUES (1, "first");
      INSERT INTO test (id, ordinal) VALUES (2, "second");
      

      The following statement returns the data of the newly inserted row (i.e. "third"):

      REPLACE INTO test (id, ordinal) VALUES(1, "third") RETURNING ordinal;
      

      There should be some way of accessing the old data that was deleted, perhaps using the 'OLD.<col_name>' syntax, as follows:

      REPLACE INTO test (id, ordinal) VALUES(1, "third") RETURNING OLD.ordinal;
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              anichols Ashford Nichols
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.