Use builtin array_remove() function rather than our custom version

Bug #1778955 reported by Mike Rylander
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Evergreen
Fix Released
Low
Unassigned
3.2
Won't Fix
Undecided
Unassigned
3.3
Won't Fix
Undecided
Unassigned
3.4
Won't Fix
Undecided
Unassigned
3.5
Won't Fix
Undecided
Unassigned
3.6
Fix Released
Low
Unassigned

Bug Description

As of Postgres 9.3 there is a built in array_remove() function that is faster than our custom version that uses unnest(). We should use that instead. Branch forthcoming...

Revision history for this message
Mike Rylander (mrylander) wrote :
tags: added: pullrequest
Changed in evergreen:
milestone: 3.2-beta → 3.2-rc
Changed in evergreen:
milestone: 3.2-rc → 3.2.1
Changed in evergreen:
milestone: 3.2.1 → 3.2.2
Changed in evergreen:
milestone: 3.2.2 → 3.2.3
Changed in evergreen:
milestone: 3.2.3 → 3.3-beta1
Changed in evergreen:
milestone: 3.3-beta1 → 3.3-rc
Changed in evergreen:
milestone: 3.3-rc → 3.3.1
Changed in evergreen:
milestone: 3.3.1 → 3.3.2
Revision history for this message
Dan Pearl (dpearl) wrote :

This code is difficult to check by only its behavior (which should be identical to the old behavior), but while doing a desk check, I saw something unusual.

In The code that previously defined the evergreen.array_remove_item_by_value function, the name of the function has been changed to the built-in (perhaps the result of a global replace?). So the code now looks like

CREATE OR REPLACE FUNCTION array_remove(inp ANYARRAY, el ANYELEMENT)
 RETURNS anyarray AS $$
     SELECT ARRAY_AGG(x.e) FROM UNNEST( $1 ) x(e) WHERE x.e <> $2;

I'm not sure what Postgres does when you redefine a built-in, but my guess is that this code
should be removed. It certainly looks out of place.

Changed in evergreen:
milestone: 3.3.2 → 3.3.3
Changed in evergreen:
milestone: 3.3.3 → 3.3.4
Changed in evergreen:
milestone: 3.3.4 → 3.3.5
Changed in evergreen:
milestone: 3.3.5 → 3.4.2
Changed in evergreen:
milestone: 3.4.2 → 3.4.3
Changed in evergreen:
milestone: 3.4.3 → 3.4.4
Changed in evergreen:
milestone: 3.4.4 → 3.3.8
milestone: 3.3.8 → 3.5.1
Revision history for this message
Jane Sandberg (sandbergja) wrote :

Thanks for this branch, Mike, and for catching that issue, Dan. I signed off at user/sandbergja/lp-1778955-use-builtin-array_remove

That branch also includes a commit to remove the issue that Dan found (it's a little odd that we were defining our custom function twice), as well as a little copy pasta that found its way into the upgrade script.

I also opted to uncomment the last line of your upgrade script, Mike, so that upgraded Evergreens aren't left with our custom function, in the hopes that removing it might reduce some confusion down the line.

It would be great to get this merged sooner rather than later, so nobody starts building new code off the old versions of these functions!

Changed in evergreen:
milestone: 3.5.1 → 3.5.2
Changed in evergreen:
milestone: 3.5.2 → 3.6.1
tags: added: deprecation
tags: added: cleanup performance
Changed in evergreen:
milestone: 3.6.1 → 3.6.2
Changed in evergreen:
milestone: 3.6.2 → 3.6.3
Revision history for this message
Rogan Hamby (rogan-hamby) wrote :

I thought I had tested and signed off on this so I will do so today (assuming testing goes well).

Changed in evergreen:
assignee: nobody → Rogan Hamby (rogan-hamby)
Revision history for this message
Rogan Hamby (rogan-hamby) wrote :

sign off pushed to user/rogan/lp1778955_use_native_array_remove

Changed in evergreen:
assignee: Rogan Hamby (rogan-hamby) → nobody
tags: added: signedup
tags: added: signedoff
removed: signedup
Changed in evergreen:
milestone: 3.6.3 → 3.6.4
Revision history for this message
Galen Charlton (gmc) wrote :

Pushed down to rel_3_6. Thanks, Mike, Dan, Jane, and Rogan!

Changed in evergreen:
milestone: 3.6.4 → 3.7.1
status: New → Confirmed
importance: Undecided → Low
status: Confirmed → Fix Committed
Changed in evergreen:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.