Short Firebird Migration Guide To Firebird 4.0
Short Firebird Migration Guide To Firebird 4.0
Short Firebird Migration Guide To Firebird 4.0
Table of Contents
Preface
1. Manual installation of Firebird 4.0 on Windows
1.1. Create SYSDBA
1.1.1. Create SYSDBA with ISQL
1.1.2. Create SYSDBA with GSEC
1.2. Configuration
1.2.1. Server architecture
1.2.2. Authorization with Firebird 2.5 client library (fbclient.dll)
1.2.3. Set connection default timezone
1.2.4. Run several instances of different Firebird versions
1.3. Run Firebird as a Windows service
1.3.1. Using install_service.bat and uninstall_service.bat
1.4. Installing client
1.5. Installing embedded
2. Converting the database to a new format
2.1. SQL incompatibilities list
2.1.1. New reserved words
2.1.2. Column names in PSQL cursors
2.1.3. New data types
2.1.4. Time and date literals
2.2. External functions (UDFs) now considered as deprecated
2.3. Upgrade your database to the new ODS
2.3.1. UDF Warnings
3. Migrating database aliases
4. Migrating user list
4.1. Migrating user list from Firebird 3.0
4.2. Migrating user list from Firebird 2.5
4.2.1. Copying user list to SRP plugin
4.2.2. Transferring user list to Legacy_UserManager plugin
5. Configuring Trusted Authentication
6. Application level incompatibilities
6.1. New data types
6.2. Consistent read in READ COMMITTED transactions
6.3. INSERT … RETURNING requires SELECT privilege
7. Conclusion
Preface
https://ib-aid.com/download/docs/fb4migrationguide.html 1/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
This article is written for those who plan to migrate to Firebird 4.0 from Firebird 2.5 or Firebird 3.0.
Why 2.5?
Many
people still use 2.5, but plan to migrate to 4.0 due to the native replication, so we will cover migration process 2.5→4.0, as
well as 3.0→4.0.
The sponsor of "Short Firebird Migration Guide to 4.0" is IBSurgeon (https://www.ib-aid.com, https://www.ibase.ru):
vendor of HQbird, advanced Firebird distribution,
and technical support, optimization and recovery services provider.
Download the archive with installation of Firebird (also called zipkit) from www.firebirdsql.org.
Please note that there
are archives for 32-bit and 64-bit versions of Firebird available, so choose the one you prefer.
Unpack the zipkit into the folder where you want to have Firebird 4.0 installed, for example, c:\Firebird\4.0.
We recommend creating of SYSDBA in case of the migration from 2.5, to facilitate the migration process.
Note
Depending on the Firebird folder location, these tools can request to start themselves with "Run as
Administrator".
https://ib-aid.com/download/docs/fb4migrationguide.html 2/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
c:\Firebird\4.0>isql
SQL> exit;
c:\Firebird\4.0>
GSEC> quit
c:\Firebird\4.0>
Warning
Tool gsec.exe is deprecated, many security features available through SQL, are not implemented in
gsec.
1.2. Configuration
Before you start Firebird as a service, it is necessary to choose the server architecture (also called server mode):
SuperServer, SuperClassic or Classic.
Uncomment it (remove symbol #) and set one of the following: Super, SuperClassic или Classic.
ServerMode = Classic
https://ib-aid.com/download/docs/fb4migrationguide.html 3/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
In order to enable LegacyAuth (and allow old firebird client libraries to connect to Firebird 4.0), it is necessary to change
the following parameters in firebird.conf: AuthServer, UserManager и WireCrypt.
Example 3. Enable legacy authorization, to allow old Firebird client libraries to connect to Firebird 4.0
WireCrypt = Enabled
Important!
After adding the parameters above, there will be 2 active user managers in Firebird (Srp and
Legacy_UserManager in our example), and the first in the UserManager list will be used as a default
(Srp in our example).
Please note, that users with the same names in the different user managers are different! They can
have different password.
If you do not plan to use secure password authentication (Srp), and plan to use only the legacy
In the example above, we have created user SYSDBA the user manager SRP.
In Legacy_UserManager user SYSDBA already
exists, with the standard password masterkey, which is better to be changed.
Let’s change the standard password for
SYSDBA in Legacy_UserManager with isql.
c:\Firebird\4.0>isql
SQL> ALTER USER SYSDBA SET PASSWORD 'er34gfde' USING PLUGIN Legacy_UserManager;
SQL> exit;
c:\Firebird\4.0>
https://ib-aid.com/download/docs/fb4migrationguide.html 4/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
Even if you don’t plan to use data types with time zone support, it should be borne in mind that expressions
CURRENT_TIMESTAMP and CURRENT_TIME now return data types with time zones.
To facilitate the transition of the
legacy code, it is necessary to enable compatibility mode, which allows transparent conversion of types with time zones to
the types without timezones.
However, this conversion will work incorrectly if the connection default timezone is set
incorrectly.
DefaultTimeZone = Europe/Moscow
RemoteServicePort = 3051
In order to connect from the client application to the Firebird instance with non-standard port, specify port number in
the connection string, for example:
Also it is recommended to alter parameters IpcName и RemotePipeName. If they will remain the same, the second
Firebird instance will log an error in firebird.log. It is not a critical error if you don’t use XNET or WNET protocols.
However, if you wish to use XNET or WNET protocols to connect to the second instance, it will be necessary to change
parameters in firebird.conf , and set them on the client side in DPB (database parameters block).
If you run it without parameters, it will show help about all commands and parameters.
https://ib-aid.com/download/docs/fb4migrationguide.html 5/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
instsvc
Usage:
instsvc i[nstall]
[ -a[uto]* | -d[emand] ]
[ -g[uardian] ]
[ -n[ame] instance ]
[ -i[nteractive] ]
sta[rt] [ -b[oostpriority] ]
[ -n[ame] instance ]
q[uery]
Important
Instsvc tool must be run in the console with administrative privileges.
instsvc install
In this case Firebird will be installed as a service named "Firebird Server – DefaultInstance".
This service by default will
automatically start on operating system boot, under LocalSystem account.
If you want to run several Firebird instances as a service, you must specify their names (different) using -n <name>
option
instsvc start
If Firebird service was installed with non-default name, you must use -n option
instsvc stop
If Firebird service was installed with non-default name, you must use -n option
https://ib-aid.com/download/docs/fb4migrationguide.html 6/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
instsvc remove
If Firebird service was installed with non-default name, you must use -n option
instsvc query
Status : running
Startup : automatic
Run as : LocalSystem
Status : running
Startup : automatic
Run as : LocalSystem
install_service.bat
uninstall_service.bat
If you want to set up name for the Firebird service, specify it as an argument
install_service.bat fb40
uninstall_service.bat fb40
https://ib-aid.com/download/docs/fb4migrationguide.html 7/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
Also, it is welcome to have firebird.msg at the same place where fbclient.dll is installed or copied.
There are lot of
error messages included in fbclient.dll , but at least for Firebird console tools it is good to have`firebird.msg` nearby.
Unlike Firebird 2.5 and 3.0 Firebird 4.0 client library may need ICU files ( icudt63.dll , icuin63.dll , icuuc63.dll и
icudt63l.dat ).
Previous versions required these files only for the server, not client.
Now these files may be needed by
client library, especially if you want to work with datatypes like TIMESTAMP WITH TIME ZONE and TIME WITH TIME ZONE .
ICU is also used by Firebird client for UtilInterface::decodeTimeTz() and UtilInterface::decodeTimestampTz()
functions.
Note
Windows 10 already have appropriate ICU library.
If you require TCP/IP wire compression, you also need zlib1.dll library.
For connection encryption you may need file plugins/chacha.dll if you want to use ChaCha encryption plugin.
As usual, application is able to load fbclient.dll if it have same bitness as application and resides near the application
or in PATH or system folders ( system32 for 64bit and SysWOW64 for 32bit).
Important
Using PATH as a place of the client library may conflict with the other applications, that needs another
version of the client library.
So, if application must work independently of the other applications, client
files must be placed at the application folder, and this folder must not be in PATH .
To install Firebird client library to the Windows system folder use the command
Important
Instclient does not copy any other files than fbclient.dll to the system folder.
intl
fbintl.conf
fbintl.dll
plugins
https://ib-aid.com/download/docs/fb4migrationguide.html 8/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
engine13.dll
firebird.conf
icudt63l.dat
fbclient.dll
ib_util.dll
icudt63.dll
icuin63.dll
icuuc63.dll
msvcp140.dll
vcruntime140.dll
firebird.msg
Also you may copy tools fbsvcmgr.exe , fbtracemgr.exe , gbak.exe , gfix.exe , gstat.exe , isql.exe ,
nbackup.exe
to that folder, if you need them.
Note
When migrating from Firebird 2.5 two moments should be considered:
Several files is needed instead of one fbembed.dll , and you must not rename fbclient.dll .
Use
fbclient.dll name as a library name in your driver or components.
If you want to connect to the one database from the different applications on the same computer,
change firebird.conf file - set parameter ServerMode to SuperClassic to Classic .
(as the
default behavior of Firebird 2.5 embedded). SuperServer mode does not allow to connect to the
database more than one application with the Firebird embedded.
Here are some common problems at the SQL level that you may fix before moving to the new ODS.
Complete list of
incompatibilities you will find in Firebird 3.0 Release Notes (for those who moves from the Firebird 2.5) and Firebird 4.0
Release Notes 4.0, "Compatibility Issues" chapter.
https://ib-aid.com/download/docs/fb4migrationguide.html 9/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
Check your database for the new keywords that are used for the identifiers, column names and variables.
With the dialect
1 these keywords cannot be used in SQL. In dialect 3 - may be used, but must be surrounded by double quotes.
Please read
Firebird 3.0 and 4.0 Release Notes, "Reserved Words and Changes" chapter.
Keywords may be used as identifiers, but this
is not recommended.
returns (n int)
as
begin
open c;
fetch c into n;
close c;
suspend;
end
-Invalid command
INT128
NUMERIC(38, x) и DECIMAL(38, x)
DECFLOAT(16) и DECFLOAT(34)
Last two types does not give problems, because you could not use them before, and they were not returned by
expressions.
https://ib-aid.com/download/docs/fb4migrationguide.html 10/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
CURRENT_TIMESTAMP and CURRENT_TIME now returns TIMESTAMP WITH TIME ZONE и TIME WITH TIME ZONE .
This may
be serious problem.
You may set compatibility mode for the old client libraries and applications, but this will not help for
the code of stored procedures, functions and triggers.
You should use LOCALTIMESTAMP and LOCALTIME instead of
CURRENT_TIMESTAMP and CURRENT_TIME where you do not want to work with the timezone datatypes.
These
expressions were introduced in Firebird 2.5.9 and Firebird 3.0.4 to allow you prepare your databases for the migration to
the Firebird 4.0.
Literals 'NOW', 'TODAY', 'TOMORROW', 'YESTERDAY' with the implicit typecast (prefixed with TIMESTAMP, DATE, TIME)
now rejected.
Value of these literals were evaluated during prepare of DSQL or PSQL, and produced unexpected results.
If you have something like TIMESTAMP 'NOW' in DSQL or PSQL, there will be compatibility issue.
..
..
/* variable 'moment' here will be "frozen" as the time of the last compliation of the procedure or function
*/
..
You should clear out literals like that from your procedures, triggers and functions (for example, change to explicit
CAST('NOW' AS TIMESTAMP) ) before moving to the new ODS.
Also you should check other date and time literals with the explicit date/time.
Previously, such literals allowed non-
standard delimiters. Now these delimiters rejected.
More details about correct date and time literals you may read in
"Firebird 4.0 Language Reference" at the chapter "Date and time literals".
Most of the functions in those libraries were already deprecated in previous Firebird versions and replaced with built-in
analogues.
Safe replacements for a few of the remaining functions are now available, either in a new library of user-
defined routines (UDRs) named
[lib]udf_compat.[dll/so/dylib], or as scripted conversions to PSQL stored functions.
The Firebird 4 distribution contains a script to migrate all (or any) of those UDF declarations. You
can edit and extract
from it to suit, if you wish, but you must keep the respective re-declarations
and conversions intact as scripted.
If you still want to use UDFs, you must change firebird.conf parameter
https://ib-aid.com/download/docs/fb4migrationguide.html 11/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
This example assumes that there is one computer with Firebird 3 and Firebird 4. Firebird 3 is using TCP port 3053, and
Firebird 4 - -3054.
First you should make backup copy of your database using current Firebird version
gbak -b -g -V -user <username> -pas <password> -se <service> <database> <backup_file> -Y <log_file>
gbak -c -v -user <username> -pas <password> -se <service> <backup_file> <database_file> -Y <log_file>
Important
Note that -V and -Y options must be used so that you can see in the log file what went wrong during the
restore process.
https://ib-aid.com/download/docs/fb4migrationguide.html 12/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
It means you have a UDF that is declared in the database but whose library is missing — which, of course, we know is
true.
There is a description above what to do in this case. Mostly this is related to your custom UDFs.
If you used only
ib_udf and fbudf libraries, you may replace them to the built-in functions or their safe UDR counterparts from
udf_compat.dll .
This can be done by the script misc/upgrade/v4.0/udf_replace.sql .
Use the following command
Example 9. Warning
This script does not change anything for the third-party UDF libraries!
https://ib-aid.com/download/docs/fb4migrationguide.html 13/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
set term ^;
EXECUTE BLOCK
AS
---------------------------------------------------
BEGIN
SELECT
PLG$USER_NAME,
PLG$VERIFIER,
PLG$SALT,
PLG$COMMENT,
PLG$FIRST,
PLG$MIDDLE,
PLG$LAST,
PLG$ATTRIBUTES,
PLG$ACTIVE
FROM PLG$SRP
!'
ON EXTERNAL :SRC_SEC_DB
AS USER :SRC_SEC_USER
INTO :PLG$USER_NAME,
:PLG$VERIFIER,
:PLG$SALT,
:PLG$COMMENT,
:PLG$FIRST,
:PLG$MIDDLE,
:PLG$LAST,
:PLG$ATTRIBUTES,
:PLG$ACTIVE
DO
BEGIN
PLG$USER_NAME,
PLG$VERIFIER,
PLG$SALT,
PLG$COMMENT,
PLG$FIRST,
PLG$MIDDLE,
PLG$LAST,
PLG$ATTRIBUTES,
PLG$ACTIVE)
VALUES (
:PLG$USER_NAME,
:PLG$VERIFIER,
https://ib-aid.com/download/docs/fb4migrationguide.html 14/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
:PLG$SALT,
:PLG$COMMENT,
:PLG$FIRST,
:PLG$MIDDLE,
:PLG$LAST,
:PLG$ATTRIBUTES,
:PLG$ACTIVE);
END
SELECT
PLG$USER_NAME,
PLG$GROUP_NAME,
PLG$UID,
PLG$GID,
PLG$PASSWD,
PLG$COMMENT,
PLG$FIRST_NAME,
PLG$MIDDLE_NAME,
PLG$LAST_NAME
FROM PLG$USERS
!'
ON EXTERNAL :SRC_SEC_DB
AS USER :SRC_SEC_USER
INTO :PLG$USER_NAME,
:PLG$GROUP_NAME,
:PLG$UID,
:PLG$GID,
:PLG$PASSWD,
:PLG$COMMENT,
:PLG$FIRST,
:PLG$MIDDLE,
:PLG$LAST
DO
BEGIN
PLG$USER_NAME,
PLG$GROUP_NAME,
PLG$UID,
PLG$GID,
PLG$PASSWD,
PLG$COMMENT,
PLG$FIRST_NAME,
PLG$MIDDLE_NAME,
PLG$LAST_NAME)
VALUES (
:PLG$USER_NAME,
:PLG$GROUP_NAME,
:PLG$UID,
:PLG$GID,
:PLG$PASSWD,
:PLG$COMMENT,
:PLG$FIRST,
:PLG$MIDDLE,
:PLG$LAST);
END
END^
set term ;^
commit;
exit;
https://ib-aid.com/download/docs/fb4migrationguide.html 15/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
Important
Do not forget to change SRC_SEC_DB variable.
Note
SYSDBA was excluded, because it is expected that you already initialized SYSDBA accout during
Firebird 4 installation.
4. Execute this script at Firebird 4.0, connecting to the security.db in embedded mode
Congratulations! Your user list is transferred with all attributes and passwords.
This method needs to run security_database.sql script, that is included to misc/upgrade of your Firebird 3
installation.
This description assumes that you have copy of this script at the same folder with isql.
Note
Firebird 4.0 does not have security_database.sql in its distribution, so you need to download
Firebird 3.0 zip archive.
Do not forget to change masterkey password in the script to your real SYSDBA password.
\fb25_backup\security2.fbk
https://ib-aid.com/download/docs/fb4migrationguide.html 16/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
bdata\4.0\security2db.fdb -v
{host/path}security2db.fdb
security2db.fdb - this is an example name, you can use any name you choose.
4. Script generates new random passwords and show them on the screen.
You need to copy this output and tell users
about their new passwords.
\fb25_backup\security2.fbk
bdata\4.0\security2db.fdb -v
https://ib-aid.com/download/docs/fb4migrationguide.html 17/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
set term ^;
EXECUTE BLOCK
AS
---------------------------------------------------
BEGIN
SELECT
RDB$USER_NAME,
RDB$GROUP_NAME,
RDB$UID,
RDB$GID,
RDB$PASSWD,
RDB$COMMENT,
RDB$FIRST_NAME,
RDB$MIDDLE_NAME,
RDB$LAST_NAME
FROM RDB$USERS
!'
ON EXTERNAL :SRC_SEC_DB
AS USER :SRC_SEC_USER
INTO
:PLG$USER_NAME,
:PLG$GROUP_NAME,
:PLG$UID,
:PLG$GID,
:PLG$PASSWD,
:PLG$COMMENT,
:PLG$FIRST,
:PLG$MIDDLE,
:PLG$LAST
DO
BEGIN
PLG$USER_NAME,
PLG$GROUP_NAME,
PLG$UID,
PLG$GID,
PLG$PASSWD,
PLG$COMMENT,
PLG$FIRST_NAME,
PLG$MIDDLE_NAME,
PLG$LAST_NAME)
VALUES (
:PLG$USER_NAME,
:PLG$GROUP_NAME,
:PLG$UID,
:PLG$GID,
:PLG$PASSWD,
:PLG$COMMENT,
https://ib-aid.com/download/docs/fb4migrationguide.html 18/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
:PLG$FIRST,
:PLG$MIDDLE,
:PLG$LAST);
END
END^
set term ;^
commit;
exit;
Important
Do not forget to change value of the variable SRC_SEC_DB to your security database.
Note
This script excludes SYSDBA, because this user was initialized during Firebird 4 install.
By default
installation creates SYSDBA using SRP plugin, so, there will be no SYSDBA for Legacy_UserManager
plugin.
But, you may create SYSDBA using Legacy_UserManager, and in this case there will be two
SYSDBA - for Srp and for Legacy_UserManager.
4. Run script on Firebird 4.0 connecting to the security database in embedded mode
At that point all users transferred with all attributes and passwords.
1. First you must turn on Win_Sspi plugin in the firebird.conf or databases.conf (by default it is turned off).
This
plugin will be used together with Srp.
TO USER;
https://ib-aid.com/download/docs/fb4migrationguide.html 19/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
TO USER;
FROM Predefined_Group
DOMAIN_ANY_RID_ADMINS
TO ROLE RDB$ADMIN;
Instead of SYSDBA-like access you may give administrative privileges to the particular user.
DataTypeCompatibility = 3.0
This is the fastest way to get compatibility with new data types.
During time you may add new data types support to your
applications.
Since it will happen gradually, one datatype first, then another, etc, you may set data type binding of the
types
that your applications still do not support.
Syntax
Please read detailed description of this command in "Firebird 4.0 Release Notes" and "Firebird 4.0 language reference".
Using 'SET BIND OF' you can bind new types right after connecting to the database, and even create AFTER CONNECT
trigger
with the set of such commands.
For example, you added timezone support to your application, but still do not support INT128 and DECFLOAT.
In this case
you may create trigger.
https://ib-aid.com/download/docs/fb4migrationguide.html 20/21
22/7/2021 Short Firebird Migration Guide to Firebird 4.0
on connect
as
begin
end
This can lead to the fact that some code not subject to transactional control can be executed multiple times within PSQL.
Examples of this type of code may be:
Please read about 'Read Consistency' in the "Firebird 4.0 Release Notes".
Another important effect is that active cursors in READ COMMITTED READ CONSISTENCY transactions prevent garbage
collection even in Read Only mode.
It is recommended that you stop using single long-running transaction READ
COMMITTED READ ONLY, and change it to several same transactions, each of them
active for exactly as long as necessary.
If READ CONSISTENCY mode is undesirable for any reason, you may set configuration parameter ReadConsistency to
previous behavior.
7. Conclusion
That’s it. We hope that this document will help to upgrade your databases and applications to Firebird 4.0 and get all
benefits of the new version!
Version v1.0
https://ib-aid.com/download/docs/fb4migrationguide.html 21/21