mirror of
https://github.com/postgres/postgres.git
synced 2025-12-12 02:37:31 +03:00
Further tightening of the array literal parser. Prevent junk
from being accepted after the outer right brace. Per report from Markus Bertheau. Also add regression test cases for this change, and for previous recent array literal parser changes.
This commit is contained in:
@@ -425,3 +425,61 @@ select 'foo' ilike all (array['F%', '%O']); -- t
|
||||
t
|
||||
(1 row)
|
||||
|
||||
--
|
||||
-- General array parser tests
|
||||
--
|
||||
-- none of the following should be accepted
|
||||
select '{{1,{2}},{2,3}}'::text[];
|
||||
ERROR: malformed array literal: "{{1,{2}},{2,3}}"
|
||||
select '{{},{}}'::text[];
|
||||
ERROR: malformed array literal: "{{},{}}"
|
||||
select '{{1,2},\\{2,3}}'::text[];
|
||||
ERROR: malformed array literal: "{{1,2},\{2,3}}"
|
||||
select '{{"1 2" x},{3}}'::text[];
|
||||
ERROR: malformed array literal: "{{"1 2" x},{3}}"
|
||||
select '{}}'::text[];
|
||||
ERROR: malformed array literal: "{}}"
|
||||
select '{ }}'::text[];
|
||||
ERROR: malformed array literal: "{ }}"
|
||||
-- none of the above should be accepted
|
||||
-- all of the following should be accepted
|
||||
select '{}'::text[];
|
||||
text
|
||||
------
|
||||
{}
|
||||
(1 row)
|
||||
|
||||
select '{{{1,2,3,4},{2,3,4,5}},{{3,4,5,6},{4,5,6,7}}}'::text[];
|
||||
text
|
||||
-----------------------------------------------
|
||||
{{{1,2,3,4},{2,3,4,5}},{{3,4,5,6},{4,5,6,7}}}
|
||||
(1 row)
|
||||
|
||||
select '{0 second ,0 second}'::interval[];
|
||||
interval
|
||||
---------------
|
||||
{"@ 0","@ 0"}
|
||||
(1 row)
|
||||
|
||||
select '{ { "," } , { 3 } }'::text[];
|
||||
text
|
||||
-------------
|
||||
{{","},{3}}
|
||||
(1 row)
|
||||
|
||||
select ' { { " 0 second " , 0 second } }'::text[];
|
||||
text
|
||||
-------------------------------
|
||||
{{" 0 second ","0 second"}}
|
||||
(1 row)
|
||||
|
||||
select '{
|
||||
0 second,
|
||||
@ 1 hour @ 42 minutes @ 20 seconds
|
||||
}'::interval[];
|
||||
interval
|
||||
------------------------------------
|
||||
{"@ 0","@ 1 hour 42 mins 20 secs"}
|
||||
(1 row)
|
||||
|
||||
-- all of the above should be accepted
|
||||
|
||||
@@ -192,3 +192,28 @@ select 'foo' not like any (array['%a', '%b']); -- t
|
||||
select 'foo' not like all (array['%a', '%o']); -- f
|
||||
select 'foo' ilike any (array['%A', '%O']); -- t
|
||||
select 'foo' ilike all (array['F%', '%O']); -- t
|
||||
|
||||
--
|
||||
-- General array parser tests
|
||||
--
|
||||
|
||||
-- none of the following should be accepted
|
||||
select '{{1,{2}},{2,3}}'::text[];
|
||||
select '{{},{}}'::text[];
|
||||
select '{{1,2},\\{2,3}}'::text[];
|
||||
select '{{"1 2" x},{3}}'::text[];
|
||||
select '{}}'::text[];
|
||||
select '{ }}'::text[];
|
||||
-- none of the above should be accepted
|
||||
|
||||
-- all of the following should be accepted
|
||||
select '{}'::text[];
|
||||
select '{{{1,2,3,4},{2,3,4,5}},{{3,4,5,6},{4,5,6,7}}}'::text[];
|
||||
select '{0 second ,0 second}'::interval[];
|
||||
select '{ { "," } , { 3 } }'::text[];
|
||||
select ' { { " 0 second " , 0 second } }'::text[];
|
||||
select '{
|
||||
0 second,
|
||||
@ 1 hour @ 42 minutes @ 20 seconds
|
||||
}'::interval[];
|
||||
-- all of the above should be accepted
|
||||
|
||||
Reference in New Issue
Block a user