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

String access operator []

    XMLWordPrintable

Details

    Description

      I propose to introduce a new operators [pos] and [pos:len] to access elements of string types. Where pos - element index, starting from 0, as in c++ stings. Example:

      mysql> CREATE TABLE `test` (
        `id` int(11) NOT NULL AUTO_INCREMENT,
        `data` varchar(100) NOT NULL,
        PRIMARY KEY (`id`)
      ) ENGINE=InnoDB;
       
      mysql> INSERT INTO `test` (`id`,`data`) VALUES(0,'');
      mysql> UPDATE `test` SET `data`[5] = 'xxx';
       
      mysql> SELECT * FROM `test` WHERE `id`=0;
      +-----+----------------------------+
      | sid | data                       |
      +-----+----------------------------+
      |   0 | '     xxx'
      +-----+----------------------------+
       
      mysql> UPDATE `test` SET `data`[3] = 'aaa';
       
      mysql> SELECT * FROM `test` WHERE `id`=0;
      +-----+----------------------------+
      | sid | data                       |
      +-----+----------------------------+
      |   0 | '   aaaxx'
      +-----+----------------------------+
       
      mysql> UPDATE `test` SET `data`[3:1] = 'bbbbbb';
       
      mysql> SELECT * FROM `test` WHERE `id`=0;
      +-----+----------------------------+
      | sid | data                       |
      +-----+----------------------------+
      |   0 | '   baaxx'
      +-----+----------------------------+
       
      mysql> SELECT `data`[4:3] FROM `test` WHERE `id`=0;
      +----------------------------+
      | data                       |
      +----------------------------+
      | 'aax'
      +----------------------------+

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Mikle Mikle
              Votes:
              2 Vote for this issue
              Watchers:
              7 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.