Fix: #19987: Reopening a function removes charset #20020
+23
−8
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.
Description
Opening and updating an existing function that has a different return CHARSET than the default CHARSET for the table or database. On saving, the CHARSET for the function changes to the DB default. Note: this online happens when the function created also uses COLLATE.
Please describe your pull request.
Took a bit of time to diagnose and replicate but ultimately was only happening when a function was created that had both a CHARSET and COLLATE sets.
So starting off, created 2 functions that had a different return CHARSET than the database default. (so DB was ASCII., Functions Latin1)
On viewing the 2 functions in the UI, the function with no COLLATE was correctly showing the return CHARSET

where as the function with a COLLATE set was not, and the 'charset' from the dropdown as no option was selected..

So in this instance when you saved, it set the CHARSET of the function to the database default.
This was happening due to the $options value used here
returning an array of 2 items - the CHARSET and COLLATE, so the string for item_returnopts_text used in the twig template was in my example was "latin1 latin1_general_ci", and in turned used to compare with charset.getName
{{ routine.item_returnopts_text == charset.getName() ? ' selected' }}So my fix separately works out the charset text and numeric values. I did contemplate doing a hackier fix in the twig template but better to return the actual CHARSET to the view
Fixes #19987 Reopening a function removes charset
Before submitting pull request, please review the following checklist:
Signed-off-byline as described in our DCO. This ensures that the work you're submitting is your own creation.