8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 20:43:02 +01:00

INTL script

This commit is contained in:
asfernandes 2005-07-05 15:25:27 +00:00
parent eda3fd0577
commit ffef9313c0
4 changed files with 146 additions and 85 deletions

View File

@ -250,6 +250,9 @@ for %%v in ( fbudf.sql fbudf.txt ) do (
mkdir %FBBUILD_OUTPUT%\misc\upgrade\ib_udf 2>nul mkdir %FBBUILD_OUTPUT%\misc\upgrade\ib_udf 2>nul
@copy %ROOT_PATH%\src\misc\upgrade\v2\ib_udf*.* %FBBUILD_OUTPUT%\misc\upgrade\ib_udf\ @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... @echo Copying other documentation...
@copy %ROOT_PATH%\builds\install\arch-specific\win32\installation_readme.txt %FBBUILD_OUTPUT%\doc\installation_readme.txt > nul @copy %ROOT_PATH%\builds\install\arch-specific\win32\installation_readme.txt %FBBUILD_OUTPUT%\doc\installation_readme.txt > nul

View File

@ -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\fbudf.dll; DestDir: {app}\UDF; Components: ServerComponent; Flags: sharedfile ignoreversion;
Source: output\UDF\*.sql; DestDir: {app}\UDF; Components: ServerComponent; Flags: 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\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; Source: output\misc\upgrade\ib_udf\*.*; DestDir: {app}\misc\upgrade\ib_udf; Components: ServerComponent; Flags: ignoreversion;

View File

@ -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. 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. 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: 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.
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;

140
src/misc/intl.sql Normal file
View File

@ -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;