-
-
Notifications
You must be signed in to change notification settings - Fork 239
New 'UNLIST' function #8418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dyemanov
merged 10 commits into
FirebirdSQL:master
from
ChudaykinAlex:master_unlist_new_function
Mar 24, 2025
Merged
New 'UNLIST' function #8418
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0167f8f
Implementation of the new internal function UNLIST
ChudaykinAlex 0653686
Added raedme file
ChudaykinAlex c7c6429
Fix typo
ChudaykinAlex be29efd
Correction of comments from the review. Added initialization of input…
ChudaykinAlex dae3606
Improved names, added error output when blr code is incorrect
ChudaykinAlex 4e4420c
Conversion to string_view
ChudaykinAlex c4928d5
Fix windows build
ChudaykinAlex f0a8d10
Changed processing of BLOB as input parameter.
ChudaykinAlex b55d5b2
Merge branch 'master' into master_unlist_new_function
ChudaykinAlex 42bbb27
Corrected remarks about variables belonging to the base class. correc…
ChudaykinAlex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
SQL Language Extension: UNLIST | ||
|
||
Function: | ||
The function parses the input string using the specified delimiter (comma "," is implied by default) and returns the identified substrings as discrete records containing a single field. Additionally, the desired type of the returned field can be specified. If the specified data type conversion is impossible, an error is raised at runtime. | ||
|
||
Author: | ||
Chudaykin Alex <[email protected]> | ||
|
||
Format | ||
<table value function> ::= | ||
UNLIST ( <input> [, <separator>] [, <data type conversion>] ) [AS] <correlation name> [ ( <derived column name> ) ] | ||
|
||
<input> ::= <value> | ||
|
||
<separator> ::= <value> | ||
|
||
<data type conversion> ::= RETURNING <data type> | ||
|
||
Syntax Rules: | ||
|
||
1) <input>: any value expression that returns a string/blob of characters (or may be converted to a string), including string literals, table columns, constants, variables, expressions, etc. This parameter is mandatory. | ||
2) <separator>: optional value expression that returns a string which is used as a delimiter (i.e. it separates one value from another inside the input string). It may also be a BLOB TEXT value, limited to 32KB. If an empty string is specified, the output will be just one record containing the input string. If omitted, the comma character is used as a delimiter. | ||
2) <data type>: target data type to convert the output values into. Alternatively, a domain can be specified as the returned type. If omitted, VARCHAR(32) is implied. Feel free to suggest any better alternative default. | ||
3) <correlation name>: alias of the record set returned by the UNLIST function. It is a mandatory parameter (per SQL standard). | ||
4) <derived column name>: optional alias of the column returned by the UNLIST function. If omitted, UNLIST is used as an alias. | ||
|
||
Example: | ||
A) | ||
SELECT * FROM UNLIST('1,2,3,4,5') AS U; | ||
|
||
B) | ||
SELECT * FROM UNLIST('100:200:300:400:500', ':' RETURNING INT) AS U; | ||
|
||
C) | ||
SELECT U.* FROM UNLIST(‘text1, text2, text3’) AS U; | ||
|
||
D) | ||
SELECT C0 FROM UNLIST(‘text1, text2, text3’) AS U(C0); | ||
|
||
E) | ||
SELECT U.C0 FROM UNLIST(‘text1, text2, text3’) AS U(C0); | ||
|
||
F) | ||
SET TERM ^ ; | ||
RECREATE PROCEDURE TEST_PROC RETURNS (PROC_RETURN_INT INT) | ||
AS | ||
DECLARE VARIABLE text VARCHAR(11); | ||
BEGIN | ||
text = '123:123:123'; | ||
FOR SELECT * FROM UNLIST( :text, ':' RETURNING INT) AS A INTO :PROC_RETURN_INT DO | ||
SUSPEND; | ||
END^ | ||
SET TERM ; ^ | ||
SELECT * FROM TEST_PROC; | ||
|
||
G) | ||
CREATE DOMAIN D1 AS INT; | ||
SELECT TEST_DOMAIN FROM UNLIST('1,2,3,4' RETURNING D1) AS A(TEST_DOMAIN); | ||
|
||
CREATE TABLE TABLE_TEST (COL1 INT); | ||
SELECT TEST_TYPE_OF FROM UNLIST('1,2,3,4' RETURNING TYPE OF COLUMN TABLE_TEST.COL1) AS A(TEST_TYPE_OF); | ||
H) | ||
CREATE VIEW TEST_VIEW AS SELECT * FROM UNLIST('1,2,3,4') AS A(B); | ||
SELECT B FROM TEST_VIEW; | ||
|
||
Unacceptable behavior: | ||
SELECT UNLIST FROM UNLIST('UNLIST,A,S,A') AS A; | ||
|
||
|
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
117 shift/reduce conflicts, 22 reduce/reduce conflicts. | ||
118 shift/reduce conflicts, 22 reduce/reduce conflicts. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it
TYPE OF [COLUMN]
allowed?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check. Granted. Added example in readme