Bug #4054 ELT trims subelements to an unspecified length of characters
Submitted: 8 Jun 2004 10:04 Modified: 11 Jun 2004 16:26
Reporter: Mr. Venom Email Updates:
Status: Can't repeat Impact on me:
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.15 OS:Linux (Linux/FreeBSD)
Assigned to: CPU Architecture:Any

[8 Jun 2004 10:04] Mr. Venom
When selecting
ELT(FIELD(`type`,'CSC','INT','LMT','LTK'),'StarptautiskÃĒs','Meridian','LMT','Lattelekom') as `Type`
the first (Starp...) element is getting trimmed from right to the length of 'Lattelekom' (e.g. Starpauti). And only if I pad the last item with spaces (e.g. 'Lattelekom      ') the string is displayed in full. This is not an issue of the elements encoding, as I figured, but of the "medium element's width" or something like that, because if I move the 'Starptautiskās' element to the end of ELT, it is being displayed normally, but again if 'LMT' is moved to the end, everything doesn't get trimmed to 3 characters. I didn't see anything like this documented, the manuals show ELT and FIELD "longest element" to be in the middle.

So why is that?

# Server: 4.0.15
# Client: 3.23.39
# Protocol-Version: 10

How to repeat:
SELECT ELT(FIELD(`type`,'CSC','INT','LMT','LTK'),'StarptautiskÃĒs','Meridian','LMT','Lattelekom') as `Type`


SELECT ELT(FIELD(`type`,'CSC','INT','LTK','LMT'),'Starptautiskās','Meridian','Lattelekom','LMT')
as `Type`

and compare with

SELECT ELT(FIELD(`type`,'INT','LMT','LTK','CSC'),'Meridian','LMT','Lattelekom','Starptautiskās') as `Type`

where the column `type` contains any of the FIELD subelements

Suggested fix:
Move the "longest" element to the end of ELT statement (huh?)
[11 Jun 2004 16:26] Alexander Keremidarski
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at

If you can provide more information, feel free to add it
to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.

Additional info:

Can't repeat it with any of current releases.


All return correct result.

By the way test case is too complex. I don't see how FIELD() part is relevant.