New SQL Features in Firebird 3, by Vlad Khorsun

Mind The Firebird
Mind The FirebirdLead at charity
New FeaturesNew SQL Features 
in 3in Firebird 3
Sponsors !
Prague SQLPrague 2014 Whats new in Firebird SQL 
3 
●Common SQL 
●Full syntax of MERGE statement (per SQL 2008) 
●MERGE ... RETURNING 
●Window (analytical) functions 
●SUBSTRING with regular expressions 
●BOOLEAN data type 
●New RDB$RECORD_VERSION pseudo-column 
●Cursor stability with data modification queries 
●Global temporary tables are improved 
Whats new in Firebird 3
Prague SQLPrague 2014 Whats new in Firebird SQL 
4 
●Procedural SQL 
●SQL functions 
●Sub-routines 
●External functions, procedures and triggers on CC++PascalJava etc. 
●Packages 
●Exceptions with parameters : EXCEPTION ... USING (...) 
●SQLSTATE in WHEN handler 
●CONTINUE in loops 
●Cursors could be references as record variable 
●Bi-directional cursors 
Whats new in Firebird 3
Prague SQLPrague 2014 Whats new in Firebird SQL 
5 
●DDL 
●Manage nullability of column 
●ALTER DOMAIN ... {NULL | NOT NULL} 
●ALTER COLUMN ... {NULL | NOT NULL} 
●ALTER DATABASE ... SET DEFAULT CHARACTER SET 
●IDENTITY columns 
●RECREATE SEQUENCE, RECREATE GENERATOR 
●DDL triggers 
●Database LINGER 
Whats new in Firebird 3
Prague SQLPrague 2014 Whats new in Firebird SQL 
6 
●Security 
●User management 
●Support for database encryption 
●Enhanced object privileges 
●DDL privileges 
●Database-level privileges 
●SET ROLE TO <role> 
●Monitoring 
●Extended statistics, queries plan's, ... 
Whats new in Firebird 3
Prague SQLPrague 2014 Whats new in Firebird SQL 
7 
Common SQL : MERGE 
Full SQL 2008 syntax 
MERGE INTO <table> 
USING <table_or_join> 
ON <search_condition> 
[WHEN MATCHED [AND <search_condition>] THEN 
UPDATE SET col1 = val1, ..., colN = valN 
| 
DELETE] 
[WHEN NOT MATCHED [AND <search_condition>] THEN 
INSERT [(col1, ..., colN)] VALUES (val1, ..., valN)]
Prague SQLPrague 2014 Whats new in Firebird SQL 
8 
Common SQL : MERGE 
DELETE substatement and multiply WHEN clauses 
MERGE INTO TABLE 
USING LOG 
ON TABLE.PK = LOG.PK 
WHEN MATCHED AND LOG.ACTION = 'D' THEN 
DELETE 
WHEN MATCHED THEN-- second WHEN MATCHED clause 
UPDATE SET col1 = LOG.val1, ... 
WHEN NOT MATCHED THEN 
INSERT (col1, ...) VALUES (LOG.val1, ...)
Prague SQLPrague 2014 Whats new in Firebird SQL 
9 
Common SQL : MERGE 
RETURNING clause 
MERGE INTO <table> 
USING <table_or_join> 
ON <search_condition> 
[WHEN MATCHED [AND <search_condition>] THEN 
UPDATE SET col1 = val1, ..., colN = valN | 
DELETE] 
[WHEN NOT MATCHED [AND <search_condition>] THEN 
INSERT [(col1, ..., colN)] VALUES (val1, ..., valN)] 
[RETURNING ... [INTO ...]]
Prague SQLPrague 2014 Whats new in Firebird SQL 
10 
Common SQL : WINDOW FUNCTIONS 
Syntax 
<window function> ::= 
<window function type> OVER (<window specification>) 
<window function type> ::= 
<aggregate function>–- aggregate 
| <rank function type>–- ranking 
| ROW_NUMBER–- yes, it is row number ;) 
| <lead or lag function>–- navigational 
| <first or last value function> 
| <nth value function> 
<window specification> ::= 
[PARTITION BY column1, ...] 
[ORDER BY column1 [ASC|DESC] [NULLS {FIRST|LAST}], ... ]
Prague SQLPrague 2014 Whats new in Firebird SQL 
11 
Common SQL : WINDOW FUNCTIONS 
Syntax 
<aggregate function> ::= 
AVG | MAX | MIN | SUM | COUNT | LIST 
<rank function type> ::= 
RANK | DENSE_RANK 
<lead or lag function> ::= 
LEAD | LAG 
<first or last value function> ::= 
{FIRST_VALUE | LAST_VALUE} (<value>) 
<nth value function> ::= 
NTH_VALUE (<value>, <nth row>)[FROM_FIRST | FROM_LAST]
Prague SQLPrague 2014 Whats new in Firebird SQL 
12 
Common SQL : WINDOW FUNCTIONS 
Example 
SELECT A, B, C, 
SUM(C) OVER(), 
SUM(C) OVER(ORDER BY A, B), 
SUM(C) OVER(PARTITION BY A), 
SUM(C) OVER(PARTITION BY A ORDER BY B) 
ABCSUMSUM1SUM2SUM311301413060301220141506050131014160606021251418540252215141100404031411411414141
Prague SQLPrague 2014 Whats new in Firebird SQL 
13 
Common SQL : substring search using REGEXP 
Syntax 
SUBSTRING(<string> SIMILAR <pattern> ESCAPE <char>) 
Rules 
●Pattern 
●R = <R1> <E> " <R2> <E> " <R3> 
●Search 
●S = <S1> <S2> <S3> 
1)<S>SIMILAR TO <R1> <R2> <R3> ESCAPE <E> 
2)<S1>SIMILAR TO <R1>ESCAPE <E> AND <S2> <S3>SIMILAR TO <R2> <R3>ESCAPE <E> 
3)<S2>SIMILAR TO <R2>ESCAPE <E> AND <S3>SIMILAR TO <R3>ESCAPE <E> 
●Result 
●S2
Prague SQLPrague 2014 Whats new in Firebird SQL 
14 
Common SQL : substring search using REGEXP 
Syntax 
SUBSTRING(<string> SIMILAR <pattern> ESCAPE <char>) 
Example 
SUBSTRING('abc-12b34xyz' SIMILAR '%"[+-]?[0-9]+"%' ESCAPE '') 
R1 = % 
R2 = [+-]?[0-9]+ 
R3 = % 
1)'abc-12b34xyz'SIMILAR TO '%[+-]?[0-9]+%' ESCAPE '' 
2)'abc' SIMILAR TO '%'ESCAPE '' AND 
'-12b34xyz' SIMILAR TO '[+-]?[0-9]+%'ESCAPE '' 
3)'-12' SIMILAR TO '[+-]?[0-9]+'ESCAPE '' AND 'b34xyz' SIMILAR TO '%'ESCAPE '' 
Result 
'-12'
Prague SQLPrague 2014 Whats new in Firebird SQL 
15 
Common SQL : BOOLEAN data type 
Syntax 
<data_type> ::= BOOLEAN 
<boolean_literal> ::= TRUE | FALSE | UNKNOWN 
Storage 
1 byte 
Client support (XSQLDA) 
#define SQL_BOOLEAN32764
Prague SQLPrague 2014 Whats new in Firebird SQL 
16 
Common SQL : BOOLEAN data type 
Truth tables 
AND 
True 
False 
Unknown 
True 
True 
False 
Unknown 
False 
False 
False 
False 
Unknown 
Unknown 
False 
Unknown 
OR 
True 
False 
Unknown 
True 
True 
True 
True 
False 
True 
False 
Unknown 
Unknown 
True 
Unknown 
Unknown 
IS 
True 
False 
Unknown 
True 
True 
False 
False 
False 
False 
True 
False 
Unknown 
False 
False 
True 
NOT 
True 
False 
False 
True 
Unknown 
Unknown
Prague SQLPrague 2014 Whats new in Firebird SQL 
17 
Common SQL : BOOLEAN data type 
Examples 
CREATE TABLE TBOOL (ID INT, BVAL BOOLEAN); 
COMMIT; 
INSERT INTO TBOOL VALUES (1, TRUE); 
INSERT INTO TBOOL VALUES (2, 2 = 4); 
INSERT INTO TBOOL VALUES (3, NULL = 1); 
COMMIT; 
SELECT * FROM TBOOL 
ID BVAL 
============ ======= 
1 <true> 
2 <false> 
3 <null>
Prague SQLPrague 2014 Whats new in Firebird SQL 
18 
Common SQL : BOOLEAN data type 
Examples 
SELECT * FROM TBOOL 
WHERE BVAL 
ID BVAL 
============ ======= 
1 <true> 
SELECT * FROM TBOOL 
WHERE BVAL IS FALSE 
ID BVAL 
============ ======= 
2 <false> 
SELECT * FROM TBOOL 
WHERE BVAL IS UNKNOWN 
ID BVAL 
============ ======= 
3 <null> 
SELECT * FROM TBOOL 
WHERE BVAL = UNKNOWN 
SELECT * FROM TBOOL 
WHERE BVAL <> UNKNOWN 
1. Test for TRUE value 
2. Test for FALSE value 
3. Tests for UNKNOWN value
Prague SQLPrague 2014 Whats new in Firebird SQL 
19 
Common SQL : BOOLEAN data type 
Examples 
SELECT ID, BVAL, BVAL AND ID < 2 
FROM TBOOL 
ID BVAL 
============ ======= ======= 
1 <true> <true> 
2 <false> <false> 
3 <null> <false> 
4. Boolean values in SELECT list
Prague SQLPrague 2014 Whats new in Firebird SQL 
20 
Common SQL : cursor stability 
The issue 
●Famous infinite insertion circle (CORE-92) 
INSERT INTO T 
SELECT * FROM T 
●DELETE more rows than expected (CORE-634) 
DELETE FROM T 
WHERE ID IN (SELECT FIRST 1 ID FROM T) 
●All DML statements is affected (INSERT, UPDATE, DELETE, MERGE) 
●Common ticket at tracker CORE-3362
Prague SQLPrague 2014 Whats new in Firebird SQL 
21 
Common SQL : cursor stability 
The reason of the issue 
●DML statements used implicit cursors : 
●INSERT INTO T SELECT ... FROM T 
works as 
FOR SELECT <values> FROM T INTO <tmp_vars> 
DO INSERT INTO T VALUES (<tmp_vars>) 
●UPDATE T SET <fields> = <values> WHERE <conditions> 
works as 
FOR SELECT <values> FROM T WHERE <conditions> INTO <tmp_vars> 
AS CURSOR <cursor> DO UPDATE T SET <fields> = <tmp_vars> WHERE CURRENT OF <cursor> 
●DELETE works like UPDATE
Prague SQLPrague 2014 Whats new in Firebird SQL 
22 
Common SQL : cursor stability 
The “standard” way 
●Rows to be insertedupdateddeleted should be marked first 
●Marked rows is insertedupdateddeleted then 
●Pros 
●rowset is stable and is not affected by DML statement itself 
●Cons 
●Marks should be saved somewhere and rows will be visited again, or 
●Whole marked rows should be saved somewhere and this store will be visited again 
●Note : this could be reached in Firebird using (well known) workaround: 
force query to have SORT in PLAN - it will materialize implicit cursor and make it stable
Prague SQLPrague 2014 Whats new in Firebird SQL 
23 
Common SQL : cursor stability 
The Firebird 3 way 
●Use undo-log to see if record was already modified by current cursor 
●if record was inserted - ignore it 
●if record was updated or deleted - read backversion 
●Pros 
●No additional bookkeeping required 
●No additional storage required 
●Relatively easy to implement 
●Cons 
●Inserted records could be visited (but ignored, of course) 
●Backversions of updateddeleted records should be read 
●Not works with SUSPEND in PSQL
Prague SQLPrague 2014 Whats new in Firebird SQL 
24 
Common SQL : cursor stability 
PSQL notes 
●PSQL cursors with SUSPEND inside still not stable ! 
This query still produced infinite circle 
FOR SELECT ID FROM T INTO :ID DO BEGIN INSERT INTO T (ID) VALUES (:ID); SUSPEND; END
Prague SQLPrague 2014 Whats new in Firebird SQL 
25 
Common SQL : cursor stability 
PSQL notes 
●PSQL cursors without SUSPEND inside is stable, this could change old behavior 
FOR SELECT ID FROM T WHERE VAL IS NULL INTO :ID DO BEGIN UPDATE T SET VAL = 1 WHERE ID = :ID; END
Prague SQLPrague 2014 Whats new in Firebird SQL 
26 
Common SQL : improvements in GTT 
●Global temporary tables is writable even in read-only transactions 
●Read-only transaction in read-write database 
●Both GTT ON COMMIT PRESERVE ROWS and COMMIT DELETE ROWS 
●Read-only transaction in read-only database 
●GTT ON COMMIT DELETE ROWS only 
●Faster rollback for GTT ON COMMIT DELETE ROWS 
●No need to backout records on rollback 
●Garbage collection in GTT is not delayed by active transactions of another 
connections 
●All this improvements is backported into v2.5.1 too
Prague SQLPrague 2014 Whats new in Firebird SQL 
27 
PSQL : SQL functions 
Syntax 
{CREATE [OR ALTER] | ALTER | RECREATE} FUNCTION <name> 
[(param1 [, ...])] 
RETURNS <type> 
AS 
BEGIN 
... 
END 
Example 
CREATE FUNCTION F(X INT) RETURNS INT 
AS 
BEGIN 
RETURN X+1; 
END; 
SELECT F(5) FROM RDB$DATABASE;
Prague SQLPrague 2014 Whats new in Firebird SQL 
28 
PSQL : SQL sub-routines 
Syntax 
●Sub-procedures 
DECLARE PROCEDURE <name> [(param1 [, ...])] 
[RETURNS (param1 [, ...])] 
AS 
... 
●Sub-functions 
DECLARE FUNCTION <name> [(param1 [, ...])] 
RETURNS <type> 
AS 
...
Prague SQLPrague 2014 Whats new in Firebird SQL 
29 
PSQL : SQL sub-routines 
Example 
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
Prague SQLPrague 2014 Whats new in Firebird SQL 
30 
PSQL : Packages 
-– package header, declarations only 
CREATE OR ALTER PACKAGE TEST 
AS 
BEGIN 
PROCEDURE P1(I INT) RETURNS (O INT);-– public procedure 
END 
-– package body, implementation 
RECREATE PACKAGE BODY TEST 
AS 
BEGIN 
FUNCTION F1(I INT) RETURNS INT;–- private function 
PROCEDURE P1(I INT) RETURNS (O INT) 
AS 
BEGIN 
END; 
FUNCTION F1(I INT) RETURNS INT 
AS 
BEGIN 
RETURN 0; 
END; 
END
Prague SQLPrague 2014 Whats new in Firebird SQL 
31 
PSQL : EXCEPTION with parameters 
Syntax 
a) Exception text could contain parameters markers (@1, @2, ...) 
CREATE EXCEPTION EX_WITH_PARAMS 'Error @1 : @2'; 
b) New clause USING allows to set parameters values whenexception raised: 
EXEPTION EX_WITH_PARAMS USING (1, 'You can not do it');
Prague SQLPrague 2014 Whats new in Firebird SQL 
32 
PSQL : Cursors references as record variable 
FOR SELECT A, B, C FROM ... 
AS CURSOR C1// no INTO clause 
DO 
BEGIN 
... 
INSERT INTO ... 
VALUES (C1.A, C1.B, C1.C, …);// cursor references 
END
Prague SQLPrague 2014 Whats new in Firebird SQL 
33 
DDL : IDENTITY columns 
Syntax 
<column definition> ::= <name> <type> GENERATED BY DEFAULT AS IDENTITY [STARTS WITH <number>] 
<constraints> 
<alter column definition> ::= <name> RESTART [WITH <number>]
Prague SQLPrague 2014 Whats new in Firebird SQL 
34 
DDL : IDENTITY columns 
Rules 
●Column type – INTEGER or NUMERIC(P, 0) 
●Implicit NOT NULL 
●Not guarantees uniqueness 
●Can not have DEFAULT clause 
●Can not be COMPUTED BY 
●Can not be altered to become non-identity and vice versa
Prague SQLPrague 2014 Whats new in Firebird SQL 
35 
DDL : DDL triggers 
Syntax 
<ddl-trigger> ::= 
{CREATE | RECREATE | CREATE OR ALTER} TRIGGER <name> 
[ACTIVE | INACTIVE] {BEFORE | AFTER} <ddl event> 
[POSITION <n>] 
<ddl event> ::= 
ANY DDL STATEMENT 
| <ddl event item> [{OR <ddl event item>}...] 
<ddl event item> ::= 
{CREATE | ALTER | DROP} 
{TABLE | PROCEDURE | FUNCTION | TRIGGER | EXCEPTION | 
VIEW | DOMAIN | SEQUENCE | INDEX | ROLE | 
USER | COLLATION | PACKAGE | PACKAGE BODY | 
CHARACTER SET }
Prague SQLPrague 2014 Whats new in Firebird SQL 
36 
DDL : DDL triggers 
New context variables (RDB$GET_CONTEXT) 
●Namespace DDL_TRIGGER 
●Defined inside DDL trigger only 
●Read only 
●Predefined variables: 
●DDL_EVENT - kind of DDL event 
●OBJECT_NAME – name of metadata object 
●SQL_TEXT - text of SQL query
Prague SQLPrague 2014 Whats new in Firebird SQL 
37 
DDL : DDL triggers 
Example 
CREATE EXCEPTION EX_BAD_SP_NAME 
'Name of procedures must start with ''@1'' : ''@2'''; 
CREATE TRIGGER TRG_SP_CREATE BEFORE CREATE PROCEDURE 
AS 
DECLARE SP_NAME VARCHAR(255); 
BEGIN 
SP_NAME = RDB$GET_CONTEXT('DDL_TRIGGER', 'OBJECT_NAME'); 
IF (SP_NAME NOT STARTING 'SP_') 
THEN EXCEPTION EX_BAD_SP_NAME USING ('SP_', SP_NAME); 
END;
Prague SQLPrague 2014 Whats new in Firebird SQL 
38 
DDL : Database LINGER 
●Linger purposes 
●Allow engine to keep in memory some database related structures after last disconnect: 
●Page cache 
●Background GC thread continue to work 
●For Shared Cache only 
●LINGER is switched off for current session, if 
●database shutdown 
●gfix -nolinger 
●Syntax 
●ALTER DATABASE SET LINGER TO <seconds> 
●ALTER DATABASE DROP LINGER
Prague SQLPrague 2014 Whats new in Firebird SQL 
39 
Security : user management 
Syntax 
CREATE [OR ALTER] USER <string> [SET] <option> [, …] 
ALTER CURRENT USER 
[SET] <option> [, …] 
<option> ::= 
PASSWORD <string> 
FIRSTNAME <string> 
MIDDLENAME <string> 
LASTNAME <string> 
{GRANT | REVOKE} ADMIN ROLE 
{ACTIVE | INACTIVE} 
TAGS (<list>)]
Prague SQLPrague 2014 Whats new in Firebird SQL 
40 
Security : user management 
Example 
CREATE USER Vlad PASSWORD pass INACTIVE; ALTER USER Vlad ACTIVE; 
ALTER USER Vlad SET TAGS (id = 1, x = 'abcd'); 
ALTER USER Vlad SET TAGS (x = 'xyz'); 
ALTER USER Vlad SET TAGS (DROP x);
Prague SQLPrague 2014 Whats new in Firebird SQL 
41 
Security : user management 
New virtual tables 
CREATE TABLE SEC$USERS 
( 
SEC$USER_NAME RDB$USER, 
SEC$FIRST_NAME SEC$NAME_PART, 
SEC$MIDDLE_NAME SEC$NAME_PART, 
SEC$LAST_NAME SEC$NAME_PART, 
SEC$ACTIVE RDB$BOOLEAN, 
SEC$ADMIN RDB$BOOLEAN, 
SEC$DESCRIPTION RDB$DESCRIPTION 
); 
CREATE TABLE SEC$USER_ATTRIBUTES 
( 
SEC$USER_NAME RDB$USER, 
SEC$KEY SEC$KEY, 
SEC$VALUE SEC$VALUE 
);
Prague SQLPrague 2014 Whats new in Firebird SQL 
42 
Security : EXECUTE privilege 
Syntax 
GRANT EXECUTE ON <object_type> <object_name> 
TO <grantee> [WITH GRANT OPTION] 
REVOKE [GRANT OPTION FOR] 
EXECUTE ON <object_type> <object_name> 
FROM <grantee> [GRANTED BY <grantor>] 
object_type ::= PROCEDURE 
| FUNCTION 
| PACKAGE
Prague SQLPrague 2014 Whats new in Firebird SQL 
43 
Security : USAGE privilege 
Syntax 
GRANT USAGE ON <object_type> <object_name> 
TO <grantee> [WITH GRANT OPTION] 
REVOKE [GRANT OPTION FOR] 
USAGE ON <object_type> <object_name> 
FROM <grantee> [GRANTED BY <grantor>] 
object_type ::= {DOMAIN | EXCEPTION | GENERATOR | SEQUENCE | CHARACTER SET | COLLATION}
Prague SQLPrague 2014 Whats new in Firebird SQL 
44 
Security : DDL privileges 
Syntax 
GRANT <ddl_privileges> <object> 
TO <grantee> [WITH GRANT OPTION] 
REVOKE [GRANT OPTION FOR] <ddl_privileges> <object> 
FROM <grantee> [GRANTED BY <grantor>] 
ddl_privileges ::= ALL [PRIVILEGES] 
| ddl_privilege[, ddl_privilege] 
ddl_privilege ::= {CREATE | ALTER ANY | DROP ANY} 
object ::= {TABLE | VIEW | PROCEDURE | FUNCTION | PACKAGE | 
GENERATOR | SEQUENCE | DOMAIN | EXCEPTION | ROLE | CHARACTER SET | COLLATION | FILTER}
Prague SQLPrague 2014 Whats new in Firebird SQL 
45 
Security : database privileges 
Syntax 
REVOKE [GRANT OPTION FOR] <ddl_privileges> <object_name> 
FROM <grantee> [GRANTED BY <grantor>] 
ddl_privileges ::= 
ALL [PRIVILEGES] 
| ddl_privilege[, ddl_privilege] 
ddl_privilege ::= {CREATE | ALTER ANY | DROP ANY}
Prague SQLPrague 2014 Whats new in Firebird SQL 
46 
Security : SET ROLE 
Syntax 
SET ROLE <name> 
SET TRUSTED ROLE
Prague SQLPrague 2014 Whats new in Firebird SQL 
47 
Questions ? 
Firebird official web site 
Firebird tracker 
THANK ATTENTIONTHANK YOU FOR ATTENTION 
hvlad@users.sf.net
1 of 47

Recommended

New features of SQL in Firebird by
New features of SQL in FirebirdNew features of SQL in Firebird
New features of SQL in FirebirdMind The Firebird
7.2K views59 slides
Firebird 3 Windows Functions by
Firebird 3 Windows  FunctionsFirebird 3 Windows  Functions
Firebird 3 Windows FunctionsMind The Firebird
3.7K views34 slides
Stored procedures in Firebird by
Stored procedures in FirebirdStored procedures in Firebird
Stored procedures in FirebirdMind The Firebird
10.3K views35 slides
Performance Instrumentation for PL/SQL: When, Why, How by
Performance Instrumentation for PL/SQL: When, Why, HowPerformance Instrumentation for PL/SQL: When, Why, How
Performance Instrumentation for PL/SQL: When, Why, HowKaren Morton
3.2K views186 slides
PL-SQL DIFFERENT PROGRAMS by
PL-SQL DIFFERENT PROGRAMSPL-SQL DIFFERENT PROGRAMS
PL-SQL DIFFERENT PROGRAMSraj upadhyay
711 views21 slides
Oracle 11g PL/SQL notes by
Oracle 11g PL/SQL notesOracle 11g PL/SQL notes
Oracle 11g PL/SQL notesanilakduygu
8K views26 slides

More Related Content

What's hot

Oracle: Procedures by
Oracle: ProceduresOracle: Procedures
Oracle: ProceduresDataminingTools Inc
1.5K views9 slides
Oracle 11g new features for developers by
Oracle 11g new features for developersOracle 11g new features for developers
Oracle 11g new features for developersScott Wesley
4.3K views75 slides
Nested subqueries and subquery chaining in openCypher by
Nested subqueries and subquery chaining in openCypherNested subqueries and subquery chaining in openCypher
Nested subqueries and subquery chaining in openCypheropenCypher
154 views52 slides
Plsql by
PlsqlPlsql
PlsqlMandeep Singh
1.8K views87 slides
0888 learning-mysql by
0888 learning-mysql0888 learning-mysql
0888 learning-mysqlsabir18
87 views272 slides
SQL Macros - Game Changing Feature for SQL Developers? by
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?Andrej Pashchenko
319 views42 slides

What's hot(20)

Oracle 11g new features for developers by Scott Wesley
Oracle 11g new features for developersOracle 11g new features for developers
Oracle 11g new features for developers
Scott Wesley4.3K views
Nested subqueries and subquery chaining in openCypher by openCypher
Nested subqueries and subquery chaining in openCypherNested subqueries and subquery chaining in openCypher
Nested subqueries and subquery chaining in openCypher
openCypher154 views
0888 learning-mysql by sabir18
0888 learning-mysql0888 learning-mysql
0888 learning-mysql
sabir1887 views
SQL Macros - Game Changing Feature for SQL Developers? by Andrej Pashchenko
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?
Andrej Pashchenko319 views
Oracle PL/SQL Bulk binds by Scott Wesley
Oracle PL/SQL Bulk bindsOracle PL/SQL Bulk binds
Oracle PL/SQL Bulk binds
Scott Wesley2.5K views
Plsql guide 2 by Vinay Kumar
Plsql guide 2Plsql guide 2
Plsql guide 2
Vinay Kumar1.7K views
Procedures/functions of rdbms by jain.pralabh
Procedures/functions of rdbmsProcedures/functions of rdbms
Procedures/functions of rdbms
jain.pralabh8.3K views
ORACLE PL SQL FOR BEGINNERS by mohdoracle
ORACLE PL SQL FOR BEGINNERSORACLE PL SQL FOR BEGINNERS
ORACLE PL SQL FOR BEGINNERS
mohdoracle18.6K views
MERGE SQL Statement: Lesser Known Facets by Andrej Pashchenko
MERGE SQL Statement: Lesser Known FacetsMERGE SQL Statement: Lesser Known Facets
MERGE SQL Statement: Lesser Known Facets
Andrej Pashchenko143 views
Oracle Baisc Tutorial by bunny0143
Oracle Baisc TutorialOracle Baisc Tutorial
Oracle Baisc Tutorial
bunny0143629 views
Oracle postgre sql-mirgration-top-10-mistakes by Jim Mlodgenski
Oracle postgre sql-mirgration-top-10-mistakesOracle postgre sql-mirgration-top-10-mistakes
Oracle postgre sql-mirgration-top-10-mistakes
Jim Mlodgenski737 views
Using histograms to get better performance by Sergey Petrunya
Using histograms to get better performanceUsing histograms to get better performance
Using histograms to get better performance
Sergey Petrunya324 views
PL/SQL by Vaibhav0
PL/SQLPL/SQL
PL/SQL
Vaibhav0817 views
New features-in-mariadb-and-mysql-optimizers by Sergey Petrunya
New features-in-mariadb-and-mysql-optimizersNew features-in-mariadb-and-mysql-optimizers
New features-in-mariadb-and-mysql-optimizers
Sergey Petrunya1.6K views

Viewers also liked

Life with big Firebird databases by
Life with big Firebird databasesLife with big Firebird databases
Life with big Firebird databasesAlexey Kovyazin
9.9K views35 slides
How Firebird transactions work by
How Firebird transactions workHow Firebird transactions work
How Firebird transactions workAlexey Kovyazin
12.4K views70 slides
Firebird's Big Databases (in English) by
Firebird's Big Databases (in English)Firebird's Big Databases (in English)
Firebird's Big Databases (in English)Alexey Kovyazin
22.3K views36 slides
High-load performance testing: Firebird 2.5, 3.0, 4.0 by
High-load performance testing:  Firebird 2.5, 3.0, 4.0High-load performance testing:  Firebird 2.5, 3.0, 4.0
High-load performance testing: Firebird 2.5, 3.0, 4.0Alexey Kovyazin
6.8K views16 slides
How Firebird transactions work by
How Firebird transactions workHow Firebird transactions work
How Firebird transactions workMind The Firebird
2.9K views72 slides
Firebird 3: provider-based architecture, plugins and OO approach to API by
Firebird 3: provider-based architecture, plugins and OO approach to API Firebird 3: provider-based architecture, plugins and OO approach to API
Firebird 3: provider-based architecture, plugins and OO approach to API Mind The Firebird
3.6K views73 slides

Viewers also liked(14)

Life with big Firebird databases by Alexey Kovyazin
Life with big Firebird databasesLife with big Firebird databases
Life with big Firebird databases
Alexey Kovyazin9.9K views
How Firebird transactions work by Alexey Kovyazin
How Firebird transactions workHow Firebird transactions work
How Firebird transactions work
Alexey Kovyazin12.4K views
Firebird's Big Databases (in English) by Alexey Kovyazin
Firebird's Big Databases (in English)Firebird's Big Databases (in English)
Firebird's Big Databases (in English)
Alexey Kovyazin22.3K views
High-load performance testing: Firebird 2.5, 3.0, 4.0 by Alexey Kovyazin
High-load performance testing:  Firebird 2.5, 3.0, 4.0High-load performance testing:  Firebird 2.5, 3.0, 4.0
High-load performance testing: Firebird 2.5, 3.0, 4.0
Alexey Kovyazin6.8K views
Firebird 3: provider-based architecture, plugins and OO approach to API by Mind The Firebird
Firebird 3: provider-based architecture, plugins and OO approach to API Firebird 3: provider-based architecture, plugins and OO approach to API
Firebird 3: provider-based architecture, plugins and OO approach to API
Mind The Firebird3.6K views
Creating logs for data auditing in FirebirdSQL by Mind The Firebird
Creating logs for data auditing in FirebirdSQLCreating logs for data auditing in FirebirdSQL
Creating logs for data auditing in FirebirdSQL
Mind The Firebird2.8K views
Новые возможности языка SQL в Firebird 3.0 by Alexey Kovyazin
Новые возможности языка SQL в Firebird 3.0Новые возможности языка SQL в Firebird 3.0
Новые возможности языка SQL в Firebird 3.0
Alexey Kovyazin7K views
Resolving Firebird performance problems by Alexey Kovyazin
Resolving Firebird performance problemsResolving Firebird performance problems
Resolving Firebird performance problems
Alexey Kovyazin67.4K views
Firebird, datos generales by albringas
Firebird, datos generalesFirebird, datos generales
Firebird, datos generales
albringas171K views

Similar to New SQL Features in Firebird 3, by Vlad Khorsun

Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo... by
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Alex Zaballa
1.9K views82 slides
Unit 3(rdbms) by
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)Jay Patel
476 views17 slides
Unit 3(rdbms) by
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)Jay Patel
564 views17 slides
Oracle Database 12c - New Features for Developers and DBAs by
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
192 views111 slides
Oracle Database 12c - New Features for Developers and DBAs by
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
3.9K views111 slides
Deep Dive of ADBMS Migration to Apache Spark—Use Cases Sharing by
Deep Dive of ADBMS Migration to Apache Spark—Use Cases SharingDeep Dive of ADBMS Migration to Apache Spark—Use Cases Sharing
Deep Dive of ADBMS Migration to Apache Spark—Use Cases SharingDatabricks
480 views64 slides

Similar to New SQL Features in Firebird 3, by Vlad Khorsun(20)

Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo... by Alex Zaballa
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Alex Zaballa1.9K views
Unit 3(rdbms) by Jay Patel
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)
Jay Patel476 views
Unit 3(rdbms) by Jay Patel
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)
Jay Patel564 views
Oracle Database 12c - New Features for Developers and DBAs by Alex Zaballa
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
Alex Zaballa192 views
Oracle Database 12c - New Features for Developers and DBAs by Alex Zaballa
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
Alex Zaballa3.9K views
Deep Dive of ADBMS Migration to Apache Spark—Use Cases Sharing by Databricks
Deep Dive of ADBMS Migration to Apache Spark—Use Cases SharingDeep Dive of ADBMS Migration to Apache Spark—Use Cases Sharing
Deep Dive of ADBMS Migration to Apache Spark—Use Cases Sharing
Databricks480 views
Proc SQL in SAS Enterprise Guide 4.3 by Mark Tabladillo
Proc SQL in SAS Enterprise Guide 4.3Proc SQL in SAS Enterprise Guide 4.3
Proc SQL in SAS Enterprise Guide 4.3
Mark Tabladillo5.7K views
Sql interview questions by nagesh Rao
Sql interview questionsSql interview questions
Sql interview questions
nagesh Rao291 views
JDBC Driver for Aerospike - Meetup Dec 2019 by Aerospike
JDBC Driver for Aerospike - Meetup Dec 2019JDBC Driver for Aerospike - Meetup Dec 2019
JDBC Driver for Aerospike - Meetup Dec 2019
Aerospike107 views
Beg sql by KPNR Jan
Beg sqlBeg sql
Beg sql
KPNR Jan363 views
Fun Things to do with Logical Decoding by Mike Fowler
Fun Things to do with Logical DecodingFun Things to do with Logical Decoding
Fun Things to do with Logical Decoding
Mike Fowler680 views
Optimizing applications and database performance by Inam Bukhary
Optimizing applications and database performanceOptimizing applications and database performance
Optimizing applications and database performance
Inam Bukhary591 views
SQL Server 2008 New Features by Dan English
SQL Server 2008 New FeaturesSQL Server 2008 New Features
SQL Server 2008 New Features
Dan English2.2K views
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D... by Alex Zaballa
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
Alex Zaballa93 views
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D... by Alex Zaballa
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
Alex Zaballa569 views

More from Mind The Firebird

Using Azure cloud and Firebird to develop applications easily by
Using Azure cloud and Firebird to develop applications easilyUsing Azure cloud and Firebird to develop applications easily
Using Azure cloud and Firebird to develop applications easilyMind The Firebird
2.2K views9 slides
A year in the life of Firebird .Net provider by
A year in the life of Firebird .Net providerA year in the life of Firebird .Net provider
A year in the life of Firebird .Net providerMind The Firebird
1.2K views16 slides
Copycat presentation by
Copycat presentationCopycat presentation
Copycat presentationMind The Firebird
1.9K views17 slides
Using ТРСС to study Firebird performance by
Using ТРСС to study Firebird performanceUsing ТРСС to study Firebird performance
Using ТРСС to study Firebird performanceMind The Firebird
1.9K views56 slides
Overview of RedDatabase 2.5 by
Overview of RedDatabase 2.5Overview of RedDatabase 2.5
Overview of RedDatabase 2.5Mind The Firebird
1.4K views30 slides
Firebird Performance counters in details by
Firebird Performance counters in detailsFirebird Performance counters in details
Firebird Performance counters in detailsMind The Firebird
1.7K views35 slides

More from Mind The Firebird(20)

Using Azure cloud and Firebird to develop applications easily by Mind The Firebird
Using Azure cloud and Firebird to develop applications easilyUsing Azure cloud and Firebird to develop applications easily
Using Azure cloud and Firebird to develop applications easily
Mind The Firebird2.2K views
A year in the life of Firebird .Net provider by Mind The Firebird
A year in the life of Firebird .Net providerA year in the life of Firebird .Net provider
A year in the life of Firebird .Net provider
Mind The Firebird1.2K views
Using ТРСС to study Firebird performance by Mind The Firebird
Using ТРСС to study Firebird performanceUsing ТРСС to study Firebird performance
Using ТРСС to study Firebird performance
Mind The Firebird1.9K views
Firebird Performance counters in details by Mind The Firebird
Firebird Performance counters in detailsFirebird Performance counters in details
Firebird Performance counters in details
Mind The Firebird1.7K views
Understanding Numbers in Firebird SQL by Mind The Firebird
Understanding Numbers in Firebird SQLUnderstanding Numbers in Firebird SQL
Understanding Numbers in Firebird SQL
Mind The Firebird6.5K views
Threading through InterBase, Firebird, and beyond by Mind The Firebird
Threading through InterBase, Firebird, and beyondThreading through InterBase, Firebird, and beyond
Threading through InterBase, Firebird, and beyond
Mind The Firebird1.8K views
Orphans, Corruption, Careful Write, and Logging by Mind The Firebird
Orphans, Corruption, Careful Write, and LoggingOrphans, Corruption, Careful Write, and Logging
Orphans, Corruption, Careful Write, and Logging
Mind The Firebird1.5K views
Firebird release strategy and roadmap for 2015/2016 by Mind The Firebird
Firebird release strategy and roadmap for 2015/2016Firebird release strategy and roadmap for 2015/2016
Firebird release strategy and roadmap for 2015/2016
Mind The Firebird3.5K views
Nbackup and Backup: Internals, Usage strategy and Pitfalls, by Dmitry Kuzmenk... by Mind The Firebird
Nbackup and Backup: Internals, Usage strategy and Pitfalls, by Dmitry Kuzmenk...Nbackup and Backup: Internals, Usage strategy and Pitfalls, by Dmitry Kuzmenk...
Nbackup and Backup: Internals, Usage strategy and Pitfalls, by Dmitry Kuzmenk...
Mind The Firebird1.1K views
Working with Large Firebird databases by Mind The Firebird
Working with Large Firebird databasesWorking with Large Firebird databases
Working with Large Firebird databases
Mind The Firebird1.7K views
Superchaging big production systems on Firebird: transactions, garbage, maint... by Mind The Firebird
Superchaging big production systems on Firebird: transactions, garbage, maint...Superchaging big production systems on Firebird: transactions, garbage, maint...
Superchaging big production systems on Firebird: transactions, garbage, maint...
Mind The Firebird1.5K views
Continuous Database Monitoring with the Trace API by Mind The Firebird
Continuous Database Monitoring with the Trace APIContinuous Database Monitoring with the Trace API
Continuous Database Monitoring with the Trace API
Mind The Firebird2.7K views
Firebird Conference 2011 - Introduction by Mind The Firebird
Firebird Conference 2011 - IntroductionFirebird Conference 2011 - Introduction
Firebird Conference 2011 - Introduction
Mind The Firebird1.9K views
Firebird database recovery and protection for enterprises and ISV by Mind The Firebird
Firebird database recovery and protection for enterprises and ISVFirebird database recovery and protection for enterprises and ISV
Firebird database recovery and protection for enterprises and ISV
Mind The Firebird2.4K views
Migration from Firebird 1.5 to Firebird 2.5 by Mind The Firebird
Migration from Firebird 1.5 to Firebird 2.5Migration from Firebird 1.5 to Firebird 2.5
Migration from Firebird 1.5 to Firebird 2.5
Mind The Firebird2.7K views

Recently uploaded

Top-5-production-devconMunich-2023.pptx by
Top-5-production-devconMunich-2023.pptxTop-5-production-devconMunich-2023.pptx
Top-5-production-devconMunich-2023.pptxTier1 app
8 views40 slides
The Path to DevOps by
The Path to DevOpsThe Path to DevOps
The Path to DevOpsJohn Valentino
5 views6 slides
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx by
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptxanimuscrm
15 views19 slides
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... by
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Lisi Hocke
35 views124 slides
Using Qt under LGPL-3.0 by
Using Qt under LGPL-3.0Using Qt under LGPL-3.0
Using Qt under LGPL-3.0Burkhard Stubert
12 views11 slides
EV Charging App Case by
EV Charging App Case EV Charging App Case
EV Charging App Case iCoderz Solutions
8 views1 slide

Recently uploaded(20)

Top-5-production-devconMunich-2023.pptx by Tier1 app
Top-5-production-devconMunich-2023.pptxTop-5-production-devconMunich-2023.pptx
Top-5-production-devconMunich-2023.pptx
Tier1 app8 views
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx by animuscrm
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
animuscrm15 views
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... by Lisi Hocke
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Lisi Hocke35 views
tecnologia18.docx by nosi6702
tecnologia18.docxtecnologia18.docx
tecnologia18.docx
nosi67025 views
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P... by NimaTorabi2
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P...Unlocking the Power of AI in Product Management - A Comprehensive Guide for P...
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P...
NimaTorabi215 views
Introduction to Git Source Control by John Valentino
Introduction to Git Source ControlIntroduction to Git Source Control
Introduction to Git Source Control
John Valentino5 views
AI and Ml presentation .pptx by FayazAli87
AI and Ml presentation .pptxAI and Ml presentation .pptx
AI and Ml presentation .pptx
FayazAli8712 views
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action by Márton Kodok
Gen Apps on Google Cloud PaLM2 and Codey APIs in ActionGen Apps on Google Cloud PaLM2 and Codey APIs in Action
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action
Márton Kodok11 views
Myths and Facts About Hospice Care: Busting Common Misconceptions by Care Coordinations
Myths and Facts About Hospice Care: Busting Common MisconceptionsMyths and Facts About Hospice Care: Busting Common Misconceptions
Myths and Facts About Hospice Care: Busting Common Misconceptions
Advanced API Mocking Techniques by Dimpy Adhikary
Advanced API Mocking TechniquesAdvanced API Mocking Techniques
Advanced API Mocking Techniques
Dimpy Adhikary23 views
Navigating container technology for enhanced security by Niklas Saari by Metosin Oy
Navigating container technology for enhanced security by Niklas SaariNavigating container technology for enhanced security by Niklas Saari
Navigating container technology for enhanced security by Niklas Saari
Metosin Oy14 views
360 graden fabriek by info33492
360 graden fabriek360 graden fabriek
360 graden fabriek
info33492138 views
Fleet Management Software in India by Fleetable
Fleet Management Software in India Fleet Management Software in India
Fleet Management Software in India
Fleetable12 views
Bootstrapping vs Venture Capital.pptx by Zeljko Svedic
Bootstrapping vs Venture Capital.pptxBootstrapping vs Venture Capital.pptx
Bootstrapping vs Venture Capital.pptx
Zeljko Svedic12 views

New SQL Features in Firebird 3, by Vlad Khorsun

  • 1. New FeaturesNew SQL Features in 3in Firebird 3
  • 3. Prague SQLPrague 2014 Whats new in Firebird SQL 3 ●Common SQL ●Full syntax of MERGE statement (per SQL 2008) ●MERGE ... RETURNING ●Window (analytical) functions ●SUBSTRING with regular expressions ●BOOLEAN data type ●New RDB$RECORD_VERSION pseudo-column ●Cursor stability with data modification queries ●Global temporary tables are improved Whats new in Firebird 3
  • 4. Prague SQLPrague 2014 Whats new in Firebird SQL 4 ●Procedural SQL ●SQL functions ●Sub-routines ●External functions, procedures and triggers on CC++PascalJava etc. ●Packages ●Exceptions with parameters : EXCEPTION ... USING (...) ●SQLSTATE in WHEN handler ●CONTINUE in loops ●Cursors could be references as record variable ●Bi-directional cursors Whats new in Firebird 3
  • 5. Prague SQLPrague 2014 Whats new in Firebird SQL 5 ●DDL ●Manage nullability of column ●ALTER DOMAIN ... {NULL | NOT NULL} ●ALTER COLUMN ... {NULL | NOT NULL} ●ALTER DATABASE ... SET DEFAULT CHARACTER SET ●IDENTITY columns ●RECREATE SEQUENCE, RECREATE GENERATOR ●DDL triggers ●Database LINGER Whats new in Firebird 3
  • 6. Prague SQLPrague 2014 Whats new in Firebird SQL 6 ●Security ●User management ●Support for database encryption ●Enhanced object privileges ●DDL privileges ●Database-level privileges ●SET ROLE TO <role> ●Monitoring ●Extended statistics, queries plan's, ... Whats new in Firebird 3
  • 7. Prague SQLPrague 2014 Whats new in Firebird SQL 7 Common SQL : MERGE Full SQL 2008 syntax MERGE INTO <table> USING <table_or_join> ON <search_condition> [WHEN MATCHED [AND <search_condition>] THEN UPDATE SET col1 = val1, ..., colN = valN | DELETE] [WHEN NOT MATCHED [AND <search_condition>] THEN INSERT [(col1, ..., colN)] VALUES (val1, ..., valN)]
  • 8. Prague SQLPrague 2014 Whats new in Firebird SQL 8 Common SQL : MERGE DELETE substatement and multiply WHEN clauses MERGE INTO TABLE USING LOG ON TABLE.PK = LOG.PK WHEN MATCHED AND LOG.ACTION = 'D' THEN DELETE WHEN MATCHED THEN-- second WHEN MATCHED clause UPDATE SET col1 = LOG.val1, ... WHEN NOT MATCHED THEN INSERT (col1, ...) VALUES (LOG.val1, ...)
  • 9. Prague SQLPrague 2014 Whats new in Firebird SQL 9 Common SQL : MERGE RETURNING clause MERGE INTO <table> USING <table_or_join> ON <search_condition> [WHEN MATCHED [AND <search_condition>] THEN UPDATE SET col1 = val1, ..., colN = valN | DELETE] [WHEN NOT MATCHED [AND <search_condition>] THEN INSERT [(col1, ..., colN)] VALUES (val1, ..., valN)] [RETURNING ... [INTO ...]]
  • 10. Prague SQLPrague 2014 Whats new in Firebird SQL 10 Common SQL : WINDOW FUNCTIONS Syntax <window function> ::= <window function type> OVER (<window specification>) <window function type> ::= <aggregate function>–- aggregate | <rank function type>–- ranking | ROW_NUMBER–- yes, it is row number ;) | <lead or lag function>–- navigational | <first or last value function> | <nth value function> <window specification> ::= [PARTITION BY column1, ...] [ORDER BY column1 [ASC|DESC] [NULLS {FIRST|LAST}], ... ]
  • 11. Prague SQLPrague 2014 Whats new in Firebird SQL 11 Common SQL : WINDOW FUNCTIONS Syntax <aggregate function> ::= AVG | MAX | MIN | SUM | COUNT | LIST <rank function type> ::= RANK | DENSE_RANK <lead or lag function> ::= LEAD | LAG <first or last value function> ::= {FIRST_VALUE | LAST_VALUE} (<value>) <nth value function> ::= NTH_VALUE (<value>, <nth row>)[FROM_FIRST | FROM_LAST]
  • 12. Prague SQLPrague 2014 Whats new in Firebird SQL 12 Common SQL : WINDOW FUNCTIONS Example SELECT A, B, C, SUM(C) OVER(), SUM(C) OVER(ORDER BY A, B), SUM(C) OVER(PARTITION BY A), SUM(C) OVER(PARTITION BY A ORDER BY B) ABCSUMSUM1SUM2SUM311301413060301220141506050131014160606021251418540252215141100404031411411414141
  • 13. Prague SQLPrague 2014 Whats new in Firebird SQL 13 Common SQL : substring search using REGEXP Syntax SUBSTRING(<string> SIMILAR <pattern> ESCAPE <char>) Rules ●Pattern ●R = <R1> <E> " <R2> <E> " <R3> ●Search ●S = <S1> <S2> <S3> 1)<S>SIMILAR TO <R1> <R2> <R3> ESCAPE <E> 2)<S1>SIMILAR TO <R1>ESCAPE <E> AND <S2> <S3>SIMILAR TO <R2> <R3>ESCAPE <E> 3)<S2>SIMILAR TO <R2>ESCAPE <E> AND <S3>SIMILAR TO <R3>ESCAPE <E> ●Result ●S2
  • 14. Prague SQLPrague 2014 Whats new in Firebird SQL 14 Common SQL : substring search using REGEXP Syntax SUBSTRING(<string> SIMILAR <pattern> ESCAPE <char>) Example SUBSTRING('abc-12b34xyz' SIMILAR '%"[+-]?[0-9]+"%' ESCAPE '') R1 = % R2 = [+-]?[0-9]+ R3 = % 1)'abc-12b34xyz'SIMILAR TO '%[+-]?[0-9]+%' ESCAPE '' 2)'abc' SIMILAR TO '%'ESCAPE '' AND '-12b34xyz' SIMILAR TO '[+-]?[0-9]+%'ESCAPE '' 3)'-12' SIMILAR TO '[+-]?[0-9]+'ESCAPE '' AND 'b34xyz' SIMILAR TO '%'ESCAPE '' Result '-12'
  • 15. Prague SQLPrague 2014 Whats new in Firebird SQL 15 Common SQL : BOOLEAN data type Syntax <data_type> ::= BOOLEAN <boolean_literal> ::= TRUE | FALSE | UNKNOWN Storage 1 byte Client support (XSQLDA) #define SQL_BOOLEAN32764
  • 16. Prague SQLPrague 2014 Whats new in Firebird SQL 16 Common SQL : BOOLEAN data type Truth tables AND True False Unknown True True False Unknown False False False False Unknown Unknown False Unknown OR True False Unknown True True True True False True False Unknown Unknown True Unknown Unknown IS True False Unknown True True False False False False True False Unknown False False True NOT True False False True Unknown Unknown
  • 17. Prague SQLPrague 2014 Whats new in Firebird SQL 17 Common SQL : BOOLEAN data type Examples CREATE TABLE TBOOL (ID INT, BVAL BOOLEAN); COMMIT; INSERT INTO TBOOL VALUES (1, TRUE); INSERT INTO TBOOL VALUES (2, 2 = 4); INSERT INTO TBOOL VALUES (3, NULL = 1); COMMIT; SELECT * FROM TBOOL ID BVAL ============ ======= 1 <true> 2 <false> 3 <null>
  • 18. Prague SQLPrague 2014 Whats new in Firebird SQL 18 Common SQL : BOOLEAN data type Examples SELECT * FROM TBOOL WHERE BVAL ID BVAL ============ ======= 1 <true> SELECT * FROM TBOOL WHERE BVAL IS FALSE ID BVAL ============ ======= 2 <false> SELECT * FROM TBOOL WHERE BVAL IS UNKNOWN ID BVAL ============ ======= 3 <null> SELECT * FROM TBOOL WHERE BVAL = UNKNOWN SELECT * FROM TBOOL WHERE BVAL <> UNKNOWN 1. Test for TRUE value 2. Test for FALSE value 3. Tests for UNKNOWN value
  • 19. Prague SQLPrague 2014 Whats new in Firebird SQL 19 Common SQL : BOOLEAN data type Examples SELECT ID, BVAL, BVAL AND ID < 2 FROM TBOOL ID BVAL ============ ======= ======= 1 <true> <true> 2 <false> <false> 3 <null> <false> 4. Boolean values in SELECT list
  • 20. Prague SQLPrague 2014 Whats new in Firebird SQL 20 Common SQL : cursor stability The issue ●Famous infinite insertion circle (CORE-92) INSERT INTO T SELECT * FROM T ●DELETE more rows than expected (CORE-634) DELETE FROM T WHERE ID IN (SELECT FIRST 1 ID FROM T) ●All DML statements is affected (INSERT, UPDATE, DELETE, MERGE) ●Common ticket at tracker CORE-3362
  • 21. Prague SQLPrague 2014 Whats new in Firebird SQL 21 Common SQL : cursor stability The reason of the issue ●DML statements used implicit cursors : ●INSERT INTO T SELECT ... FROM T works as FOR SELECT <values> FROM T INTO <tmp_vars> DO INSERT INTO T VALUES (<tmp_vars>) ●UPDATE T SET <fields> = <values> WHERE <conditions> works as FOR SELECT <values> FROM T WHERE <conditions> INTO <tmp_vars> AS CURSOR <cursor> DO UPDATE T SET <fields> = <tmp_vars> WHERE CURRENT OF <cursor> ●DELETE works like UPDATE
  • 22. Prague SQLPrague 2014 Whats new in Firebird SQL 22 Common SQL : cursor stability The “standard” way ●Rows to be insertedupdateddeleted should be marked first ●Marked rows is insertedupdateddeleted then ●Pros ●rowset is stable and is not affected by DML statement itself ●Cons ●Marks should be saved somewhere and rows will be visited again, or ●Whole marked rows should be saved somewhere and this store will be visited again ●Note : this could be reached in Firebird using (well known) workaround: force query to have SORT in PLAN - it will materialize implicit cursor and make it stable
  • 23. Prague SQLPrague 2014 Whats new in Firebird SQL 23 Common SQL : cursor stability The Firebird 3 way ●Use undo-log to see if record was already modified by current cursor ●if record was inserted - ignore it ●if record was updated or deleted - read backversion ●Pros ●No additional bookkeeping required ●No additional storage required ●Relatively easy to implement ●Cons ●Inserted records could be visited (but ignored, of course) ●Backversions of updateddeleted records should be read ●Not works with SUSPEND in PSQL
  • 24. Prague SQLPrague 2014 Whats new in Firebird SQL 24 Common SQL : cursor stability PSQL notes ●PSQL cursors with SUSPEND inside still not stable ! This query still produced infinite circle FOR SELECT ID FROM T INTO :ID DO BEGIN INSERT INTO T (ID) VALUES (:ID); SUSPEND; END
  • 25. Prague SQLPrague 2014 Whats new in Firebird SQL 25 Common SQL : cursor stability PSQL notes ●PSQL cursors without SUSPEND inside is stable, this could change old behavior FOR SELECT ID FROM T WHERE VAL IS NULL INTO :ID DO BEGIN UPDATE T SET VAL = 1 WHERE ID = :ID; END
  • 26. Prague SQLPrague 2014 Whats new in Firebird SQL 26 Common SQL : improvements in GTT ●Global temporary tables is writable even in read-only transactions ●Read-only transaction in read-write database ●Both GTT ON COMMIT PRESERVE ROWS and COMMIT DELETE ROWS ●Read-only transaction in read-only database ●GTT ON COMMIT DELETE ROWS only ●Faster rollback for GTT ON COMMIT DELETE ROWS ●No need to backout records on rollback ●Garbage collection in GTT is not delayed by active transactions of another connections ●All this improvements is backported into v2.5.1 too
  • 27. Prague SQLPrague 2014 Whats new in Firebird SQL 27 PSQL : SQL functions Syntax {CREATE [OR ALTER] | ALTER | RECREATE} FUNCTION <name> [(param1 [, ...])] RETURNS <type> AS BEGIN ... END Example CREATE FUNCTION F(X INT) RETURNS INT AS BEGIN RETURN X+1; END; SELECT F(5) FROM RDB$DATABASE;
  • 28. Prague SQLPrague 2014 Whats new in Firebird SQL 28 PSQL : SQL sub-routines Syntax ●Sub-procedures DECLARE PROCEDURE <name> [(param1 [, ...])] [RETURNS (param1 [, ...])] AS ... ●Sub-functions DECLARE FUNCTION <name> [(param1 [, ...])] RETURNS <type> AS ...
  • 29. Prague SQLPrague 2014 Whats new in Firebird SQL 29 PSQL : SQL sub-routines Example 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
  • 30. Prague SQLPrague 2014 Whats new in Firebird SQL 30 PSQL : Packages -– package header, declarations only CREATE OR ALTER PACKAGE TEST AS BEGIN PROCEDURE P1(I INT) RETURNS (O INT);-– public procedure END -– package body, implementation RECREATE PACKAGE BODY TEST AS BEGIN FUNCTION F1(I INT) RETURNS INT;–- private function PROCEDURE P1(I INT) RETURNS (O INT) AS BEGIN END; FUNCTION F1(I INT) RETURNS INT AS BEGIN RETURN 0; END; END
  • 31. Prague SQLPrague 2014 Whats new in Firebird SQL 31 PSQL : EXCEPTION with parameters Syntax a) Exception text could contain parameters markers (@1, @2, ...) CREATE EXCEPTION EX_WITH_PARAMS 'Error @1 : @2'; b) New clause USING allows to set parameters values whenexception raised: EXEPTION EX_WITH_PARAMS USING (1, 'You can not do it');
  • 32. Prague SQLPrague 2014 Whats new in Firebird SQL 32 PSQL : Cursors references as record variable FOR SELECT A, B, C FROM ... AS CURSOR C1// no INTO clause DO BEGIN ... INSERT INTO ... VALUES (C1.A, C1.B, C1.C, …);// cursor references END
  • 33. Prague SQLPrague 2014 Whats new in Firebird SQL 33 DDL : IDENTITY columns Syntax <column definition> ::= <name> <type> GENERATED BY DEFAULT AS IDENTITY [STARTS WITH <number>] <constraints> <alter column definition> ::= <name> RESTART [WITH <number>]
  • 34. Prague SQLPrague 2014 Whats new in Firebird SQL 34 DDL : IDENTITY columns Rules ●Column type – INTEGER or NUMERIC(P, 0) ●Implicit NOT NULL ●Not guarantees uniqueness ●Can not have DEFAULT clause ●Can not be COMPUTED BY ●Can not be altered to become non-identity and vice versa
  • 35. Prague SQLPrague 2014 Whats new in Firebird SQL 35 DDL : DDL triggers Syntax <ddl-trigger> ::= {CREATE | RECREATE | CREATE OR ALTER} TRIGGER <name> [ACTIVE | INACTIVE] {BEFORE | AFTER} <ddl event> [POSITION <n>] <ddl event> ::= ANY DDL STATEMENT | <ddl event item> [{OR <ddl event item>}...] <ddl event item> ::= {CREATE | ALTER | DROP} {TABLE | PROCEDURE | FUNCTION | TRIGGER | EXCEPTION | VIEW | DOMAIN | SEQUENCE | INDEX | ROLE | USER | COLLATION | PACKAGE | PACKAGE BODY | CHARACTER SET }
  • 36. Prague SQLPrague 2014 Whats new in Firebird SQL 36 DDL : DDL triggers New context variables (RDB$GET_CONTEXT) ●Namespace DDL_TRIGGER ●Defined inside DDL trigger only ●Read only ●Predefined variables: ●DDL_EVENT - kind of DDL event ●OBJECT_NAME – name of metadata object ●SQL_TEXT - text of SQL query
  • 37. Prague SQLPrague 2014 Whats new in Firebird SQL 37 DDL : DDL triggers Example CREATE EXCEPTION EX_BAD_SP_NAME 'Name of procedures must start with ''@1'' : ''@2'''; CREATE TRIGGER TRG_SP_CREATE BEFORE CREATE PROCEDURE AS DECLARE SP_NAME VARCHAR(255); BEGIN SP_NAME = RDB$GET_CONTEXT('DDL_TRIGGER', 'OBJECT_NAME'); IF (SP_NAME NOT STARTING 'SP_') THEN EXCEPTION EX_BAD_SP_NAME USING ('SP_', SP_NAME); END;
  • 38. Prague SQLPrague 2014 Whats new in Firebird SQL 38 DDL : Database LINGER ●Linger purposes ●Allow engine to keep in memory some database related structures after last disconnect: ●Page cache ●Background GC thread continue to work ●For Shared Cache only ●LINGER is switched off for current session, if ●database shutdown ●gfix -nolinger ●Syntax ●ALTER DATABASE SET LINGER TO <seconds> ●ALTER DATABASE DROP LINGER
  • 39. Prague SQLPrague 2014 Whats new in Firebird SQL 39 Security : user management Syntax CREATE [OR ALTER] USER <string> [SET] <option> [, …] ALTER CURRENT USER [SET] <option> [, …] <option> ::= PASSWORD <string> FIRSTNAME <string> MIDDLENAME <string> LASTNAME <string> {GRANT | REVOKE} ADMIN ROLE {ACTIVE | INACTIVE} TAGS (<list>)]
  • 40. Prague SQLPrague 2014 Whats new in Firebird SQL 40 Security : user management Example CREATE USER Vlad PASSWORD pass INACTIVE; ALTER USER Vlad ACTIVE; ALTER USER Vlad SET TAGS (id = 1, x = 'abcd'); ALTER USER Vlad SET TAGS (x = 'xyz'); ALTER USER Vlad SET TAGS (DROP x);
  • 41. Prague SQLPrague 2014 Whats new in Firebird SQL 41 Security : user management New virtual tables CREATE TABLE SEC$USERS ( SEC$USER_NAME RDB$USER, SEC$FIRST_NAME SEC$NAME_PART, SEC$MIDDLE_NAME SEC$NAME_PART, SEC$LAST_NAME SEC$NAME_PART, SEC$ACTIVE RDB$BOOLEAN, SEC$ADMIN RDB$BOOLEAN, SEC$DESCRIPTION RDB$DESCRIPTION ); CREATE TABLE SEC$USER_ATTRIBUTES ( SEC$USER_NAME RDB$USER, SEC$KEY SEC$KEY, SEC$VALUE SEC$VALUE );
  • 42. Prague SQLPrague 2014 Whats new in Firebird SQL 42 Security : EXECUTE privilege Syntax GRANT EXECUTE ON <object_type> <object_name> TO <grantee> [WITH GRANT OPTION] REVOKE [GRANT OPTION FOR] EXECUTE ON <object_type> <object_name> FROM <grantee> [GRANTED BY <grantor>] object_type ::= PROCEDURE | FUNCTION | PACKAGE
  • 43. Prague SQLPrague 2014 Whats new in Firebird SQL 43 Security : USAGE privilege Syntax GRANT USAGE ON <object_type> <object_name> TO <grantee> [WITH GRANT OPTION] REVOKE [GRANT OPTION FOR] USAGE ON <object_type> <object_name> FROM <grantee> [GRANTED BY <grantor>] object_type ::= {DOMAIN | EXCEPTION | GENERATOR | SEQUENCE | CHARACTER SET | COLLATION}
  • 44. Prague SQLPrague 2014 Whats new in Firebird SQL 44 Security : DDL privileges Syntax GRANT <ddl_privileges> <object> TO <grantee> [WITH GRANT OPTION] REVOKE [GRANT OPTION FOR] <ddl_privileges> <object> FROM <grantee> [GRANTED BY <grantor>] ddl_privileges ::= ALL [PRIVILEGES] | ddl_privilege[, ddl_privilege] ddl_privilege ::= {CREATE | ALTER ANY | DROP ANY} object ::= {TABLE | VIEW | PROCEDURE | FUNCTION | PACKAGE | GENERATOR | SEQUENCE | DOMAIN | EXCEPTION | ROLE | CHARACTER SET | COLLATION | FILTER}
  • 45. Prague SQLPrague 2014 Whats new in Firebird SQL 45 Security : database privileges Syntax REVOKE [GRANT OPTION FOR] <ddl_privileges> <object_name> FROM <grantee> [GRANTED BY <grantor>] ddl_privileges ::= ALL [PRIVILEGES] | ddl_privilege[, ddl_privilege] ddl_privilege ::= {CREATE | ALTER ANY | DROP ANY}
  • 46. Prague SQLPrague 2014 Whats new in Firebird SQL 46 Security : SET ROLE Syntax SET ROLE <name> SET TRUSTED ROLE
  • 47. Prague SQLPrague 2014 Whats new in Firebird SQL 47 Questions ? Firebird official web site Firebird tracker THANK ATTENTIONTHANK YOU FOR ATTENTION hvlad@users.sf.net