Firebird-5 0 1-ReleaseNotes
Firebird-5 0 1-ReleaseNotes
1 Release Notes
Firebird Project: Core Developers, Mark Rotteveel
Table of Contents
1. General Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Compatibility with Older Versions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Sub-release V.5.0.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
V.5.0.1 Improvements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Bug Reporting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2. New In Firebird 5.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Summary of New Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Complete In Firebird 5.0 Release Candidate 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Complete In Firebird 5.0 Release Candidate 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Complete In Firebird 5.0 Beta 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3. Changes in the Firebird Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Quick Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Support for parallel operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Inline minor ODS upgrade. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
More cursor-related details in the plan output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Denser compression of records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Compiled statement cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
SQL and PSQL profiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Package routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Snapshot tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Auxiliary views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
RDB$BLOB_UTIL package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Package routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4. Changes to the Firebird API and ODS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
ODS (On-Disk Structure) Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
New Minor ODS Number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
New System Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
New Columns in System Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Application Programming Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Main API Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Extensions to various getInfo() Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Services API Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5. Reserved Words and Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
New Keywords in Firebird 5.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Non-reserved . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
6. Configuration Additions and Changes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
1
Table of Contents
2
Table of Contents
3
Table of Contents
4
Chapter 1. General Notes
ODS (On-Disk Structure) 13.1 is introduced. It’s a minor ODS upgrade, so databases in ODS 13.0
(created by Firebird 4.0) may still be opened with a Firebird 5.0 server (with some new features
being unavailable), but databases in older ODS cannot be opened.
RC1 has an ODS change affecting the profiler, specifically with nullability and
default values of its procedures and functions. If you intend to use (or have
already used) the profiler, it is advisable to recreate the database.
Also, if you used the profiler in a pre-RC1 build, and don’t intend to recreate the
database, you will need to drop the tables and views prefixed with PLG$PROF due to
changes in these tables (which are not considered part of the ODS). The next use of
the profiler will recreate these tables and views.
The engine library is still named engine13.dll (Windows) and libEngine13.so (POSIX). The security
database is named security5.fdb. Binaries layout and configuration are unchanged from Firebird 4.
That said, you can copy the Firebird engine library from the Firebird 3.0
distribution package (named engine12.dll (Windows) and libEngine12.so (POSIX),
and located inside the /plugins sub-directory) to continue working with databases
in ODS 12 without needing a backup/restore. However, new features introduced
with Firebird 4.0 and Firebird 5.0 will not be accessible.
Sub-release V.5.0.1
Bugs reported and fixed prior to the version 5.0.1 release are listed HERE.
V.5.0.1 Improvements
#8181 — Ensure the standalone CS listener on Linux uses the SO_REUSEADDR socket option
5
Chapter 1. General Notes
#8104 — More efficient evaluation of expressions like RDB$DB_KEY <= ? after mass delete
#8061 — Unnest IN/ANY/EXISTS sub-queries and optimize them using semi-join algorithm
#8042 — Improve conflict resolution on replica when table has both primary and unique keys
6
Chapter 1. General Notes
Bug Reporting
Bugs fixed in this release are listed and described in the chapter entitled Bugs Fixed.
• If you think you have discovered a new bug in this release, please make a point of reading the
instructions for bug reporting in the article How to Report Bugs Effectively, at the Firebird
Project website.
• If you think a bug fix has not worked, or has caused a regression, please locate the original bug
report in the Tracker, reopen it if necessary, and follow the instructions below.
1. Write detailed bug reports, supplying the exact build number of your Firebird kit. Also provide
details of the OS platform.
2. Include reproducible test data in your report and post it to our Tracker.
Documentation
You will find all the README documents referred to in these notes — as well as many others not
referred to — in the doc subdirectory of your Firebird 5.0 installation.
7
Chapter 2. New In Firebird 5.0
• Partial indices;
• SKIP LOCKED clause for SELECT WITH LOCK, UPDATE and DELETE statements;
The following list summarises the features and changes, with links to the chapters and topics where
more detailed information can be found.
Allow to configure Firebird in POSIX using relative directories with options --with-fb
#7918 by Adriano dos Santos Fernandes
Resolve difficulty returning the product version with the legacy connection
#7819 by Vlad Khorsun
8
Chapter 2. New In Firebird 5.0
Update Windows distribution with new zlib version 1.3 (released 2023-08-18)
#7755 by Vlad Khorsun
Avoid truncation of the access path information inside the PLG$PROF_RECORD_SOURCES table to 255
characters
#7752 by Adriano dos Santos Fernandes
Make trace config parser resolve symlinks in database file path in trace configuration
#7692 by Vlad Khorsun
Allow tracing database events even if the trace/audit is configured using a symbolic link instead
of a real database file path.
Column LEVEL is added to the profiler record source tables/views. It returns the actual
indentation level that allows proper reconstruction of multi-line access path nodes.
Use ParallelWorkers setting from firebird.conf as default for all parallelized operations
#7682 by Vlad Khorsun
This allows utilities started via the Service Manager to use the server-side ParallelWorkers
setting without a need to specify the number of workers explicitly.
9
Chapter 2. New In Firebird 5.0
Make the profiler store aggregated requests by default, with an option for the detailed store
#7652 by Adriano dos Santos Fernandes
Make the profiler data aggregated at the statement level by default (with REQUEST_ID = 0), thus
making the flushing faster. A detailed (non-aggregated) data may be requested explicitly by
specifying the 'DETAILED_REQUESTS' value in the PLUGIN_OPTIONS parameter of the
RDB$PROFILER.START_SESSION function.
New context variables DECFLOAT_ROUND and DECFLOAT_TRAPS are added to the SYSTEM namespace of
the RDB$GET_CONTEXT function. They return the current settings of the corresponding session
options.
Some modern CPUs may contain two sets of cores - Efficient (E) and Performance (P). By default
Firebird runs on all available cores and that may cause performance degradation in CPU-bound
tasks. Now, E-cores are excluded from the default affinity mask. If the AffinityMask configuration
setting is used explicitly, please pay attention which types of cores are specified to be enabled.
gfix -icu rebuilds indexes and thus can benefit from parallelization. Now it’s allowed to use the
-icu and -parallel switches together, to override the ParallelWorkers setting used by default.
Compiler warnings raise when build cloop-generated Firebird.pas in RAD Studio 11.3
#7542 by Vlad Khorsun
10
Chapter 2. New In Firebird 5.0
• New variable PARALLEL_WORKERS is now available in the SYSTEM context of the RDB$GET_CONTEXT
function.
Index scan algorithm has been improved to avoid unnecessary record reads for partial lookups
in compound indices.
Allows to trace parse/compile events for the stored modules, corresponding elapsed time and
also plans for queries inside those PSQL modules.
Add REPLICA MODE to the output of the isql SHOW DATABASE command
#7425 by Dmitry Yemanov
Surface internal optimization modes (all rows vs first rows) at the SQL and configuration
levels
#7405 by Dmitry Yemanov
For more details, see OptimizeForFirstRows, OPTIMIZE FOR Clause, and SET OPTIMIZE.
Use Windows private namespace for kernel objects used in server-to-server IPC
#7213 by Vlad Khorsun
This improvement allows to synchronize Firebird processes across different Windows sessions.
11
Chapter 2. New In Firebird 5.0
For more details, see QUARTER added to EXTRACT, FIRST_DAY and LAST_DAY.
Such operations as logical backup/restore, sweeping and CREATE INDEX statement execution can
be executed in parallel by multiple threads, thus decreasing the total operation time.
See chapters Support for parallel operations, Parallel backup/restore and Parallel sweep and ICU
dependencies rebuild for more details.
The CREATE INDEX DDL statement has been extended to support partial indices, i.e. an index may
now declare a condition that defines the subset of records to be indexed.
New clause SKIP LOCKED was introduced for statements SELECT WITH LOCK, UPDATE and DELETE. It
allows to skip the already locked records while reading the table.
An ability to upgrade the database to the latest minor ODS version has been introduced, it does
not require a backup/restore cycle.
A built-in ability to profile SQL and PSQL statements has been added, making it possible to
measure execution time at different levels.
12
Chapter 2. New In Firebird 5.0
The MERGE statement has been extended to support the WHEN NOT MATCHED BY SOURCE clause.
New built-in functions UNICODE_CHAR and UNICODE_VAL have been added to allow conversion
between Unicode code point and character.
New system package RDB$BLOB_UTIL has been added to allow various operations with BLOBs in
the PSQL modules.
Support multiple rows being returned by DML with the RETURNING clause
#6815 by Adriano dos Santos Fernandes
The RETURNING clause, if used in DSQL queries, now allows multiple rows to be returned.
The built-in compression algorithm has been improved to allow denser compression of records.
Other improvements are briefly listed below, please follow the tracker references for more
information.
Unify display of system procedures & packages with other system objects
#7411 by Alexander Peshkov
Create Android packages with all necessary files in all architectures (x86, x64, arm32, arm64)
#7293 by Adriano dos Santos Fernandes
13
Chapter 2. New In Firebird 5.0
Provide ability to see in the trace log events related to missing security context
#7165 by Alexander Peshkov
For more details, see Trace events before a valid security context is established.
Results of negation must be the same for each datatype (SMALLINT / INT / BIGINT / INT128) when
argument is minimum value for this type
#7025 by Alexander Peshkov
Transform OUTER joins into INNER ones if the WHERE condition violates the outer join rules
#6992 by Dmitry Yemanov
Add way to retrieve statement BLR with Statement.getInfo() and ISQL's SET EXEC_PATH_DISPLAY
BLR
#6910 by Adriano dos Santos Fernandes
SIMILAR TO should use index when pattern starts with non-wildcard character (as LIKE does)
#6873 by Adriano dos Santos Fernandes
14
Chapter 2. New In Firebird 5.0
For more details, see Full SQL standard character string literal syntax.
For more details, see Full SQL standard binary string literal syntax.
For more details, see Allow subroutines to access variables/parameters defined at the
outer/parent level.
15
Chapter 3. Changes in the Firebird Engine
• RDB$BLOB_UTIL package
The Firebird engine can now execute some tasks using multiple threads in parallel. Currently,
parallel execution is implemented for the sweep and the index creation tasks. Parallel execution is
supported for both automatic and manual sweep.
To handle a task with multiple threads, the engine runs additional worker threads and creates
internal worker attachments. By default, parallel execution is not enabled. There are two ways to
enable parallelism in a user attachment:
1. set the number of parallel workers in DPB using new tag isc_dpb_parallel_workers,
2. set the default number of parallel workers using new setting ParallelWorkers in firebird.conf.
The gfix utility has a new command-line switch, -parallel, that allows to set the number of parallel
workers for the sweep task.
For example, the following will run sweep on the given database and asks the engine to use 4
workers:
gfix uses DPB tag isc_dpb_parallel_workers when attaches to <database>, if switch -parallel is
present.
The new firebird.conf setting ParallelWorkers sets the default number of parallel workers that can
be used by any user attachment running parallelizable task. The default value is 1 and means no
use of additional parallel workers. The value in the DPB has a higher priority than the setting in
16
Chapter 3. Changes in the Firebird Engine
firebird.conf.
To control the number of additional workers that can be created by the engine, there are two new
settings in firebird.conf:
ParallelWorkers
Sets the default number of parallel workers used by a user attachments. Can be overridden by
attachment using tag isc_dpb_parallel_workers in DPB.
MaxParallelWorkers
Limits the maximum number of simultaneously used workers for the given database and
Firebird process.
Internal worker attachments are created and managed by the engine itself. The engine maintains
per-database pools of worker attachments. The number of threads in each pool is limited by the
value of the MaxParallelWorkers setting. The pools are created by each Firebird process
independently.
Examples:
1. Connect to test database not using isc_dpb_parallel_workers in DPB and execute a CREATE INDEX
… SQL statement. On commit, the index will be created and the engine will use three additional
worker attachments. In total, four attachments in four threads will work on index creation.
2. Ensure auto-sweep is enabled for test database. When auto-sweep runs on that database, it will
also use three additional workers (and run within four threads).
3. More than one task at a time can be parallelized: make two attachments and execute a CREATE
INDEX … in each of them (of course indices to be built should be different). Each index will be
created using four attachments (one user and three worker) and four threads.
4. Run gfix -sweep <database> without specifying switch -parallel: sweep will run using four
attachments in four threads.
5. Run gfix -sweep -parallel 2 <database>: sweep will run using two attachments in two threads.
This shows that value in DPB tag isc_dpb_parallel_workers overrides value of setting
ParallelWorkers.
17
Chapter 3. Changes in the Firebird Engine
This feature allows to upgrade the existing database to the newest ODS version without
backup/restore, provided that the database belongs to the same major ODS version.
For example, a database created by Firebird 4.0 uses ODS 13.0 and thus can be upgraded to the ODS
13.1 used by Firebird 5.0.
Notes
• The upgrade must be done manually, using gfix -upgrade command
• After the upgrade, Firebird 4.0 can no longer open the database
Usage
Detailed plan output now distinguishes between user-specified SELECT statements (reported as select
expressions), PSQL declared cursors and sub-queries. Both legacy and detailed plans now also
include information about cursor’s position (line/column) inside their PSQL module.
Examples:
Legacy plan
Detailed plan
18
Chapter 3. Changes in the Firebird Engine
Line/column numbers (as well as PSQL declared cursors) cannot be seen directly in the plan for
user-specified SQL queries, except if the query is EXECUTE BLOCK. However, they are accessible in
the MON$EXPLAINED_PLAN column in either MON$STATEMENTS or MON$COMPILED_STATEMENTS tables.
Starting with ODS 13.1, the engine uses an advanced RLE compression method (with variable-
length counter) that stores repeating byte sequences more effectively, thus reducing the storage
overhead. This improves compression for long VARCHAR fields (especially UTF8 encoded) that are
filled only partially.
The engine now maintains a per-attachment cache of compiled SQL statements. By default, caching
is enabled, the caching threshold is defined by the MaxStatementCacheSize parameter in
firebird.conf. It can be disabled by setting MaxStatementCacheSize to zero.
The cache is maintained automatically; cached statements are invalidated when required (usually
when some DDL statement is executed).
19
Chapter 3. Changes in the Firebird Engine
The profiler allows users to measure performance cost of SQL and PSQL code. It’s implemented
with a system package in the engine passing data to a profiler plugin.
This documentation treats the engine and plugin parts as a single thing, in the way the default
profiler (Default_Profiler) is going to be used.
The RDB$PROFILER package can profile execution of PSQL code, collecting statistics of how many
times each line was executed along with its minimum, maximum and accumulated execution times
(with nanoseconds precision), as well as open and fetch statistics of implicit and explicit SQL
cursors.
To collect profile data, a user must first start a profile session with RDB$PROFILER.START_SESSION. This
function returns a profile session ID which is later stored in the profiler snapshot tables to be
queried and analyzed by the user. A profiler session may be local (same attachment) or remote
(another attachment).
Remote profiling just forwards commands to the remote attachment. So, it’s possible that a client
profiles multiple attachments simultaneously. It’s also possible that a locally or remotely started
profile session have commands issued by another attachment.
Remotely issued commands require that the target attachment is in an idle state, i.e. not executing
others requests. When the target attachment is not idle, the call blocks waiting for that state.
If the remote attachment is from a different user, the calling user must have the system privilege
PROFILE_ANY_ATTACHMENT.
After a session is started, PSQL and SQL statements statistics are collected in memory. A profile
session collects data only of statements executed in the same attachment associated with the
session. Data is aggregated and stored per requests (i.e. a statement execution). When querying
snapshot tables, the user may do extra aggregation per statement, or use the auxiliary views that do
that automatically.
A session may be paused to temporarily disable statistics collecting. It may be resumed later to
return statistics collection in the same session.
A new session may be started when a session is already active. In that case, it has the same
semantics of finishing the current session with RDB$PROFILER.FINISH_SESSION(FALSE), so snapshots
tables are not updated.
To analyze the collected data, the user must flush the data to the snapshot tables, which can be
done by finishing or pausing a session (with FLUSH parameter set to TRUE), or calling
RDB$PROFILER.FLUSH. Data is flushed using an autonomous transaction (a transaction started and
finished for the specific purpose of profiler data update).
20
Chapter 3. Changes in the Firebird Engine
set term !;
set term ;!
2. Start profiling
set term !;
execute block
as
begin
execute procedure ins;
delete from tab;
end!
set term ;!
21
Chapter 3. Changes in the Firebird Engine
where id <= 50
group by mod(id, 5)
order by sum(val);
3. Data analysis
select preq.*
from plg$prof_requests preq
join plg$prof_sessions pses
on pses.profile_id = preq.profile_id and
pses.description = 'Profile Session 1';
select pstat.*
from plg$prof_psql_stats pstat
join plg$prof_sessions pses
on pses.profile_id = pstat.profile_id and
pses.description = 'Profile Session 1'
order by pstat.profile_id,
pstat.request_id,
pstat.line_num,
pstat.column_num;
select pstat.*
from plg$prof_record_source_stats pstat
join plg$prof_sessions pses
on pses.profile_id = pstat.profile_id and
pses.description = 'Profile Session 2'
order by pstat.profile_id,
pstat.request_id,
pstat.cursor_id,
pstat.record_source_id;
Package routines
Function START_SESSION
RDB$PROFILER.START_SESSION starts a new profiler session, makes it the current session (of the given
ATTACHMENT_ID) and returns its identifier.
22
Chapter 3. Changes in the Firebird Engine
If FLUSH_INTERVAL is different from NULL, auto-flush is set up in the same way as manually calling
RDB$PROFILER.SET_FLUSH_INTERVAL.
PLUGIN_OPTIONS are plugin specific options and currently should be NULL for the Default_Profiler
plugin.
Input parameters
• DESCRIPTION type VARCHAR(255) CHARACTER SET UTF8 default NULL
Return type
BIGINT NOT NULL
Procedure PAUSE_SESSION
RDB$PROFILER.PAUSE_SESSION pauses the current profiler session (of the given ATTACHMENT_ID), so the
next executed statements statistics are not collected.
If FLUSH is TRUE, the snapshot tables are updated with data up to the current moment, otherwise data
remains only in memory for later update.
Input parameters
• FLUSH type BOOLEAN NOT NULL default FALSE
Procedure RESUME_SESSION
RDB$PROFILER.RESUME_SESSION resumes the current profiler session (of the given ATTACHMENT_ID), if it
was paused, so the next executed statements statistics are collected again.
Input parameter
• ATTACHMENT_ID type BIGINT NOT NULL default CURRENT_CONNECTION
Procedure FINISH_SESSION
RDB$PROFILER.FINISH_SESSION finishes the current profiler session (of the given ATTACHMENT_ID).
If FLUSH is TRUE, the snapshot tables are updated with data of the finished session (and old finished
sessions not yet present in the snapshot), otherwise data remains only in memory for later update.
23
Chapter 3. Changes in the Firebird Engine
Input parameters
• FLUSH type BOOLEAN NOT NULL default TRUE
Procedure CANCEL_SESSION
RDB$PROFILER.CANCEL_SESSION cancels the current profiler session (of the given ATTACHMENT_ID).
All session data present in the profiler plugin is discarded and will not be flushed.
Input parameter
• ATTACHMENT_ID type BIGINT NOT NULL default CURRENT_CONNECTION
Procedure DISCARD
RDB$PROFILER.DISCARD removes all sessions (of the given ATTACHMENT_ID) from memory, without
flushing them.
Input parameter
• ATTACHMENT_ID type BIGINT NOT NULL default CURRENT_CONNECTION
Procedure FLUSH
RDB$PROFILER.FLUSH updates the snapshot tables with data from the profile sessions (of the given
ATTACHMENT_ID) in memory.
Input parameter
• ATTACHMENT_ID type BIGINT NOT NULL default CURRENT_CONNECTION
Procedure SET_FLUSH_INTERVAL
24
Chapter 3. Changes in the Firebird Engine
Input parameters
• FLUSH_INTERVAL type INTEGER NOT NULL
Snapshot tables
Snapshot tables (as well views and sequence) are automatically created in the first usage of the
profiler. They are owned by the database owner, with read/write permissions for PUBLIC.
When a session is deleted, the related data in other profiler snapshot tables are automatically
deleted too through foreign keys with DELETE CASCADE option.
Table PLG$PROF_SESSIONS
START_TIMESTAMP type TIMESTAMP WITH TIME Moment the profile session was started
ZONE
FINISH_TIMESTAMP type TIMESTAMP WITH TIME Moment the profile session was finished
ZONE (NULL when not finished)
Table PLG$PROF_STATEMENTS
SQL_TEXT type BLOB SUB_TYPE TEXT CHARACTER SQL text for BLOCK
SET UTF8
Primary key PROFILE_ID, STATEMENT_ID
25
Chapter 3. Changes in the Firebird Engine
Table PLG$PROF_CURSORS
Table PLG$PROF_RECORD_SOURCES
ACCESS_PATH type BLOB SUB_TYPE TEXT Access path for the record source
CHARACTER SET UTF8
Primary key PROFILE_ID, STATEMENT_ID, CURSOR_ID,
RECORD_SOURCE_ID
Table PLG$PROF_REQUESTS
START_TIMESTAMP type TIMESTAMP WITH TIME Moment this request was first gathered
ZONE profile data
FINISH_TIMESTAMP type TIMESTAMP WITH TIME Moment this request was finished
ZONE
26
Chapter 3. Changes in the Firebird Engine
Table PLG$PROF_PSQL_STATS
Table PLG$PROF_RECORD_SOURCE_STATS
27
Chapter 3. Changes in the Firebird Engine
Auxiliary views
They should be the preferred way to analyze the collected data. They can also be used together with
the tables to get additional data not present on the views.
After hotspots are found, one can drill down in the data at the request level through the tables.
View PLG$PROF_STATEMENT_STATS_VIEW
select req.profile_id,
req.statement_id,
sta.statement_type,
sta.package_name,
sta.routine_name,
sta.parent_statement_id,
sta_parent.statement_type parent_statement_type,
sta_parent.routine_name parent_routine_name,
(select sql_text
from plg$prof_statements
where profile_id = req.profile_id and
statement_id = coalesce(sta.parent_statement_id, req.statement_id)
) sql_text,
count(*) counter,
min(req.total_elapsed_time) min_elapsed_time,
max(req.total_elapsed_time) max_elapsed_time,
cast(sum(req.total_elapsed_time) as bigint) total_elapsed_time,
cast(sum(req.total_elapsed_time) / count(*) as bigint) avg_elapsed_time
from plg$prof_requests req
join plg$prof_statements sta
on sta.profile_id = req.profile_id and
sta.statement_id = req.statement_id
left join plg$prof_statements sta_parent
on sta_parent.profile_id = sta.profile_id and
sta_parent.statement_id = sta.parent_statement_id
group by req.profile_id,
req.statement_id,
28
Chapter 3. Changes in the Firebird Engine
sta.statement_type,
sta.package_name,
sta.routine_name,
sta.parent_statement_id,
sta_parent.statement_type,
sta_parent.routine_name
order by sum(req.total_elapsed_time) desc
View PLG$PROF_PSQL_STATS_VIEW
select pstat.profile_id,
pstat.statement_id,
sta.statement_type,
sta.package_name,
sta.routine_name,
sta.parent_statement_id,
sta_parent.statement_type parent_statement_type,
sta_parent.routine_name parent_routine_name,
(select sql_text
from plg$prof_statements
where profile_id = pstat.profile_id and
statement_id = coalesce(sta.parent_statement_id, pstat.statement_id)
) sql_text,
pstat.line_num,
pstat.column_num,
cast(sum(pstat.counter) as bigint) counter,
min(pstat.min_elapsed_time) min_elapsed_time,
max(pstat.max_elapsed_time) max_elapsed_time,
cast(sum(pstat.total_elapsed_time) as bigint) total_elapsed_time,
cast(sum(pstat.total_elapsed_time) / nullif(sum(pstat.counter), 0) as bigint)
avg_elapsed_time
from plg$prof_psql_stats pstat
join plg$prof_statements sta
on sta.profile_id = pstat.profile_id and
sta.statement_id = pstat.statement_id
left join plg$prof_statements sta_parent
on sta_parent.profile_id = sta.profile_id and
sta_parent.statement_id = sta.parent_statement_id
group by pstat.profile_id,
pstat.statement_id,
sta.statement_type,
sta.package_name,
sta.routine_name,
sta.parent_statement_id,
sta_parent.statement_type,
sta_parent.routine_name,
pstat.line_num,
pstat.column_num
order by sum(pstat.total_elapsed_time) desc
29
Chapter 3. Changes in the Firebird Engine
View PLG$PROF_RECORD_SOURCE_STATS_VIEW
select rstat.profile_id,
rstat.statement_id,
sta.statement_type,
sta.package_name,
sta.routine_name,
sta.parent_statement_id,
sta_parent.statement_type parent_statement_type,
sta_parent.routine_name parent_routine_name,
(select sql_text
from plg$prof_statements
where profile_id = rstat.profile_id and
statement_id = coalesce(sta.parent_statement_id, rstat.statement_id)
) sql_text,
rstat.cursor_id,
cur.name cursor_name,
cur.line_num cursor_line_num,
cur.column_num cursor_column_num,
rstat.record_source_id,
recsrc.parent_record_source_id,
recsrc.level,
recsrc.access_path,
cast(sum(rstat.open_counter) as bigint) open_counter,
min(rstat.open_min_elapsed_time) open_min_elapsed_time,
max(rstat.open_max_elapsed_time) open_max_elapsed_time,
cast(sum(rstat.open_total_elapsed_time) as bigint) open_total_elapsed_time,
cast(sum(rstat.open_total_elapsed_time) / nullif(sum(rstat.open_counter), 0) as
bigint) open_avg_elapsed_time,
cast(sum(rstat.fetch_counter) as bigint) fetch_counter,
min(rstat.fetch_min_elapsed_time) fetch_min_elapsed_time,
max(rstat.fetch_max_elapsed_time) fetch_max_elapsed_time,
cast(sum(rstat.fetch_total_elapsed_time) as bigint) fetch_total_elapsed_time,
cast(sum(rstat.fetch_total_elapsed_time) / nullif(sum(rstat.fetch_counter), 0)
as bigint) fetch_avg_elapsed_time,
cast(coalesce(sum(rstat.open_total_elapsed_time), 0) +
coalesce(sum(rstat.fetch_total_elapsed_time), 0) as bigint)
open_fetch_total_elapsed_time
from plg$prof_record_source_stats rstat
join plg$prof_cursors cur
on cur.profile_id = rstat.profile_id and
cur.statement_id = rstat.statement_id and
cur.cursor_id = rstat.cursor_id
join plg$prof_record_sources recsrc
on recsrc.profile_id = rstat.profile_id and
recsrc.statement_id = rstat.statement_id and
recsrc.cursor_id = rstat.cursor_id and
recsrc.record_source_id = rstat.record_source_id
join plg$prof_statements sta
on sta.profile_id = rstat.profile_id and
sta.statement_id = rstat.statement_id
30
Chapter 3. Changes in the Firebird Engine
RDB$BLOB_UTIL package
Adriano dos Santos Fernandes
This package provides procedures and functions to manipulate BLOBs in a way that standard
Firebird functions, like BLOB_APPEND and SUBSTRING, cannot do or are very slow.
These routines operate on binary data directly, even for text BLOBs.
Package routines
Function NEW_BLOB
RDB$BLOB_UTIL.NEW_BLOB creates a new BLOB SUB_TYPE BINARY. It returns a BLOB suitable for data
appending, similar to BLOB_APPEND.
The advantage over BLOB_APPEND is that it’s possible to set custom SEGMENTED and TEMP_STORAGE
options.
BLOB_APPEND always creates BLOBs in temporary storage, which may not always be the best
approach if the created BLOB is going to be stored in a permanent table, as this will require a copy
operation.
The BLOB returned from this function, even when TEMP_STORAGE = FALSE, may be used with
BLOB_APPEND for appending data.
31
Chapter 3. Changes in the Firebird Engine
Input parameters
• SEGMENTED type BOOLEAN NOT NULL
Return type
BLOB SUB_TYPE BINARY NOT NULL
Function OPEN_BLOB
RDB$BLOB_UTIL.OPEN_BLOB opens an existing BLOB for reading. It returns a handle (an integer bound
to the transaction) suitable for use with other functions of this package, like SEEK, READ_DATA and
CLOSE_HANDLE.
Handles which are not explicitly closed are closed automatically when the transaction ends.
Input parameter
• BLOB type BLOB NOT NULL
Return type
INTEGER NOT NULL
Function IS_WRITABLE
RDB$BLOB_UTIL.IS_WRITABLE returns TRUE when a BLOB is suitable for data appending using
BLOB_APPEND without copying.
Input parameter
• BLOB type BLOB NOT NULL
Return type:
BOOLEAN NOT NULL
Function READ_DATA
If LENGTH is passed with a positive number, it returns a VARBINARY with its maximum length.
If LENGTH is NULL it returns just a segment of the BLOB with a maximum length of 32765.
Input parameters
• HANDLE type INTEGER NOT NULL
Return type
VARBINARY(32765)
32
Chapter 3. Changes in the Firebird Engine
Function SEEK
RDB$BLOB_UTIL.SEEK sets the position for the next READ_DATA, it returns the new position.
MODE may be 0 (from the start), 1 (from current position) or 2 (from end).
Input parameters
• HANDLE type INTEGER NOT NULL
Return type
INTEGER NOT NULL
SEEK only works on stream blobs. Attempting to seek on a segmented blob results
in error “invalid BLOB type for operation”.
Procedure CANCEL_BLOB
If the same BLOB is used after cancel, an “invalid blob id” error will be raised.
Input parameter
• BLOB type BLOB
Procedure CLOSE_HANDLE
Handles which are not explicitly closed are closed automatically when the transaction ends.
Input parameter
• HANDLE type INTEGER NOT NULL
Examples
Create a BLOB in temporary space and return it in EXECUTE BLOCK
33
Chapter 3. Changes in the Firebird Engine
b = blob_append(b, '67');
suspend;
end
s = rdb$blob_util.read_data(bhandle, 3);
suspend;
s = rdb$blob_util.read_data(bhandle, 3);
suspend;
s = rdb$blob_util.read_data(bhandle, 3);
suspend;
Seek in a blob
set term !;
-- Add data.
b = blob_append(b, '0123456789');
34
Chapter 3. Changes in the Firebird Engine
bhandle = rdb$blob_util.open_blob(b);
-- Advance 2.
rdb$blob_util.seek(bhandle, 1, 2);
s = rdb$blob_util.read_data(bhandle, 3);
suspend;
set term ;!
set term !;
set term ;!
35
Chapter 4. Changes to the Firebird API and ODS
Firebird 5.0 creates databases with an ODS (On-Disk Structure) version of 13.1. It can also work
with databases created in ODS 13.0 (by Firebird 4.0), but some new features will be unavailable.
See Inline minor ODS upgrade for a new method of upgrading an ODS 13.0 database to 13.1.
RDB$KEYWORDS Virtual table that enumerates keywords used by the SQL parser
• RDB$CONDITION_SOURCE and RDB$CONDITION_BLR were added to the system table RDB$INDICES, they
belong to the partial indices feature
ResultSet
36
Chapter 4. Changes to the Firebird API and ODS
Used to query cursor information. Currently, only one information item is supported,
INF_RECORD_COUNT. INF_RECORD_COUNT returns the number of records cached by the scrollable cursor,
or -1 for a uni-directional (forward-only) cursor.
Statement::getInfo()
Examples of use of new parameters in fbsvcmgr utility (login and password were left out for
brevity):
Example of use of new parameter in fbsvcmgr utility (login and password were left out for brevity):
37
Chapter 5. Reserved Words and Changes
LOCKED
OPTIMIZE
QUARTER
TARGET
TIMEZONE_NAME
UNICODE_CHAR
UNICODE_VAL
38
Chapter 6. Configuration Additions and Changes
Limits the total number of parallel workers that can be created within a single Firebird process for
each attached database. Integer values in the range between 1 (no parallelism) and 64 are allowed.
All other values are silently ignored and the default value of 1 is used.
ParallelWorkers
Specifies the default number of parallel workers for a single task. Integer values in the range
between 1 (no parallelism) and MaxParallelWorkers (see above) are allowed. All other values are
silently ignored and the default value of 1 is used.
Other Parameters
MaxStatementCacheSize
Defines the maximum amount of memory used to cache unused DSQL compiled statements. A
value of zero (‘0’) means no statement caching is used. Default value is 2 megabytes.
OnDisconnectTriggerTimeout
Configures a timeout (in seconds) that is applied to the ON DISCONNECT trigger execution. The trigger
will be automatically cancelled by the engine after the specified time has passed. A value of zero (‘
0’) means no timeout is set. Default value is 180 seconds.
DefaultProfilerPlugin
Specifies the default profiler plugin used to profile connections using the RDB$PROFILER package.
OptimizeForFirstRows
Defines whether queries should be optimized to retrieve the first records as soon as possible rather
than returning the whole dataset as soon as possible. By default, retrieval of all rows is implied by
the optimizer.
39
Chapter 6. Configuration Additions and Changes
OuterJoinConversion
Defines whether OUTER joins can be converted into INNER joins by the optimizer, provided that
such a transformation is possible from the query result perspective.
Enabled by default. Can be disabled to simplify the migration path if OUTER joins are used
intentionally in SQL queries (e.g. as optimizer hints) even if they are known to be semantically
equivalent to INNER joins.
SubQueryConversion
Defines whether IN/ANY/EXISTS sub-queries can be unnested and merged with the outer query using
the semi-join algorithm, provided that such a transformation is possible.
being evaluated just once and then cached. However, it may also lead to a worse
performance in some cases, e.g. when the sub-query returns many rows. Please
test with real-world use cases before enabling this conversion in a production
environment.
A new variant of the ChaCha#20 plugin was added. It uses a 64-bit internal counter rather than 32-
bit. The new default value of this parameter is now ChaCha64, ChaCha, Arc4.
Specifies whether changes applied to the replica database will be also subject of further replication
(if any configured). Default value is false (cascading is disabled).
This parameter was removed along with the removal of WNET (aka named pipes) protocol support
for Windows.
40
Chapter 6. Configuration Additions and Changes
TcpLoopbackFastPath
This parameter was removed because Microsoft discourages using the SIO_LOOPBACK_FAST_PATH
socket option.
41
Chapter 7. Security
Chapter 7. Security
Security enhancements in Firebird 5 include:
When remote SQL profiling is used and the attachment being profiled is from a different user, the
calling user must have this system privilege.
A privileged trace session (e.g. by an administrator or user with TRACE_ANY_ATTACHMENT) can now
report events (i.e. errors) taking place before validation of an attachment’s security context.
As an example:
# ./isql employee
Database: employee, User: SYSDBA
SQL> create user qq password 'qq';
SQL> create global mapping z1 using * from user qq to user z1;
SQL> create global mapping z2 using * from user qq to user z2;
SQL> ^D
Because of the conflicting mapping user QQ can not attach to a database even with valid
login/password:
42
Chapter 7. Security
43
Chapter 8. Management Statements
Configures whether the optimizer should optimize for fetching first or all rows.
Syntax
<optimize-mode> ::=
FOR {FIRST | ALL} ROWS
| TO DEFAULT
This feature allows the optimizer to consider another (hopefully better) plan if only a subset or
rows is fetched initially by the user application (with the remaining rows being fetched on
demand), thus improving the response time.
It can also be specified at the statement level using the OPTIMIZE FOR clause.
The default behaviour can be specified globally using the OptimizeForFirstRows setting in
firebird.conf or databases.conf.
44
Chapter 9. Data Definition Language (DDL)
• COMMENT ON MAPPING
This feature allows to index only a subset of table rows defined by the search condition specified
during index creation.
Syntax
Examples
-- 1.
CREATE INDEX IT1_COL ON T1 (COL) WHERE COL < 100;
SELECT * FROM T1 WHERE COL < 100;
-- PLAN (T1 INDEX (IT1_COL))
-- 2.
CREATE INDEX IT1_COL2 ON T1 (COL) WHERE COL IS NOT NULL;
SELECT * FROM T1 WHERE COL > 100;
-- PLAN (T1 INDEX IT1_COL2)
-- 3.
CREATE INDEX IT1_COL3 ON T1 (COL) WHERE COL = 1 OR COL = 2;
SELECT * FROM T1 WHERE COL = 2;
-- PLAN (T1 INDEX IT1_COL3)
Notes:
1. A partial index definition may include the UNIQUE specification. In this case, every key in the
index is required to be unique. This allows to enforce uniqueness across some subset of table
rows.
◦ The WHERE condition includes exactly the same boolean expression as the one defined for
45
Chapter 9. Data Definition Language (DDL)
the index;
◦ The search condition defined for the index contains ORed boolean expressions and one of
them is explicitly included in the WHERE condition;
◦ The search condition defined for the index specifies IS NOT NULL and the WHERE condition
includes an expression on the same field that is known to ignore NULLs.
COMMENT ON MAPPING
Alex Peshkov
46
Chapter 10. Data Manipulation Language (DML)
• Changes to literals
• Improvements to IN
SKIP LOCKED can be used with SELECT … WITH LOCK, UPDATE and DELETE statements. It makes the
engine skip records locked by other transactions instead of waiting on them or raise conflict errors.
This is very useful to implement work queues where one or more processes post work to a table
and issue an event, while workers listen for events and read/delete items from the table. Using SKIP
LOCKED multiple workers can get exclusive work items from the table without conflicts.
Syntax
SELECT
[FIRST ...]
[SKIP ...]
FROM <sometable>
[WHERE ...]
[PLAN ...]
[ORDER BY ...]
[{ ROWS ... } | {OFFSET ...} | {FETCH ...}]
[FOR UPDATE [OF ...]]
[WITH LOCK [SKIP LOCKED]]
UPDATE <sometable>
SET ...
47
Chapter 10. Data Manipulation Language (DML)
[WHERE ...]
[PLAN ...]
[ORDER BY ...]
[ROWS ...]
[SKIP LOCKED]
[RETURNING ...]
If a statement has both SKIP LOCKED and OFFSET/SKIP/ROWS subclauses, locked rows
may be skipped before OFFSET/SKIP/ROWS subclause can account for them, thus
skipping more rows than specified in OFFSET/SKIP/ROWS.
Examples:
• Prepare metadata
set term !;
set term ;!
• Client application
48
Chapter 10. Data Manipulation Language (DML)
More than one instance of the application may be running, for example to load balance work.
Syntax
<merge when not matched by target> is called when a source record matches no record in target.
INSERT will change the target table.
<merge when not matched by source> is called when a target record matches no record in source.
UPDATE or DELETE will change the target table.
Example
MERGE
INTO customers c
USING new_customers nc
ON (c.id = nc.id)
WHEN MATCHED THEN
UPDATE SET name = nc.name
WHEN NOT MATCHED BY SOURCE THEN
DELETE
49
Chapter 10. Data Manipulation Language (DML)
In DSQL, the RETURNING clause is now able to return multiple rows for DML statements than can
affect multiple rows.
The DML syntax was extended to allow a parenthesized query expression (select including order by,
offset and fetch clauses, but without with clause) to occur where previously only a query
specification (select without with, order by, offset and fetch clauses) was allowed.
This allows more expressive queries, especially in UNION statements, and offers more compatibility
with statements generated by certain ORMs.
Example
(
select emp_no, salary, 'lowest' as type
from employee
order by salary asc
fetch first row only
)
union all
(
select emp_no, salary, 'highest' as type
from employee
order by salary desc
fetch first row only
);
50
Chapter 10. Data Manipulation Language (DML)
Syntax
Syntax
Syntax
SELECT
...
[WITH LOCK [SKIP LOCKED]]
[OPTIMIZE FOR {FIRST | LAST} ROWS]
This feature allows the optimizer to consider another (hopefully better) plan if only a subset or
rows is fetched initially by the user application (with the remaining rows being fetched on
demand), thus improving the response time.
It can also be specified at the session level using the SET OPTIMIZE management statement.
The default behaviour can be specified globally using the OptimizeForFirstRows setting in
51
Chapter 10. Data Manipulation Language (DML)
firebird.conf or databases.conf.
Changes to literals
Full SQL standard character string literal syntax
The syntax of character string literals was changed to support the full SQL standard syntax. This
means a literal can be “interrupted” by whitespace or a comment. This can be used, for example, to
break up a long literal over several lines, or provide inline comments.
<separator> ::=
{ <comment> | <white space> }...
Examples
The syntax of binary string literals was changed to support the full SQL standard syntax. This
means a literal can contain spaces to separate hexadecimal characters, and it can be “interrupted”
by whitespace or a comment. This can be used, for example, to make the hex string more readable
by grouping characters, or to break up a long literal over several lines, or provide inline comments.
52
Chapter 10. Data Manipulation Language (DML)
Examples
Improvements to IN
Dmitry Yemanov
Processing of IN <list> predicates is now linear rather than recursive, thus no runtime stack
limitations. The limit of 1500 items has been raised to 65535 items.
Lists that are known to be constant are pre-evaluated as invariants and cached as a binary search
tree, making comparisons faster if the condition needs to be tested for many rows or if the value list
is long.
If the list is very long or if the IN predicate is not selective, the index scan supports searching groups
using the sibling pointer (i.e. horizontally) rather than searching every group from the root (i.e.
vertically), thus utilizing a single index scan for the whole IN list.
53
Chapter 10. Data Manipulation Language (DML)
UNICODE_CHAR
Syntax
UNICODE_CHAR( <number> )
The argument to UNICODE_CHAR must be a valid Unicode code point and not in
the range of high/low surrogates (0xD800 to 0xDFFF), otherwise it throws an error.
Example
UNICODE_VAL
Returns the Unicode code point of the first character of the specified string, or zero if the string is
empty.
Syntax
UNICODE_VAL( <string> )
Example
The scalar functions EXTRACT, FIRST_DAY and LAST_DAY now support the date part QUARTER.
Example
select
extract(quarter from date '2023-09-21') as Q,
first_day(of quarter from date '2023-09-21') as Q_START,
last_day(of quarter from date '2023-09-21') as Q_END
from rdb$database;
Q Q_START Q_END
======= =========== ===========
3 2023-07-01 2023-09-30
54
Chapter 11. Procedural SQL (PSQL)
Subroutines can now read from and write to variables and parameters of the outer/parent routine.
This does not apply to cursors: subroutines cannot access cursors of their parent.
Variables and parameters that are accessed by subroutines may have a small performance penalty
(even in the main routine) when being read.
55
Chapter 12. Monitoring & Command-line Utilities
Monitoring
New virtual tables:
RDB$KEYWORDS:
MON$COMPILED_STATEMENTS:
In MON$ATTACHMENTS:
In MON$STATEMENTS:
In MON$CALL_STACK:
In SEC$GLOBAL_AUTH_MAPPING:
56
Chapter 12. Monitoring & Command-line Utilities
isql
Unify display of system procedures and functions & packages with other
system objects
Alex Peshkov
The SHOW SYSTEM command of isql now lists system packages and their procedures and functions.
The SHOW SYSTEM <object-type> now supports the additional object types PROCEDURES, PACKAGES, and
PUBLICATIONS (see also below).
The equivalent “normal” SHOW <object-type> commands no longer list system functions, procedures
or packages.
The SET EXEC_PATH_DISPLAY command is a debug command to show the BLR (compiled form) of the
statement. When a statement is executed, it retrieves the compiled execution path of a DML
statement formatted as BLR text.
This feature is intimately tied to engine internals. Its usage is discouraged if you do
not understand very well how these internals are subject to change between
versions.
Dmitry Yemanov
• The SHOW DATABASE command now reports the “Replica mode” and “Publication” state
• The SHOW TABLE name command now reports the publications that include the table
• The SHOW PUBLICATIONS [name] command will show the named publication, or — without
name — all user-defined publications in the current database
57
Chapter 12. Monitoring & Command-line Utilities
• The command SHOW SYSTEM now also lists system publications, and SHOW SYSTEM PUBLICATIONS was
added to only show system publications
Vlad Khorsun
This command turns the display of per-table statistics on or off as desired. If no parameter is
supplied to the command, it toggles the current state of the per-table statistics display.
When set to ON, isql shows per-table run-time statistics after query execution. It is set to OFF by
default. This command is independent of the SET STATS command. The name PER_TABLE_STATS can be
abbreviated up to PER_TAB. Tables in the output are sorted by their relation id’s.
COUNT
=====================
534
Note, some system tables are shown that were not listed in the query; the engine reads some
58
Chapter 12. Monitoring & Command-line Utilities
gbak
Parallel backup/restore
Vlad Khorsun
It defines how many parallel workers will be used for the requested task.
Usage examples:
gfix
Parallel sweep and ICU dependencies rebuild
Vlad Khorsun
It defines how many parallel workers will be used for the requested task.
Usage example:
The -parallel option is only valid in combination with the -sweep and -icu tasks.
ODS upgrade
Dmitry Yemanov
59
Chapter 12. Monitoring & Command-line Utilities
It allows to upgrade ODS of the database to the latest supported minor version (within the
supported major version).
Usage example(s):
60
Chapter 13. Compatibility Issues
SQL
Changes that may affect existing SQL code:
Client-side INSERT … SELECT, UPDATE, DELETE, MERGE and UPDATE OR INSERT queries containing the
RETURNING clause may now return multiple records instead of raising error “multiple rows in
singleton select” as it happened before.
These queries are now described as isc_info_sql_stmt_select during preparation, while in previous
versions they were described as isc_info_sql_stmt_exec_procedure.
Singleton INSERT … VALUES statements, as well as positioned UPDATE and DELETE statements (i.e. the
ones containing the WHERE CURRENT OF clause) preserve the existing behaviour, being described as
isc_info_sql_stmt_exec_procedure. They also preserve the ability of being executed within a single
protocol roundtrip to the server.
However, all these queries, if used in PSQL and the RETURNING clause is applied, are still treated as
singleton.
61
Chapter 13. Compatibility Issues
Removal of QLI
Command-line utility QLI is removed in Firebird 5.0, in accordance with its deprecation
announcement published in the Firebird 4.0 release notes.
Removal of fbclient_bor.lib
API import library for Embarcadero (former Borland) compilers fbclient_bor.lib is no longer
distributed in Firebird 5.0 packages for Windows x86 platform. Anyone affected by this change may
generate it using the implib.exe utility supplied with Embarcadero (former Borland) development
tools as documented here.
62
Chapter 14. Bugs Fixed
#8189 — Slow connection times with a lot of simultaneous connections and active trace session
present
#8156 — Can not specify concrete IPv6 address in ES/EDS connection string
63
Chapter 14. Bugs Fixed
#8100 — The isc_array_lookup_bounds function returns invalid values for low and high array
bounds
#8086 — IN predicate with string-type elements is evaluated wrongly against a numeric field
#8085 — Memory leak when executing a lot of different queries and StatementTimeout > 0
64
Chapter 14. Bugs Fixed
#8078 — SIMILAR TO with constant pattern using ‘|’, ‘*’, ‘?’ or ‘{0,N}’ doesn’t work as expected
#8077 — Error "Too many recursion levels" does not stop execution of code that uses ON DISCONNECT
trigger (FB 4.x+)
#8056 — Error "Too many temporary blobs" with BLOB_APPEND when selecting a stored procedure
with rows-clause
#8040 — Bugcheck 183 (wrong record length) could happen on replica database after UK violation
on insert
#8033 — Invalid result when string compared with indexed NUMERIC(x,y) field where x > 18 and y !=
0
65
Chapter 14. Bugs Fixed
#7997 — Unexpected results when comparing integer with string containing value out of range of
that integer datatype
#7993 — Unexpected results when using CASE WHEN with RIGHT JOIN
#7969 — Characters are garbled when replicating fields with type BLOB SUB_TYPE TEXT if the
character set of the connection and the field are different
66
Chapter 14. Bugs Fixed
#7937 — Inner join raises error "no current record for fetch operation" if a stored procedure
depends on some table via input parameter and also has an indexed relationship with another
table
#7927 — Some default values are set incorrectly for SC/CS architectures
#7921 — Firebird 5 uses PK for ordered plan even if matching index with fewer fields exists
#7899 — Inconsistent state of master-detail occurs after reconnect + 'SET AUTODDL OFF' + 'drop
<FK>' which is rolled back
#7896 — replication.log remains empty (and without any error in firebird.log) until concurrent FB
instance is running under different account and generates segments on its master. Significant delay
required after stopping concurrent FB to allow first one to write in its replication log.
#7873 — Wrong memory buffer alignment and I/O buffer size when working in direct I/O mode
#7863 — Non-correlated sub-query is evaluated multiple times if it is based on a view rather than
on an equivalent derived table
Server Crashes/Hangups
67
Chapter 14. Bugs Fixed
#8151 — Deadlock happens when running 'List Trace Sessions' service and there are many active
trace sessions
#8149 — A hang or crash could happen when connection fires TRACE_EVENT_DETACH event and a
new trace session is created concurrently
#8101 — Firebird crashes if a plugin factory returns nullptr and no error in the status
#8087 — AV when preparing a query with IN <list> that contains both literals and sub-query
68
Chapter 14. Bugs Fixed
#8079 — Engine could crash when executing some trigger(s) while another attachment modifies
them
#8039 — Segfault when opening damaged (last TIP is missing in RDB$PAGES, user’s FW was OFF)
database
#7998 — Сrash during partial index checking if the condition raises a conversion error
#7985 — Hang in case of error when sweep thread is attaching to database (Classic Server)
#7979 — Hang when database with disconnect trigger using MON$ tables is shutting down
Utilities
isql
#8016 — Free memory issued for isql command list but has never been freed on output file write
#7962 — System procedure/function inconsistency between isql SHOW FUNCTIONS and SHOW PROCEDURES
69
Chapter 14. Bugs Fixed
gbak
#7974 — Restore of wide table can fail with "adjusting an invalid decompression length from <N> to
<M>"
#7950 — Unable to restore database when .fbk was created on host with other ICU
Builds/Packaging
70
Chapter 14. Bugs Fixed
#7885 — Unstable error messages in services due to races related with service status vector
71
Chapter 14. Bugs Fixed
#7827 — Problem using Python firebird-driver with either Intel or M1 Mac builds with version 4.0.3
or 5.0+
#7795 — NOT IN <list> returns incorrect result if NULLs are present inside the value list
#7461 — Differences in field metadata descriptions between Firebird 2.5 and Firebird 4
Server Crashes/Hangups
#7917 — Hang in case of error when the sweep thread is attaching the database
72
Chapter 14. Bugs Fixed
#7832 — Firebird 5 and 6 crash on "… RETURNING * " without INTO in PSQL
#7779 — Firebird 4.0.3 is constantly crashing with the same symptoms (fbclient.dll) (incl. DMP File
Analysis)
#7762 — Crash on "Operating system call pthread_mutex_destroy failed. Error code 16" in log
Utilities
isql
gbak
#7851 — [FB1+, GBAK, Restore] The skip of att_functionarg_field_precision does not check
RESTORE_format
73
Chapter 14. Bugs Fixed
#7747 — Fix an issue where the garbage collection in indexes and blobs is not performed in
VIO_backout
#7737 — Fix cases where the precedence relationship between a record page and a blob page is not
set
#7730 — Server ignores the size of VARCHAR when performing SET BIND … TO VARCHAR(N)
74
Chapter 14. Bugs Fixed
#7729 — SET BIND OF TIMESTAMP WITH TIMEZONE TO VARCHAR(128) uses the date format of Dialect 1
#7727 — Index for integer column cannot be used when INT128/DECFLOAT value is being searched
#7723 — Wrong error message on login if the user doesn’t exist and WireCrypt is disabled
#7713 — FOR SELECT statement can not see any changes made in DO block
#7710 — Expression index — more than one null value cause attempt to store duplicate value error
#7696 — SELECT from external procedure validates output parameters even when fetch method
returns false
#7694 — Fix false positives of “missing entries for record X” error during index validation when a
deleted record version is committed and has a backversion
75
Chapter 14. Bugs Fixed
#7670 — Cursor name can duplicate parameter and variable names in procedures and functions
#7664 — DROP TABLE executed for a table with big records may lead to “wrong page type” or “end of
file” error
76
Chapter 14. Bugs Fixed
#7638 — OVERRIDING USER VALUE should be allowed for GENERATED ALWAYS AS IDENTITY
#7627 — The size of a database with big records becomes bigger after backup/restore
#7611 — Can’t backup/restore database from v3 to v4 with SEC$USER_NAME field longer than 10
characters
#7604 — PSQL functions do not convert the output BLOB to the connection character set
#7598 — DDL statements hang when the compiled statements cache is enabled
77
Chapter 14. Bugs Fixed
#7556 — FB Classic can hang when attempts to attach DB while it is starting to encrypt/decrypt
#7555 — Invalid configuration for random fresh created database may be used after drop of
another one with alias in databases.conf
#7548 — SET BIND OF TIMESTAMP WITH TIME ZONE TO CHAR is not working with UTF8 connection
charset
#7537 — Wrong name in error message when unknown namespace is passed into
RDB$SET_CONTEXT()
78
Chapter 14. Bugs Fixed
#7535 — High CPU usage connect to Firebird 3 database using Firebird 4 Classic and SuperClassic
service
#7499 — Error during restore: “Index cannot be used in the specified plan”
#7486 — No initialization of rpb’s runtime flags causes problems with SKIP LOCKED when config
ReadConsistency = 0 and SuperServer
#7480 — Firebird server stops accepting new connections after some time
#7233 — Postfix for #5385 (CORE-5101): Fix slow database restore when Classic server mode is used
79
Chapter 14. Bugs Fixed
Server Crashes/Hangups
#7504 — Segfault when closing SQL statement in remote provider during shutdown
#7472 — Window functions may lead to crash interacting with others exceptions
Utilities
gbak
nbackup
#7579 — Cannot nbackup a Firebird 3.0 database in Firebird 4.0 service with engine12 setup in
Providers
80
Chapter 14. Bugs Fixed
Core Engine
#7422 — Seek in temporary blob level 0 makes read return wrong data
#7304 — Events in system attachments (like garbage collector) are not traced
#7220 — TYPE OF COLUMN dependency not tracked in package header and external routines
#7183 — Regression when derived table has column evaluated as result of subquery with IN, ANY or
ALL predicate: “invalid BLR at offset … / context already in use”
#7133 — ORDER BY for big (>34 digits) int128 values is broken when index on that field is used
81
Chapter 14. Bugs Fixed
#6869 — Domain CHECK-expression can be ignored when we DROP objects that are involved in it
#6807 — Regression: error “Unexpected end of command” with incorrect line/column info
Server Crashes/Hangups
#7195 — Crash when accessing already cleared memory in the sorting module
82
Chapter 14. Bugs Fixed
Utilities
gbak
83
Chapter 15. Firebird 5.0 Project Teams
Adriano dos Santos Brazil International character-set handling; text and text
Fernandes BLOB enhancements; new DSQL features; code
scrutineering
84
Appendix A: Licence Notice
The Initial Writer of the Original Documentation is: Dmitry Yemanov. Persons named in
attributions are Contributors.
Copyright © 2023-2024. All Rights Reserved. Initial Writer contact: dimitr at users dot sourceforge
dot net.
Portions created by Mark Rotteveel are Copyright © 2023-2024. All Rights Reserved. (Contributor
contact(s): mrotteveel at users dot sourceforge dot net).
85