What s New in MariaDB Server 10.3
What s New in MariaDB Server 10.3
Database Compatibility Enhancements PL/SQL Compatibility for MariaDB Stored Functions including packages
PL/SQL Compatibility for MariaDB Stored Functions including packages Stored Functions in MariaDB Server are based on SQL/PSM, but are now providing PL/SQL compatibility for easy migration from Oracle to MariaDB no need to migrate Oracle PL/SQL logic to SQL/PSM or to the application layer, when migrating to MariaDB To stay compatible with older versions of MariaDB Server, an Oracle SQL Mode is needed to enable this compatibility sql_mode= oracle There has not been removed any syntax, which would not be allowed in PL/SQL, as this would break compatibility with existing stored functions
PL/SQL Compatibility for MariaDB Stored Functions including packages SQL/PSM ------CREATE [OR REPLACE] [DEFINER = {user CURRENT_USER }] PROCEDURE sp_name ([proc_parameter[,...]]) [characteristic...] body PL/SQL -----CREATE [OR REPLACE] [DEFINER = {user CURRENT_USER}] PROCEDURE sp_name [([proc_parameter[,...]])] [characteristic...] {IS AS} body proc_parameter: [IN OUT INOUT] name type name [IN OUT INOUT] type type: Any MariaDB data type characteristic: LANGUAGE SQL [NOT] DETERMINISTIC contains reads modifies SQL clause SQL SECURITY {DEFINER INVOKER} {DEFINER INVOKER} COMMENT 'string' any MariaDB or Oracle data type LANGUAGE SQL [NOT] DETERMINISTIC contains reads modifies SQL clause SQL SECURITY COMMENT 'string'
SQL/PSM ------- PL/SQL Compatibility for MariaDB Stored Functions including packages PL/SQL ------ label: <<label>> IF... THEN... [ELSE...] END IF IF... THEN... [ELSE...] END IF LOOP... END LOOP LOOP... END LOOP WHILE... DO...; END WHILE WHILE LOOP...; END LOOP CASE... WHEN... THEN... END CASE CASE... WHEN... THEN... END CASE REPEAT... UNTIL... ELSIF FOR GOTO NULL LEAVE EXIT [WHEN...] ITERATE CONTINUE [WHEN...]
Stored Function Packages A package is a schema object that groups logically related PL/SQL data types, items (e.g. variables, cursors, exceptions) and subprograms. Packages usually have two parts, specification and body The specification describes the interface of the package; it declares the types, variables, constants, exceptions, cursors, and subprograms available for use. The body fully defines cursors and subprograms, and so implements the specification.
Stored Function Packages Advantages when using packages: Logical grouping of related functions/procedures can simplify development Package-wide variables to pass data across functions, reduces the number of parameters when calling functions Separation of specification and definition (body) A User only needs the specification separate access privileges for specification and body Simplified privilege management. Grants on package inherits the access privileges to included functions
CREATE PACKAGE pkg1 AS PROCEDURE p1; Stored Function Packages FUNCTION f1 RETURN TEXT; END; Examples CREATE PACKAGE BODY pkg1 AS PROCEDURE p1 AS BEGIN NULL; END; FUNCTION f1 RETURN TEXT AS BEGIN RETURN 'This is f1'; END; END;
Stored Function Packages Current Limitations not support of package-wide variables for CREATE PACKAGE CREATE PACKAGE BODY supports it CREATE PACKAGE [BODY] does not support exception declaration type definition cursor declaration cursor variable declaration
Database Compatibility Enhancements Generation of unique primary keys by SEQUENCES
Generation of unique primary keys by SEQUENCES To enhance the database compatibility with other vendors, MariaDB Server now allows the creation of a SEQUENCE, which is used to create a sequence of numeric values Creating a SEQUENCE is not replacing the auto increment option which is well known by MariaDB users,, but is an alternative of creating unique identifiers and offers more control of how numbers are created Sequences also allow to compute the last number created by all sequences, a limitation auto increments have Sequences are implemented as tables with some exclusive options in MariaDB, which allows that existing tools and processes work unchanged
Generation of unique primary keys by SEQUENCES CREATE [OR REPLACE] [TEMPORARY] SEQUENCE [IF NOT EXISTS] sequence_name [ INCREMENT [ BY = ] increment ] [ MINVALUE [=] minvalue NO MINVALUE NOMINVALUE ] [ MAXVALUE [=] maxvalue NO MAXVALUE NOMAXVALUE ] [ START [ WITH = ] start ] [ CACHE [=] cache ] [ [ NO ] CYCLE ] [table_options] NEXT VALUE FOR sequence_name NEXTVAL(sequence_name) PREVIOUS VALUE FOR sequence_name LASTVAL(sequence_name) With sqlmode=oracle sequence_name.nextval sequence_name.currval are supported
Database Compatibility Enhancements Operations over result sets with INTERSECT and EXCEPT
Operations over result sets with INTERSECT and EXCEPT MariaDB Server is adding INTERSECT and EXCEPT to UNION, which already exists in former versions The result of an INTERSECT is the intersection of right and left SELECT results, i.e. only records that are present in both result sets will be included in the result of the operation. INTERSECT The result of EXCEPT is all records of the left SELECT result except records which are in right SELECT result set, i.e. it is subtraction of two result sets. EXCEPT
Database Compatibility Enhancements Define Columns to be hidden if not explicitly queried
Define Columns to be hidden if not explicitly queried An enhanced syntax allows to define a column as hidden A statement like select * from table will not show columns, which are defined as hidden A statement explicitly needs to be referenced to be shown in a result set SELECT hidden_col from table Creating a table with a column defined as hidden cannot have the constraint NOT NULL, when no default is given An insert statement does not require a value to be provided for a hidden column Hidden columns allow to remove dependency to applications, as columns can be added to tables with hiding them from the application, which otherwise might fail to run this can help to keep historical columns not needed by applications anymore or to prepare the database level for an upgrade before an application will be upgraded
Analytics / Temporal data processing System Versioned Tables with AS OF Query enhancement
System Versioned Tables with AS OF Query enhancement System Versioned tables are added to the InnoDB Storage Engine with MariaDB Server 10.3 System Versioned Tables include timestamped versions of the data in a table. This allows to track changes to compare data based on timestamps to visualize the development cycle of data and to create trends to audit the change of data A table can be altered to enable, disable or remove system versioned data The query enhancement AS OF is used to query data based on a defined timestamp Detailed Slides https://docs.google.com/a/mariadb.com/presentation/d/1ofdao0vbgkjbt8y51khvdz-7483jyloxb0sor4m obxg/edit?usp=sharing
User Flexibility User Defined Aggregate Functions
User Defined Aggregate Functions Text
Performance enhancements creating unique constraints on long data types
Storage Engine Enhancements MyRocks Storage Engine Evolution
Storage Engine Enhancements Sharding by integration of the Spider Storage Engine
Sharding by integration of the Spider Storage Engine NOTE: The final decision about which of these enhancements will make it into 10.3 is not finally decided The Spider storage engine allows to shard data over multiple MariaDB Server nodes while accessing the complete data set via a MariaDB Server acting as the Spider proxy. Shards are defined by creating partitions. the partitioned data is stored on the sharding nodes. MariaDB Server 10.3. includes the enhancements: Integration of the Vertical Partition Engine This allows partitioning by columns Engine condition pushdown support in the partition engine to push down the engine condition to the data nodes Multi range read support in the partition engine. Direct update/delete. This involves pushdown of updates and deletes to the data nodes. Full Text Search support in the partition engine. Bulk access support in the partition engine.
Sharding by integration of the Spider Storage Engine NOTE: The final decision about which of these enhancements will make it into 10.3 is not finally decided Auto-increment data type support in the partition engine. Support for direct aggregation sums, min, max, avg through the partition engine. Support for child partition pruning in MyIsam Merge tables through the partition engine. Option to log result errors. Options to log stored procedure queries.
Proxy Layer Support for MariaDB Server Client / Server authentication via a Proxy like MariaDB MaxScale using a Server Proxy Protocol Support
Proxy Layer Support for MariaDB Server MariaDB Server 10.3 allows a client to connect to the Server via a proxy without the need to define the user privileges based on the host of the proxy, as the proxy protocol allows a proxy to provide the client IP address to the server This simplifies the user management for clients, which can connect directly to the Server and via Proxy. When introducing a proxy layer, client privileges do not need to be changed When using the Audit Plugin and other logs, the logged client IP address is now the real client IP and not the IP from the proxy anymore. A new parameter controls the host IP address, which is allowed to use the proxy protocol
Summary - What s New Database Compatibility PL/SQL Compatibility for MariaDB Stored Functions including packages Generation of unique primary keys by SEQUENCES Operations over result sets with INTERSECT and EXCEPT Define Columns to be hidden if not explicitly queried Analytics / Temporal data processing System Versioned Tables with AS OF Query enhancement User Flexibility User Defined Aggregate Functions Performance enhancements creating unique constraints on long data types Storage Engine Enhancements MyRocks Storage Engine Evolution Sharding by integration of the Spider Storage Engine Enable InnoDB NUMA interleave for InnoDB Proxy Layer Support for MariaDB Server Client / Server authentication via a Proxy like MariaDB MaxScale using a Server Proxy Protocol Support Backup MariaDB Backup for MyRocks
Thank you