From ffef9313c05cf59f7cb77aecd65db06441c04937 Mon Sep 17 00:00:00 2001 From: asfernandes Date: Tue, 5 Jul 2005 15:25:27 +0000 Subject: [PATCH] INTL script --- .../win32/BuildExecutableInstall.bat | 3 + .../win32/FirebirdInstall_20.iss | 1 + doc/README.intl | 87 +---------- src/misc/intl.sql | 140 ++++++++++++++++++ 4 files changed, 146 insertions(+), 85 deletions(-) create mode 100644 src/misc/intl.sql diff --git a/builds/install/arch-specific/win32/BuildExecutableInstall.bat b/builds/install/arch-specific/win32/BuildExecutableInstall.bat index 7969760af4..450049a4cd 100644 --- a/builds/install/arch-specific/win32/BuildExecutableInstall.bat +++ b/builds/install/arch-specific/win32/BuildExecutableInstall.bat @@ -250,6 +250,9 @@ for %%v in ( fbudf.sql fbudf.txt ) do ( mkdir %FBBUILD_OUTPUT%\misc\upgrade\ib_udf 2>nul @copy %ROOT_PATH%\src\misc\upgrade\v2\ib_udf*.* %FBBUILD_OUTPUT%\misc\upgrade\ib_udf\ +::INTL script +@copy %ROOT_PATH%\src\misc\intl.sql %FBBUILD_OUTPUT%\misc\ + @echo Copying other documentation... @copy %ROOT_PATH%\builds\install\arch-specific\win32\installation_readme.txt %FBBUILD_OUTPUT%\doc\installation_readme.txt > nul diff --git a/builds/install/arch-specific/win32/FirebirdInstall_20.iss b/builds/install/arch-specific/win32/FirebirdInstall_20.iss index a4e5d1d344..61ba609b65 100644 --- a/builds/install/arch-specific/win32/FirebirdInstall_20.iss +++ b/builds/install/arch-specific/win32/FirebirdInstall_20.iss @@ -336,6 +336,7 @@ Source: output\UDF\ib_udf.dll; DestDir: {app}\UDF; Components: ServerComponent; Source: output\UDF\fbudf.dll; DestDir: {app}\UDF; Components: ServerComponent; Flags: sharedfile ignoreversion; Source: output\UDF\*.sql; DestDir: {app}\UDF; Components: ServerComponent; Flags: ignoreversion; +Source: output\misc\*.*; DestDir: {app}\misc; Components: ServerComponent; Flags: ignoreversion; Source: output\misc\upgrade\security\*.*; DestDir: {app}\misc\upgrade\security; Components: ServerComponent; Flags: ignoreversion; Source: output\misc\upgrade\ib_udf\*.*; DestDir: {app}\misc\upgrade\ib_udf; Components: ServerComponent; Flags: ignoreversion; diff --git a/doc/README.intl b/doc/README.intl index b1001e8d12..4d233cc187 100644 --- a/doc/README.intl +++ b/doc/README.intl @@ -168,88 +168,5 @@ Drivers New character sets and collations are implemented through dynamic libraries and installed in the server with a manifest file in intl subdirectory. For a example see fbintl.conf. Not all implemented character sets and collations need to be listed in the manifest file. Only those listed are available and duplications are not loaded. -After installed in the server, they should be registered in the database's system tables (rdb$character_sets and rdb$collations). The followings stored procedures do the job: - - set term !; - - create or alter procedure sp_register_character_set - ( - name char(31) character set unicode_fss, - max_bytes_per_character smallint - ) - as - declare variable id smallint; - declare variable temp_id smallint; - begin - name = upper(name); - id = 255; - - for select rdb$character_set_id - from rdb$character_sets - order by rdb$character_set_id desc - into temp_id do - begin - if (temp_id = id) then - id = id - 1; - else - break; - end - - insert into rdb$character_sets - (rdb$character_set_name, rdb$character_set_id, rdb$system_flag, rdb$bytes_per_character) - values (:name, :id, 0, :max_bytes_per_character); - - insert into rdb$collations - (rdb$collation_name, rdb$collation_id, rdb$character_set_id, rdb$system_flag) - values (:name, 0, :id, 0); - end! - - create or alter procedure sp_register_collation - ( - character_set char(31) character set unicode_fss, - name char(31) character set unicode_fss, - base_name char(31) character set unicode_fss = null, - attributes smallint = null, - specific_attributes blob sub_type text character set unicode_fss = null - ) - as - declare variable id smallint; - declare variable temp_id smallint; - declare variable charset_id smallint; - begin - character_set = upper(character_set); - name = upper(name); - base_name = coalesce(upper(base_name), name); - id = 126; - - select rdb$character_set_id - from rdb$character_sets - where rdb$character_set_name = :character_set into charset_id; - - for select rdb$collation_id - from rdb$collations - where rdb$character_set_id = :charset_id - order by rdb$collation_id desc - into temp_id do - begin - if (temp_id = id) then - id = id - 1; - else - break; - end - - insert into rdb$collations - (rdb$collation_name, rdb$collation_id, rdb$character_set_id, rdb$system_flag, - rdb$base_collation_name, rdb$collation_attributes, rdb$specific_attributes) - values (:name, :id, :charset_id, 0, :base_name, :attributes, :specific_attributes); - end! - - set term ;! - commit; - -Usage example: - execute procedure sp_register_character_set ('CHARSET_NAME', 1); - commit; - - execute procedure sp_register_collation ('ISO8859_1', 'COLLATION_NAME'); - commit; +After installed in the server, they should be registered in the database's system tables (rdb$character_sets and rdb$collations). +One script file with stored procedures to register/unregister is provided in misc/intl.sql. diff --git a/src/misc/intl.sql b/src/misc/intl.sql new file mode 100644 index 0000000000..0cec4f162d --- /dev/null +++ b/src/misc/intl.sql @@ -0,0 +1,140 @@ +/*** + * + * Usage example + * ------------- + * + * input 'intl.sql'; + * + * execute procedure sp_register_character_set ('CHARSET_NAME', 1); + * execute procedure sp_register_collation ('CHARSET_NAME', 'COLLATION_NAME'); + * commit; + * + * execute procedure sp_unregister_collation ('CHARSET_NAME', 'COLLATION_NAME'); + * execute procedure sp_unregister_character_set ('CHARSET_NAME'); + * commit; + * + */ + + +set term !; + + +create or alter procedure sp_register_character_set +( + name char(31) character set unicode_fss, + max_bytes_per_character smallint +) +as + declare variable id smallint; + declare variable temp_id smallint; +begin + name = upper(name); + id = 255; + + for select rdb$character_set_id + from rdb$character_sets + order by rdb$character_set_id desc + into temp_id do + begin + if (temp_id = id) then + id = id - 1; + else + break; + end + + insert into rdb$character_sets + (rdb$character_set_name, rdb$character_set_id, rdb$system_flag, rdb$bytes_per_character) + values (:name, :id, 0, :max_bytes_per_character); + + insert into rdb$collations + (rdb$collation_name, rdb$collation_id, rdb$character_set_id, rdb$system_flag) + values (:name, 0, :id, 0); +end! + + +create or alter procedure sp_unregister_character_set +( + name char(31) character set unicode_fss +) +as + declare variable id smallint; +begin + name = upper(name); + + select rdb$character_set_id + from rdb$character_sets + where rdb$character_set_name = :name + into :id; + + delete from rdb$collations + where rdb$character_set_id = :id; + + delete from rdb$character_sets + where rdb$character_set_id = :id; +end! + + +create or alter procedure sp_register_collation +( + character_set char(31) character set unicode_fss, + name char(31) character set unicode_fss, + base_name char(31) character set unicode_fss = null, + attributes smallint = null, + specific_attributes blob sub_type text character set unicode_fss = null +) +as + declare variable id smallint; + declare variable temp_id smallint; + declare variable charset_id smallint; +begin + character_set = upper(character_set); + name = upper(name); + base_name = coalesce(upper(base_name), name); + id = 126; + + select rdb$character_set_id + from rdb$character_sets + where rdb$character_set_name = :character_set into charset_id; + + for select rdb$collation_id + from rdb$collations + where rdb$character_set_id = :charset_id + order by rdb$collation_id desc + into temp_id do + begin + if (temp_id = id) then + id = id - 1; + else + break; + end + + insert into rdb$collations + (rdb$collation_name, rdb$collation_id, rdb$character_set_id, rdb$system_flag, + rdb$base_collation_name, rdb$collation_attributes, rdb$specific_attributes) + values (:name, :id, :charset_id, 0, :base_name, :attributes, :specific_attributes); +end! + + +create or alter procedure sp_unregister_collation +( + character_set char(31) character set unicode_fss, + name char(31) character set unicode_fss +) +as + declare variable id smallint; +begin + character_set = upper(character_set); + name = upper(name); + + select rdb$character_set_id + from rdb$character_sets + where rdb$character_set_name = :character_set + into :id; + + delete from rdb$collations + where rdb$character_set_id = :id and rdb$collation_name = :name; +end! + + +set term ;! +commit;