Issue Details (XML | Word | Printable)

Key: CORE-2777
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Adriano dos Santos Fernandes
Reporter: Adriano dos Santos Fernandes
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Firebird Core

Make possible to alter the default database character set without manual update of system table

Created: 30/Nov/09 05:29 AM   Updated: 28/Sep/15 01:47 PM
Component/s: Engine
Affects Version/s: None
Fix Version/s: 3.0 Alpha 1

File Attachments: 1. Zip Archive core-2777.log.zip (1 kB)

Issue Links:
Relate
 


 Description  « Hide
Add ALTER DATABASE ... SET DEFAULT CHARACTER SET ...


 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Pavel Zotov added a comment - 09/Apr/15 08:40 PM
Was it intentionally done that new character set take effect only for NEW attachments ?

Consider the following script (correct values in 'shell del ...' and 'create database' statements to yours):

shell del C:\MIX\firebird\QA\fbt-repo\tmp\c2777.fdb 1>nul 2>&1;
set echo on;
create database 'localhost/3333:C:\MIX\firebird\QA\fbt-repo\tmp\c2777.fdb' default character set dos850;


drop user admin2;
commit;
create user admin2 password '123';
commit;
grant create table to admin2;
commit;

set list on;
set width db_default_cset 15;

create or alter view v_table_field_cset as
select
   rf.rdb$relation_name tab_name
  ,rf.rdb$field_name fld_name
  ,cs.rdb$character_set_name fld_cset
  ,rb.RDB$CHARACTER_SET_NAME db_default_cset
from rdb$relation_fields rf
join rdb$fields ff on rf.rdb$field_source = ff.rdb$field_name
join rdb$character_sets cs on ff.rdb$character_set_id = cs.rdb$character_set_id
cross join rdb$database rb
;
commit;

set term ^;
create or alter procedure sp_create_table(
    a_tab_name varchar(31),
    a_cset_mnemona varchar(15)
) as
    declare v_dbname type of column mon$database.mon$database_name;
    declare v_stt varchar(1024);
    declare v_usr rdb$user = 'admin2';
    declare v_pwd varchar(20) = '123';
begin
    execute statement
        ( 'create table ' || a_tab_name || '( text_' || a_cset_mnemona || ' varchar(10) )' )
    on external (v_dbname)
    as user :v_usr password :v_pwd;

end
^
set term ;^
commit;

-------------------------- main phase --------------------------
set width fld_name 31;
set width fld_cset 31;

create table old_att_init(text_init varchar(10));
commit;

select *
from v_table_field_cset v
where v.tab_name = upper('old_att_init');

------------------------------------------------------------------

alter database set default character set utf8;
commit;

-- Make new table with default charset = UTF8 using the SAME
-- attachment as just used for changing default charset:
create table old_att_utf8(text_utf8 varchar(10));
commit;

select *
from v_table_field_cset v
where v.tab_name = upper('old_att_utf8');

-- Now try to create table with default charset = UTF8 using NEW attachment:
execute procedure sp_create_table('new_att_utf8','utf8');
commit;

select *
from v_table_field_cset v
where v.tab_name = upper('new_att_utf8');

------------------------------------------------------------------

alter database set default character set win1250;
commit;


-- Make new table with default charset = WIN1250 using the SAME
-- attachment as just used for changing default charset:
create table old_att_w1250(text_w1250 varchar(10));
commit;

select *
from v_table_field_cset v
where v.tab_name = upper('old_att_w1250');

-- Now try to create table with default charset = WIN1250 using NEW attachment:
execute procedure sp_create_table('new_att_w1250','w1250');
commit;

select *
from v_table_field_cset v
where v.tab_name = upper('new_att_w1250');

------------------------------------------------------------------


alter database set default character set dos866;
commit;

create table old_att_d866(text_d866 varchar(10));
commit;

-- Make new table with default charset = DOS866 using the SAME
-- attachment as just used for changing default charset:
select *
from v_table_field_cset v
where v.tab_name = upper('old_att_d866');


-- Now try to create table with default charset = dos866 using NEW attachment:
execute procedure sp_create_table('new_att_d866','d866');
commit;

select *
from v_table_field_cset v
where v.tab_name = upper('new_att_d866');

------------------------------------------------------------------
alter database set default character set win1252;
commit;

-- Make new table with default charset = WIN1252 using the SAME
-- attachment as just used for changing default charset:
create table old_att_w1252(text_w1252 varchar(10));
commit;

select *
from v_table_field_cset v
where v.tab_name = upper('old_att_w1252');

-- Now try to create table with default charset = WIN1252 using NEW attachment:
execute procedure sp_create_table('new_att_w1252','w1252');
commit;

select *
from v_table_field_cset v
where v.tab_name = upper('new_att_w1252');
------------------------------------------------------------------

When I run this script on WI-T3.0.0.31780 then result is evidence that new charset will be seen only for NEW attachment (which is done by ES EDS when calling sp_create_table) -- please see it in attached file.

Adriano dos Santos Fernandes added a comment - 09/Apr/15 11:20 PM
It's not expected, please create a proper ticket for it.

And please, in this new ticket, mention also that the character set passed in alter database is not being validated to be an existing one.

Pavel Zotov added a comment - 10/Apr/15 09:42 AM
> create a proper ticket for it

http://tracker.firebirdsql.org/browse/CORE-4744