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

stored function can see half-updated table

    XMLWordPrintable

Details

    Description

      Normally if the table is being updated/deleted and selected from, execution stores rowids
      in a temp table first (used_key_is_modified, multi-update, query_plan.using_io_buffer, whatever).

      But accessing the table-to-be-updated (or deleted) from a stored function bypasses this check:

      create table t1 (i int);
      insert t1 values (1), (1);
      create function summ () returns int return (select sum(i) from t1);
      update t1 set i=summ();
      --echo # both rows should be 2
      select * from t1;
      update t1 set i=1;
      delete from t1 where i+1=summ();
      --echo # should be empty
      select * from t1;
      drop table t1;
      drop function summ;
      

      Attachments

        Activity

          People

            sanja Oleksandr Byelkin
            serg Sergei Golubchik
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.