Firebird-3 0 3-ReleaseNotes
Firebird-3 0 3-ReleaseNotes
Firebird-3 0 3-ReleaseNotes
3 Release Notes
iv
Firebird 3.0.3 Release Notes
v
Firebird 3.0.3 Release Notes
vi
Firebird 3.0.3 Release Notes
vii
Firebird 3.0.3 Release Notes
viii
Firebird 3.0.3 Release Notes
ix
List of Tables
3.1. Matrix of Server Modes ................................................................................................................. 12
6.1. Parameters available in databases.conf ............................................................................................ 47
11.1. Arguments for gbak STATISTICS Output ................................................................................... 118
14.1. Firebird Development Teams ...................................................................................................... 213
x
Chapter 1
General Notes
Thank you for choosing Firebird 3.0. We cordially invite you to test it hard against your expectations and engage
with us in identifying and fixing any bugs you might encounter.
If you are upgrading from a previous major release version, be sure to study Chapter 12, Compatibility Issues
before you attempt to do anything to your existing databases!
Sub-release V.3.0.3
Bugs reported and fixed prior to the v.3.0.3 release are listed HERE.
Security Alert
If you are using the database encryption feature, or plan to do so, it is essential to upgrade to this sub-release.
Refer to this report for details.
V. 3.0.3 Improvements
(CORE-5727) Engine response has been improved on cancel/shutdown signals when scanning a long
list of pointer pages.
Implemented by V. Khorsun
~ ~ ~
(CORE-5712) The name of the encryption key is not top secret information. It can be read using the
gstat utility or service, for example. However, for working with that name from a program it was desirable to
access the key name using the API call Attachment::getInfo(). Hence, this facility is now provided via
the information item fb_info_crypt_key.
Implemented by A. Peshkov
~ ~ ~
(CORE-5704) Some clauses of the ALTER DATABASE statement require updating of the single row in RDB
$DATABASE: SET DEFAULT CHARACTER SET, SET LINGER, DROP LINGER. Others, such as BEGIN|END
BACKUP, ENCRYPT, DECRYPT, et al., do not need to touch that record.
In previous versions, to prevent concurrent instances of ALTER DATABASE running in parallel transactions, the
engine would run an update on the RDB$DATABASE record regardless of the nature of clauses specified by
the user. Hence, any other transaction that read the RDB$DATABASE record in READ COMMITTED NO
RECORD VERSION mode would be blocked briefly, even by a “dummy update” that in fact did not update
the record.
1
General Notes
In some cases, such as with an ALTER DATABASE END BACKUP the blockage could last 10 minutes or more.
A user would seem to be unable to connect to the database with isql, for example, while ALTER DATABASE
END BACKUP was running. In fact, isql would connect successfully, but it would read RDB$DATABASE
immediately after attaching, using a READ COMMITTED NO RECORD VERSION WAIT transaction and then just
wait until the work of ALTER DATABASE END BACKUP was committed.
From this sub-release forward, the update of the RDB$DATABASE record is avoided when possible and an
implicit lock is placed to prevent concurrent runs of the ALTER DATABASE statement.
Implemented by V. Khorsun
~ ~ ~
(CORE-5676) All queries that are semantically the same should have the same plan. However, until
now, the optimizer understood only an explicit reference inside an ORDER BY clause and would ignore sorts
derived from equivalent expressions. Now, it will consider equivalence classes for index navigation. Refer to
the Tracker ticket for an example.
Implemented by D. Yemanov
~ ~ ~
implemented by V. Khorsun
~ ~ ~
(CORE-5660) Flushing a large number of dirty pages has been made faster.
Implemented by V. Khorsun
~ ~ ~
(CORE-5648) Measures have been taken to avoid serialization of isc_attach_database calls issued
by EXECUTE STATEMENT.
Implemented by V. Khorsun
~ ~ ~
(CORE-5629) Output from gstat now includes the date and time of analysis.
implemented by A. Peshkov
~ ~ ~
(CORE-5614) The merge stage of a physical backup stage could run too long, especially with huge page
cache. Changes have been made to reduce it.
Implemented by V. Khorsun
~ ~ ~
(CORE-5610) Message “Error during sweep: connection shutdown” now provides information about the
database that was being swept.
2
General Notes
Implemented by A. Peshkov
~ ~ ~
(CORE-5602) Improvement in performance of ALTER DOMAIN when the domain has many dependencies.
Implemented by V. Khorsun
~ ~ ~
(CORE-5601) Compression details and encryption status of the connection (fb_info_conn_flags) have
been added to the getInfo() API call. For more information see notes in the API chapter.
(CORE-5543) Restoring a pre ODS 11.1 database now correctly populates RDB$RELATION_TYPE
field in the metadata.
implemented by D. Yemanov
~ ~ ~
(CORE-4913) Speed of backup with nBackup when directed to NAS over SMB protocol has been improved.
~ ~ ~
(CORE-3295) The optimizer can now estimate the actual record compression ratio.
Implemented by D. Yemanov
~ ~ ~
Sub-release V.3.0.2
Bugs reported and fixed prior to the v.3.0.2 release are listed HERE.
One important bug fix addresses a serious security vulnerability present in all preceding Firebird releases and
sub-releases.
Warning
The exploit is available to authenticated users only, somewhat limiting the risks. However, it is strongly rec-
ommended that any previous installation be upgraded to this one without delay.
New Feature
(CORE-4563) Support was added for fast/low-latency “TCP Loopback Fast Path” functionality introduced
in Windows 8 and Server 2012.
This feature is said to improve the performance of the TCP stack for local loopback connections, by short-
circuiting the TCP stack for local calls. The details of the feature can be found in this Microsoft Technet blog.
3
General Notes
Implemented by V. Khorsun
Improvements
The following improvements appear in this sub-release:
(CORE-5475) IMPROVEMENT: It is now possible to filter out info and warnings from the trace log.
implemented by V. Khorsun
~ ~ ~
(CORE-5442) IMPROVEMENT: Enhanced control capability when sharing the database crypt key between
Superserver attachments.
implemented by A. Peshkov
~ ~ ~
(CORE-5441) IMPROVEMENT: The physical numbers of frequently used data pages are now cached
to reduce the number of fetches of pointer pages.
implemented by V. Khorsun
~ ~ ~
(CORE-5434) IMPROVEMENT: A read-only transaction will no longer force write the Header\TIP page
content to disk immediately after a change. This improvement gives a significant performance gain where there
are numerous light read-only transactions. At this stage, it affects only servers in SS mode. For CS and SC it is
more complex to implement and should appear in Firebird 4.0.
implemented by V. Khorsun
~ ~ ~
(CORE-5374) IMPROVEMENT: The database name was made available to an encryption plug-in.
implemented by A. Peshkov
~ ~ ~
implemented by M. A. Popa
~ ~ ~
implemented by V. Khorsun
~ ~ ~
(CORE-5204) IMPROVEMENT: The Linux code is now built with --enable-binreloc and an option
was included in the installer script to install in locations other than /opt/firebird.
4
General Notes
implemented by A. Peshkov
~ ~ ~
(CORE-4486) IMPROVEMENT: For Trace, a filter has been provided to INCLUDE / EXCLUDE errors
by their mnemonical names.
implemented by V. Khorsun
~ ~ ~
implemented by A. Peshkov
~ ~ ~
(CORE-3637) IMPROVEMENT: A port was done and tested for Linux on the ancient Motorola 680000
CPU platform to satisfy some requirement from Debian.
implemented by A. Peshkov
~ ~ ~
(CORE-1095) IMPROVEMENT: Support has been added to enable SELECT expressions to be valid
operands for the BETWEEN predicate.
implemented by D. Yemanov
~ ~ ~
Sub-release V.3.0.1
Bugs reported and fixed prior to the v.3.0.1 release are listed HERE.
implemented by A. Peshkov
~ ~ ~
implemented by A. Peshkov
~ ~ ~
5
General Notes
~ ~ ~
(CORE-5216) IMPROVEMENT: Line and column numbers (location context) are now provided for
runtime errors raised inside EXECUTE BLOCK.
implemented by D. Yemanov
~ ~ ~
(CORE-5205) IMPROVEMENT: A switch was added to build POSIX binaries with a built-in libtommath
library.
implemented by A. Peshkov
~ ~ ~
(CORE-5201) IMPROVEMENT: gbak now returns a non-zero result code when restore fails on creating
and activating a deferred user index.
implemented by A. Peshkov
~ ~ ~
(CORE-5167) IMPROVEMENT: Implicit conversion between Boolean and string is now done automati-
cally when a string for 'true' or 'false' is used as a value in an expression. Case-insensitive. Not valid when used
with a Boolean operator—IS, NOT, AND or OR; not available for UNKNOWN.
~ ~ ~
Bug Reporting
Bugs fixed since the release of v.3.0.0 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 hasn't 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. Include reproducible test data in your report and post it to our Tracker.
2. You are warmly encouraged to make yourself known as a field-tester of this pre-release by subscribing to
the field-testers' list and posting the best possible bug description you can.
3. If you want to start a discussion thread about a bug or an implementation, please do so by subscribing to the
firebird-devel list. In that forum you might also see feedback about any tracker ticket you post regarding
this Beta.
6
General Notes
Documentation
You will find all of the README documents referred to in these notes—as well as many others not referred to
—in the doc sub-directory of your Firebird 3.0 installation.
7
Chapter 2
Alongside these aims came new strategies to improve performance, query optimization, monitoring and scal-
ability and to address the demand for more security options. A number of popular features were introduced
into the SQL language, including the long-awaited support for the Boolean data type and the associated logical
predications.
Sub-Releases
Details of improvements and links to bug fixes in sub-releases can be found in the General Notes chapter.
Summary of Features
The following list summarises the features and changes, with links to the chapters and topics where more detailed
information can be found.
Note
The previous aliases.conf is replaced by databases.conf, now including not just aliases for
databases but also (optionally) configuration parameters to enable configuration of databases and/or alter-
native security databases individually.
The changes are described in more detail in the chapter Changes in the Firebird Engine.
Tracker: CORE-775
Implemented by V. Khorsun
8
New In Firebird 3.0
Object-oriented C++ APIs enable external code routines to plug in and run safely inside Firebird engine
space, including (but not limited to):
• Eventually, plug-in support for stored procedures, triggers and functions written in Java, C++, Object-
Pascal, etc.
“Per-Database” Configuration
Custom configuration at database level can now be achieved with formal entries in databases.conf
(formerly aliases.conf).
Note
The flag MON$SEC_DATABASE was added to the monitoring table MON$DATABASE to assist in
determining what type of security database is used—Default, Self or Other.
UPDATE ATABLE
SET MYBOOL = (COLUMN1 IS DISTINCT FROM COLUMN2)
IDENTITY type, spawning unique identifiers for the defined column from an internal generator. For details,
see IDENTITY-Style Column.
9
New In Firebird 3.0
DDL Triggers
Now, triggers can be written to execute when database objects are modified or deleted. A typical use is to
block unauthorised users from performing these tasks.
For details, refer to DDL Triggers.
Statistical functions
A suite of statistical functions returning values for a variety of variance, standard deviation and linear re-
gression formulae. See Statistical Functions.
Scrollable Cursors
The query engine now supports bi-directional (“scrollable”) cursors, enabling both forward and backward
navigation in PSQL and in DSQL with support from the API. See Scrollable (Bi-directional) Cursor Support.
IPv6 Support
Firebird 3 can use IPv6 connections on both client and server sides. See the notes for the new configuration
parameter IPv6V6Only.
10
Chapter 3
Changes in the
Firebird Engine
In Firebird 3, the remodelling of the architecture that was begun in v.2.5 was completed with the implementation
of full SMP support for the Superserver model. In the new scheme, it is possible to configure the execution
model individually per database.
Remodelled Architecture
Dmitry Yemanov
The remodelled architecture integrates the core engine for Classic/Superclassic, Superserver and embedded
models in a common binary. The cache and lock behaviours that distinguish the execution models are now
determined externally by the settings in the new configuration parameter ServerMode. The connection method
is determined by the order and content of another parameter, Providers and the connection protocol that is
deduced at run-time from the connection string supplied when a client requests an attachment.
The parameters for configuring the architecture are specified globally (in firebird.conf). Providers can
be overridden specifically for a database (in databases.conf).
Note
databases.conf is the old aliases.conf from previous versions, with a new name. In Firebird 3, the role
of this file involves (potentially) much more than being just a lookup for database file paths. For more details
about what can be configured at database level, refer to the chapter Configuration Additions and Changes.
11
Changes in the Firebird Engine
Server Modes
Providers
The providers are more or less what we traditionally thought of as the methods used to connect a client to a
server, that is to say, across a network, host-locally, via the local loopback (“localhost”) or by a more direct
local connection (the old libfbembed.so on POSIX, now implemented as the plug-in library libEngine1
2.so; on Windows, engine12.dll; on MacOSX, engine12.dylib).
#Providers = Remote,Engine12,Loopback
• In databases.conf, one or more providers can be blocked by pasting the line from firebird.conf,
uncommenting it, and deleting the unwanted provider[s].
12
Changes in the Firebird Engine
Although a key feature of Firebird 3, the Providers architecture is not new. Providers existed historically in
Firebird's predecessors and, though well hidden, are present in all previous versions of Firebird. They were
introduced originally to deal with a task that has been performed since then by “interface layers” such as ODBC,
ADO, BDE and the like, to enable access to different database engines using a single external interface.
Subsequently, this Providers architecture (known then as Open Systems Relational Interface, OSRI) also showed
itself as very efficient for supporting a mix of old and new database formats—different major on-disk structure
versions—on a single server having mixed connections to local and remote databases.
The providers implemented in Firebird 3 make it possible to support all these modes (remote connections,
databases with differing ODS, foreign engines) as well as chaining providers. Chaining is a term for a situation
where a provider is using a callback to the standard API when performing an operation on a database.
The Components
The main element of the Providers architecture is the y-valve. On the initial attach or create database
call y-valve scans the list of known providers and calls them one by one until one of them completes the requested
operation successfully. For a connection that is already established, the appropriate provider is called at once
with almost zero overhead.
Let's take a look at some samples of y-valve operation when it selects the appropriate provider at the attach
stage. These use the default configuration, which contains three providers:
• Loopback (force network connection to the local server for <database name> without an explicit network
protocol being supplied).
The typical client configuration works this way: when one attaches to a database called RemoteHost:dbname
(TCP/IP syntax) or \\RemoteHost\dbname (NetBios) the Remote provider detects explicit network protocol
syntax and, finding it first in the Provider list, redirects the call to RemoteHost.
When <database name> does not contain a network protocol but just the database name, the Remote provider
rejects it and the Engine12 provider comes to the fore and tries to open the named database file. If it succeeds,
we get an embedded connection to the database.
Note
A special “embedded library” is no longer required. To make the embedded connection, the standard client
loads the appropriate provider and becomes an embedded server.
Failure Response
But what happens if the engine returns an error on an attempt to attach to a database?
• If the database file to be attached to does not exist there is no interest at all.
• An embedded connection may fail if the user attaching to it does not have enough rights to open the database
file. That would be the normal case if the database was not created by that user in embedded mode or if he
was not explicitly given OS rights for embedded access to databases on that box.
13
Changes in the Firebird Engine
Note
Setting access rights in such a manner is a requirement for correct Superserver operation.
• After a failure of Engine12 to access the database, the Loopback provider is attempted for an attach. It is
not very different to Remote except that it tries to access the named database <dbname> on a server running
a TCP/IP local loopback.
On Windows, XNET is tried first, then TCP/IP loopback (with localhost: prepended to <dbname>), then
Named Pipes (NetBEUI) loopback (with \\.\ prepended). The server may be started with XNET (or any other
protocol) disabled, so we try all the options. On POSIX only TCP/IP protocol is supported, other options
are not available
If the attachment succeeds, a remote-like connection is established with the database even though it is located
on the local machine.
Other Providers
Use of providers is not limited to the three standard ones. Firebird 3 does not support pre-ODS 12 databases.
Removing support for old formats from the engine helps to simplify its code and gain a little speed. Taking into
account that this speed gain sometimes takes place in performance-critical places, like searching a key in an
index block, avoiding old code and related branches really does make Firebird fly faster.
Nevertheless, the Providers architecture does make it possible to access old databases when changing to a higher
version of Firebird. A suitable provider may be considered for inclusion in a later sub-release.
Custom Providers
A strong feature of the Providers architecture is ability for the deployer to add his own providers to the server,
the client, or both.
So what else might be wanted on a client, other than a remote connection? Recall Provider chaining that was
mentioned earlier. Imagine a case where a database is accessed via very slow network connection, say something
like 3G or, worse, GPRS. What comes to mind as a way to speed it up is to cache on the client some big tables that
rarely change. Such systems were actually implemented but, to do it, one had to rename fbclient to something
arbitrary and load it into its own library called fbclient, thus making it possible to use standard tools to access
the database at the same time as caching required tables. It works but, as a solution, it is clearly not ideal.
With the Providers architecture, instead of renaming libraries, one just adds a local caching provider which can
use any method to detect connections to it (something like a cache@ prefix at the beginning of the database
name, or whatever else you choose).
In this example, when the database name cache@RemoteHost:dbname is used, the caching provider accepts
the connection and invokes the y-valve once more with the traditional database name RemoteHost:dbname.
When the user later performs any call to his database, the caching provider gets control of it before Remote
does and, for a locally cached table, can forestall calls to the remote server.
Use of chaining allows a lot of other useful things to be implemented. An example might be MySQL-style
replication at statement level without the need for triggers: just repeat the same calls for the replication host,
perhaps whena transaction is committed. In this case, the chaining provider would be installed on the server, not
the client, and no modification of the command line would be needed.
14
Changes in the Firebird Engine
Note
To avoid cycling when performing a callback to y-valve at attach time, such a provider can modify the list of
providers using the isc_dpb_config parameter in the DPB. The same technique may be used at the
client, too.
The ability to access foreign database engines using providers should not be overlooked, either. It might seem
strange to consider this, given the number of tools available for this sort of task. Think about the ability to
access other Firebird databases using EXECUTE STATEMENT, that became available in Firebird 2.5. With
a provider to ODBC or other common tool to access various data sources it is within reach to use EXECUTE
STATEMENT to get direct access from procedures and triggers, to data from any database having a driver for
the chosen access tool. It is even possible to have a provider to access some particular type of foreign database
engine if there is some reason to want to avoid the ODBC layer.
Providers Q & A
Q. Interfaces and providers are probably very good, but I have an old task written using plain API functions and
for a lot of reasons I can't rewrite it in the near future. Does it mean I will have problems migrating to Firebird 3?
• A. Definitely no problems. The old API is supported for backward compatibility in Firebird 3 and will be
supported in future versions as long as people need it.
• A. The functional API is implemented as a very thin layer over interfaces. Code in most cases is trivial:
convert passed handles to pointers to interfaces—hitherto referred to as “handle validation”—and invoke the
appropriate function from the interface.
Functions that execute an SQL operation and fetch data from it are one place where coding is a little more
complex, involving the SQLDA construct. The data moves related to the SQLDA have always created an
overhead. The logic between the new and old APIs does not add significantly to that old overhead.
15
Changes in the Firebird Engine
Local connection is implied if <host> is omitted. Depending on settings, platform and Firebird version, it
could be performed via either the embedded engine, XNET (shared memory) protocol or TCP/IP localhost
loopback.
Examples
192.168.0.11:/db/mydb.fdb
192.168.0.11:C:\db\mydb.fdb
myserver:C:\db\mydb.fdb
localhost:/db/mydb.fdb
192.168.0.11:mydb
myserver:mydb
localhost:mydb
192.168.0.11/3051:C:\db\mydb.fdb
192.168.0.11/3051:mydb
myserver/3051:/db/mydb.fdb
localhost/3051:/db/mydb.fdb
myserver/3051:mydb
localhost/3051:mydb
192.168.0.11/fb_db:C:\db\mydb.fdb
192.168.0.11/fb_db:mydb
localhost/fb_db:/db/mydb.fdb
myserver/fb_db:/db/mydb.fdb
myserver/fb_db:mydb
localhost/fb_db:mydb
\\myserver\C:\db\mydb.fdb
\\myserver@fb_db\C:\db\mydb.fdb
Local connection:
/db/mydb.fdb
C:\db\mydb.fdb
mydb
16
Changes in the Firebird Engine
INET resolves to TCP/IP, WNET to Named Pipes, while XNET surfaces the old “Windows local proto-
col” (shared memory).
Examples
inet://192.168.0.11//db/mydb.fdb
inet://192.168.0.11/C:\db\mydb.fdb
inet://myserver/C:\db\mydb.fdb
inet://localhost//db/mydb.fdb
inet://192.168.0.11/mydb
inet://myserver/mydb
inet://localhost/mydb
inet://192.168.0.11:3051/C:\db\mydb.fdb
inet://192.168.0.11:3051/mydb
inet://myserver:3051//db/mydb.fdb
inet://localhost:3051//db/mydb.fdb
inet://myserver:3051/mydb
inet://localhost:3051/mydb
inet://192.168.0.11:fb_db/C:\db\mydb.fdb
inet://192.168.0.11:fb_db/mydb
inet://localhost:fb_db//db/mydb.fdb
inet://myserver:fb_db//db/mydb.fdb
inet://myserver:fb_db/mydb
inet://localhost:fb_db/mydb
wnet://myserver/C:\db\mydb.fdb
wnet://myserver:fb_db/C:\db\mydb.fdb
inet:///db/mydb.fdb
17
Changes in the Firebird Engine
inet://C:\db\mydb.fdb
inet://mydb
wnet://C:\db\mydb.fdb
wnet://mydb
xnet://C:\db\mydb.fdb
xnet://mydb
/db/mydb.fdb
C:\db\mydb.fdb
mydb
Local connection is implied if <host> is omitted. Depending on settings, platform and Firebird version, it could
be performed via either the embedded engine, XNET (shared memory) protocol or TCP/IP localhost loopback.
On the server side, the provider configuration is in the default order Remote, Engine12, Loopback. If the Remote
provider fails to match the connection string because the protocol or host parts are missing, then Engine12, the
embedded engine, handles it as a hostless connection. To connect locally using a specific transport protocol, it
is necessary to specify that protocol:
Note
WNET (named pipes) and XNET (shared memory) protocols are available only on Windows.
Plug-Ins
Alex Peshkov
From version 3 onward, Firebird's architecture supports plug-ins. For a number of predefined points in the
Firebird code, a developer can write his own fragment of code for execution when needed.
A plug-in is not necessarily one written by a third party: Firebird has a number of intrinsic plug-ins. Even some
core parts of Firebird are implemented as plug-ins.
What is a Plug-In?
The term “plug-in” is used to name related but different things:
18
Changes in the Firebird Engine
• a dynamic library, containing code to be loaded as a plug-in (often called a plug-in module) and stored in
the $FIREBIRD/plugins directory;
• code implementing a plug-in. That is slightly different from the library, since a single dynamic library may
contain code for more than one plug-in;
• a plug-in's factory: an object created by that code (pure virtual C++ class), creating instances of the plug-
in at Firebird's request;
Plug-In Types
Firebird's plug-in architecture makes it possible to create plug-ins of predefined types. Each version of Firebird
will have a fixed set of supported plug-in types. To add a further type, the first requirement is to modify the
Firebird code. Our plug-in architecture facilitates both adding new types of plug-ins and simplifying the coding
of the plug-in along generic lines.
To be able to implement a plug-in, say, for encrypting a database on the disk, the Firebird code has to be prepared
for it: it must have a point from which the plug-in is called.
ExternalEngine
Controls the use of various engines, see External Engines.
Trace
The Trace plug-in was introduced in Firebird 2.5, but the way it interacts with the engine was changed in
Firebird 3 to accord with the new generic rules.
Encryption
encrypting plug-ins are for
• network (WireCrypt)
• disk (DbCrypt)
• a helper plug-in (KeyHolder), used to help maintain the secret key(s) for DbCrypt
Provider
Firebird 3 supports providers as a plug-in type.
Technical Details
Plug-ins use a set of special Firebird interfaces. All plug-in-specific interfaces are reference counted, thus putting
their lifetime under specific control. Interfaces are declared in the include file plug-in.h. A simple example
for writing a plug-in module can be found in DbCrypt_example.
19
Changes in the Firebird Engine
Note
The example does not perform any actual encryption, it is just a sample of how to write a plug-in. Complete
instructions for writing plug-ins are not in scope for this document.
Features of a Plug-In
• You can write a plug-in in any language that supports pure virtual interfaces. Interface declarations will need
to be written for your language if they are missing.
• As with UDFs, you are free to add any reasonable code to your plug-in—with emphasis on reasonable. For
example, prompting for user input at the server's console from a plug-in is hardly “reasonable”!
• Calling the Firebird API from your plug-in is OK, if needed. For example, the default authentication server
and user manager use a Firebird database to store accounts.
• Firebird provides a set of interfaces to help with configuring your plug-ins. It is not obligatory to use them,
since the plug-in code is generic and can employ any useful method for capturing configuration information.
However, using the standard tools provides commonality with the established configuration style and should
save the additional effort of rolling your own and documenting it separately.
Configuring Plug-ins
The plug-ins to be loaded for each plug-in type are defined in the main configuration file, firebird.conf,
usually with defaults. The ones defined in Firebird 3 are discussed in the chapter entitled “Configuration Ad-
ditions and Changes”. In summary, the set that provides normal operation in the server, client and embedded
cases consists of:
• UserManager = Srp
• TracePlugin = fbtrace
• Providers = Remote,Engine12,Loopback
• WireCryptPlugin = Arc4
Note
If you want to add other plug-ins, they must be cited in firebird.conf. Apart from other considerations, this
requirement acts as a security measure to avoid loading unknown code.
20
Changes in the Firebird Engine
Taking the entry TracePlugin = fbtrace as an example, what does the value fbtrace signify? In a trivial case,
it can indicate the name of a dynamic library but the precise answer is more complicated.
As mentioned earlier, a single plug-in module may implement more than one plug-in. In addition, a single plug-
in may have more than one configuration at once, with a separate plug-in factory created for each configuration.
Each of these three object contexts (module | implementation | factory) has its own name:
• The name of a plug-in implementation is the one given to it by the developer of the plug-in. It is hard-coded
inside the module.
• The name of a factory is, by default, the same as the name of the plug-in implementation's name. It is the
factory name which is actually used in firebird.conf.
In a typical trivial case, a module contains one plug-in that works with just one configuration and all three
names are equal, and no more configuration is needed. An example would be libEngine12.so | Engine12.dll |
Engine12.dylib, that contains the implementation of the embedded provider Engine12. Nothing other than the
record Providers = Engine12 is needed to load it.
For something more complex a file will help you to set up the plug-in factories precisely.
plugins.conf
The file $(root)/plugins.conf has two types of records: config and plugin.
the plugin record is a set of rules for loading land activating the plug-in. Its format is:
When plug-in PlugName is needed, Firebird loads the library LibName and locates the plug-in registered with
the name RegName. The configuration values from the config record ConfName or the config file ConfFile are
passed to the library.
Note
If both ConfName and ConfFile are given, then the config record will be used.
If both parameters are missing, the default PlugName is used; except that if the ConfigFile is present and its
name is the same as the module's dynamic library but with a .conf extension, it will be used.
The ConfigFile is expected to use the format Key=Value, in line with other Firebird configuration files.
Config = ConfName
{
Key1 = Value1
21
Changes in the Firebird Engine
Key2 = Value2
...
}
A Sample Setup
Suppose you have a server for which some clients trust the wire encryption from one vendor and others prefer a
different one. They have different licences for the appropriate client components but both vendors use the name
“BestCrypt” for their products.
The situation would require renaming the libraries to, say, WC1 and WC2, since there cannot be two files in
the same directory with the same name. Now, the modules stop loading automatically because neither is called
“BestCrypt” any longer.
Plugin = WC1
{
RegisterName = BestCrypt
}
Plugin = WC2
{
RegisterName = BestCrypt
}
The module names will be automatically set to WC1 and WC2 and found. You can add any configuration info
that the plug-ins need.
Remember to modify firebird.conf to enable both plug-ins for the WireCryptPlugin parameter:
The server will now select appropriate plug-in automatically to talk to the client.
Another sample is distributed with Firebird, in $(root)/plugins.conf, configuring one of the standard
plug-ins, UDR. Because it was written to a use non-default configuration, the module name and one configura-
tion parameter are supplied explicitly.
Plug-Ins Q & A
Q. There are plug-ins named Remote, Loopback, Arc4 in the default configuration, but no libraries with such
names. How do they work?
• A. They are “built-in” plug-ins, built into the fbclient library, and thus always present. Their existence is due
to the old ability to distribute the Firebird client for Windows as a single dll. The feature is retained for cases
where the standard set of plug-ins is used.
• A. Srp implements the Secure Remote Passwords protocol, the default way of authenticating users in Firebird
3. Its effective password length is 20 bytes, resistant to most attacks (including “man in the middle”) and
works without requiring any key exchange between client and server to work.
22
Changes in the Firebird Engine
Arc4 means Alleged RC4 - an implementation of RC4 cypher. Its advantage is that it can generate a unique,
cryptographically strong key on both client and server that is impossible to guess by capturing data transferred
over the wire during password validation by SRP.
The key is used after the SRP handshake by Arc4, which makes wire encryption secure without need to
exchange any keys between client and server explicitly.
• A. Windows SSPI has been in use since Firebird 2.1 for Windows trusted user authentication. Legacy_Auth
is a compatibility plug-in to enable connection by the Firebird 3 client to older servers. It is enabled by default
in the client.
And Yes, it still transfers almost plain passwords over the wire, for compatibility.
On the server it works with security3.fdb just as with a security database from Firebird 2.5 It should be
avoided except in situations where you understand well what you are sacrificing.
To use Legacy_Auth on the server you will need to avert network traffic encryption in firebird.conf
by reducing the default Required setting for the WireCrypt parameter, either
WireCrypt = Enabled
or
WireCrypt = Disabled
Q. How can I find out what the standard Authentication and User Manager plug-ins are?
External Engines
Adriano dos Santos Fernandes
The UDR (User Defined Routines) engine adds a layer on top of the FirebirdExternal engine interface with the
purpose of
• establishing a way to hook external modules into the server and make them available for use
• creating an API so that external modules can register their available routines
• making instances of routines “per attachment”, rather than dependent on the internal implementation details
of the engine
External Names
An external name for the UDR engine is defined as
23
Changes in the Firebird Engine
The <module name> is used to locate the library, <routine name> is used to locate the routine registered by
the given module, and <misc info> is an optional user-defined string that can be passed to the routine to be
read by the user.
Module Availability
Modules available to the UDR engine should be in a directory listed by way of the path attribute of the corre-
sponding plugin_config tag. By default, a UDR module should be on <fbroot>/plugins/udr, in accordance with
its path attribute in <fbroot>/plugins/udr_engine.conf.
The user library should include FirebirdUdr.h (or FirebirdUdrCpp.h) and link with the udr_engine library. Rou-
tines are easily defined and registered, using some macros, but nothing prevents you from doing things manually.
Note
A sample routine library is implemented in examples/udr, showing how to write functions, selectable pro-
cedures and triggers. It also shows how to interact with the current attachment through the legacy API.
Scope
The state of a UDR routine (i.e., its member variables) is shared among multiple invocations of the same routine
until it is unloaded from the metadata cache. However, it should be noted that the instances are isolated “per
session”.
Character Set
By default, UDR routines use the character set that was specified by the client.
Note
In future, routines will be able to modify the character set by overriding the getCharSet method. The chosen
character set will be valid for communication with the old Firebird client library as well as the communications
passed through the FirebirdExternal API.
Syntax Pattern
24
Changes in the Firebird Engine
Examples
How it Works
The external names are opaque strings to Firebird. They are recognized by specific external engines. External
engines are declared in configuration files, possibly in the same file as a plug-in, as in the sample UDR library
that is implemented in $(root)/plugins.
external_engine = UDR {
plugin_module = UDR_engine
}
plugin_module = UDR_engine {
filename = $(this)/udr_engine
plugin_config = UDR_config
}
plugin_config = UDR_config {
path = $(this)/udr
}
When Firebird wants to load an external routine (function, procedure or trigger) into its metadata cache, it gets
the external engine through the plug-in external engine factory and asks it for the routine. The plug-in used is
the one referenced by the attribute plugin_module of the external engine.
Note
Depending on the server architecture (Superserver, Classic, etc) and implementation details, Firebird may get
external engine instances “per database” or “per connection”. Currently, it always gets instances “per database”.
25
Changes in the Firebird Engine
Optimizer Improvements
Dmitry Yemanov
Hash/merge joins for non-field (DBKEY or derived expression) equalities are now allowed.
The optimizer now considers the ORDER BY optimization when making its decision about join order.
Other Optimizations
Vlad Khorsun
Data pages are now allocated as a group of sequential ordered pages (extents).
The main database file extends faster when physical backup state changes from stalled to merge.
Linux systems that support “fast file growth” can now use it.
Attachments no longer block others when the allocation table is read for the first time.
Contention has been reduced for the allocation table lock while database is in stalled physical backup state.
Further improvements were made to Firebird's network protocol, providing a denser data stream and better
prefetch logic. The following improvements were implemented:
1. The full length of a field whose value is NULL is no longer sent over the wire. (Tracker item CORE-2897).
NULL flags (4 bytes per field) are replaced with a bitmap and only these flags are transmitted, in the bitmap.
This improvement is available for the DSQL API only, so gbak does not benefit from this improvement,
as it uses a lower level BLR API.
26
Changes in the Firebird Engine
2. The prefetch (batch receive) algorithm is now aware of variable-length messages, so that VARCHARs and
NULLs may reduce the transmitted message size, allowing more rows to be transmitted in each batch.
Acknowledgement
This work was sponsored by donations collected at the 9th Firebird Developers' Day conference in Brazil.
Miscellaneous Improvements
Miscellaneous engine improvements include.-
(CORE-4439) :: Maximum connections (FD_SETSIZE) on Windows Superserver and Superclassic was raised
from 1024 to 2048.
(CORE-3881) :: The error reported for index/constraint violations has been extended to include the problematic
key value.
A silly message sent by the parser when a reference to an undefined object was encountered was replaced with
one that tells it like it really is.
27
Changes in the Firebird Engine
A pseudocolumn named RDB$RECORD_VERSION returns the number of the transaction that created the cur-
rent record version.
It is retrieved the same way as RDB$DB_KEY, i.e., select RDB$RECORD_VERSION from aTable where...
systemd init scripts are available in Firebird 3 POSIX installers. See Tracker ticket CORE-4085.
28
Chapter 4
Changes to the
Firebird API and ODS
Note
A legacy provider for databases with ODS 8 to 11.2 is planned for a future sub-release.
Implementation ID is Deprecated
Alex Peshkov
The Implementation ID in the ODS of a database is deprecated in favour of a new field in database headers
describing hardware details that need to match in order for the database to be assumed to have been created by
a compatible implementation.
The old Implementation ID is replaced with a 4-byte structure consisting of hardware ID, operating system ID,
compiler ID and compatibility flags. The three ID fields are just for information: the ODS does not depend upon
them directly and they are not checked when opening the database.
The compatibility flags are checked for a match between the database and the engine opening it. Currently we
have only one flag, for endianness. As previously, Firebird will not open a database on little-endian that was
created on big-endian, nor vice versa.
# ./gstat -h employee
Database “/usr/home/firebird/trunk/gen/Debug/firebird/examples/empbuild/employee.fdb”
Database header page information:
..............
Implementation HW=AMD/Intel/x64 little-endian OS=Linux CC=gcc
..............
29
Changes to the Firebird API and ODS
Historically, transaction ID space was limited to 231 transactions, counted from the time the database was created.
After that point, the database becomes unavailable until backup and restore is performed to reset the transaction
ID counter back to zero. Initially in Firebird 3.0, the transaction ID space was raised to 232 transactions, doubling
the database up-time without backup and restore.
This improvement request is about shifting that limit even further, with the introduction of 48-bit internal trans-
action IDs that are publicly (via the API and the MON$ tables) represented as 64-bit numbers. This makes the
new limit roughly equal to 2.8 * 1014 transactions. Later, it could be extended up to the 263 limit.
The implemented solution has no additional storage overhead until the transaction counters grow beyond the
232 boundary.
System Tables
30
Changes to the Firebird API and ODS
RDB$SYSTEM_FLAG
Claudio Valderrama C.
CORE-2787.
RDB$TYPES
Dmitry Yemanov
Missing entries were added to RDB$TYPES. They describe the numeric values for these columns:
Monitoring Tables
Dmitry Yemanov
Prior to Firebird 3.0, the network address of remote clients were reported in MON$ATTACHMENTS.MON
$REMOTE_ADDRESS and RDB$GET_CONTEXT('SYSTEM', 'CLIENT_ADDRESS'). For TCP/IP protocol
(a.k.a. INET), it contained a TCPv4 dot-separated address. For Named Pipes (a.k.a. WNET, NetBeui) protocol,
it was always NULL. For shared memory (aka XNET) protocol, it contained the local host name.
Starting with Firebird 3.0, the network address of a remote client contains the TCP/IP port number of the remote
client, separated with a slash:
31
Changes to the Firebird API and ODS
<IP address>/<port>
The port number is also retrieved via the new built-in context variable RDB$GET_CONTEXT('SYSTEM',
'CLIENT_PORT').
The host name is also reported now, in the new column MON$REMOTE_HOST.
Alert
The WNET (Named Pipes/Netbeui) protocol should be considered as deprecated. It is likely to be abandoned
in a future version.
Per-table performance counters have been added to all of the monitoring tables. See Tracker CORE-4564.
MON$ATTACHMENTS
MON$DATABASE
• Security database type (MON$SEC_DATABASE) flag added. Value will be one of Default/Self/Other. See
Tracker CORE-4729.
MON$STATEMENTS
Note
32
Changes to the Firebird API and ODS
The new public API can be also used inside user-defined routines (UDR, q.v.) for callbacks inside the engine,
allowing a UDR to select or modify something in the database, for example.
The main difference between the new API and the legacy one is that UDRs can query and modify data in the
same connection or transaction context as the user query that called that UDR. It is now possible to write external
triggers and procedures, not just external functions (UDFs).
• High on the list was the limitation of the 16-bit integer pervading the legacy API, encompassing message
size, SQL operator length, BLOB data portions, to name a few examples. While 16-bit was probably adequate
when that old API came to life, in today's environments it is costly to work around.
A trivial solution might be to add new functions that support 32-bit variables. The big downside is the obvious
need to retain support for the old API by having pairs of functions with the same functionality but differing
integer sizes. In fact, we did something like this to support 64-bit performance counters, for no better reason
than being pressed to provide for it without having a more elegant way to implement it.
• Another important reason, less obvious, derives from the era when Firebird's predecessor, InterBase, did
not support SQL. It used a non-standard query language, GDML, to manage databases. Data requests were
transported between client and server using messages whose formats were defined at request compilation
time in BLR (binary language representation). In SQL, the operator does not contain the description of the
message format so the decision was taken to surround each message with a short BLR sequence describing
its format.
The ISC API also has the XSQLDA layer over BLR. The trap with the XSQLDA solution is that it encapsu-
lates both the location of the data and their format, making it possible to change location or format (or both)
between fetch calls. Hence, the need for the BLR wrapping in every fetch call—notwithstanding, this potential
capability to change the data format between fetches was broken in the network layer before Firebird existed.
But to support the XSQLDA layer that rides on top of the message-based API that lower level API also has
support sending format BLR at every turn.
This system involving calls processing data through multiple layers is hard to extend and wastes performance;
the SQLDA is not simple to use; the desire to fix it was strong.
• Other reasons—numerous but perhaps less demanding—for changing the API included enhancing the status
vector and optimizing dynamic library loading. Interfaces also make it so much easier and more comfortable
to use the messages API.
The new interfaces are not compatible with COM, deliberately, and the reasons have to do with future perfor-
mance enhancement.
At the centre of the Providers architecture in Firebird 3.0 is the y-valve, which is directed at dispatching API
calls to the correct provider. Amongst the potential providers are older ones with potentially older interfaces. If
we used COM, we would have to call the method IUnknown for each call (including record fetch), just to ensure
33
Changes to the Firebird API and ODS
that the provider really had some newer API method. Along with that comes the likelihood of future additions
to the catalogue of API calls to optimize performance. A COM-based solution does not play well with that.
Firebird interfaces, unlike COM, support multiple versions. The interface version is determined by the total
number of virtual functions it encompasses and is stored as a pointer-size integer at the beginning of the virtual
functions table. This makes it possible for very fast checking of the interface version, since it requires no virtual
call. That is to say, the pointer check has no overhead, unlike COM.
A detailed discussion of all the functions presented by all the interfaces is outside the scope of this overview.
The general schematic looks like this:
The base of the structure is IVersioned. It is the interface that enables a version upgrade. A lot of interfaces
not requiring additional lifetime control are based directly on IVersioned. IMaster is one example already
mentioned. Others include a number of callback interfaces whose lifetimes must match the lifetimes of the
objects from which they were to be used for callback.
Two interfaces deal with lifetime control: IDisposable and IRefCounted. The latter is especially active in the
creation of other interfaces: IPlugin is reference counted, as are many other interfaces that are used by plug-ins.
These include the interfaces that describe database attachment, transaction management and SQL statements.
Not everything needs the extra overhead of a reference-counted interface. For example, IMaster, the main inter-
face that calls functions available to the rest of the API, has unlimited lifetime by definition. For others, the API
is defined strictly by the lifetime of a parent interface; the IStatus interface is non-threaded. For interfaces with
limited lifetimes it is of benefit to have a simple way to destroy them, that is, a dispose() function.
34
Changes to the Firebird API and ODS
Each plug-in has one and only one main interface—IPlugin—which is responsible for basic plug-in function-
ality. In fact, a lot of plugins have only that interface, although that is not a requirement.
Finally, there is IProvider, a kind of “main” plug-in in the Firebird API. IProvider is derived from IPlugin and
must be implemented by every provider. If you want to write your own provider you must implement IProvider.
It is implemented also by the y-valve: it is the y-valve implementation that is returned to the user when the
getDispatcher() function from the master interface is called.
IProvider contains functions enabling creation of an attachment to a database (attach and create) or to the
Services Manager.
Interfaces Q & A
Q. We access new API using IMaster. But how to get access to IMaster itself?
• A. This is done using just the one new API function fb_get_master_interface(). It is exported by the fb-
client library. Also IMaster is passed as a parameter to each plug-in during its registration in the system.
Q. The non-use of COM-based interfaces was said to be to avoid working with IUnknown methods and that
this is done due to performance issues. Instead you have to check the interface version. Why is that faster than
using IUnknown?
• A. As was already mentioned we do not need to execute virtual calls when checking the interface version.
Taking into an account that each virtual call means a reset of the CPU cache, it is an important difference,
especially for the very small calls like getting specific metadata properties from IMetadata.
For creating custom plug-ins and bridges, the relevant interface (API) needs to be implemented in the plug-
in code.
API Improvements
The following improvements to the API should be noted.
• The size of the body of a stored procedure or a trigger can exceed the traditional limit of 32 KB. The theoretical
limit provided by the new API is 4GB. At the moment, as a security measure, a hard-coded limit of 10MB is
imposed. The same limit of 10MB also applies to any user-defined DSQL query.
35
Changes to the Firebird API and ODS
• The total size of all input or output parameters for a stored procedure or a user-defined DSQL query is no
longer limited to the traditional size of (64KB minus overhead). The theoretical limit provided by the new
API is 4GB.
Legacy API
In PSQL, a scrollable cursor can be operated on directly to navigate flexibly from the current row to any anoth-
er row either forwards or backwards. API support is available to make scrollable cursors available to DSQL
applications.
The result set must be opened with the flag IStatement::CURSOR_TYPE_SCROLLABLE explicitly spec-
ified.
Fetch Methods
Moves the cursor's current position to the next row and returns it. If the cursor is empty or already positioned
at the last row, the condition NO_DATA is returned.
Moves the cursor's current position to the prior row and returns it. If the cursor is empty or already positioned
at the first row, the condition NO_DATA is returned.
Moves the cursor's current position to the first row and returns it. If the cursor is empty, the condition NO_DATA
is returned.
Moves the cursor's current position to the last row and returns it. If the cursor is empty, the condition NO_DATA
is returned.
36
Changes to the Firebird API and ODS
Moves the cursor's current position to the specified <position> and returns the located row. If <position> is
beyond the cursor's boundaries, the condition NO_DATA is returned.
Moves the cursor's current position backward or forward by the specified <offset> and returns the located row.
If the calculated position is beyond the cursor's boundaries, the condition NO_DATA is returned.
Notes
1. When a scrolling option is omitted, NO SCROLL is implied (i.e., the cursor is opened as forward-only).
This means that only the fetchNext() API call can be used. Other fetch methods will return an error.
2. Scrollable cursors are internally materialized as a temporary record set, thus consuming memory/disk
resources, so this feature should be used only when really necessary.
A new, much requested feature was added to gbak verbose output: optional run-time statistics. Read about it
here. The feature is fully supported in the Services API with a new item in the SPB (Services Parameter Block),
#define isc_spb_bkp_stat 15
Usage
where <len> (2 bytes) indicates the length of the following string parameter, and <string> (1-4 bytes) is a
string consisting of one character per statistics item.
Include expected and actual string length in the error message for string overflows (SQLCODE -802).
37
Changes to the Firebird API and ODS
More details in the error message "wrong page type", i.e., identifying expected and encountered page types by
name instead of numerical type.
An option was added to the API function isc_database_info() to return the number of free pages in a
database. See CORE-1538.
Compression details and encryption status of a connection (fb_info_conn_flags) have been added to the get-
Info() API call. The data stored in the information block are of type integer in network format, accessible
as isc_vax_integer.
The Services API now includes the tag isc_spb_prp_nolinger, for example (in one line):
For information regarding LINGER, see the write-up in the DDL chapter.
In previous Firebird versions, a serverless protocol known as “Windows Local” was available to local clients
connecting to Superserver on a Windows platform, using the XNET subsystem. A typical connection string
looked like this:
c:\Program Files\Firebird_2_5\examples\empbuild\employee.fdb
Under the new unified server, that form of connection attempts to load an embedded server. It is no longer valid
for a serverless client connection to Superserver. If you try, you will get a refusal message to the effect “File is in
38
Changes to the Firebird API and ODS
use by another process”. This is not a bug. Since Superserver clients share resources, another server (in this case,
an embedded server) cannot attach a client to the same database that Superserver has any clients attached to.
However, all is not lost. The XNET subsystem can still do local client sessions for Superserver. You just need
a more elaborate connection string now. You have a few choices:
• this one is the former “Windows local”, using the XNET subsystem and shared memory for a (nominally)
serverless connection:
xnet://alias-or-path-to-database
xnet://c:\Program Files\Firebird_3_0\examples\empbuild\employee.fdb
or using an alias:
xnet://employee
inet://host:port/alias-or-path-to-database
inet4://host:port/alias-or-path-to-database
This option was added in v.3.0.1. See also the configuration parameter IPv6V6Only.
wnet://host:port/alias-or-path-to-database
inet://alias-or-path-to-database
wnet://alias-or-path-to-database
39
Changes to the Firebird API and ODS
Database validation enables low-level checks of the consistency of on-disk structures and even to fix some
minor corruptions. The recommended procedure for any valuable database is for the DBA to validate a database
periodically to ensure it is healthy.
Exclusive access to the database is required: any kind of concurrent access is forbidden during validation. Some-
times, blocking user access could be a major hold-up, especially if the database is large and complex.
Online validation is a new feature that allows some consistency checks to be performed without exclusive access.
While a table (and\or its index) is undergoing validation, user attachments are allowed to read this table. Any
attempt to change data (INSERT\UPDATE\DELETE) will wait until validation finishes or, depending on the
lock timeout of the user transaction, will return a lock timeout error.
Any kind of garbage collection on the table or its indexes is disabled whilst it is undergoing validation:
• background and cooperative garbage collection will just skip this table
When online validation starts to check a table, it acquires a couple of locks to prevent concurrent modifications
of its data:
Both locks are acquired using a user-specified lock timeout. An error is reported for any lock request that fails
and that table is skipped.
Once the locks are acquired, the table and its indexes are validated in the same way as a full validation does it.
The locks are released when it completes and the whole procedure is repeated for the next table.
Online validation is implemented as a Firebird service and is accessed through the Services API. Thus, it cannot
be run from the gfix utility.
Action:
isc_action_svc_validate
40
Changes to the Firebird API and ODS
Parameters:
isc_spb_dbname :
database file name, string, mandatory
isc_spb_val_tab_incl, isc_spb_val_tab_excl,
isc_spb_val_idx_incl, isc_spb_val_idx_excl :
patterns for tables\indices names, string, optional
isc_spb_val_lock_timeout :
lock timeout, integer, optional
Output:
text messages with progress of online validation process
The fbsvcmgr utility has full support for the new service. The syntax is:
where
Usage Notes
• Patterns are regular expressions, processed by the same rules as SIMILAR TO expressions.
• If the pattern for tables is omitted then all user tables will be validated.
• If the pattern for indexes is omitted then all indexes of the appointed tables will be validated.
3. Enclose the whole list in double quotes to avoid confusing the command interpreter
41
Changes to the Firebird API and ODS
Examples
1. Validate all tables in database 'c:\db.fdb' with names starting with 'A'. Indexes are not validated. Lock wait
is not performed.
2. Validate tables TAB1 and TAB2 and all their indexes. Lock wait timeout is 10 seconds (the default):
3. Default behavior of val_XXX options: validate all user tables and their indexes in database 'c:\db.fdb', lock
wait is the default 10 seconds:
Code Improvement
Alex Peshkov
42
Chapter 5
Non-reserved
43
Chapter 6
Configuration
Additions and Changes
The file aliases.conf is renamed to databases.conf. An old aliases.conf from a previous version
can simply be renamed and the new engine will just continue to use it as before. However, databases.conf
can now include some configuration information for individual databases.
Scope of Parameters
Some parameters are marked as configurable per-database or per-connection.
• Per-connection configuration is primarily for client tool use and is done using the DPB parameter
isc_dpb_config or, for Services, the SPB parameter isc_spb_config.
• In the case of Embedded, the DPB can be used to tune per-database entries on first attaching to a database.
Macro Substitution
A number of predefined macros (syntax $(name)) is available for use in the configuration files to substitute for
a directory name:
$(root)
Root directory of Firebird instance
$(install)
Directory where Firebird is installed. $(root) and $(install) are initially the same. $(root) can be overridden
by setting or altering the environment variable FIREBIRD, in which case it becomes different from $(install).
$(this)
Directory where current configuration file is located
$(dir_conf)
Directory where firebird.conf and databases.conf are located
$(dir_secdb)
Directory where the default security database is located
$(dir_plugins)
Directory where plugins are located
44
Configuration Additions and Changes
$(dir_udf)
Directory where UDFs are located by default
$(dir_sample)
Directory where samples are located
$(dir_sampledb)
Directory where sample DB (employee.fdb) is located
$(dir_intl)
Directory where international modules are located
$(dir_msg)
Directory where the messages file (firebird.msg) is located. $(dir_msg) usually should be the same as $(root)
but can be overridden by the environment variable FIREBIRD_MSG.
Tip
Notes
In our pre-built binaries, $(dir_conf) and $(dir_secdb) would normally be the same as $(root) and $(install).
$(dir_plugins), $(dir_udf), $(dir_sample), $(dir_sampledb) and $(dir_intl) are predefined sub-directories inside
$(root).
The build conventions are not “rules” that could be expected to apply in every distribution of Firebird. Dis-
tro-specific Linux packages, for example, each prefer to fit the Firebird components into standard layouts that
comply with their own conventions. As an illustration, user binaries, such as isql might be located in /usr/
bin, server binaries in /usr/sbin, configuration files in /etc/firebird.d and so on. Obviously, $(root)
would then make no sense, even if the $(dir_something) macros still pointed to actual directories.
Includes
One configuration file can be included in another by using an “include” directive, e.g.,
include some_file.conf
A relative path is treated as relative to the enclosing configuration file. So, if our example above is inside /opt/
config/master.conf then our include refers to the file /opt/config/some_file.conf.
Wildcards
The standard wildcards * and ? may be used in an include directive, to include all matching files in undefined
order. For example,
include $(dir_plugins)/config/*.conf
45
Configuration Additions and Changes
Boolean values are expressed as non-zero (true)|zero (false) by default, but you may now use the quoted strings
'y', 'yes' or 'true' instead of a non-zero digit.
“Per-database” Configuration
Custom configuration at database level is achieved with formal entries in databases.conf.
aliasname = /absolute/path/to/database_file
If you are not adding any database-specific configuration directives for an alias, the format is just as it was
before, e.g.,
A slightly more complex format is used for cases where certain non-global parameters are to be targeted at an
indvidual databases. The entry for the database is defined by the alias declaration, as previously. The database-
specific directives are listed below it, within curly brackets.
#
# Directives for MYBIGDB
MYBIGDB = opt/databases/mybigdb.fdb
{
LockMemSize = 32M # We know that MYBIGDB needs a lot of locks
LockHashSlots = 19927 # and a hash table large enough for them
}
Parameters Available
The following parameters can be copy/pasted to databases.conf and used as overrides for specific databas-
es.
46
Configuration Additions and Changes
Engine-related
DatabaseGrowthIncrement DeadlockTimeout DefaultDbCachePages
EventMemSize FileSystemCacheThreshold ExternalFileAccess
GCPolicy LockAcquireSpins LockHashSlots
LockMemSize MaxUnflushedWrites MaxUnflushedWriteTime
SecurityDatabase UserManager
WireCompression WireCrypt WireCryptPlugin
Some parameters can be configured at the client connection via the
DPB/SPB, as an alternative to configuring them in databases.
Client-related
conf. Please refer back to Scope of Parameters at the beginning of
this chapter to understand these differences.
AuthClient Providers
The following parameters can be configured ONLY via the DPB/SPB
ConnectionTimeout DummyPacketInterval IpcName
RemoteAuxPort RemotePipeName RemoteServiceName
RemoteServicePort TCPNoNagle
New Parameters
New parameters added to firebird.conf are:
SecurityDatabase
Defines the name and location of the security database that stores login user names and passwords used by the
server to validate remote connections. By default, in firebird.conf, it is $(root)/security3.fdb. It
can be overridden for a specific database by a configuration in databases.conf.
• Secure remote passwords (Srp), using the plug-in is the default, using the OS-appropriate plug-in (libSrp.
s0 | Srp.dll | Srp.dylib)
47
Configuration Additions and Changes
• On Windows, the Security Support Provider Interface (Sspi) is used when no login credentials are supplied
• Client applications can use legacy authentication (Legacy_Auth) to talk to old servers.
For AuthServer, Srp and Win_Sspi are listed; for AuthClient, Srp, Win_Sspi and Legacy_Auth.
To disable a method, erase the comment marker (#) and remove the unwanted method from the list.
Both parameters can be used in databases.conf. They can both be used in the DPB or the SPB for a con-
nection-specific configuration.
WireCrypt
Sets whether the network connection should be encrypted. It has three possible values: Required | Enabled |
Disabled. The default is set such that encryption is Required for connections coming in to the server and Enabled
for connections outgoing to a server.
To access a server using an older client library and, thus, no encryption, WireCrypt in the server configuration
file should be set to Enabled or Disabled to avert the default Required.
The rules are simple: if one side has WireCrypt = Required and the other sets the parameter to Disabled,
side with WireCrypt=Required rejects the connection and it is not established.
A missing WireCrypt plug-in or encryption key in cases where the channel must be encrypted also thwarts a
connection.
In all other cases, connection is established without encryption if at least one side has WireCrypt = Dis-
abled. In other cases, the encrypted connection is established.
UserManager
Sets the plug-in that will operate on the security database. It can be a list with blanks, commas or semicolons
as separators: the first plug-in from the list is used.
TracePlugin
Specifies the plug-in used by Firebird's Trace facility to send trace data to the client app or audit data to the
log file.
WireCryptPlugin
A wire-crypt plug-in is used to encrypt and decrypt data transferred over the network.
48
Configuration Additions and Changes
The installation default Arc4 implies use of an Alleged RC4 plug-in. The configured plug-in, which requires a
key generated by the configured authentication plug-in, can be overridden in the API for a specific connection
via the DPB or the SPB.
Tip
For information about configuring plug-ins, see Configuring Plug-ins in the Engine chapter.
KeyHolderPlugin
This parameter would represent some form of temporary storage for database encryption keys. Nothing is im-
plemented as a default plug-in but a sample Linux plug-in named libCryptKeyHolder_example.so can
be found in /plugins/.
Providers
List of allowed transports for accessing databases, discussed in the Engine chapter.
ServerMode
Determines the execution mode of the server (“server model”). Discussed in the Engine chapter.
RemoteAccess
Parameter in firebird.conf and databases.conf provides an efficient, configurable replacement for
hard-coded rules limiting access to security3.fdb. It can also be used to configure limited remote access
to any other database, including non-default security databases.
By default RemoteAccess is enabled for all databases except the security database. If you intend using more
than one dedicated security database, then disabling remote access to it (or them) via databases.conf is
recommended.
For stricter security, server-wide, you can set RemoteAccess to false in firebird.conf and use entries in
database.conf to re-enable it for specific databases.
WireCompression
Alex Peshkov
The default setting is disabled (= False). Settings and environment must be correct at both server and client for
WireCompression to take effect:
• To enable it at the server side, in firebird.conf and/or databases.conf, change the setting to True
49
Configuration Additions and Changes
• To activate Wirecompression from the client side, pass the appropriate tag in the config item of the DPB
or SPB call:
• Both server and client versions must be Firebird 3 or greater (protocol >=13)
IPv6V6Only
Michael Kubecek
Parameter in firebird.conf only. (TCP ports are created before any connection is established.)
Server
By default, the Firebird server listens on the zero IPv6 address (::) and accepts all incoming connections, whether
IPv4 or IPv6, and IPv6V6Only is set to false (=0). If it is set to true, the server, still listening implicitly or
explicitly on the zero IPv6 address, will accept only IPv6 connections.
Note
A different listening address, either IPv4 or IPv6, can be set using the RemoteBindAddress parameter. If an
IPv4 address or a non-zero IPv6 address is used, the IPv6V6Only directive has no effect.
On POSIX platforms, in Classic mode, the parameters RemoteBindAddress, RemoteServicePort and Remote-
ServiceName are ignored by fbserver, since the listening socket is set up by (x)inetd. The listening ad-
dress and/or port need to be set in the (x)inetd.
Client
The standard text form of an IPv6 address uses the colon character to separate the four groups of digits. In the
connection string, the IPv6 address must be enclosed in square brackets, to resolve the ambiguity with the use
of the colon as the separator between the host IP address and the database path. For example:
connect '[2014:1234::5]:test';
connect '[2014:1234::5]/3049:/srv/firebird/test.fdb';
Notes
For consistency, square brackets can be optionally used around an IPv4 address or a domain name.
If a domain name is used in connection string, all addresses (IPv4 and IPv6) are tried in the order returned by
resolver until a connection is established. If all attempts fail, the client fails to connect.
50
Configuration Additions and Changes
ExternalFileAccess
Entries in the “Restrict” list of the ExternalFileAccess parameter can be used to mangle file names with relative
paths.
Entries in the “Restrict” list were already used to mangle file names with no path component. For example, with
ExternalFileAccess = /opt/extern
The improvement avoids this gap by mangling the file name in accord with the value of the parameter and, if
necessary, creating the missing path components, such as 'dir' in the example above.
RootDirectory
In older version, this parameter provided a superfluous option for recording the file system path to Firebird's
“root” files (firebird.conf, the security database and so on).
LegacyHash
This parameter used to make it possible to use the old security.fdb from Firebird 1.X installations after it
had been subjected to an upgrade script and thence to enable or disable use of the obsolete DES hash encrypting
algorithm. It is no longer supported.
51
Configuration Additions and Changes
OldSetClauseSemantics
This parameter enabled temporary support for an implementation fault in certain sequences of SET clauses in
versions of Firebird prior to v.2.5. It is no longer available.
OldColumnNaming
This parameter temporarily enabled legacy code support for an old InterBase/Firebird 1.0 bug that generated
unnamed columns for computed output which was not explicitly aliased in the SELECT specification. It is no
longer available.
LockGrantOrder
This parameter used to allow the option to have Firebird's Lock Manager emulate InterBase v3.3 lock allocation
behaviour, whereby locks would be granted in no particular order, as soon as soon as they were available, rather
than by the normal order (first-come, first-served). The legacy option is no longer supported.
52
Chapter 7
Security
Security improvements in Firebird 3 include:
CORE-685
Firebird now supports an unlimited number of security databases. Any database may act as a security database
and can be a security database for itself.
Use databases.conf to configure a non-default security database. This example configures /mnt/stor-
age/private.security.fdb as the security database for the first and second databases:
first = /mnt/storage/first.fdb
{
SecurityDatabase = /mnt/storage/private.security.fdb
}
second = /mnt/storage/second.fdb
{
SecurityDatabase = /mnt/storage/private.security.fdb
}
third = /mnt/storage/third.fdb
{
SecurityDatabase = third
}
Note
The value of the SecurityDatabase parameter can be a database alias or the actual database path.
53
Security
Now connect to any database which will be served by the security database you are currently preparing, in order
to create its SYSDBA user:
Database Encryption
Alex Peshkov
CORE-657
With Firebird 3 comes the ability to encrypt data stored in database. Not all of the database file is encrypted:
just data, index and blob pages.
To make it possible to encrypt a database you need to obtain or write a database crypt plug-in.
Note
The sample crypt plug-in in examples/dbcrypt does not perform real encryption, it is merely a sample
of how to go about it.
Secret Key
The main problem with database encryption is how to store the secret key. Firebird provides a helper to transfer
that key from the client but that does not imply that storing the key on a client is the best way: it is no more than
a possible alternative. A very bad option is to keep the key on the same disk as the database.
Encryption Tasks
To separate encryption and key access efficiently, a database crypt plug-in is split into two parts: encryption
itself and the secret key holder. This may be an efficient approach for third-party plug-ins when you want to use
some good encryption algorithm but you have your own secret way to store a key.
Encrypting a Database
Once you have decided on a crypt plug-in and a key, you can encrypt the database with:
The optional KEY argument allows the key name to be passed in the command, if the plug-in requires it.
54
Security
Encryption will start right after this statement commits and will be performed in background. Normal database
activity is not disturbed during encryption.
Monitoring Encryption
During encryption, progress can be monitored using the field MON$CRYPT_PAGE in the pseudo-table MON
$DATABASE. For example:
The example query will output the percentage of encryption completed so far.
You can also watch the database header page using repeated calls to gstat -e.If the database has been en-
crypted, gstat -h can also provide limited information about encryption state.
Decrypting a Database
For Linux, an example plug-in named libDbCrypt_example.so can be found in the /plugins/ sub-
directory.
All of the code related to authentication is plug-in-enabled. Though Firebird performs the generic work, like
extracting authentication data from a network message or putting it into such messages as appropriate, all the
activity related to calculating hashes, storing data in databases or elsewhere, using specific prime numbers and
so on is done by plug-ins.
Firebird 3 has new method of user authentication implemented as a default plugin: secure remote password
(SRP) protocol. Quoting from Wikipedia:
“The SRP protocol creates a large private key shared between the two parties in a manner similar to Diffie-
Hellman key exchange, then verifies to both parties that the two keys are identical and that both sides have
the user's password. In cases where encrypted communications as well as authentication are required, the SRP
protocol is more secure than the alternative SSH protocol and faster than using Diffie-Hellman key exchange
with signed messages. It is also independent of third parties, unlike Kerberos.”
SSH needs key pre-exchange between server and client when placing a public key on the server to make it work.
SRP does not need that. All a client needs are login and password. All exchange happens when the connection
is established.
55
Security
Important
Use of the new authentication method is not compatible with old security databases and passwords from them.
However, an upgrade procedure is available to migrate users from a Firebird 2.x security2.fdb database.
For instructions, see Upgrading a v.2.x Security Database in the Compatibility chapter.
Use of an old security database can be supported with the Legacy_Auth authentication plug-in, but this kills
the security benefits of Firebird 3.
The Firebird 3 client is built to make it possible to talk to old servers with the default configuration.
SSL/TLS Support
CORE-3251
So, the answer to the question “Does Firebird use SSL/TLS for password validation?” is “yes and no”. The “No”
answer comes because, by default, SSL is not used. That is due to a minor licensing incompatibility between
Firebird and OpenSSL, the most popular SSL implementation.
The “Yes” applies because anyone is free to write an authentication plug-in that uses SSL and TLS.
Implementation of SRP in our plugin has increased the password length from 8 bytes to 20 or more. Because of
the use of SHA1 for hashes, maximum security is provided for passwords up to 20 characters in length. Longer
passwords can be used without restriction but there is a remote possibility of hash collisions between passwords
that differ beyond the 20th byte. Just be aware of the possibility that any password longer than 20 characters
password could share the same hash with some shorter password so, theoretically, they could be attacked using
brute force.
A custom SRP plug-in could be built quite easily, using a hash algorithm that would guarantee unique hashes
for longer passwords.
Tip
The increased length limit means the default SYSDBA password in Windows and MacOS installations is the
full 'masterkey' string (9 chars), no longer 'masterke' (8 chars) as in older versions!
Support for the LegacyHash and Authentication parameters in firebird.conf has been dropped. Authentication
is overtaken by an AuthServer parameter in firebird.conf or elsewhere.
56
Security
• User Manager—adds, modifies and deletes users on the server. It is not needed if some external authentication
method, such as Windows trusted authentication, is used.
All three parts are actually separate plug-ins which should be configured separately in firebird.conf. Let's
look at an example of configuring a server to accept connections from old clients. The default setting are:
If we also want to manage the list of users in the old format we must add:
UserManager = Legacy_UserManager
SEC$USER_NAME SEC$PLUGIN
=============================== ===============================
SYSDBA Legacy_UserManager
SYSDBA Srp
QA_USER1 Srp
QA_USER2 Srp
QA_USER3 Srp
QA_USER4 Srp
QA_USER5 Srp
GUEST Srp
SHUT1 Srp
SHUT2 Srp
QATEST Srp
There might well be two users named SYSDBA in such a list, because each user manager has its own SYSDBA.
Notes
• All user management commands can have the USING PLUGIN clause, whose purpose is to enable selection
of a particular UserManager plug-in from the list in firebird.conf.
• The default user manager in firebird.conf is Srp. If you need to manage legacy logins, set it to
Legacy_UserManager, e.g., UserManager = Legacy_UserManager,Srp.
57
Security
CORE-672 ...
All network traffic in Firebird 3 may be optionally encrypted. As with authentication, plug-ins are used for
encrypting and decrypting network traffic.
The default plug-in is arc4 (Alleged RC4). It is eminently possible to write your own crypt plug-in to encrypt
data travelling over the wire. Whatever you use for your plug-in, it is necessary to use the Firebird 3 version
of the fbclient library.
Tip
If you want to use encryption with an authentication plug-in that does not provide the session key and agree to
use some pre-defined key, say, one stored at the client side as a file and on the server in the security database
for that specific client, then make that plug-in inform Firebird that it does have a session key.
Specifications for the key's size, its format, how it is calculated and verified, etc., are not generalised. The key's
format and other details are specific to the wire encryption/decryption plug-in.
In particular, RC4 uses a symmetric key which can have any length, while the key produced by SRP has a
length of 20 bytes. That key is a SHA-1 hash on SRP's session key and some other SRP-related things, such
as user name.
To export a key from your authentication plug-in, use the ServerBlock or the ClientBlock interface. One of these
is always passed to the server/client part of an authentication plug-in. Both have a “newKey” method that returns
a pointer to the CryptKey interface. That interface in turn has the methods setSymmetric and setAsymmetric
for storing the symmetric or asymmetric key in the interface, i.e., exporting that key.
58
Security
Firebird 3 introduces new SQL privileges to map access between users and groups and security objects and
between databases. See Tracker item CORE-1900.
With Firebird now supporting multiple security databases, some new problems arise that could not occur with
a single, global security database. Clusters of databases using the same security database were efficiently sepa-
rated. Mappings provide the means to achieve the same efficiency when multiple databases are using their own
security databases. Some cases require control for limited interaction between such clusters. For example:
• when EXECUTE STATEMENT ON EXTERNAL DATA SOURCE requires some data exchange between
clusters
• when server-wide SYSDBA access to databases is needed from other clusters, using services.
• comparable problems that have existed on Firebird 2.1 and 2.5 for Windows, due to support for Trusted User
authentication: two separate lists of users—one in the security database and another in Windows, with cases
where it was necessary to relate them. An example is the demand for a ROLE granted to a Windows group
to be assigned automatically to members of that group.
The single solution for all such cases is mapping the login information assigned to a user when it connects to a
Firebird server to internal security objects in a database—CURRENT_USER and CURRENT_ROLE.
1. mapping scope—whether the mapping is local to the current database or whether its effect is to be global,
affecting all databases in the cluster, including security databases
2. mapping name—an SQL identifier, since mappings are objects in a database, like any other
3. the object FROM which the mapping maps. It consists of four items:
plug-in name or
the product of a mapping in another database or
use of server-wide authentication or
any method
• The type of that name—user name | role | OS group—depending upon the plug-in that added that name
during authentication
59
Security
Description
Global mapping works best if a Firebird 3 or higher version database is used as the security database. If
you plan to use another database for this purpose—using your own provider, for example—then you should
create a table in it named RDB$MAP, with the same structure as RDB$MAP in a Firebird 3 database and
with SYSDBA-only write access.
Beware!
If global and local mappings of the same name exist then know and make it known that they are different
objects!
• The CREATE, ALTER and CREATE OR ALTER statements use the same set of options. The name (iden-
tifier) of a mapping is used to identify it, as in other DDL command sets.
- an explicit plug-in name means it will work only for that plug-in
- it can use any available plug-in; although not if the source is the product of a previous mapping
- it can be left to use any method, using the asterisk (*) argument
- it can be provided with the name of the database that originated the mapping for the FROM object
Note
• The FROM clause takes a mandatory argument, the type of the object named.
-> When mapping names from plug-ins, type is defined by the plug-in.
-> When mapping the product of a previous mapping, type can be only USER or ROLE.
60
Security
-> If an explicit name is provided, it will be taken into account by this mapping
-> Use the ANY keyword to work with any name of the given type.
• In the TO clause, the USER or ROLE to which the mapping is made must be specified. NAME is optional:
if it is not supplied, the name from the originating mapping is used.
Examples
The examples use the CREATE syntax. Usage of ALTER is exactly the same and the usage of DROP should
be obvious.
1. Enable use of Windows trusted authentication in all databases that use the current security database:
Note
The group DOMAIN_ANY_RID_ADMINS does not exist in Windows, but such a name would be added
by the win_sspi plug-in to provide exact backwards compatibility.
3. Enable a particular user from another database to access the current database with another name:
Important
Database names or aliases will need to be enclosed in double quotes on operating systems that have case-
sensitive file names.
4. Enable the server's SYSDBA (from the main security database) to access the current database. (Assume
that the database is using a non-default security database):
61
Security
5. Ensure users who logged in using the legacy authentication plug-in do not have too many privileges:
Generic mapping is used to set the rule defining the user name under which the user accesses a database when
performing a request from a database using one security database to a database using a different one, or when
server-wide authentication, such as win_sspi, is used. The rule comes into action whenever the Firebird engine
is processing the authentication block associated with a request to connect to a database.
In Firebird 3, an explicit mapping must exist in systems with server-wide “trusted user” authentication enabled,
including Win_Sspi authentication on Windows, in order for the system user's user name to be assigned to the
context variables CURRENT_USER and CURRENT_ROLE.
For creating user names and passwords, the new authentication plug-ins bring a degree of flexibility with regard
to character sets. To make use of international credentials support, it is necessary to use SRP or any other set
of authentication plug-ins that supports the new model.
Advice
Use of the legacy authentication plug-in is not recommended, except where it is necessary for connecting a client
to a server version older than Firebird 3. Legacy authentication has never supported international characters in
user names and passwords. This restriction is unchanged for Firebird 3 legacy authentication.
When writing authentication plug-ins it is unnecessary to be concerned about character sets, since all data ex-
change with the new plug-ins is done using UTF8. Just be prepared to handle user names and passwords that
contain characters beyond the range of the 7-bit ASCII character subset.
62
Security
1. connecting via a Windows text console with the default OEM code page selected
3. running scripts
1. All operating systems except Windows use same the same character set (code page, locale), by default, for
all programs. In Windows, for historical reasons, GUI applications use an ANSI code page, but applications
started on the command-line console emulator use the corresponding OEM code page. As an example, the
Russian version of Windows is uses code page 1251 (ANSI Russian) for GUI applications and code page
866 (OEM Russian) for command-line applications.
The Firebird client always uses the ANSI code page. In order to provide the fully functional behaviour of
a console application, the console must be switched to the ANSI codepage (chcp 1251 for our Russian
example).
The Windows weirdness does not stop there. Parameters passed to a Windows application, but not to 16-bit
DOS, are always passed in the ANSI encoding, even if it was started from a command-line console running
in the default OEM mode. This might give the illusion that Firebird utilities run correctly out-of-the-box
on an OEM console. However, they run correctly only as far as the international information supplied in
a command line, e.g.,
This works. However, as soon as you try to use a CONNECT or CREATE DATABASE command inside isql,
or to enter the password from the OEM terminal, you will encounter problems. This is inconvenient and
we apologise for that. The OEM console issues are in the plan to be fixed in a future version.
2. Currently, command-line parameters and the CONNECT and CREATE DATABASE commands in isql are not
affected by SET NAMES or the -CHarset parameter. All the other commands, particularly CREATE/AL-
TER/DROP USER, are affected by them and thus, the character set must be specified. This is very important
because, in future versions, the plan is to make all usage of international credentials depend on a character
set that is explicitly specified.
Take careful note of one very confusing use case, an attempt to set a non-ASCII password for the current
user:
This command will succeed, even if the character set has not been set correctly. However, a subsequent
attempt to log in with the modified password will fail.
63
Security
3. In scripts, the first requirement is to set the correct character set for the SQL server that is to run the script,
using a SET NAMES statement. For Firebird 3, it is essential to pay attention to the locale and code page
settings in the environment in which the script is to execute. They must match the character set that is set
in the script.
Setting the locale correctly affects particularly the credentials passed to the server when attaching to it. The
rest of the script should proceed successfully even without configuring the environment properly.
In summary, if you plan to use international character credentials in the script, you DO need to attend to
the international settings in your environment.
Reminder
User names are SQL identifiers and thus conform to the same rules, i.e., enclosed in double quotes when
containing international characters or when case-sensitivity is required.
The SQL set of DDL commands for managing user accounts has been enhanced in Firebird 3, thus improving
the capability to manage (add, modify or delete) users in a security database from a regular database attachment.
Syntax Forms
PASSWORD 'password'
FIRSTNAME 'string value'
MIDDLENAME 'string value'
LASTNAME 'string value'
ACTIVE
INACTIVE
USING PLUGIN plugin_name
64
Security
DROP TAGNAME
Note
The tagname side of the name/value pair can be any valid SQL identifier.
Usage Details
The CREATE USER, CREATE OR ALTER USER and DROP USER clauses are available only for SYSDBA
or another user granted the RDB$ADMIN role in the security database (and logged in under that role, of course.)
An ordinary user can ALTER his own password, real name attributes and tags. Any attempt to modify another
user will fail, as will an attempt to make “self” inactive or active.
If you want to modify “self”, you can use the simplified form ALTER CURRENT USER.
It is not a requirement to use any of the clauses FIRSTNAME, MIDDLENAME and LASTNAME. Any of them
may be left empty or used to store short information about the user.
The INACTIVE clause is used to disable the user's login capability without dropping it. The ACTIVE clause
restores that login ability.
Quick Tip
From v.3.0.1, the statement CREATE OR ALTER USER SYSDBA PASSWORD <password> can be used
to initialize an empty securityN.fdb security database.
TAGS is a list of end-user defined attributes. The length of the string value should not exceed 255 bytes.
Setting a list of tags for the user retains previously set tags if they are not mentioned in the current list.
Note
A UID or GID that was entered by the deprecated gsec utility is treated as a tag in the SQL interface.
Examples
65
Security
Generic:
Note
Output depends upon the user management plug-in. If the legacy plug-in is used, bear in mind that some options
are not supported and will simply be ignored.
SET ROLE
Alex Peshkov
66
Security
The SQL2008-compliant operator SET ROLE allows the CURRENT_ROLE context variable to be set to one
that has been granted to the CURRENT_USER or to a user assigned to the database attachment as trusted (SET
TRUSTED ROLE).
Displays:
ROLE
===============================
MANAGER
The idea of a separate SET TRUSTED ROLE command is that, when the trusted user attaches to a database with-
out providing any role info, SET TRUSTED ROLE makes a trusted role (if one exists) the CURRENT_ROLE
without any additional activity, such as setting it in the DPB.
A trusted role is not a specific type of role but may be any role that was created using CREATE ROLE, or a
predefined system role such as RDB$ADMIN. It becomes a trusted role for an attachment when the security
objects mapping subsystem finds a match between the authentication result passed from the plug-in and a local
or global mapping for the current database. The role may be one that is not even granted explicitly to that trusted
user.
Notes
• A trusted role is not assigned to the attachment by default. It is possible to change this behaviour using an
appropriate authentication plug-in and a CREATE/ALTER MAPPING command.
• Whilst the CURRENT_ROLE can be changed using SET ROLE, it is not always possible to revert using
the same command, because it performs an access rights check.
Syntax Pattern
Enable access to a trusted role, if the CURRENT_USER is logged in under Trusted User authentication and
the role is available:
67
Security
An example of the use of a trusted role is assigning the system role RDB$ADMIN to a Windows administrator
when Windows trusted authentication is in use.
Previously, the grantor or revoker of SQL privileges was always the current user. This change makes it so that
a different grantor or revoker can be specified in GRANT and REVOKE commands.
Syntax Pattern
The GRANTED BY clause form is recommended by the SQL standard. The alternative form using AS is
supported by Informix and possibly some other servers and is included for better compatibility.
-- (in isql)
show grant;
/* Grant permissions for this database */
GRANT R1 TO PUBLIC GRANTED BY USER1
GRANT R1 TO USER1 WITH ADMIN OPTION
Syntax Pattern
Example
68
Security
Database: employee
SQL> REVOKE ALL ON ALL FROM USER guest;
SQL>
In Firebird 3, the system tables are read-only. This SQL syntax provides the means to assign metadata write
privileges to specified users or roles for specified objects. See Tracker item CORE-735.
Note
Some people have been applying the nickname “DDL privileges” to this feature. Don't confuse it with “DDL
triggers”! A more useful nickname would be “Metadata privileges”.
Syntax Patterns
69
Security
Notes on Usage
Note
The metadata for triggers and indices are accessed through the privileges for the table that owns them.
• If the ANY option is used, the user will be able to perform any operation on any object
• If the ANY option is absent, the user will be able to perform operations on the object only if he owns it
• If the ANY option was acquired via a GRANT operation then, to revoke it, the REVOKE operation must
accord with that GRANT operation
Example
CORE-2554: EXECUTE permission is now supported for UDFs (both legacy and PSQL based ones).
Syntax Pattern
Note
The initial EXECUTE permission is granted to the function owner (user who created or declared the function).
A recursive stored procedure no longer requires the EXECUTE privilege to call itself. See Tracker item
CORE-3242.
70
Security
Syntax Pattern
Notes
The initial USAGE permission is granted to the object owner (user who created the object).
In Firebird 3.0.0, only USAGE permissions for exceptions (CORE-2884) and generators/sequences (gen_id,
next value for: CORE-2553) are enforced. Granting privileges for character sets, collations and domains is
disabled, making these object types unavailable for any type of GRANT or REVOKE commands. Access to
them is not subject to any form of enforcement, although this could change in future releases if it is deemed
appropriate.
To access lists of users and attributes, query the virtual tables SEC$USERS and SEC$USER_ATTRIBUTES.
Important
This feature depends highly on the user management plug-in. Take into an account that some options are ignored
when using the legacy user management plug-in.
The pseudo-tables are much like the MON$ family tables used for monitoring the server. The table is created
on demand when you run the statement
or
71
Security
The output lists the users (or their attributes) in the security database that is configured for the current database
and available for management to the current user. SEC$USERS includes a field indicating whether a user has
the RDB$ADMIN role in the security database.
Prior to Firebird 3.0.1, any user could drop a role. This is a bug which has been fixed in sub-release 3.0.1. Now,
only the user who created the role and one who has been granted the role WITH ADMIN OPTION can drop it.
Important
72
Chapter 8
Data Definition
Language (DDL)
Quick Links
• BOOLEAN Data Type
• IDENTITY-Style Column
• Manage Nullability in Domains and Columns
• Modify Generators (Sequences)
• Alter Default Character Set
• BLOB Expressions in Computed Columns
• “Linger” Database Closure for Superserver
• New option in DROP SHADOW to Preserve the Shadow File
• New SQL for Managing Users and Access Privileges
DDL Enhancements
The following enhancements have been added to the SQL data definition language lexicon:
The SQL-2008 compliant BOOLEAN data type (8 bits) comprises the distinct truth values TRUE and FALSE.
Unless prohibited by a NOT NULL constraint, the BOOLEAN data type also supports the truth value UN-
KNOWN as the null value. The specification does not make a distinction between the NULL value of this data
type and the truth value UNKNOWN that is the result of an SQL predicate, search condition, or boolean value
expression: they may be used interchangeably to mean exactly the same thing.
As with many programming languages, the SQL BOOLEAN values can be tested with implicit truth values. For
example, field1 OR field2 and NOT field1 are valid expressions.
73
Data Definition Language (DDL)
The IS Operator
Predications use the operator IS [NOT] for matching. For example, field1 IS FALSE, or field1 IS NOT TRUE.
Note
Equivalence operators (“=”, “!=”, “<>” and so on) are valid in all comparisons.
Examples
74
Data Definition Language (DDL)
'false' is converted to Boolean. An attempt use the Boolean operators AND, NOT, OR and IS will fail. NOT
'False', for example, is invalid.
A Boolean can be explicitly converted to and from string with CAST. UNKNOWN is not available for any
form of casting.
Other Notes
• Represented in the API with the FB_BOOLEAN type and FB_TRUE and FB_FALSE constants.
An identity column is a column associated with an internal sequence generator. Its value is set automatically
when the column is omitted in an INSERT statement.
Syntax Patterns
When defining a column, the optional START WITH clause allows the generator to be initialised to a value
other than zero. See Tracker ticket CORE-4199.
A column definition can be altered to modify the starting value of the generator. RESTART alone resets the
generator to zero; the optional WITH <value> clause allows the restarted generator to start at a value other than
zero. See Tracker ticket CORE-4206.
75
Data Definition Language (DDL)
Rules
• The data type of an identity column must be an exact number type with zero scale. Allowed types are thus
SMALLINT, INTEGER, BIGINT, NUMERIC(x,0) and DECIMAL(x,0).
Notes
• An identity column cannot be altered to become a regular column. The reverse is also true.
• Uniqueness is not enforced automatically. A UNIQUE or PRIMARY KEY constraint is required to guar-
antee uniqueness.
• The use of other methods of generating key values for IDENTITY columns, e.g., by trigger-generator code
or by allowing users to change or add them, is discouraged to avoid unexpected key violations.
Example
ID NAME
============ ===============
1 Table
2 Book
10 Computer
Implementation Details
Two new columns have been inserted in RDB$RELATION_FIELDS to support identity columns: RDB
$GENERATOR_NAME and RDB$IDENTITY_TYPE.
• RDB$GENERATOR_NAME stores the automatically created generator for the column. In RDB$GENER-
ATORS, the value of RDB$SYSTEM_FLAG of that generator will be 6.
• Currently, RDB$IDENTITY_TYPE will currently always store the value 1 (by default) for identity columns
and NULL for non-identity columns. In the future this column will store the value 0, too (for ALWAYS)
when Firebird implements support for this type of identity column.
ALTER syntax is now available to change the nullability of a table column or a domain
76
Data Definition Language (DDL)
Syntax Pattern
ALTER TABLE <table name> ALTER <field name> { DROP | SET } [NOT] NULL
Notes
The success of a change in a table column from NULL to NOT NULL is subject to a full data validation on the
table, so ensure that the column has no nulls before attempting the change.
A change in a domain subjects all the tables using the domain to validation.
An explicit NOT NULL on a column that depends on a domain prevails over the domain. In this situation, the
changing of the domain to make it nullable does not propagate to the column.
RESTART can now be used on its own to restart the sequence at its previous start or restart value. A new column
RDB$INITIAL_VALUE is added to the system table RDB$GENERATORS to store that value.
A generator (sequence) can also be [re]created or altered to include an optional “step” clause to make the gen-
erator increment the series by two or more steps instead of the default 1. The clause is implemented as INCRE-
MENT BY <number> and is stored in RDB$GENERATORS in RDB$GENERATOR_INCREMENT.
Syntax Forms
CREATE OR ALTER { SEQUENCE | GENERATOR } <sequence name> { RESTART | START WITH <value> }
[ INCREMENT BY <number> ]
Function GEN_ID()
The legacy function GEN_ID(generator_name, step_value)) still works to set a one-time step value in its second
argument. If it is used, the stored RDB$GENERATOR_INCREMENT value is overridden.
77
Data Definition Language (DDL)
ALTER DATABASE
...
SET DEFAULT CHARACTER SET <new_charset>
The alteration does not change any existing data. The new default character set is used only in subsequent DDL
commands and will assume the default collation of the new character set.
A substring from a BLOB column can now be used to define a computed column.
For Example
Firebird 3.0 introduces an enhancement to ALTER DATABASE to manage this optional LINGER capability
for databases running under Superserver.
Syntax Form
Usage
Either of the following forms will clear the linger setting and return the database to the normal condition (no
linger):
78
Data Definition Language (DDL)
Note
Dropping LINGER is not an ideal solution for the occasional need to turn it off for some once-only condition
where the server needs a forced shutdown. The gfix utility now has the -NoLinger switch, which will close the
specified database immediately the last attachment is gone, regardless of the LINGER setting in the database.
The LINGER setting is retained and works normally the next time.
The same one-off override is also available through the Services API, using the tag isc_spb_prp_nolinger,
e.g. (in one line):
See also Tracker ticket CORE-4263 for some discussion of the development of this feature.
The DROP SHADOW command has a new option to preserve the shadow file in the filesystem:
The SQL set of DDL commands for managing user accounts has been enhanced in Firebird 3, thus improving
the capability to manage (add, modify or delete) users in a security database from a regular database attachment.
gsec is deprecated!
The command-line and shell utility gsec is deprecated from this release forward. It will continue to work with
security3.fdb but it will not work with alternative security databases.
The SQL2008-compliant operator SET ROLE allows the CURRENT_ROLE context variable to be set to one
that has been granted to the CURRENT_USER or to a user assigned to the database attachment as trusted (SET
TRUSTED ROLE).
79
Data Definition Language (DDL)
Previously, the grantor or revoker of SQL privileges was always the current user. The GRANTED BY clause
makes it so that a different grantor or revoker can be specified in GRANT and REVOKE commands.
When a user is removed from the security database or another authentication source, this new command is useful
for revoking its access to all objects in the database.
In Firebird 3, the system tables are read-only. This SQL syntax provides the means to assign metadata write
privileges to specified users or roles for specified objects.
EXECUTE permission is now supported for UDFs (both legacy and PSQL based ones).
GRANT/REVOKE USAGE
New SQL-2008 compliant USAGE permission is introduced to protect metadata objects other than tables, views,
procedures and functions.
80
Chapter 9
Data Manipulation
Language (DML)
In this chapter are the additions and improvements that have been added to the SQL data manipulation language
subset in Firebird 3.0.
Quick Links
• Supplemental SQL 2008 Features for MERGE
• Window (Analytical) Functions
• Advanced PLAN Output
• SUBSTRING With Regular Expressions
• Inverse Hyperbolic Trig Functions
• Statistical Functions
• Enhancements to DATEADD() Internal Function
• TRIM() BLOB Arguments Lose 32 KB limit
• Alternatives for Embedding Quotes in String Literals
• SQL:2008-Compliant OFFSET and FETCH Clauses
• Prohibit Edgy Mixing of Implicit/Explicit Joins
• Support for Left-side Parameters in WHERE Clause
• RETURNING Clause Can be Aliased
• RETURNING Clause from Positioned Updates and Deletes
• Cursor Stability
• Improvements for Global Temporary Tables
• Improvements for DML Strings
• COUNT() Now Returns BIGINT
• SIMILAR TO Performance Improvement
• OR'ed Parameter in WHERE Clause
• A Little Dialect 1 Accommodation
• Embedded SQL (ESQL) Enhancements
In summary, support for MERGE was supplemented with the introduction of these features:
• Enabling the use of multiple WHEN MATCHED | NOT MATCHED clauses (CORE-3639) and ability to
apply conditions to WHEN MATCHED | NOT MATCHED
81
Data Manipulation Language (DML)
The purpose of MERGE is to read data from the source and INSERT or UPDATE in the target table according
to a condition. It is available in DSQL and PSQL.
Syntax Pattern
Rules
At least one of <merge when matched> or <merge when not matched> should be specified.
Example
Notes
A right join is made between the INTO (left-side) and USING tables using the condition. UPDATE is called
when a record exists in the left table (INTO), otherwise INSERT is called.
As soon as it is determined whether or not the source matches a record in the target, the set formed from the
corresponding (WHEN MATCHED / WHEN NOT MATCHED) clauses is evaluated in the order specified,
to check their optional conditions. The first clause whose condition evaluates to true is the one which will be
executed, and the subsequent ones will be ignored.
82
Data Manipulation Language (DML)
According to the SQL specification, window functions (also known as analytical functions) are a kind of ag-
gregation, but one that does not “filter” the result set of a query. The rows of aggregated data are mixed with
the query result set.
The window functions are used with the OVER clause. They may appear only in the SELECT list or the ORDER
BY clause of a query.
Besides the OVER clause, Firebird window functions may be partitioned and ordered.
Syntax Pattern
Imagine a table EMPLOYEE with columns ID, NAME and SALARY, and the need to show each employee
with his respective salary and the percentage of his salary over the payroll.
select
id,
department,
salary,
salary / (select sum(salary) from employee) portion
from employee
order by id;
Results
83
Data Manipulation Language (DML)
The query is repetitive and lengthy to run, especially if EMPLOYEE happened to be a complex view.
The same query could be specified in a much faster and more elegant way using a window function:
select
id,
department,
salary,
salary / sum(salary) OVER () portion
from employee
order by id;
Here, sum(salary) over () is computed with the sum of all SALARY from the query (the employee table).
Partitioning
Like aggregate functions, that may operate alone or in relation to a group, window functions may also operate
on a group, which is called a “partition”.
Syntax Pattern
Aggregation over a group could produce more than one row, so the result set generated by a partition is joined
with the main query using the same expression list as the partition.
Continuing the employee example, instead of getting the portion of each employee's salary over the all-employ-
ees total, we would like to get the portion based on just the employees in the same department:
select
id,
department,
salary,
salary / sum(salary) OVER (PARTITION BY department) portion
from employee
order by id;
Results
84
Data Manipulation Language (DML)
Ordering
The ORDER BY sub-clause can be used with or without partitions and, with the standard aggregate functions,
make them return the partial aggregations as the records are being processed.
Example
select
id,
salary,
sum(salary) over (order by salary) cumul_salary
from employee
order by salary;
id salary cumul_salary
-- ------ ------------
3 8.00 8.00
4 9.00 17.00
1 10.00 37.00
5 10.00 37.00
2 12.00 49.00
Then cumul_salary returns the partial/accumulated (or running) aggregation (of the SUM function). It may
appear strange that 37.00 is repeated for the ids 1 and 5, but that is how it should work. The ORDER BY keys
are grouped together and the aggregation is computed once (but summing the two 10.00). To avoid this, you
can add the ID field to the end of the ORDER BY clause.
It's possible to use multiple windows with different orders, and ORDER BY parts like ASC/DESC and NULLS
FIRST/LAST.
With a partition, ORDER BY works the same way, but at each partition boundary the aggregation is reset.
All aggregation functions, other than LIST(), are usable with ORDER BY.
Ranking Functions
The rank functions compute the ordinal rank of a row within the window partition. In this category are the
functions DENSE_RANK, RANK and ROW_NUMBER.
Syntax
85
Data Manipulation Language (DML)
DENSE_RANK() |
RANK() |
ROW_NUMBER()
The ranking functions can be used to create different type of incremental counters. Consider SUM(1) OVER
(ORDER BY SALARY) as an example of what they can do, each of them in a different way. Following is an
example query, also comparing with the SUM behavior.
select
id,
salary,
dense_rank() over (order by salary),
rank() over (order by salary),
row_number() over (order by salary),
sum(1) over (order by salary)
from employee
order by salary;
The difference between DENSE_RANK and RANK is that there is a gap related to duplicate rows (relative to the
window ordering) only in RANK. DENSE_RANK continues assigning sequential numbers after the duplicate
salary. On the other hand, ROW_NUMBER always assigns sequential numbers, even when there are duplicate
values.
Navigational Functions
The navigational functions get the simple (non-aggregated) value of an expression from another row of the
query, within the same partition.
Syntax
Important to Note
FIRST_VALUE, LAST_VALUE and NTH_VALUE also operate on a window frame. Currently, Firebird al-
ways frames from the first to the current row of the partition, not to the last. This is likely to produce strange
results for NTH_VALUE and especially LAST_VALUE.
86
Data Manipulation Language (DML)
Example
select
id,
salary,
first_value(salary) over (order by salary),
last_value(salary) over (order by salary),
nth_value(salary, 2) over (order by salary),
lag(salary) over (order by salary),
lead(salary) over (order by salary)
from employee
order by salary;
FIRST_VALUE and LAST_VALUE get, respectively, the first and last value of the ordered partition.
NTH_VALUE gets the n-th value, starting from the first (default) or the last record, from the ordered parti-
tion. An offset of 1 from first would be equivalent to FIRST_VALUE; an offset of 1 from last is equivalent
to LAST_VALUE.
LAG looks for a preceding row, and LEAD for a following row. LAG and LEAD get their values within a
distance respective to the current row and the offset (which defaults to 1) passed.
In a case where the offset points outside the partition, the default parameter (which defaults to NULL) is returned.
PLAN output can now be output in a more structured and comprehensible form, e.g.
SELECT statement
-> First [10]
-> Sort [SUM, O_ORDERDATE]
-> Aggregate
-> Sort [L_ORDERKEY, O_ORDERDATE, O_SHIPPRIORITY]
-> Inner Loop Join
-> Filter
-> Table #ORDERS# Access By ID
-> Bitmap
-> Index #ORDERS_ORDERDATE# Range Scan
-> Filter
-> Table #CUSTOMER# Access By ID
-> Bitmap
-> Index #CUSTOMER_PK# Unique Scan
87
Data Manipulation Language (DML)
-> Filter
-> Table #LINEITEM# Access By ID
-> Bitmap
-> Index #LINEITEM_PK# Unique Scan
Internal Functions
Additions and enhancements to the internal functions set are:
Search Pattern
Discussion: TrackerCORE-2006
For more information about the use of SIMILAR TO expressions, refer to README.similar_to.txt in the /
doc/ subdirectory of your Firebird installation.
Tip
The regex used is the SQL one. A guide is available in the DML chapter of the v.2.5 release notes and also
at the Firebird web site.
The six inverse hyperbolic trigonometric functions have been implemented internally. They are:
ACOSH
Returns the hyperbolic arc cosine of a number (expressed in radians). Format: ACOSH( <number> )
ASINH
Returns the hyperbolic arc sine of a number (expressed in radians). Format: ASINH( <number> )
ATANH
Returns the hyperbolic arc tangent of a number (expressed in radians). Format: ATANH( <number> )
88
Data Manipulation Language (DML)
COSH
Returns the hyperbolic cosine of an angle (expressed in radians). Format: COSH( <number> )
SINH
Returns the hyperbolic sine of an angle (expressed in radians). Format: SINH( <number> )
TANH
Returns the hyperbolic tangent of an angle (expressed in radians). Format: TANH( <number> )
Statistical Functions
Hajime Nakagami
Adriano dos Santos Fernandes
Syntax
<single param statistical function> ::= <single param statistical function name>(<expr>)
<single param statistical function name> := { VAR_POP | VAR_SAMP | STDDEV_POP | STDDEV_SAMP }
<dual param statistical function> ::= <dual param statistical function name>(<expr1>, <expr>>)
<dual param statistical function name> := { COVAR_POP | COVAR_SAMP | CORR }
Semantics
• NULL is returned from VAR_POP, STDDEV_POP, COVAR_POP or CORR if the result count is 0
Syntax
89
Data Manipulation Language (DML)
SQRT(VAR_SAMP(<expr>))
SQRT(VAR_POP(<expr>))
The suite of REGR_* functions analyses the relationships between two sets of numeric data, considering only
sets that are not NULL in either expression. See Tracker ticket CORE-4722.
Syntax
Formulae
90
Data Manipulation Language (DML)
Important
All functions eliminate expression pairs where either expression in the pair is NULL. If no rows remain, the
functions (except REGR_COUNT()) return NULL.
Formula: REGR_COUNT(Y, X) = N
91
Data Manipulation Language (DML)
In prior versions, TRIM(substring from string) allowed BLOBs for both arguments, but the first argument had
to be smaller than 32 KB. Now both arguments can take BLOBs of up to 4 GB.
The internal length of a string can, at some levels, be almost 64 KB. Tests demonstrated that it is safe to accept
a string literal of up to that size for writing to a text BLOB. Accordingly,
1. The (32KB - 3) “safety limit” on literal string length for writing to text BLOBs has been raised to 65,533
bytes (64KB - 3);
2. A limit, in characters, is calculated in run-time for strings that are in multi-byte character sets, to avoid
overrunning the bytes limit. For example, for a UTF8 string (max. 4 bytes/character) the run-time limit is
likely to be about (floor (65533/4)) = 16383 characters.
92
Data Manipulation Language (DML)
• The function now supports a fractional value for MILLISECOND. See Tracker item CORE-4457.
• the data type of input <amount> arguments has changed from INTEGER to BIGINT. See Tracker item
CORE-4310.
DML Improvements
A collection of useful DML improvements is released with Firebird 3.
It is now possible to use a character, or character pair, other than the doubled (escaped) apostrophe, to embed a
quoted string inside another string. The keyword q or Q preceding a quoted string informs the parser that certain
left-right pairs or pairs of identical characters within the string are the delimiters of the embedded string literal.
Syntax
Rules
When <alternate start char> is '(', '{', '[' or '<', <alternate end char> is paired up with its respective “partner”,
viz. ')', '}', ']' and '>'. In other cases, <alternate end char> is the same as <alternate start char>.
Inside the string, i.e., <char> items, single (not escaped) quotes could be used. Each quote will be part of the
result string.
Examples
New SQL:2008 compliant OFFSET and FETCH clauses provide a standard equivalent for FIRST and SKIP,
and an alternative for ROWS...TO, when fetching sets from ordered output.
93
Data Manipulation Language (DML)
As with SKIP and FIRST, OFFSET and FETCH clauses can be applied independently, in both top-level and
nested query expressions. They are available in PSQL and DSQL.
Syntax Pattern
<simple_value_expr> is a (numeric) literal, a DSQL parameter (?) or a PSQL named parameter (:namedpa-
rameter) that resolves to an integer data type.
Examples
-- 1:
SELECT * FROM T1 ORDER BY COL1
OFFSET 10 ROWS;
-- 2:
SELECT * FROM T1 ORDER BY COL1
FETCH FIRST 10 ROWS ONLY;
-- 3:
SELECT * FROM (
SELECT * FROM T1 ORDER BY COL1 DESC
OFFSET 1 ROW
FETCH NEXT 10 ROWS ONLY
) a
ORDER BY a.COL1
FETCH FIRST ROW ONLY;
Notes
2. The OFFSET and/or FETCH clauses cannot be mixed with clauses from the FIRST/SKIP or ROWS al-
ternatives in the same query expression.
3. Expressions and column references are not allowed within either the OFFSET or the FETCH clause.
4. Unlike the ROWS clause, OFFSET and FETCH are available only in SELECT statements.
6. “FETCH ... WITH TIES” defined in the SQL standard is not supported.
While mixing of implicit and explict join syntaxes is not recommended at all, the parser would allows them,
nevertheless. Certain “mixes” actually cause the optimizer to produce unexpected results, including “No record
for fetch” errors. The same edgy styles are prohibited by other SQL engines and now they are prohibited in
Firebird.
To visit some discussion on the subject, see the Tracker ticket CORE-2812.
94
Data Manipulation Language (DML)
The following style of subquery, with the parameter in the left side of a WHERE...IN (SELECT...) condition,
would fail with the error “The data type of the parameter is unknown”.
Important
Better SQL coding practice would be to use EXISTS in these cases; however, developers were stumbling over
this problem when using generated SQL from Hibernate, which used the undesirable style.
When using the RETURNING clause to return a value to the client, the value can now be passed under an alias.
UPDATE T1 SET F2 = F2 * 10
RETURNING OLD.F2, NEW.F2; -- without aliases
UPDATE T1 SET F2 = F2 * 10
RETURNING OLD.F2 OLD_F2, NEW.F2 AS NEW_F2; -- with aliases
Note
Support has been added for a RETURNING clause in positioned (WHERE CURRENT OF) UPDATE and
DELETE statements.
Example
95
Data Manipulation Language (DML)
Cursor Stability
Vlad Khorsun
Until this release, Firebird suffered from an infamous bug whereby a data modification operation could loop
infinitely and, depending on the operation, delete all the rows in a table, continue updating the same rows ad
infinitum or insert rows until the host machine ran out of resources. All DML statements were affected (INSERT,
UPDATE, DELETE, MERGE). It occurred because the engine used an implicit cursor for the operations.
To ensure stability, rows to be inserted, updated or deleted had to be marked in some way in order to avoid
multiple visits. Another workaround was to force the query to have a SORT in its plan, in order to materialize
the cursor.
From Firebird 3, engine uses the Undo log to check whether a row was already inserted or modified by the
current cursor.
Important
Global temporary tables (GTTs) are now writable even in read-only transactions. The effect is as follows.-
Also
Note
96
Data Manipulation Language (DML)
Strings in DML queries are now transformed or validated to avoid passing malformed strings to the engine
internals, for example, to the MON$STATEMENTS.MON$SQL_TEXT column.
Optimizations
Optimizations made for this release included:
SIMILAR TO
Adriano dos Santos Fernandes
Performance for (table.field = :param or :param = -1) in the WHERE clause was enhanced.
Previously, when an ORDER plan was in a SELECT structure, the optimizer would choose the first index
candidate that matched the ORDER BY or GROUP BY clause. This “first come” approach is not the best when
multiple index choices are available. The Firebird 3 engine surveys all of the available choices and picks the
most suitable index.
Previously, the execution path for UNION queries was hierarchical, often causing redundant reads. This opti-
mization replaces the hierarchical execution path with a plainer one that improves performance.
97
Data Manipulation Language (DML)
The optimizer now allows an index walk (ORDER plan) when a suitable compound index (A, B) is available
for a query condition of the style WHERE A = ? ORDER BY B.
BTR_selectivity() would walk the whole leaf level of given index b-tree to calculate index selectivity. Through-
out the process, the only rescheduling would happen at a disk I/O operation. The effect was to impose long waits
for AST requests from concurrent attachments, such as page lock requests, monitoring, cancellation, etc. An
improvement in Firebird 3 seems to solve that problem.
Dialect 1 Interface
Adriano dos Santos Fernandes
Two enhancements were included in the Embedded SQL subset in this release:
98
Chapter 10
Quick Links
• PSQL Stored Functions
• PSQL Subroutines
• Packages
• DDL Triggers
• Exceptions with Parameters
• CONTINUE in Looping Logic
• PSQL Cursor Stabilization
• PSQL Cursors as Variables
• SQLSTATE Now Valid in Exception Trap
• Some Size Limits Removed Using New API
It is now possible to write a scalar function in PSQL and call it just like an internal function.
Tip
The CREATE statement is the declaration syntax for PSQL functions, parallel to DECLARE for legacy UDFs.
Example
99
Procedural SQL (PSQL)
PSQL Sub-routines
Adriano dos Santos Fernandes
The header of a PSQL module (stored procedure, stored function, trigger, executable block) can now accept
sub-procedure and sub-function blocks in the header declarations for use within the body of the module.
Examples
SET TERM ^;
--
-- Sub-function in EXECUTE BLOCK
--
EXECUTE BLOCK RETURNS (N INT)
AS
DECLARE FUNCTION F(X INT) RETURNS INT
AS
BEGIN
RETURN X+1;
END
BEGIN
N = F(5);
SUSPEND;
END ^
--
-- Sub-function inside a stored function
--
CREATE OR ALTER FUNCTION FUNC1 (n1 INTEGER, n2 INTEGER)
RETURNS INTEGER
AS
DECLARE FUNCTION SUBFUNC (n1 INTEGER, n2 INTEGER)
RETURNS INTEGER
AS
BEGIN
RETURN n1 + n2;
END
BEGIN
RETURN SUBFUNC(n1, n2);
100
Procedural SQL (PSQL)
END ^
--
select func1(5, 6) from rdb$database ^
Packages
A. dos Santos Fernandes
Acknowledgement
This feature was sponsored with donations gathered at the fifth Brazilian Firebird Developers' Day, 2008
A package is a group of procedures and functions managed as one entity. The notion of “packaging” the code
components of a database operation addresses several objectives:
Modularisation
The idea is to separate blocks of interdependent code into logical modules, as programming languages do.
In programming it is well recognised that grouping code in various ways, in namespaces, units or classes,
for example, is a good thing. With standard procedures and functions in the database this is not possible.
Although they can be grouped in different script files, two problems remain:
2. Scripted routines all participate in a flat namespace and are callable by everyone (we are not referring
to security permissions here).
Firebird packages come in two parts: a header (keyword PACKAGE) and a body (keyword PACKAGE
BODY). This division is very similar to a Delphi unit, the header corresponding to the interface part and the
body corresponding to the implementation part.
The header is created first (CREATE PACKAGE) and the body (CREATE PACKAGE BODY) follows.
Whenever a packaged routine determines that it uses a certain database object, a dependency on that object is
registered in Firebird system tables. Thereafter, to drop, or maybe alter that object, you first need to remove
what depends on it. As it is a package body that depends on it, that package body can just be dropped,
even if some other database object depends on this package. When the body is dropped, the header remains,
allowing you to recreate its body once the changes related to the removed object are done.
Packaged routines do not have individual privileges. The privileges act on the package. Privileges granted
to packages are valid for all package body routines, including private ones, but are stored for the package
header.
101
Procedural SQL (PSQL)
For example:
All programming languages have the notion of routine scope, which is not possible without some form of
grouping. Firebird packages also work like Delphi units in this regard. If a routine is not declared in the
package header (interface) and is implemented in the body (implementation), it becomes a private routine.
A private routine can only be called from inside its package.
Signatures
For each routine that is assigned to a package, elements of a digital signature (the set of [routine name, parameters
and return type]) are stored in the system tables.
SELECT...
-- sample query to come
Packaging Syntax
<package_header> ::=
{ CREATE [OR ALTER] | ALTER | RECREATE } PACKAGE <name>
AS
BEGIN
[ <package_item> ... ]
END
<package_item> ::=
<function_decl> ; |
<procedure_decl> ;
<function_decl> ::=
FUNCTION <name> [( <parameters> )] RETURNS <type>
<procedure_decl> ::=
PROCEDURE <name> [( <parameters> ) [RETURNS ( <parameters> )]]
<package_body> ::=
{ CREATE | RECREATE } PACKAGE BODY <name>
AS
BEGIN
[ <package_item> ... ]
[ <package_body_item> ... ]
END
102
Procedural SQL (PSQL)
<package_body_item> ::=
<function_impl> |
<procedure_impl>
<function_impl> ::=
FUNCTION <name> [( <parameters> )] RETURNS <type>
AS
BEGIN
...
END
|
FUNCTION <name> [( <parameters> )] RETURNS <type>
EXTERNAL NAME '<name>' ENGINE <engine>
<procedure_impl> ::=
PROCEDURE <name> [( <parameters> ) [RETURNS ( <parameters> )]]
AS
BEGIN
...
END
|
PROCEDURE <name> [( <parameters> ) [RETURNS ( <parameters> )]]
EXTERNAL NAME '<name>' ENGINE <engine>
<drop_package_header> ::=
DROP PACKAGE <name>
<drop_package_body> ::=
DROP PACKAGE BODY <name>
Syntax rules
• All routines declared in the header and at the start of the body should be implemented in the body with the
same signature, i.e., you cannot declare the routine in different ways in the header and in the body.
• Default values for procedure parameters cannot be redefined in <package_item> and <package_body_item>.
They can be in <package_body_item> only for private procedures that are not declared.
Notes
• DROP PACKAGE drops the package body before dropping its header.
• The source of package bodies is retained after ALTER/RECREATE PACKAGE. The column RDB
$PACKAGES.RDB$VALID_BODY_FLAG indicates the state of the package body. See Tracker item
CORE-4487.
• UDF declarations (DECLARE EXTERNAL FUNCTION) are currently not supported inside packages.
• Syntax is available for a description (COMMENT ON) for package procedures and functions and their
parameters. See Tracker item CORE-4484.
SET TERM ^;
-- package header, declarations only
CREATE OR ALTER PACKAGE TEST
103
Procedural SQL (PSQL)
AS
BEGIN
PROCEDURE P1(I INT) RETURNS (O INT); -- public procedure
END
Note
DDL triggers
A. dos Santos Fernandes
Acknowledgement
This feature was sponsored with donations gathered at the fifth Brazilian Firebird Developers' Day, 2008
The purpose of a “DDL trigger” is to enable restrictions to be placed on users who attempt to create, alter or
drop a DDL object.
Syntax Pattern
<database-trigger> ::=
{CREATE | RECREATE | CREATE OR ALTER}
TRIGGER <name>
[ACTIVE | INACTIVE]
{BEFORE | AFTER} <ddl event>
[POSITION <n>]
AS
BEGIN
...
END
104
Procedural SQL (PSQL)
| ALTER TABLE
| DROP TABLE
| CREATE PROCEDURE
| ALTER PROCEDURE
| DROP PROCEDURE
| CREATE FUNCTION
| ALTER FUNCTION
| DROP FUNCTION
| CREATE TRIGGER
| ALTER TRIGGER
| DROP TRIGGER
| CREATE EXCEPTION
| ALTER EXCEPTION
| DROP EXCEPTION
| CREATE VIEW
| ALTER VIEW
| DROP VIEW
| CREATE DOMAIN
| ALTER DOMAIN
| DROP DOMAIN
| CREATE ROLE
| ALTER ROLE
| DROP ROLE
| CREATE SEQUENCE
| ALTER SEQUENCE
| DROP SEQUENCE
| CREATE USER
| ALTER USER
| DROP USER
| CREATE INDEX
| ALTER INDEX
| DROP INDEX
| CREATE COLLATION
| DROP COLLATION
| ALTER CHARACTER SET
| CREATE PACKAGE
| ALTER PACKAGE
| DROP PACKAGE
| CREATE PACKAGE BODY
| DROP PACKAGE BODY
Semantics
1. BEFORE triggers are fired before changes to the system tables. AFTER triggers are fired after system table
changes.
Important Rule
2. When a DDL statement fires a trigger that raises an exception (BEFORE or AFTER, intentionally or un-
intentionally) the statement will not be committed. That is, exceptions can be used to ensure that a DDL
operation will fail if the conditions are not precisely as intended.
3. DDL trigger actions are executed only when committing the transaction in which the affected DDL com-
mand runs. Never overlook the fact that what is possible to do in an AFTER trigger is exactly what is
possible to do after a DDL command without autocommit. You cannot, for example, create a table in the
trigger and use it there.
105
Procedural SQL (PSQL)
4. With “CREATE OR ALTER” statements, a trigger is fired one time at the CREATE event or the ALTER
event, according to the previous existence of the object. With RECREATE statements, a trigger is fired for
the DROP event if the object exists, and for the CREATE event.
5. ALTER and DROP events are generally not fired when the object name does not exist. For the exception,
see point 6.
6. The exception to rule 5 is that BEFORE ALTER/DROP USER triggers fire even when the user name does
not exist. This is because, underneath, these commands perform DML on the security database and the
verification is not done before the command on it is run. This is likely to be different with embedded users,
so do not write code that depends on this.
7. If some exception is raised after the DDL command starts its execution and before AFTER triggers are
fired, AFTER triggers will not be fired.
8. Packaged procedures and triggers do not fire individual {CREATE | ALTER | DROP} {PROCEDURE
| FUNCTION} triggers.
Permissions
The following users can create, alter or drop DDL triggers and access the trigger-related switches in the Firebird
utilities:
• SYSDBA
Support in Utilities
A DDL trigger is a type of database trigger, so the parameters -nodbtriggers (GBAK and ISQL) and -T
(NBACKUP) apply to them. Remember that only users with the appropriate metadata privileges can use these
switches.
The DDL_TRIGGER context works like a stack. Before a DDL trigger is fired, the values relative to the exe-
cuted command are pushed onto this stack. After the trigger finishes, the values are popped. So in the case of
cascade DDL statements, when an user DDL command fires a DDL trigger and this trigger executes another
DDL command with EXECUTE STATEMENT, the values of the DDL_TRIGGER namespace are the ones
relative to the command that fired the last DDL trigger on the call stack.
106
Procedural SQL (PSQL)
• DDL_EVENT: event name (<ddl event item>), where <ddl_event_item> is EVENT_TYPE || ' ' ||
OBJECT_TYPE
Note
ALTER DOMAIN <old name> TO <new name> sets OLD_OBJECT_NAME and NEW_OBJECT_NAME
in both BEFORE and AFTER triggers. For this command, OBJECT_NAME will have the old object name in
BEFORE triggers and the new object name in AFTER triggers.
Here is how you might use a DDL trigger to enforce a consistent naming scheme, in this case, stored procedure
names should begin with the prefix “SP_”:
set term !;
-- Test
-- The last command raises this exception and procedure TEST is not created
-- Statement failed, SQLSTATE = 42000
-- exception 1
-- -E_INVALID_SP_NAME
107
Procedural SQL (PSQL)
set term ;!
Implement custom DDL security, in this case restricting the running of DDL commands to certain users:
set term !;
-- Test
-- The last command raises this exception and procedure SP_TEST is not created
-- Statement failed, SQLSTATE = 42000
-- exception 1
-- -E_ACCESS_DENIED
-- -Access denied
-- -At trigger 'TRIG_DDL' line: 4, col: 5
set term ;!
set term !;
108
Procedural SQL (PSQL)
in autonomous transaction do
begin
insert into ddl_log (id, moment, user_name, event_type, object_type,
ddl_event, object_name, sql_text, ok)
values (next value for ddl_seq, current_timestamp, current_user,
rdb$get_context('DDL_TRIGGER', 'EVENT_TYPE'),
rdb$get_context('DDL_TRIGGER', 'OBJECT_TYPE'),
rdb$get_context('DDL_TRIGGER', 'DDL_EVENT'),
rdb$get_context('DDL_TRIGGER', 'OBJECT_NAME'),
rdb$get_context('DDL_TRIGGER', 'SQL_TEXT'),
'N')
returning id into id;
rdb$set_context('USER_SESSION', 'trig_ddl_log_id', id);
end
end!
-- Note: the above trigger will fire for this DDL command. It's good idea to
-- use -nodbtriggers when working with them!
create trigger trig_ddl_log_after after any ddl statement
as
begin
-- Here we need an AUTONOMOUS TRANSACTION because the original transaction
-- will not see the record inserted on the BEFORE trigger autonomous
-- transaction if user transaction is not READ COMMITTED.
in autonomous transaction do
update ddl_log set ok = 'Y'
where id = rdb$get_context('USER_SESSION', 'trig_ddl_log_id');
end!
commit!
set term ;!
-- Test
109
Procedural SQL (PSQL)
commit;
Instead of just fetching rows sequentially in a forward direction, “scrollability” allows flexible navigation
through an open cursor set both backwards and forwards. Rows next to, prior to and relative to the current cursor
row can be targetted. In PSQL, a scrollable cursor can be operated on directly. API support is available to enable
DSQL applications to fetch rows in a similar manner.
110
Procedural SQL (PSQL)
To fetch forward:
See also Scrollable Cursor Support for DSQL in the chapter entitled [Changes to the Firebird API and ODS]. The
section entitled Scrollable Cursor Usage explains a little more about the usage of the various FETCH options.
Notes
1. When a scrolling option is omitted, NO SCROLL is implied (i.e., the cursor is opened as forward-only).
This means that only FETCH [NEXT FROM] commands can be used. Other commands will return an
error.
2. Scrollable cursors are internally materialized as a temporary record set, thus consuming memory/disk
resources, so this feature should be used only when really necessary.
An exception can now be defined with a message containing slots for parameters which are filled and passed
when raising the exception, using the syntax pattern
Examples
...
if (val < 1000) then
thing = val;
else
exception e_invalid_val using (val, 'thing');
end
111
Procedural SQL (PSQL)
Notes
The status vector is generated using this code combination: isc_except, <exception number>,
isc_formatted_exception, <formatted exception message>, <exception parameters>
Since a new error code (isc_formatted_exception) is used, the client must be v.3.0, or at least use the fire-
bird.msg file from v.3.0, in order to translate the status vector to a string.
Considering, in left-to-right order, each parameter passed in the exception-raising statement as “the Nth”, with
N starting at 1:
• If more parameters are passed than are defined in the exception message, the surplus ones are ignored.
• The total length of the message, including the values of the parameters, is still limited to 1053 bytes.
CONTINUE is a complementary command to BREAK/LEAVE, allowing flow of control to break (leave) and
start of the next iteration of a FOR/WHILE loop.
Syntax
CONTINUE [<label>];
Example
112
Procedural SQL (PSQL)
Previously, this block would loop interminably. Now, the loop will not select the value if it was set within the
loop.
Note
If there is a SUSPEND inside the block, the old instability remains: this query, for example, still produces the
infinite loop:
Hitherto, the colon (:) prefix has been used in PSQL to mark a reference to a variable in DML statements. Its
use has been extended in Firebird 3 for two unrelated purposes:
1. to allow OLD/NEW fields in cursors to be read or assigned to and to assign them to variables.
2. to make variable assignment in both DML and PSQL statements in modules and blocks more flexible and,
where needed, to resolve ambiguity between field names and variable names
In FOR SELECT loops, it requires the AS CURSOR clause to be specified. For example:
execute block as
begin
for
select id, x from t1 as cursor c1
do begin
113
Procedural SQL (PSQL)
Note
Notice the extension of the use of a colon (:) as a prefix to the referenced cursor field.
Another example
for
select rdb$relation_id as id, rdb$relation_name as name
from rdb$relations
where rdb$view_blr is null
as cursor tables
do begin
out_id = tables.id;
out_name = tables.name;
suspend;
end
out_id = :tables.id;
out_name = :tables.name;
/* or */
:out_id = :tables.id;
:out_name = :tables.name;
var1 = :var2;
/* or */
new.fld = :var;
:var1 = :var2;
/* or */
:new.fld = :var;
114
Procedural SQL (PSQL)
:v = :old.n;
/* and */
v = :old.n;
Here, it is just “syntactic sugar” but, in other cases, it provides the means to resolve ambiguity between field
name references and variable names.
for
select rdb$relation_id as id, rdb$relation_name as name
from rdb$relations
where rdb$view_blr is null
as cursor tables
do begin
out_id = :table.id;
select tables.name from tables where tables.id = :tables.id into :out_name;
suspend;
end
Inside the nested SELECT, “tables” is both a table name and a cursor name here, so the colon is used to resolve
the ambiguity.
An SQLSTATE code becomes a valid condition for trapping an exception with a WHEN statement. In alignment
with SQLCODE and GDSCODE, the SQLSTATE code can be used as in the following snippet:
...
WHEN SQLSTATE '22006' DO
BEGIN
-- do something
END
...
115
Procedural SQL (PSQL)
Note
For details, see Some SQL Size Limits Removed Using New API in the API chapter.
116
Chapter 11
Monitoring &
Command-line Utilities
No new monitoring features or other utilities are released with Firebird 3.0. Existing features have undergone
a few improvements.
Monitoring
> Dmitry Yemanov
Several changes have been made to the set of virtual tables storing the monitoring information. These are listed
in the System Tables section of Chapter 4, Changes to the Firebird API and ODS.
From this version forward, the port number of the remote client address for TCPv4 and TCPv6 protocols is
included in MON$ATTACHMENTS.MON$REMOTE_ADDRESS. A new column in that table also reports the host
name of the remote client. For details, see Changes to Client Address Reporting in the same chapter.
Tracing
Latest improvements to the Trace functions include:
• Trace output now supports showing the explained plan. See Tracker CORE-4451 (V. Khorsun).
• Trace no longer ignores the fact that users from different security databases are actually different users.
It now “knows” in which security database a particular SYSDBA was authenticated or where a privileged
user's elevated privileges are established. It is no longer possible, for example, for a user named SYSDBA
to access security3.fdb if it is not currently authenticated for that access. See See Tracker CORE-4851
(A. Peshkov).
gbak
117
Monitoring & Command-line Utilities
gbak has a new option switch-- -skip_d(ata) to ignore the data from specific tables during a backup.
The switch -skip_d(ata) accepts a regular expression as its argument. For example, to skip two tables in the
employee database (aliased here as 'employee'):
Tip
The regex used is the SQL one—the same one that is used for Firebird's SIMILAR TO searches. A guide is
available in the DML chapter of the v.2.5 release notes and also at the Firebird web site.
This improvement allows the gbak log to take an extra-long name without encountering the message “Attempt
to store 256 bytes in a clumplet”.
gbak can now show some runtime statistics in its verbose output. A new command-line switch -STATISTICS
has been added to specify which statistics items should be produced. Currently, four items are implemented:
At least one item is mandatory for the STATISTICS switch. The arguments are case-insensitive and they can
be in any order. For example, “TDRW” and “WdrT” are equivalent.
The STATISTICS switch will have no effect if the -v[er] switch is not specified.
• a line with headers for the specified statistics, printed before the other statistics lines:
118
Monitoring & Command-line Utilities
• a line with total statistics summaries for the specified items, printed after the end of the main process:
Note
The feature is fully supported in the Services API with a new item in the SPB (Services Parameter Block). The
fbsvcmgr utility also supports the SPB implementation.
Examples
119
Monitoring & Command-line Utilities
From v.3.0.1, gbak returns a non-zero result code when restore fails on creating and activating a deferred user
index.
gsec
The gsec utility is deprecated from Firebird 3 forward. This means you are encouraged to use the new SQL
features for managing access described in Chapter 7, Security, in preference to existing equivalents provided
by gsec.
Important
gsec will continue to work with security3.fdb. However, it does not work with alternative security databas-
es.
isql
A new SET option is added: SET EXPLAIN [ON | OFF]. It extends the SET PLAN option to report the explained
plan instead of the standard one.
If SET PLAN is omitted, then SET EXPLAIN turns the plan output on. SET PLANONLY works as in previous
versions.
Usage options
Metadata Extract
Claudio Valderrama C.
120
Monitoring & Command-line Utilities
The metadata extract tool (-[e]x[tract] switch) was improved to create a script that takes the dependency order
of objects properly into account.
A label has also been added, reflecting the deterministic flag for stored functions. (A. dos Santos Fernandes)
The INPUT command will now use a relative path based on the directory of the last-opened, unclosed file in
the chain to locate the next file.
The size of the isql command buffer has increased from 64 KB to 10 MB to match the new engine limits. See
Tracker ticket CORE-4148.
A label was added in the SHOW FUNCTION command reflecting the deterministic flag for stored functions.
fb_lock_print
Input Arguments
Dmitry Yemanov
fb_lock_print now accepts 32-bit integers as the input arguments for seconds and intervals. Previously they were
limited to SMALLINT.
Useability Improvements
Vlad Khorsun
1. More detailed usage help is available from the command line (-help).
2. Events history and list of owners are no longer output by default: they may be requested explicitly if re-
quired. Header-only is the new default.
3. New -o[wners] switch to print only owners (locks) with pending requests
121
Monitoring & Command-line Utilities
gfix
-NoLinger Switch
Alex Peshkov
gfix has a new switch -NoLinger to provide a one-off override to the LINGER setting of a database.
For information regarding LINGER, see the write-up in the DDL chapter.
• The table name is now returned in the text of validation contraint error messages, to help identify the error
context
Other Tweaks
Some implementation annoyances were cleared up in several utilities.
All utilities resolve database paths in databases.conf when they need to access a database file directly. But
not all of them would follow the same rules when expanding a database name. Now, they do.
All command-line utilities except gpre and qli now present help and version information in a unified and coherent
way.
122
Monitoring & Command-line Utilities
Hard-coded messages were replaced with the regular parameterised-style ones in tracemanager and nbackup.
Switch options in qli and nbackup were made to check the correctness (or not) of the abbreviated switch options
presented.
123
Chapter 12
Compatibility Issues
In this section are features and modifications that might affect the way you have installed and used Firebird
in earlier releases.
On POSIX platforms, you will find the tools and other executable programs in similar locations to those used
for earlier versions. Exactly where depends on the distribution you are using.
aliases.conf Is No More
The file aliases.conf is replaced by databases.conf in the Firebird root directory. The format for
database aliases has not changed so you can copy/paste the contents of your existing aliases.conf file into
databases.conf successfully. The new file is capable of carrying a lot more configuration detail, however,
to enable database-level configuration of many features that were previously available only at the global server
level.
Embedded Connections
For an embedded connection, an authenticated login is no longer required on POSIX platforms. If you provide
a user name and password, the password is ignored. Applications may still require a user name and possibly a
role name, due to SQL privileges in databases.
This feature is new for embedded Firebird on POSIX but it is the way embedded always worked on Windows,
when the embedded engine was a separate executable.
124
Compatibility Issues
However, when using the standard installers for Windows, Linux and MacOSX, the SYSDBA user is created
during the final step of the installation, with a password that is either random or defined via a user input routine.
In a situation where the SYSDBA initialization step either fails, or is missing from an OS-specific install process,
such as a Windows .zip kit install or a dedicated POSIX platform port, it may be necessary to initialize the
security database manually for use with the SRP plugins. You will need to create the user SYSDBA and set up
the password for it using SQL CREATE USER command syntax in embedded mode as your first step to getting
access to databases and utilities.
The gsec utility can be used instead but, having been deprecated, it is not discussed here.
Important
This initialization is not required and should NOT be performed if you have configured the server to use legacy
(pre-Firebird 3 style) authentication and user management. The legacy security plugins totally preserve the
legacy behaviour and thus contain the legacy record for SYSDBA with “masterke” as the initial password.
Instructions for configuring firebird.conf for legacy authentication behaviour are in the next section.
Initialization Steps
Initialization is performed in embedded mode using the isql utility. For an embedded connection, an authenti-
cation password is not required and will be ignored if you provide one. An embedded connection will work fine
with no login credentials and “log you in” using your host credentials if you omit a user name. However, even
though the user name is not subject to authentication, creating or modifying anything in the existing security
database requires that the user be SYSDBA; otherwise, isql will throw a privilege error for the CREATE USER
request.
The SQL user management commands will work with any open database. Because the sample database em-
ployee.fdb is present in your installation and already aliased in databases.conf, it is convenient to use
it for the user management task.
1. Stop the Firebird server. Firebird 3 caches connections to the security database aggressively. The pres-
ence of server connections may prevent isql from establishing an embedded connection.
2. In a suitable shell, start an isql interactive session, opening the employee database via its alias:
125
Compatibility Issues
SQL> commit;
SQL> quit;
Note
The SYSDBA user will have full administrator rights automatically. Do not assign the ADMIN role (RDB
$ADMIN) to SYSDBA.
Quick Tip
From v.3.0.1, the statement CREATE OR ALTER USER SYSDBA PASSWORD <password> can be
used to initialize an empty securityN.fdb security database.
4. To complete the initialization, start the Firebird server again. Now you will be able to perform a network
login to databases, including the security database, using the password you assigned to SYSDBA.
About Passwords
• An effective password, using the default user manager Srp, can be up to 20 characters, although a password
of up to 255 characters will be valid.
• If you intend in future to configure the server to use legacy authentication (not recommended!), then only the
first 8 characters of any password, including that of the SYSDBA, will be read.
The gsec utility, although deprecated in Firebird 3, is still available for access to security3.fdb only. It
cannot be used to manage a custom user database. It is recommended that database admins plan to move away
from relying on gsec and become familiar with the newer SQL user management features.
Legacy Authentication
If you do not intend to use SRP encrypted log-ins right away and want to use the security database—security
3.fdb— as you have done in previous Firebird versions, proceed as follows:
1. Using a text editor, open firebird.conf and find the entry for the parameter UserManager:
#UserManager = Srp
UserManager = Legacy_UserManager
126
Compatibility Issues
WireCrypt = Enabled
-- or, if you don't plan to use SRP encryption at all --
WireCrypt = Disabled
Delete the “#” symbol and change the order of the arguments:
Delete the “#” symbol and change the order of the arguments:
Legacy Passwords
• The old masterke password is available for your first login as SYSDBA. It is known to the whole world
and should be changed as soon as possible.
• Reminder: Legacy authentication reads only the first 8 characters of any password.
127
Compatibility Issues
The SYSDBA user is not touched: after the upgrade procedure, it will remain as it was before.
Steps
Note
• In the commands below, replace masterkey with the actual SYSDBA password for the server version,
as appropriate.
• The procedure requires running the script security_database.sql that is located in the misc/up-
grade directory of your Firebird 3 installation. These instructions assume you have a temporary copy of
this script in the same directory as the isql executable.
1. Under the Firebird 2.5 server, back up the security database. Here, use the SYSDBA password for the v.2.5
installation:
2. Under the Firebird 3 server, restore a copy of v.2.5 backup. Here, use the SYSDBA password for the v.3
installation:
3. Under the Firebird 3 server, go to the directory where the isql utility is located and run the upgrade script:
"security2db.fdb" is just a sample name for the database: it can be any preferred name.
4. The procedure will generate new, random passwords and will output them to screen afterwards. Capture
the output and notify users of their new passwords.
5. When you are ready, shut down Firebird. Rename security3.fdb or move it another location; then
rename the upgraded database to security3.fdb.
c:\Program Files\Firebird_2_5\examples\empbuild\employee.fdb
Under the new unified server, that form of connection is no longer valid for a serverless client connection to
Superserver. It attempts to load an embedded server. If you try whilst Superserver is connected to your database,
you will get a refusal message to the effect “File is in use by another process”.
128
Compatibility Issues
This is not a bug. Since Superserver clients share resources, another server (in this case, an embedded server)
cannot attach a client to the same database that Superserver has any clients attached to.
However, all is not lost. The XNET subsystem can still do local client sessions for Superserver. You just need
a more elaborate connection string now:
xnet://alias-or-path-to-database
xnet://c:\Program Files\Firebird_3_0\examples\empbuild\employee.fdb
or using an alias:
xnet://employee
Note
New connection strings are available as alternatives for other local connection protocols, too. For more infor-
mation, see New Connection Formats for Local Clients on Windows.
Configuration Parameters
The previously deprecated firebird.conf parameters CompleteBooleanEvaluation, OldColumnNaming
and OldSetClauseSemantics are no longer supported anymore and have been removed. The lack of one or more
of these parameters may break your application code, so please check these settings in firebird.conf on
your older server version.
Important
Ensure that you study the chapter Configuration Additions and Changes in preparation for upgrading user
software to Firebird 3.
129
Compatibility Issues
Case-sensitive user names are also supported now. The CONNECT and CREATE DATABASE statements in isql
will thus allow user names to be specified in double quotes.
Illustration:
130
Compatibility Issues
• those that modify the table that is being explicitly or implicitly selected from within the same statement
• (as a side effect) some MERGE statements, that might work differently if multiple matches are possible.
Note
The SQL standard stipulates that the MERGE statement must raise an error if multiple matches are found.
Firebird is not so strict in this regard, but its behaviour should be considered undefined in these cases.
Reserved Words
A number of new reserved keywords are introduced. Please refer to the chapter Reserved Words and Changes and
ensure your DSQL statements and procedure/trigger sources do not contain any of those keywords as identifiers.
Otherwise, it will be necessary either to use them quoted (in Dialect 3 only) or to rename them.
Pay special attention to the keywords INSERTING, UPDATING and DELETING in your PSQL modules. They are
now reserved words and thus must not be used as identifiers.
Also check very carefully that the keyword BOOLEAN is not used as a domain name in your databases.
Old format:
<database %[\\/](test|azk2|rulez).fdb>
enabled true
time_threshold 100
log_statement_finish true
</database>
New format:
database = %[\\/](test|azk2|rulez).fdb
{
enabled = true
131
Compatibility Issues
time_threshold = 100
log_statement_finish = true
}
Important
Pay attention to the “database” section header and equality signs between parameter names and values.
In fact, the complete error stack previously contained {isc_lock_conflict, isc_deadlock, isc_
update_conflict}, whereas it now contains, more correctly, {isc_deadlock, isc_update_con-
flict}.
However, the GDSCODE system variable returns the first error element, thus causing possible compatibility
issues. Be sure that, besides isc_lock_conflict, your error handlers for updates and deletes also check for
the other error codes, isc_deadlock and isc_update_conflict.
<IP address>/<port>
A new column in that table also reports the host name of the remote client.
For details, see Changes to Client Address Reporting in the chapter entitled Changes to the Firebird API and
ODS.
132
Chapter 13
Bugs Fixed
Core Engine
(CORE-5735) An additional keyholder could open unauthorized connections to an encrypted database,
creating a vulnerability.
fixed by A. Peshkov
~ ~ ~
(CORE-5720) Sweep in Classic mode could run too slowly when there was a big load on the server.
fixed by V. Khorsun
~ ~ ~
~ ~ ~
(CORE-5695) The function position did not consider the collation for BLOBs.
fixed by V. Khorsun
~ ~ ~
(CORE-5694) Duplicate values could occur in columns with the UNIQUE constraint.
fixed by V. Khorsun
~ ~ ~
(CORE-5684) Error “no current record for fetch operation” was raised while deleting a record from MON
$ATTACHMENTS using ORDER BY clause
fixed by D. Yemanov
~ ~ ~
133
Bugs Fixed
(CORE-5681) An access violation could occur when an external statement was executed and the local
transaction was rolled back.
fixed by V. Khorsun
~ ~ ~
fixed by D. Sibiryakov
~ ~ ~
(CORE-5673) Unique constraint would not work in an encrypted database on first command.
fixed by A. Peshkov
~ ~ ~
(CORE-5667) Message “CTE 'X' has cyclic dependencies” would appear when 'X' was the alias for a result
set and there was a previous CTE part in the query with the same name 'X'.
fixed by V. Khorsun
~ ~ ~
(CORE-5659) The optimizer was generating a bad plan under certain conditions.
fixed by D. Yemanov
~ ~ ~
fixed by V. Khorsun
~ ~ ~
~ ~ ~
(CORE-5643) Message “Operating system call munmap failed. Error code 12” could appear in firebird.
log under heavy load in Classic or Superclassic.
fixed by A. Peshkov
~ ~ ~
134
Bugs Fixed
~ ~ ~
(CORE-5618) Some portions of the pages of second-level blobs were not released when dropping relations.
fixed by D. Logashov
~ ~ ~
(CORE-5605) When running with a plug-in to access a V.2.5 database, the engine would incorrectly check
for existing MAP if a pre-FB3 security database was used.
fixed by A. Peshkov
~ ~ ~
(CORE-5600) An invalid blob id would be reported when adding a new blob column of type text and
updating another field in the same operation.
fixed by V.Khorsun
~ ~ ~
(CORE-5598) Error “Block size exceeds implementation restriction” could occur while inner joining large
datasets with a long key using the HASH JOIN plan.
fixed by D. Yemanov
~ ~ ~
(CORE-5588) DbInfo interface was not being passed to ancillary instances of a plug-in.
fixed by A. Peshkov
~ ~ ~
(CORE-5580) Signatures of packaged functions were not being checked for mismatch with the [NOT]
DETERMINISTIC attribute.
~ ~ ~
fixed by R. Simakov
~ ~ ~
~ ~ ~
(CORE-5555) Error handling for SELECT WITH LOCK broke compatibility with Firebird 2.5.
fixed by V. Khorsun
135
Bugs Fixed
~ ~ ~
(CORE-5553) A database could not be encrypted if the DatabaseAccess was set to None.
fixed by A. Peshkov
~ ~ ~
(CORE-5550) A computed decimal field in a view could be stored with the wrong RDB
$FIELD_PRECISION value.
~ ~ ~
(CORE-5549) Errors could occur when building or running Firebird on hardware that did not have SSE
enabled.
fixed by A. Peshkov
~ ~ ~
~ ~ ~
~ ~ ~
(CORE-5528) Internal Firebird consistency check (limbo impossible (184), file: vio.cpp line: 2379)
fixed by V. Khorsun
~ ~ ~
(CORE-5527) External routines were not receiving default values for their output parameters.
~ ~ ~
(CORE-5526) External routines could receive parameters with incorrect length or data type.
~ ~ ~
(CORE-5517) Classic server could raise the error “Global mapping memory overflow” periodically and
require restarting to accept new connections.
136
Bugs Fixed
fixed by A. Peshknov
~ ~ ~
(CORE-5416) Memory leak: Firebird did not release memory after load tests.
fixed by V. Khorsun
~ ~ ~
(CORE-5415) Found and fixed an elusive bug whereby an unexpected memory overwrite could cause the
in-memory image of a random database page to be corrupted.
~ ~ ~
(CORE-4492) With OR or IN predicates for RDB$DBKEY, the optimizer failed to use an INDEX plan
when it should have.
fixed by D. Yemanov
~ ~ ~
fixed by V. Khorsun
~ ~ ~
fixed by V. Khorsun
~ ~ ~
fixed by V. Khorsun
~ ~ ~
(CORE-2284) Records were left in RDB$PAGES after rollback of CREATE TABLE statement.
~ ~ ~
Server Crashes/Hang-ups
(CORE-5730) The connection to the server could hang when working with encrypted databases over
network protocol other than TCP.
fixed by A. Peshkov
~ ~ ~
137
Bugs Fixed
(CORE-5719) Firebird 3 engine could crash when restoring from a backup made by Firebird 2.5.
~ ~ ~
(CORE-5707) Begin and end of physical backup in the same transaction could crash the engine.
fixed by V. Khorsun
~ ~ ~
(CORE-5706) Trace config with misplaced “{” could lead to an engine crash.
~ ~ ~
(CORE-5591) The engine could hang during transaction start, soon after certain errors.
fixed by A. Peshkov
~ ~ ~
(CORE-5562) Firebird could crash when a UDF was loaded and unloaded frequently.
fixed by A. Peshkov
~ ~ ~
(CORE-5547) The server could crash while compiling a stored procedure with nested references to query-
based computed fields.
fixed by D. Yemanov
~ ~ ~
(CORE-5533) The engine could crash when a database contained a database-level trigger.
~ ~ ~
fixed by V. Khorsun
~ ~ ~
Builds
(CORE-5654) Intermediate build files for plugins examples were mixed up.
fixed by A. Peshkov
~ ~ ~
138
Bugs Fixed
API/Remote Interface
(CORE-5721) Information items isc_info_length and fb_info_crypt_state had the same code.
Important
Software using the fb_info_crypt_state constant should be recompiled to make it work with release
3.0.3 and later.
fixed by A. Peshkov
~ ~ ~
(CORE-5686) Firebird 3.0.2 would allow any protocol version >= 10 to connect, including InterBase
protocol 14
fixed by M. Rotteveel
~ ~ ~
fixed by A. Peshkov
~ ~ ~
(CORE-5521) A race condition could arise between event notification and event registration.
fixed by V. Khorsun
~ ~ ~
(CORE-5510) The engine could send a status vector with more than 20 items to old clients and cause
a disconnection.
fixed by R. Simakov
~ ~ ~
POSIX Only
(CORE-5650) Dropping a procedure on the Classic server could cause a segmentation fault.
fixed by A. Peshkov
~ ~ ~
(CORE-5624) An old bug was fixed, whereby backslashes in path strings for use on POSIX file systems
were not always converted to forward slashes.
fixed by A. Peshkov
139
Bugs Fixed
~ ~ ~
Utilities
gbak
(CORE-5653) gbak restore with a large number of small blobs was very slow using Linux Classic.
fixed by R. Simakov
~ ~ ~
fixed by A. Peshkov
~ ~ ~
fixed by V. Khorsun
~ ~ ~
(CORE-5566) The server could crash while restoring from a backup if the shadow file already existed.
fixed by D. Yemanov
~ ~ ~
isql
(CORE-5569) isql would incorrectly pad UNICODE_FSS/UTF8 columns when they used a collation.
~ ~ ~
(CORE-5570) Negative infinity (double) was being shown incorrectly without the sign in isql.
~ ~ ~
nBackup
(CORE-5613) Superserver could hang when changing physical backup state under high load
fixed by V. Khorsun
~ ~ ~
140
Bugs Fixed
(CORE-5540) Alternate executions of an isql command from the command line in embedded mode would
be 5 to 10 times slower, i.e., fast-slow-fast-slow...
fixed by V. Khorsun
~ ~ ~
User Management
(CORE-5651) Problem migrating users to V3.0.
fixed by A. Peshkov
~ ~ ~
Core Engine
(CORE-5501) Diagnostics form gstat were unclear when a damaged page in DB file appeared encrypted.
fixed by A. Peshkov
~ ~ ~
fixed by V. Khorsun
~ ~ ~
(CORE-5496) Creating SRP SYSDBA with explicit admin (-admin yes in gsec or grant admin role in
create user) was creating two SYSDBA accounts.
fixed by A. Peshkov
~ ~ ~
(CORE-5489) Performance for NULLs filtering inside a navigational index scan was poor.
fixed by D. Yemanov
~ ~ ~
(CORE-5474) The setting 'Restrict UDF' for configuration parameter UdfAccess was ineffective because
of fbudf.so being dynamically linked against libc.
~ ~ ~
141
Bugs Fixed
fixed by A. Peshkov
~ ~ ~
(CORE-5470) Trace INCLUDE_FILTER with [[:WHITESPACE:]]+ would not work when a statement
was issued that contained a newline character.
fixed by V. Khorsun
~ ~ ~
(CORE-5464) An access violation would occur in fbclient when reading a BLOB stored in incompatible
encoding.
fixed by V. Khorsun
~ ~ ~
fixed by D. Yemanov
~ ~ ~
(CORE-5456) When attempting to migrate a database from Firebird 2.5.2 to 3.0.1, gbak restore would
always crash at the end.
fixed by D. Yemanov
~ ~ ~
(CORE-5452) A segmentation fault would occue when the engine's dynamic library was unloaded right
after closing worker threads (GC and/or cache writer).
fixed by A. Peshkov
~ ~ ~
(CORE-5448) Bugcheck oocurred when creating a view on a table that has a column with character set
NONE, database default charset is UTF8, and the default collation is UNICODE.
fixed by V. Khorsun
~ ~ ~
(CORE-5447) EXECUTE STATEMENT <e> when <e> starts with '--' (comment) issues “Unexpected
end of command” error with a wrong column number.
~ ~ ~
(CORE-5432) Classic Server suffered a performance regression: too much time was being spent during
context switches.
fixed by D. Yemanov
142
Bugs Fixed
~ ~ ~
(CORE-5422) The error “Decompression overran buffer” could occur after rollback. It affected all platforms
but would appear particularly on Windows Superserver, when GCPolicy was set to 'Combined' or 'Cooperative'
and CpuAffinityMask was configured to more than a single core.
fixed by V. Khorsun
~ ~ ~
fixed by D. Yemanov
~ ~ ~
(CORE-5414) Error restoring on FB 3.0 from FB 2.5 backup: bugcheck 221 (cannot remap).
fixed by D. Yemanov
~ ~ ~
(CORE-5410) Dependencies were not stored when certain types of construction were used in subroutines.
~ ~ ~
(CORE-5393) Optimization was poor for some operations with views containing subqueries.
fixed by D. Yemanov
~ ~ ~
(CORE-5392) BUGCHECK 179 (decompression overran buffer) or an unexpected lock conflict could
happen during back-out of record versions.
fixed by D. Yemanov
~ ~ ~
(CORE-5390) isql would crash with corrupt memory when statement length exceeded 10 MB.
~ ~ ~
(CORE-5384) Plug-in manager was failing to provide the appropriate config information when the name
of the configuration file was set in plugins.conf.
fixed by A. Peshkov
~ ~ ~
~ ~ ~
143
Bugs Fixed
(CORE-5382) An SQL statement longer than 10MB could be processed (truncated) incorrectly.
fixed by D. Yemanov
~ ~ ~
(CORE-5381) Regression: A (select from view with nested view) query could not be executed.
fixed by D. Yemanov
~ ~ ~
(CORE-5368) Regression: a client application could hang or throw an access violation on selecting from
multiple threads using one embedded connection.
fixed by A. Peshkov
~ ~ ~
(CORE-5367) Regression: A BOOLEAN state as a parameter for a search condition was incorrectly
rejected as invalid.
~ ~ ~
(CORE-5366) Regression: A CASE expression with more than 255 conditions was being rejected.
~ ~ ~
fixed by V. Khorsun
~ ~ ~
(CORE-5314) UDFs declared with large varchars were taking excessive time to execute.
~ ~ ~
(CORE-3530) BETWEEN operand/clause was not supported for COMPUTED BY columns -- “feature
is not supported”. Now it is.
fixed by D. Yemanov
~ ~ ~
Server Crashes/Hang-ups
(CORE-5428) An old bug could occasionally cause a segmentation fault in Classic when the structure
of a table with triggers was modified (DDL) while another attachment was preparing a request to work with
144
Bugs Fixed
that table. In rare cases, pointers to the old triggers were cached by the request compiler and the fault would
occur the next time they were used.
fixed by A. Peshkov
~ ~ ~
fixed by A. Peshkov
~ ~ ~
(CORE-5417) The engine could hang if an automatic sweep was starting during a database shutdown.
fixed by V. Khorsun
~ ~ ~
(CORE-1894) (Old bug) Circular dependencies between computed fields would crash the engine.
~ ~ ~
Builds
(CORE-5120) Issues with the function snprintf (in autoconfing_msvc.h) and user-defined literals in VS
2015 (MSVC 14).
fixed by V. Khorsun
~ ~ ~
API
(CORE-5359) New API - MessageMetadata's getScale() was returning INTEGER, while
MetadataBuilder's setScale() expected unsigned.
fixed by A. Peshkov
~ ~ ~
POSIX Only
(CORE-5503) Classic Server was limited to 64 connections when using systemd init scripts
fixed by A. Peshkov
~ ~ ~
(CORE-5484) A database on an NFS share was unavailable when accessed using the mount point path.
145
Bugs Fixed
fixed by A. Peshkov
~ ~ ~
fixed by A. Peshkov
~ ~ ~
Windows Only
(CORE-5477) Trace was duplicating ascii_char(13) in its output on Windows.
fixed by V. Khorsun
~ ~ ~
Core Engine
(CORE-5355) XpbBuilder was failing to create a new TPB.
fixed by A. Peshkov
~ ~ ~
(CORE-5351) LEFT JOIN would incorrectly push a UDF into the inner stream, causing wrong results.
fixed by D. Yemanov
~ ~ ~
~ ~ ~
(CORE-5339) An assertion could occur in createDatabase() when doing the overwrite check.
fixed by A. Peshkov
~ ~ ~
(CORE-5337) A subquery in the insert list expression was ignoring changes made earlier in the same
executable block.
146
Bugs Fixed
fixed by V. Khorsun
~ ~ ~
(CORE-5329) A database could suffer partial corruption in the “use all space” (no-reserve) mode.
~ ~ ~
fixed by V. Khorsun
~ ~ ~
(CORE-5322) Cascade deletion in a self-referencing table could raise the error “no current record for
fetch operation”.
fixed by V. Khorsun
~ ~ ~
(CORE-5313) A “Data type unknown” error was occurring with the LIST operation.
~ ~ ~
(CORE-5307) Random “invalid transaction handle” errors were being returned from the engine.
fixed by D. Yemanov
~ ~ ~
fixed by V. Khorsun
~ ~ ~
(CORE-5302) REGRESSION: Performance was degraded when bulk inserting into a table with indices.
fixed by V. Khorsun
~ ~ ~
(CORE-5292) Trying to encrypt a database in the absence of the the appropriate key could corrupt it.
fixed by A. Peshkov
~ ~ ~
(CORE-5289) A small memory leak could occur when an empty result set was returned.
fixed by V. Khorsun
~ ~ ~
147
Bugs Fixed
fixed by A. Peshkov
~ ~ ~
(CORE-5277) Parameters with multi-byte character sets were being allowed to exceed the length limit
for VARCHAR fields.
~ ~ ~
(CORE-5275) Expression index could become inconsistent if CREATE INDEX was interrupted after b-
tree creation but before committing.
fixed by D. Yemanov
~ ~ ~
fixed by D. Yemanov
~ ~ ~
(CORE-5248) Consistency between roles and privileges in GRANT syntax needed improving in accordance
with the SQL standard.
fixed by A. Peshkov
~ ~ ~
fixed by A. Peshkov
~ ~ ~
(CORE-5241) Affected rows were not being counted for some update operations with views.
fixed by D. Yemanov
~ ~ ~
(CORE-5236) IN/ANY/ALL predicates could cause sub-optimal execution (late filtering) of joins.
fixed by D. Yemanov
~ ~ ~
148
Bugs Fixed
~ ~ ~
~ ~ ~
(CORE-5231) EXECUTE STATEMENT would throw a BLR error if the number of output parameters
exceeded 256.
fixed by D. Yemanov
~ ~ ~
(CORE-5226) An incorrect result set (missing records) could be returned by an ORDER plan query
navigating on a descending index.
fixed by D. Yemanov
~ ~ ~
(CORE-5225) Authentication was ending with first plug-in that had the user but would fail there, instead
of continuing with the next plug-in.
fixed by A. Peshkov
~ ~ ~
(CORE-5222) SELECT WITH LOCK could raise unexpected update conflict errors under concurrent load.
fixed by D. Yemanov
~ ~ ~
(CORE-5213) A database could get decrypted after changing a couple of bytes in the database header
without 'agreement' from the crypt plug-in.
fixed by A. Peshkov
~ ~ ~
(CORE-5210) POST_EVENT was not working with the Fb 3.0 server and client.
fixed by V. Khorsun
~ ~ ~
~ ~ ~
fixed by D. Yemanov
149
Bugs Fixed
~ ~ ~
(CORE-5142) The error “no current record to fetch” was thrown if some record was to be deleted both by
the statement itself and by some trigger fired during statement execution.
fixed by V. Khorsun
~ ~ ~
(CORE-1746) An expression index could be created while inserts into the table were in progress.
fixed by V. Khorsun
~ ~ ~
Server Crashes
(CORE-5234) Access violation from certain UDFs would cause the server to crash.
fixed by V. Khorsun
~ ~ ~
API/Remote Interface
(CORE-5347) Race conditions could arise when initializing wire compression.
fixed by A. Peshkov
~ ~ ~
(CORE-5296) A network protocol error was exhibited when performing a callback to a client for the
database crypt key.
fixed by A. Peshkov
~ ~ ~
fixed by A. Peshkov
~ ~ ~
(CORE-5224) Transaction id tags for the Services API did not support new 48-bit transaction ids.
fixed by D. Yemanov
~ ~ ~
(CORE-5154) The Services API would not work with non-ASCII database names.
fixed by D. Sibiryakov
150
Bugs Fixed
~ ~ ~
Utilities
fbsvcmgr
(CORE-5270) fbsvcmgr was not producing any error when it attempted to shut down a database without
a specified timeout (prp_force_shutdown N).
fixed by A. Peshkov
~ ~ ~
gbak
(CORE-5228) Restore could hang if the database contained more than 4 billion records.
fixed by D. Yemanov
~ ~ ~
gfix
(CORE-5295) Validation could read after the end-of-file when operating on a multi-file database.
fixed by V. Khorsun
~ ~ ~
isql
fixed by A. Peshkov
~ ~ ~
(CORE-5294) isql would leak memory when SHOW GRANTS was used on a new, empty database.
fixed by A. Peshkov
~ ~ ~
(CORE-5220) isql -[e]X[tract_metadata] output was omitting double quotes for the COLLATE <collation>
clause of a CREATE DOMAIN statement when <collation> was for any non-ascii character set.
~ ~ ~
151
Bugs Fixed
(CORE-5218) isql -[e]X[tract_metadata] was not exporting explicitly defined names for NOT NULL
constraints for Dialect 3 databases.
fixed by D. Yemanov
~ ~ ~
(CORE-5217) isql -[e]X[tract_metadata] could crash while exporting an exception with message text
length longer than 127 bytes.
fixed by D. Yemanov
~ ~ ~
(CORE-5207) isql -[e]X[tract_metadata] could generate invalid GRANT USAGE statements for domains.
fixed by D. Yemanov
~ ~ ~
fixed by D. Yemanov
~ ~ ~
fixed by A. Peshkov
~ ~ ~
nBackup
(CORE-5264) A database located on a raw device could not be unlocked from an nBackup-locked state.
fixed by A. Peshkov
~ ~ ~
Builds
(CORE-5348) Databases created during the process of the Windows builds were owned by a Windows
administrator, not SYSDBA.
fixed by V. Khorsun
~ ~ ~
152
Bugs Fixed
fixed by A. Peshkov
~ ~ ~
POSIX-Specific
(CORE-5335) A segfault could occur when op_que_events was used on a port that was not prepared
for events processing.
fixed by A. Peshkov
~ ~ ~
(CORE-5285) A segfault could occur if an attachment was closed while requests were still open.
fixed by A. Peshkov
~ ~ ~
fixed by A. Peshkov
~ ~ ~
Core Engine
(CORE-5184) An assertion would occur in the cloop dispatcher when trying to save exception information
in the status interface.
fixed by A. Peshkov
~ ~ ~
(CORE-5182) Failure to find a record on re-fetch would produce inconsistent effects on subsequent
statement execution.
fixed by D. Yemanov
~ ~ ~
(CORE-5166) Unique key violation on a BOOLEAN column was returning an erroneous message.
~ ~ ~
153
Bugs Fixed
(CORE-5165) HAVING COUNT(*) NOT IN ( <Q> ) would erroneously exclude a record from the outer
result set. (<Q> represents a result set without nulls)
~ ~ ~
fixed by V. Khorsun
~ ~ ~
(CORE-5159) Regression: the engine could throw transliteration errors when running from a non-ASCII
system path.
~ ~ ~
(CORE-5157) The server could go into an infinite loop when data was being sent from a client to the
server in small packets.
fixed by A. Peshkov
~ ~ ~
(CORE-5149) Regression: LEFT JOIN was incorrectly pushing COALESCE into the inner stream, causing
wrong results.
fixed by D. Yemanov
~ ~ ~
(CORE-5147) CREATE TRIGGER was failing with the error "Ambiguous field name between table
B and table A".
~ ~ ~
(CORE-5146) Join order was sub-optimal if one table had a selective predicate and MIN was calculated
for the other one.
fixed by D. Yemanov
~ ~ ~
(CORE-5144) Deadlock could occur when a database was being encrypted or decrypted under high
parallel load.
fixed by A. Peshkov
~ ~ ~
(CORE-5133) ALTER SEQUENCE RESTART WITH was failing to change the initial value.
fixed by D. Yemanov
154
Bugs Fixed
~ ~ ~
(CORE-5130) Minor regression: wrong error message was being returned on an attempt to compile a view
with both a subquery and the WITH CHECK OPTION clause in its definition—an illegal combination.
~ ~ ~
(CORE-5122) The optimizer could avoid using an expression index if the query was running in a different
connection character set to the one that was in effect when the index was created.
fixed by D. Yemanov
~ ~ ~
(CORE-4645) Internal Firebird consistency check (cannot find tip page (165), file: tra.cpp line: 2375)
would occur if too many transactions were created for one connection to a read-only database. This was a very
old bug, dating back to InterBase 6.
fixed by V. Khorsun
~ ~ ~
Server Crashes
(CORE-5153) Regression: The server would crash when aggregate functions were used together with
the NOT IN predicate.
~ ~ ~
Utilities
gbak
(CORE-5143) gbak restore could fail when there was some SQL function accessing a table while the
switch -O(NE_AT_A_TIME) was in use.
fixed by D. Yemanov
~ ~ ~
gfix
(CORE-5140) An attempt to set the number of page buffers to a non-supported value would return the
wrong error message.
fixed by V. Khorsun
155
Bugs Fixed
~ ~ ~
isql
(CORE-5194) An invalid COMPUTED BY definition was being generated by the 'extract metadata'
operation.
~ ~ ~
Monitoring
fixed by D. Yemanov
~ ~ ~
User Management
(CORE-5189) The codes of operation for user management plug-ins were missing from the public API.
fixed by A. Peshkov
~ ~ ~
(CORE-5162) Users with the same name can co-exist in the security database if they are created by
different plug-ins. However, tags or attributes for a user created using one plug-in were being displayed in the
SEC$ virtual tables for the same-name user created by the other plug-in.
fixed by A. Peshkov
~ ~ ~
(CORE-5155) [CREATE OR] ALTER USER statement would fail if the PASSWORD parameter was present
and was not specified immediately after the USER parameter.
fixed by A. Peshkov
~ ~ ~
Builds
(CORE-5181) The build would fail if HAVE_MMAP was not defined.
fixed by A. Peshkov
~ ~ ~
156
Bugs Fixed
fixed by A. Peshkov
~ ~ ~
fixed by A. Peshkov
~ ~ ~
Minor Improvements
Implemented by A. Peshkov
~ ~ ~
(CORE-1538) NEW: An option was added to the API function isc_database_info() to return the
number of free pages in a database.
Implemented by V. Khorsun
~ ~ ~
(CORE-5112) IMPROVEMENT: The error messages for a malformed SQDLA were improved.
Implemented by D. Sibiryakov
~ ~ ~
(CORE-5100) IMPROVEMENT: Improved control over database crypt keys, see Encryption Tasks.
Implemented by A. Peshkov
~ ~ ~
(CORE-5083) IMPROVEMENT: A method was provided to set the correct offsets in user-implemented
IMessageMetadata.
Implemented by A. Peshkov
~ ~ ~
(CORE-5077) IMPROVEMENT: In isql, SHOW DATABASE includes the encryption status of the
database, as does gstat -h[eader].
157
Bugs Fixed
Implemented by A. Peshkov
~ ~ ~
(CORE-5063) IMPROVEMENT: In isql, SHOW DATABASE includes the numbers of used and free
pages in the database.
Implemented by V. Khorsun
~ ~ ~
(CORE-5028) IMPROVEMENT: The remote port number was added to the monitoring table MON
$ATTACHMENTS.
Implemented by V. Khorsun
~ ~ ~
(CORE-4978) IMPROVEMENT: Validation and repair of lost data pages have been improved.
~ ~ ~
(CORE-2493) IMPROVEMENT: The IP address of the remote host is now appended to error messages
in firebird.log for TCP connections.
Implemented by V. Khorsun
~ ~ ~
Bugs
Core Engine
(CORE-5110) A false primary or foreign key violation could be reported when an attachment used the
isc_dpb_no_garbage_collect flag.
fixed by V. Khorsun
~ ~ ~
~ ~ ~
(CORE-5097) COMPUTED BY expressions were not being converted to their data type inside the engine.
~ ~ ~
(CORE-5093) ALTER COLUMN was not changing the type of a computed column where it should.
158
Bugs Fixed
~ ~ ~
(CORE-5082) The server was not validating the correctness of the user/password pair provided in the
EXECUTE STATEMENT operation.
fixed by A. Peshkov
~ ~ ~
(CORE-5078) The "Invalid BLOB ID" error was being thrown unexpectedly after a large VARCHAR
column was changed to text BLOB.
fixed by V. Khorsun
~ ~ ~
(CORE-5075) ON DISCONNECT trigger with EXECUTE STATEMENT was not working and would
lead to a server crash when it was recreated.
fixed by V. Khorsun
~ ~ ~
(CORE-5062)
fixed by A. dos Santos FernandesFunction CHAR_TO_UUID on an indexed column would throw the error
"expression evaluation not supported".
~ ~ ~
(CORE-5060) CREATE VIEW that selected from a system table would fail, despite all grants being
available.
fixed by A. Peshkov
~ ~ ~
(CORE-5056) The write lock on the database file was being cleared when retrieving the database statistics
via the Services API.
fixed by A. Peshkov
~ ~ ~
~ ~ ~
(CORE-5047) mapUser() routine would establish a secondary attachment using the wrong provider.
fixed by A. Peshkov
~ ~ ~
159
Bugs Fixed
(CORE-5039) Connecting to a service with an invalid service name would yield an incorrect error message.
fixed by A. Peshkov
~ ~ ~
(CORE-5034) A delay of at least 5 seconds could occur on disconnect if the disconnect followed closely
on an Event Manager initialization.
fixed by V. Khorsun
~ ~ ~
(CORE-5033) The file fb_user_mapping could be left behind in the Firebird lock directory after a
correct shutdown of all Firebird worker processes.
fixed by V. Khorsun
~ ~ ~
(CORE-5032) Connection to a database with its own security database was not possible in the absence
of security3.fdb.
fixed by A. Peshkov
~ ~ ~
(CORE-5026) Firebird authentication would give up after failing to establish authentication via the first
common plugin.
fixed by A. Peshkov
~ ~ ~
(CORE-5020) An ORDER BY clause on the key columns of a compound index could disable usage of
other indices.
fixed by D. Yemanov
~ ~ ~
(CORE-5018) Non-indexed predicates might not have been applied immediately after retrieval when
tables were being joined.
fixed by D. Yemanov
~ ~ ~
(CORE-5017) Interrupt of aux connection during TCP setup phase would cause a server exit due to an
unhandled exception.
fixed by A. Peshkov
~ ~ ~
(CORE-5014) Interrupt of aux connection during TCP setup phase was producing unclear error messages
in firebird.log.
160
Bugs Fixed
fixed by A. Peshkov
~ ~ ~
(CORE-4997) Races would occur when two threads tried simultaneously to establish the first enbedded
connection to the engine.
fixed by A. Peshkov
~ ~ ~
(CORE-4991) The Keyholder plug-in was being loaded on connection to a database but not on creating
a database.
fixed by A. Peshkov
~ ~ ~
(CORE-4980) The REVOKE operator could modify the privileges granted to system tables at database
creation time.
fixed by A. Peshkov
~ ~ ~
(CORE-4969) The SEC$USERS table became unavailable when an error occurred in any configured
UserManager plug-in.
fixed by A. Peshkov
~ ~ ~
(CORE-4964) Real errors during connection to a security database were being hidden by the Srp user
manager.
fixed by A. Peshkov
~ ~ ~
(CORE-4885) Retrieving the current user name when using Windows trusted authentication and an OS
user name containing non-ASCII characters would cause an error.
~ ~ ~
fixed by D. Yemanov
~ ~ ~
~ ~ ~
161
Bugs Fixed
Server Crashes
(CORE-5107) SET AUTODDL OFF and sequence of CREATE + ALTER + DROP VIEW would lead
to a server crash.
~ ~ ~
(CORE-5087) A database shutdown could cause a server crash if multiple attachments were running
EXECUTE STATEMENT.
fixed by V. Khorsun
~ ~ ~
(CORE-5016) The server could crash during garbage collection when a DELETE is executed after adding
a new referencing column.
fixed by D. Yemanov
~ ~ ~
(CORE-5015) The server could crash when an event was posted from an ON DISCONNECT trigger.
fixed by V. Khorsun
~ ~ ~
(CORE-4982) The server could crash during a select from a procedure if an exception was thrown while
backing out the current savepoint.
fixed by D. Yemanov
~ ~ ~
Database Encryption
(CORE-5105) Deadlocks could occur when a database was initially encrypted.
fixed by A. Peshkov
~ ~ ~
fixed by A. Peshkov
~ ~ ~
fixed by A. Peshkov
162
Bugs Fixed
~ ~ ~
(CORE-4999) Trying to access a database with an invalid crypt key would cause a deadlock.
fixed by A. Peshkov
~ ~ ~
fixed by A. Peshkov
~ ~ ~
API/Remote Interface
(CORE-5102) fbclient.dll API calls were (wrongly) modifying the FPU control word.
fixed by V. Khorsun
~ ~ ~
(CORE-5067) New connections were being blocked as a consequence of sweeps of the security database
taking too long.
fixed by V. Khorsun
~ ~ ~
(CORE-5042) The V.3 client could not create a database on a V.2.5 server.
fixed by A. Peshkov
~ ~ ~
(CORE-5029) A crash could occur in fbclient when a multi-threaded application was using the XNET
protocol.
fixed by V. Khorsun
~ ~ ~
(CORE-4998) Neither client nor server could close the connection after failed authentication.
fixed by V. Khorsun
~ ~ ~
Utilities
gbak
(CORE-5101) Restore wass slow when the database contained many small tables with indices.
163
Bugs Fixed
fixed by V. Khorsun
~ ~ ~
gstat
(CORE-5088) A segmentation fault could occur while gstat -h was closing.
fixed by A. Peshkov
~ ~ ~
isql
(CORE-5092) The EXTRACT command would lose the data types of COMPUTED BY columns.
~ ~ ~
~ ~ ~
(CORE-5061) Plan output was being unexpectedly truncated after a query was simplified by shortening it.
fixed by D. Yemanov
~ ~ ~
Monitoring
(CORE-4708) Content of MON$EXPLAINED_PLAN in MON$STATEMENTS was being truncated if
it exceeded the 32KB limit.
fixed by D. Yemanov
~ ~ ~
(CORE-4179) The MON$ tables became unavailable when there was intensive disk-bound load.
fixed by D. Yemanov
~ ~ ~
164
Bugs Fixed
fixed by A. Peshkov
~ ~ ~
(CORE-5002) (WINDOWS): The Windows installer exhibited some character set confusion (ANSI vs.
UTF8) in its GUI for non-English environments.
fixed by P. Reeves
~ ~ ~
(CORE-4910) (WINDOWS): The Windows build would fail if a path to source files contained spaces.
fixed by D. Sibiryakov
~ ~ ~
(CORE-4862) (WINDOWS): ibase.h from the x64 package included a nonexistent file.
fixed by D. Yemanov
~ ~ ~
(CORE-4842) (POSIX): the installer script would fail in some Linux environments.
~ ~ ~
Minor Improvements
(CORE-4911) IMPROVEMENT: Most errors that occur in providers are fatal and it is pointless to try
other providers in the hope another will succeed when that one failed. As an example, if the remote redirector
detects that the format of the database connection string matches a certain protocol, trying other providers will
be futile if connection on that protocol failed. Or, suppose the engine reports some internal database error (other
than invalid ODS version) it will be no use trying to open the same database through the loopback provider.
A better option appeared to be to enumerate the codes for those errors after which it would make sense to try
other providers—primarily isc_unavailable and isc_no_priv. Given the desirability of retaining the
content of the status vector as-is, the solution was to add some more error codes.
Implemented by A. Peshkov
~ ~ ~
(CORE-4898) IMPROVEMENT: Creation and loading of functions was slow when there were many
functions in the database. This process has been given a speed boost.
165
Bugs Fixed
~ ~ ~
(CORE-4880) IMPROVEMENT: Creating packages containing many functions was slow. This process
has been given a speed boost.
~ ~ ~
(CORE-4939) IMPROVEMENT: I/O operations on the nBackup backup file at are now aligned at the
page size boundary
Implemented by V. Khorsun
~ ~ ~
(CORE-4936) IMPROVEMENT: Internal contention in the background garbage collector has been reduced
Implemented by V. Khorsun
~ ~ ~
(CORE-4935) IMPROVEMENT: Performance was improved on backing out a dead record version or
undoing a newly created primary record version when the back-version chain gets too long
Implemented by V. Khorsun
~ ~ ~
Bugs
Core Engine
(CORE-4984) Ordering by a compound index together with a range condition was giving wrong results
fixed by D. Yemanov
~ ~ ~
(CORE-4954) Packaged procedure with a default input value would not be called if the default parameter
was not specified
~ ~ ~
fixed by V. Khorsun
~ ~ ~
166
Bugs Fixed
fixed by A. Peshkov
~ ~ ~
(CORE-4950) Statistics could not be recalculated or updated for any system index
~ ~ ~
(CORE-4947) A compound ALTER TABLE statement that tried to ADD and DROP the same check
constraint would fail
~ ~ ~
(CORE-4943) Casting a Dialect 1 date to string would break when a domain with a check constraint
was present
~ ~ ~
(CORE-4938) Operations (get statistics, change forced wites, make backup) could not be completed on
a database when working in embedded mode
fixed by V. Khorsun
~ ~ ~
(CORE-4929) PSQL source with “ELSE IF ( <expr> ) THEN” block containing commands to manipulate
an explicit cursor would not compile
fixed by D. Yemanov
~ ~ ~
(CORE-4921) Predicate IS [NOT] DISTINCT FROM was not being pushed into unions/aggregates,
resulting in sub-optimal plans
fixed by D. Yemanov
~ ~ ~
(CORE-4917) ALTER DOMAIN ... TO <new_name> would allow the <new_name> to be specified in
the same pattern as domains generated by the system, i.e., matching to 'RDB$[[:DIGIT:]]*'
~ ~ ~
(CORE-4914) Moving a database into the 'full shutdown' state could corrupt indexes on long-key text
columns
fixed by V. Khorsun
167
Bugs Fixed
~ ~ ~
(CORE-4909) MERGE / HASH JOINs would produce incorrect results when VARCHAR join keys
differed only by trailing spaces
fixed by D. Yemanov
~ ~ ~
(CORE-4906) An access violation would occur if the server was shut down with active trace session(s)
fixed by V. Khorsun
~ ~ ~
(CORE-4904) Index corruption could occur while inserting data into a long-key-indexed field
fixed by V. Khorsun
~ ~ ~
~ ~ ~
(CORE-4897) The fbsvcmgr could produce a broken log when restoring a database
fixed by A. Peshkov
~ ~ ~
(CORE-4890) Placing a comment (single-lined or multi-lined) between the final END statement and the
terminator character (^) in stored procedure code produced a compiling error if the utility tool used the legacy
API
fixed by A. Peshkov
~ ~ ~
(CORE-4889) Using fbsvcmgr with action_trace_start under SuperSsrver would cause a livelock
and prevent attachments using local protocol
fixed by V. Khorsun
~ ~ ~
(CORE-4887) An AFTER CREATE/ALTER PACKAGE DDL trigger would run before inserts and updates
of RDB$PROCEDURES and RDB$FUNCTIONS, whereas it should run after all changes to the system tables.
~ ~ ~
(CORE-4884) A script containing EXECUTE BLOCK with MULTIPLE nested BEGIN..END statements
would cause a crash during parsing
168
Bugs Fixed
~ ~ ~
(CORE-4872) The V.3 fbclient could not work with servers older than V.2.5 via the remote protocol
fixed by D. Yemanov
~ ~ ~
(CORE-4861) A segmentation fault could occur when working with a saved exception in a request
fixed by A. Peshkov
~ ~ ~
(CORE-4854) The client library was handling non-UTF8 representation of international characters incor-
rectly in the SPB
fixed by A. Peshkov
~ ~ ~
(CORE-4848) MERGE ... WHEN NOT MATCHED ... RETURNING was returning wrong (non-null)
values when no insert was performed
~ ~ ~
(CORE-4846) Altering a trigger to attempt to change the table to which it belongs did not succeed but it
failed with bizarre results and an unhelpful error message
~ ~ ~
(CORE-4836) GRANT UPDATE(c) ON T TO U01 WITH GRANT OPTION: user U01 would be unable
to revoke this privilege if some DML was executed before REVOKE
fixed by A. Peshkov
~ ~ ~
(CORE-4710) “Invalid request BLR at offset 361 context already in use (BLR error)” was the wrong
message for the error concerned, occurring only when the context count was near the 256 limit
fixed by D. Yemanov
~ ~ ~
fixed by V. Khorsun
~ ~ ~
169
Bugs Fixed
(CORE-4585) A column CHECK constraint could not be created if the column was based on a domain
~ ~ ~
(CORE-4497) Regression: wrong handling in FOR-cursor when a “NOT EXISTS( select from <view> )”
expression was used to check results obtained from a stored procedure
fixed by D. Yemanov
~ ~ ~
(CORE-4292) The server would ignores asynchronous requests (monitoring or cancellation) while preparing
a query with a lot of windowed functions
~ ~ ~
(CORE-4279) Invalid error message: “CHARACTER SET OCTETS is not defined” when creating a
database specifying isc_dpb_lc_ctype = OCTETS
~ ~ ~
(CORE-4277) A database could be created with an invalid character set as its default
~ ~ ~
(CORE-4276) CREATE TABLE would throw an error if a column was being defined with the character
set DOS775
~ ~ ~
(CORE-4107) (subquery + derived table + union) would produce a wrong result set
fixed by D. Yemanov
~ ~ ~
(CORE-3717) Anomalies existed between the three methods of user management, regarding valid user
names and passwords
fixed by A. Peshkov
~ ~ ~
~ ~ ~
170
Bugs Fixed
POSIX-Specific
(CORE-4919) On AIX and Solaris, all processes on a Classic server would hang after the death of one
process
fixed by A. Peshkov
~ ~ ~
Windows-Specific
(CORE-4859) Embedded server could not work without the folder C:\ProgramData\firebird
fixed by V. Khorsun
~ ~ ~
(CORE-4860) Online validation on Windows would fail if the dbname argument contained forward slash
('/') and a concurrent attachment existed that also used '/'
fixed by V. Khorsun
~ ~ ~
Services API
(CORE-4879) When using the Services API to manage users (from fbsvcmgr or by building a SPB in some
program, for example) it was required—but not documented—to place the user name parameter immediately
after the desired action (add/modify). If any other parameter was placed before the user name, the Services
Manager on the server would go crazy and build a wrong command line for the gsec service.
fixed by A. Peshkov
~ ~ ~
Utilities
fbsvcmgr
(CORE-4855) Online validation during DML activity in another connection would lead to errors: “Error
while trying to read from file” and “Page in use during flush (210)”
fixed by V. Khorsun
~ ~ ~
(CORE-4876) A named trace session launched by fbsvcmgr with a non-empty value for the parameter
trc_name could not be stopped using its name
171
Bugs Fixed
fixed by V. Khorsun
~ ~ ~
gbak
(CORE-4928) The connection information in an ON CONNECT trigger could not be saved if the connection
was established by gbak
~ ~ ~
gfix
(CORE-4899) Using gfix -online in Classic returned the message "IProvider::attachDatabase failed
when loading mapping cache" if access was using a remote protocol
fixed by A. Peshkov
~ ~ ~
fixed by V. Khorsun
~ ~ ~
(CORE-3548) gfix would return an error after correctly shutting down a database
fixed by A. Peshkov
~ ~ ~
isql
(CORE-4882) The isql INPUT command (or the -i option at the command line) was reading large (>
64K) lines incorrectly
~ ~ ~
fixed by A. Peshkov
~ ~ ~
(CORE-4870) In isql, SET COUNT ON reports the wrong number of affected rows when issuing UPDATE
on a view which was created WITH CHECK OPTION
172
Bugs Fixed
~ ~ ~
Core Engine
(CORE-4819) failure of the engine to check the validity of RETURNING_VALUES for EXECUTE
PROCEDURE and INTO for EXECUTE STATEMENT could lead to bugchecks.
~ ~ ~
(CORE-4809) HASH/MERGE JOIN was not used for more than two streams if they were joined via
USING/NATURAL clauses and the join was based on DBKEY concatenations.
fixed by D. Yemanov
~ ~ ~
fixed by D. Yemanov
~ ~ ~
(CORE-4798) Regression: MIN() or MAX() with a join would ignore possible index navigation.
fixed by D. Yemanov
~ ~ ~
(CORE-4789) Timestamps that were out of valid range were not prevented from being cast to VARCHAR
or CHAR.
~ ~ ~
(CORE-4786) When an attempt was made to insert a duplicate value into a primary or unique key column,
where the length of the key was 127 characters or more, the problematic key was not shown in the error message.
fixed by D. Yemanov
~ ~ ~
(CORE-4781) Maximum string length (32765 bytes) was not being validated by the parser.
~ ~ ~
173
Bugs Fixed
(CORE-4774) Table aliasing was being required unnecessarily when doing UPDATE ... RETURNING
RDB$ pseudo-columns.
~ ~ ~
(CORE-4768) CREATE USER ... TAGS ( argument_1 = 'value1', ..., argument_N = 'valueN' ) would
return wrong results from the statement when there were many arguments.
fixed by A. Peshkov
~ ~ ~
(CORE-4767) In CREATE USER ... TAGS ( attr = 'prefix #suffix' ) the character “#” in the attribute value
would cause the subsequent characters to be dropped from storage.
fixed by A. Peshkov
~ ~ ~
(CORE-4760) A user with non-ascii (multi-byte) characters in the name could not be created.
fixed by A. Peshkov
~ ~ ~
(CORE-4759) A request synchronization error could occur when building an expression index.
fixed by V. Khorsun
~ ~ ~
(CORE-4755) A parameterized exception would produce wrong output when the number of arguments
exceeded seven.
~ ~ ~
(CORE-4754) Manipulations with a GTT from several attachments (using EXECUTE STATEMENT
with an ON EXTERNAL clause and different roles) could lead to the error “Internal Firebird consistency check
(invalid SEND request (167), file: JrdStatement.cpp line: 325)”.
fixed by V. Khorsun
~ ~ ~
fixed by V. Khorsun
~ ~ ~
(CORE-4752) EXECUTE STATEMENT using BLOB parameters would result in an “Invalid BLOB
ID” error.
174
Bugs Fixed
~ ~ ~
(CORE-4747) The error “Invalid BLOB ID” could occur when retrieving MON$STATEMENTS.MON
$SQL_TEXT using EXECUTE STATEMENT with an ON EXTERNAL clause with the db_connect argument
unspecified.
fixed by V. Khorsun
~ ~ ~
(CORE-4744) The statement ALTER DATABASE SET DEFAULT CHARACTER SET exhibited two
faults: 1) it would take effect only once for the current attachment; 2) it was not checking that the new character
set existed until it was actually used.
~ ~ ~
(CORE-4743) A granted role would not work with a non-ASCII user name.
fixed by A. Peshkov
~ ~ ~
(CORE-4740) SIMILAR TO with quantifier {n,} in the pattern was failing in v.2.5 with the error “Invalid
pattern” and was producing strange results in v.3.0.
~ ~ ~
~ ~ ~
(CORE-4725) Inconsistencies were exhibited with ALTER DOMAIN and ALTER TABLE involving
DROP NOT NULL and PRIMARY KEYs.
~ ~ ~
(CORE-4719) The message “Statement failed, SQLSTATE = 00000 + unknown ISC error 0” would appear
when issuing REVOKE ALL ON ALL FROM <existing_user>.
fixed by A. Peshkov
~ ~ ~
(CORE-4713) A “BLOB not found” error would be thrown at rollback after inserting into a table with
an expression index.
fixed by V. Khorsun
175
Bugs Fixed
~ ~ ~
(CORE-4712) Messages stating “Error in isc_release_request() ... when working with legacy security
database” were appearing in firebird.log for the Classic server when connecting with legacy authentication.
fixed by A. Peshkov
~ ~ ~
fixed by D. Yemanov
~ ~ ~
(CORE-4684) An error was being thrown while preparing a complex query (“Too many Contexts of
Relation/Procedure/Views. Maximum allowed is 256”.)
fixed by D. Yemanov
~ ~ ~
(CORE-4675) Conditions like WHERE <field> = <cursor>.<field> would not use an existing index.
fixed by D. Yemanov
~ ~ ~
(CORE-4673) A computed index based on a computed column would store NULL for all its keys.
fixed by D. Yemanov
~ ~ ~
fixed by D. Yemanov
~ ~ ~
(CORE-4668) SELECT FROM MON$TABLE_STATS did not work on Superclassic and Classic.
fixed by D. Yemanov
~ ~ ~
(CORE-4665) Search criteria would produce wrong results on WHERE <field_C> STARTING WITH
<:value> ORDER BY <field_N> when field_C was the leading part of a compound index key consisting of
{ field_C, field_N }.
fixed by D. Yemanov
~ ~ ~
(CORE-4659) A bug was introduced when implementing support for multiple user managers, whereby
the error “Missing security context for .....\SECURITY3.FDB” could appear when performing some operations
where per-database security was configured.
176
Bugs Fixed
fixed by A. Peshkov
~ ~ ~
(CORE-4656) The server could hang while chasing dead record versions.
fixed by D. Starodubov
~ ~ ~
fixed by D. Starodubov
~ ~ ~
(CORE-4648) A user with the RDB$ADMIN role was denied the privilege for CREATE DATABASE.
fixed by A. Peshkov
~ ~ ~
(CORE-4644) Security context and open database errors could present under heavy concurrent load.
fixed by A. Peshkov
~ ~ ~
(CORE-4634) The error “No current record for fetch operation” could occur when the same indexed
column was specified in both the WHERE and the ORDER BY clauses.
fixed by D. Yemanov
~ ~ ~
(CORE-4631) When the shared memory region backing the lock table could not be remapped, the status
vector would return the error message “Lock manager out of room” without any low-level details (e.g. OS level
error), thus hiding the real cause of the problem.
fixed by D. Yemanov
~ ~ ~
(CORE-4624) Firebird's handling of ':' characters in mount table entries was invalid.
fixed by A. Peshkov
~ ~ ~
(CORE-4623) PSQL variables based on “Domain” and “Type Of” referring to BLOB with sub_type <
0 were no longer working.
~ ~ ~
(CORE-4622) Triggers with the UPDATE OR INSERT statement and IIF() were not working as expected.
177
Bugs Fixed
fixed by D. Yemanov
~ ~ ~
(CORE-4618) Rollback was failing to undo changes when a MERGE statement was updating the same
target rows multiple times and the optimizer used PLAN MERGE.
fixed by D. Yemanov
~ ~ ~
(CORE-4604) EXECUTE STATEMENT was inflating the CHAR_LENGTH() size for VARCHARs.
~ ~ ~
(CORE-4599) The REPLACE() function was not working correcting with multi-byte character sets.
~ ~ ~
(CORE-4583) The embedded engine would try to load the ICU DLLs from PATH folders.
fixed by A. Peshkov
~ ~ ~
(CORE-4582) During the “linger” period, problems would occur when attempting to change some database
properties.
fixed by A. Peshkov
~ ~ ~
(CORE-4581) The embedded server was trying to load UDFs from wrong place.
fixed by V. Khorsun
~ ~ ~
(CORE-4572) The incorrect error message was returned for PSQL functions when the number of actual
arguments did not match the number of formal arguments.
fixed by D. Yemanov
~ ~ ~
(CORE-4571) Selecting from a table with ICU columns would fail where the database had been created
on Linux with ICU 4.2.1 and then copied to Windows.
fixed by A. Peshkov
~ ~ ~
(CORE-4561) BUGCHECK(183) was thrown when using a cursor with ORDER BY ID+0 and FOR
UPDATE WITH LOCK.
178
Bugs Fixed
fixed by D. Yemanov
~ ~ ~
fixed by D. Yemanov
~ ~ ~
fixed by D. Yemanov
~ ~ ~
(CORE-4472) The message “Modifying function <F> which is currently in use” was displayed when <F>
was called from an internal function declared in another unit.
fixed by D. Yemanov
~ ~ ~
(CORE-4384) Problems would occur when a table grew beyond 65535 pointer pages.
fixed by D. Yemanov
~ ~ ~
(CORE-4383) Index and BLOBs garbage collection was not working for in-place updates.
~ ~ ~
fixed by D. Sibiryakov
~ ~ ~
(CORE-4369) BUGCHECK(177) was being thrown for a MERGE involving multiple matches.
fixed by D. Yemanov
~ ~ ~
fixed by D. Yemanov
~ ~ ~
(CORE-4161) It was not possible to insert records into a table having a column GENERATED BY
DEFAULT AS IDENTITY in its DDL.
fixed by D. Yemanov
179
Bugs Fixed
~ ~ ~
~ ~ ~
~ ~ ~
(CORE-2848) Page-level “lock conversion denied” or “lock denied” errors could occur under high load
when no deadlocks were apparent.
fixed by V. Khorsun
~ ~ ~
fixed by D. Yemanov
~ ~ ~
Server Crashes
(CORE-4766) An access violation would occur on an attempt to manage the users list using EXECUTE
STATEMENT on behalf of a non-SYSDBA user having the RDB$ADMIN role.
fixed by V. Khorsun
~ ~ ~
(CORE-4705) Superclassic would crash at disconnect after running EXECUTE STATEMENT as non-
current user.
fixed by D. Yemanov
~ ~ ~
(CORE-4653) Infinite mutual stored procedure calls were causing the server to crash instead of returning
the appropriate error, “Too many concurrent executions of the same request”.
fixed by V. Khorsun
~ ~ ~
fixed by D. Yemanov
~ ~ ~
180
Bugs Fixed
(CORE-3632) The application would crash after calling fork() in a process using libfbembed.so.
fixed by A. Peshkov
~ ~ ~
API/Remote Interface
(CORE-4795) fbclient was executing the event callback function twice.
fixed by A. Peshkov
~ ~ ~
(CORE-4794) isc_cancel_events() was returning the error “invalid events id (handle) (code: 335545021)”
if an event was no longer queued.
fixed by A. Peshkov
~ ~ ~
(CORE-4788) The Superclassic server could hang when receiving a network packet.
fixed by A. Peshkov
~ ~ ~
fixed by A. Peshkov
~ ~ ~
fixed by A. Peshkov
~ ~ ~
(CORE-4646) Attachment would fail when using LegacyAuth on the server and the default configuration
on the client.
fixed by A. Peshkov
~ ~ ~
fixed by D. Yemanov
~ ~ ~
(CORE-4471) The Legacy_Auth plugin would not connect from a FB3 to a FB2.5 server when tried
after Win_Sspi.
181
Bugs Fixed
fixed by A. Peshkov
~ ~ ~
Utilities
isql
(CORE-4782) SHOW TABLE command in isql would fail when the table contained a field with Unicode
collation in its DDL.
~ ~ ~
(CORE-4706) isql was padding BLOB columns wrongly when the column alias had more than 17 characters.
~ ~ ~
fixed by A. Peshkov
~ ~ ~
(CORE-4503) In isql, the command SHOW USERS would display only the current user.
fixed by A. Peshkov
~ ~ ~
(CORE-4259) The call to setlocale(LC_CTYPE, "") should not be made in isql for Windows.
~ ~ ~
gbak
(CORE-4715) Restore of a shadowed database would fail if the -k (“restore without shadow”) switch
was used.
fixed by A. Peshkov
~ ~ ~
(CORE-4704) Permissions for generators and exceptions were being corrupted after backup/restore.
fixed by D. Yemanov
~ ~ ~
182
Bugs Fixed
gsec
(CORE-4698) Typing add -user SYSDBA -pw masterkey -admin yes into gsec would crash firebird.exe.
~ ~ ~
(CORE-4791) INSERTING, UPDATING and DELETING were made reserved words to fix ambiguity
with Boolean expressions.
~ ~ ~
(CORE-4735) An expression 'where bool_field IS true | false' can now use the same index as 'where
bool_field = true | false' if such an index exists.
~ ~ ~
(CORE-4731) Issuing DML or DDL statements on the RDB$-- system tables is prohibited in Firebird 3.
implemented by A. Peshkov
~ ~ ~
(CORE-4729) A flag was added to MON$DATABASE to assist in determining what type of security
database is used - default, self or other.
~ ~ ~
(CORE-4696) Flushing dirty pages to disk after creation of a temporary table index is now avoided.
implemented by V. Khorsun
~ ~ ~
(CORE-4685) Resolved some risky issues on POSIX when aliases in databases.conf were pointing
to symbolic or hard links, allowing invalid database accesses.
implemented by A. Peshkov
~ ~ ~
(CORE-4671) Internal temporary blobs are released early, to free up some memory\disk space.
183
Bugs Fixed
implemented by V. Khorsun
~ ~ ~
(CORE-4610) Diagnostics will now report a tag name when transliteration errors occur in Parameter
Block values.
implemented by A. Peshkov
~ ~ ~
(CORE-4607) Support added for having multiple UserManagers in firebird.conf and for using them
from SQL.
implemented by A. Peshkov
~ ~ ~
implemented by A. Peshkov
~ ~ ~
(CORE-4590) The data type of the result returned by the functions CHAR_LENGTH(), BIT_LENGTH()
and OCTET_LENGTH() for BLOBs was changed to BIGINT.
~ ~ ~
implemented by D. Yemanov
~ ~ ~
(CORE-3526) Support was added for WHEN SQLSTATE error handlers in PSQL.
implemented by D. Yemanov
~ ~ ~
(CORE-3234) Support was added for text BLOBs >= 32K as the first argument for the TRIM() function.
~ ~ ~
implemented by M. Kubecek
~ ~ ~
implemented by A. Peshkov
184
Bugs Fixed
~ ~ ~
Core Engine
(CORE-4576) The Cache Writer thread could not start.
fixed by V. Khorsun
~ ~ ~
~ ~ ~
~ ~ ~
(CORE-4566) Incorrect size of the output parameter or argument when EXECUTE BLOCK, procedure
or function used a system field in the metadata character set.
fixed by A. Peshkov
~ ~ ~
(CORE-4565) GDSCODE could have value = 0 in WHEN-section under some concurrent environments.
This bug affected Superclassic and Classic models but not Superserver.
fixed by V. Khorsun
~ ~ ~
~ ~ ~
fixed by D. Yemanov
~ ~ ~
(CORE-4522) DDL permissions were not protecting against removal of BLOB filters.
185
Bugs Fixed
fixed by R. Simakov
~ ~ ~
(CORE-4515) Regression: trace was reporting UPDATEs in statistics when doing INSERT into
<some_table>.
fixed by D. Yemanov
~ ~ ~
(CORE-4505) Use of a named cursor would fail if a statement was not executed.
fixed by A. Peshkov
~ ~ ~
(CORE-4488) A FOR SELECT <L> FROM <T> AS CURSOR <C> seems to return a wrong result
if table <T> is modified inside the cursor's BEGIN...END block. Cursor references, which are not variables,
should represent the current state of the record. If it was updated "in place" (via "where current of"), then cursor
references should return the new values. The first example reported in CORE-4488 should return NULLs.
~ ~ ~
fixed by A. Peshkov
~ ~ ~
(CORE-4477) The field RDB$MAP_TO_TYPE was missing from the system table RDB$TYPES.
fixed by A. Peshkov
~ ~ ~
fixed by A. Peshkov
~ ~ ~
(CORE-4464) Duplicate tags for CREATE/ALTER USER were not handled correctly.
fixed by A. Peshkov
~ ~ ~
(CORE-4453) Regression: The NOT NULL constraint, if declared in a domain, did not work.
~ ~ ~
(CORE-4447) A positioned UPDATE statement would preclude its index usage for the subsequent cursor
field references.
186
Bugs Fixed
fixed by D. Yemanov
~ ~ ~
(CORE-4444) Engine could hang and block all attachments in an out-of-disk-space condition during
physical backup.
fixed by V. Khorsun
~ ~ ~
fixed by V. Khorsun
~ ~ ~
(CORE-4435) After calling release() instead of detach() for an attachment to a database in embedded
mode, the attachment would remain interminably active.
fixed by A. Peshkov
~ ~ ~
fixed by A. Peshkov
~ ~ ~
~ ~ ~
(CORE-4396) A query executed via EXECUTE STATEMENT was returning the wrong result.
~ ~ ~
(CORE-4395) EXECUTE STATEMENT ON EXTERNAL was not finding a Firebird 2.5 database.
fixed by A. Peshkov
~ ~ ~
(CORE-4394) "Cursor not found error" when using the legacy API.
fixed by A. Peshkov
~ ~ ~
(CORE-4388) SELECT WITH LOCK could enter an infinite loop for a single record.
fixed by D. Yemanov
187
Bugs Fixed
~ ~ ~
~ ~ ~
(CORE-4379) Explicit cursors containing correlated subqueries in the select list were performing poorly.
fixed by D. Yemanov
~ ~ ~
(CORE-4376) Preparation of an erroneous DDL statement was not indicating that the main command failed.
~ ~ ~
(CORE-4375) A procedure would execute infinitely if it contained more than 32767 statements inside
any BEGIN/END block.
fixed by D. Yemanov
~ ~ ~
~ ~ ~
~ ~ ~
(CORE-4372) Deadlock could occur when two data pages contained record fragments pointing to each other.
fixed by V. Khorsun
~ ~ ~
fixed by D. Yemanov
~ ~ ~
(CORE-4366) A WHERE predicate containing NULL IS NOT DISTINCT FROM (select min(NULL)
from ...) was returning the wrong result.
fixed by D. Yemanov
188
Bugs Fixed
~ ~ ~
(CORE-4365) Equality predicate distribution was not working for some complex queries.
fixed by D. Yemanov
~ ~ ~
(CORE-4360) SELECT from derived table which contains GROUP BY on a column with a literal value
was returning wrong results.
fixed by D. Yemanov
~ ~ ~
(CORE-4354) Parsing of a recursive query would return the error “Column does not belong to referenced
table” when the source table did have such a column.
~ ~ ~
fixed by D. Yemanov
~ ~ ~
(CORE-4344) Error “no current record for fetch operation” when table inner joins procedure inner joins
table.
fixed by D. Yemanov
~ ~ ~
(CORE-4334) Resources (e.g. sort files) owned by a trigger could be left unreleased when the trigger
was interrupted asynchronously.
fixed by D. Yemanov
~ ~ ~
(CORE-4331) LAG, LEAD and NTH_VALUE would raise an error when the second argument was NULL.
~ ~ ~
(CORE-4330) The function LAG returned an incorrect result if the OFFSET value was assigned from a table.
~ ~ ~
(CORE-4326) The keyword SET was required in the ALTER USER statement when it should have been
optional.
fixed by A. Peshkov
189
Bugs Fixed
~ ~ ~
(CORE-4318) Regression: Predicates involving PSQL variables or parameters were not pushed inside
the aggregation.
fixed by D. Yemanov
~ ~ ~
(CORE-4313) Error “Attempt to reopen an open cursor” could be raised if the query handle was reused
in a different transaction.
fixed by D. Yemanov
~ ~ ~
(CORE-4309) The 'Cache Writer' record in MON$ATTACHMENTS would vanish when deleting, via
delete from MON$ATTACHMENTS, another connection that was running a heavy update on a big table.
fixed by V. Khorsun
~ ~ ~
(CORE-4307) Any fields present only in the WHERE clause of a view WITH CHECK OPTION would
cause an invalid CHECK CONSTRAINT violation.
~ ~ ~
fixed by A. Peshkov
~ ~ ~
~ ~ ~
(CORE-4286) The error “Statement already has a cursor assigned” would be thrown when trying to execute
another SQL statement using a different cursor name.
fixed by A. Peshkov
~ ~ ~
(CORE-4118) Expression index might be overlooked for derived fields or view fields.
fixed by D. Yemanov
~ ~ ~
(CORE-3305) A “BLOB not found” error would be returned after creating or altering an invalid trigger.
fixed by D. Yemanov
190
Bugs Fixed
~ ~ ~
(CORE-2350) An over-long column name for a SELECT alias was not being rejected, as it should have been.
~ ~ ~
(CORE-1475) A database which had active attachments could not be replaced from a backup file even
after the database was shut down.
fixed by D. Yemanov
~ ~ ~
Server Crashes
(CORE-4575) The server would crash in the garbage collector thread at disconnect of the last attachment.
fixed by V. Khorsun
~ ~ ~
(CORE-4568) The server could crash while disconnecting from the database under load.
fixed by D. Yemanov
~ ~ ~
fixed by V. Khorsun
~ ~ ~
(CORE-4506) The server would crash when executing almost any "show ..." commands after a reconnect.
fixed by A. Peshkov
~ ~ ~
(CORE-4500) Firebird would crash after an unsuccessful remapping of the lock table's shared memory.
fixed by D. Yemanov
~ ~ ~
(CORE-4498) The server would crash when getting an explained plan for a DBKEY-based retrieval.
fixed by D. Yemanov
~ ~ ~
191
Bugs Fixed
fixed by D. Yemanov
~ ~ ~
(CORE-4419) The server could crash while sorting records longer than 128KB.
fixed by D. Yemanov
~ ~ ~
(CORE-4322) The engine would crash when aggregate or window functions were used in a recursive query.
~ ~ ~
fixed by A. Peshkov
~ ~ ~
(CORE-4319) The engine would crash when the Trace config contained the line “connection_id=NN” and
an attempt was made to connect to a non-existent database or alias.
fixed by V. Khorsun
~ ~ ~
(CORE-4304) The engine would crash when an attempt to REcreate a table with a foreign key was made
after a syntax error that preceded the RECREATE attempt.
~ ~ ~
API/Remote Interface
(CORE-4275) CREATE DATABASE would fault if fbclient.dll was loaded from another directory
(Providers = Engine12).
fixed by V. Khorsun
~ ~ ~
Utilities
isql
(CORE-4480) isql would issue the warning “Bad debug info format” when connecting to a database with
stored functions after a restore.
fixed by D. Yemanov
192
Bugs Fixed
~ ~ ~
(CORE-4440) isql would crash without connecting when executing the command SHOW VERSION.
fixed by A. Peshkov
~ ~ ~
~ ~ ~
(CORE-4320) Regression: isql would crash when receiving statistics from the execution of a SQL query.
fixed by V. Khorsun
~ ~ ~
gbak
(CORE-4470) gbak restore would fail on a database containing dependency between views and packaged
functions.
~ ~ ~
(CORE-4425) User collations based on UNICODE were not being upgraded to a newer ICU version
on restore.
~ ~ ~
(CORE-4417) gbak refused to commit the index for a primary key with characters accented with an umlaut.
~ ~ ~
(CORE-4346) V.3 gbak was unable to restore backups made on earlier server versions.
fixed by D. Yemanov
~ ~ ~
nBackup
fixed by A. Peshkov
~ ~ ~
193
Bugs Fixed
qli
(CORE-4327) qli was throwing an error when copying NULL blobs between databases.
fixed by A. Peshkov
~ ~ ~
Core Engine
(CORE-4302) Descending index could be very inefficient for some keys
fixed by V. Khorsun
~ ~ ~
(CORE-4289) A NOT NULL field from a derived table could become NULL when referred to from
outside the derived table
fixed by D. Yemanov
~ ~ ~
(CORE-4281) TYPE OF arguments of stored functions could cause the server to hang if depending on
a domain or column that had been changed
~ ~ ~
(CORE-4270) A subquery involving a windowed function and a where <field> IN(select ...)
condition could cause an error
fixed by D. Yemanov
~ ~ ~
(CORE-4265) An unexpected lock conflict error could be raised while connecting to a heavily loaded
database
fixed by D. Yemanov
~ ~ ~
(CORE-4262) Context parsing errors could occur with derived tables and CASE functions
fixed by D. Yemanov
194
Bugs Fixed
~ ~ ~
(CORE-4261) JOIN result could be wrong when joined fields had been created via the row_number()
function
fixed by D. Yemanov
~ ~ ~
(CORE-4258) The boundary for the minimum value for BIGINT/DECIMAL(18) was wrong
~ ~ ~
(CORE-4251) The Guardian service could write garbage after the end of a message in the Event Log
fixed by V. Khorsun
~ ~ ~
fixed by V. Khorsun
~ ~ ~
(CORE-4237) Metadata being reported from system table queries for UDF return arguments was different
to that returned in Firebird 2.5
~ ~ ~
~ ~ ~
(CORE-4229) Bidirectional cursor was not being positioned by the first call of FETCH LAST
fixed by D. Yemanov
~ ~ ~
(CORE-4227) A parser conflict was causing wrong evaluation of BETWEEN and Boolean expressions
~ ~ ~
fixed by V. Khorsun
~ ~ ~
195
Bugs Fixed
(CORE-4211) The embedded engine would hang for 5 seconds when closing, with errors about timeout
in shutdown process and invalid mutex being written into firebird.log
fixed by A. Peshkov
~ ~ ~
(CORE-4201) A computed field would return NULL inside a BEFORE INSERT trigger
fixed by D. Yemanov
~ ~ ~
(CORE-4198) An incorrect “token unknown” error would occur when an SQL string ended with a hex
number literal
~ ~ ~
~ ~ ~
fixed by D. Yemanov
~ ~ ~
~ ~ ~
(CORE-3989) Bad performance and slow response were exhibited when many concurrent sorts were
executed
fixed by D. Yemanov
~ ~ ~
(CORE-3921) With bugcheckabort=1 and sweep starting at gap ~21000, “Bugcheck 186 (record disap-
peared)” and 100% CPU load would occur
fixed by V. Khorsun
~ ~ ~
(CORE-2165) Unnecessary index reads could occur when using a strict inequality condition
fixed by V. Khorsun
~ ~ ~
196
Bugs Fixed
Server Crashes
(CORE-4293) The server could crash on a SELECT with a long or complex list of compound AND/
OR'd predicates
fixed by D. Yemanov
~ ~ ~
(CORE-4271) Recreation of an errant package body could cause the engine to crash
~ ~ ~
fixed by D. Yemanov
~ ~ ~
fixed by D. Yemanov
~ ~ ~
(CORE-4225) The server could crash when trace activity was attempted on a database having a database-
level trigger
fixed by V. Khorsun
~ ~ ~
fixed by A. Peshkov
~ ~ ~
API/Remote Interface
(CORE-4283) “Resource temporarily unavailable” errors could occur while events were being registered
simultaneously
fixed by A. Peshkov
~ ~ ~
(CORE-4236) Database shutdown was being reported as successfully completed before all active connec-
tions had actually been interrupted
fixed by D. Yemanov
197
Bugs Fixed
~ ~ ~
(CORE-4178) The new API was still returning obscure historical definition artifacts of data fields, instead
of proper metadata properties that would make the interface actually usable
fixed by A. Peshkov
~ ~ ~
fixed by A. Peshkov
~ ~ ~
Security/User Management
(CORE-4241) Log-in could succeed with an empty password
fixed by A. Peshkov
~ ~ ~
(CORE-4200) An uncommitted SELECT from the pseudo table sec$users would block new database
connections
fixed by A. Peshkov
~ ~ ~
Procedural Language
(CORE-4247) Positioned DELETE (WHERE CURRENT OF <CURSOR>) could fail for tables with
newly added fields
~ ~ ~
(CORE-4244) Creating a procedure could be a problem if it involved adding text in DOS864 character set
~ ~ ~
(CORE-4184) An error would be raised while executing an empty EXECUTE BLOCK with NOT NULL
output parameter
~ ~ ~
(CORE-4160) A parameterized exception would mishandle non-ASCII characters passed as the parameter
198
Bugs Fixed
~ ~ ~
(CORE-4145) Preparing an EXECUTE BLOCK that used domains was causing a memory leak
~ ~ ~
fixed by V. Khorsun
~ ~ ~
(CORE-4212) Dropping a foreign key on a Global temporary table would cause a server crash
fixed by V. Khorsun
~ ~ ~
(CORE-4203) Packaged routines with CHAR or VARCHAR parameters could not be created
~ ~ ~
(CORE-4180) CREATE COLLATION was not verifying the base collation character set
~ ~ ~
(CORE-4173) Setting a generator value twice in a single transaction would set it to zero
fixed by D. Yemanov
~ ~ ~
(CORE-4155) External routines DDL in packages was wrongly reporting termination with semi-colon
as an error
~ ~ ~
fixed by D. Yemanov
199
Bugs Fixed
~ ~ ~
fixed by D. Yemanov
~ ~ ~
(CORE-4240) Recursive query would return incorrect results if passage through more than one branch
was requested
fixed by D. Yemanov
~ ~ ~
~ ~ ~
Utilities
gfix
(CORE-4297) gfix would crash when the size of the description of a limbo transaction was larger than 1 KB
fixed by V. Khorsun
~ ~ ~
fbsvcmgr
(CORE-4298) fbsvcmgr was not recognising sts_record_versions and other sts switches
fixed by A. Peshkov
~ ~ ~
isql
(CORE-4259) Bug in the isql command setlocale(LC_CTYPE, "") on Windows due to a reference
to editline, which is not available on that platform
fixed by F. Schlottmann-Goedde
~ ~ ~
(CORE-4205) ISQL -x was failing to output the START WITH clause of generators/sequences
200
Bugs Fixed
~ ~ ~
fixed by D. Yemanov
~ ~ ~
fixed by F. Schlottmann-Goedde
~ ~ ~
gbak
(CORE-4202) Backup/restore from an older version to v.3.0 would fail with a BLR error
fixed by D. Yemanov
~ ~ ~
(CORE-4168) A backup containing procedures or triggers that selected from external tables could not
be restored with ExternalFileAccess = None
fixed by D. Yemanov
~ ~ ~
(CORE-4164) Owner name was missing for generators and exceptions restored from a backup
fixed by D. Yemanov
~ ~ ~
nbackup
(CORE-2648) nBackup's delta file was ignoring the Forced Writes setting of the database
fixed by V. Khorsun
~ ~ ~
(CORE-4235) Deadlock could occur while accessing the monitoring tables under concurrent load
~ ~ ~
(CORE-4176) Monitoring tables were returning incomplete information in Classic and Superclassic
configurations
201
Bugs Fixed
fixed by D. Yemanov
~ ~ ~
Trace
(CORE-4219) Regular expressions with double-slash would fail in trace
fixed by A. Peshkov
~ ~ ~
fixed by A. Peshkov
~ ~ ~
Installation Issues
(CORE-4153) Attempting to use Legacy_Auth directly after install would not work without restarting
the service
fixed by P. Reeves
~ ~ ~
Core Engine
(CORE-4135) Sweep was blocking the establishment of concurrent attachments in Superserver.
fixed by V. Khorsun
~ ~ ~
fixed by V. Khorsun
~ ~ ~
(CORE-4074) COMPUTED BY columns and POSITION function could produce garbled results.
202
Bugs Fixed
~ ~ ~
(CORE-4027) Creating a table with computed fields containing SELECT FIRST could produce a corrupted
result.
~ ~ ~
(CORE-3973) The SQLDA for an aliased column in a grouped query was missing the original table name,
column name and owner.
~ ~ ~
(CORE-3947) Wrong results were produced when a column in the WHERE clause used the collation
option (NUMERIC-SORT=1).
~ ~ ~
~ ~ ~
(CORE-3929) The invalid error “attempted update of read-only column” would appear when selecting
MINVALUE from a list of more than 255 elements.
~ ~ ~
(CORE-3894) When an attempt was made to reduce the size of a CHAR or VARCHAR column, the
numbers delivered in the error message were incorrect.
~ ~ ~
(CORE-3874) A computed column would appear in non-existent rows output from a left join.
~ ~ ~
(CORE-3820) Some character sets were duplicated in the system table RDB$TYPES.
~ ~ ~
203
Bugs Fixed
~ ~ ~
(CORE-3735) An unprivileged user could delete from the system tables RDB$DATABASE, RDB$COL-
LATIONS and RDB$CHARACTER_SETS.
fixed by D. Yemanov
~ ~ ~
(CORE-3694) “Internal consistency check” would occur in a query with grouping by subquery+stored
procedure+aggregate.
~ ~ ~
(CORE-3672) It was not possible to use the SUBSTRING function to create a computed index for large
columns.
~ ~ ~
(CORE-3638) Some collation tweaking: FR_CA_CI_AI collation was introduced; FR_FR was changed
to be identical to FR_CA and FR_FR_CI_AI was changed to be identical to the new FR_CA_CI_AI.
~ ~ ~
(CORE-3476) The LIST function was concatenating binary blobs as though they were text.
~ ~ ~
(CORE-3401) Collation errors could occur with the use of [type of] <domain> and type of <column>.
~ ~ ~
(CORE-3373) It was possible to store a string of length 31 characters into a VARCHAR(25) column.
~ ~ ~
(CORE-3338) Regression: Code changes had disabled support for expression indexes with COALESCE,
CASE and DECODE.
~ ~ ~
(CORE-3317) Success of row deletion depended on the order of insertion of the rows.
204
Bugs Fixed
fixed by V. Khorsun
~ ~ ~
~ ~ ~
fixed by A. Peshkov
~ ~ ~
(CORE-3250) The Firebird server could not be started under any user name other than “root”, “firebird”,
“interbas” or “interbase”.
fixed by A. Peshkov
~ ~ ~
(CORE-3239) The collation UTF8 UNICODE_CI could not be used in a compound index.
~ ~ ~
(CORE-3204) A constraint violation error involving CAST was not being raised inside views.
~ ~ ~
(CORE-3052) Comparisons involving multiple index segments could produce wrong result sets.
~ ~ ~
(CORE-2988) The concurrent transaction number was not being reported when a lock timeout occurred.
fixed by N. Samofatov
~ ~ ~
fixed by D. Yemanov
~ ~ ~
fixed by D. Sibiryakov
205
Bugs Fixed
~ ~ ~
~ ~ ~
(CORE-2922) The character set used in a constant was not being registered as a dependency.
~ ~ ~
~ ~ ~
(CORE-2798) Plan output lacked the names of views when selecting from views that contained procedure
calls.
fixed by D. Yemanov
~ ~ ~
fixed by D. Yemanov
~ ~ ~
(CORE-2678) A full outer join could not use available indices, resulting in very slow execution sometimes.
fixed by D. Yemanov
~ ~ ~
(CORE-2508) Use of certain choices of character in double-quoted index names, for example a bracket
character, could defeat the parsing logic when generating a human-readable plan.
fixed by D. Yemanov
~ ~ ~
(CORE-2155) A join of a stored procedure with a view or a table could fail with the error “No current
record for fetch operation”.
fixed by D. Yemanov
~ ~ ~
(CORE-1712) A buffer overrun error was being caught erroneously in a DOUBLE PRECISION to
VARCHAR conversion in a Dialect 1 database.
fixed by C. Valderrama C.
206
Bugs Fixed
~ ~ ~
~ ~ ~
(CORE-1550) An unnecessary index scan was executed when the same index is mapped to both WHERE
and ORDER BY clauses.
fixed by D. Yemanov
~ ~ ~
API/Remote Interface
(CORE-3718) The cient library could hang after an unsuccessful attempt to connect to the remote auxiliary
(events) port.
fixed by A. Peshkov
~ ~ ~
(CORE-3475) Parameters inside the CAST function were being wrongly described in the SQLDA as
non-nullable.
~ ~ ~
(CORE-3269) The client would perform detach incorrectly when the server became unavailable.
fixed by A. Peshkov
~ ~ ~
(CORE-2484) An erroneous “Success” message would be returned in the error status vector when failing
to connect to a trash database file.
fixed by C. Valderrama C.
~ ~ ~
(CORE-2431) String values in error messages were not converted to the connection character set.
~ ~ ~
Procedural Language
(CORE-4018) Use of a system domain in declarations of arguments or return values in a stored procedure
could prevent the procedure from being modifiable.
207
Bugs Fixed
~ ~ ~
(CORE-3737) EXECUTE BLOCK parameter definitions were not being respected and could cause wrong
behavior with respect to character sets.
~ ~ ~
(CORE-3545) Validation of domain CHECK constraints when used in PSQL declarations was inconsistent:
it was using the type of the expression, instead of the type of the variable.
~ ~ ~
(CORE-3055) The names of variables or arguments could be wrong or absent in error messages when
more than 256 variables were used.
~ ~ ~
(CORE-3047) Resolution of EXECUTE BLOCK parameter collations was using wrong logic.
~ ~ ~
(CORE-2204) Constraints on stored procedure output parameters were checked even when the procedure
returned no rows.
~ ~ ~
(CORE-1620) Incorrect error message (an absurd column number) was returned if an empty SQL string
was prepared for EXECUTE STATEMENT.
fixed by D. Yemanov
~ ~ ~
~ ~ ~
(CORE-3056) Problems could occur if further DDL commands were issued in the same transaction
following a CREATE COLLATION command.
208
Bugs Fixed
~ ~ ~
(CORE-2696) The ALTER TABLE command allowed the addition of a column with a NOT NULL
definition, allowing a non-savvy DBAdmin to wreck the table.
~ ~ ~
(CORE-1748) Unrestorable backup: a problem which would occur if ALTER TABLE...ADD COLUMN
added a column with a NOT NULL constraint. The fix for CORE-2696 has now made it impossible to do this.
~ ~ ~
(CORE-1518) Adding a non-nullable column to a populated table would render the table inconsistent. The
fix for CORE-2696 has now made it impossible to do this.
~ ~ ~
(CORE-1355) Client tools tended to be confused about how to interpret a NULL that is returned from
a non-nullable column. The fix for CORE-2696 has now made it impossible to add a non-nullable column to
a populated table.
It is not clear, though, whether this part of the fix makes it mandatory to specify a default value for a non-
nullable column.
~ ~ ~
(CORE-634) Bad behaviour of DELETE when the WHERE clause was a subquery involving FIRST/
SKIP: the operation would zap every row in the table.
fixed by V. Khorsun
~ ~ ~
(CORE-304) Any user could alter or drop generators and exceptions#a metadata security hole.
fixed by D. Yemanov
~ ~ ~
fixed by V. Khorsun
209
Bugs Fixed
~ ~ ~
fixed by V. Khorsun
~ ~ ~
(CORE-3416) Inserting a word containing the 8-bit character 'ä' into a CHARACTER SET ASCII column
would succeed instead of throwing a transliteration error.
~ ~ ~
(CORE-3201) The internal function ATAN2 was returning an incorrect value with arguments (0, 0).
~ ~ ~
(CORE-3174) An expression index involving TRIM could lead to an incorrect indexed lookup.
~ ~ ~
~ ~ ~
(CORE-2606) A multi-byte CHAR value requested as VARCHAR was returned with padded spaces.
~ ~ ~
(CORE-2238) With UTF8 and large varchar fields, IS DISTINCT FROM would cause the error “Imple-
mentation limit exceeded”.
fixed by D. Yemanov
~ ~ ~
(CORE-1188) STARTING WITH ? (where the parameter value supplied is an empty string) would fail
if the plan used a compound index.
~ ~ ~
(CORE-92) Infinite insertion cycle: INSERT INTO THIS_TABLE SELECT ... FROM THIS_TABLE
would loop forever until resources were exhausted.
fixed by V. Khorsun
210
Bugs Fixed
~ ~ ~
Command-line Utilities
(CORE-2547) Utilities did not always honour the minimum number of characters required to recognise
an option.
fixed by C. Valderrama C.
~ ~ ~
FbGuard
(CORE-2784) Guardian would keep creating more and more threads each time FBServer died.
fixed by C. Valderrama C.
~ ~ ~
(CORE-1595) Firebird Guardian's tray icon would disappear after a Windows Explorer crash.
fixed by C. Valderrama C.
~ ~ ~
isql
(CORE-4137) isql was generating metadata script output with syntax errors in the CHARACTER SET
clause, e.g., CHARACTER SETISO8859_1.
~ ~ ~
~ ~ ~
(CORE-2788) isql would extract the array dimensions after the character set name.
fixed by C. Valderrama C.
~ ~ ~
gbak
(CORE-3575) gbak did not support backup volumes of size greater than 4GB.
211
Bugs Fixed
fixed by A. Peshkov
~ ~ ~
(CORE-2740) gbak would restore invalid views without any warning to the user.
fixed by C. Valderrama C.
~ ~ ~
fixed by C. Valderrama C.
~ ~ ~
nbackup
fixed by C. Valderrama C.
~ ~ ~
~ ~ ~
212
Chapter 14
213
Firebird 3.0 Project Teams
214
Appendix A:
Licence Notice
The contents of this Documentation are subject to the Public Documentation License Version 1.0 (the “Li-
cense”); you may only use this Documentation if you comply with the terms of this Licence. Copies of the
Licence are available at http://www.firebirdsql.org/pdfmanual/pdl.pdf (PDF) and http://www.firebirdsql.org/
manual/pdl.html (HTML).
The Initial Writer of the Original Documentation is: Helen Borrie. Persons named in attributions are Contrib-
utors.
Copyright (C) 2004-2015. All Rights Reserved. Initial Writer contact: helebor at users dot sourceforge dot net.
215