Bug #2646 rpad not truncating literals to given len
Submitted: 5 Feb 2004 0:13 Modified: 5 Feb 2004 10:53
Reporter: guru karur Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.15 OS:Windows (Windows 2000)
Assigned to: Dean Ellis CPU Architecture:Any

[5 Feb 2004 0:13] guru karur
Description:
rpad function is replacing characters with given 'padstr value' instead of truncating input string to given length argument. in the following example: it would be replace 'ate' with char(32)  

select rpad('truncate', 5, char(32) ) 

returns string of size 9 with trailing blank space. the documentation says this has been fixed in 3.23. 

thanks
guru

How to repeat:

Suggested fix:
[5 Feb 2004 10:53] Dean Ellis
I cannot repeat this with 4.0.17 or 4.0.18.  Can you try it with a current release?
[5 Feb 2004 17:53] guru karur
we are currently using 4.0.15 version. i'll verify when we upgrade to the latest stable version. thanks Dean
[2 Mar 2004 20:36] developer developer
sample comment by afzal for testing purpose.....
[2 Mar 2004 20:37] developer developer
sample comment by afzal for testing purpose.....
[29 Apr 2005 8:20] Chandrasekhar Telkapalli
Same problem I am also facing I wanted to populate padded data in list box 
Like this
My Query is like this
MYSQL="select RecordID,rpad(rtrim(category)," & max_length_category & ",char(32,1)) as cat,rpad(rtrim(subcategory)," & max_length_subcategory & ",'#')as subcat,question from faqdetails order by Category asc,subcategory asc"
And I wanted to populate in Lis box like this
I am going to open record set in ASP Like RS
<select id="RecordID" name="RecordID" size="10" style="width: '100%'">
<%while not rs.eof%>
<option><%=rs("category")&rs("subcategory") & rs("title")</option>
<%rs.movenext
wend
%>
In which it is padding me ok from the database
All the three data fields are varchar Type ie:category& sub category & Title
 But in HTML It is looking like uneven 
Can you find out a solution for this.