Bug #11888 SHOW CREATE PROCEDURE/FUNCTION doesn't show non-ascii characters correctly
Submitted: 12 Jul 2005 15:51 Modified: 19 Jul 2005 7:20
Reporter: Per-Erik Martin Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0 OS:Linux (linux)
Assigned to: Assigned Account CPU Architecture:Any

[12 Jul 2005 15:51] Per-Erik Martin
Description:
Different character set settings cause SHOW CREATE PROCEDURE/FUNCTION to display
non-ascii characters incorrectly, sometimes as just a question mark.

Some parts are shown differently, i.e. the name, the CREATE PROCEDURE ..., and the body.
Switching between different charcter sets sometimes cause syntax errors when attempting
to read routines from the database.

Note: This seems to be mostly a problem with latin1, and when switching between character
sets. Just sticking to one character set (preferably utf8) causes no problems.

How to repeat:
This tests some combinations using latin1 and utf8. It's possible that similar discrepancies
can be found using other combinations.

et character set latin1;

drop table if exists räkor;
create table räkor ( typ char(10), antal int );

drop procedure if exists räkna_räkor;
delimiter //;
create procedure räkna_räkor()
begin
  declare alla_räkor int default 0;

  fånig:
  begin
    declare n int;

    select count(*) from räkor where typ = 'stora';
    set alla_räkor = alla_räkor + n;
    select count(*) from räkor where typ = 'små';
    set alla_räkor = alla_räkor + n;
  end fånig;
  select alla_räkor;
end//
delimiter ;//

select 'show latin1-latin1';
show create table räkor;
show create procedure räkna_räkor;

set character set utf8;

select 'show latin1-utf8';
show create table räkor;
show create procedure räkna_räkor;

drop table if exists räkor;
create table räkor ( typ char(10), antal int );

drop procedure if exists räkna_räkor;
delimiter //;
create procedure räkna_räkor()
begin
  declare alla_räkor int default 0;

  fånig:
  begin
    declare n int;

    select count(*) from räkor where typ = 'stora';
    set alla_räkor = alla_räkor + n;
    select count(*) from räkor where typ = 'små';
    set alla_räkor = alla_räkor + n;
  end fånig;
  select alla_räkor;
end//
delimiter ;//

select 'utf8-utf8';
show create table räkor;
show create procedure räkna_räkor;

set character set latin1;

select 'utf8-latin1';
show create table räkor;
show create procedure räkna_räkor;

drop table räkor;
drop procedure räkna_räkor;
[13 Jul 2005 17:52] Jorge del Conde
I was able to reproduce this in 5.0 from bk and Linux !
[14 Jul 2005 10:00] Per-Erik Martin
SP charsets test

Attachment: sp-charsets.sql (application/octet-stream, text), 1.40 KiB.

[14 Jul 2005 10:02] Per-Erik Martin
I see in an email that strange things might happen to non-USASCII characters when cutting and pasting in a web browser, so just to make sure I have attached the test case as a file here too.
[19 Jul 2005 7:20] Alexander Barkov
Duplicate with 3349