[MDEV-7994] Needed SQL statement which converted a delimited string into a table Created: 2015-04-14  Updated: 2015-10-31

Status: Open
Project: MariaDB Server
Component/s: None
Fix Version/s: None

Type: Task Priority: Major
Reporter: Mikhail Gavrilov Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Blocks
is blocked by MDEV-5199 Table functions (a.k.a UDF returning ... Open
Relates
relates to MDEV-7417 Implement unnest feature Open

 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



 Comments   
Comment by Mikhail Gavrilov [ 2015-04-14 ]

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.

Comment by Sergei Golubchik [ 2015-04-15 ]

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.

Generated at Thu Feb 08 07:23:51 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.