| Firebird Documentation Index | Firebird Home |
![]() |
Table of Contents
List of Tables
Table of Contents
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.
Follow these guidelines as you attempt to analyse your bug:
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.
You are warmly encouraged to make yourself known as a field-tester of this alpha by subscribing to the field-testers' list and posting the best possible bug description you can.
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 alpha.
You will find all of the README documents referred to in these notes in the doc sub-directory of your Firebird 2.5 Alpha 1 installation.
An automated "Release Notes" page in the Tracker provides lists and links for all of the Tracker tickets associated with this alpha. Use this link.
--The Firebird Project
Table of Contents
The primary goal for Firebird 2.5 was to establish the basics for a new threading architecture that is almost entirely common to both the Superserver and Classic models, taking in lower level synchronization and thread safety generally.
Although SQL enhancements are not a primary objective of this release, for the first time, user management becomes accessible through SQL CREATE/ALTER/DROP USER statements and syntaxes for ALTER VIEW and CREATE OR ALTER VIEW are implemented. PSQL improvements include the introduction of autonomous transactions and ability to query another database via EXECUTE STATEMENT.
Other new features and improvements in this release include:
Regular expression support using the SIMILAR TO predicate
ALTER COLUMN for computed columns
Autonomous transactions within a PSQL module (stored procedure, trigger or dynamically executable PSQL block)
Enhanced access to stored procedures in view definitions
New built-in functions for converting UUID CHAR(16) OCTETS strings to RFC4122-compliant format and vice versa
Ability to pass 32-bit and 64-bit integers as hexadecimal in numeric literal and X-prefixed binary string literal formats
New system role RDB$ADMIN in the ODS 11.2 database allows SYSDBA to transfer its privileges to another user on a per-database basis
More information in the monitoring tables
Asynchronous cancellation of connections
Statements now return an SQL-2003 standard 5-alphanumeric SQLSTATE completion code
New constant DSQL_unprepare available for use with isc_dsql_free_statement for efficient unpreparing of statements
Table of Contents
On-disk structure (ODS) changes include the following:
Additions to the Firebird API include.-
Tracker reference CORE-1761.
Statements now return an SQL-2003 standard 5-alphanumeric SQLSTATE completion code. Further information to come.
Tracker reference CORE-1741.
The new option DSQL_unprepare (numeric value 4) for the API routine isc_dsql_free_statement() allows the DSQL statement handle to survive the “unpreparing” of the statement.
Previously, the isc_dsql_free_statement() function supported only DSQL_close (for closing a named cursor) and DSQL_drop (which frees the statement handle).
The API addition is:
#define DSQL_close 1
#define DSQL_drop 2
#define DSQL_unprepare 4
New fb_cancel_operation() API call, allowing cancellation of the current activity being performed by some kind of blocking API call in the given connection.
More information to come.
New fb_shutdown() API call. When used for the embedded engine, it terminates all the current activity, rolls back active transactions, disconnects active attachments and shuts down the engine gracefully.
At this point (Alpha 1) it is implemented as a no-op for the other client libraries. This may change before the final release.
More information to come.
Table of Contents
No new configuration parameters are added in this version. However, certain changes affect existing parameters, as follows:
On Windows server platforms, since V.2.1, Authentication has been used for configuring the server authentication mode if you need it to be other than the default mixed.
The mode settings for v.2.5 are the same, viz.
trusted makes use of Windows “trusted authentication” which, under the right conditions, may be the most secure way to authenticate on Windows.
native sets the traditional Firebird server authentication mode, requiring users to log in using a user name and password defined in the security database.
mixed allows both.
Under v.2.5, although the modes are unchanged, configuring 'mixed' or 'trusted' mode no longer confers SYSDBA privileges to Windows domain administrators automatically by default. Please read the notes in the Administrative Features chapter regarding the new RDB$ADMIN role in ODS 11.2 databases and auto-mapping SYSDBA privileges to domain administrators.
Table of Contents
The primary objective of this release was to refactor Firebird's threading architecture to take advantage of the symmetric multiprocessing (SMP) capabilities of multiprocessor hardware. This has a noticeable effect on the scaleability of Superserver when multiple databases are being accessed simultaneously but its major effect is the emergence of the architectural “Superclassic” model that will underpin the fine-grained multi-threading under development for Firebird 3.
For Superserver, the new architecture will be most obvious in two ways:
Superserver threads distributed evenly to available processors according the the database clients attach to.
The default CpuAffinity setting still binds SuperServer to a single processor
only. In order to scale better when working with multiple databases, this setting should be changed in
firebird.conf.
The default value may change before the final release.
A slight improvement in scaling for single database usage on SMP hardware
It is with Classic that the effects are most evident:
Classic Server can now be multi-threaded. The one worker thread per process model remains but now it is possible to use additional threads for parallel tasks such as asynchronous shutdown, sweep, inter-process communications with the lock manager and more.
On POSIX, services in Classic also run in threads now, rather than in forked processes as previously.
For Windows Classic, services became threadable in v.2.1.
The embedded library on POSIX, libfbembed.so, is now multi-thread-capable and thread-safe, so it can be used in multi-threaded applications.
Testing suggests that the performance of Classic in this version will be be significantly faster than previous Classic versions.
This multi-threaded mode for Classic has been dubbed “Superclassic” for its capability to handle multiple worker threads—dedicated or pooled—inside a single server process. It shares all the usual Classic features, with a few differences:
Safe, full shutdown is possible on any platform
It performs better than Classic—by about 15-20%, according to TPC testing
It uses fewer kernel resources (although not less memory)
When a Superclassic process crashes, it takes all its connections with it
Recognised limitations in the Services API for the Classic server, such as the inability to retrieve the list of attachments/active users, do not apply to SuperClassic.
On POSIX, Superclassic does not require [x]inetd.
On Windows, the same fb_inet_server.exe binary delivers either the Classic or
the Superclassic working modes, according to switch settings. Classic is the default mode.
To use the Superclassic mode, add the -m (multi-threaded) switch to the command
line, as follows:
When intending to run Superclassic as an application, use
fb_inet_server -a -m
When installing Superclassic to run as a service, you need to include an
-m switch in the instsvc.exe command.
On POSIX, the new binary fb_smp_server is supplied for the Superclassic model.
It contains the network listener, meaning it works similarly to fbserver with regard
to attachment requests and does not require [x]inetd.
The multi-threaded engine used by fb_smp_server is the
libfbembed.so library, in accordance with OSRI requirements. The Classic packages
also include fbguard (the Guardian) which, for Classic, starts
fb_smp_server, rather than fbserver as it does when the
Superserver model is installed with Guardian.
Tracker reference CORE-707.
The client libraries, including the embedded one, can now be used in multi-threaded applications without any application-level synchronization.
Improvements implemented include:
The Classic server now detects immediately when a Classic process has been broken by a client disconnection. Its response is to terminate any pending activity, roll back the active transaction and close the network connection.
Tracker reference CORE-818.
Important optimizations include:
An optimization improves data retrieval performance for tables from which no fields are accessed.
Tracker reference CORE-1598.
An optimization avoids memory consumption of <page size> bytes for each temporary BLOB created during assignment.
Tracker reference CORE-1658.
The root determination mechanism for the Windows embedded engine has been changed to avoid common problems that occur when an installation of the application structure encounters “DLL Hell”. Previously, the implicit root directory was the directory containing the user application's main executable file. Now it is the directory where the renamed fbembed.dll library is located.
Tracker reference CORE-1814.
Tracker reference CORE-1937.
When a string UDF is written to return a pointer not allocated by the same runtime as the Firebird server is accessing, the presence of the FREE_IT keyword in its declaration corrupts memory and crashes the server. As a safeguard against such dysfunctional UDFs, the engine now
detects such UDFs and throws an exception
depends on the presence of the updated ib_util library in the path for all server models, including embedded
Better diagnostics and error reporting when TPB contents are malformed. More information to come.
Tracker reference CORE-1600.
Both table and column names are now reported when access privilege exceptions occur for a column.
Tracker reference CORE-1234.
An improvement allows the current value of RDB$DEFAULT_COLLATE_NAME in the system table RDB$CHARACTER_SETS to survive the backup/restore cycle.
Tracker reference CORE-789.
Table of Contents
V.2.5 brings a few significant additions and enhancements to DDL.
Tracker reference CORE-696.
In v.2.5, Firebird finally has syntax to enable user accounts on the server to be managed by submitting SQL statements when logged in to a regular database.
Syntax Patterns
A user with SYSDBA privileges can add a new user:
CREATE USER <username> {PASSWORD 'password'}
[FIRSTNAME 'firstname']
[MIDDLENAME 'middlename']
[LASTNAME 'lastname'];
The PASSWORD clause is required when creating a new user. It should be the initial password for that new user. (The user can change it later, using ALTER USER.)
A user with SYSDBA privileges can change one or more of the password and proper name attributes of an existing user. Non-privileged users can use this statement to alter only their own attributes.
ALTER USER <username>
[PASSWORD 'password']
[FIRSTNAME 'firstname']
[MIDDLENAME 'middlename']
[LASTNAME 'lastname'];
At least one of PASSWORD, FIRSTNAME, MIDDLENAME or LASTNAME must be present.
ALTER USER does not allow the <username> to be changed. If a different <username> is required, the old one should be deleted (dropped) and a new one created.
A user with SYSDBA privileges can delete a user:
DROP USER <username>;
Restrictions
CREATE and DROP statements are available only for the SYSDBA or a user that has been granted the RDB$ADMIN role in the security database. An ordinary user can ALTER his own password and elements of his proper name. An attempt to modify another user will fail.
Examples
CREATE USER alex PASSWORD 'test';
ALTER USER alex FIRSTNAME 'Alex' LASTNAME 'Peshkov';
ALTER USER alex PASSWORD 'IdQfA';
DROP USER alex;
Firebird 2.5 does not allow you to set up more than one security database on a server. From V.3.0, it is intended to be possible to have separate security databases for each database. For now, you can be connected to any database on the server (even employee.fdb) to update its one-and-only security2.fdb.
In future, it will be essential to send these requests from a database that is associated with the security database that is to be affected by them.
Previously, in order to alter a view definition, it was necessary to save the view definition off-line somewhere and drop the view, before recreating it with its changes. This made things very cumbersome, especially if there were dependencies. V.2.5 introduces syntaxes for ALTER VIEW and CREATE OR ALTER VIEW.
Tracker references are CORE-770 and CORE-1640.
ALTER VIEW enables a view definition to be altered without the need to recreate (drop and create) the old version of the view and all of its dependencies.
With CREATE OR ALTER VIEW, the view definition will be altered (as with ALTER VIEW) if it exists, or created if it does not exist.
Syntax Pattern
create [ or alter ] | alter } view <view_name>
[ ( <field list> ) ]
as <select statement>
Example
create table users (
id integer,
name varchar(20),
passwd varchar(20)
);
create view v_users as
select name from users;
alter view v_users (id, name) as
select id, name from users;
Tracker reference CORE-886.
A selectable stored procedure can now be specified in the FROM clause of a view definition.
More information to come.
Tracker reference CORE-1454.
A column defined as COMPUTED BY <expression> can now be altered using the ALTER TABLE...ALTER COLUMN syntax. This feature can be used only to change the <expression> element of the column definition to a different expression. It cannot convert a computed column to non-computed or vice versa.
Syntax Pattern
alter table <table-name>
alter <computed-column-name>
[type <data-type>]
COMPUTED BY (<expression>);
Examples
create table test (
n integer,
dn computed by (n * 2)
);
commit;
alter table test
alter dn computed by (n + n);
A GRANTED BY or GRANTED AS clause can now be optionally included in GRANT and REVOKE statements, enabling the grantor to be a user other than the CURRENT_USER (the default).
Syntax Pattern
grant <right> to <object>
[ { granted by | as } [ user ] <username> ]
--
revoke <right> from <object>
[ { granted by | as } [ user ] <username> ]
GRANTED BY and GRANTED AS are equivalent. GRANTED BY is the form recommended by SQL standard. We support GRANTED AS for compatibility with some other servers (Informix, for example).
Example
Logged in as SYSDBA:
create role r1; -- SYSDBA owns the role
/* next, SYSDBA grants the role to user1
with the power to grant it to others */
grant r1 to user1 with admin option;
/* SYSDBA uses GRANTED BY to exercise
user1's ADMIN OPTION */
grant r1 to public granted by user1;
In isql, we look at the effects:
SQL>show grant;
/* Grant permissions for this database */
GRANT R1 TO PUBLIC GRANTED BY USER1
GRANT R1 TO USER1 WITH ADMIN OPTION
SQL>
Tracker reference CORE-1660.
The new ALTER ROLE statement has a specialised function to control the assignment of SYSDBA permissions to Windows administrators during trusted authentication. It has no other purpose currently.
For usage details, see the topic in the Administrative Features chapter, entitled Automatically Mapping RDB$ADMIN to a Windows User.
Tracker references CORE-1737 and CORE-1803.
An ODS 11.2 or higher database can now have a default COLLATION attribute associated with the default character set, enabling all text column, domain and variable definitions to be created with the same collation order unless a COLLATE clause for a different collation is specified.
The COLLATION clause is optional. If it is omitted, the default collation order for the character set is used.
Note also that the default collation order for a character set used in a database can now also be changed, thanks to the introduction of syntax for ALTER CHARACTER SET.
Syntax Pattern
create database <file name>
[ page_size <page size> ]
[ length = <length> ]
[ user <user name> ]
[ password <user password> ]
[ set names <charset name> ]
[ default character set <charset name>
[ collation <collation name> ] ]
[ difference file <file name> ]
Example
create database 'test.fdb'
default character set win1252
collation win_ptbr;
Tracker reference CORE-1803.
New syntax introduced in this version, enabling the default collation for a character set to be set for a database.
The default collation is used when table columns are created with a given character set (explicitly, through a CHARACTER SET clause in the column or domain definition, or implicitly, through the default character set attribute of the database) and no COLLATION clause is specified.
String constants also use the default collation of the connection character set.
Syntax Pattern
ALTER CHARACTER SET <charset_name>
SET DEFAULT COLLATION <collation_name>
Example
create database 'people.fdb'
default character set win1252;
alter character set win1252
set default collation win_ptbr;
create table person (
id integer,
name varchar(50) /* will use the database default
character set and the win1252
default collation */
);
insert into person
values (1, 'adriano');
insert into person
values (2, 'ADRIANO');
/* will retrieve both records
because win_ptbr is case insensitive */
select * from person where name like 'A%';
Another improvement allows the current value of RDB$DEFAULT_COLLATE_NAME in the system table RDB$CHARACTER_SETS to survive the backup/restore cycle.
Table of Contents
In this chapter are the additions and improvements that have been added to the SQL data manipulation language subset in Firebird 2.5.
Tracker reference CORE-769.
A new SIMILAR TO predicate is introduced to support regular expressions. The predicate's function is to verify whether a given SQL-standard regular expression matches a string argument. It is valid in any context that accepts Boolean expressions, such as WHERE clauses, CHECK constraints and PSQL IF() tests.
Syntax Patterns
<similar predicate> ::=
<value> [ NOT ] SIMILAR TO <similar pattern> [ ESCAPE <escape character> ]
<similar pattern> ::= <character value expression: regular expression>
<regular expression> ::=
<regular term>
| <regular expression> <vertical bar> <regular term>
<regular term> ::=
<regular factor>
| <regular term> <regular factor>
<regular factor> ::=
<regular primary>
| <regular primary> <asterisk>
| <regular primary> <plus sign>
| <regular primary> <question mark>
| <regular primary> <repeat factor>
<repeat factor> ::=
<left brace> <low value> [ <upper limit> ] <right brace>
<upper limit> ::= <comma> [ <high value> ]
<low value> ::= <unsigned integer>
<high value> ::= <unsigned integer>
<regular primary> ::=
<character specifier>
| <percent>
| <regular character set>
| <left paren> <regular expression> <right paren>
<character specifier> ::=
<non-escaped character>
| <escaped character>
<regular character set> ::=
<underscore>
| <left bracket> <character enumeration>... <right bracket>
| <left bracket> <circumflex> <character enumeration>... <right bracket>
| <left bracket> <character enumeration include>... <circumflex> <character enumeration exclude>...
<right bracket>
<character enumeration include> ::= <character enumeration>
<character enumeration exclude> ::= <character enumeration>
<character enumeration> ::=
<character specifier>
| <character specifier> <minus sign> <character specifier>
| <left bracket> <colon> <character class identifier> <colon> <right bracket>
<character specifier> ::=
<non-escaped character>
| <escaped character>
<character class identifier> ::=
ALPHA
| UPPER
| LOWER
| DIGIT
| SPACE
| WHITESPACE
| ALNUM
<non-escaped character> is any character except <left bracket>, <right bracket>, <left paren>, <right paren>, <vertical bar>, <circumflex>, <minus sign>, <plus sign>, <asterisk>, <underscore>, <percent>, <question mark>, <left brace> and <escape character>.
<escaped character> is the <escape character> succeeded by one of <left bracket>, <right bracket>, <left paren>, <right paren>, <vertical bar>, <circumflex>, <minus sign>, <plus sign>, <asterisk>, <underscore>, <percent>, <question mark>, <left brace> or <escape character>.
Table 7.1. Character class identifiers
| Identifier | Description | Note |
|---|---|---|
| ALPHA | All characters that are simple latin letters (a-z, A-Z) | Includes latin letters with accents when using accent-insensitive collation |
| UPPER | All characters that are simple latin uppercase letters (A-Z) | Includes lowercase latters when using case-insensitive collation |
| LOWER | All characters that are simple latin lowercase letters (a-z) | Includes uppercase latters when using case-insensitive collation |
| DIGIT | All characters that are numeric digits (0-9) | |
| SPACE | All characters that are the space character (ASCII 32) | |
| WHITESPACE | All characters that are whitespaces (vertical tab (9), newline (10), horizontal tab (11), carriage return (13), formfeed (12), space (32)) | |
| ALNUM | All characters that are simple latin letters (ALPHA) or numeric digits (DIGIT) |
Usage Guide
Return true for a string that matches <regular expression> or <regular term>: <regular expression> <vertical bar> <regular term>
'ab' SIMILAR TO 'ab|cd|efg' -- true
'efg' SIMILAR TO 'ab|cd|efg' -- true
'a' SIMILAR TO 'ab|cd|efg' -- false
Match zero or more occurrences of <regular primary>: <regular primary> <asterisk>
'' SIMILAR TO 'a*' -- true
'a' SIMILAR TO 'a*' -- true
'aaa' SIMILAR TO 'a*' -- true
Match one or more occurrences of <regular primary>: <regular primary> <plus sign>
'' SIMILAR TO 'a+' -- false
'a' SIMILAR TO 'a+' -- true
'aaa' SIMILAR TO 'a+' -- true
Match zero or one occurrence of <regular primary>: <regular primary> <question mark>
'' SIMILAR TO 'a?' -- true
'a' SIMILAR TO 'a?' -- true
'aaa' SIMILAR TO 'a?' -- false
Match exact <low value> occurrences of <regular primary>: <regular primary> <left brace> <low value> <right brace>
'' SIMILAR TO 'a{2}' -- false
'a' SIMILAR TO 'a{2}' -- false
'aa' SIMILAR TO 'a{2}' -- true
'aaa' SIMILAR TO 'a{2}' -- false
Match <low value> or more occurrences of <regular primary>: <regular primary> <left brace> <low value> <comma> <right brace>:
'' SIMILAR TO 'a{2,}' -- false
'a' SIMILAR TO 'a{2,}' -- false
'aa' SIMILAR TO 'a{2,}' -- true
'aaa' SIMILAR TO 'a{2,}' -- true
Match <low value> to <high value> occurrences of <regular primary> <regular primary> <left brace> <low value> <comma> <high value> <right brace>:
'' SIMILAR TO 'a{2,4}' -- false
'a' SIMILAR TO 'a{2,4}' -- false
'aa' SIMILAR TO 'a{2,4}' -- true
'aaa' SIMILAR TO 'a{2,4}' -- true
'aaaa' SIMILAR TO 'a{2,4}' -- true
'aaaaa' SIMILAR TO 'a{2,4}' -- false
Match any (non-empty) character: <underscore>
'' SIMILAR TO '_' -- false
'a' SIMILAR TO '_' -- true
'1' SIMILAR TO '_' -- true
'a1' SIMILAR TO '_' -- false
Match a string of any length (including empty strings): <percent>
'' SIMILAR TO '%' -- true
'az' SIMILAR TO 'a%z' -- true
'a123z' SIMILAR TO 'a%z' -- true
'azx' SIMILAR TO 'a%z' -- false
Group a complete <regular expression> to use as one single <regular primary> as a sub-expression: <left paren> <regular expression> <right paren>
'ab' SIMILAR TO '(ab){2}' -- false
'aabb' SIMILAR TO '(ab){2}' -- false
'abab' SIMILAR TO '(ab){2}' -- true
Match a character identical to one of <character enumeration>: <left bracket> <character enumeration>... <right bracket>
'b' SIMILAR TO '[abc]' -- true
'd' SIMILAR TO '[abc]' -- false
'9' SIMILAR TO '[0-9]' -- true
'9' SIMILAR TO '[0-8]' -- false
Match a character not identical to one of <character enumeration>: <left bracket> <circumflex> <character enumeration>... <right bracket>
'b' SIMILAR TO '[^abc]' -- false
'd' SIMILAR TO '[^abc]' -- true
Match a character identical to one of <character enumeration include> but not identical to one of <character enumeration exclude>: <left bracket> <character enumeration include>... <circumflex> <character enumeration exclude>...
'3' SIMILAR TO '[[:DIGIT:]^3]' -- false
'4' SIMILAR TO '[[:DIGIT:]^3]' -- true
Match a character identical to one character included in <character class identifier>. Refer to the table of Character Class Identifiers, above. May be used with <circumflex> to invert the logic (see above): <left bracket> <colon> <character class identifier> <colon> <right bracket>
'4' SIMILAR TO '[[:DIGIT:]]' -- true
'a' SIMILAR TO '[[:DIGIT:]]' -- false
'4' SIMILAR TO '[^[:DIGIT:]]' -- false
'a' SIMILAR TO '[^[:DIGIT:]]' -- true
Examples
create table department (
number numeric(3) not null,
name varchar(25) not null,
phone varchar(14)
check (phone similar to '\([0-9]{3}\) [0-9]{3}\-[0-9]{4}' escape '\')
);
insert into department
values ('000', 'Corporate Headquarters', '(408) 555-1234');
insert into department
values ('100', 'Sales and Marketing', '(415) 555-1234');
insert into department
values ('140', 'Field Office: Canada', '(416) 677-1000');
insert into department
values ('600', 'Engineering', '(408) 555-123'); -- check constraint violation
select * from department
where phone not similar to '\([0-9]{3}\) 555\-%' escape '\';
Tracker reference CORE-1760.
Support for hexadecimal numeric and binary string literals has been introduced.
Syntax Patterns
<numeric hex literal> ::=
{ 0x | 0X } <hexit> [ <hexit>... ]
<binary string literal> ::=
{ x | X } <quote> [ { <hexit> <hexit> }... ] <quote>
<digit> ::=
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<hexit> ::=
<digit> | A | B | C | D | E | F | a | b | c | d | e | f
The number of <hexit> in the string cannot exceed 16.
If the number of <hexit> is greater than eight, the constant data type is a signed BIGINT. If it is eight or less, the data type is a signed INTEGER.
That means 0xF0000000 is -268435456 and 0x0F0000000 is 4026531840.
The resulting string is defined as a CHAR(n/2) CHARACTER SET OCTETS, where n is the number of <hexit>.
Examples
select 0x10, cast('0x0F0000000' as bigint)
from rdb$database;
select x'deadbeef'
from rdb$database;
Tracker references CORE-1656 and CORE-1682.
Two new built-in functions, UUID_TO_CHAR and CHAR_TO_UUID, enable conversion between a UUID in the form of a CHAR(16) OCTETS string and the RFC4122-compliant form.
The function CHAR_TO_UUID() converts the CHAR(32) ASCII representation of a UUID (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX) to the CHAR(16) OCTETS representation, optimized for storage.
Syntax Model
CHAR_TO_UUID( <string> )
Example
select char_to_uuid('93519227-8D50-4E47-81AA-8F6678C096A1')
from rdb$database;
Tracker reference CORE-1453
A string expression is now allowed as the delimiter argument of the LIST() function.
Example
SELECT
DISCUSSION_ID,
LIST(COMMMENT, ASCII_CHAR(13))
FROM COMMENTS
GROUP BY DISCUSSION_ID;
Table of Contents
Several significant changes appear in Firebird's procedural language (PSQL), the language set for triggers, stored procedures and dynamic executable blocks, especially with regard to new extensions to the capabilities of EXECUTE STATEMENT. This release also heralds the arrival of the “autonomous transaction”.
Tracker reference CORE-1409.
This new implementation allows a piece of code to run in an autonomous transaction within a PSQL module. It can be handy for a situation where you need to raise an exception but do not want the database changes to be rolled back.
The new transaction is initiated with the same isolation level as the one from which it is launched. Any exception raised in a block within the autonomous transaction will cause changes to be rolled back. If the block runs through until its end, the transaction is committed.
Because the autonomous transaction is independent from the one from which is launched, you need to use this feature with caution to avoid deadlocks.
Syntax Pattern
IN AUTONOMOUS TRANSACTION
DO
<simple statement | compound statement>
Example of Use
create table log (
logdate timestamp,
msg varchar(60)
);
create exception e_conn 'Connection rejected';
set term !;
create trigger t_conn on connect
as
begin
if (current_user = 'BAD_USER') then
begin
in autonomous transaction
do
begin
insert into log (logdate, msg) values (current_timestamp, 'Connection rejected');
end
exception e_conn;
end
end!
set term ;!
Tracker reference CORE-1356.
This feature extends the implementation in v.2 whereby domains became available as “data types” for declaring variables in PSQL. Now it is possible to borrow the data type of a column definition from a table or view for this purpose.
Syntax Pattern
data_type ::=
<builtin_data_type>
| <domain_name>
| TYPE OF <domain_name>
| TYPE OF COLUMN <table or view>.<column>
TYPE OF COLUMN gets only the type of the column. Any constraints or default values defined for the column are ignored.
Examples
CREATE TABLE PERSON (
ID INTEGER,
NAME VARCHAR(40)
);
CREATE PROCEDURE SP_INS_PERSON (
ID TYPE OF COLUMN PERSON.ID,
NAME TYPE OF COLUMN PERSON.NAME
)
AS
DECLARE VARIABLE NEW_ID TYPE OF COLUMN PERSON.ID;
BEGIN
INSERT INTO PERSON (ID, NAME)
VALUES (:ID, :NAME)
RETURNING ID INTO :NEW_ID;
END
Unusually for our release notes, we begin this chapter with the full, newly extended syntax for the EXECUTE STATEMENT statement in PSQL and move on afterwards to explain the various new features and their usage.
[FOR] EXECUTE STATEMENT <query_text> [(<input_parameters>)]
[ON EXTERNAL [DATA SOURCE] <connection_string>]
[WITH {AUTONOMOUS | COMMON} TRANSACTION]
[AS USER <user_name>]
[PASSWORD <password>]
[WITH CALLER PRIVILEGES]
[INTO <variables>]
The order of the optional clauses is not fixed so, for example, a statement based on the following model would be just as valid:
[ON EXTERNAL [DATA SOURCE] <connection_string>]
[WITH {AUTONOMOUS | COMMON} TRANSACTION]
[AS USER <user_name>]
[PASSWORD <password>]
[WITH CALLER PRIVILEGES]
Clauses cannot be duplicated.
If there is no ON EXTERNAL DATA SOURCE clause present, EXECUTE STATEMENT is normally executed within the CURRENT_CONNECTION context. This will be the case if the AS USER clause is omitted, or it is present with its <user_name> argument equal to CURRENT_USER.
However, if <user_name> is not equal to CURRENT_USER, then the statement is executed in a separate connection, established without Y-Valve and remote layers, inside the same engine instance.
In the absence of an AS USER <user_name> clause, CURRENT_USER is the default.
Where server authentication is needed for a connection that is different to CURRENT_CONNECTION, e.g., for executing an EXECUTE STATEMENT command on an external datasource, the AS USER and PASSWORD clauses are required. However, under some conditions, the PASSWORD may be omitted and the effects will be as follows:
On Windows, for the CURRENT_CONNECTION (i.e., no external data source), trusted authentication will be performed if it is active and the AS USER parameter is missing, null or equal to CURRENT_USER.
If the external data source parameter is present and its <connection_string> refers to the same database as the CURRENT_CONNECTION, the effective user account will be that of the CURRENT_USER.
If the external data source parameter is present and its <connection_string> refers to a different database than the one CURRENT_CONNECTION is attached to, the effective user account will be the operating system account under which the Firebird process is currently running.
In any other case where the PASSWORD clause is missing, only isc_dpb_user_name will be presented in the DPB (attachment parameters) and native authentication will be attempted.
The new syntax has an optional clause for setting the appropriate transaction behaviour: WITH AUTONOMOUS TRANSACTION and WITH COMMON TRANSACTION. WITH COMMON TRANSACTION is the default and does not need to be specified. Transaction lifetimes are bound to the lifetime of CURRENT_TRANSACTION and are committed or rolled back in accordance with the CURRENT_TRANSACTION.
The behaviour for WITH COMMON TRANSACTION is as follows:
Causes any transaction in an external data source to be started with the same parameters as CURRENT_TRANSACTION; otherwise
Executes the statement inside the CURRENT_TRANSACTION; or
May use another transaction that is started internally in CURRENT_CONNECTION.
The WITH AUTONOMOUS TRANSACTION setting starts a new transaction with the same parameters as CURRENT_TRANSACTION. That transaction will be committed if the statement is executed without exceptions or rolled back if the statement encounters an error.
Tracker reference CORE-1928.
By design, the original implementation of EXECUTE STATEMENT isolated the executable code from the access privileges of the calling stored procedure or trigger, falling back to the privileges available to the CURRENT_USER. In general, the strategy is wise, since it reduces the vulnerability inherent in providing for the execution of arbitrary statements. However, in hardened environments, or where privacy is not an issue, it could present a limitation.
The introduction of the optional clause WITH CALLER PRIVILEGES now makes it possible to have the executable statement inherit the access privileges of the calling stored procedure or trigger. The statement is prepared using any additional privileges that apply to the calling stored procedure or trigger. The effect is the same as if the statement were executed by the stored procedure or trigger directly.
The WITH CALLER PRIVILEGES option is not compatible with the ON EXTERNAL DATA SOURCE option.
Tracker reference CORE-1853.
EXECUTE STATEMENT now supports queries against external databases by inclusion of the ON EXTERNAL DATA SOURCE clause with its <connection_string> argument.
The format of <connection_string> is the usual one that is passed through the API function isc_attach_database(), viz.
[<host_name><protocol_delimiter>]database_path
The connection to the external data source uses the same character set as is being used by the CURRENT_CONNECTION context.
If the external data source is on another server then the clauses AS USER <user_name> and PASSWORD <password> will be needed.
The clause WITH CALLER PRIVILEGES is a no-op if the external data source is on another server.
MORE INFORMATION REQUIRED. ROLES?
Use of a two-phase transaction for the external connection is not available in V.2.5.