Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
97c4d9b7
Commit
97c4d9b7
authored
May 31, 2013
by
Noah Misch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't emit non-canonical empty arrays in array_remove().
Dean Rasheed
parent
01497e73
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
0 deletions
+15
-0
src/backend/utils/adt/arrayfuncs.c
src/backend/utils/adt/arrayfuncs.c
+8
-0
src/test/regress/expected/arrays.out
src/test/regress/expected/arrays.out
+6
-0
src/test/regress/sql/arrays.sql
src/test/regress/sql/arrays.sql
+1
-0
No files found.
src/backend/utils/adt/arrayfuncs.c
View file @
97c4d9b7
...
...
@@ -5398,6 +5398,14 @@ array_replace_internal(ArrayType *array,
return
array
;
}
/* If all elements were removed return an empty array */
if
(
nresult
==
0
)
{
pfree
(
values
);
pfree
(
nulls
);
return
construct_empty_array
(
element_type
);
}
/* Allocate and initialize the result array */
if
(
hasnulls
)
{
...
...
src/test/regress/expected/arrays.out
View file @
97c4d9b7
...
...
@@ -1577,6 +1577,12 @@ select array_remove(array['A','CC','D','C','RR'], 'RR');
select array_remove('{{1,2,2},{1,4,3}}', 2); -- not allowed
ERROR: removing elements from multidimensional arrays is not supported
select array_remove(array['X','X','X'], 'X') = '{}';
?column?
----------
t
(1 row)
select array_replace(array[1,2,5,4],5,3);
array_replace
---------------
...
...
src/test/regress/sql/arrays.sql
View file @
97c4d9b7
...
...
@@ -438,6 +438,7 @@ select array_remove(array[1,2,2,3], 5);
select
array_remove
(
array
[
1
,
NULL
,
NULL
,
3
],
NULL
);
select
array_remove
(
array
[
'A'
,
'CC'
,
'D'
,
'C'
,
'RR'
],
'RR'
);
select
array_remove
(
'{{1,2,2},{1,4,3}}'
,
2
);
-- not allowed
select
array_remove
(
array
[
'X'
,
'X'
,
'X'
],
'X'
)
=
'{}'
;
select
array_replace
(
array
[
1
,
2
,
5
,
4
],
5
,
3
);
select
array_replace
(
array
[
1
,
2
,
5
,
4
],
5
,
NULL
);
select
array_replace
(
array
[
1
,
2
,
NULL
,
4
,
NULL
],
NULL
,
5
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment