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

feature request: Needed SQL statement which converted a delimited string into a table

    Details

    • Type: Task
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Hi!

      Sorry I couldn't select here issue type 'New Feature'.

      Here a lot of useless string functions are not clear even in some cases it is necessary for example MAKE_SET, SPACE or EXPORT_SET, but none of which are allowed to make a delimited string table.

      SELECT * FROM seq_1_to_10
      WHERE FIND_IN_SET (seq, '5,6,10')
      

      makes the identity thing as

      SELECT * FROM seq_1_to_10
      WHERE seq IN (1,6,10)
      

      the same can be obtained as

      SELECT * FROM seq_1_to_10
      WHERE seq IN (SELECT 1 UNION ALL SELECT 6 UNION ALL SELECT 10)
      

      If the SQL statement would be that converted a delimited string into a table as I show below would be better

      SELECT * FROM seq_1_to_10
      WHERE seq IN TABLE_STR ('5; 6; 10' ';')
      

      could provide a virtual table from any line

      SELECT * FROM TABLE_STR ('Aaa; zzz; xxx; bbb', ';') AS t1
      
      seq
      --------------
      Aaa
      zzz
      xxx
      bbb
      

      and continue to use it in a cursor, etc.

      SELECT
          SUBSTRING_INDEX (seq, '=', 1) as key
          SUBSTRING_INDEX (seq, '=', - 1) as value
      FROM TABLE_STR ('key1 = value1; key2 = value2; key3 = value3; key4 =', ';') AS t1
      
      key value
      ------ --------
      key1 value1
      key2 value2
      key3 value3
      key4
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              mikhail Mikhail Gavrilov added a comment -

              Also it would be more useful than COLUMN_LIST

              SELECT COLUMN_LIST(@test);
              `INN`,`check`,`resCntr`,`citizens`,`birthdate`,`check_grp`,`firstname`,`birthplace`,`id_profile`,`middlename`,`secondname`,`id_education`,`old_firstname`,`id_army_status`,`id_family_type`,`old_middlename`,`old_secondname`,`reason_fio_chg`,`id_social_state`

              because get list of columns in table form which can be easily joined or converted to string with delimiter.

              Show
              mikhail Mikhail Gavrilov added a comment - Also it would be more useful than COLUMN_LIST SELECT COLUMN_LIST(@test); `INN`,`check`,`resCntr`,`citizens`,`birthdate`,`check_grp`,`firstname`,`birthplace`,`id_profile`,`middlename`,`secondname`,`id_education`,`old_firstname`,`id_army_status`,`id_family_type`,`old_middlename`,`old_secondname`,`reason_fio_chg`,`id_social_state` because get list of columns in table form which can be easily joined or converted to string with delimiter.
              Hide
              serg Sergei Golubchik added a comment -

              This requires MariaDB to support functions that can return a table. We don't support it now, it's MDEV-5199 which is not done yet. I'm marking this task as "blocked by" MDEV-5199 — when we implement table functions, we can implement this your request easily.

              Show
              serg Sergei Golubchik added a comment - This requires MariaDB to support functions that can return a table. We don't support it now, it's MDEV-5199 which is not done yet. I'm marking this task as "blocked by" MDEV-5199 — when we implement table functions, we can implement this your request easily.

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  mikhail Mikhail Gavrilov
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated: