(689,'CREATE TABLE',38,'Syntax\n------\n\nCREATE [OR REPLACE] [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name\n  (create_definition,...) [table_options    ]... [partition_options]\nCREATE [OR REPLACE] [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name\n  [(create_definition,...)] [table_options   ]... [partition_options]\n  select_statement\nCREATE [OR REPLACE] [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name\n { LIKE old_table_name | (LIKE old_table_name) }\nselect_statement:\n  [IGNORE | REPLACE] [AS] SELECT ...   (Some legal select statement)\n\nDescription\n-----------\n\nUse the CREATE TABLE statement to create a table with the given name.\n\nIn its most basic form, the CREATE TABLE statement provides a table name\nfollowed by a list of columns, indexes, and constraints. By default, the table\nis created in the default database. Specify a database with db_name.tbl_name.\nIf you quote the table name, you must quote the database name and table name\nseparately as `db_name`.`tbl_name`. This is particularly useful for CREATE\nTABLE ... SELECT, because it allows to create a table into a database, which\ncontains data from other databases. See Identifier Qualifiers.\n\nIf a table with the same name exists, error 1050 results. Use IF NOT EXISTS to\nsuppress this error and issue a note instead. Use SHOW WARNINGS to see notes.\n\nThe CREATE TABLE statement automatically commits the current transaction,\nexcept when using the TEMPORARY keyword.\n\nFor valid identifiers to use as table names, see Identifier Names.\n\nNote: if the default_storage_engine is set to ColumnStore then it needs\nsetting on all UMs. Otherwise when the tables using the default engine are\nreplicated across UMs they will use the wrong engine. You should therefore not\nuse this option as a session variable with ColumnStore.\n\nMicrosecond precision can be between 0-6. If no precision is specified it is\nassumed to be 0, for backward compatibility reasons.\n\nPrivileges\n----------\n\nExecuting the CREATE TABLE statement requires the CREATE privilege for the\ntable or the database.\n\nCREATE OR REPLACE\n-----------------\n\nIf the OR REPLACE clause is used and the table already exists, then instead of\nreturning an error, the server will drop the existing table and replace it\nwith the newly defined table.\n\nThis syntax was originally added to make replication more robust if it has to\nrollback and repeat statements such as CREATE ... SELECT on replicas.\n\nCREATE OR REPLACE TABLE table_name (a int);\n\nis basically the same as:\n\nDROP TABLE IF EXISTS table_name;\nCREATE TABLE table_name (a int);\n\nwith the following exceptions:\n\n* If table_name was locked with LOCK TABLES it will continue to be locked\nafter the statement.\n* Temporary tables are only dropped if the TEMPORARY keyword was used.  (With\nDROP TABLE,  temporary tables are preferred to be dropped before normal\ntables).\n\nThings to be Aware of With CREATE OR REPLACE\n--------------------------------------------\n\n* The table is dropped first (if it existed), after that the CREATE is done.\nBecause of this, if the CREATE fails, then the table will not exist anymore\nafter the statement.  If the table was used with LOCK TABLES it will be\nunlocked.\n* One can\'t use OR REPLACE together with IF EXISTS.\n* Slaves in replication will by default use CREATE OR REPLACE when replicating\nCREATE statements that don\'\'t use IF EXISTS. This can be changed by setting\nthe variable slave-ddl-exec-mode to STRICT.\n\nCREATE TABLE IF NOT EXISTS\n--------------------------\n\nIf the IF NOT EXISTS clause is used, then the table will only be created if a\ntable with the same name does not already exist. If the table already exists,\nthen a warning will be triggered by default.\n\nCREATE TEMPORARY TABLE\n----------------------\n\nUse the TEMPORARY keyword to create a temporary table that is only available\nto the current session. Temporary tables are dropped when the session ends.\nTemporary table names are specific to the session. They will not conflict with\nother temporary tables from other sessions even if they share the same name.\nThey will shadow names of non-temporary tables or views, if they are\nidentical. A temporary table can have the same name as a non-temporary table\nwhich is located in the same database. In that case, their name will reference\nthe temporary table when used in SQL statements. You must have the CREATE\nTEMPORARY TABLES privilege on the database to create temporary tables. If no\nstorage engine is specified, the default_tmp_storage_engine setting will\ndetermine the engine.\n\nROCKSDB temporary tables cannot be created by setting the\ndefault_tmp_storage_engine system variable, or using CREATE TEMPORARY TABLE\nLIKE. Before MariaDB 10.7, they could be specified, but would silently fail,\nand a MyISAM table would be created instead. From MariaDB 10.7 an error is\nreturned. Explicitly creating a temporary table with ENGINE=ROCKSDB has never\nbeen permitted.\n\nCREATE TABLE ... LIKE\n---------------------\n\nUse the LIKE clause instead of a full table definition to create a table with\nthe same definition as another table, including columns, indexes, and table\noptions. Foreign key definitions, as well as any DATA DIRECTORY or INDEX\nDIRECTORY table options specified on the original table, will not be created.\n\nCREATE TABLE ... SELECT\n-----------------------\n\nYou can create a table containing data from other tables using the CREATE ...\nSELECT statement. Columns will be created in the table for each field returned\nby the SELECT query.\n\nYou can also define some columns normally and add other columns from a SELECT.\nYou can also create columns in the normal way and assign them some values\nusing the query, this is done to force a certain type or other field\ncharacteristics. The columns that are not named in the query will be placed\nbefore the others. For example:\n\nCREATE TABLE test (a INT NOT NULL, b CHAR(10)) ENGINE=MyISAM\n  SELECT 5 AS b, c, d FROM another_table;\n\nRemember that the query just returns data. If you want to use the same\nindexes, or the same columns attributes ([NOT] NULL, DEFAULT, AUTO_INCREMENT)\nin the new table, you need to specify them manually. Types and sizes are not\nautomatically preserved if no data returned by the SELECT requires the full\nsize, and VARCHAR could be converted into CHAR. The CAST() function can be\nused to forcee the new table to use certain types.\n\nAliases (AS) are taken into account, and they should always be used when you\nSELECT an expression (function, arithmetical operation, etc).\n\nIf an error occurs during the query, the table will not be created at all.\n\nIf the new table has a primary key or UNIQUE indexes, you can use the IGNORE\nor REPLACE keywords to handle duplicate key errors during the query. IGNORE\nmeans that the newer values must not be inserted an identical value exists in\nthe index. REPLACE means that older values must be overwritten.\n\nIf the columns in the new table are more than the rows returned by the query,\nthe columns populated by the query will be placed after other columns. Note\nthat if the strict SQL_MODE is on, and the columns that are not names in the\nquery do not have a DEFAULT value, an error will raise and no rows will be\ncopied.\n\nConcurrent inserts are not used during the execution of a CREATE ... SELECT.\n\nIf the table already exists, an error similar to the following will be\nreturned:\n\nERROR 1050 (42S01): Table \'t\' already exists\n\nIf the IF NOT EXISTS clause is used and the table exists, a note will be\nproduced instead of an error.\n\nTo insert rows from a query into an existing table, INSERT ... SELECT can be\nused.\n\nColumn Definitions\n------------------\n\ncreate_definition:\n { col_name column_definition | index_definition | period_definition | CHECK\n(expr) }\ncolumn_definition:\n data_type\n  [NOT NULL | NULL] [DEFAULT default_value | (expression)]\n  [ON UPDATE [NOW | CURRENT_TIMESTAMP] [(precision)]]\n  [AUTO_INCREMENT] [ZEROFILL] [UNIQUE [KEY] | [PRIMARY] KEY]\n  [INVISIBLE] [{WITH|WITHOUT} SYSTEM VERSIONING]\n  [COMMENT \'string\'] [REF_SYSTEM_ID = value]\n  [reference_definition]\n | data_type [GENERATED ALWAYS]\n AS { { ROW {START|END} } | { (expression) [VIRTUAL | PERSISTENT | STORED] } }\n   [UNIQUE [KEY]] [COMMENT \'string\']\nconstraint_definition:\n CONSTRAINT [constraint_name] CHECK (expression)\nNote: Until MariaDB 10.4, MariaDB accepts the shortcut format with a\nREFERENCES clause only in ALTER TABLE and CREATE TABLE statements, but that\nsyntax does nothing. For example:\n\nCREATE TABLE b(for_key INT REFERENCES a(not_key));\n\nMariaDB simply parses it without returning any error or warning, for\ncompatibility with other DBMS\'s. Before MariaDB 10.2.1 this was also true for\nCHECK constraints. However, only the syntax described below creates foreign\nkeys.\n\nFrom MariaDB 10.5, MariaDB will attempt to apply the constraint. See Foreign\nKeys examples.\n\nEach definition either creates a column in the table or specifies and index or\nconstraint on one or more columns. See Indexes below for details on creating\nindexes.\n\nCreate a column by specifying a column name and a data type, optionally\nfollowed by column options. See Data Types for a full list of data types\nallowed in MariaDB.\n\nNULL and NOT NULL\n-----------------\n\nUse the NULL or NOT NULL options to specify that values in the column may or\nmay not be NULL, respectively. By default, values may be NULL. See also NULL\nValues in MariaDB.\n\nDEFAULT Column Option\n---------------------\n\nMariaDB starting with 10.2.1\n----------------------------\nThe DEFAULT clause was enhanced in MariaDB 10.2.1. Some enhancements include\n\n* BLOB and TEXT columns now support DEFAULT.\n* The DEFAULT clause can now be used with an expression or function.\n\nSpecify a default value using the DEFAULT clause. If you don\'t specify DEFAULT\nthen the following rules apply:\n\n* If the column is not defined with NOT NULL, AUTO_INCREMENT or TIMESTAMP, an\nexplicit DEFAULT NULL will be added.\nNote that in MySQL and in MariaDB before 10.1.6, you may get an explicit\nDEFAULT for primary key parts, if not specified with NOT NULL.\n\nThe default value will be used if you INSERT a row without specifying a value\nfor that column, or if you specify DEFAULT for that column. Before MariaDB\n10.2.1 you couldn\'t usually provide an expression or function to evaluate at\ninsertion time. You had to provide a constant default value instead. The one\nexception is that you may use CURRENT_TIMESTAMP as the default value for a\nTIMESTAMP column to use the current timestamp at insertion time.\n\nCURRENT_TIMESTAMP may also be used as the default value for a DATETIME\n\nFrom MariaDB 10.2.1 you can use most functions in DEFAULT. Expressions should\nhave parentheses around them. If you use a non deterministic function in\nDEFAULT then all inserts to the table will be replicated in row mode. You can\neven refer to earlier columns in the DEFAULT expression (excluding\nAUTO_INCREMENT columns):\n\nCREATE TABLE t1 (a int DEFAULT (1+1), b int DEFAULT (a+1));\nCREATE TABLE t2 (a bigint primary key DEFAULT UUID_SHORT());\n\nThe DEFAULT clause cannot contain any stored functions or subqueries, and a\ncolumn used in the clause must already have been defined earlier in the\nstatement.\n\nSince MariaDB 10.2.1, it is possible to assign BLOB or TEXT columns a DEFAULT\nvalue. In earlier versions, assigning a default to these columns was not\npossible.\n\nMariaDB starting with 10.3.3\n----------------------------\nStarting from 10.3.3 you can also use DEFAULT (NEXT VALUE FOR sequence)\n\nAUTO_INCREMENT Column Option\n----------------------------\n\nUse AUTO_INCREMENT to create a column whose value can can be set automatically\nfrom a simple counter. You can only use AUTO_INCREMENT on a column with an\ninteger type. The column must be a key, and there can only be one\nAUTO_INCREMENT column in a table. If you insert a row without specifying a\nvalue for that column (or if you specify 0, NULL, or DEFAULT as the value),\nthe actual value will be taken from the counter, with each insertion\nincrementing the counter by one. You can still insert a value explicitly. If\nyou insert a value that is greater than the current counter value, the counter\nis set based on the new value. An AUTO_INCREMENT column is implicitly NOT\nNULL. Use LAST_INSERT_ID to get the AUTO_INCREMENT value most recently used by\nan INSERT statement.\n\nZEROFILL Column Option\n----------------------\n\nIf the ZEROFILL column option is specified for a column using a numeric data\ntype, then the column will be set to UNSIGNED and the spaces used by default\nto pad the field are replaced with zeros. ZEROFILL is ignored in expressions\nor as part of a UNION. ZEROFILL is a non-standard MySQL and MariaDB\nenhancement.\n\nPRIMARY KEY Column Option\n-------------------------\n\nUse PRIMARY KEY to make a column a primary key. A primary key is a special\ntype of a unique key. There can be at most one primary key per table, and it\nis implicitly NOT NULL.\n\nSpecifying a column as a unique key creates a unique index on that column. See\nthe Index Definitions section below for more information.\n\nUNIQUE KEY Column Option\n------------------------\n\nUse UNIQUE KEY (or just UNIQUE) to specify that all values in the column must\nbe distinct from each other. Unless the column is NOT NULL, there may be\nmultiple rows with NULL in the column.\n\nSpecifying a column as a unique key creates a unique index on that column. See\nthe Index Definitions section below for more information.\n\nCOMMENT Column Option\n---------------------\n\nYou can provide a comment for each column using the COMMENT clause. The\nmaximum length is 1024 characters. Use the SHOW FULL COLUMNS statement to see\ncolumn comments.\n\nREF_SYSTEM_ID\n-------------\n\nREF_SYSTEM_ID can be used to specify Spatial Reference System IDs for spatial\ndata type columns. For example:\n\nCREATE TABLE t1(g GEOMETRY(9,4) REF_SYSTEM_ID=101);\n\nGenerated Columns\n-----------------\n\nA generated column is a column in a table that cannot explicitly be set to a\nspecific value in a DML query. Instead, its value is automatically generated\nbased on an expression. This expression might generate the value based on the\nvalues of other columns in the table, or it might generate the value by\ncalling built-in functions or user-defined functions (UDFs).\n\nThere are two types of generated columns:\n\n* PERSISTENT or STORED: This type\'s value is actually stored in the table.\n* VIRTUAL: This type\'s value is not stored at all. Instead, the value is\ngenerated dynamically when the table is queried. This type is the default.\n\nGenerated columns are also sometimes called computed columns or virtual\ncolumns.\n\nFor a complete description about generated columns and their limitations, see\nGenerated (Virtual and Persistent/Stored) Columns.\n\nCOMPRESSED\n----------\n\nMariaDB starting with 10.3.3\n----------------------------\nCertain columns may be compressed. See Storage-Engine Independent Column\nCompression.\n\nINVISIBLE\n---------\n\nMariaDB starting with 10.3.3\n----------------------------\nColumns may be made invisible, and hidden in certain contexts. See Invisible\nColumns.\n\nWITH SYSTEM VERSIONING Column Option\n------------------------------------\n\nMariaDB starting with 10.3.4\n----------------------------\nColumns may be explicitly marked as included from system versioning. See\nSystem-versioned tables for details.\n\nWITHOUT SYSTEM VERSIONING Column Option\n---------------------------------------\n\nMariaDB starting with 10.3.4\n----------------------------\nColumns may be explicitly marked as excluded from system versioning. See\nSystem-versioned tables for details.\n\nIndex Definitions\n-----------------\n\nindex_definition:\n  {INDEX|KEY} [index_name] [index_type] (index_col_name,...) [index_option]\n...\n {{{|}}} {FULLTEXT|SPATIAL} [INDEX|KEY] [index_name] (index_col_name,...)\n[index_option] ...\n {{{|}}} [CONSTRAINT [symbol]] PRIMARY KEY [index_type] (index_col_name,...)\n[index_option] ...\n {{{|}}} [CONSTRAINT [symbol]] UNIQUE [INDEX|KEY] [index_name] [index_type]\n(index_col_name,...) [index_option] ...\n {{{|}}} [CONSTRAINT [symbol]] FOREIGN KEY [index_name] (index_col_name,...)\nreference_definition\n\nindex_col_name:\n  col_name [(length)] [ASC | DESC]\n\nindex_type:\n  USING {BTREE | HASH | RTREE}\n\nindex_option:\n  [ KEY_BLOCK_SIZE [=] value\n {{{|}}} index_type\n {{{|}}} WITH PARSER parser_name\n {{{|}}} COMMENT \'string\'\n {{{|}}} CLUSTERING={YES| NO} ]\n [ IGNORED | NOT IGNORED ]\n\nreference_definition:\n  REFERENCES tbl_name (index_col_name,...)\n   [MATCH FULL | MATCH PARTIAL | MATCH SIMPLE]\n   [ON DELETE reference_option]\n   [ON UPDATE reference_option]\n\nreference_option:\n  RESTRICT | CASCADE | SET NULL | NO ACTION\n\nINDEX and KEY are synonyms.\n\nIndex names are optional, if not specified an automatic name will be assigned.\nIndex name are needed to drop indexes and appear in error messages when a\nconstraint is violated.\n\nIndex Categories\n----------------\n\nPlain Indexes\n-------------\n\nPlain indexes are regular indexes that are not unique, and are not acting as a\nprimary key or a foreign key. They are also not the \"specialized\" FULLTEXT or\nSPATIAL indexes.\n\nSee Getting Started with Indexes: Plain Indexes for more information.\n\nPRIMARY KEY\n-----------\n\nFor PRIMARY KEY indexes, you can specify a name for the index, but it is\nignored, and the name of the index is always PRIMARY. From MariaDB 10.3.18 and\nMariaDB 10.4.8, a warning is explicitly issued if a name is specified. Before\nthen, the name was silently ignored.\n\nSee Getting Started with Indexes: Primary Key for more information.\n\nUNIQUE\n------\n\nThe UNIQUE keyword means that the index will not accept duplicated values,\nexcept for NULLs. An error will raise if you try to insert duplicate values in\na UNIQUE index.\n\nFor UNIQUE indexes, you can specify a name for the constraint, using the\nCONSTRAINT keyword. That name will be used in error messages.\n\nSee Getting Started with Indexes: Unique Index for more information.\n\nFOREIGN KEY\n-----------\n\nFor FOREIGN KEY indexes, a reference definition must be provided.\n\nFor FOREIGN KEY indexes, you can specify a name for the constraint, using the\nCONSTRAINT keyword. That name will be used in error messages.\n\nFirst, you have to specify the name of the target (parent) table and a column\nor a column list which must be indexed and whose values must match to the\nforeign key\'s values. The MATCH clause is accepted to improve the\ncompatibility with other DBMS\'s, but has no meaning in MariaDB. The ON DELETE\nand ON UPDATE clauses specify what must be done when a DELETE (or a REPLACE)\nstatements attempts to delete a referenced row from the parent table, and when\nan UPDATE statement attempts to modify the referenced foreign key columns in a\nparent table row, respectively. The following options are allowed:\n\n* RESTRICT: The delete/update operation is not performed.  The statement\nterminates with a 1451 error (SQLSTATE \'2300\').\n* NO ACTION: Synonym for RESTRICT.\n* CASCADE: The delete/update operation is performed in both tables.\n* SET NULL: The update or delete goes ahead in the parent table, and the\ncorresponding foreign key fields in the child table are set to NULL.  (They\nmust not be defined as NOT NULL for this to succeed).\n* SET DEFAULT: This option is currently implemented only for the PBXT storage\nengine, which is disabled by default and no longer maintained. It sets the\nchild table\'s foreign key fields to their DEFAULT values when the referenced\nparent table key entries are updated or deleted.\n\nIf either clause is omitted, the default behavior for the omitted clause is\nRESTRICT.\n\nSee Foreign Keys for more information.\n\nFULLTEXT\n--------\n\nUse the FULLTEXT keyword to create full-text indexes.\n\nSee Full-Text Indexes for more information.\n\nSPATIAL\n-------\n\nUse the SPATIAL keyword to create geometric indexes.\n\nSee SPATIAL INDEX for more information.\n\nIndex Options\n-------------\n\nKEY_BLOCK_SIZE Index Option\n---------------------------\n\nThe KEY_BLOCK_SIZE index option is similar to the KEY_BLOCK_SIZE table option.\n\nWith the InnoDB storage engine, if you specify a non-zero value for the\nKEY_BLOCK_SIZE table option for the whole table, then the table will\nimplicitly be created with the ROW_FORMAT table option set to COMPRESSED.\nHowever, this does not happen if you just set the KEY_BLOCK_SIZE index option\nfor one or more indexes in the table. The InnoDB storage engine ignores the\nKEY_BLOCK_SIZE index option. However, the SHOW CREATE TABLE statement may\nstill report it for the index.\n\nFor information about the KEY_BLOCK_SIZE index option, see the KEY_BLOCK_SIZE\ntable option below.\n\nIndex Types\n-----------\n\nEach storage engine supports some or all index types. See Storage Engine Index\nTypes for details on permitted index types for each storage engine.\n\nDifferent index types are optimized for different kind of operations:\n\n* BTREE is the default type, and normally is the best choice. It is supported\nby all storage engines. It can be used to compare a column\'s value with a\nvalue using the =, >, >=, <, <=, BETWEEN, and LIKE operators. BTREE can also\nbe used to find NULL values. Searches against an index prefix are possible.\n* HASH is only supported by the MEMORY storage engine. HASH indexes can only\nbe used for =, <=, and >= comparisons. It can not be used for the ORDER BY\nclause. Searches against an index prefix are not possible.\n* RTREE is the default for SPATIAL indexes, but if the storage engine does not\nsupport it BTREE can be used.\n\nIndex columns names are listed between parenthesis. After each column, a\nprefix length can be specified. If no length is specified, the whole column\nwill be indexed. ASC and DESC can be specified for compatibility with are\nDBMS\'s, but have no meaning in MariaDB.\n\nWITH PARSER Index Option\n------------------------\n\nThe WITH PARSER index option only applies to FULLTEXT indexes and contains the\nfulltext parser name. The fulltext parser must be an installed plugin.\n\nCOMMENT Index Option\n--------------------\n\nA comment of up to 1024 characters is permitted with the COMMENT index option.\n\nThe COMMENT index option allows you to specify a comment with user-readable\ntext describing what the index is for. This information is not used by the\nserver itself.\n\nCLUSTERING Index Option\n-----------------------\n\nThe CLUSTERING index option is only valid for tables using the TokuDB storage\nengine.\n\nIGNORED / NOT IGNORED\n---------------------\n\nMariaDB starting with 10.6.0\n----------------------------\nFrom MariaDB 10.6.0, indexes can be specified to be ignored by the optimizer.\nSee Ignored Indexes.\n\nPeriods\n-------\n\nMariaDB starting with 10.3.4\n----------------------------\n\nperiod_definition:\n  PERIOD FOR SYSTEM_TIME (start_column_name, end_column_name)\nMariaDB supports a subset of the standard syntax for periods. At the moment\nit\'s only used for creating System-versioned tables. Both columns must be\ncreated, must be either of a TIMESTAMP(6) or BIGINT UNSIGNED type, and be\ngenerated as ROW START and ROW END accordingly. See System-versioned tables\nfor details.\n\nThe table must also have the WITH SYSTEM VERSIONING clause.\n\nConstraint Expressions\n----------------------\n\nMariaDB starting with 10.2.1\n----------------------------\nMariaDB 10.2.1 introduced new ways to define a constraint.\n\nNote: Before MariaDB 10.2.1, constraint expressions were accepted in the\nsyntax but ignored.\n\nMariaDB 10.2.1 introduced two ways to define a constraint:\n\n* CHECK(expression) given as part of a column definition.\n* CONSTRAINT [constraint_name] CHECK (expression)\n\nBefore a row is inserted or updated, all constraints are evaluated in the\norder they are defined. If any constraints fails, then the row will not be\nupdated. One can use most deterministic functions in a constraint, including\nUDFs.\n\ncreate table t1 (a int check(a>0) ,b int check (b> 0), constraint abc check\n(a>b));\n\nIf you use the second format and you don\'t give a name to the constraint, then\nthe constraint will get a auto generated name. This is done so that you can\nlater delete the constraint with ALTER TABLE DROP constraint_name.\n\nOne can disable all constraint expression checks by setting the variable\ncheck_constraint_checks to OFF. This is useful for example when loading a\ntable that violates some constraints that you want to later find and fix in\nSQL.\n\nSee CONSTRAINT for more information.\n\nTable Options\n-------------\n\nFor each individual table you create (or alter), you can set some table\noptions. The general syntax for setting options is:\n\n<OPTION_NAME> = <option_value>, [<OPTION_NAME> = <option_value> ...]\n\nThe equal sign is optional.\n\nSome options are supported by the server and can be used for all tables, no\nmatter what storage engine they use; other options can be specified for all\nstorage engines, but have a meaning only for some engines. Also, engines can\nextend CREATE TABLE with new options.\n\nIf the IGNORE_BAD_TABLE_OPTIONS SQL_MODE is enabled, wrong table options\ngenerate a warning; otherwise, they generate an error.\n\ntable_option:    \n  [STORAGE] ENGINE [=] engine_name\n | AUTO_INCREMENT [=] value\n | AVG_ROW_LENGTH [=] value\n | [DEFAULT] CHARACTER SET [=] charset_name\n | CHECKSUM [=] {0 | 1}\n | [DEFAULT] COLLATE [=] collation_name\n | COMMENT [=] \'string\'\n | CONNECTION [=] \'connect_string\'\n | DATA DIRECTORY [=] \'absolute path to directory\'\n | DELAY_KEY_WRITE [=] {0 | 1}\n | ENCRYPTED [=] {YES | NO}\n | ENCRYPTION_KEY_ID [=] value\n | IETF_QUOTES [=] {YES | NO}\n | INDEX DIRECTORY [=] \'absolute path to directory\'\n | INSERT_METHOD [=] { NO | FIRST | LAST }\n | KEY_BLOCK_SIZE [=] value\n | MAX_ROWS [=] value\n | MIN_ROWS [=] value\n | PACK_KEYS [=] {0 | 1 | DEFAULT}\n | PAGE_CHECKSUM [=] {0 | 1}\n | PAGE_COMPRESSED [=] {0 | 1}\n | PAGE_COMPRESSION_LEVEL [=] {0 .. 9}\n | PASSWORD [=] \'string\'\n | ROW_FORMAT [=] {DEFAULT|DYNAMIC|FIXED|COMPRESSED|REDUNDANT|COMPACT|PAGE}\n | SEQUENCE [=] {0|1}\n | STATS_AUTO_RECALC [=] {DEFAULT|0|1}\n | STATS_PERSISTENT [=] {DEFAULT|0|1}\n | STATS_SAMPLE_PAGES [=] {DEFAULT|value}\n | TABLESPACE tablespace_name\n | TRANSACTIONAL [=]  {0 | 1}\n | UNION [=] (tbl_name[,tbl_name]...)\n | WITH SYSTEM VERSIONING\n\n[STORAGE] ENGINE\n----------------\n\n[STORAGE] ENGINE specifies a storage engine for the table. If this option is\nnot used, the default storage engine is used instead. That is, the\ndefault_storage_engine session option value if it is set, or the value\nspecified for the --default-storage-engine mysqld startup option, or the\ndefault storage engine, InnoDB. If the specified storage engine is not\ninstalled and active, the default value will be used, unless the\nNO_ENGINE_SUBSTITUTION SQL MODE is set (default). This is only true for CREATE\nTABLE, not for ALTER TABLE. For a list of storage engines that are present in\nyour server, issue a SHOW ENGINES.\n\nAUTO_INCREMENT\n--------------\n\nAUTO_INCREMENT specifies the initial value for the AUTO_INCREMENT primary key.\nThis works for MyISAM, Aria, InnoDB, MEMORY, and ARCHIVE tables. You can\nchange this option with ALTER TABLE, but in that case the new value must be\nhigher than the highest value which is present in the AUTO_INCREMENT column.\nIf the storage engine does not support this option, you can insert (and then\ndelete) a row having the wanted value - 1 in the AUTO_INCREMENT column.\n\nAVG_ROW_LENGTH\n--------------\n\nAVG_ROW_LENGTH is the average rows size. It only applies to tables using\nMyISAM and Aria storage engines that have the ROW_FORMAT table option set to\nFIXED format.\n\nMyISAM uses MAX_ROWS and AVG_ROW_LENGTH to decide the maximum size of a table\n(default: 256TB, or the maximum file size allowed by the system).\n\n[DEFAULT] CHARACTER SET/CHARSET\n-------------------------------\n\n[DEFAULT] CHARACTER SET (or [DEFAULT] CHARSET) is used to set a default\ncharacter set for the table. This is the character set used for all columns\nwhere an explicit character set is not specified. If this option is omitted or\nDEFAULT is specified, database\'s default character set will be used. See\nSetting Character Sets and Collations for details on setting the character\nsets.\n\nCHECKSUM/TABLE_CHECKSUM\n-----------------------\n\nCHECKSUM (or TABLE_CHECKSUM) can be set to 1 to maintain a live checksum for\nall table\'s rows. This makes write operations slower, but CHECKSUM TABLE will\nbe very fast. This option is only supported for MyISAM and Aria tables.\n\n[DEFAULT] COLLATE\n-----------------\n\n[DEFAULT] COLLATE is used to set a default collation for the table. This is\nthe collation used for all columns where an explicit character set is not\nspecified. If this option is omitted or DEFAULT is specified, database\'s\ndefault option will be used. See Setting Character Sets and Collations for\ndetails on setting the collations\n\nCOMMENT\n-------\n\nCOMMENT is a comment for the table. The maximum length is 2048 characters.\nAlso used to define table parameters when creating a Spider table.\n\nCONNECTION\n----------\n\nCONNECTION is used to specify a server name or a connection string for a\nSpider, CONNECT, Federated or FederatedX table.\n\nDATA DIRECTORY/INDEX DIRECTORY\n------------------------------\n\nDATA DIRECTORY and INDEX DIRECTORY are supported for MyISAM and Aria, and DATA\nDIRECTORY is also supported by InnoDB if the innodb_file_per_table server\nsystem variable is enabled, but only in CREATE TABLE, not in ALTER TABLE. So,\ncarefully choose a path for InnoDB tables at creation time, because it cannot\nbe changed without dropping and re-creating the table. These options specify\nthe paths for data files and index files, respectively. If these options are\nomitted, the database\'s directory will be used to store data files and index\nfiles. Note that these table options do not work for partitioned tables (use\nthe partition options instead), or if the server has been invoked with the\n--skip-symbolic-links startup option. To avoid the overwriting of old files\nwith the same name that could be present in the directories, you can use the\n--keep_files_on_create option (an error will be issued if files already\nexist). These options are ignored if the NO_DIR_IN_CREATE SQL_MODE is enabled\n(useful for replication slaves). Also note that symbolic links cannot be used\nfor InnoDB tables.\n\nDATA DIRECTORY works by creating symlinks from where the table would normally\nhave been (inside the datadir) to where the option specifies. For security\nreasons, to avoid bypassing the privilege system, the server does not permit\nsymlinks inside the datadir. Therefore, DATA DIRECTORY cannot be used to\nspecify a location inside the datadir. An attempt to do so will result in an\nerror 1210 (HY000) Incorrect arguments to DATA DIRECTORY.\n\nDELAY_KEY_WRITE\n---------------\n\nDELAY_KEY_WRITE is supported by MyISAM and Aria, and can be set to 1 to speed\nup write operations. In that case, when data are modified, the indexes are not\nupdated until the table is closed. Writing the changes to the index file\naltogether can be much faster. However, note that this option is applied only\nif the delay_key_write server variable is set to \'ON\'. If it is \'OFF\' the\ndelayed index writes are always disabled, and if it is \'ALL\' the delayed index\nwrites are always used, disregarding the value of DELAY_KEY_WRITE.\n\nENCRYPTED\n---------\n\nThe ENCRYPTED table option can be used to manually set the encryption status\nof an InnoDB table. See InnoDB Encryption for more information.\n\nAria does not support the ENCRYPTED table option. See MDEV-18049.\n\nSee Data-at-Rest Encryption for more information.\n\nENCRYPTION_KEY_ID\n-----------------\n\nThe ENCRYPTION_KEY_ID table option can be used to manually set the encryption\nkey of an InnoDB table. See InnoDB Encryption for more information.\n\nAria does not support the ENCRYPTION_KEY_ID table option. See MDEV-18049.\n\nSee Data-at-Rest Encryption for more information.\n\nIETF_QUOTES\n-----------\n\nFor the CSV storage engine, the IETF_QUOTES option, when set to YES, enables\nIETF-compatible parsing of embedded quote and comma characters. Enabling this\noption for a table improves compatibility with other tools that use CSV, but\nis not compatible with MySQL CSV tables, or MariaDB CSV tables created without\nthis option. Disabled by default.\n\nINSERT_METHOD\n-------------\n\nINSERT_METHOD is only used with MERGE tables. This option determines in which\nunderlying table the new rows should be inserted. If you set it to \'NO\' (which\nis the default) no new rows can be added to the table (but you will still be\nable to perform INSERTs directly against the underlying tables). FIRST means\nthat the rows are inserted into the first table, and LAST means that thet are\ninserted into the last table.\n\nKEY_BLOCK_SIZE\n--------------\n\nKEY_BLOCK_SIZE is used to determine the size of key blocks, in bytes or\nkilobytes. However, this value is just a hint, and the storage engine could\nmodify or ignore it. If KEY_BLOCK_SIZE is set to 0, the storage engine\'s\ndefault value will be used.\n\nWith the InnoDB storage engine, if you specify a non-zero value for the\nKEY_BLOCK_SIZE table option for the whole table, then the table will\nimplicitly be created with the ROW_FORMAT table option set to COMPRESSED.\n\nMIN_ROWS/MAX_ROWS\n-----------------\n\nMIN_ROWS and MAX_ROWS let the storage engine know how many rows you are\nplanning to store as a minimum and as a maximum. These values will not be used\nas real limits, but they help the storage engine to optimize the table.\nMIN_ROWS is only used by MEMORY storage engine to decide the minimum memory\nthat is always allocated. MAX_ROWS is used to decide the minimum size for\nindexes.\n\nPACK_KEYS\n---------\n\nPACK_KEYS can be used to determine whether the indexes will be compressed. Set\nit to 1 to compress all keys. With a value of 0, compression will not be used.\nWith the DEFAULT value, only long strings will be compressed. Uncompressed\nkeys are faster.\n\nPAGE_CHECKSUM\n-------------\n\nPAGE_CHECKSUM is only applicable to Aria tables, and determines whether\nindexes and data should use page checksums for extra safety.\n\nPAGE_COMPRESSED\n---------------\n\nPAGE_COMPRESSED is used to enable InnoDB page compression for InnoDB tables.\n\nPAGE_COMPRESSION_LEVEL\n----------------------\n\nPAGE_COMPRESSION_LEVEL is used to set the compression level for InnoDB page\ncompression for InnoDB tables. The table must also have the PAGE_COMPRESSED\ntable option set to 1.\n\nValid values for PAGE_COMPRESSION_LEVEL are 1 (the best speed) through 9 (the\nbest compression), .\n\nPASSWORD\n--------\n\nPASSWORD is unused.\n\nRAID_TYPE\n---------\n\nRAID_TYPE is an obsolete option, as the raid support has been disabled since\nMySQL 5.0.\n\nROW_FORMAT\n----------\n\nThe ROW_FORMAT table option specifies the row format for the data file.\nPossible values are engine-dependent.\n\nSupported MyISAM Row Formats\n----------------------------\n\nFor MyISAM, the supported row formats are:\n\n* FIXED\n* DYNAMIC\n* COMPRESSED\n\nThe COMPRESSED row format can only be set by the myisampack command line tool.\n\nSee MyISAM Storage Formats for more information.\n\nSupported Aria Row Formats\n--------------------------\n\nFor Aria, the supported row formats are:\n\n* PAGE\n* FIXED\n* DYNAMIC.\n\nSee Aria Storage Formats for more information.\n\nSupported InnoDB Row Formats\n----------------------------\n\nFor InnoDB, the supported row formats are:\n\n* COMPACT\n* REDUNDANT\n* COMPRESSED\n* DYNAMIC.\n\nIf the ROW_FORMAT table option is set to FIXED for an InnoDB table, then the\nserver will either return an error or a warning depending on the value of the\ninnodb_strict_mode system variable. If the innodb_strict_mode system variable\nis set to OFF, then a warning is issued, and MariaDB will create the table\nusing the default row format for the specific MariaDB server version. If the\ninnodb_strict_mode system variable is set to ON, then an error will be raised.\n\nSee InnoDB Storage Formats for more information.\n\nOther Storage Engines and ROW_FORMAT\n------------------------------------\n\nOther storage engines do not support the ROW_FORMAT table option.\n\nSEQUENCE\n--------\n\nMariaDB starting with 10.3\n--------------------------\nIf the table is a sequence, then it will have the SEQUENCE set to 1.\n\nSTATS_AUTO_RECALC\n-----------------\n\nSTATS_AUTO_RECALC indicates whether to automatically recalculate persistent\nstatistics (see STATS_PERSISTENT, below) for an InnoDB table. If set to 1,\nstatistics will be recalculated when more than 10% of the data has changed.\nWhen set to 0, stats will be recalculated only when an ANALYZE TABLE is run.\nIf set to DEFAULT, or left out, the value set by the innodb_stats_auto_recalc\nsystem variable applies. See InnoDB Persistent Statistics.\n\nSTATS_PERSISTENT\n----------------\n\nSTATS_PERSISTENT indicates whether the InnoDB statistics created by ANALYZE\nTABLE will remain on disk or not. It can be set to 1 (on disk), 0 (not on\ndisk, the pre-MariaDB 10 behavior), or DEFAULT (the same as leaving out the\noption), in which case the value set by the innodb_stats_persistent system\nvariable will apply. Persistent statistics stored on disk allow the statistics\nto survive server restarts, and provide better query plan stability. See\nInnoDB Persistent Statistics.\n\nSTATS_SAMPLE_PAGES\n------------------\n\nSTATS_SAMPLE_PAGES indicates how many pages are used to sample index\nstatistics. If 0 or DEFAULT, the default value, the innodb_stats_sample_pages\nvalue is used. See InnoDB Persistent Statistics.\n\nTRANSACTIONAL\n-------------\n\nTRANSACTIONAL is only applicable for Aria tables. In future Aria tables\ncreated with this option will be fully transactional, but currently this\nprovides a form of crash protection. See Aria Storage Engine for more details.\n\nUNION\n-----\n\nUNION must be specified when you create a MERGE table. This option contains a\ncomma-separated list of MyISAM tables which are accessed by the new table. The\nlist is enclosed between parenthesis. Example: UNION = (t1,t2)\n\nWITH SYSTEM VERSIONING\n----------------------\n\nWITH SYSTEM VERSIONING is used for creating System-versioned tables.\n\nPartitions\n----------\n\npartition_options:\n  PARTITION BY\n    { [LINEAR] HASH(expr)\n    | [LINEAR] KEY(column_list)\n    | RANGE(expr)\n    | LIST(expr)\n    | SYSTEM_TIME [INTERVAL time_quantity time_unit] [LIMIT num] }\n  [PARTITIONS num]\n  [SUBPARTITION BY\n    { [LINEAR] HASH(expr)\n    | [LINEAR] KEY(column_list) }\n   [SUBPARTITIONS num]\n  ]\n  [(partition_definition [, partition_definition] ...)]\npartition_definition:\n  PARTITION partition_name\n    [VALUES {LESS THAN {(expr) | MAXVALUE} | IN (value_list)}]\n    [[STORAGE] ENGINE [=] engine_name]\n    [COMMENT [=] \'comment_text\' ]\n    [DATA DIRECTORY [=] \'data_dir\']\n    [INDEX DIRECTORY [=] \'index_dir\']\n    [MAX_ROWS [=] max_number_of_rows]\n    [MIN_ROWS [=] min_number_of_rows]\n    [TABLESPACE [=] tablespace_name]\n    [NODEGROUP [=] node_group_id]\n    [(subpartition_definition [, subpartition_definition] ...)]\nsubpartition_definition:\n  SUBPARTITION logical_name\n    [[STORAGE] ENGINE [=] engine_name]\n    [COMMENT [=] \'comment_text\' ]\n    [DATA DIRECTORY [=] \'data_dir\']\n    [INDEX DIRECTORY [=] \'index_dir\']\n    [MAX_ROWS [=] max_number_of_rows]\n    [MIN_ROWS [=] min_number_of_rows]\n    [TABLESPACE [=] tablespace_name]\n    [NODEGROUP [=] node_group_id]\nIf the PARTITION BY clause is used, the table will be partitioned. A partition\nmethod must be explicitly indicated for partitions and subpartitions.\nPartition methods are:\n\n* [LINEAR] HASH creates a hash key which will be used to read and write rows.\nThe partition function can be any valid SQL expression which returns an\nINTEGER number. Thus, it is possible to use the HASH method on an integer\ncolumn, or on functions which accept integer columns as an argument. However,\nVALUES LESS THAN and VALUES IN clauses can not be used with HASH. An example:\n\nCREATE TABLE t1 (a INT, b CHAR(5), c DATETIME)\n  PARTITION BY HASH ( YEAR(c) );\n\n[LINEAR] HASH can be used for subpartitions, too.\n\n* [LINEAR] KEY is similar to HASH, but the index has an even distribution of\ndata. Also, the expression can only be a column or a list of columns. VALUES\nLESS THAN and VALUES IN clauses can not be used with KEY.\n* RANGE partitions the rows using on a range of values, using the VALUES LESS\nTHAN operator. VALUES IN is not allowed with RANGE. The partition function can\nbe any valid SQL expression which returns a single value.\n* LIST assigns partitions based on a table\'s column with a restricted set of\npossible values. It is similar to RANGE, but VALUES IN must be used for at\nleast 1 columns, and VALUES LESS THAN is disallowed.\n* SYSTEM_TIME partitioning is used for System-versioned tables to store\nhistorical data separately from current data.\n\nOnly HASH and KEY can be used for subpartitions, and they can be [LINEAR].\n\nIt is possible to define up to 1024 partitions and subpartitions.\n\nThe number of defined partitions can be optionally specified as PARTITION\ncount. This can be done to avoid specifying all partitions individually. But\nyou can also declare each individual partition and, additionally, specify a\nPARTITIONS count clause; in the case, the number of PARTITIONs must equal\ncount.\n\nAlso see Partitioning Types Overview.\n\nSequences\n---------\n\nMariaDB starting with 10.3\n--------------------------\nCREATE TABLE can also be used to create a SEQUENCE. See CREATE SEQUENCE and\nSequence Overview.\n\nAtomic DDL\n----------\n\nMariaDB starting with 10.6.1\n----------------------------\nMariaDB 10.6.1 supports Atomic DDL. CREATE TABLE is atomic, except for CREATE\nOR REPLACE, which is only crash safe.\n\nExamples\n--------\n\ncreate table if not exists test (\na bigint auto_increment primary key,\nname varchar(128) charset utf8,\nkey name (name(32))\n) engine=InnoDB default charset latin1;\n\nThis example shows a couple of things:\n\n* Usage of IF NOT EXISTS; If the table already existed, it will not be\ncreated.  There will not be any error for the client, just a warning.\n* How to create a PRIMARY KEY that is automatically generated.\n* How to specify a table-specific character set and another for a column.\n* How to create an index (name) that is only partly indexed (to save space).\n\nThe following clauses will work from MariaDB 10.2.1 only.\n\nCREATE TABLE t1(\n a int DEFAULT (1+1),\n b int DEFAULT (a+1),\n expires DATETIME DEFAULT(NOW() + INTERVAL 1 YEAR),\n x BLOB DEFAULT USER()\n);\n\nURL: https://mariadb.com/kb/en/create-table/','','https://mariadb.com/kb/en/create-table/'),(690,'DROP TABLE',38,'Syntax\n------\n\nDROP [TEMPORARY] TABLE [IF EXISTS] [/*COMMENT TO SAVE*/]\n  tbl_name [, tbl_name] ...\n  [WAIT n|NOWAIT]\n  [RESTRICT | CASCADE]\n\nDescription\n-----------\n\nDROP TABLE removes one or more tables. You must have the DROP privilege for\neach table. All table data and the table definition are removed, as well as\ntriggers associated to the table, so be careful with this statement! If any of\nthe tables named in the argument list do not exist, MariaDB returns an error\nindicating by name which non-existing tables it was unable to drop, but it\nalso drops all of the tables in the list that do exist.\n\nImportant: When a table is dropped, user privileges on the table are not\nautomatically dropped. See GRANT.\n\nIf another thread is using the table in an explicit transaction or an\nautocommit transaction, then the thread acquires a metadata lock (MDL) on the\ntable. The DROP TABLE statement will wait in the \"Waiting for table metadata\nlock\" thread state until the MDL is released. MDLs are released in the\nfollowing cases:\n\n* If an MDL is acquired in an explicit transaction, then the MDL will be\nreleased when the transaction ends.\n* If an MDL is acquired in an autocommit transaction, then the MDL will be\nreleased when the statement ends.\n* Transactional and non-transactional tables are handled the same.\n\nNote that for a partitioned table, DROP TABLE permanently removes the table\ndefinition, all of its partitions, and all of the data which was stored in\nthose partitions. It also removes the partitioning definition (.par) file\nassociated with the dropped table.\n\nFor each referenced table, DROP TABLE drops a temporary table with that name,\nif it exists. If it does not exist, and the TEMPORARY keyword is not used, it\ndrops a non-temporary table with the same name, if it exists. The TEMPORARY\nkeyword ensures that a non-temporary table will not accidentally be dropped.\n\nUse IF EXISTS to prevent an error from occurring for tables that do not exist.\nA NOTE is generated for each non-existent table when using IF EXISTS. See SHOW\nWARNINGS.\n\nIf a foreign key references this table, the table cannot be dropped. In this\ncase, it is necessary to drop the foreign key first.\n\nRESTRICT and CASCADE are allowed to make porting from other database systems\neasier. In MariaDB, they do nothing.\n\nThe comment before the table names (/*COMMENT TO SAVE*/) is stored in the\nbinary log. That feature can be used by replication tools to send their\ninternal messages.\n\nIt is possible to specify table names as db_name.tab_name. This is useful to\ndelete tables from multiple databases with one statement. See Identifier\nQualifiers for details.\n\nThe DROP privilege is required to use DROP TABLE on non-temporary tables. For\ntemporary tables, no privilege is required, because such tables are only\nvisible for the current session.\n\nNote: DROP TABLE automatically commits the current active transaction, unless\nyou use the TEMPORARY keyword.\n\nMariaDB starting with 10.5.4\n----------------------------\nFrom MariaDB 10.5.4, DROP TABLE reliably deletes table remnants inside a\nstorage engine even if the .frm file is missing. Before then, a missing .frm\nfile would result in the statement failing.\n\nMariaDB starting with 10.3.1\n----------------------------\n\nWAIT/NOWAIT\n-----------\n\nSet the lock wait timeout. See WAIT and NOWAIT.\n\nDROP TABLE in replication\n-------------------------\n\nDROP TABLE has the following characteristics in replication:\n\n* DROP TABLE IF EXISTS are always logged.\n* DROP TABLE without IF EXISTS for tables that don\'t exist are not written to\nthe binary log.\n* Dropping of TEMPORARY tables are prefixed in the log with TEMPORARY. These\ndrops are only logged when running statement or mixed mode replication.\n* One DROP TABLE statement can be logged with up to 3 different DROP\nstatements:\nDROP TEMPORARY TABLE list_of_non_transactional_temporary_tables\nDROP TEMPORARY TABLE list_of_transactional_temporary_tables\nDROP TABLE list_of_normal_tables\n\nDROP TABLE on the primary is treated on the replica as DROP TABLE IF EXISTS.\nYou can change that by setting slave-ddl-exec-mode to STRICT.\n\nDropping an Internal #sql-... Table\n-----------------------------------\n\nFrom MariaDB 10.6, DROP TABLE is atomic and the following does not apply.\nUntil MariaDB 10.5, if the mariadbd/mysqld process is killed during an ALTER\nTABLE you may find a table named #sql-... in your data directory. In MariaDB\n10.3, InnoDB tables with this prefix will be deleted automatically during\nstartup. From MariaDB 10.4, these temporary tables will always be deleted\nautomatically.\n\nIf you want to delete one of these tables explicitly you can do so by using\nthe following syntax:\n\nDROP TABLE `#mysql50##sql-...`;\n\nWhen running an ALTER TABLE…ALGORITHM=INPLACE that rebuilds the table, InnoDB\nwill create an internal #sql-ib table. Until MariaDB 10.3.2, for these tables,\nthe .frm file will be called something else. In order to drop such a table\nafter a server crash, you must rename the #sql*.frm file to match the\n#sql-ib*.ibd file.\n\nFrom MariaDB 10.3.3, the same name as the .frm file is used for the\nintermediate copy of the table. The #sql-ib names are used by TRUNCATE and\ndelayed DROP.\n\nFrom MariaDB 10.2.19 and MariaDB 10.3.10, the #sql-ib tables will be deleted\nautomatically.\n\nDropping All Tables in a Database\n---------------------------------\n\nThe best way to drop all tables in a database is by executing DROP DATABASE,\nwhich will drop the database itself, and all tables in it.\n\nHowever, if you want to drop all tables in the database, but you also want to\nkeep the database itself and any other non-table objects in it, then you would\nneed to execute DROP TABLE to drop each individual table. You can construct\nthese DROP TABLE commands by querying the TABLES table in the\ninformation_schema database. For example:\n\nSELECT CONCAT(\'DROP TABLE IF EXISTS `\', TABLE_SCHEMA, \'`.`\', TABLE_NAME, \'`;\')\nFROM information_schema.TABLES\nWHERE TABLE_SCHEMA = \'mydb\';\n\nAtomic DROP TABLE\n-----------------\n\nMariaDB starting with 10.6.1\n----------------------------\nFrom MariaDB 10.6, DROP TABLE for a single table is atomic (MDEV-25180) for\nmost engines, including InnoDB, MyRocks, MyISAM and Aria.\n\nThis means that if there is a crash (server down or power outage) during DROP\nTABLE, all tables that have been processed so far will be completely dropped,\nincluding related trigger files and status entries, and the binary log will\ninclude a DROP TABLE statement for the dropped tables. Tables for which the\ndrop had not started will be left intact.\n\nIn older MariaDB versions, there was a small chance that, during a server\ncrash happening in the middle of DROP TABLE, some storage engines that were\nusing multiple storage files, like MyISAM, could have only a part of its\ninternal files dropped.\n\nIn MariaDB 10.5, DROP TABLE was extended to be able to delete a table that was\nonly partly dropped (MDEV-11412) as explained above. Atomic DROP TABLE is the\nfinal piece to make DROP TABLE fully reliable.\n\nDropping multiple tables is crash-safe.\n\nSee Atomic DDL for more information.\n\nExamples\n--------\n\nDROP TABLE Employees, Customers;\n\nNotes\n-----\n\nBeware that DROP TABLE can drop both tables and sequences. This is mainly done\nto allow old tools like mysqldump to work with sequences.\n\nURL: https://mariadb.com/kb/en/drop-table/','','https://mariadb.com/kb/en/drop-table/'),(691,'RENAME TABLE',38,'Syntax\n------\n\nRENAME TABLE[S] [IF EXISTS] tbl_name \n [WAIT n | NOWAIT]\n TO new_tbl_name\n  [, tbl_name2 TO new_tbl_name2] ...\n\nDescription\n-----------\n\nThis statement renames one or more tables or views, but not the privileges\nassociated with them.\n\nIF EXISTS\n---------\n\nMariaDB starting with 10.5.2\n----------------------------\nIf this directive is used, one will not get an error if the table to be\nrenamed doesn\'t exist.\n\nThe rename operation is done atomically, which means that no other session can\naccess any of the tables while the rename is running. For example, if you have\nan existing table old_table, you can create another table new_table that has\nthe same structure but is empty, and then replace the existing table with the\nempty one as follows (assuming that backup_table does not already exist):\n\nCREATE TABLE new_table (...);\nRENAME TABLE old_table TO backup_table, new_table TO old_table;\n\ntbl_name can optionally be specified as db_name.tbl_name. See Identifier\nQualifiers. This allows to use RENAME to move a table from a database to\nanother (as long as they are on the same filesystem):\n\nRENAME TABLE db1.t TO db2.t;\n\nNote that moving a table to another database is not possible if it has some\ntriggers. Trying to do so produces the following error:\n\nERROR 1435 (HY000): Trigger in wrong schema\n\nAlso, views cannot be moved to another database:\n\nERROR 1450 (HY000): Changing schema from \'old_db\' to \'new_db\' is not allowed.\n\nMultiple tables can be renamed in a single statement. The presence or absence\nof the optional S (RENAME TABLE or RENAME TABLES) has no impact, whether a\nsingle or multiple tables are being renamed.\n\nIf a RENAME TABLE renames more than one table and one renaming fails, all\nrenames executed by the same statement are rolled back.\n\nRenames are always executed in the specified order. Knowing this, it is also\npossible to swap two tables\' names:\n\nRENAME TABLE t1 TO tmp_table,\n  t2 TO t1,\n  tmp_table TO t2;\n\nWAIT/NOWAIT\n-----------\n\nMariaDB starting with 10.3.0\n----------------------------\nSet the lock wait timeout. See WAIT and NOWAIT.\n\nPrivileges\n----------\n\nExecuting the RENAME TABLE statement requires the DROP, CREATE and INSERT\nprivileges for the table or the database.\n\nAtomic RENAME TABLE\n-------------------\n\nMariaDB starting with 10.6.1\n----------------------------\nFrom MariaDB 10.6, RENAME TABLE is atomic for most engines, including InnoDB,\nMyRocks, MyISAM and Aria (MDEV-23842). This means that if there is a crash\n(server down or power outage) during RENAME TABLE, all tables will revert to\ntheir original names and any changes to trigger files will be reverted.\n\nIn older MariaDB version there was a small chance that, during a server crash\nhappening in the middle of RENAME TABLE, some tables could have been renamed\n(in the worst case partly) while others would not be renamed.\n\nSee Atomic DDL for more information.\n\nURL: https://mariadb.com/kb/en/rename-table/','','https://mariadb.com/kb/en/rename-table/'),(692,'TRUNCATE TABLE',38,'Syntax\n------\n\nTRUNCATE [TABLE] tbl_name\n [WAIT n | NOWAIT]\n\nDescription\n-----------\n\nTRUNCATE TABLE empties a table completely. It requires the DROP privilege. See\nGRANT.\n\ntbl_name can also be specified in the form db_name.tbl_name (see Identifier\nQualifiers).\n\nLogically, TRUNCATE TABLE is equivalent to a DELETE statement that deletes all\nrows, but there are practical differences under some circumstances.\n\nTRUNCATE TABLE will fail for an InnoDB table if any FOREIGN KEY constraints\nfrom other tables reference the table, returning the error:\n\nERROR 1701 (42000): Cannot truncate a table referenced in a foreign key\nconstraint\n\nForeign Key constraints between columns in the same table are permitted.\n\nFor an InnoDB table, if there are no FOREIGN KEY constraints, InnoDB performs\nfast truncation by dropping the original table and creating an empty one with\nthe same definition, which is much faster than deleting rows one by one. The\nAUTO_INCREMENT counter is reset by TRUNCATE TABLE, regardless of whether there\nis a FOREIGN KEY constraint.\n\nThe count of rows affected by TRUNCATE TABLE is accurate only when it is\nmapped to a DELETE statement.\n\nFor other storage engines, TRUNCATE TABLE differs from DELETE in the following\nways:\n\n* Truncate operations drop and re-create the table, which is much\n faster than deleting rows one by one, particularly for large tables.\n* Truncate operations cause an implicit commit.\n* Truncation operations cannot be performed if the session holds an\n active table lock.\n* Truncation operations do not return a meaningful value for the number\n of deleted rows. The usual result is \"0 rows affected,\" which should\n be interpreted as \"no information.\"\n* As long as the table format file tbl_name.frm is valid, the\n table can be re-created as an empty table\n with TRUNCATE TABLE, even if the data or index files have become\n corrupted.\n* The table handler does not remember the last\n used AUTO_INCREMENT value, but starts counting\n from the beginning. This is true even for MyISAM and InnoDB, which normally\n do not reuse sequence values.\n* When used with partitioned tables, TRUNCATE TABLE preserves\n the partitioning; that is, the data and index files are dropped and\n re-created, while the partition definitions (.par) file is\n unaffected.\n* Since truncation of a table does not make any use of DELETE,\n the TRUNCATE statement does not invoke ON DELETE triggers.\n* TRUNCATE TABLE will only reset the values in the Performance Schema summary\ntables to zero or null, and will not remove the rows.\n\nFor the purposes of binary logging and replication, TRUNCATE TABLE is treated\nas DROP TABLE followed by CREATE TABLE (DDL rather than DML).\n\nTRUNCATE TABLE does not work on views. Currently, TRUNCATE TABLE drops all\nhistorical records from a system-versioned table.\n\nMariaDB starting with 10.3.0\n----------------------------\n\nWAIT/NOWAIT\n-----------\n\nSet the lock wait timeout. See WAIT and NOWAIT.\n\nOracle-mode\n-----------\n\nOracle-mode from MariaDB 10.3 permits the optional keywords REUSE STORAGE or\nDROP STORAGE to be used.\n\nTRUNCATE [TABLE] tbl_name [{DROP | REUSE} STORAGE] [WAIT n | NOWAIT]\n\nThese have no effect on the operation.\n\nPerformance\n-----------\n\nTRUNCATE TABLE is faster than DELETE, because it drops and re-creates a table.\n\nWith InnoDB, TRUNCATE TABLE is slower if innodb_file_per_table=ON is set (the\ndefault). This is because TRUNCATE TABLE unlinks the underlying tablespace\nfile, which can be an expensive operation. See MDEV-8069 for more details.\n\nThe performance issues with innodb_file_per_table=ON can be exacerbated in\ncases where the InnoDB buffer pool is very large and\ninnodb_adaptive_hash_index=ON is set. In that case, using DROP TABLE followed\nby CREATE TABLE instead of TRUNCATE TABLE may perform better. Setting\ninnodb_adaptive_hash_index=OFF (it defaults to ON before MariaDB 10.5) can\nalso help. In MariaDB 10.2 only, from MariaDB 10.2.19, this performance can\nalso be improved by setting innodb_safe_truncate=OFF. See MDEV-9459 for more\ndetails.\n\nSetting innodb_adaptive_hash_index=OFF can also improve TRUNCATE TABLE\nperformance in general. See MDEV-16796 for more details.\n\nURL: https://mariadb.com/kb/en/truncate-table/','','https://mariadb.com/kb/en/truncate-table/'),(693,'CREATE DATABASE',38,'Syntax\n------\n\nCREATE [OR REPLACE] {DATABASE | SCHEMA} [IF NOT EXISTS] db_name\n  [create_specification] ...\n\ncreate_specification:\n  [DEFAULT] CHARACTER SET [=] charset_name\n | [DEFAULT] COLLATE [=] collation_name\n | COMMENT [=] \'comment\'\n\nDescription\n-----------\n\nCREATE DATABASE creates a database with the given name. To use this statement,\nyou need the CREATE privilege for the database. CREATE SCHEMA is a synonym for\nCREATE DATABASE.\n\nFor valid identifiers to use as database names, see Identifier Names.\n\nOR REPLACE\n----------\n\nMariaDB starting with 10.1.3\n----------------------------\nThe OR REPLACE clause was added in MariaDB 10.1.3\n\nIf the optional OR REPLACE clause is used, it acts as a shortcut for:\n\nDROP DATABASE IF EXISTS db_name;\nCREATE DATABASE db_name ...;\n\nIF NOT EXISTS\n-------------\n\nWhen the IF NOT EXISTS clause is used, MariaDB will return a warning instead\nof an error if the specified database already exists.\n\nCOMMENT\n-------\n\nMariaDB starting with 10.5.0\n----------------------------\nFrom MariaDB 10.5.0, it is possible to add a comment of a maximum of 1024\nbytes. If the comment length exceeds this length, a error/warning code 4144 is\nthrown. The database comment is also added to the db.opt file, as well as to\nthe information_schema.schemata table.\n\nExamples\n--------\n\nCREATE DATABASE db1;\nQuery OK, 1 row affected (0.18 sec)\n\nCREATE DATABASE db1;\nERROR 1007 (HY000): Can\'t create database \'db1\'; database exists\n\nCREATE OR REPLACE DATABASE db1;\nQuery OK, 2 rows affected (0.00 sec)\n\nCREATE DATABASE IF NOT EXISTS db1;\nQuery OK, 1 row affected, 1 warning (0.01 sec)\n\nSHOW WARNINGS;\n+-------+------+----------------------------------------------+\n| Level | Code | Message                                      |\n+-------+------+----------------------------------------------+\n| Note  | 1007 | Can\'t create database \'db1\'; database exists |\n+-------+------+----------------------------------------------+\n\nSetting the character sets and collation. See Setting Character Sets and\nCollations for more details.\n\nCREATE DATABASE czech_slovak_names \n CHARACTER SET = \'keybcs2\'\n COLLATE = \'keybcs2_bin\';\n\nComments, from MariaDB 10.5.0:\n\nCREATE DATABASE presentations COMMENT \'Presentations for conferences\';\n\nURL: https://mariadb.com/kb/en/create-database/','','https://mariadb.com/kb/en/create-database/'),(694,'CREATE EVENT',38,'Syntax\n------\n\nCREATE [OR REPLACE]\n  [DEFINER = { user | CURRENT_USER | role | CURRENT_ROLE }]\n  EVENT\n  [IF NOT EXISTS]\n  event_name\n  ON SCHEDULE schedule\n  [ON COMPLETION [NOT] PRESERVE]\n  [ENABLE | DISABLE | DISABLE ON SLAVE]\n  [COMMENT \'comment\']\n  DO sql_statement;\n\nschedule:\n  AT timestamp [+ INTERVAL interval] ...\n | EVERY interval\n  [STARTS timestamp [+ INTERVAL interval] ...]\n  [ENDS timestamp [+ INTERVAL interval] ...]\n\ninterval:\n  quantity {YEAR | QUARTER | MONTH | DAY | HOUR | MINUTE |\n       WEEK | SECOND | YEAR_MONTH | DAY_HOUR | DAY_MINUTE |\n       DAY_SECOND | HOUR_MINUTE | HOUR_SECOND | MINUTE_SECOND}\n\nDescription\n-----------\n\nThis statement creates and schedules a new event. It requires the EVENT\nprivilege for the schema in which the event is to be created.\n\nThe minimum requirements for a valid CREATE EVENT statement are as follows:\n\n* The keywords CREATE EVENT plus an event name, which uniquely identifies\n the event in the current schema. (Prior to MySQL 5.1.12, the event name\n needed to be unique only among events created by the same user on a given\n database.)\n* An ON SCHEDULE clause, which determines when and how often the event\n executes.\n* A DO clause, which contains the SQL statement to be executed by an\n event.\n\nHere is an example of a minimal CREATE EVENT statement:\n\nCREATE EVENT myevent\n  ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR\n  DO\n   UPDATE myschema.mytable SET mycol = mycol + 1;\n\nThe previous statement creates an event named myevent. This event executes\nonce — one hour following its creation — by running an SQL statement that\nincrements the value of the myschema.mytable table\'s mycol column by 1.\n\nThe event_name must be a valid MariaDB identifier with a maximum length of 64\ncharacters. It may be delimited using back ticks, and may be qualified with\nthe name of a database schema. An event is associated with both a MariaDB user\n(the definer) and a schema, and its name must be unique among names of events\nwithin that schema. In general, the rules governing event names are the same\nas those for names of stored routines. See Identifier Names.\n\nIf no schema is indicated as part of event_name, the default (current) schema\nis assumed.\n\nFor valid identifiers to use as event names, see Identifier Names.\n\nOR REPLACE\n----------\n\nThe OR REPLACE clause was included in MariaDB 10.1.4. If used and the event\nalready exists, instead of an error being returned, the existing event will be\ndropped and replaced by the newly defined event.\n\nIF NOT EXISTS\n-------------\n\nIf the IF NOT EXISTS clause is used, MariaDB will return a warning instead of\nan error if the event already exists. Cannot be used together with OR REPLACE.\n\nON SCHEDULE\n-----------\n\nThe ON SCHEDULE clause can be used to specify when the event must be triggered.\n\nAT\n--\n\nIf you want to execute the event only once (one time event), you can use the\nAT keyword, followed by a timestamp. If you use CURRENT_TIMESTAMP, the event\nacts as soon as it is created. As a convenience, you can add one or more\nintervals to that timestamp. You can also specify a timestamp in the past, so\nthat the event is stored but not triggered, until you modify it via ALTER\nEVENT.\n\nThe following example shows how to create an event that will be triggered\ntomorrow at a certain time:\n\nCREATE EVENT example\nON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY + INTERVAL 3 HOUR\nDO something;\n\nYou can also specify that an event must be triggered at a regular interval\n(recurring event). In such cases, use the EVERY clause followed by the\ninterval.\n\nIf an event is recurring, you can specify when the first execution must happen\nvia the STARTS clause and a maximum time for the last execution via the ENDS\nclause. STARTS and ENDS clauses are followed by a timestamp and, optionally,\none or more intervals. The ENDS clause can specify a timestamp in the past, so\nthat the event is stored but not executed until you modify it via ALTER EVENT.\n\nIn the following example, next month a recurring event will be triggered\nhourly for a week:\n\nCREATE EVENT example\nON SCHEDULE EVERY 1 HOUR\nSTARTS CURRENT_TIMESTAMP + INTERVAL 1 MONTH\nENDS CURRENT_TIMESTAMP + INTERVAL 1 MONTH + INTERVAL 1 WEEK\nDO some_task;\n\nIntervals consist of a quantity and a time unit. The time units are the same\nused for other staments and time functions, except that you can\'t use\nmicroseconds for events. For simple time units, like HOUR or MINUTE, the\nquantity is an integer number, for example \'10 MINUTE\'. For composite time\nunits, like HOUR_MINUTE or HOUR_SECOND, the quantity must be a string with all\ninvolved simple values and their separators, for example \'2:30\' or \'2:30:30\'.\n\nON COMPLETION [NOT] PRESERVE\n----------------------------\n\nThe ON COMPLETION clause can be used to specify if the event must be deleted\nafter its last execution (that is, after its AT or ENDS timestamp is past). By\ndefault, events are dropped when they are expired. To explicitly state that\nthis is the desired behaviour, you can use ON COMPLETION NOT PRESERVE.\nInstead, if you want the event to be preserved, you can use ON COMPLETION\nPRESERVE.\n\nIn you specify ON COMPLETION NOT PRESERVE, and you specify a timestamp in the\npast for AT or ENDS clause, the event will be immediatly dropped. In such\ncases, you will get a Note 1558: \"Event execution time is in the past and ON\nCOMPLETION NOT PRESERVE is set. The event was dropped immediately after\ncreation\".\n\nENABLE/DISABLE/DISABLE ON SLAVE\n-------------------------------\n\nEvents are ENABLEd by default. If you want to stop MariaDB from executing an\nevent, you may specify DISABLE. When it is ready to be activated, you may\nenable it using ALTER EVENT. Another option is DISABLE ON SLAVE, which\nindicates that an event was created on a master and has been replicated to the\nslave, which is prevented from executing the event. If DISABLE ON SLAVE is\nspecifically set, the event will be disabled everywhere. It will not be\nexecuted on the mater or the slaves.\n\nCOMMENT\n-------\n\nThe COMMENT clause may be used to set a comment for the event. Maximum length\nfor comments is 64 characters. The comment is a string, so it must be quoted.\nTo see events comments, you can query the INFORMATION_SCHEMA.EVENTS table (the\ncolumn is named EVENT_COMMENT).\n\nExamples\n--------\n\nMinimal CREATE EVENT statement:\n\nCREATE EVENT myevent\n  ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR\n  DO\n   UPDATE myschema.mytable SET mycol = mycol + 1;\n\nAn event that will be triggered tomorrow at a certain time:\n\nCREATE EVENT example\nON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY + INTERVAL 3 HOUR\nDO something;\n\nNext month a recurring event will be triggered hourly for a week:\n\nCREATE EVENT example\nON SCHEDULE EVERY 1 HOUR\nSTARTS CURRENT_TIMESTAMP + INTERVAL 1 MONTH\nENDS CURRENT_TIMESTAMP + INTERVAL 1 MONTH + INTERVAL 1 WEEK\nDO some_task;\n\nOR REPLACE and IF NOT EXISTS:\n\nCREATE EVENT myevent\n  ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR\n  DO\n   UPDATE myschema.mytable SET mycol = mycol + 1;\nERROR 1537 (HY000): Event \'myevent\' already exists\n\nCREATE OR REPLACE EVENT myevent\n  ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR\n  DO\n   UPDATE myschema.mytable SET mycol = mycol + 1;;\nQuery OK, 0 rows affected (0.00 sec)\n\nCREATE EVENT IF NOT EXISTS myevent\n  ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR\n  DO\n   UPDATE myschema.mytable SET mycol = mycol + 1;\nQuery OK, 0 rows affected, 1 warning (0.00 sec)\n\nSHOW WARNINGS;\n+-------+------+--------------------------------+\n| Level | Code | Message                        |\n+-------+------+--------------------------------+\n| Note  | 1537 | Event \'myevent\' already exists |\n+-------+------+--------------------------------+\n\nURL: https://mariadb.com/kb/en/create-event/','','https://mariadb.com/kb/en/create-event/'),(695,'CREATE FUNCTION',38,'Syntax\n------\n\nCREATE [OR REPLACE]\n  [DEFINER = {user | CURRENT_USER | role | CURRENT_ROLE }]\n  [AGGREGATE] FUNCTION [IF NOT EXISTS] func_name ([func_parameter[,...]])\n  RETURNS type\n  [characteristic ...]\n  RETURN func_body\nfunc_parameter:\n  [ IN | OUT | INOUT | IN OUT ]  param_name type\ntype:\n  Any valid MariaDB data type\ncharacteristic:\n  LANGUAGE SQL\n | [NOT] DETERMINISTIC\n | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }\n | SQL SECURITY { DEFINER | INVOKER }\n | COMMENT \'string\'\nfunc_body:\n  Valid SQL procedure statement\n\nDescription\n-----------\n\nUse the CREATE FUNCTION statement to create a new stored function. You must\nhave the CREATE ROUTINE database privilege to use CREATE FUNCTION. A function\ntakes any number of arguments and returns a value from the function body. The\nfunction body can be any valid SQL expression as you would use, for example,\nin any select expression. If you have the appropriate privileges, you can call\nthe function exactly as you would any built-in function. See Security below\nfor details on privileges.\n\nYou can also use a variant of the CREATE FUNCTION statement to install a\nuser-defined function (UDF) defined by a plugin. See CREATE FUNCTION (UDF) for\ndetails.\n\nYou can use a SELECT statement for the function body by enclosing it in\nparentheses, exactly as you would to use a subselect for any other expression.\nThe SELECT statement must return a single value. If more than one column is\nreturned when the function is called, error 1241 results. If more than one row\nis returned when the function is called, error 1242 results. Use a LIMIT\nclause to ensure only one row is returned.\n\nYou can also replace the RETURN clause with a BEGIN...END compound statement.\nThe compound statement must contain a RETURN statement. When the function is\ncalled, the RETURN statement immediately returns its result, and any\nstatements after RETURN are effectively ignored.\n\nBy default, a function is associated with the current database. To associate\nthe function explicitly with a given database, specify the fully-qualified\nname as db_name.func_name when you create it. If the function name is the same\nas the name of a built-in function, you must use the fully qualified name when\nyou call it.\n\nThe parameter list enclosed within parentheses must always be present. If\nthere are no parameters, an empty parameter list of () should be used.\nParameter names are not case sensitive.\n\nEach parameter can be declared to use any valid data type, except that the\nCOLLATE attribute cannot be used.\n\nFor valid identifiers to use as function names, see Identifier Names.\n\nIN | OUT | INOUT | IN OUT\n-------------------------\n\nMariaDB starting with 10.8.0\n----------------------------\nThe function parameter qualifiers for IN, OUT, INOUT, and IN OUT were added in\na 10.8.0 preview release. Prior to 10.8.0 quantifiers were supported only in\nprocedures.\n\nOUT, INOUT and its equivalent IN OUT, are only valid if called from SET and\nnot SELECT. These quantifiers are especially useful for creating functions\nwith more than one return value. This allows functions to be more complex and\nnested.\n\nDELIMITER $$\nCREATE FUNCTION add_func3(IN a INT, IN b INT, OUT c INT) RETURNS INT\nBEGIN\n SET c = 100;\n RETURN a + b;\nEND;\n$$\nDELIMITER ;\n\nSET @a = 2;\nSET @b = 3;\nSET @c = 0;\nSET @res= add_func3(@a, @b, @c);\n\nSELECT add_func3(@a, @b, @c);\nERROR 4186 (HY000): OUT or INOUT argument 3 for function add_func3 is not\nallowed here\n\nDELIMITER $$\nCREATE FUNCTION add_func4(IN a INT, IN b INT, d INT) RETURNS INT\nBEGIN\n DECLARE c, res INT;\n SET res = add_func3(a, b, c) + d;\n if (c > 99) then\n  return  3;\n else\n  return res;\n end if;\nEND;\n$$\n\nDELIMITER ;\n\nSELECT add_func4(1,2,3);\n+------------------+\n| add_func4(1,2,3) |\n+------------------+\n|                3 |\n+------------------+\n\nAGGREGATE\n---------\n\nMariaDB starting with 10.3.3\n----------------------------\nFrom MariaDB 10.3.3, it is possible to create stored aggregate functions as\nwell. See Stored Aggregate Functions for details.\n\nRETURNS\n-------\n\nThe RETURNS clause specifies the return type of the function. NULL values are\npermitted with all return types.\n\nWhat happens if the RETURN clause returns a value of a different type? It\ndepends on the SQL_MODE in effect at the moment of the function creation.\n\nIf the SQL_MODE is strict (STRICT_ALL_TABLES or STRICT_TRANS_TABLES flags are\nspecified), a 1366 error will be produced.\n\nOtherwise, the value is coerced to the proper type. For example, if a function\nspecifies an ENUM or SET value in the RETURNS clause, but the RETURN clause\nreturns an integer, the value returned from the function is the string for the\ncorresponding ENUM member of set of SET members.\n\nMariaDB stores the SQL_MODE system variable setting that is in effect at the\ntime a routine is created, and always executes the routine with this setting\nin force, regardless of the server SQL mode in effect when the routine is\ninvoked.\n\nLANGUAGE SQL\n------------\n\nLANGUAGE SQL is a standard SQL clause, and it can be used in MariaDB for\nportability. However that clause has no meaning, because SQL is the only\nsupported language for stored functions.\n\nA function is deterministic if it can produce only one result for a given list\nof parameters. If the result may be affected by stored data, server variables,\nrandom numbers or any value that is not explicitly passed, then the function\nis not deterministic. Also, a function is non-deterministic if it uses\nnon-deterministic functions like NOW() or CURRENT_TIMESTAMP(). The optimizer\nmay choose a faster execution plan if it known that the function is\ndeterministic. In such cases, you should declare the routine using the\nDETERMINISTIC keyword. If you want to explicitly state that the function is\nnot deterministic (which is the default) you can use the NOT DETERMINISTIC\nkeywords.\n\nIf you declare a non-deterministic function as DETERMINISTIC, you may get\nincorrect results. If you declare a deterministic function as NOT\nDETERMINISTIC, in some cases the queries will be slower.\n\nOR REPLACE\n----------\n\nMariaDB starting with 10.1.3\n----------------------------\nIf the optional OR REPLACE clause is used, it acts as a shortcut for:\n\nDROP FUNCTION IF EXISTS function_name;\nCREATE FUNCTION function_name ...;\n\nwith the exception that any existing privileges for the function are not\ndropped.\n\nIF NOT EXISTS\n-------------\n\nMariaDB starting with 10.1.3\n----------------------------\nIf the IF NOT EXISTS clause is used, MariaDB will return a warning instead of\nan error if the function already exists. Cannot be used together with OR\nREPLACE.\n\n[NOT] DETERMINISTIC\n-------------------\n\nThe [NOT] DETERMINISTIC clause also affects binary logging, because the\nSTATEMENT format can not be used to store or replicate non-deterministic\nstatements.\n\nCONTAINS SQL, NO SQL, READS SQL DATA, and MODIFIES SQL DATA are informative\nclauses that tell the server what the function does. MariaDB does not check in\nany way whether the specified clause is correct. If none of these clauses are\nspecified, CONTAINS SQL is used by default.\n\nMODIFIES SQL DATA\n-----------------\n\nMODIFIES SQL DATA means that the function contains statements that may modify\ndata stored in databases. This happens if the function contains statements\nlike DELETE, UPDATE, INSERT, REPLACE or DDL.\n\nREADS SQL DATA\n--------------\n\nREADS SQL DATA means that the function reads data stored in databases, but\ndoes not modify any data. This happens if SELECT statements are used, but\nthere no write operations are executed.\n\nCONTAINS SQL\n------------\n\nCONTAINS SQL means that the function contains at least one SQL statement, but\nit does not read or write any data stored in a database. Examples include SET\nor DO.\n\nNO SQL\n------\n\nNO SQL means nothing, because MariaDB does not currently support any language\nother than SQL.\n\nOracle Mode\n-----------\n\nMariaDB starting with 10.3\n--------------------------\nFrom MariaDB 10.3, a subset of Oracle\'s PL/SQL language has been supported in\naddition to the traditional SQL/PSM-based MariaDB syntax. See Oracle mode from\nMariaDB 10.3 for details on changes when running Oracle mode.\n\nSecurity\n--------\n\nYou must have the EXECUTE privilege on a function to call it. MariaDB\nautomatically grants the EXECUTE and ALTER ROUTINE privileges to the account\nthat called CREATE FUNCTION, even if the DEFINER clause was used.\n\nEach function has an account associated as the definer. By default, the\ndefiner is the account that created the function. Use the DEFINER clause to\nspecify a different account as the definer. You must have the SUPER privilege,\nor, from MariaDB 10.5.2, the SET USER privilege, to use the DEFINER clause.\nSee Account Names for details on specifying accounts.\n\nThe SQL SECURITY clause specifies what privileges are used when a function is\ncalled. If SQL SECURITY is INVOKER, the function body will be evaluated using\nthe privileges of the user calling the function. If SQL SECURITY is DEFINER,\nthe function body is always evaluated using the privileges of the definer\naccount. DEFINER is the default.\n\nThis allows you to create functions that grant limited access to certain data.\nFor example, say you have a table that stores some employee information, and\nthat you\'ve granted SELECT privileges only on certain columns to the user\naccount roger.\n\nCREATE TABLE employees (name TINYTEXT, dept TINYTEXT, salary INT);\nGRANT SELECT (name, dept) ON employees TO roger;\n\nTo allow the user the get the maximum salary for a department, define a\nfunction and grant the EXECUTE privilege:\n\nCREATE FUNCTION max_salary (dept TINYTEXT) RETURNS INT RETURN\n (SELECT MAX(salary) FROM employees WHERE employees.dept = dept);\nGRANT EXECUTE ON FUNCTION max_salary TO roger;\n\nSince SQL SECURITY defaults to DEFINER, whenever the user roger calls this\nfunction, the subselect will execute with your privileges. As long as you have\nprivileges to select the salary of each employee, the caller of the function\nwill be able to get the maximum salary for each department without being able\nto see individual salaries.\n\nCharacter sets and collations\n-----------------------------\n\nFunction return types can be declared to use any valid character set and\ncollation. If used, the COLLATE attribute needs to be preceded by a CHARACTER\nSET attribute.\n\nIf the character set and collation are not specifically set in the statement,\nthe database defaults at the time of creation will be used. If the database\ndefaults change at a later stage, the stored function character set/collation\nwill not be changed at the same time; the stored function needs to be dropped\nand recreated to ensure the same character set/collation as the database is\nused.\n\nExamples\n--------\n\nThe following example function takes a parameter, performs an operation using\nan SQL function, and returns the result.\n\nCREATE FUNCTION hello (s CHAR(20))\n  RETURNS CHAR(50) DETERMINISTIC\n  RETURN CONCAT(\'Hello, \',s,\'!\');\n\nSELECT hello(\'world\');\n+----------------+\n| hello(\'world\') |\n+----------------+\n| Hello, world!  |\n+----------------+\n\nYou can use a compound statement in a function to manipulate data with\nstatements like INSERT and UPDATE. The following example creates a counter\nfunction that uses a temporary table to store the current value. Because the\ncompound statement contains statements terminated with semicolons, you have to\nfirst change the statement delimiter with the DELIMITER statement to allow the\nsemicolon to be used in the function body. See Delimiters in the mysql client\nfor more.\n\nCREATE TEMPORARY TABLE counter (c INT);\nINSERT INTO counter VALUES (0);\nDELIMITER //\nCREATE FUNCTION counter () RETURNS INT\n BEGIN\n  UPDATE counter SET c = c + 1;\n  RETURN (SELECT c FROM counter LIMIT 1);\n END //\nDELIMITER ;\n\nCharacter set and collation:\n\nCREATE FUNCTION hello2 (s CHAR(20))\n RETURNS CHAR(50) CHARACTER SET \'utf8\' COLLATE \'utf8_bin\' DETERMINISTIC\n RETURN CONCAT(\'Hello, \',s,\'!\');\n\nURL: https://mariadb.com/kb/en/create-function/','','https://mariadb.com/kb/en/create-function/'),(696,'CREATE INDEX',38,'Syntax\n------\n\nCREATE [OR REPLACE] [UNIQUE|FULLTEXT|SPATIAL] INDEX \n [IF NOT EXISTS] index_name\n  [index_type]\n  ON tbl_name (index_col_name,...)\n  [WAIT n | NOWAIT]\n  [index_option]\n  [algorithm_option | lock_option] ...\n\nindex_col_name:\n  col_name [(length)] [ASC | DESC]\n\nindex_type:\n  USING {BTREE | HASH | RTREE}\n\nindex_option:\n  [ KEY_BLOCK_SIZE [=] value\n | index_type\n | WITH PARSER parser_name\n | COMMENT \'string\'\n | CLUSTERING={YES| NO} ]\n [ IGNORED | NOT IGNORED ]\n\nalgorithm_option:\n  ALGORITHM [=] {DEFAULT|INPLACE|COPY|NOCOPY|INSTANT}\n\nlock_option:\n  LOCK [=] {DEFAULT|NONE|SHARED|EXCLUSIVE}\n\nDescription\n-----------\n\nCREATE INDEX is mapped to an ALTER TABLE statement to create indexes. See\nALTER TABLE. CREATE INDEX cannot be used to create a PRIMARY KEY; use ALTER\nTABLE instead.\n\nIf another connection is using the table, a metadata lock is active, and this\nstatement will wait until the lock is released. This is also true for\nnon-transactional tables.\n\nAnother shortcut, DROP INDEX, allows the removal of an index.\n\nFor valid identifiers to use as index names, see Identifier Names.\n\nNote that KEY_BLOCK_SIZE is currently ignored in CREATE INDEX, although it is\nincluded in the output of SHOW CREATE TABLE.\n\nPrivileges\n----------\n\nExecuting the CREATE INDEX statement requires the INDEX privilege for the\ntable or the database.\n\nOnline DDL\n----------\n\nOnline DDL is supported with the ALGORITHM and LOCK clauses.\n\nSee InnoDB Online DDL Overview for more information on online DDL with InnoDB.\n\nCREATE OR REPLACE INDEX\n-----------------------\n\nIf the OR REPLACE clause is used and if the index already exists, then instead\nof returning an error, the server will drop the existing index and replace it\nwith the newly defined index.\n\nCREATE INDEX IF NOT EXISTS\n--------------------------\n\nIf the IF NOT EXISTS clause is used, then the index will only be created if an\nindex with the same name does not already exist. If the index already exists,\nthen a warning will be triggered by default.\n\nIndex Definitions\n-----------------\n\nSee CREATE TABLE: Index Definitions for information about index definitions.\n\nWAIT/NOWAIT\n-----------\n\nSet the lock wait timeout. See WAIT and NOWAIT.\n\nALGORITHM\n---------\n\nSee ALTER TABLE: ALGORITHM for more information.\n\nLOCK\n----\n\nSee ALTER TABLE: LOCK for more information.\n\nProgress Reporting\n------------------\n\nMariaDB provides progress reporting for CREATE INDEX statement for clients\nthat support the new progress reporting protocol. For example, if you were\nusing the mysql client, then the progress report might look like this::\n\nCREATE INDEX i ON tab (num);\nStage: 1 of 2 \'copy to tmp table\'    46% of stage\n\nThe progress report is also shown in the output of the SHOW PROCESSLIST\nstatement and in the contents of the information_schema.PROCESSLIST table.\n\nSee Progress Reporting for more information.\n\nWITHOUT OVERLAPS\n----------------\n\nMariaDB starting with 10.5.3\n----------------------------\nThe WITHOUT OVERLAPS clause allows one to constrain a primary or unique index\nsuch that application-time periods cannot overlap.\n\nExamples\n--------\n\nCreating a unique index:\n\nCREATE UNIQUE INDEX HomePhone ON Employees(Home_Phone);\n\nOR REPLACE and IF NOT EXISTS:\n\nCREATE INDEX xi ON xx5 (x);\nQuery OK, 0 rows affected (0.03 sec)\n\nCREATE INDEX xi ON xx5 (x);\nERROR 1061 (42000): Duplicate key name \'xi\'\n\nCREATE OR REPLACE INDEX xi ON xx5 (x);\nQuery OK, 0 rows affected (0.03 sec)\n\nCREATE INDEX IF NOT EXISTS xi ON xx5 (x);\nQuery OK, 0 rows affected, 1 warning (0.00 sec)\n\nSHOW WARNINGS;\n+-------+------+-------------------------+\n| Level | Code | Message                 |\n+-------+------+-------------------------+\n| Note  | 1061 | Duplicate key name \'xi\' |\n+-------+------+-------------------------+\n\nFrom MariaDB 10.5.3, creating a unique index for an application-time period\ntable with a WITHOUT OVERLAPS constraint:\n\nCREATE UNIQUE INDEX u ON rooms (room_number, p WITHOUT OVERLAPS);\n\nURL: https://mariadb.com/kb/en/create-index/','','https://mariadb.com/kb/en/create-index/'),(697,'CREATE PACKAGE',38,'MariaDB starting with 10.3.5\n----------------------------\nOracle-style packages were introduced in MariaDB 10.3.5.\n\nSyntax\n------\n\nCREATE\n  [ OR REPLACE]\n  [DEFINER = { user | CURRENT_USER | role | CURRENT_ROLE }]\n  PACKAGE [ IF NOT EXISTS ]\n  [ db_name . ] package_name\n  [ package_characteristic ... ]\n{ AS | IS }\n  [ package_specification_element ... ]\nEND [ package_name ]\n\npackage_characteristic:\n  COMMENT \'string\'\n | SQL SECURITY { DEFINER | INVOKER }\n\npackage_specification_element:\n  FUNCTION_SYM package_specification_function ;\n | PROCEDURE_SYM package_specification_procedure ;\n\npackage_specification_function:\n  func_name [ ( func_param [, func_param]... ) ]\n  RETURNS func_return_type\n  [ package_routine_characteristic... ]\n\npackage_specification_procedure:\n  proc_name [ ( proc_param [, proc_param]... ) ]\n  [ package_routine_characteristic... ]\n\nfunc_return_type:\n  type\n\nfunc_param:\n  param_name [ IN | OUT | INOUT | IN OUT ] type\n\nproc_param:\n  param_name [ IN | OUT | INOUT | IN OUT ] type\n\ntype:\n  Any valid MariaDB explicit or anchored data type\n\npackage_routine_characteristic:\n   COMMENT  \'string\'\n  | LANGUAGE SQL\n  | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }\n  | SQL SECURITY { DEFINER | INVOKER }\n\nDescription\n-----------\n\nThe CREATE PACKAGE statement can be used when Oracle SQL_MODE is set.\n\nThe CREATE PACKAGE creates the specification for a stored package (a\ncollection of logically related stored objects). A stored package\nspecification declares public routines (procedures and functions) of the\npackage, but does not implement these routines.\n\nA package whose specification was created by the CREATE PACKAGE statement,\nshould later be implemented using the CREATE PACKAGE BODY statement.\n\nFunction parameter quantifiers IN | OUT | INOUT | IN OUT\n--------------------------------------------------------\n\nMariaDB starting with 10.8.0\n----------------------------\nThe function parameter quantifiers for IN, OUT, INOUT, and IN OUT where added\nin a 10.8.0 preview release. Prior to 10.8.0 quantifiers were supported only\nin procedures.\n\nOUT, INOUT and its equivalent IN OUT, are only valid if called from SET and\nnot SELECT. These quantifiers are especially useful for creating functions and\nprocedures with more than one return value. This allows functions and\nprocedures to be more complex and nested.\n\nExamples\n--------\n\nSET sql_mode=ORACLE;\nDELIMITER $$\nCREATE OR REPLACE PACKAGE employee_tools AS\n FUNCTION getSalary(eid INT) RETURN DECIMAL(10,2);\n PROCEDURE raiseSalary(eid INT, amount DECIMAL(10,2));\n PROCEDURE raiseSalaryStd(eid INT);\n PROCEDURE hire(ename TEXT, esalary DECIMAL(10,2));\nEND;\n$$\nDELIMITER ;\n\nURL: https://mariadb.com/kb/en/create-package/','','https://mariadb.com/kb/en/create-package/'),(698,'CREATE PACKAGE BODY',38,'MariaDB starting with 10.3.5\n----------------------------\nOracle-style packages were introduced in MariaDB 10.3.5.\n\nSyntax\n------\n\nCREATE [ OR REPLACE ]\n  [DEFINER = { user | CURRENT_USER | role | CURRENT_ROLE }]\n  PACKAGE BODY\n  [ IF NOT EXISTS ]\n  [ db_name . ] package_name\n  [ package_characteristic... ]\n{ AS | IS }\n  package_implementation_declare_section\n  package_implementation_executable_section\nEND [ package_name]\n\npackage_implementation_declare_section:\n  package_implementation_item_declaration\n   [ package_implementation_item_declaration... ]\n   [ package_implementation_routine_definition... ]\n | package_implementation_routine_definition\n   [ package_implementation_routine_definition...]\n\npackage_implementation_item_declaration:\n  variable_declaration ;\n\nvariable_declaration:\n  variable_name[,...] type [:= expr ]\n\npackage_implementation_routine_definition:\n  FUNCTION package_specification_function\n   [ package_implementation_function_body ] ;\n | PROCEDURE package_specification_procedure\n   [ package_implementation_procedure_body ] ;\n\npackage_implementation_function_body:\n  { AS | IS } package_routine_body [func_name]\n\npackage_implementation_procedure_body:\n  { AS | IS } package_routine_body [proc_name]\n\npackage_routine_body:\n  [ package_routine_declarations ]\n  BEGIN\n   statements [ EXCEPTION exception_handlers ]\n  END\n\npackage_routine_declarations:\n  package_routine_declaration \';\' [package_routine_declaration \';\']...\n\npackage_routine_declaration:\n     variable_declaration\n    | condition_name CONDITION FOR condition_value\n    | user_exception_name EXCEPTION\n    | CURSOR_SYM cursor_name\n     [ ( cursor_formal_parameters ) ]\n     IS select_statement\n    ;\n\npackage_implementation_executable_section:\n     END\n    | BEGIN\n      statement ; [statement ; ]...\n     [EXCEPTION exception_handlers]\n     END\n\nexception_handlers:\n     exception_handler [exception_handler...]\n\nexception_handler:\n     WHEN_SYM condition_value [, condition_value]...\n      THEN_SYM statement ; [statement ;]...\n\ncondition_value:\n     condition_name\n    | user_exception_name\n    | SQLWARNING\n    | SQLEXCEPTION\n    | NOT FOUND\n    | OTHERS_SYM\n    | SQLSTATE [VALUE] sqlstate_value\n    | mariadb_error_code\n\nDescription\n-----------\n\nThe CREATE PACKAGE BODY statement can be used when Oracle SQL_MODE is set.\n\nThe CREATE PACKAGE BODY statement creates the package body for a stored\npackage. The package specification must be previously created using the CREATE\nPACKAGE statement.\n\nA package body provides implementations of the package public routines and can\noptionally have:\n\n* package-wide private variables\n* package private routines\n* forward declarations for private routines\n* an executable initialization section\n\nExamples\n--------\n\nSET sql_mode=ORACLE;\nDELIMITER $$\nCREATE OR REPLACE PACKAGE employee_tools AS\n FUNCTION getSalary(eid INT) RETURN DECIMAL(10,2);\n PROCEDURE raiseSalary(eid INT, amount DECIMAL(10,2));\n PROCEDURE raiseSalaryStd(eid INT);\n PROCEDURE hire(ename TEXT, esalary DECIMAL(10,2));\nEND;\n$$\nCREATE PACKAGE BODY employee_tools AS\n -- package body variables\n stdRaiseAmount DECIMAL(10,2):=500;\n\n-- private routines\n PROCEDURE log (eid INT, ecmnt TEXT) AS\n BEGIN\n  INSERT INTO employee_log (id, cmnt) VALUES (eid, ecmnt);\n END;\n\n-- public routines\n PROCEDURE hire(ename TEXT, esalary DECIMAL(10,2)) AS\n  eid INT;\n BEGIN\n  INSERT INTO employee (name, salary) VALUES (ename, esalary);\n  eid:= last_insert_id();\n  log(eid, \'hire \' || ename);\n END;\n\nFUNCTION getSalary(eid INT) RETURN DECIMAL(10,2) AS\n  nSalary DECIMAL(10,2);\n BEGIN\n  SELECT salary INTO nSalary FROM employee WHERE id=eid;\n  log(eid, \'getSalary id=\' || eid || \' salary=\' || nSalary);\n  RETURN nSalary;\n END;\n\nPROCEDURE raiseSalary(eid INT, amount DECIMAL(10,2)) AS\n BEGIN\n  UPDATE employee SET salary=salary+amount WHERE id=eid;\n  log(eid, \'raiseSalary id=\' || eid || \' amount=\' || amount);\n END;\n\nPROCEDURE raiseSalaryStd(eid INT) AS\n BEGIN\n  raiseSalary(eid, stdRaiseAmount);\n  log(eid, \'raiseSalaryStd id=\' || eid);\n END;\n\nBEGIN\n -- This code is executed when the current session\n -- accesses any of the package routines for the first time\n log(0, \'Session \' || connection_id() || \' \' || current_user || \' started\');\nEND;\n$$\n\nDELIMITER ;\n\nURL: https://mariadb.com/kb/en/create-package-body/','','https://mariadb.com/kb/en/create-package-body/'),(699,'CREATE PROCEDURE',38,'Syntax\n------\n\nCREATE\n  [OR REPLACE]\n  [DEFINER = { user | CURRENT_USER | role | CURRENT_ROLE }]\n  PROCEDURE [IF NOT EXISTS] sp_name ([proc_parameter[,...]])\n  [characteristic ...] routine_body\n\nproc_parameter:\n  [ IN | OUT | INOUT ] param_name type\n\ntype:\n  Any valid MariaDB data type\n\ncharacteristic:\n  LANGUAGE SQL\n | [NOT] DETERMINISTIC\n | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }\n | SQL SECURITY { DEFINER | INVOKER }\n | COMMENT \'string\'\n\nroutine_body:\n  Valid SQL procedure statement\n\nDescription\n-----------\n\nCreates a stored procedure. By default, a routine is associated with the\ndefault database. To associate the routine explicitly with a given database,\nspecify the name as db_name.sp_name when you create it.\n\nWhen the routine is invoked, an implicit USE db_name is performed (and undone\nwhen the routine terminates). The causes the routine to have the given default\ndatabase while it executes. USE statements within stored routines are\ndisallowed.\n\nWhen a stored procedure has been created, you invoke it by using the CALL\nstatement (see CALL).\n\nTo execute the CREATE PROCEDURE statement, it is necessary to have the CREATE\nROUTINE privilege. By default, MariaDB automatically grants the ALTER ROUTINE\nand EXECUTE privileges to the routine creator. See also Stored Routine\nPrivileges.\n\nThe DEFINER and SQL SECURITY clauses specify the security context to be used\nwhen checking access privileges at routine execution time, as described here.\nRequires the SUPER privilege, or, from MariaDB 10.5.2, the SET USER privilege.\n\nIf the routine name is the same as the name of a built-in SQL function, you\nmust use a space between the name and the following parenthesis when defining\nthe routine, or a syntax error occurs. This is also true when you invoke the\nroutine later. For this reason, we suggest that it is better to avoid re-using\nthe names of existing SQL functions for your own stored routines.\n\nThe IGNORE_SPACE SQL mode applies to built-in functions, not to stored\nroutines. It is always allowable to have spaces after a routine name,\nregardless of whether IGNORE_SPACE is enabled.\n\nThe parameter list enclosed within parentheses must always be present. If\nthere are no parameters, an empty parameter list of () should be used.\nParameter names are not case sensitive.\n\nEach parameter can be declared to use any valid data type, except that the\nCOLLATE attribute cannot be used.\n\nFor valid identifiers to use as procedure names, see Identifier Names.\n\nThings to be Aware of With CREATE OR REPLACE\n--------------------------------------------\n\n* One can\'t use OR REPLACE together with IF EXISTS.\n\nCREATE PROCEDURE IF NOT EXISTS\n------------------------------\n\nIf the IF NOT EXISTS clause is used, then the procedure will only be created\nif a procedure with the same name does not already exist. If the procedure\nalready exists, then a warning will be triggered by default.\n\nIN/OUT/INOUT\n------------\n\nEach parameter is an IN parameter by default. To specify otherwise for a\nparameter, use the keyword OUT or INOUT before the parameter name.\n\nAn IN parameter passes a value into a procedure. The procedure might modify\nthe value, but the modification is not visible to the caller when the\nprocedure returns. An OUT parameter passes a value from the procedure back to\nthe caller. Its initial value is NULL within the procedure, and its value is\nvisible to the caller when the procedure returns. An INOUT parameter is\ninitialized by the caller, can be modified by the procedure, and any change\nmade by the procedure is visible to the caller when the procedure returns.\n\nFor each OUT or INOUT parameter, pass a user-defined variable in the CALL\nstatement that invokes the procedure so that you can obtain its value when the\nprocedure returns. If you are calling the procedure from within another stored\nprocedure or function, you can also pass a routine parameter or local routine\nvariable as an IN or INOUT parameter.\n\nDETERMINISTIC/NOT DETERMINISTIC\n-------------------------------\n\nDETERMINISTIC and NOT DETERMINISTIC apply only to functions. Specifying\nDETERMINISTC or NON-DETERMINISTIC in procedures has no effect. The default\nvalue is NOT DETERMINISTIC. Functions are DETERMINISTIC when they always\nreturn the same value for the same input. For example, a truncate or substring\nfunction. Any function involving data, therefore, is always NOT DETERMINISTIC.\n\nCONTAINS SQL/NO SQL/READS SQL DATA/MODIFIES SQL DATA\n----------------------------------------------------\n\nCONTAINS SQL, NO SQL, READS SQL DATA, and MODIFIES SQL DATA are informative\nclauses that tell the server what the function does. MariaDB does not check in\nany way whether the specified clause is correct. If none of these clauses are\nspecified, CONTAINS SQL is used by default.\n\nMODIFIES SQL DATA means that the function contains statements that may modify\ndata stored in databases. This happens if the function contains statements\nlike DELETE, UPDATE, INSERT, REPLACE or DDL.\n\nREADS SQL DATA means that the function reads data stored in databases, but\ndoes not modify any data. This happens if SELECT statements are used, but\nthere no write operations are executed.\n\nCONTAINS SQL means that the function contains at least one SQL statement, but\nit does not read or write any data stored in a database. Examples include SET\nor DO.\n\nNO SQL means nothing, because MariaDB does not currently support any language\nother than SQL.\n\nThe routine_body consists of a valid SQL procedure statement. This can be a\nsimple statement such as SELECT or INSERT, or it can be a compound statement\nwritten using BEGIN and END. Compound statements can contain declarations,\nloops, and other control structure statements. See Programmatic and Compound\nStatements for syntax details.\n\nMariaDB allows routines to contain DDL statements, such as CREATE and DROP.\nMariaDB also allows stored procedures (but not stored functions) to contain\nSQL transaction statements such as COMMIT.\n\nFor additional information about statements that are not allowed in stored\nroutines, see Stored Routine Limitations.\n\nInvoking stored procedure from within programs\n----------------------------------------------\n\nFor information about invoking stored procedures from within programs written\nin a language that has a MariaDB/MySQL interface, see CALL.\n\nOR REPLACE\n----------\n\nIf the optional OR REPLACE clause is used, it acts as a shortcut for:\n\nDROP PROCEDURE IF EXISTS name;\nCREATE PROCEDURE name ...;\n\nwith the exception that any existing privileges for the procedure are not\ndropped.\n\nsql_mode\n--------\n\nMariaDB stores the sql_mode system variable setting that is in effect at the\ntime a routine is created, and always executes the routine with this setting\nin force, regardless of the server SQL mode in effect when the routine is\ninvoked.\n\nCharacter Sets and Collations\n-----------------------------\n\nProcedure parameters can be declared with any character set/collation. If the\ncharacter set and collation are not specifically set, the database defaults at\nthe time of creation will be used. If the database defaults change at a later\nstage, the stored procedure character set/collation will not be changed at the\nsame time; the stored procedure needs to be dropped and recreated to ensure\nthe same character set/collation as the database is used.\n\nOracle Mode\n-----------\n\nMariaDB starting with 10.3\n--------------------------\nFrom MariaDB 10.3, a subset of Oracle\'s PL/SQL language has been supported in\naddition to the traditional SQL/PSM-based MariaDB syntax. See Oracle mode from\nMariaDB 10.3 for details on changes when running Oracle mode.\n\nExamples\n--------\n\nThe following example shows a simple stored procedure that uses an OUT\nparameter. It uses the DELIMITER command to set a new delimiter for the\nduration of the process — see Delimiters in the mysql client.\n\nDELIMITER //\n\nCREATE PROCEDURE simpleproc (OUT param1 INT)\n BEGIN\n SELECT COUNT(*) INTO param1 FROM t;\n END;\n//\n\nDELIMITER ;\n\nCALL simpleproc(@a);\n\nSELECT @a;\n+------+\n| @a   |\n+------+\n|    1 |\n+------+\n\nCharacter set and collation:\n\nDELIMITER //\n\nCREATE PROCEDURE simpleproc2 (\n OUT param1 CHAR(10) CHARACTER SET \'utf8\' COLLATE \'utf8_bin\'\n)\n BEGIN\n SELECT CONCAT(\'a\'),f1 INTO param1 FROM t;\n END;\n//\n\nDELIMITER ;\n\nCREATE OR REPLACE:\n\nDELIMITER //\n\nCREATE PROCEDURE simpleproc2 (\n OUT param1 CHAR(10) CHARACTER SET \'utf8\' COLLATE \'utf8_bin\'\n)\n BEGIN\n SELECT CONCAT(\'a\'),f1 INTO param1 FROM t;\n END;\n//\nERROR 1304 (42000): PROCEDURE simpleproc2 already exists\n\nDELIMITER ;\n\nDELIMITER //\n\nCREATE OR REPLACE PROCEDURE simpleproc2 (\n OUT param1 CHAR(10) CHARACTER SET \'utf8\' COLLATE \'utf8_bin\'\n)\n BEGIN\n SELECT CONCAT(\'a\'),f1 INTO param1 FROM t;\n END;\n//\nERROR 1304 (42000): PROCEDURE simpleproc2 already exists\n\nDELIMITER ;\nQuery OK, 0 rows affected (0.03 sec)\n\nURL: https://mariadb.com/kb/en/create-procedure/','','https://mariadb.com/kb/en/create-procedure/'),(700,'CREATE SERVER',38,'Syntax\n------\n\nCREATE [OR REPLACE] SERVER [IF NOT EXISTS] server_name\n  FOREIGN DATA WRAPPER wrapper_name\n  OPTIONS (option [, option] ...)\n\noption:\n { HOST character-literal\n | DATABASE character-literal\n | USER character-literal\n | PASSWORD character-literal\n | SOCKET character-literal\n | OWNER character-literal\n | PORT numeric-literal }\n\nDescription\n-----------\n\nThis statement creates the definition of a server for use with the Spider,\nConnect, FEDERATED or FederatedX storage engine. The CREATE SERVER statement\ncreates a new row within the servers table within the mysql database. This\nstatement requires the SUPER privilege or, from MariaDB 10.5.2, the FEDERATED\nADMIN privilege.\n\nThe server_name should be a unique reference to the server. Server definitions\nare global within the scope of the server, it is not possible to qualify the\nserver definition to a specific database. server_name has a maximum length of\n64 characters (names longer than 64 characters are silently truncated), and is\ncase insensitive. You may specify the name as a quoted string.\n\nThe wrapper_name may be quoted with single quotes. Supported values are:\n\n* mysql\n* mariadb (in MariaDB 10.3 and later)\n\nFor each option you must specify either a character literal or numeric\nliteral. Character literals are UTF-8, support a maximum length of 64\ncharacters and default to a blank (empty) string. String literals are silently\ntruncated to 64 characters. Numeric literals must be a number between 0 and\n9999, default value is 0.\n\nNote: The OWNER option is currently not applied, and has no effect on the\nownership or operation of the server connection that is created.\n\nThe CREATE SERVER statement creates an entry in the mysql.servers table that\ncan later be used with the CREATE TABLE statement when creating a Spider,\nConnect, FederatedX or FEDERATED table. The options that you specify will be\nused to populate the columns in the mysql.servers table. The table columns are\nServer_name, Host, Db, Username, Password, Port and Socket.\n\nDROP SERVER removes a previously created server definition.\n\nCREATE SERVER is not written to the binary log, irrespective of the binary log\nformat being used. From MariaDB 10.1.13, Galera replicates the CREATE SERVER,\nALTER SERVER and DROP SERVER statements.\n\nFor valid identifiers to use as server names, see Identifier Names.\n\nOR REPLACE\n----------\n\nIf the optional OR REPLACE clause is used, it acts as a shortcut for:\n\nDROP SERVER IF EXISTS name;\nCREATE SERVER server_name ...;\n\nIF NOT EXISTS\n-------------\n\nIf the IF NOT EXISTS clause is used, MariaDB will return a warning instead of\nan error if the server already exists. Cannot be used together with OR REPLACE.\n\nExamples\n--------\n\nCREATE SERVER s\nFOREIGN DATA WRAPPER mysql\nOPTIONS (USER \'Remote\', HOST \'192.168.1.106\', DATABASE \'test\');\n\nOR REPLACE and IF NOT EXISTS:\n\nCREATE SERVER s \nFOREIGN DATA WRAPPER mysql \nOPTIONS (USER \'Remote\', HOST \'192.168.1.106\', DATABASE \'test\');\nERROR 1476 (HY000): The foreign server, s, you are trying to create already\nexists\n\nCREATE OR REPLACE SERVER s \nFOREIGN DATA WRAPPER mysql \nOPTIONS (USER \'Remote\', HOST \'192.168.1.106\', DATABASE \'test\');\nQuery OK, 0 rows affected (0.00 sec)\n\nCREATE SERVER IF NOT EXISTS s \nFOREIGN DATA WRAPPER mysql \nOPTIONS (USER \'Remote\', HOST \'192.168.1.106\', DATABASE \'test\');\nQuery OK, 0 rows affected, 1 warning (0.00 sec)\n\nSHOW WARNINGS;\n+-------+------+---------------------------------------------------------------\n+\n| Level | Code | Message                                                      \n |\n+-------+------+---------------------------------------------------------------\n+\n| Note  | 1476 | The foreign server, s, you are trying to create already\nexists |\n+-------+------+---------------------------------------------------------------\n+\n\nURL: https://mariadb.com/kb/en/create-server/','','https://mariadb.com/kb/en/create-server/'),(701,'CREATE TABLESPACE',38,'The CREATE TABLESPACE statement is not supported by MariaDB. It was originally\ninherited from MySQL NDB Cluster. In MySQL 5.7 and later, the statement is\nalso supported for InnoDB. However, MariaDB has chosen not to include that\nspecific feature. See MDEV-19294 for more information.\n\nURL: https://mariadb.com/kb/en/create-tablespace/','','https://mariadb.com/kb/en/create-tablespace/'),(702,'CREATE TRIGGER',38,'Syntax\n------\n\nCREATE [OR REPLACE]\n  [DEFINER = { user | CURRENT_USER | role | CURRENT_ROLE }]\n  TRIGGER [IF NOT EXISTS] trigger_name trigger_time trigger_event\n  ON tbl_name FOR EACH ROW\n [{ FOLLOWS | PRECEDES } other_trigger_name ]\n trigger_stmt;\n\nDescription\n-----------\n\nThis statement creates a new trigger. A trigger is a named database object\nthat is associated with a table, and that activates when a particular event\noccurs for the table. The trigger becomes associated with the table named\ntbl_name, which must refer to a permanent table. You cannot associate a\ntrigger with a TEMPORARY table or a view.\n\nCREATE TRIGGER requires the TRIGGER privilege for the table associated with\nthe trigger.\n\nMariaDB starting with 10.2.3\n----------------------------\nYou can have multiple triggers for the same trigger_time and trigger_event.\n\nFor valid identifiers to use as trigger names, see Identifier Names.\n\nOR REPLACE\n----------\n\nMariaDB starting with 10.1.4\n----------------------------\nIf used and the trigger already exists, instead of an error being returned,\nthe existing trigger will be dropped and replaced by the newly defined trigger.\n\nDEFINER\n-------\n\nThe DEFINER clause determines the security context to be used when checking\naccess privileges at trigger activation time. Usage requires the SUPER\nprivilege, or, from MariaDB 10.5.2, the SET USER privilege.\n\nIF NOT EXISTS\n-------------\n\nMariaDB starting with 10.1.4\n----------------------------\nIf the IF NOT EXISTS clause is used, the trigger will only be created if a\ntrigger of the same name does not exist. If the trigger already exists, by\ndefault a warning will be returned.\n\ntrigger_time\n------------\n\ntrigger_time is the trigger action time. It can be BEFORE or AFTER to indicate\nthat the trigger activates before or after each row to be modified.\n\ntrigger_event\n-------------\n\ntrigger_event indicates the kind of statement that activates the trigger. The\ntrigger_event can be one of the following:\n\n* INSERT: The trigger is activated whenever a new row is inserted into the\ntable; for example, through INSERT, LOAD DATA, and REPLACE statements.\n* UPDATE: The trigger is activated whenever a row is modified; for example,\nthrough UPDATE statements.\n* DELETE: The trigger is activated whenever a row is deleted from the table;\nfor example, through DELETE and REPLACE statements. However, DROP TABLE and\nTRUNCATE statements on the table do not activate this trigger, because they do\nnot use DELETE. Dropping a partition does not activate DELETE triggers, either.\n\nFOLLOWS/PRECEDES other_trigger_name\n-----------------------------------\n\nMariaDB starting with 10.2.3\n----------------------------\nThe FOLLOWS other_trigger_name and PRECEDES other_trigger_name options were\nadded in MariaDB 10.2.3 as part of supporting multiple triggers per action\ntime. This is the same syntax used by MySQL 5.7, although MySQL 5.7 does not\nhave multi-trigger support.\n\nFOLLOWS adds the new trigger after another trigger while PRECEDES adds the new\ntrigger before another trigger. If neither option is used, the new trigger is\nadded last for the given action and time.\n\nFOLLOWS and PRECEDES are not stored in the trigger definition. However the\ntrigger order is guaranteed to not change over time. mariadb-dump/mysqldump\nand other backup methods will not change trigger order. You can verify the\ntrigger order from the ACTION_ORDER column in INFORMATION_SCHEMA.TRIGGERS\ntable.\n\nSELECT trigger_name, action_order FROM information_schema.triggers \n WHERE event_object_table=\'t1\';\n\nAtomic DDL\n----------\n\nMariaDB starting with 10.6.1\n----------------------------\nMariaDB 10.6.1 supports Atomic DDL and CREATE TRIGGER is atomic.\n\nExamples\n--------\n\nCREATE DEFINER=`root`@`localhost` TRIGGER increment_animal\n AFTER INSERT ON animals FOR EACH ROW\n UPDATE animal_count SET animal_count.animals = animal_count.animals+1;\n\nOR REPLACE and IF NOT EXISTS\n\nCREATE DEFINER=`root`@`localhost` TRIGGER increment_animal\n AFTER INSERT ON animals FOR EACH ROW\n  UPDATE animal_count SET animal_count.animals = animal_count.animals+1;\nERROR 1359 (HY000): Trigger already exists\n\nCREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER increment_animal\n AFTER INSERT ON animals  FOR EACH ROW\n  UPDATE animal_count SET animal_count.animals = animal_count.animals+1;\nQuery OK, 0 rows affected (0.12 sec)\n\nCREATE DEFINER=`root`@`localhost` TRIGGER IF NOT EXISTS increment_animal\n AFTER INSERT ON animals FOR EACH ROW\n  UPDATE animal_count SET animal_count.animals = animal_count.animals+1;\nQuery OK, 0 rows affected, 1 warning (0.00 sec)\n\nSHOW WARNINGS;\n+-------+------+------------------------+\n| Level | Code | Message                |\n+-------+------+------------------------+\n| Note  | 1359 | Trigger already exists |\n+-------+------+------------------------+\n1 row in set (0.00 sec)\n\nURL: https://mariadb.com/kb/en/create-trigger/','','https://mariadb.com/kb/en/create-trigger/'),(703,'CREATE VIEW',38,'Syntax\n------\n\nCREATE\n  [OR REPLACE]\n  [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]\n  [DEFINER = { user | CURRENT_USER | role | CURRENT_ROLE }]\n  [SQL SECURITY { DEFINER | INVOKER }]\n  VIEW [IF NOT EXISTS] view_name [(column_list)]\n  AS select_statement\n  [WITH [CASCADED | LOCAL] CHECK OPTION]\n\nDescription\n-----------\n\nThe CREATE VIEW statement creates a new view, or replaces an existing one if\nthe OR REPLACE clause is given. If the view does not exist, CREATE OR REPLACE\nVIEW is the same as CREATE VIEW. If the view does exist, CREATE OR REPLACE\nVIEW is the same as ALTER VIEW.\n\nThe select_statement is a SELECT statement that provides the definition of the\nview. (When you select from the view, you select in effect using the SELECT\nstatement.) select_statement can select from base tables or other views.\n\nThe view definition is \"frozen\" at creation time, so changes to the underlying\ntables afterwards do not affect the view definition. For example, if a view is\ndefined as SELECT * on a table, new columns added to the table later do not\nbecome part of the view. A SHOW CREATE VIEW shows that such queries are\nrewritten and column names are included in the view definition.\n\nThe view definition must be a query that does not return errors at view\ncreation times. However, the base tables used by the views might be altered\nlater and the query may not be valid anymore. In this case, querying the view\nwill result in an error. CHECK TABLE helps in finding this kind of problems.\n\nThe ALGORITHM clause affects how MariaDB processes the view. The DEFINER and\nSQL SECURITY clauses specify the security context to be used when checking\naccess privileges at view invocation time. The WITH CHECK OPTION clause can be\ngiven to constrain inserts or updates to rows in tables referenced by the\nview. These clauses are described later in this section.\n\nThe CREATE VIEW statement requires the CREATE VIEW privilege for the view, and\nsome privilege for each column selected by the SELECT statement. For columns\nused elsewhere in the SELECT statement you must have the SELECT privilege. If\nthe OR REPLACE clause is present, you must also have the DROP privilege for\nthe view.\n\nA view belongs to a database. By default, a new view is created in the default\ndatabase. To create the view explicitly in a given database, specify the name\nas db_name.view_name when you create it.\n\nCREATE VIEW test.v AS SELECT * FROM t;\n\nBase tables and views share the same namespace within a database, so a\ndatabase cannot contain a base table and a view that have the same name.\n\nViews must have unique column names with no duplicates, just like base tables.\nBy default, the names of the columns retrieved by the SELECT statement are\nused for the view column names. To define explicit names for the view columns,\nthe optional column_list clause can be given as a list of comma-separated\nidentifiers. The number of names in column_list must be the same as the number\nof columns retrieved by the SELECT statement.\n\nMySQL until 5.1.28\n------------------\nPrior to MySQL 5.1.29, When you modify an existing view, the current view\ndefinition is backed up and saved. It is stored in that table\'s database\ndirectory, in a subdirectory named arc. The backup file for a view v is named\nv.frm-00001. If you alter the view again, the next backup is named\nv.frm-00002. The three latest view backup definitions are stored. Backed up\nview definitions are not preserved by mysqldump, or any other such programs,\nbut you can retain them using a file copy operation. However, they are not\nneeded for anything but to provide you with a backup of your previous view\ndefinition. It is safe to remove these backup definitions, but only while\nmysqld is not running. If you delete the arc subdirectory or its files while\nmysqld is running, you will receive an error the next time you try to alter\nthe view:\n\nMariaDB [test]> ALTER VIEW v AS SELECT * FROM t; \nERROR 6 (HY000): Error on delete of \'.\\test\\arc/v.frm-0004\' (Errcode: 2)\n\nColumns retrieved by the SELECT statement can be simple references to table\ncolumns. They can also be expressions that use functions, constant values,\noperators, and so forth.\n\nUnqualified table or view names in the SELECT statement are interpreted with\nrespect to the default database. A view can refer to tables or views in other\ndatabases by qualifying the table or view name with the proper database name.\n\nA view can be created from many kinds of SELECT statements. It can refer to\nbase tables or other views. It can use joins, UNION, and subqueries. The\nSELECT need not even refer to any tables. The following example defines a view\nthat selects two columns from another table, as well as an expression\ncalculated from those columns:\n\nCREATE TABLE t (qty INT, price INT);\n\nINSERT INTO t VALUES(3, 50);\n\nCREATE VIEW v AS SELECT qty, price, qty*price AS value FROM t;\n\nSELECT * FROM v;\n+------+-------+-------+\n| qty  | price | value |\n+------+-------+-------+\n|    3 |    50 |   150 |\n+------+-------+-------+\n\nA view definition is subject to the following restrictions:\n\n* The SELECT statement cannot contain a subquery in the FROM clause.\n* The SELECT statement cannot refer to system or user variables.\n* Within a stored program, the definition cannot refer to program parameters\nor local variables.\n* The SELECT statement cannot refer to prepared statement parameters.\n* Any table or view referred to in the definition must exist. However, after a\nview has been created, it is possible to drop a table or view that the\ndefinition refers to. In this case, use of the view results in an error. To\ncheck a view definition for problems of this kind, use the CHECK TABLE\nstatement.\n* The definition cannot refer to a TEMPORARY table, and you cannot create a\nTEMPORARY view.\n* Any tables named in the view definition must exist at definition time.\n* You cannot associate a trigger with a view.\n* For valid identifiers to use as view names, see Identifier Names.\n\nORDER BY is allowed in a view definition, but it is ignored if you select from\na view using a statement that has its own ORDER BY.\n\nFor other options or clauses in the definition, they are added to the options\nor clauses of the statement that references the view, but the effect is\nundefined. For example, if a view definition includes a LIMIT clause, and you\nselect from the view using a statement that has its own LIMIT clause, it is\nundefined which limit applies. This same principle applies to options such as\nALL, DISTINCT, or SQL_SMALL_RESULT that follow the SELECT keyword, and to\nclauses such as INTO, FOR UPDATE, and LOCK IN SHARE MODE.\n\nThe PROCEDURE clause cannot be used in a view definition, and it cannot be\nused if a view is referenced in the FROM clause.\n\nIf you create a view and then change the query processing environment by\nchanging system variables, that may affect the results that you get from the\nview:\n\nCREATE VIEW v (mycol) AS SELECT \'abc\';\n\nSET sql_mode = \'\';\n\nSELECT \"mycol\" FROM v;\n+-------+\n| mycol |\n+-------+\n| mycol | \n+-------+\n\nSET sql_mode = \'ANSI_QUOTES\';\n\nSELECT \"mycol\" FROM v;\n+-------+\n| mycol |\n+-------+\n| abc   | \n+-------+\n\nThe DEFINER and SQL SECURITY clauses determine which MariaDB account to use\nwhen checking access privileges for the view when a statement is executed that\nreferences the view. They were added in MySQL 5.1.2. The legal SQL SECURITY\ncharacteristic values are DEFINER and INVOKER. These indicate that the\nrequired privileges must be held by the user who defined or invoked the view,\nrespectively. The default SQL SECURITY value is DEFINER.\n\nIf a user value is given for the DEFINER clause, it should be a MariaDB\naccount in \'user_name\'@\'host_name\' format (the same format used in the GRANT\nstatement). The user_name and host_name values both are required. The definer\ncan also be given as CURRENT_USER or CURRENT_USER(). The default DEFINER value\nis the user who executes the CREATE VIEW statement. This is the same as\nspecifying DEFINER = CURRENT_USER explicitly.\n\nIf you specify the DEFINER clause, these rules determine the legal DEFINER\nuser values:\n\n* If you do not have the SUPER privilege, or, from MariaDB 10.5.2, the SET\nUSER privilege, the only legal user value is your own account, either\nspecified literally or by using CURRENT_USER. You cannot set the definer to\nsome other account.\n* If you have the SUPER privilege, or, from MariaDB 10.5.2, the SET USER\nprivilege, you can specify any syntactically legal account name. If the\naccount does not actually exist, a warning is generated.\n* If the SQL SECURITY value is DEFINER but the definer account does not exist\nwhen the view is referenced, an error occurs.\n\nWithin a view definition, CURRENT_USER returns the view\'s DEFINER value by\ndefault. For views defined with the SQL SECURITY INVOKER characteristic,\nCURRENT_USER returns the account for the view\'s invoker. For information about\nuser auditing within views, see\nhttp://dev.mysql.com/doc/refman/5.1/en/account-activity-auditing.html.\n\nWithin a stored routine that is defined with the SQL SECURITY DEFINER\ncharacteristic, CURRENT_USER returns the routine\'s DEFINER value. This also\naffects a view defined within such a program, if the view definition contains\na DEFINER value of CURRENT_USER.\n\nView privileges are checked like this:\n\n* At view definition time, the view creator must have the privileges needed to\nuse the top-level objects accessed by the view. For example, if the view\ndefinition refers to table columns, the creator must have privileges for the\ncolumns, as described previously. If the definition refers to a stored\nfunction, only the privileges needed to invoke the function can be checked.\nThe privileges required when the function runs can be checked only as it\nexecutes: For different invocations of the function, different execution paths\nwithin the function might be taken.\n* When a view is referenced, privileges for objects accessed by the view are\nchecked against the privileges held by the view creator or invoker, depending\non whether the SQL SECURITY characteristic is DEFINER or INVOKER, respectively.\n* If reference to a view causes execution of a stored function, privilege\nchecking for statements executed within the function depend on whether the\nfunction is defined with a SQL SECURITY characteristic of DEFINER or INVOKER.\nIf the security characteristic is DEFINER, the function runs with the\nprivileges of its creator. If the characteristic is INVOKER, the function runs\nwith the privileges determined by the view\'s SQL SECURITY characteristic.\n\nExample: A view might depend on a stored function, and that function might\ninvoke other stored routines. For example, the following view invokes a stored\nfunction f():\n\nCREATE VIEW v AS SELECT * FROM t WHERE t.id = f(t.name);\n\nSuppose that f() contains a statement such as this:\n\nIF name IS NULL then\n CALL p1();\nELSE\n CALL p2();\nEND IF;\n\nThe privileges required for executing statements within f() need to be checked\nwhen f() executes. This might mean that privileges are needed for p1() or\np2(), depending on the execution path within f(). Those privileges must be\nchecked at runtime, and the user who must possess the privileges is determined\nby the SQL SECURITY values of the view v and the function f().\n\nThe DEFINER and SQL SECURITY clauses for views are extensions to standard SQL.\nIn standard SQL, views are handled using the rules for SQL SECURITY INVOKER.\n\nIf you invoke a view that was created before MySQL 5.1.2, it is treated as\nthough it was created with a SQL SECURITY DEFINER clause and with a DEFINER\nvalue that is the same as your account. However, because the actual definer is\nunknown, MySQL issues a warning. To make the warning go away, it is sufficient\nto re-create the view so that the view definition includes a DEFINER clause.\n\nThe optional ALGORITHM clause is an extension to standard SQL. It affects how\nMariaDB processes the view. ALGORITHM takes three values: MERGE, TEMPTABLE, or\nUNDEFINED. The default algorithm is UNDEFINED if no ALGORITHM clause is\npresent. See View Algorithms for more information.\n\nSome views are updatable. That is, you can use them in statements such as\nUPDATE, DELETE, or INSERT to update the contents of the underlying table. For\na view to be updatable, there must be a one-to-one relationship between the\nrows in the view and the rows in the underlying table. There are also certain\nother constructs that make a view non-updatable. See Inserting and Updating\nwith Views.\n\nWITH CHECK OPTION\n-----------------\n\nThe WITH CHECK OPTION clause can be given for an updatable view to prevent\ninserts or updates to rows except those for which the WHERE clause in the\nselect_statement is true.\n\nIn a WITH CHECK OPTION clause for an updatable view, the LOCAL and CASCADED\nkeywords determine the scope of check testing when the view is defined in\nterms of another view. The LOCAL keyword restricts the CHECK OPTION only to\nthe view being defined. CASCADED causes the checks for underlying views to be\nevaluated as well. When neither keyword is given, the default is CASCADED.\n\nFor more information about updatable views and the WITH CHECK OPTION clause,\nsee Inserting and Updating with Views.\n\nIF NOT EXISTS\n-------------\n\nMariaDB starting with 10.1.3\n----------------------------\nThe IF NOT EXISTS clause was added in MariaDB 10.1.3\n\nWhen the IF NOT EXISTS clause is used, MariaDB will return a warning instead\nof an error if the specified view already exists. Cannot be used together with\nthe OR REPLACE clause.\n\nAtomic DDL\n----------\n\nMariaDB starting with 10.6.1\n----------------------------\nMariaDB 10.6.1 supports Atomic DDL and CREATE VIEW is atomic.\n\nExamples\n--------\n\nCREATE TABLE t (a INT, b INT) ENGINE = InnoDB;\n\nINSERT INTO t VALUES (1,1), (2,2), (3,3);\n\nCREATE VIEW v AS SELECT a, a*2 AS a2 FROM t;\n\nSELECT * FROM v;\n+------+------+\n| a    | a2   |\n+------+------+\n|    1 |    2 |\n|    2 |    4 |\n|    3 |    6 |\n+------+------+\n\nOR REPLACE and IF NOT EXISTS:\n\nCREATE VIEW v AS SELECT a, a*2 AS a2 FROM t;\nERROR 1050 (42S01): Table \'v\' already exists\n\nCREATE OR REPLACE VIEW v AS SELECT a, a*2 AS a2 FROM t;\nQuery OK, 0 rows affected (0.04 sec)\n\nCREATE VIEW IF NOT EXISTS v AS SELECT a, a*2 AS a2 FROM t;\nQuery OK, 0 rows affected, 1 warning (0.01 sec)\n\nSHOW WARNINGS;\n+-------+------+--------------------------+\n| Level | Code | Message                  |\n+-------+------+--------------------------+\n| Note  | 1050 | Table \'v\' already exists |\n+-------+------+--------------------------+\n\nURL: https://mariadb.com/kb/en/create-view/','','https://mariadb.com/kb/en/create-view/'),(704,'Generated (Virtual and Persistent/Stored) Columns',38,'Syntax\n------\n\n<type>  [GENERATED ALWAYS]  AS   ( <expression> )\n[VIRTUAL | PERSISTENT | STORED]  [UNIQUE] [UNIQUE KEY] [COMMENT <text>]\n\nMariaDB\'s generated columns syntax is designed to be similar to the syntax for\nMicrosoft SQL Server\'s computed columns and Oracle Database\'s virtual columns.\nIn MariaDB 10.2 and later, the syntax is also compatible with the syntax for\nMySQL\'s generated columns.\n\nDescription\n-----------\n\nA generated column is a column in a table that cannot explicitly be set to a\nspecific value in a DML query. Instead, its value is automatically generated\nbased on an expression. This expression might generate the value based on the\nvalues of other columns in the table, or it might generate the value by\ncalling built-in functions or user-defined functions (UDFs).\n\nThere are two types of generated columns:\n\n* PERSISTENT (a.k.a. STORED): This type\'s value is actually stored in the\ntable.\n* VIRTUAL: This type\'s value is not stored at all. Instead, the value is\ngenerated dynamically when the table is queried. This type is the default.\n\nGenerated columns are also sometimes called computed columns or virtual\ncolumns.\n\nSupported Features\n------------------\n\nStorage Engine Support\n----------------------\n\n* Generated columns can only be used with storage engines which support them.\nIf you try to use a storage engine that does not support them, then you will\nsee an error similar to the following:\n\nERROR 1910 (HY000): TokuDB storage engine does not support computed columns\n\n* InnoDB, Aria, MyISAM and CONNECT support generated columns.\n\n* A column in a MERGE table can be built on a PERSISTENT generated column.\nHowever, a column in a MERGE table can not be defined as a VIRTUAL and\nPERSISTENT generated column.\n\nData Type Support\n-----------------\n\n* All data types are supported when defining generated columns.\n\n* Using the ZEROFILL column option is supported when defining generated\ncolumns.\n\n* Using the AUTO_INCREMENT column option is not supported when defining\ngenerated columns. Until MariaDB 10.2.25, it was supported, but this support\nwas removed, because it would not work correctly. See MDEV-11117.\n\nIndex Support\n-------------\n\n* Using a generated column as a table\'s primary key is not supported. See\nMDEV-5590 for more information. If you try to use one as a primary key, then\nyou will see an error similar to the following:\n\nERROR 1903 (HY000): Primary key cannot be defined upon a computed column\n\n* Using PERSISTENT generated columns as part of a foreign key is supported.\n\n* Referencing PERSISTENT generated columns as part of a foreign key is also\nsupported.\nHowever, using the ON UPDATE CASCADE, ON UPDATE SET NULL, or ON DELETE SET\nNULL clauses is not supported. If you try to use an unsupported clause, then\nyou will see an error similar to the following:\n\nERROR 1905 (HY000): Cannot define foreign key with ON UPDATE SET NULL clause\non a computed column\n\n* Defining indexes on both VIRTUAL and PERSISTENT generated columns is\nsupported.\nIf an index is defined on a generated column, then the optimizer considers\nusing it in the same way as indexes based on \"real\" columns.\n\nStatement Support\n-----------------\n\n* Generated columns are used in DML queries just as if they were \"real\"\ncolumns.\nHowever, VIRTUAL and PERSISTENT generated columns differ in how their data is\nstored.\nValues for PERSISTENT generated columns are generated whenever a DML queries\ninserts or updates the row with the special DEFAULT value. This generates the\ncolumns value, and it is stored in the table like the other \"real\" columns.\nThis value can be read by other DML queries just like the other \"real\" columns.\nValues for VIRTUAL generated columns are not stored in the table. Instead, the\nvalue is generated dynamically whenever the column is queried. If other\ncolumns in a row are queried, but the VIRTUAL generated column is not one of\nthe queried columns, then the column\'s value is not generated.\n\n* The SELECT statement supports generated columns.\n\n* Generated columns can be referenced in the INSERT, UPDATE, and DELETE\nstatements.\nHowever, VIRTUAL or PERSISTENT generated columns cannot be explicitly set to\nany other values than NULL or DEFAULT. If a generated column is explicitly set\nto any other value, then the outcome depends on whether strict mode is enabled\nin sql_mode. If it is not enabled, then a warning will be raised and the\ndefault generated value will be used instead. If it is enabled, then an error\nwill be raised instead.\n\n* The CREATE TABLE statement has limited support for generated columns.\nIt supports defining generated columns in a new table.\nIt supports using generated columns to partition tables.\nIt does not support using the versioning clauses with generated columns.\n\n* The ALTER TABLE statement has limited support for generated columns.\nIt supports the MODIFY and CHANGE clauses for PERSISTENT generated columns.\nIt does not support the MODIFY clause for VIRTUAL generated columns if\nALGORITHM is not set to COPY. See MDEV-15476 for more information.\nIt does not support the  CHANGE clause for VIRTUAL generated columns if\nALGORITHM is not set to COPY. See MDEV-17035 for more information.\nIt does not support altering a table if ALGORITHM is not set to COPY if the\ntable has a VIRTUAL generated column that is indexed. See MDEV-14046 for more\ninformation.\nIt does not support adding a VIRTUAL generated column with the ADD clause if\nthe same statement is also adding other columns if ALGORITHM is not set to\nCOPY. See MDEV-17468 for more information.\nIt also does not support altering an existing column into a VIRTUAL generated\ncolumn.\nIt supports using generated columns to partition tables.\nIt does not support using the versioning clauses with generated columns.\n\n* The SHOW CREATE TABLE statement supports generated columns.\n\n* The DESCRIBE statement can be used to check whether a table has generated\ncolumns.\nYou can tell which columns are generated by looking for the ones where the\nExtra column is set to either VIRTUAL or PERSISTENT. For example:\n\nDESCRIBE table1;\n+-------+-------------+------+-----+---------+------------+\n| Field | Type        | Null | Key | Default | Extra      |\n+-------+-------------+------+-----+---------+------------+\n| a     | int(11)     | NO   |     | NULL    |            |\n| b     | varchar(32) | YES  |     | NULL    |            |\n| c     | int(11)     | YES  |     | NULL    | VIRTUAL    |\n| d     | varchar(5)  | YES  |     | NULL    | PERSISTENT |\n+-------+-------------+------+-----+---------+------------+\n\n* Generated columns can be properly referenced in the NEW and OLD rows in\ntriggers.\n\n* Stored procedures support generated columns.\n\n* The HANDLER statement supports generated columns.\n\nExpression Support\n------------------\n\n* Most legal, deterministic expressions which can be calculated are supported\nin expressions for generated columns.\n\n* Most built-in functions are supported in expressions for generated columns.\nHowever, some built-in functions can\'t be supported for technical reasons. For\nexample,  If you try to use an unsupported function in an expression, an error\nis generated similar to the following:\n\nERROR 1901 (HY000): Function or expression \'dayname()\' cannot be used in the\nGENERATED ALWAYS AS clause of `v`\n\n* Subqueries are not supported in expressions for generated columns because\nthe underlying data can change.\n\n* Using anything that depends on data outside the row is not supported in\nexpressions for generated columns.\n\n* Stored functions are not supported in expressions for generated columns. See\nMDEV-17587 for more information.\n\n* Non-deterministic built-in functions are supported in expressions for not\nindexed VIRTUAL generated columns.\n\n* Non-deterministic built-in functions are not supported in expressions for\nPERSISTENT or indexed VIRTUAL generated columns.\n\n* User-defined functions (UDFs) are supported in expressions for generated\ncolumns.\nHowever, MariaDB can\'t check whether a UDF is deterministic, so it is up to\nthe user to be sure that they do not use non-deterministic UDFs with VIRTUAL\ngenerated columns.\n\n* Defining a generated column based on other generated columns defined before\nit in the table definition is supported. For example:\n\nCREATE TABLE t1 (a int as (1), b int as (a));\n\n* However, defining a generated column based on other generated columns\ndefined after in the table definition is not supported in expressions for\ngeneration columns because generated columns are calculated in the order they\nare defined.\n\n* Using an expression that exceeds 255 characters in length is supported in\nexpressions for generated columns. The new limit for the entire table\ndefinition, including all expressions for generated columns, is 65,535 bytes.\n\n* Using constant expressions is supported in expressions for generated\ncolumns. For example:\n\nCREATE TABLE t1 (a int as (1));\n\nMaking Stored Values Consistent\n-------------------------------\n\nWhen a generated column is PERSISTENT or indexed, the value of the expression\nneeds to be consistent regardless of the SQL Mode flags in the current\nsession. If it is not, then the table will be seen as corrupted when the value\nthat should actually be returned by the computed expression and the value that\nwas previously stored and/or indexed using a different sql_mode setting\ndisagree.\n\nThere are currently two affected classes of inconsistencies: character padding\nand unsigned subtraction:\n\n* For a VARCHAR or TEXT generated column the length of the value returned can\nvary depending on the PAD_CHAR_TO_FULL_LENGTH sql_mode flag.  To make the\nvalue consistent, create the generated column using an RTRIM() or RPAD()\nfunction.  Alternately, create the generated column as a CHAR column so that\nits data is always fully padded.\n\n* If a SIGNED generated column is based on the subtraction of an UNSIGNED\nvalue, the resulting value can vary depending on how large the value is and\nthe NO_UNSIGNED_SUBTRACTION sql_mode flag.  To make the value consistent, use\nCAST() to ensure that each UNSIGNED operand is SIGNED before the subtraction.\n\nMariaDB starting with 10.5\n--------------------------\nBeginning in MariaDB 10.5, there is a fatal error generated when trying to\ncreate a generated column whose value can change depending on the SQL Mode\nwhen its data is PERSISTENT or indexed.\n\nFor an existing generated column that has a potentially inconsistent value, a\nwarning about a bad expression is generated the first time it is used (if\nwarnings are enabled).\n\nBeginning in MariaDB 10.4.8, MariaDB 10.3.18, and MariaDB 10.2.27 a\npotentially inconsistent generated column outputs a warning when created or\nfirst used (without restricting their creation).\n\nHere is an example of two tables that would be rejected in MariaDB 10.5 and\nwarned about in the other listed versions:\n\nCREATE TABLE bad_pad (\n txt CHAR(5),\n -- CHAR -> VARCHAR or CHAR -> TEXT can\'t be persistent or indexed:\n vtxt VARCHAR(5) AS (txt) PERSISTENT\n);\n\nCREATE TABLE bad_sub (\n num1 BIGINT UNSIGNED,\n num2 BIGINT UNSIGNED,\n -- The resulting value can vary for some large values\n vnum BIGINT AS (num1 - num2) VIRTUAL,\n KEY(vnum)\n);\n\nThe warnings for the above tables look like this:\n\nWarning (Code 1901): Function or expression \'`txt`\' cannot be used in the\nGENERATED ALWAYS AS clause of `vtxt`\nWarning (Code 1105): Expression depends on the @@sql_mode value\nPAD_CHAR_TO_FULL_LENGTH\n\nWarning (Code 1901): Function or expression \'`num1` - `num2`\' cannot be used\nin the GENERATED ALWAYS AS clause of `vnum`\nWarning (Code 1105): Expression depends on the @@sql_mode value\nNO_UNSIGNED_SUBTRACTION\n\nTo work around the issue, force the padding or type to make the generated\ncolumn\'s expression return a consistent value. For example:\n\nCREATE TABLE good_pad (\n txt CHAR(5),\n -- Using RTRIM() or RPAD() makes the value consistent:\n vtxt VARCHAR(5) AS (RTRIM(txt)) PERSISTENT,\n -- When not persistent or indexed, it is OK for the value to vary by mode:\n vtxt2 VARCHAR(5) AS (txt) VIRTUAL,\n -- CHAR -> CHAR is always OK:\n txt2 CHAR(5) AS (txt) PERSISTENT\n);\n\nCREATE TABLE good_sub (\n num1 BIGINT UNSIGNED,\n num2 BIGINT UNSIGNED,\n -- The indexed value will always be consistent in this expression:\n vnum BIGINT AS (CAST(num1 AS SIGNED) - CAST(num2 AS SIGNED)) VIRTUAL,\n KEY(vnum)\n);\n\nMySQL Compatibility Support\n---------------------------\n\n* The STORED keyword is supported as an alias for the PERSISTENT keyword.\n\n* Tables created with MySQL 5.7 or later that contain MySQL\'s generated\ncolumns can be imported into MariaDB without a dump and restore.\n\nImplementation Differences\n--------------------------\n\nGenerated columns are subject to various constraints in other DBMSs that are\nnot present in MariaDB\'s implementation. Generated columns may also be called\ncomputed columns or virtual columns in different implementations. The various\ndetails for a specific implementation can be found in the documentation for\neach specific DBMS.\n\nImplementation Differences Compared to Microsoft SQL Server\n-----------------------------------------------------------\n\nMariaDB\'s generated columns implementation does not enforce the following\nrestrictions that are present in Microsoft SQL Server\'s computed columns\nimplementation:\n\n* MariaDB allows server variables in generated column expressions, including\nthose that change dynamically, such as warning_count.\n* MariaDB allows the CONVERT_TZ() function to be called with a named time zone\nas an argument, even though time zone names and time offsets are configurable.\n* MariaDB allows the CAST() function to be used with non-unicode character\nsets, even though character sets are configurable and differ between\nbinaries/versions.\n* MariaDB allows FLOAT expressions to be used in generated columns. Microsoft\nSQL Server considers these expressions to be \"imprecise\" due to potential\ncross-platform differences in floating-point implementations and precision.\n* Microsoft SQL Server requires the ARITHABORT mode to be set, so that\ndivision by zero returns an error, and not a NULL.\n* Microsoft SQL Server requires QUOTED_IDENTIFIER to be set in sql_mode. In\nMariaDB, if data is inserted without ANSI_QUOTES set in sql_mode, then it will\nbe processed and stored differently in a generated column that contains quoted\nidentifiers.\n\nMicrosoft SQL Server enforces the above restrictions by doing one of the\nfollowing things:\n\n* Refusing to create computed columns.\n* Refusing to allow updates to a table containing them.\n* Refusing to use an index over such a column if it can not be guaranteed that\nthe expression is fully deterministic.\n\nIn MariaDB, as long as the sql_mode, language, and other settings that were in\neffect during the CREATE TABLE remain unchanged, the generated column\nexpression will always be evaluated the same. If any of these things change,\nthen please be aware that the generated column expression might not be\nevaluated the same way as it previously was.\n\nIf you try to update a virtual column, you will get an error if the default\nstrict mode is enabled in sql_mode, or a warning otherwise.\n\nDevelopment History\n-------------------\n\nGenerated columns was originally developed by Andrey Zhakov. It was then\nmodified by Sanja Byelkin and Igor Babaev at Monty Program for inclusion in\nMariaDB. Monty did the work on MariaDB 10.2 to lift a some of the old\nlimitations.\n\nExamples\n--------\n\nHere is an example table that uses both VIRTUAL and PERSISTENT virtual columns:\n\nUSE TEST;\n\nCREATE TABLE table1 (\n  a INT NOT NULL,\n  b VARCHAR(32),\n  c INT AS (a mod 10) VIRTUAL,\n  d VARCHAR(5) AS (left(b,5)) PERSISTENT);\n\nIf you describe the table, you can easily see which columns are virtual by\nlooking in the \"Extra\" column:\n\nDESCRIBE table1;\n+-------+-------------+------+-----+---------+------------+\n| Field | Type        | Null | Key | Default | Extra      |\n+-------+-------------+------+-----+---------+------------+\n| a     | int(11)     | NO   |     | NULL    |            |\n| b     | varchar(32) | YES  |     | NULL    |            |\n| c     | int(11)     | YES  |     | NULL    | VIRTUAL    |\n| d     | varchar(5)  | YES  |     | NULL    | PERSISTENT |\n+-------+-------------+------+-----+---------+------------+\n\nTo find out what function(s) generate the value of the virtual column you can\nuse SHOW CREATE TABLE:\n\nSHOW CREATE TABLE table1;\n\n| table1 | CREATE TABLE `table1` (\n `a` int(11) NOT NULL,\n `b` varchar(32) DEFAULT NULL,\n `c` int(11) AS (a mod 10) VIRTUAL,\n `d` varchar(5) AS (left(b,5)) PERSISTENT\n) ENGINE=MyISAM DEFAULT CHARSET=latin1 |\n\nIf you try to insert non-default values into a virtual column, you will\nreceive a warning and what you tried to insert will be ignored and the derived\nvalue inserted instead:\n\nWARNINGS;\nShow warnings enabled.\n\nINSERT INTO table1 VALUES (1, \'some text\',default,default);\nQuery OK, 1 row affected (0.00 sec)\n\nINSERT INTO table1 VALUES (2, \'more text\',5,default);\nQuery OK, 1 row affected, 1 warning (0.00 sec)\n\nWarning (Code 1645): The value specified for computed column \'c\' in table\n\'table1\' has been ignored.\n\nINSERT INTO table1 VALUES (123, \'even more text\',default,\'something\');\nQuery OK, 1 row affected, 2 warnings (0.00 sec)\n\nWarning (Code 1645): The value specified for computed column \'d\' in table\n\'table1\' has been ignored.\nWarning (Code 1265): Data truncated for column \'d\' at row 1\n\nSELECT * FROM table1;\n+-----+----------------+------+-------+\n| a   | b              | c    | d     |\n+-----+----------------+------+-------+\n|   1 | some text      |    1 | some  |\n|   2 | more text      |    2 | more  |\n| 123 | even more text |    3 | even  |\n+-----+----------------+------+-------+\n3 rows in set (0.00 sec)\n\nIf the ZEROFILL clause is specified, it should be placed directly after the\ntype definition, before the AS (<expression>):\n\nCREATE TABLE table2 (a INT, b INT ZEROFILL AS (a*2) VIRTUAL);\nINSERT INTO table2 (a) VALUES (1);\n\nSELECT * FROM table2;\n+------+------------+\n| a    | b          |\n+------+------------+\n|    1 | 0000000002 |\n+------+------------+\n1 row in set (0.00 sec)\n\nYou can also use virtual columns to implement a \"poor man\'s partial index\".\nSee example at the end of Unique Index.\n\nURL: https://mariadb.com/kb/en/generated-columns/','','https://mariadb.com/kb/en/generated-columns/'),(705,'Invisible Columns',38,'MariaDB starting with 10.3.3\n----------------------------\nInvisible columns (sometimes also called hidden columns) first appeared in\nMariaDB 10.3.3.\n\nColumns can be given an INVISIBLE attribute in a CREATE TABLE or ALTER TABLE\nstatement. These columns will then not be listed in the results of a SELECT *\nstatement, nor do they need to be assigned a value in an INSERT statement,\nunless INSERT explicitly mentions them by name.\n\nSince SELECT * does not return the invisible columns, new tables or views\ncreated in this manner will have no trace of the invisible columns. If\nspecifically referenced in the SELECT statement, the columns will be brought\ninto the view/new table, but the INVISIBLE attribute will not.\n\nInvisible columns can be declared as NOT NULL, but then require a DEFAULT\nvalue.\n\nIt is not possible for all columns in a table to be invisible.\n\nExamples\n--------\n\nCREATE TABLE t (x INT INVISIBLE);\nERROR 1113 (42000): A table must have at least 1 column\n\nCREATE TABLE t (x INT, y INT INVISIBLE, z INT INVISIBLE NOT NULL);\nERROR 4106 (HY000): Invisible column `z` must have a default value\n\nCREATE TABLE t (x INT, y INT INVISIBLE, z INT INVISIBLE NOT NULL DEFAULT 4);\n\nINSERT INTO t VALUES (1),(2);\n\nINSERT INTO t (x,y) VALUES (3,33);\n\nSELECT * FROM t;\n+------+\n| x    |\n+------+\n|    1 |\n|    2 |\n|    3 |\n+------+\n\nSELECT x,y,z FROM t;\n+------+------+---+\n| x    | y    | z |\n+------+------+---+\n|    1 | NULL | 4 |\n|    2 | NULL | 4 |\n|    3 |   33 | 4 |\n+------+------+---+\n\nDESC t;\n+-------+---------+------+-----+---------+-----------+\n| Field | Type    | Null | Key | Default | Extra     |\n+-------+---------+------+-----+---------+-----------+\n| x     | int(11) | YES  |     | NULL    |           |\n| y     | int(11) | YES  |     | NULL    | INVISIBLE |\n| z     | int(11) | NO   |     | 4       | INVISIBLE |\n+-------+---------+------+-----+---------+-----------+\n\nALTER TABLE t MODIFY x INT INVISIBLE, MODIFY y INT, MODIFY z INT NOT NULL\nDEFAULT 4;\n\nDESC t;\n+-------+---------+------+-----+---------+-----------+\n| Field | Type    | Null | Key | Default | Extra     |\n+-------+---------+------+-----+---------+-----------+\n| x     | int(11) | YES  |     | NULL    | INVISIBLE |\n| y     | int(11) | YES  |     | NULL    |           |\n| z     | int(11) | NO   |     | 4       |           |\n+-------+---------+------+-----+---------+-----------+\n\nCreating a view from a table with hidden columns:\n\nCREATE VIEW v1 AS SELECT * FROM t;\n\nDESC v1;\n+-------+---------+------+-----+---------+-------+\n| Field | Type    | Null | Key | Default | Extra |\n+-------+---------+------+-----+---------+-------+\n| y     | int(11) | YES  |     | NULL    |       |\n| z     | int(11) | NO   |     | 4       |       |\n+-------+---------+------+-----+---------+-------+\n\nCREATE VIEW v2 AS SELECT x,y,z FROM t;\n\nDESC v2;\n+-------+---------+------+-----+---------+-------+\n| Field | Type    | Null | Key | Default | Extra |\n+-------+---------+------+-----+---------+-------+\n| x     | int(11) | YES  |     | NULL    |       |\n| y     | int(11) | YES  |     | NULL    |       |\n| z     | int(11) | NO   |     | 4       |       |\n+-------+---------+------+-----+---------+-------+\n\nAdding a Surrogate Primary Key:\n\ncreate table t1 (x bigint unsigned not null, y varchar(16), z text);\n\ninsert into t1 values (123, \'qq11\', \'ipsum\');\n\ninsert into t1 values (123, \'qq22\', \'lorem\');\n\nalter table t1 add pkid serial primary key invisible first;\n\ninsert into t1 values (123, \'qq33\', \'amet\');\n\nselect * from t1;\n+-----+------+-------+\n| x   | y    | z     |\n+-----+------+-------+\n| 123 | qq11 | ipsum |\n| 123 | qq22 | lorem |\n| 123 | qq33 | amet  |\n+-----+------+-------+\n\nselect pkid, z from t1;\n+------+-------+\n| pkid | z     |\n+------+-------+\n|    1 | ipsum |\n|    2 | lorem |\n|    3 | amet  |\n+------+-------+\n\nURL: https://mariadb.com/kb/en/invisible-columns/','','https://mariadb.com/kb/en/invisible-columns/'),(706,'DROP DATABASE',38,'Syntax\n------\n\nDROP {DATABASE | SCHEMA} [IF EXISTS] db_name\n\nDescription\n-----------\n\nDROP DATABASE drops all tables in the database and deletes the database. Be\nvery careful with this statement! To use DROP DATABASE, you need the DROP\nprivilege on the database. DROP SCHEMA is a synonym for DROP DATABASE.\n\nImportant: When a database is dropped, user privileges on the database are not\nautomatically dropped. See GRANT.\n\nIF EXISTS\n---------\n\nUse IF EXISTS to prevent an error from occurring for databases that do not\nexist. A NOTE is generated for each non-existent database when using IF\nEXISTS. See SHOW WARNINGS.\n\nAtomic DDL\n----------\n\nMariaDB starting with 10.6.1\n----------------------------\nMariaDB 10.6.1 supports Atomic DDL.\n\nDROP DATABASE is implemented as\n\nloop over all tables\n DROP TABLE table\n\nEach individual DROP TABLE is atomic while DROP DATABASE as a whole is\ncrash-safe.\n\nExamples\n--------\n\nDROP DATABASE bufg;\nQuery OK, 0 rows affected (0.39 sec)\n\nDROP DATABASE bufg;\nERROR 1008 (HY000): Can\'t drop database \'bufg\'; database doesn\'t exist\n\n\\W\nShow warnings enabled.\n\nDROP DATABASE IF EXISTS bufg;\nQuery OK, 0 rows affected, 1 warning (0.00 sec)\nNote (Code 1008): Can\'t drop database \'bufg\'; database doesn\'t exist\n\nURL: https://mariadb.com/kb/en/drop-database/','','https://mariadb.com/kb/en/drop-database/'),(707,'DROP EVENT',38,'Syntax\n------\n\nDROP EVENT [IF EXISTS] event_name\n\nDescription\n-----------\n\nThis statement drops the event named event_name. The event immediately ceases\nbeing active, and is deleted completely from the server.\n\nIf the event does not exist, the error ERROR 1517 (HY000): Unknown event\n\'event_name\' results. You can override this and cause the statement to\ngenerate a NOTE for non-existent events instead by using IF EXISTS. See SHOW\nWARNINGS.\n\nThis statement requires the EVENT privilege. In MySQL 5.1.11 and earlier, an\nevent could be dropped only by its definer, or by a user having the SUPER\nprivilege.\n\nExamples\n--------\n\nDROP EVENT myevent3;\n\nUsing the IF EXISTS clause:\n\nDROP EVENT IF EXISTS myevent3;\nQuery OK, 0 rows affected, 1 warning (0.01 sec)\n\nSHOW WARNINGS;\n+-------+------+-------------------------------+\n| Level | Code | Message                       |\n+-------+------+-------------------------------+\n| Note  | 1305 | Event myevent3 does not exist |\n+-------+------+-------------------------------+\n\nURL: https://mariadb.com/kb/en/drop-event/','','https://mariadb.com/kb/en/drop-event/'),(708,'DROP FUNCTION',38,'Syntax\n------\n\nDROP FUNCTION [IF EXISTS] f_name\n\nDescription\n-----------\n\nThe DROP FUNCTION statement is used to drop a stored function or a\nuser-defined function (UDF). That is, the specified routine is removed from\nthe server, along with all privileges specific to the function. You must have\nthe ALTER ROUTINE privilege for the routine in order to drop it. If the\nautomatic_sp_privileges server system variable is set, both the ALTER ROUTINE\nand EXECUTE privileges are granted automatically to the routine creator - see\nStored Routine Privileges.\n\nIF EXISTS\n---------\n\nThe IF EXISTS clause is a MySQL/MariaDB extension. It prevents an error from\noccurring if the function does not exist. A NOTE is produced that can be\nviewed with SHOW WARNINGS.\n\nFor dropping a user-defined functions (UDF), see DROP FUNCTION UDF.\n\nExamples\n--------\n\nDROP FUNCTION hello;\nQuery OK, 0 rows affected (0.042 sec)\n\nDROP FUNCTION hello;\nERROR 1305 (42000): FUNCTION test.hello does not exist\n\nDROP FUNCTION IF EXISTS hello;\nQuery OK, 0 rows affected, 1 warning (0.000 sec)\n\nSHOW WARNINGS;\n+-------+------+------------------------------------+\n| Level | Code | Message                            |\n+-------+------+------------------------------------+\n| Note  | 1305 | FUNCTION test.hello does not exist |\n+-------+------+------------------------------------+\n\nURL: https://mariadb.com/kb/en/drop-function/','','https://mariadb.com/kb/en/drop-function/'),(709,'DROP INDEX',38,'Syntax\n------\n\nDROP INDEX [IF EXISTS] index_name ON tbl_name \n  [WAIT n |NOWAIT]\n\nDescription\n-----------\n\nDROP INDEX drops the index named index_name from the table tbl_name. This\nstatement is mapped to an ALTER TABLE statement to drop the index.\n\nIf another connection is using the table, a metadata lock is active, and this\nstatement will wait until the lock is released. This is also true for\nnon-transactional tables.\n\nSee ALTER TABLE.\n\nAnother shortcut, CREATE INDEX, allows the creation of an index.\n\nTo remove the primary key, `PRIMARY` must be specified as index_name. Note\nthat the quotes are necessary, because PRIMARY is a keyword.\n\nPrivileges\n----------\n\nExecuting the DROP INDEX statement requires the INDEX privilege for the table\nor the database.\n\nOnline DDL\n----------\n\nOnline DDL is used by default with InnoDB, when the drop index operation\nsupports it.\n\nSee InnoDB Online DDL Overview for more information on online DDL with InnoDB.\n\nDROP INDEX IF EXISTS ...\n------------------------\n\nIf the IF EXISTS clause is used, then MariaDB will return a warning instead of\nan error if the index does not exist.\n\nWAIT/NOWAIT\n-----------\n\nMariaDB starting with 10.3.0\n----------------------------\nSet the lock wait timeout. See WAIT and NOWAIT.\n\nProgress Reporting\n------------------\n\nMariaDB provides progress reporting for DROP INDEX statement for clients that\nsupport the new progress reporting protocol. For example, if you were using\nthe mysql client, then the progress report might look like this::\n\nURL: https://mariadb.com/kb/en/drop-index/','','https://mariadb.com/kb/en/drop-index/'),(710,'DROP PACKAGE',38,'MariaDB starting with 10.3.5\n----------------------------\nOracle-style packages were introduced in MariaDB 10.3.5.\n\nSyntax\n------\n\nDROP PACKAGE [IF EXISTS]  [ db_name . ] package_name\n\nDescription\n-----------\n\nThe DROP PACKAGE statement can be used when Oracle SQL_MODE is set.\n\nThe DROP PACKAGE statement drops a stored package entirely:\n\n* Drops the package specification (earlier created using the CREATE PACKAGE\nstatement).\n* Drops the package implementation, if the implementation was already created\nusing the CREATE PACKAGE BODY statement.\n\nURL: https://mariadb.com/kb/en/drop-package/','','https://mariadb.com/kb/en/drop-package/'),(711,'DROP PACKAGE BODY',38,'MariaDB starting with 10.3.5\n----------------------------\nOracle-style packages were introduced in MariaDB 10.3.5.\n\nSyntax\n------\n\nDROP PACKAGE BODY [IF EXISTS]  [ db_name . ] package_name\n\nDescription\n-----------\n\nThe DROP PACKAGE BODY statement can be used when Oracle SQL_MODE is set.\n\nThe DROP PACKAGE BODY statement drops the package body (i.e the\nimplementation), previously created using the CREATE PACKAGE BODY statement.\n\nNote, DROP PACKAGE BODY drops only the package implementation, but does not\ndrop the package specification. Use DROP PACKAGE to drop the package entirely\n(i.e. both implementation and specification).\n\nURL: https://mariadb.com/kb/en/drop-package-body/','','https://mariadb.com/kb/en/drop-package-body/'),(712,'DROP PROCEDURE',38,'Syntax\n------\n\nDROP PROCEDURE [IF EXISTS] sp_name\n\nDescription\n-----------\n\nThis statement is used to drop a stored procedure. That is, the specified\nroutine is removed from the server along with all privileges specific to the\nprocedure. You must have the ALTER ROUTINE privilege for the routine. If the\nautomatic_sp_privileges server system variable is set, that privilege and\nEXECUTE are granted automatically to the routine creator - see Stored Routine\nPrivileges.\n\nThe IF EXISTS clause is a MySQL/MariaDB extension. It prevents an error from\noccurring if the procedure or function does not exist. A NOTE is produced that\ncan be viewed with SHOW WARNINGS.\n\nWhile this statement takes effect immediately, threads which are executing a\nprocedure can continue execution.\n\nExamples\n--------\n\nDROP PROCEDURE simpleproc;\n\nIF EXISTS:\n\nDROP PROCEDURE simpleproc;\nERROR 1305 (42000): PROCEDURE test.simpleproc does not exist\n\nDROP PROCEDURE IF EXISTS simpleproc;\nQuery OK, 0 rows affected, 1 warning (0.00 sec)\n\nSHOW WARNINGS;\n+-------+------+------------------------------------------+\n| Level | Code | Message                                  |\n+-------+------+------------------------------------------+\n| Note  | 1305 | PROCEDURE test.simpleproc does not exist |\n+-------+------+------------------------------------------+\n\nURL: https://mariadb.com/kb/en/drop-procedure/','','https://mariadb.com/kb/en/drop-procedure/'),(713,'DROP SERVER',38,'Syntax\n------\n\nDROP SERVER [ IF EXISTS ] server_name\n\nDescription\n-----------\n\nDrops the server definition for the server named server_name. The\ncorresponding row within the mysql.servers table will be deleted. This\nstatement requires the SUPER privilege or, from MariaDB 10.5.2, the FEDERATED\nADMIN privilege.\n\nDropping a server for a table does not affect any FederatedX, FEDERATED,\nConnect or Spider tables that used this connection information when they were\ncreated.\n\nDROP SERVER is not written to the binary log, irrespective of the binary log\nformat being used. From MariaDB 10.1.13, Galera replicates the CREATE SERVER,\nALTER SERVER and DROP SERVER statements.\n\nIF EXISTS\n---------\n\nIf the IF EXISTS clause is used, MariaDB will not return an error if the\nserver does not exist. Unlike all other statements, DROP SERVER IF EXISTS does\nnot issue a note if the server does not exist. See MDEV-9400.\n\nExamples\n--------\n\nDROP SERVER s;\n\nIF EXISTS:\n\nDROP SERVER s;\nERROR 1477 (HY000): The foreign server name you are trying to reference \n does not exist. Data source error:  s\n\nDROP SERVER IF EXISTS s;\nQuery OK, 0 rows affected (0.00 sec)\n\nURL: https://mariadb.com/kb/en/drop-server/','','https://mariadb.com/kb/en/drop-server/'),(714,'DROP TABLESPACE',38,'The DROP TABLESPACE statement is not supported by MariaDB. It was originally\ninherited from MySQL NDB Cluster. In MySQL 5.7 and later, the statement is\nalso supported for InnoDB. However, MariaDB has chosen not to include that\nspecific feature. See MDEV-19294 for more information.\n\nURL: https://mariadb.com/kb/en/drop-tablespace/','','https://mariadb.com/kb/en/drop-tablespace/'),(715,'DROP TRIGGER',38,'Syntax\n------\n\nDROP TRIGGER [IF EXISTS] [schema_name.]trigger_name\n\nDescription\n-----------\n\nThis statement drops a trigger. The schema (database) name is optional. If the\nschema is omitted, the trigger is dropped from the default schema. Its use\nrequires the TRIGGER privilege for the table associated with the trigger.\n\nUse IF EXISTS to prevent an error from occurring for a trigger that does not\nexist. A NOTE is generated for a non-existent trigger when using IF EXISTS.\nSee SHOW WARNINGS.\n\nNote: Triggers for a table are also dropped if you drop the table.\n\nAtomic DDL\n----------\n\nMariaDB starting with 10.6.1\n----------------------------\nMariaDB 10.6.1 supports Atomic DDL and DROP TRIGGER is atomic.\n\nExamples\n--------\n\nDROP TRIGGER test.example_trigger;\n\nUsing the IF EXISTS clause:\n\nDROP TRIGGER IF EXISTS test.example_trigger;\nQuery OK, 0 rows affected, 1 warning (0.01 sec)\n\nSHOW WARNINGS;\n+-------+------+------------------------+\n| Level | Code | Message                |\n+-------+------+------------------------+\n| Note  | 1360 | Trigger does not exist |\n+-------+------+------------------------+\n\nURL: https://mariadb.com/kb/en/drop-trigger/','','https://mariadb.com/kb/en/drop-trigger/'),(716,'DROP VIEW',38,'Syntax\n------\n\nDROP VIEW [IF EXISTS]\n  view_name [, view_name] ...\n  [RESTRICT | CASCADE]\n\nDescription\n-----------\n\nDROP VIEW removes one or more views. You must have the DROP privilege for each\nview. If any of the views named in the argument list do not exist, MariaDB\nreturns an error indicating by name which non-existing views it was unable to\ndrop, but it also drops all of the views in the list that do exist.\n\nThe IF EXISTS clause prevents an error from occurring for views that don\'t\nexist. When this clause is given, a NOTE is generated for each non-existent\nview. See SHOW WARNINGS.\n\nRESTRICT and CASCADE, if given, are parsed and ignored.\n\nIt is possible to specify view names as db_name.view_name. This is useful to\ndelete views from multiple databases with one statement. See Identifier\nQualifiers for details.\n\nThe DROP privilege is required to use DROP TABLE on non-temporary tables. For\ntemporary tables, no privilege is required, because such tables are only\nvisible for the current session.\n\nIf a view references another view, it will be possible to drop the referenced\nview. However, the other view will reference a view which does not exist any\nmore. Thus, querying it will produce an error similar to the following:\n\nERROR 1356 (HY000): View \'db_name.view_name\' references invalid table(s) or \ncolumn(s) or function(s) or definer/invoker of view lack rights to use them\n\nThis problem is reported in the output of CHECK TABLE.\n\nNote that it is not necessary to use DROP VIEW to replace an existing view,\nbecause CREATE VIEW has an OR REPLACE clause.\n\nAtomic DDL\n----------\n\nMariaDB starting with 10.6.1\n----------------------------\nMariaDB 10.6.1 supports Atomic DDL and DROP VIEW for a singular view is\natomic. Dropping multiple views is crash-safe.\n\nExamples\n--------\n\nDROP VIEW v,v2;\n\nGiven views v and v2, but no view v3\n\nDROP VIEW v,v2,v3;\nERROR 1051 (42S02): Unknown table \'v3\'\n\nDROP VIEW IF EXISTS v,v2,v3;\nQuery OK, 0 rows affected, 1 warning (0.01 sec)\n\nSHOW WARNINGS;\n+-------+------+-------------------------+\n| Level | Code | Message                 |\n+-------+------+-------------------------+\n| Note  | 1051 | Unknown table \'test.v3\' |\n+-------+------+-------------------------+\n\nURL: https://mariadb.com/kb/en/drop-view/','','https://mariadb.com/kb/en/drop-view/'),(717,'CONSTRAINT',38,'MariaDB supports the implementation of constraints at the table-level using\neither CREATE TABLE or ALTER TABLE statements. A table constraint restricts\nthe data you can add to the table. If you attempt to insert invalid data on a\ncolumn, MariaDB throws an error.\n\nSyntax\n------\n\n[CONSTRAINT [symbol]] constraint_expression\n\nconstraint_expression:\n | PRIMARY KEY [index_type] (index_col_name, ...) [index_option] ...\n | FOREIGN KEY [index_name] (index_col_name, ...)\n   REFERENCES tbl_name (index_col_name, ...)\n   [ON DELETE reference_option]\n   [ON UPDATE reference_option]\n | UNIQUE [INDEX|KEY] [index_name]\n   [index_type] (index_col_name, ...) [index_option] ...\n | CHECK (check_constraints)\n\nindex_type:\n USING {BTREE | HASH | RTREE}\n\nindex_col_name:\n col_name [(length)] [ASC | DESC]\n\nindex_option:\n | KEY_BLOCK_SIZE [=] value\n | index_type\n | WITH PARSER parser_name\n | COMMENT \'string\'\n | CLUSTERING={YES|NO}\n\nreference_option:\n RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT\n\nDescription\n-----------\n\nConstraints provide restrictions on the data you can add to a table. This\nallows you to enforce data integrity from MariaDB, rather than through\napplication logic. When a statement violates a constraint, MariaDB throws an\nerror.\n\nThere are four types of table constraints:\n\n+------------------------------------+---------------------------------------+\n| Constraint                         | Description                           |\n+------------------------------------+---------------------------------------+\n| PRIMARY KEY                        | Sets the column for referencing       |\n|                                    | rows.  Values must be unique and not  |\n|                                    | null.                                 |\n+------------------------------------+---------------------------------------+\n| FOREIGN KEY                        | Sets the column to reference the      |\n|                                    | primary key on another table.         |\n+------------------------------------+---------------------------------------+\n| UNIQUE                             | Requires values in column or columns  |\n|                                    | only occur once in the table.         |\n+------------------------------------+---------------------------------------+\n| CHECK                              | Checks whether the data meets the     |\n|                                    | given condition.                      |\n+------------------------------------+---------------------------------------+\n\nThe Information Schema TABLE_CONSTRAINTS Table contains information about\ntables that have constraints.\n\nFOREIGN KEY Constraints\n-----------------------\n\nInnoDB supports foreign key constraints. The syntax for a foreign key\nconstraint definition in InnoDB looks like this:\n\n[CONSTRAINT [symbol]] FOREIGN KEY\n  [index_name] (index_col_name, ...)\n  REFERENCES tbl_name (index_col_name,...)\n  [ON DELETE reference_option]\n  [ON UPDATE reference_option]\n\nreference_option:\n  RESTRICT | CASCADE | SET NULL | NO ACTION\n\nThe Information Schema REFERENTIAL_CONSTRAINTS table has more information\nabout foreign keys.\n\nCHECK Constraints\n-----------------\n\nMariaDB starting with 10.2.1\n----------------------------\nFrom MariaDB 10.2.1, constraints are enforced. Before MariaDB 10.2.1\nconstraint expressions were accepted in the syntax but ignored.\n\nIn MariaDB 10.2.1 you can define constraints in 2 different ways:\n\n* CHECK(expression) given as part of a column definition.\n* CONSTRAINT [constraint_name] CHECK (expression)\n\nBefore a row is inserted or updated, all constraints are evaluated in the\norder they are defined. If any constraint expression returns false, then the\nrow will not be inserted or updated. One can use most deterministic functions\nin a constraint, including UDFs.\n\nCREATE TABLE t1 (a INT CHECK (a>2), b INT CHECK (b>2), CONSTRAINT a_greater\nCHECK (a>b));\n\nIf you use the second format and you don\'t give a name to the constraint, then\nthe constraint will get an automatically generated name. This is done so that\nyou can later delete the constraint with ALTER TABLE DROP constraint_name.\n\nOne can disable all constraint expression checks by setting the\ncheck_constraint_checks variable to OFF. This is useful for example when\nloading a table that violates some constraints that you want to later find and\nfix in SQL.\n\nReplication\n-----------\n\nIn row-based replication, only the master checks constraints, and failed\nstatements will not be replicated. In statement-based replication, the slaves\nwill also check constraints. Constraints should therefore be identical, as\nwell as deterministic, in a replication environment.\n\nAuto_increment\n--------------\n\nMariaDB starting with 10.2.6\n----------------------------\n* From MariaDB 10.2.6, auto_increment columns are no longer permitted in check\nconstraints. Previously they were permitted, but would not work correctly. See\nMDEV-11117.\n\nExamples\n--------\n\nCREATE TABLE product (category INT NOT NULL, id INT NOT NULL,\n           price DECIMAL,\n           PRIMARY KEY(category, id)) ENGINE=INNODB;\nCREATE TABLE customer (id INT NOT NULL,\n           PRIMARY KEY (id)) ENGINE=INNODB;\nCREATE TABLE product_order (no INT NOT NULL AUTO_INCREMENT,\n              product_category INT NOT NULL,\n              product_id INT NOT NULL,\n              customer_id INT NOT NULL,\n              PRIMARY KEY(no),\n              INDEX (product_category, product_id),\n              FOREIGN KEY (product_category, product_id)\n               REFERENCES product(category, id)\n               ON UPDATE CASCADE ON DELETE RESTRICT,\n              INDEX (customer_id),\n              FOREIGN KEY (customer_id)\n               REFERENCES customer(id)) ENGINE=INNODB;\n\nMariaDB starting with 10.2.1\n----------------------------\nThe following examples will work from MariaDB 10.2.1 onwards.\n\nNumeric constraints and comparisons:\n\nCREATE TABLE t1 (a INT CHECK (a>2), b INT CHECK (b>2), CONSTRAINT a_greater\nCHECK (a>b));\n\nINSERT INTO t1(a) VALUES (1);\nERROR 4022 (23000): CONSTRAINT `a` failed for `test`.`t1`\n\nINSERT INTO t1(a,b) VALUES (3,4);\nERROR 4022 (23000): CONSTRAINT `a_greater` failed for `test`.`t1`\n\nINSERT INTO t1(a,b) VALUES (4,3);\nQuery OK, 1 row affected (0.04 sec)\n\nDropping a constraint:\n\nALTER TABLE t1 DROP CONSTRAINT a_greater;\n\nAdding a constraint:\n\nALTER TABLE t1 ADD CONSTRAINT a_greater CHECK (a>b);\n\nDate comparisons and character length:\n\nCREATE TABLE t2 (name VARCHAR(30) CHECK (CHAR_LENGTH(name)>2), start_date\nDATE, \n end_date DATE CHECK (start_date IS NULL OR end_date IS NULL OR\nstart_date<end_date));\n\nINSERT INTO t2(name, start_date, end_date) VALUES(\'Ione\', \'2003-12-15\',\n\'2014-11-09\');\nQuery OK, 1 row affected (0.04 sec)\n\nINSERT INTO t2(name, start_date, end_date) VALUES(\'Io\', \'2003-12-15\',\n\'2014-11-09\');\nERROR 4022 (23000): CONSTRAINT `name` failed for `test`.`t2`\n\nINSERT INTO t2(name, start_date, end_date) VALUES(\'Ione\', NULL, \'2014-11-09\');\nQuery OK, 1 row affected (0.04 sec)\n\nINSERT INTO t2(name, start_date, end_date) VALUES(\'Ione\', \'2015-12-15\',\n\'2014-11-09\');\nERROR 4022 (23000): CONSTRAINT `end_date` failed for `test`.`t2`\n\nA misplaced parenthesis:\n\nCREATE TABLE t3 (name VARCHAR(30) CHECK (CHAR_LENGTH(name>2)), start_date\nDATE, \n end_date DATE CHECK (start_date IS NULL OR end_date IS NULL OR\nstart_date<end_date));\nQuery OK, 0 rows affected (0.32 sec)\n\nINSERT INTO t3(name, start_date, end_date) VALUES(\'Io\', \'2003-12-15\',\n\'2014-11-09\');\nQuery OK, 1 row affected, 1 warning (0.04 sec)\n\nSHOW WARNINGS;\n+---------+------+----------------------------------------+\n| Level   | Code | Message                                |\n+---------+------+----------------------------------------+\n| Warning | 1292 | Truncated incorrect DOUBLE value: \'Io\' |\n+---------+------+----------------------------------------+\n\nCompare the definition of table t2 to table t3. CHAR_LENGTH(name)>2 is very\ndifferent to CHAR_LENGTH(name>2) as the latter mistakenly performs a numeric\ncomparison on the name field, leading to unexpected results.\n\nURL: https://mariadb.com/kb/en/constraint/','','https://mariadb.com/kb/en/constraint/'),(718,'Dynamic Columns',38,'Dynamic columns allow one to store different sets of columns for each row in a\ntable. It works by storing a set of columns in a blob and having a small set\nof functions to manipulate it. Dynamic columns should be used when it is not\npossible to use regular columns. A typical use case is when one needs to store\nitems that may have many different attributes (like size, color, weight, etc),\nand the set of possible attributes is very large and/or unknown in advance. In\nthat case, attributes can be put into dynamic columns.\n\nDynamic Columns Basics\n----------------------\n\nThe table should have a blob column which will be used as storage for dynamic\ncolumns:\n\ncreate table assets (\n item_name varchar(32) primary key, -- A common attribute for all items\n dynamic_cols  blob  -- Dynamic columns will be stored here\n);\n\nOnce created, one can access dynamic columns via dynamic column functions:\n\nInsert a row with two dynamic columns: color=blue, size=XL\n\nINSERT INTO assets VALUES \n (\'MariaDB T-shirt\', COLUMN_CREATE(\'color\', \'blue\', \'size\', \'XL\'));\n\nInsert another row with dynamic columns: color=black, price=500\n\nINSERT INTO assets VALUES\n (\'Thinkpad Laptop\', COLUMN_CREATE(\'color\', \'black\', \'price\', 500));\n\nSelect dynamic column \'color\' for all items:\n\nSELECT item_name, COLUMN_GET(dynamic_cols, \'color\' as char) \n AS color FROM assets;\n+-----------------+-------+\n| item_name       | color |\n+-----------------+-------+\n| MariaDB T-shirt | blue  |\n| Thinkpad Laptop | black |\n+-----------------+-------+\n\nIt is possible to add and remove dynamic columns from a row:\n\n-- Remove a column:\nUPDATE assets SET dynamic_cols=COLUMN_DELETE(dynamic_cols, \"price\") \nWHERE COLUMN_GET(dynamic_cols, \'color\' as char)=\'black\';\n\n-- Add a column:\nUPDATE assets SET dynamic_cols=COLUMN_ADD(dynamic_cols, \'warranty\', \'3 years\')\nWHERE item_name=\'Thinkpad Laptop\';\n\nYou can also list all columns, or get them together with their values in JSON\nformat:\n\nSELECT item_name, column_list(dynamic_cols) FROM assets;\n+-----------------+---------------------------+\n| item_name       | column_list(dynamic_cols) |\n+-----------------+---------------------------+\n| MariaDB T-shirt | `size`,`color`            |\n| Thinkpad Laptop | `color`,`warranty`        |\n+-----------------+---------------------------+\n\nSELECT item_name, COLUMN_JSON(dynamic_cols) FROM assets;\n+-----------------+----------------------------------------+\n| item_name       | COLUMN_JSON(dynamic_cols)              |\n+-----------------+----------------------------------------+\n| MariaDB T-shirt | {\"size\":\"XL\",\"color\":\"blue\"}           |\n| Thinkpad Laptop | {\"color\":\"black\",\"warranty\":\"3 years\"} |\n+-----------------+----------------------------------------+\n\nDynamic Columns Reference\n-------------------------\n\nThe rest of this page is a complete reference of dynamic columns in MariaDB\n\nDynamic Columns Functions\n-------------------------\n\nCOLUMN_CREATE\n-------------\n\nCOLUMN_CREATE(column_nr, value [as type], [column_nr, value \n [as type]]...);\nCOLUMN_CREATE(column_name, value [as type], [column_name, value \n [as type]]...);\n\nReturn a dynamic columns blob that stores the specified columns with values.\n\nThe return value is suitable for\n\n* \nstoring in a table\nfurther modification with other dynamic columns functions\n\nThe as type part allows one to specify the value type. In most cases, this is\nredundant because MariaDB will be able to deduce the type of the value.\nExplicit type specification may be needed when the type of the value is not\napparent. For example, a literal \'2012-12-01\' has a CHAR type by default, one\nwill need to specify \'2012-12-01\' AS DATE to have it stored as a date. See the\nDatatypes section for further details. Note also MDEV-597.\n\nTypical usage:\n\n-- MariaDB 5.3+:\nINSERT INTO tbl SET dyncol_blob=COLUMN_CREATE(1 /*column id*/, \"value\");\n-- MariaDB 10.0.1+:\nINSERT INTO tbl SET dyncol_blob=COLUMN_CREATE(\"column_name\", \"value\");\n\nCOLUMN_ADD\n----------\n\nCOLUMN_ADD(dyncol_blob, column_nr, value [as type], \n [column_nr, value [as type]]...);\nCOLUMN_ADD(dyncol_blob, column_name, value [as type], \n [column_name, value [as type]]...);\n\nAdds or updates dynamic columns.\n\n* \ndyncol_blob must be either a valid dynamic columns blob (for example,\nCOLUMN_CREATE returns such blob), or an empty string.\ncolumn_name specifies the name of the column to be added. If dyncol_blob\nalready has a column with this name, it will be overwritten.\nvalue specifies the new value for the column.  Passing a NULL value will cause\nthe column to be deleted.\nas type is optional. See #datatypes section for a discussion about types.\n\nThe return value is a dynamic column blob after the modifications.\n\nTypical usage:\n\n-- MariaDB 5.3+:\nUPDATE tbl SET dyncol_blob=COLUMN_ADD(dyncol_blob, 1 /*column id*/, \"value\") \n WHERE id=1;\n-- MariaDB 10.0.1+:\nUPDATE t1 SET dyncol_blob=COLUMN_ADD(dyncol_blob, \"column_name\", \"value\") \n WHERE id=1;\n\nNote: COLUMN_ADD() is a regular function (just like CONCAT()), hence, in order\nto update the value in the table you have to use the UPDATE ... SET\ndynamic_col=COLUMN_ADD(dynamic_col, ....) pattern.\n\nCOLUMN_GET\n----------\n\nCOLUMN_GET(dyncol_blob, column_nr as type);\nCOLUMN_GET(dyncol_blob, column_name as type);\n\nGet the value of a dynamic column by its name. If no column with the given\nname exists, NULL will be returned.\n\ncolumn_name as type requires that one specify the datatype of the dynamic\ncolumn they are reading.\n\nThis may seem counter-intuitive: why would one need to specify which datatype\nthey\'re retrieving? Can\'t the dynamic columns system figure the datatype from\nthe data being stored?\n\nThe answer is: SQL is a statically-typed language. The SQL interpreter needs\nto know the datatypes of all expressions before the query is run (for example,\nwhen one is using prepared statements and runs \"select COLUMN_GET(...)\", the\nprepared statement API requires the server to inform the client about the\ndatatype of the column being read before the query is executed and the server\ncan see what datatype the column actually has).\n\nSee the Datatypes section for more information about datatypes.\n\nCOLUMN_DELETE\n-------------\n\nCOLUMN_DELETE(dyncol_blob, column_nr, column_nr...);\nCOLUMN_DELETE(dyncol_blob, column_name, column_name...);\n\nDelete a dynamic column with the specified name. Multiple names can be given.\n\nThe return value is a dynamic column blob after the modification.\n\nCOLUMN_EXISTS\n-------------\n\nCOLUMN_EXISTS(dyncol_blob, column_nr);\nCOLUMN_EXISTS(dyncol_blob, column_name);\n\nCheck if a column with name column_name exists in dyncol_blob. If yes, return\n1, otherwise return 0.\n\nCOLUMN_LIST\n-----------\n\nCOLUMN_LIST(dyncol_blob);\n\nReturn a comma-separated list of column names. The names are quoted with\nbackticks.\n\nSELECT column_list(column_create(\'col1\',\'val1\',\'col2\',\'val2\'));\n+---------------------------------------------------------+\n| column_list(column_create(\'col1\',\'val1\',\'col2\',\'val2\')) |\n+---------------------------------------------------------+\n| `col1`,`col2`                                           |\n+---------------------------------------------------------+\n\nCOLUMN_CHECK\n------------\n\nCOLUMN_CHECK(dyncol_blob);\n\nCheck if dyncol_blob is a valid packed dynamic columns blob. Return value of 1\nmeans the blob is valid, return value of 0 means it is not.\n\nRationale: Normally, one works with valid dynamic column blobs. Functions like\nCOLUMN_CREATE, COLUMN_ADD, COLUMN_DELETE always return valid dynamic column\nblobs. However, if a dynamic column blob is accidentally truncated, or\ntranscoded from one character set to another, it will be corrupted. This\nfunction can be used to check if a value in a blob field is a valid dynamic\ncolumn blob.\n\nNote: It is possible that a truncation cut a Dynamic Column \"clearly\" so that\nCOLUMN_CHECK will not notice the corruption, but in any case of truncation a\nwarning is issued during value storing.\n\nCOLUMN_JSON\n-----------\n\nCOLUMN_JSON(dyncol_blob);\n\nReturn a JSON representation of data in dyncol_blob.\n\nExample:\n\nSELECT item_name, COLUMN_JSON(dynamic_cols) FROM assets;\n+-----------------+----------------------------------------+\n| item_name       | COLUMN_JSON(dynamic_cols)              |\n+-----------------+----------------------------------------+\n| MariaDB T-shirt | {\"size\":\"XL\",\"color\":\"blue\"}           |\n| Thinkpad Laptop | {\"color\":\"black\",\"warranty\":\"3 years\"} |\n+-----------------+----------------------------------------+\n\nLimitation: COLUMN_JSON will decode nested dynamic columns at a nesting level\nof not more than 10 levels deep. Dynamic columns that are nested deeper than\n10 levels will be shown as BINARY string, without encoding.\n\nNesting Dynamic Columns\n-----------------------\n\nIt is possible to use nested dynamic columns by putting one dynamic column\nblob inside another. The COLUMN_JSON function will display nested columns.\n\nSET @tmp= column_create(\'parent_column\', \n column_create(\'child_column\', 12345));\nQuery OK, 0 rows affected (0.00 sec)\n\nSELECT column_json(@tmp);\n+------------------------------------------+\n| column_json(@tmp)                        |\n+------------------------------------------+\n| {\"parent_column\":{\"child_column\":12345}} |\n+------------------------------------------+\n\nSELECT column_get(column_get(@tmp, \'parent_column\' AS char), \n \'child_column\' AS int);\n+------------------------------------------------------------------------------\n\n| column_get(column_get(@tmp, \'parent_column\' as char), \'child_column\' as int)\n|\n+------------------------------------------------------------------------------\n\n|                                                                        12345\n|\n+------------------------------------------------------------------------------\n\nIf you are trying to get a nested dynamic column as a string use \'as BINARY\'\nas the last argument of COLUMN_GET (otherwise problems with character set\nconversion and illegal symbols are possible):\n\nselect column_json( column_get(\n column_create(\'test1\',\n  column_create(\'key1\',\'value1\',\'key2\',\'value2\',\'key3\',\'value3\')),\n \'test1\' as BINARY));\n\nDatatypes\n---------\n\nIn SQL, one needs to define the type of each column in a table. Dynamic\ncolumns do not provide any way to declare a type in advance (\"whenever there\nis a column \'weight\', it should be integer\" is not possible). However, each\nparticular dynamic column value is stored together with its datatype.\n\nThe set of possible datatypes is mostly the same as that used by the SQL CAST\nand CONVERT functions. However, note that there are currently some differences\n- see MDEV-597.\n\n+--------+----------------------------------------------+-------------------+\n| type   | dynamic column internal type                 | description       |\n+--------+----------------------------------------------+-------------------+\n| BINARY | DYN_COL_STRING                               | (variable length  |\n| (N)]   |                                              | string with       |\n|        |                                              | binary charset)   |\n+--------+----------------------------------------------+-------------------+\n| CHAR[( | DYN_COL_STRING                               | (variable length  |\n| )]     |                                              | string with       |\n|        |                                              | charset)          |\n+--------+----------------------------------------------+-------------------+\n| DATE   | DYN_COL_DATE                                 | (date - 3 bytes)  |\n+--------+----------------------------------------------+-------------------+\n| DATETI | DYN_COL_DATETIME                             | (date and time    |\n| E[(D)] |                                              | (with             |\n|        |                                              | microseconds) -   |\n|        |                                              | 9 bytes)          |\n+--------+----------------------------------------------+-------------------+\n| DECIMA | DYN_COL_DECIMAL                              | (variable length  |\n| [(M[,D |                                              | binary decimal    |\n| )]     |                                              | representation    |\n|        |                                              | with MariaDB      |\n|        |                                              | limitation)       |\n+--------+----------------------------------------------+-------------------+\n| DOUBLE | DYN_COL_DOUBLE                               | (64 bit           |\n| (M,D)] |                                              | double-precision  |\n|        |                                              | floating point)   |\n+--------+----------------------------------------------+-------------------+\n| INTEGE | DYN_COL_INT                                  | (variable         |\n|        |                                              | length, up to 64  |\n|        |                                              | bit signed        |\n|        |                                              | integer)          |\n+--------+----------------------------------------------+-------------------+\n| SIGNED | DYN_COL_INT                                  | (variable         |\n| [INTEG |                                              | length, up to 64  |\n| R]     |                                              | bit signed        |\n|        |                                              | integer)          |\n+--------+----------------------------------------------+-------------------+\n| TIME[( | DYN_COL_TIME                                 | (time (with       |\n| )]     |                                              | microseconds,     |\n|        |                                              | may be negative)  |\n|        |                                              | - 6 bytes)        |\n+--------+----------------------------------------------+-------------------+\n| UNSIGN | DYN_COL_UINT                                 | (variable         |\n| D      |                                              | length, up to     |\n| [INTEG |                                              | 64bit unsigned    |\n| R]     |                                              | integer)          |\n+--------+----------------------------------------------+-------------------+\n\nA Note About Lengths\n--------------------\n\nIf you\'re running queries like\n\nSELECT COLUMN_GET(blob, \'colname\' as CHAR) ...\n\nwithout specifying a maximum length (i.e. using #as CHAR#, not as CHAR(n)),\nMariaDB will report the maximum length of the resultset column to be\n53,6870,911 (bytes or characters?) for MariaDB 5.3-10.0.0 and 16,777,216 for\nMariaDB 10.0.1+. This may cause excessive memory usage in some client\nlibraries, because they try to pre-allocate a buffer of maximum resultset\nwidth. If you suspect you\'re hitting this problem, use CHAR(n) whenever you\'re\nusing COLUMN_GET in the select list.\n\nMariaDB 5.3 vs MariaDB 10.0\n---------------------------\n\nThe dynamic columns feature was introduced into MariaDB in two steps:\n\n* MariaDB 5.3 was the first version to support dynamic columns. Only numbers\n could be used as column names in this version.\n* In MariaDB 10.0.1, column names can be either numbers or strings.\n Also, the COLUMN_JSON and COLUMN_CHECK functions were added.\n\nSee also Dynamic Columns in MariaDB 10.\n\nClient-side API\n---------------\n\nIt is also possible to create or parse dynamic columns blobs on the client\nside. libmysql client library now includes an API for writing/reading dynamic\ncolumn blobs. See dynamic-columns-api for details.\n\nLimitations\n-----------\n\n+---------------------------------------------------+------------------------+\n| Description                                       | Limit                  |\n+---------------------------------------------------+------------------------+\n| Max number of columns                             | 65535                  |\n+---------------------------------------------------+------------------------+\n| Max total length of packed dynamic column         | max_allowed_packet     |\n|                                                   | (1G)                   |\n+---------------------------------------------------+------------------------+\n\nURL: https://mariadb.com/kb/en/dynamic-columns/','','https://mariadb.com/kb/en/dynamic-columns/'),(719,'Dynamic Columns from MariaDB 10',38,'MariaDB starting with 10.0.1\n----------------------------\nMariaDB 10.0.1 introduced the following improvements to the dynamic columns\nfeature.\n\nColumn Name Support\n-------------------\n\nIt is possible to refer to column by names. Names can be used everywhere where\nin MariaDB 5.3 one could use only strings:\n\n* Create a dynamic column blob:\n\nCOLUMN_CREATE(\'int_col\', 123 as int, \'double_col\', 3.14 as double,\n\'string_col\', \'text-data\' as char);\n\n* Set a column value:\n\nCOLUMN_ADD(dyncol_blob, \'intcol\', 1234);\n\n* Get a column value:\n\nCOLUMN_GET(dynstr, \'column1\' as char(10));\n\n* Check whether a column exists\n\nCOLUMN_EXISTS(dyncol_blob, \'column_name\');\n\nChanges in Behavior\n-------------------\n\n* Column list output now includes quoting:\n\nselect column_list(column_create(1, 22, 2, 23));\n+------------------------------------------+\n| column_list(column_create(1, 22, 2, 23)) |\n+------------------------------------------+\n| `1`,`2`                                  |\n+------------------------------------------+\nselect column_list(column_create(\'column1\', 22, \'column2\', 23)); \n+----------------------------------------------------------+\n| column_list(column_create(\'column1\', 22, \'column2\', 23)) |\n+----------------------------------------------------------+\n| `column1`,`column2`                                      |\n+----------------------------------------------------------+\n\n* Column name interpretation has been changed so that the string now is not\nconverted to a number. So some \"magic\" tricks will not work any more, for\nexample, \"1test\" and \"1\" now become different column names:\n\nselect column_list(column_add(column_create(\'1a\', 22), \'1b\', 23));\n+------------------------------------------------------------+\n| column_list(column_add(column_create(\'1a\', 22), \'1b\', 23)) |\n+------------------------------------------------------------+\n| `1a`,`1b`                                                  |\n+------------------------------------------------------------+\n\n* Old behavior:\n\nselect column_list(column_add(column_create(\'1a\', 22), \'1b\', 23));\n+------------------------------------------------------------+\n| column_list(column_add(column_create(\'1a\', 22), \'1b\', 23)) |\n+------------------------------------------------------------+\n| 1                                                          |\n+------------------------------------------------------------+\n\nNew Functions\n-------------\n\nThe following new functions have been added to dynamic columns in MariaDB 10\n\nCOLUMN_CHECK\n------------\n\nCOLUMN_CHECK is used to check a column\'s integrity. When it encounters an\nerror it does not return illegal format errors but returns false instead. It\nalso checks integrity more thoroughly and finds errors in the dynamic column\ninternal structures which might not be found by other functions.\n\nselect column_check(column_create(\'column1\', 22));\n+--------------------------------------------+\n| column_check(column_create(\'column1\', 22)) |\n+--------------------------------------------+\n|                                          1 |\n+--------------------------------------------+\nselect column_check(\'abracadabra\');\n+-----------------------------+\n| column_check(\'abracadabra\') |\n+-----------------------------+\n|                           0 |\n+-----------------------------+\n\nCOLUMN_JSON\n-----------\n\nCOLUMN_JSON converts all dynamic column record content to a JSON object.\n\nselect column_json(column_create(\'column1\', 1, \'column2\', \"two\"));\n+------------------------------------------------------------+\n| column_json(column_create(\'column1\', 1, \'column2\', \"two\")) |\n+------------------------------------------------------------+\n| {\"column1\":1,\"column2\":\"two\"}                              |\n+------------------------------------------------------------+\n\nOther Changes\n-------------\n\n* All API functions has prefix mariadb_dyncol_ (old prefix dynamic_column_ is\ndepricated\n* API changed to be able to work with the new format (*_named functions).\n* Removed \'delete\' function because deleting could be done by adding NULL\nvalue.\n* \'Time\' and \'datetime\' in the new format are stored without microseconds if\nthey are 0.\n* New function added to API (except that two which are representing SQL level\nfunctions):\n\'Unpack\' the dynamic columns content to an arrays of values and names.\n3 functions to get any column value as string, integer (long long) or floating\npoint (double).\n\n* New type of \"dynamic column\" row added on the API level (in SQL level output\nit is a string but if you use dynamic column functions to construct object it\nwill be added as dynamic column value) which allow to add dynamic columns\ninside dynamic columns. JSON function represent such recursive constructions\ncorrectly but limit depth of representation as current implementation limit\n(internally depth of dynamic columns embedding is not limited).\n\nInterface with Cassandra\n------------------------\n\nCassandraSE is no longer actively being developed and has been removed in\nMariaDB 10.6. See MDEV-23024.\n\nSome internal changes were added to dynamic columns to allow them to serve as\nan interface to Apache Cassandra dynamic columns. The Cassandra engine may\npack all columns which were not mentioned in the MariaDB interface table\ndefinition and even bring changes in the dynamic column contents back to the\ncassandra columns family (the table analog in cassandra).\n\nURL: https://mariadb.com/kb/en/dynamic-columns-from-mariadb-10/','','https://mariadb.com/kb/en/dynamic-columns-from-mariadb-10/'),(720,'MERGE',38,'Description\n-----------\n\nThe MERGE storage engine, also known as the MRG_MyISAM engine, is a collection\nof identical MyISAM tables that can be used as one. \"Identical\" means that all\ntables have identical column and index information. You cannot merge MyISAM\ntables in which the columns are listed in a different order, do not have\nexactly the same columns, or have the indexes in different order. However, any\nor all of the MyISAM tables can be compressed with myisampack. Columns names\nand indexes names can be different, as long as data types and NULL/NOT NULL\nclauses are the same. Differences in table options such as AVG_ROW_LENGTH,\nMAX_ROWS, or PACK_KEYS do not matter.\n\nEach index in a MERGE table must match an index in underlying MyISAM tables,\nbut the opposite is not true. Also, a MERGE table cannot have a PRIMARY KEY or\nUNIQUE indexes, because it cannot enforce uniqueness over all underlying\ntables.\n\nThe following options are meaningful for MERGE tables:\n\n* UNION. This option specifies the list of the underlying MyISAM tables. The\nlist is enclosed between parentheses and separated with commas.\n* INSERT_METHOD. This options specifies whether, and how, INSERTs are allowed\nfor the table. Allowed values are: NO (INSERTs are not allowed), FIRST (new\nrows will be written into the first table specified in the UNION list), LAST\n(new rows will be written into the last table specified in the UNION list).\nThe default value is NO.\n\nIf you define a MERGE table with a definition which is different from the\nunderlying MyISAM tables, or one of the underlying tables is not MyISAM, the\nCREATE TABLE statement will not return any error. But any statement which\ninvolves the table will produce an error like the following:\n\nERROR 1168 (HY000): Unable to open underlying table which is differently\ndefined \n or of non-MyISAM type or doesn\'t exist\n\nA CHECK TABLE will show more information about the problem.\n\nThe error is also produced if the table is properly define, but an underlying\ntable\'s definition changes at some point in time.\n\nIf you try to insert a new row into a MERGE table with INSERT_METHOD=NO, you\nwill get an error like the following:\n\nERROR 1036 (HY000): Table \'tbl_name\' is read only\n\nIt is possible to build a MERGE table on MyISAM tables which have one or more\nvirtual columns. MERGE itself does not support virtual columns, thus such\ncolumns will be seen as regular columns. The data types and sizes will still\nneed to be identical, and they cannot be NOT NULL.\n\nExamples\n--------\n\nCREATE TABLE t1 (\n  a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\n  message CHAR(20)) ENGINE=MyISAM;\n\nCREATE TABLE t2 (\n  a INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\n  message CHAR(20)) ENGINE=MyISAM;\n\nINSERT INTO t1 (message) VALUES (\'Testing\'),(\'table\'),(\'t1\');\n\nINSERT INTO t2 (message) VALUES (\'Testing\'),(\'table\'),(\'t2\');\n\nCREATE TABLE total (\n  a INT NOT NULL AUTO_INCREMENT,\n  message CHAR(20), INDEX(a))\n  ENGINE=MERGE UNION=(t1,t2) INSERT_METHOD=LAST;\n\nSELECT * FROM total;\n+---+---------+\n| a | message |\n+---+---------+\n| 1 | Testing |\n| 2 | table   |\n| 3 | t1      |\n| 1 | Testing |\n| 2 | table   |\n| 3 | t2      |\n+---+---------+\n\nIn the following example, we\'ll create three MyISAM tables, and then a MERGE\ntable on them. However, one of them uses a different data type for the column\nb, so a SELECT will produce an error:\n\nCREATE TABLE t1 (\n a INT,\n b INT\n) ENGINE = MyISAM;\n\nCREATE TABLE t2 (\n a INT,\n b INT\n) ENGINE = MyISAM;\n\nCREATE TABLE t3 (\n a INT,\n b TINYINT\n) ENGINE = MyISAM;\n\nCREATE TABLE t_mrg (\n a INT,\n b INT\n) ENGINE = MERGE,UNION=(t1,t2,t3);\n\nSELECT * FROM t_mrg;\nERROR 1168 (HY000): Unable to open underlying table which is differently\ndefined\n or of non-MyISAM type or doesn\'t exist\n\nTo find out what\'s wrong, we\'ll use a CHECK TABLE:\n\nCHECK TABLE t_mrg\\G\n*************************** 1. row ***************************\n Table: test.t_mrg\n   Op: check\nMsg_type: Error\nMsg_text: Table \'test.t3\' is differently defined or of non-MyISAM type or\ndoesn\'t exist\n*************************** 2. row ***************************\n Table: test.t_mrg\n   Op: check\nMsg_type: Error\nMsg_text: Unable to open underlying table which is differently defined or of\nnon-MyISAM type or doesn\'t exist\n*************************** 3. row ***************************\n Table: test.t_mrg\n   Op: check\nMsg_type: error\nMsg_text: Corrupt\n\nNow, we know that the problem is in t3\'s definition.\n\nURL: https://mariadb.com/kb/en/merge/','','https://mariadb.com/kb/en/merge/'),(721,'Sequence Overview',39,'MariaDB starting with 10.3\n--------------------------\nSequences were introduced in MariaDB 10.3.\n\nIntroduction\n------------\n\nA sequence is an object that generates a sequence of numeric values, as\nspecified by the CREATE SEQUENCE statement.\n\nCREATE SEQUENCE will create a sequence that generates new values when called\nwith NEXT VALUE FOR sequence_name. It\'s an alternative to AUTO INCREMENT when\none wants to have more control of how the numbers are generated. As the\nSEQUENCE caches values (up to the CACHE value in the CREATE SEQUENCE\nstatement, by default 1000) it can in some cases be much faster than AUTO\nINCREMENT. Another benefit is that one can access the last value generated by\nall used sequences, which solves one of the limitations with LAST_INSERT_ID().\n\nCreating a Sequence\n-------------------\n\nThe CREATE SEQUENCE statement is used to create a sequence. Here is an example\nof a sequence starting at 100, incrementing by 10 each time:\n\nCREATE SEQUENCE s START WITH 100 INCREMENT BY 10;\n\nThe CREATE SEQUENCE statement, along with defaults, can be viewd with the SHOW\nCREATE SEQUENCE STATEMENT, for example:\n\nSHOW CREATE SEQUENCE s\\G\n*************************** 1. row ***************************\n   Table: s\nCreate Table: CREATE SEQUENCE `s` start with 100 minvalue 1 maxvalue\n9223372036854775806 \n increment by 10 cache 1000 nocycle ENGINE=InnoDB\n\nUsing Sequence Objects\n----------------------\n\nTo get the next value from a sequence, use\n\nNEXT VALUE FOR sequence_name\n\nor\n\nNEXTVAL(sequence_name)\n\nor in Oracle mode (SQL_MODE=ORACLE)\n\nsequence_name.nextval\n\nFor retrieving the last value used by the current connection from a sequence\nuse:\n\nPREVIOUS VALUE FOR sequence_name\n\nor\n\nLASTVAL(sequence_name)\n\nor in Oracle mode (SQL_MODE=ORACLE)\n\nsequence_name.currval\n\nFor example:\n\nSELECT NEXTVAL(s);\n+------------+\n| NEXTVAL(s) |\n+------------+\n|        100 |\n+------------+\n\nSELECT NEXTVAL(s);\n+------------+\n| NEXTVAL(s) |\n+------------+\n|        110 |\n+------------+\n\nSELECT LASTVAL(s);\n+------------+\n| LASTVAL(s) |\n+------------+\n|        110 |\n+------------+\n\nUsing Sequences in DEFAULT\n--------------------------\n\nMariaDB starting with 10.3.3\n----------------------------\nStarting from 10.3.3 you can use Sequences in DEFAULT:\n\ncreate sequence s1;\ncreate table t1 (a int primary key default (next value for s1), b int);\ninsert into t1 (b) values (1),(2);\nselect * from t1;\n+---+------+\n| a | b    |\n+---+------+\n| 1 |    1 |\n| 2 |    2 |\n+---+------+\n\nChanging a Sequence\n-------------------\n\nThe ALTER SEQUENCE statement is used for changing sequences. For example, to\nrestart the sequence at another value:\n\nALTER SEQUENCE s RESTART 50;\n\nSELECT NEXTVAL(s);\n+------------+\n| NEXTVAL(s) |\n+------------+\n|         50 |\n+------------+\n\nThe SETVAL function can also be used to set the next value to be returned for\na SEQUENCE, for example:\n\nSELECT SETVAL(s, 100);\n+----------------+\n| SETVAL(s, 100) |\n+----------------+\n|            100 |\n+----------------+\n\nSETVAL can only be used to increase the sequence value. Attempting to set a\nlower value will fail, returning NULL:\n\nSELECT SETVAL(s, 50);\n+---------------+\n| SETVAL(s, 50) |\n+---------------+\n|          NULL |\n+---------------+\n\nDropping a Sequence\n-------------------\n\nThe DROP SEQUENCE statement is used to drop a sequence, for example:\n\nDROP SEQUENCE s;\n\nReplication\n-----------\n\nIf one wants to use Sequences in a master-master setup or with Galera one\nshould use INCREMENT=0. This will tell the Sequence to use\nauto_increment_increment and auto_increment_offset to generate unique values\nfor each server.\n\nStandards Compliance\n--------------------\n\nMariaDB 10.3 supports both ANSI SQL and Oracle syntax for sequences.\n\nHowever as SEQUENCE is implemented as a special kind of table, it uses the\nsame namespace as tables. The benefits are that sequences show up in SHOW\nTABLES, and one can also create a sequence with CREATE TABLE and drop it with\nDROP TABLE. One can SELECT from it as from any other table. This ensures that\nall old tools that work with tables should work with sequences.\n\nSince sequence objects act as regular tables in many contexts, they will be\naffected by LOCK TABLES. This is not the case in other DBMS, such as Oracle,\nwhere LOCK TABLE does not affect sequences.\n\nNotes\n-----\n\nOne of the goals with the Sequence implementation is that all old tools, such\nas mysqldump, should work unchanged, while still keeping the normal usage of\nsequence standard compatibly.\n\nTo make this possible, sequence is currently implemented as a table with a few\nexclusive properties.\n\nThe special properties for sequence tables are:\n\n* A sequence table has always one row.\n* When one creates a sequence, either with CREATE TABLE or CREATE SEQUENCE,\none row will be inserted.\n* If one tries to insert into a sequence table, the single row will be\nupdated.  This allows mysqldump to work but also gives the additional benefit\nthat one can change all properties of a sequence with a single insert. New\napplications should of course also use ALTER SEQUENCE.\n* UPDATE or DELETE can\'t be performed on Sequence objects.\n* Doing a select on the sequence shows the current state of the sequence,\nexcept the values that are reserved in the cache.  The next_value column shows\nthe next value not reserved by the cache.\n* FLUSH TABLES will close the sequence and the next sequence number generated\nwill be according to what\'s stored in the Sequence object. In effect, this\nwill discard the cached values.\n* A number of normal table operations work on Sequence tables. See next\nsection.\n\nTable Operations that Work with Sequences\n-----------------------------------------\n\n* SHOW CREATE TABLE sequence_name. This shows the table structure that is\nbehind the SEQUENCE including the field names that can be used with SELECT or\neven CREATE TABLE.\n* CREATE TABLE sequence-structure ... SEQUENCE=1\n* ALTER TABLE sequence RENAME TO sequence2\n* RENAME TABLE sequence_name TO new_sequence_name\n* DROP TABLE sequence_name. This is allowed mainly to get old tools like\nmysqldump to work with sequence tables.\n* SHOW TABLES\n\nImplementation\n--------------\n\nInternally, sequence tables are created as a normal table without rollback\n(the InnoDB, Aria and MySAM engines support this), wrapped by a sequence\nengine object. This allowed us to create sequences with almost no performance\nimpact for normal tables. (The cost is one \'if\' per insert if the binary log\nis enabled).\n\nUnderlying Table Structure\n--------------------------\n\nThe following example shows the table structure of sequences and how it can be\nused as a table. (Output of results are slightly edited to make them easier to\nread)\n\ncreate sequence t1;\nshow create sequence t1\\G\n*************************** 1. row ***************************\n CREATE SEQUENCE `t1` start with 1 minvalue 1 maxvalue 9223372036854775806\n increment by 1 cache 1000 nocycle ENGINE=InnoDB\n\nshow create table t1\\G\n*************************** 1. row ***************************\nCreate Table: CREATE TABLE `t1` (\n `next_not_cached_value` bigint(21) NOT NULL,\n `minimum_value` bigint(21) NOT NULL,\n `maximum_value` bigint(21) NOT NULL,\n `start_value` bigint(21) NOT NULL COMMENT \'start value when sequences is\ncreated or value if RESTART is used\',\n `increment` bigint(21) NOT NULL COMMENT \'increment value\',\n `cache_size` bigint(21) unsigned NOT NULL,\n `cycle_option` tinyint(1) unsigned NOT NULL COMMENT \'0 if no cycles are\nallowed, 1 if the sequence should begin a new cycle when maximum_value is\npassed\',\n `cycle_count` bigint(21) NOT NULL COMMENT \'How many cycles have been done\'\n) ENGINE=InnoDB SEQUENCE=1\n\nselect * from t1\\G\nnext_not_cached_value: 1\n minimum_value: 1\n maximum_value: 9223372036854775806\n start_value: 1\n increment: 1\n cache_size: 1000\n cycle_option: 0\n cycle_count: 0\n\nThe cycle_count column is incremented every time the sequence wraps around.\n\nCredits\n-------\n\n* Thanks to Jianwe Zhao from Aliyun for his work on SEQUENCE in AliSQL, which\ngave ideas and inspiration for this work.\n* Thanks to Peter Gulutzan,who helped test and gave useful comments about the\nimplementation.\n\nURL: https://mariadb.com/kb/en/sequence-overview/','','https://mariadb.com/kb/en/sequence-overview/'),(722,'CREATE SEQUENCE',39,'MariaDB starting with 10.3\n--------------------------\nCREATE SEQUENCE was introduced in MariaDB 10.3.\n\nSyntax\n------\n\nCREATE [OR REPLACE] [TEMPORARY] SEQUENCE [IF NOT EXISTS] sequence_name\n[ INCREMENT [ BY | = ] increment ]\n[ MINVALUE [=] minvalue | NO MINVALUE | NOMINVALUE ]\n[ MAXVALUE [=] maxvalue | NO MAXVALUE | NOMAXVALUE ]\n[ START [ WITH | = ] start ] \n[ CACHE [=] cache | NOCACHE ] [ CYCLE | NOCYCLE] \n[table_options]\nThe options for CREATE SEQUENCE can be given in any order, optionally followed\nby table_options.\n\ntable_options can be any of the normal table options in CREATE TABLE but the\nmost usable ones are ENGINE=... and COMMENT=.\n\nNOMAXVALUE and NOMINVALUE are there to allow one to create SEQUENCEs using the\nOracle syntax.\n\nDescription\n-----------\n\nCREATE SEQUENCE will create a sequence that generates new values when called\nwith NEXT VALUE FOR sequence_name. It\'s an alternative to AUTO INCREMENT when\none wants to have more control of how the numbers are generated. As the\nSEQUENCE caches values (up to CACHE) it can in some cases be much faster than\nAUTO INCREMENT. Another benefit is that one can access the last value\ngenerated by all used sequences, which solves one of the limitations with\nLAST_INSERT_ID().\n\nCREATE SEQUENCE requires the CREATE privilege.\n\nDROP SEQUENCE can be used to drop a sequence, and ALTER SEQUENCE to change it.\n\nArguments to Create\n-------------------\n\nThe following options may be used:\n\n+---------------+------------------------------+----------------------------+\n| Option        | Default value                | Description                |\n+---------------+------------------------------+----------------------------+\n| INCREMENT     | 1                            | Increment to use for       |\n|               |                              | values. May be negative.   |\n|               |                              | Setting an increment of 0  |\n|               |                              | causes the sequence to     |\n|               |                              | use the value of the       |\n|               |                              | auto_increment_increment   |\n|               |                              | system variable at the     |\n|               |                              | time of creation, which    |\n|               |                              | is always a positive       |\n|               |                              | number. (see MDEV-16035).  |\n+---------------+------------------------------+----------------------------+\n| MINVALUE      | 1 if INCREMENT > 0 and       | Minimum value for the      |\n|               | -9223372036854775807 if      | sequence                   |\n|               | INCREMENT < 0                |                            |\n+---------------+------------------------------+----------------------------+\n| MAXVALUE      | 9223372036854775806 if       | Max value for sequence     |\n|               | INCREMENT > 0 and -1 if      |                            |\n|               | INCREMENT < 0                |                            |\n+---------------+------------------------------+----------------------------+\n| START         | MINVALUE if INCREMENT > 0    | First value that the       |\n|               | and MAX_VALUE if INCREMENT<  | sequence will generate     |\n|               | 0                            |                            |\n+---------------+------------------------------+----------------------------+\n| CACHE         | 1000                         | Number of values that      |\n|               |                              | should be cached. 0 if no  |\n|               |                              | CACHE.  The underlying     |\n|               |                              | table will be updated      |\n|               |                              | first time a new sequence  |\n|               |                              | number is generated and    |\n|               |                              | each time the cache runs   |\n|               |                              | out.                       |\n+---------------+------------------------------+----------------------------+\n\nIf CYCLE is used then the sequence should start again from MINVALUE after it\nhas run out of values. Default value is NOCYCLE.\n\nConstraints on Create Arguments\n-------------------------------\n\nTo be able to create a legal sequence, the following must hold:\n\n* MAXVALUE >= start\n* MAXVALUE > MINVALUE\n* START >= MINVALUE\n* MAXVALUE <= 9223372036854775806  (LONGLONG_MAX-1)\n* MINVALUE >= -9223372036854775807 (LONGLONG_MIN+1)\n\nNote that sequences can\'t generate the maximum/minimum 64 bit number because\nof the constraint of MINVALUE and MAXVALUE.\n\nAtomic DDL\n----------\n\nMariaDB starting with 10.6.1\n----------------------------\nMariaDB 10.6.1 supports Atomic DDL and CREATE SEQUENCE is atomic.\n\nExamples\n--------\n\nCREATE SEQUENCE s START WITH 100 INCREMENT BY 10;\n\nCREATE SEQUENCE s2 START WITH -100 INCREMENT BY -10;\n\nThe following statement fails, as the increment conflicts with the defaults\n\nCREATE SEQUENCE s3 START WITH -100 INCREMENT BY 10;\nERROR 4082 (HY000): Sequence \'test.s3\' values are conflicting\n\nThe sequence can be created by specifying workable minimum and maximum values:\n\nCREATE SEQUENCE s3 START WITH -100 INCREMENT BY 10 MINVALUE=-100 MAXVALUE=1000;\n\nURL: https://mariadb.com/kb/en/create-sequence/','','https://mariadb.com/kb/en/create-sequence/'),(723,'ALTER SEQUENCE',39,'MariaDB starting with 10.3.1\n----------------------------\nALTER SEQUENCE was introduced in MariaDB 10.3.\n\nSyntax\n------\n\nALTER SEQUENCE [IF EXISTS] sequence_name\n[ INCREMENT [ BY | = ] increment ]\n[ MINVALUE [=] minvalue | NO MINVALUE | NOMINVALUE ]\n[ MAXVALUE [=] maxvalue | NO MAXVALUE | NOMAXVALUE ]\n[ START [ WITH | = ] start ] [ CACHE [=] cache ] [ [ NO ] CYCLE ]\n[ RESTART [[WITH | =] restart]\n\nALTER SEQUENCE allows one to change any values for a SEQUENCE created with\nCREATE SEQUENCE.\n\nThe options for ALTER SEQUENCE can be given in any order.\n\nDescription\n-----------\n\nALTER SEQUENCE changes the parameters of an existing sequence generator. Any\nparameters not specifically set in the ALTER SEQUENCE command retain their\nprior settings.\n\nALTER SEQUENCE requires the ALTER privilege.\n\nArguments to ALTER SEQUENCE\n---------------------------\n\nThe following options may be used:\n\n+---------------+-------------------------------+---------------------------+\n| Option        | Default value                 | Description               |\n+---------------+-------------------------------+---------------------------+\n| INCREMENT     | 1                             | Increment to use for      |\n|               |                               | values. May be negative.  |\n+---------------+-------------------------------+---------------------------+\n| MINVALUE      | 1 if INCREMENT > 0 and        | Minimum value for the     |\n|               | -9223372036854775807 if       | sequence.                 |\n|               | INCREMENT < 0                 |                           |\n+---------------+-------------------------------+---------------------------+\n| MAXVALUE      | 9223372036854775806 if        | Max value for sequence.   |\n|               | INCREMENT > 0 and -1 if       |                           |\n|               | INCREMENT < 0                 |                           |\n+---------------+-------------------------------+---------------------------+\n| START         | MINVALUE if INCREMENT > 0     | First value that the      |\n|               | and MAX_VALUE if INCREMENT< 0 | sequence will generate.   |\n+---------------+-------------------------------+---------------------------+\n| CACHE         | 1000                          | Number of values that     |\n|               |                               | should be cached. 0 if    |\n|               |                               | no CACHE.  The            |\n|               |                               | underlying table will be  |\n|               |                               | updated first time a new  |\n|               |                               | sequence number is        |\n|               |                               | generated and each time   |\n|               |                               | the cache runs out.       |\n+---------------+-------------------------------+---------------------------+\n| CYCLE         | 0 (= NO CYCLE)                | 1 if the sequence should  |\n|               |                               | start again from          |\n|               |                               | MINVALUE# after it has    |\n|               |                               | run out of values.        |\n+---------------+-------------------------------+---------------------------+\n| RESTART       | START if restart value not    | If  RESTART option is     |\n|               | is given                      | used, NEXT VALUE will     |\n|               |                               | return the restart value. |\n+---------------+-------------------------------+---------------------------+\n\nThe optional clause RESTART [ WITH restart ] sets the next value for the\nsequence. This is equivalent to calling the SETVAL() function with the is_used\nargument as 0. The specified value will be returned by the next call of\nnextval. Using RESTART with no restart value is equivalent to supplying the\nstart value that was recorded by CREATE SEQUENCE or last set by ALTER SEQUENCE\nSTART WITH.\n\nALTER SEQUENCE will not allow you to change the sequence so that it\'s\ninconsistent. For example:\n\nCREATE SEQUENCE s1;\nALTER SEQUENCE s1 MINVALUE 10;\nERROR 4061 (HY000): Sequence \'test.t1\' values are conflicting\n\nALTER SEQUENCE s1 MINVALUE 10 RESTART 10;\nERROR 4061 (HY000): Sequence \'test.t1\' values are conflicting\n\nALTER SEQUENCE s1 MINVALUE 10 START 10 RESTART 10;\n\nINSERT\n------\n\nTo allow SEQUENCE objects to be backed up by old tools, like mysqldump, one\ncan use SELECT to read the current state of a SEQUENCE object and use an\nINSERT to update the SEQUENCE object. INSERT is only allowed if all fields are\nspecified:\n\nCREATE SEQUENCE s1;\nINSERT INTO s1 VALUES(1000,10,2000,1005,1,1000,0,0);\nSELECT * FROM s1;\n\n+------------+-----------+-----------+-------+-----------+-------+-------+-----\n-+\n| next_value | min_value | max_value | start | increment | cache | cycle |\nround |\n+------------+-----------+-----------+-------+-----------+-------+-------+-----\n-+\n|       1000 |        10 |      2000 |  1005 |         1 |  1000 |     0 |    \n0 |\n+------------+-----------+-----------+-------+-----------+-------+-------+-----\n-+\n\nSHOW CREATE SEQUENCE s1;\n+-------+----------------------------------------------------------------------\n---------------------------------------+\n| Table | Create Table                                                        \n                    |\n+-------+----------------------------------------------------------------------\n---------------------------------------+\n| s1    | CREATE SEQUENCE `s1` start with 1005 minvalue 10 maxvalue 2000\nincrement by 1 cache 1000 nocycle ENGINE=Aria |\n+-------+----------------------------------------------------------------------\n---------------------------------------+\n\nNotes\n-----\n\nALTER SEQUENCE will instantly affect all future SEQUENCE operations. This is\nin contrast to some other databases where the changes requested by ALTER\nSEQUENCE will not be seen until the sequence cache has run out.\n\nALTER SEQUENCE will take a full table lock of the sequence object during its\n(brief) operation. This ensures that ALTER SEQUENCE is replicated correctly.\nIf you only want to set the next sequence value to a higher value than\ncurrent, then you should use SETVAL() instead, as this is not blocking.\n\nIf you want to change storage engine, sequence comment or rename the sequence,\nyou can use ALTER TABLE for this.\n\nURL: https://mariadb.com/kb/en/alter-sequence/','','https://mariadb.com/kb/en/alter-sequence/'),(724,'DROP SEQUENCE',39,'MariaDB starting with 10.3\n--------------------------\nDROP SEQUENCE was introduced in MariaDB 10.3.\n\nSyntax\n------\n\nDROP [TEMPORARY] SEQUENCE [IF EXISTS] [/*COMMENT TO SAVE*/]\n  sequence_name [, sequence_name] ...\n\nDescription\n-----------\n\nDROP SEQUENCE removes one or more sequences created with CREATE SEQUENCE. You\nmust have the DROP privilege for each sequence. MariaDB returns an error\nindicating by name which non-existing tables it was unable to drop, but it\nalso drops all of the tables in the list that do exist.\n\nImportant: When a table is dropped, user privileges on the table are not\nautomatically dropped. See GRANT.\n\nIf another connection is using the sequence, a metadata lock is active, and\nthis statement will wait until the lock is released. This is also true for\nnon-transactional tables.\n\nFor each referenced sequence, DROP SEQUENCE drops a temporary sequence with\nthat name, if it exists. If it does not exist, and the TEMPORARY keyword is\nnot used, it drops a non-temporary sequence with the same name, if it exists.\nThe TEMPORARY keyword ensures that a non-temporary sequence will not\naccidentally be dropped.\n\nUse IF EXISTS to prevent an error from occurring for sequences that do not\nexist. A NOTE is generated for each non-existent sequence when using IF\nEXISTS. See SHOW WARNINGS.\n\nDROP SEQUENCE requires the DROP privilege.\n\nNotes\n-----\n\nDROP SEQUENCE only removes sequences, not tables. However, DROP TABLE can\nremove both sequences and tables.\n\nURL: https://mariadb.com/kb/en/drop-sequence/','','https://mariadb.com/kb/en/drop-sequence/'),(725,'NEXT VALUE for sequence_name',39,'MariaDB starting with 10.3\n--------------------------\nSEQUENCEs were introduced in MariaDB 10.3\n\nSyntax\n------\n\nNEXT VALUE FOR sequence\n\nor\n\nNEXTVAL(sequence_name)\n\nor in Oracle mode (SQL_MODE=ORACLE)\n\nsequence_name.nextval\n\nNEXT VALUE FOR is ANSI SQL syntax while NEXTVAL() is PostgreSQL syntax.\n\nDescription\n-----------\n\nGenerate next value for a SEQUENCE.\n\n* You can greatly speed up NEXT VALUE by creating the sequence with the CACHE\noption. If not, every NEXT VALUE usage will cause changes in the stored\nSEQUENCE table.\n* When using NEXT VALUE the value will be reserved at once and will not be\nreused, except if the SEQUENCE was created with CYCLE. This means that when\nyou are using SEQUENCEs you have to expect gaps in the generated sequence\nnumbers.\n* If one updates the SEQUENCE with SETVAL() or ALTER SEQUENCE ... RESTART,\nNEXT VALUE FOR will notice this and start from the next requested value.\n* FLUSH TABLES will close the sequence and the next sequence number generated\nwill be according to what\'s stored in the SEQUENCE object. In effect, this\nwill discard the cached values.\n* A server restart (or closing the current connection) also causes a drop of\nall cached values. The cached sequence numbers are reserved only for the\ncurrent connection.\n* NEXT VALUE requires the INSERT privilege.\n\nMariaDB starting with 10.3.3\n----------------------------\n* You can also use NEXT VALUE FOR sequence for column DEFAULT.\n\nURL: https://mariadb.com/kb/en/next-value-for-sequence_name/','','https://mariadb.com/kb/en/next-value-for-sequence_name/'),(726,'PREVIOUS VALUE FOR sequence_name',39,'MariaDB starting with 10.3\n--------------------------\nSEQUENCEs were introduced in MariaDB 10.3.\n\nSyntax\n------\n\nPREVIOUS VALUE FOR sequence_name\n\nor\n\nLASTVAL(sequence_name)\n\nor in Oracle mode (SQL_MODE=ORACLE)\n\nsequence_name.currval\n\nPREVIOUS VALUE FOR is IBM DB2 syntax while LASTVAL() is PostgreSQL syntax.\n\nDescription\n-----------\n\nGet last value in the current connection generated from a sequence.\n\n* If the sequence has not yet been used by the connection, PREVIOUS VALUE FOR\nreturns NULL (the same thing applies with a new connection which doesn\'t see a\nlast value for an existing sequence).\n* If a SEQUENCE has been dropped and re-created then it\'s treated as a new\nSEQUENCE and PREVIOUS VALUE FOR will return NULL.\n* FLUSH TABLES has no effect on PREVIOUS VALUE FOR.\n* Previous values for all used sequences are stored per connection until\nconnection ends.\n* PREVIOUS VALUE FOR requires the SELECT privilege.\n\nExample\n-------\n\nCREATE SEQUENCE s START WITH 100 INCREMENT BY 10;\n\nSELECT PREVIOUS VALUE FOR s;\n+----------------------+\n| PREVIOUS VALUE FOR s |\n+----------------------+\n|                 NULL |\n+----------------------+\n\n# The function works for sequences only, if the table is used an error is\ngenerated\nSELECT PREVIOUS VALUE FOR t;\nERROR 4089 (42S02): \'test.t\' is not a SEQUENCE\n\n# Call the NEXT VALUE FOR s:\nSELECT NEXT VALUE FOR s;\n+------------------+\n| NEXT VALUE FOR s |\n+------------------+\n|              100 |\n+------------------+\n\nSELECT PREVIOUS VALUE FOR s;\n+----------------------+\n| PREVIOUS VALUE FOR s |\n+----------------------+\n|                  100 |\n+----------------------+\n\nNow try to start the new connection and check that the last value is still\nNULL, before updating the value in the new connection after the output of the\nnew connection gets current value (110 in the example below). Note that first\nconnection cannot see this change and the result of last value still remains\nthe same (100 in the example above).\n\n$ .mysql -uroot test -e\"SELECT PREVIOUS VALUE FOR s; SELECT NEXT VALUE FOR s;\nSELECT PREVIOUS VALUE FOR s;\"\n+----------------------+\n| PREVIOUS VALUE FOR s |\n+----------------------+\n|                 NULL |\n+----------------------+\n+------------------+\n| NEXT VALUE FOR s |\n+------------------+\n|              110 |\n+------------------+\n+----------------------+\n| PREVIOUS VALUE FOR s |\n+----------------------+\n|                  110 |\n+----------------------+\n\nURL: https://mariadb.com/kb/en/previous-value-for-sequence_name/','','https://mariadb.com/kb/en/previous-value-for-sequence_name/'),(727,'SETVAL',39,'MariaDB starting with 10.3.1\n----------------------------\nSEQUENCEs were introduced in MariaDB 10.3.\n\nSyntax\n------\n\nSETVAL(sequence_name, next_value, [is_used, [round]])\n\nDescription\n-----------\n\nSet the next value to be returned for a SEQUENCE.\n\nThis function is compatible with PostgreSQL syntax, extended with the round\nargument.\n\nIf the is_used argument is not given or is 1 or true, then the next used value\nwill one after the given value. If is_used is 0 or false then the next\ngenerated value will be the given value.\n\nIf round is used then it will set the round value (or the internal cycle\ncount, starting at zero) for the sequence. If round is not used, it\'s assumed\nto be 0.\n\nnext_value must be an integer literal.\n\nFor SEQUENCE tables defined with CYCLE (see CREATE SEQUENCE) one should use\nboth next_value and round to define the next value. In this case the current\nsequence value is defined to be round, next_value.\n\nThe result returned by SETVAL() is next_value or NULL if the given next_value\nand round is smaller than the current value.\n\nSETVAL() will not set the SEQUENCE value to a something that is less than its\ncurrent value. This is needed to ensure that SETVAL() is replication safe. If\nyou want to set the SEQUENCE to a smaller number use ALTER SEQUENCE.\n\nIf CYCLE is used, first round and then next_value are compared to see if the\nvalue is bigger than the current value.\n\nInternally, in the MariaDB server, SETVAL() is used to inform slaves that a\nSEQUENCE has changed value. The slave may get SETVAL() statements out of\norder, but this is ok as only the biggest one will have an effect.\n\nSETVAL requires the INSERT privilege.\n\nExamples\n--------\n\nSELECT setval(foo, 42);           -- Next nextval will return 43\nSELECT setval(foo, 42, true);     -- Same as above\nSELECT setval(foo, 42, false);    -- Next nextval will return 42\n\nSETVAL setting higher and lower values on a sequence with an increment of 10:\n\nSELECT NEXTVAL(s);\n+------------+\n| NEXTVAL(s) |\n+------------+\n|         50 |\n+------------+\n\nSELECT SETVAL(s, 100);\n+----------------+\n| SETVAL(s, 100) |\n+----------------+\n|            100 |\n+----------------+\n\nSELECT NEXTVAL(s);\n+------------+\n| NEXTVAL(s) |\n+------------+\n|        110 |\n+------------+\n\nSELECT SETVAL(s, 50);\n+---------------+\n| SETVAL(s, 50) |\n+---------------+\n|          NULL |\n+---------------+\n\nSELECT NEXTVAL(s);\n+------------+\n| NEXTVAL(s) |\n+------------+\n|        120 |\n+------------+\n\nExample demonstrating round:\n\nCREATE OR REPLACE SEQUENCE s1\n START WITH 1\n MINVALUE 1\n MAXVALUE 99\n INCREMENT BY 1\n CACHE 20\n CYCLE;\n\nSELECT SETVAL(s1, 99, 1, 0);\n+----------------------+\n| SETVAL(s1, 99, 1, 0) |\n+----------------------+\n|                   99 |\n+----------------------+\n\nSELECT NEXTVAL(s1);\n+-------------+\n| NEXTVAL(s1) |\n+-------------+\n|           1 |\n+-------------+\n\nThe following statement returns NULL, as the given next_value and round is\nsmaller than the current value.\n\nSELECT SETVAL(s1, 99, 1, 0);\n+----------------------+\n| SETVAL(s1, 99, 1, 0) |\n+----------------------+\n|                 NULL |\n+----------------------+\n\nSELECT NEXTVAL(s1);\n+-------------+\n| NEXTVAL(s1) |\n+-------------+\n|           2 |\n+-------------+\n\nIncreasing the round from zero to 1 will allow next_value to be returned.\n\nSELECT SETVAL(s1, 99, 1, 1);\n+----------------------+\n| SETVAL(s1, 99, 1, 1) |\n+----------------------+\n|                   99 |\n+----------------------+\n\nSELECT NEXTVAL(s1);\n+-------------+\n| NEXTVAL(s1) |\n+-------------+\n|           1 |\n+-------------+\n\nURL: https://mariadb.com/kb/en/setval/','','https://mariadb.com/kb/en/setval/'),(728,'JSONPath Expressions',40,'A number of JSON functions accept JSON Path expressions. MariaDB defines this\npath as follows:\n\nJSON Path Syntax\n----------------\n\npath : [\'lax\'] \'$\' [step]*\n\nThe path starts with an optional path mode. At the moment, MariaDB supports\nonly the \"lax\" mode, which is also the mode that is used when it is not\nexplicitly specified.\n\nThe $ symbol represents the context item. The search always starts from the\ncontext item; because of that, the path always starts with $.\n\nThen, it is followed by zero or more steps, which select element(s) in the\nJSON document. A step may be one of the following:\n\n* Object member selector\n* Array element selector\n* Wildcard selector\n\nObject Member Selector\n----------------------\n\nTo select member(s) in a JSON object, one can use one of the following:\n\n* .memberName selects the value of the member with name memberName.\n* .\"memberName\" - the same as above but allows one to select a member with a\nname that\'s not a valid identifier (that is, has space, dot, and/or other\ncharacters)\n* .* - selects the values of all members of the object.\n\nIf the current item is an array (instead of an object), nothing will be\nselected.\n\nArray Element Selector\n----------------------\n\nTo select elements of an array, one can use one of the following:\n\n* [N] selects element number N in the array. The elements are counted from\nzero.\n* [*] selects all elements in the array.\n\nIf the current item is an object (instead of an array), nothing will be\nselected.\n\nStarting from MariaDB server 10.9, JSON path also supports negative index in\narray, \'last\' keyword and range notation (\'to\' keyword) for accessing array\nelements. Negative index starts from -1.\n\n* [-N] selects n th element from end.\n* [last-N] selects n th element from the last element.\n* [M to N] selects range of elements starting from index M to N.\n\nExample:\n\nSET @json=\'{\n      \"A\": [0,\n         [1, 2, 3],\n         [4, 5, 6],\n         \"seven\",\n         0.8,\n         true,\n         false,\n         \"eleven\",\n         [12, [13, 14], {\"key1\":\"value1\"},[15]],\n         true],\n      \"B\": {\"C\": 1},\n      \"D\": 2\n     }\';\nSELECT JSON_EXTRACT(@json, \'$.A[-8][1]\');\n+--------------------------------------------------+\n| JSON_EXTRACT(@json, \'$.A[-8][1]\')                |\n+--------------------------------------------------+\n| 5                                                |\n+--------------------------------------------------+\n\nSELECT JSON_EXTRACT(@json, \'$.A[last-7][1]\');\n+-----------------------------------------------+\n| SELECT JSON_EXTRACT(@json, \'$.A[last-7][1]\'); |\n+-----------------------------------------------+\n| 5                                             |\n+-----------------------------------------------+\n\nSET @json= \'[\n      [1, {\"key1\": \"value1\"}, 3],\n      [false, 5, 6],\n      [7, 8, [9, {\"key2\": 2}, 11]],\n      [15, 1.34, [14], [\"string1\", [16, {\"key1\":[1,2,3,[4,5,6]]}, 18]]],\n      [19, 20],\n      21, 22\n      ]\';\n\nSELECT JSON_EXTRACT(@json, \'$[0 to 3][2]\');\n+-----------------------------------------------+\n| JSON_EXTRACT(@json, \'$[0 to 3][2]\')           |\n+-----------------------------------------------+\n| [3, 6, [9, {\"key2\": 2}, 11], [14]]            |\n+-----------------------------------------------+\n\nThis will produce output for first index of eighth from last element of a two\ndimensional array.\n\nNote: In range notation, when M > N ( when M,N are greater than or equal to 0)\nor (size of array - M or size of array - N when M, N are less than 0), then it\nis treated as an impossible range and NULL is returned.\n\nSET @json= \'[1, 2, 3, 4, 5]\';\nSELECT JSON_EXTRACT(@json, \'$[4 to 2]\');\n+-----------------------------------+\n| JSON_EXTRACT(@json, \'$[4 to 2]\')  |\n+-----------------------------------+\n| NULL                              |\n+-----------------------------------+\n\nWildcard\n--------\n\nThe wildcard step, **, recursively selects all child elements of the current\nelement. Both array elements and object members are selected.\n\nThe wildcard step must not be the last step in the JSONPath expression. It\nmust be followed by an array or object member selector step.\n\nFor example:\n\nselect json_extract(@json_doc, \'$**.price\');\n\nwill select all object members in the document that are named price, while\n\nselect json_extract(@json_doc, \'$**[2]\');\n\nwill select the second element in each of the arrays present in the document.\n\nCompatibility\n-------------\n\nMariaDB\'s JSONPath syntax supports a subset of JSON Path\'s definition in the\nSQL Standard. The most notable things not supported are the strict mode and\nfilters.\n\nMariaDB\'s JSONPath is close to MySQL\'s JSONPath. The wildcard step ( ** ) is a\nnon-standard extension that has the same meaning as in MySQL. The differences\nbetween MariaDB and MySQL\'s JSONPath are: MySQL supports [last] and [M to N]\nas array element selectors; MySQL doesn\'t allow one to specify the mode\nexplicitly (but uses lax mode implicitly).\n\nURL: https://mariadb.com/kb/en/jsonpath-expressions/','','https://mariadb.com/kb/en/jsonpath-expressions/'),(729,'JSON_ARRAY',40,'Syntax\n------\n\nJSON_ARRAY([value[, value2] ...])\n\nDescription\n-----------\n\nReturns a JSON array containing the listed values. The list can be empty.\n\nExample\n-------\n\nSELECT Json_Array(56, 3.1416, \'My name is \"Foo\"\', NULL);\n+--------------------------------------------------+\n| Json_Array(56, 3.1416, \'My name is \"Foo\"\', NULL) |\n+--------------------------------------------------+\n| [56, 3.1416, \"My name is \\\"Foo\\\"\", null]         |\n+--------------------------------------------------+\n\nURL: https://mariadb.com/kb/en/json_array/','','https://mariadb.com/kb/en/json_array/'),(730,'JSON_ARRAY_APPEND',40,'Syntax\n------\n\nJSON_ARRAY_APPEND(json_doc, path, value[, path, value] ...)\n\nDescription\n-----------\n\nAppends values to the end of the specified arrays within a JSON document,\nreturning the result, or NULL if any of the arguments are NULL.\n\nEvaluation is performed from left to right, with the resulting document from\nthe previous pair becoming the new value against which the next pair is\nevaluated.\n\nIf the json_doc is not a valid JSON document, or if any of the paths are not\nvalid, or contain a * or ** wildcard, an error is returned.\n\nExamples\n--------\n\nSET @json = \'[1, 2, [3, 4]]\';\n\nSELECT JSON_ARRAY_APPEND(@json, \'$[0]\', 5)\n+-------------------------------------+\n| JSON_ARRAY_APPEND(@json, \'$[0]\', 5) |\n+-------------------------------------+\n| [[1, 5], 2, [3, 4]]                 |\n+-------------------------------------+\n\nSELECT JSON_ARRAY_APPEND(@json, \'$[1]\', 6);\n+-------------------------------------+\n| JSON_ARRAY_APPEND(@json, \'$[1]\', 6) |\n+-------------------------------------+\n| [1, [2, 6], [3, 4]]                 |\n+-------------------------------------+\n\nSELECT JSON_ARRAY_APPEND(@json, \'$[1]\', 6, \'$[2]\', 7);\n+------------------------------------------------+\n| JSON_ARRAY_APPEND(@json, \'$[1]\', 6, \'$[2]\', 7) |\n+------------------------------------------------+\n| [1, [2, 6], [3, 4, 7]]                         |\n+------------------------------------------------+\n\nSELECT JSON_ARRAY_APPEND(@json, \'$\', 5);\n+----------------------------------+\n| JSON_ARRAY_APPEND(@json, \'$\', 5) |\n+----------------------------------+\n| [1, 2, [3, 4], 5]                |\n+----------------------------------+\n\nSET @json = \'{\"A\": 1, \"B\": [2], \"C\": [3, 4]}\';\n\nSELECT JSON_ARRAY_APPEND(@json, \'$.B\', 5);\n+------------------------------------+\n| JSON_ARRAY_APPEND(@json, \'$.B\', 5) |\n+------------------------------------+\n| {\"A\": 1, \"B\": [2, 5], \"C\": [3, 4]} |\n+------------------------------------+\n\nURL: https://mariadb.com/kb/en/json_array_append/','','https://mariadb.com/kb/en/json_array_append/'),(731,'JSON_ARRAY_INSERT',40,'Syntax\n------\n\nJSON_ARRAY_INSERT(json_doc, path, value[, path, value] ...)\n\nDescription\n-----------\n\nInserts a value into a JSON document, returning the modified document, or NULL\nif any of the arguments are NULL.\n\nEvaluation is performed from left to right, with the resulting document from\nthe previous pair becoming the new value against which the next pair is\nevaluated.\n\nIf the json_doc is not a valid JSON document, or if any of the paths are not\nvalid, or contain a * or ** wildcard, an error is returned.\n\nExamples\n--------\n\nSET @json = \'[1, 2, [3, 4]]\';\n\nSELECT JSON_ARRAY_INSERT(@json, \'$[0]\', 5);\n+-------------------------------------+\n| JSON_ARRAY_INSERT(@json, \'$[0]\', 5) |\n+-------------------------------------+\n| [5, 1, 2, [3, 4]]                   |\n+-------------------------------------+\n\nSELECT JSON_ARRAY_INSERT(@json, \'$[1]\', 6);\n+-------------------------------------+\n| JSON_ARRAY_INSERT(@json, \'$[1]\', 6) |\n+-------------------------------------+\n| [1, 6, 2, [3, 4]]                   |\n+-------------------------------------+\n\nSELECT JSON_ARRAY_INSERT(@json, \'$[1]\', 6, \'$[2]\', 7);\n+------------------------------------------------+\n| JSON_ARRAY_INSERT(@json, \'$[1]\', 6, \'$[2]\', 7) |\n+------------------------------------------------+\n| [1, 6, 7, 2, [3, 4]]                           |\n+------------------------------------------------+\n\nURL: https://mariadb.com/kb/en/json_array_insert/','','https://mariadb.com/kb/en/json_array_insert/'),(732,'JSON_COMPACT',40,'Syntax\n------\n\nJSON_COMPACT(json_doc)\n\nDescription\n-----------\n\nRemoves all unnecessary spaces so the json document is as short as possible.\n\nExample\n-------\n\nSET @j = \'{ \"A\": 1, \"B\": [2, 3]}\';\n\nSELECT JSON_COMPACT(@j), @j;\n+-------------------+------------------------+\n| JSON_COMPACT(@j)  | @j                     |\n+-------------------+------------------------+\n| {\"A\":1,\"B\":[2,3]} | { \"A\": 1, \"B\": [2, 3]} |\n+-------------------+------------------------+\n\nURL: https://mariadb.com/kb/en/json_compact/','','https://mariadb.com/kb/en/json_compact/'),(733,'JSON_CONTAINS',40,'Syntax\n------\n\nJSON_CONTAINS(json_doc, val[, path])\n\nDescription\n-----------\n\nReturns whether or not the specified value is found in the given JSON document\nor, optionally, at the specified path within the document. Returns 1 if it\ndoes, 0 if not and NULL if any of the arguments are null. An error occurs if\nthe document or path is not valid, or contains the * or ** wildcards.\n\nExamples\n--------\n\nSET @json = \'{\"A\": 0, \"B\": {\"C\": 1}, \"D\": 2}\';\n\nSELECT JSON_CONTAINS(@json, \'2\', \'$.A\');\n+----------------------------------+\n| JSON_CONTAINS(@json, \'2\', \'$.A\') |\n+----------------------------------+\n|                                0 |\n+----------------------------------+\n\nSELECT JSON_CONTAINS(@json, \'2\', \'$.D\');\n+----------------------------------+\n| JSON_CONTAINS(@json, \'2\', \'$.D\') |\n+----------------------------------+\n|                                1 |\n+----------------------------------+\n\nSELECT JSON_CONTAINS(@json, \'{\"C\": 1}\', \'$.A\');\n+-----------------------------------------+\n| JSON_CONTAINS(@json, \'{\"C\": 1}\', \'$.A\') |\n+-----------------------------------------+\n|                                       0 |\n+-----------------------------------------+\n\nSELECT JSON_CONTAINS(@json, \'{\"C\": 1}\', \'$.B\');\n+-----------------------------------------+\n| JSON_CONTAINS(@json, \'{\"C\": 1}\', \'$.B\') |\n+-----------------------------------------+\n|                                       1 |\n+-----------------------------------------+\n\nURL: https://mariadb.com/kb/en/json_contains/','','https://mariadb.com/kb/en/json_contains/'),(734,'JSON_CONTAINS_PATH',40,'Syntax\n------\n\nJSON_CONTAINS_PATH(json_doc, return_arg, path[, path] ...)\n\nDescription\n-----------\n\nIndicates whether the given JSON document contains data at the specified path\nor paths. Returns 1 if it does, 0 if not and NULL if any of the arguments are\nnull.\n\nThe return_arg can be one or all:\n\n* one - Returns 1 if at least one path exists within the JSON document. \n* all - Returns 1 only if all paths exist within the JSON document.\n\nExamples\n--------\n\nSET @json = \'{\"A\": 1, \"B\": [2], \"C\": [3, 4]}\';\n\nSELECT JSON_CONTAINS_PATH(@json, \'one\', \'$.A\', \'$.D\');\n+------------------------------------------------+\n| JSON_CONTAINS_PATH(@json, \'one\', \'$.A\', \'$.D\') |\n+------------------------------------------------+\n|                                              1 |\n+------------------------------------------------+\n1 row in set (0.00 sec)\n\nSELECT JSON_CONTAINS_PATH(@json, \'all\', \'$.A\', \'$.D\');\n+------------------------------------------------+\n| JSON_CONTAINS_PATH(@json, \'all\', \'$.A\', \'$.D\') |\n+------------------------------------------------+\n|                                              0 |\n+------------------------------------------------+\n\nURL: https://mariadb.com/kb/en/json_contains_path/','','https://mariadb.com/kb/en/json_contains_path/'),(735,'JSON_DEPTH',40,'Syntax\n------\n\nJSON_DEPTH(json_doc)\n\nDescription\n-----------\n\nReturns the maximum depth of the given JSON document, or NULL if the argument\nis null. An error will occur if the argument is an invalid JSON document.\n\n* Scalar values or empty arrays or objects have a depth of 1.\n* Arrays or objects that are not empty but contain only elements or member\nvalues of depth 1 will have a depth of 2.\n* In other cases, the depth will be greater than 2.\n\nExamples\n--------\n\nSELECT JSON_DEPTH(\'[]\'), JSON_DEPTH(\'true\'), JSON_DEPTH(\'{}\');\n+------------------+--------------------+------------------+\n| JSON_DEPTH(\'[]\') | JSON_DEPTH(\'true\') | JSON_DEPTH(\'{}\') |\n+------------------+--------------------+------------------+\n|                1 |                  1 |                1 |\n+------------------+--------------------+------------------+\n\nSELECT JSON_DEPTH(\'[1, 2, 3]\'), JSON_DEPTH(\'[[], {}, []]\');\n+-------------------------+----------------------------+\n| JSON_DEPTH(\'[1, 2, 3]\') | JSON_DEPTH(\'[[], {}, []]\') |\n+-------------------------+----------------------------+\n|                       2 |                          2 |\n+-------------------------+----------------------------+\n\nSELECT JSON_DEPTH(\'[1, 2, [3, 4, 5, 6], 7]\');\n+---------------------------------------+\n| JSON_DEPTH(\'[1, 2, [3, 4, 5, 6], 7]\') |\n+---------------------------------------+\n|                                     3 |\n+---------------------------------------+\n\nURL: https://mariadb.com/kb/en/json_depth/','','https://mariadb.com/kb/en/json_depth/'),(736,'JSON_DETAILED',40,'Syntax\n------\n\nJSON_DETAILED(json_doc[, tab_size])\n\nDescription\n-----------\n\nRepresents JSON in the most understandable way emphasizing nested structures.\n\nExample\n-------\n\nSET @j = \'{ \"A\":1,\"B\":[2,3]}\';\n\nSELECT @j;\n+--------------------+\n| @j                 |\n+--------------------+\n| { \"A\":1,\"B\":[2,3]} |\n+--------------------+\n\nSELECT JSON_DETAILED(@j);\n+------------------------------------------------------------+\n| JSON_DETAILED(@j)                                          |\n+------------------------------------------------------------+\n| {\n  \"A\": 1,\n  \"B\":\n  [\n    2,\n    3\n  ]\n} |\n+------------------------------------------------------------+\n\nURL: https://mariadb.com/kb/en/json_detailed/','','https://mariadb.com/kb/en/json_detailed/'),(737,'JSON_EXISTS',40,'Syntax\n------\n\nDescription\n-----------\n\nDetermines whether a specified JSON value exists in the given data. Returns 1\nif found, 0 if not, or NULL if any of the inputs were NULL.\n\nExamples\n--------\n\nSELECT JSON_EXISTS(\'{\"key1\":\"xxxx\", \"key2\":[1, 2, 3]}\', \"$.key2\");\n+------------------------------------------------------------+\n| JSON_EXISTS(\'{\"key1\":\"xxxx\", \"key2\":[1, 2, 3]}\', \"$.key2\") |\n+------------------------------------------------------------+\n|                                                          1 |\n+------------------------------------------------------------+\n\nSELECT JSON_EXISTS(\'{\"key1\":\"xxxx\", \"key2\":[1, 2, 3]}\', \"$.key3\");\n+------------------------------------------------------------+\n| JSON_EXISTS(\'{\"key1\":\"xxxx\", \"key2\":[1, 2, 3]}\', \"$.key3\") |\n+------------------------------------------------------------+\n|                                                          0 |\n+------------------------------------------------------------+\n\nSELECT JSON_EXISTS(\'{\"key1\":\"xxxx\", \"key2\":[1, 2, 3]}\', \"$.key2[1]\");\n+---------------------------------------------------------------+\n| JSON_EXISTS(\'{\"key1\":\"xxxx\", \"key2\":[1, 2, 3]}\', \"$.key2[1]\") |\n+---------------------------------------------------------------+\n|                                                             1 |\n+---------------------------------------------------------------+\n\nSELECT JSON_EXISTS(\'{\"key1\":\"xxxx\", \"key2\":[1, 2, 3]}\', \"$.key2[10]\");\n+----------------------------------------------------------------+\n| JSON_EXISTS(\'{\"key1\":\"xxxx\", \"key2\":[1, 2, 3]}\', \"$.key2[10]\") |\n+----------------------------------------------------------------+\n|                                                              0 |\n+----------------------------------------------------------------+\n\nURL: https://mariadb.com/kb/en/json_exists/','','https://mariadb.com/kb/en/json_exists/'),(738,'JSON_EXTRACT',40,'Syntax\n------\n\nJSON_EXTRACT(json_doc, path[, path] ...)\n\nDescription\n-----------\n\nExtracts data from a JSON document. The extracted data is selected from the\nparts matching the path arguments. Returns all matched values; either as a\nsingle matched value, or, if the arguments could return multiple values, a\nresult autowrapped as an array in the matching order.\n\nReturns NULL if no paths match or if any of the arguments are NULL.\n\nAn error will occur if any path argument is not a valid path, or if the\njson_doc argument is not a valid JSON document.\n\nThe path expression be a JSONPath expression as supported by MariaDB\n\nExamples\n--------\n\nSET @json = \'[1, 2, [3, 4]]\';\n\nSELECT JSON_EXTRACT(@json, \'$[1]\');\n+-----------------------------+\n| JSON_EXTRACT(@json, \'$[1]\') |\n+-----------------------------+\n| 2                           |\n+-----------------------------+\n\nSELECT JSON_EXTRACT(@json, \'$[2]\');\n+-----------------------------+\n| JSON_EXTRACT(@json, \'$[2]\') |\n+-----------------------------+\n| [3, 4]                      |\n+-----------------------------+\n\nSELECT JSON_EXTRACT(@json, \'$[2][1]\');\n+--------------------------------+\n| JSON_EXTRACT(@json, \'$[2][1]\') |\n+--------------------------------+\n| 4                              |\n+--------------------------------+\n\nURL: https://mariadb.com/kb/en/json_extract/','','https://mariadb.com/kb/en/json_extract/'),(739,'JSON_INSERT',40,'Syntax\n------\n\nJSON_INSERT(json_doc, path, val[, path, val] ...)\n\nDescription\n-----------\n\nInserts data into a JSON document, returning the resulting document or NULL if\nany argument is null.\n\nAn error will occur if the JSON document is not invalid, or if any of the\npaths are invalid or contain a * or ** wildcard.\n\nJSON_INSERT can only insert data while JSON_REPLACE can only update. JSON_SET\ncan update or insert data.\n\nExamples\n--------\n\nSET @json = \'{ \"A\": 0, \"B\": [1, 2]}\';\n\nSELECT JSON_INSERT(@json, \'$.C\', \'[3, 4]\');\n+--------------------------------------+\n| JSON_INSERT(@json, \'$.C\', \'[3, 4]\')  |\n+--------------------------------------+\n| { \"A\": 0, \"B\": [1, 2], \"C\":\"[3, 4]\"} |\n+--------------------------------------+\n\nURL: https://mariadb.com/kb/en/json_insert/','','https://mariadb.com/kb/en/json_insert/'),(740,'JSON_KEYS',40,'Syntax\n------\n\nJSON_KEYS(json_doc[, path])\n\nDescription\n-----------\n\nReturns the keys as a JSON array from the top-level value of a JSON object or,\nif the optional path argument is provided, the top-level keys from the path.\n\nExcludes keys from nested sub-objects in the top level value. The resulting\narray will be empty if the selected object is empty.\n\nReturns NULL if any of the arguments are null, a given path does not locate an\nobject, or if the json_doc argument is not an object.\n\nAn error will occur if JSON document is invalid, the path is invalid or if the\npath contains a * or ** wildcard.\n\nExamples\n--------\n\nSELECT JSON_KEYS(\'{\"A\": 1, \"B\": {\"C\": 2}}\');\n+--------------------------------------+\n| JSON_KEYS(\'{\"A\": 1, \"B\": {\"C\": 2}}\') |\n+--------------------------------------+\n| [\"A\", \"B\"]                           |\n+--------------------------------------+\n\nSELECT JSON_KEYS(\'{\"A\": 1, \"B\": 2, \"C\": {\"D\": 3}}\', \'$.C\');\n+-----------------------------------------------------+\n| JSON_KEYS(\'{\"A\": 1, \"B\": 2, \"C\": {\"D\": 3}}\', \'$.C\') |\n+-----------------------------------------------------+\n| [\"D\"]                                               |\n+-----------------------------------------------------+\n\nURL: https://mariadb.com/kb/en/json_keys/','','https://mariadb.com/kb/en/json_keys/'),(741,'JSON_LENGTH',40,'Syntax\n------\n\nJSON_LENGTH(json_doc[, path])\n\nDescription\n-----------\n\nReturns the length of a JSON document, or, if the optional path argument is\ngiven, the length of the value within the document specified by the path.\n\nReturns NULL if any of the arguments argument are null or the path argument\ndoes not identify a value in the document.\n\nAn error will occur if the JSON document is invalid, the path is invalid or if\nthe path contains a * or ** wildcard.\n\nLength will be determined as follow:\n\n* A scalar\'s length is always 1.\n* If an array, the number of elements in the array.\n* If an object, the number of members in the object.\n\nThe length of nested arrays or objects are not counted.\n\nExamples\n--------\n\nURL: https://mariadb.com/kb/en/json_length/','','https://mariadb.com/kb/en/json_length/'),(742,'JSON_LOOSE',40,'Syntax\n------\n\nJSON_LOOSE(json_doc)\n\nDescription\n-----------\n\nAdds spaces to a JSON document to make it look more readable.\n\nExample\n-------\n\nSET @j = \'{ \"A\":1,\"B\":[2,3]}\';\n\nSELECT JSON_LOOSE(@j), @j;\n+-----------------------+--------------------+\n| JSON_LOOSE(@j)        | @j                 |\n+-----------------------+--------------------+\n| {\"A\": 1, \"B\": [2, 3]} | { \"A\":1,\"B\":[2,3]} |\n+-----------------------+--------------------+\n\nURL: https://mariadb.com/kb/en/json_loose/','','https://mariadb.com/kb/en/json_loose/'),(743,'JSON_MERGE',40,'Syntax\n------\n\nJSON_MERGE(json_doc, json_doc[, json_doc] ...)\n\nDescription\n-----------\n\nMerges the given JSON documents.\n\nReturns the merged result,or NULL if any argument is NULL.\n\nAn error occurs if any of the arguments are not valid JSON documents.\n\nJSON_MERGE has been deprecated since MariaDB 10.2.25, MariaDB 10.3.16 and\nMariaDB 10.4.5. JSON_MERGE_PATCH is an RFC 7396-compliant replacement, and\nJSON_MERGE_PRESERVE is a synonym.\n\nExample\n-------\n\nSET @json1 = \'[1, 2]\';\nSET @json2 = \'[3, 4]\';\n\nSELECT JSON_MERGE(@json1,@json2);\n+---------------------------+\n| JSON_MERGE(@json1,@json2) |\n+---------------------------+\n| [1, 2, 3, 4]              |\n+---------------------------+\n\nURL: https://mariadb.com/kb/en/json_merge/','','https://mariadb.com/kb/en/json_merge/'),(744,'JSON_MERGE_PATCH',40,'MariaDB starting with 10.2.25\n-----------------------------\nJSON_MERGE_PATCH was introduced in MariaDB 10.2.25, MariaDB 10.3.16 and\nMariaDB 10.4.5.\n\nSyntax\n------\n\nJSON_MERGE_PATCH(json_doc, json_doc[, json_doc] ...)\n\nDescription\n-----------\n\nMerges the given JSON documents, returning the merged result, or NULL if any\nargument is NULL.\n\nJSON_MERGE_PATCH is an RFC 7396-compliant replacement for JSON_MERGE, which\nhas been deprecated.\n\nExample\n-------\n\nSET @json1 = \'[1, 2]\';\nSET @json2 = \'[2, 3]\';\nSELECT JSON_MERGE_PATCH(@json1,@json2),JSON_MERGE_PRESERVE(@json1,@json2);\n+---------------------------------+------------------------------------+\n| JSON_MERGE_PATCH(@json1,@json2) | JSON_MERGE_PRESERVE(@json1,@json2) |\n+---------------------------------+------------------------------------+\n| [2, 3]                          | [1, 2, 2, 3]                       |\n+---------------------------------+------------------------------------+\n\nURL: https://mariadb.com/kb/en/json_merge_patch/','','https://mariadb.com/kb/en/json_merge_patch/'),(745,'JSON_MERGE_PRESERVE',40,'MariaDB starting with 10.2.25\n-----------------------------\nJSON_MERGE_PRESERVE was introduced in MariaDB 10.2.25, MariaDB 10.3.16 and\nMariaDB 10.4.5.\n\nSyntax\n------\n\nJSON_MERGE_PRESERVE(json_doc, json_doc[, json_doc] ...)\n\nDescription\n-----------\n\nMerges the given JSON documents, returning the merged result, or NULL if any\nargument is NULL.\n\nJSON_MERGE_PRESERVE was introduced in MariaDB 10.2.25, MariaDB 10.3.16 and\nMariaDB 10.4.5 as a synonym for JSON_MERGE, which has been deprecated.\n\nExample\n-------\n\nSET @json1 = \'[1, 2]\';\nSET @json2 = \'[2, 3]\';\nSELECT JSON_MERGE_PATCH(@json1,@json2),JSON_MERGE_PRESERVE(@json1,@json2);\n+---------------------------------+------------------------------------+\n| JSON_MERGE_PATCH(@json1,@json2) | JSON_MERGE_PRESERVE(@json1,@json2) |\n+---------------------------------+------------------------------------+\n| [2, 3]                          | [1, 2, 2, 3]                       |\n+---------------------------------+------------------------------------+\n\nURL: https://mariadb.com/kb/en/json_merge_preserve/','','https://mariadb.com/kb/en/json_merge_preserve/'),(746,'JSON_OBJECT',40,'Syntax\n------\n\nJSON_OBJECT([key, value[, key, value] ...])\n\nDescription\n-----------\n\nReturns a JSON object containing the given key/value pairs. The key/value list\ncan be empty.\n\nAn error will occur if there are an odd number of arguments, or any key name\nis NULL.\n\nExample\n-------\n\nSELECT JSON_OBJECT(\"id\", 1, \"name\", \"Monty\");\n+---------------------------------------+\n| JSON_OBJECT(\"id\", 1, \"name\", \"Monty\") |\n+---------------------------------------+\n| {\"id\": 1, \"name\": \"Monty\"}            |\n+---------------------------------------+\n\nURL: https://mariadb.com/kb/en/json_object/','','https://mariadb.com/kb/en/json_object/'),(747,'JSON_QUERY',40,'Syntax\n------\n\nJSON_QUERY(json_doc, path)\n\nDescription\n-----------\n\nGiven a JSON document, returns an object or array specified by the path.\nReturns NULL if not given a valid JSON document, or if there is no match.\n\nExamples\n--------\n\nselect json_query(\'{\"key1\":{\"a\":1, \"b\":[1,2]}}\', \'$.key1\');\n+-----------------------------------------------------+\n| json_query(\'{\"key1\":{\"a\":1, \"b\":[1,2]}}\', \'$.key1\') |\n+-----------------------------------------------------+\n| {\"a\":1, \"b\":[1,2]}                                  |\n+-----------------------------------------------------+\n\nselect json_query(\'{\"key1\":123, \"key1\": [1,2,3]}\', \'$.key1\');\n+-------------------------------------------------------+\n| json_query(\'{\"key1\":123, \"key1\": [1,2,3]}\', \'$.key1\') |\n+-------------------------------------------------------+\n| [1,2,3]                                               |\n+-------------------------------------------------------+\n\nURL: https://mariadb.com/kb/en/json_query/','','https://mariadb.com/kb/en/json_query/'),(748,'JSON_QUOTE',40,'Syntax\n------\n\nJSON_QUOTE(json_value)\n\nDescription\n-----------\n\nQuotes a string as a JSON value, usually for producing valid JSON string\nliterals for inclusion in JSON documents. Wraps the string with double quote\ncharacters and escapes interior quotes and other special characters, returning\na utf8mb4 string.\n\nReturns NULL if the argument is NULL.\n\nExamples\n--------\n\nSELECT JSON_QUOTE(\'A\'), JSON_QUOTE(\"B\"), JSON_QUOTE(\'\"C\"\');\n+-----------------+-----------------+-------------------+\n| JSON_QUOTE(\'A\') | JSON_QUOTE(\"B\") | JSON_QUOTE(\'\"C\"\') |\n+-----------------+-----------------+-------------------+\n| \"A\"             | \"B\"             | \"\\\"C\\\"\"           |\n+-----------------+-----------------+-------------------+\n\nURL: https://mariadb.com/kb/en/json_quote/','','https://mariadb.com/kb/en/json_quote/'),(749,'JSON_REMOVE',40,'Syntax\n------\n\nJSON_REMOVE(json_doc, path[, path] ...)\n\nDescription\n-----------\n\nRemoves data from a JSON document returning the result, or NULL if any of the\narguments are null. If the element does not exist in the document, no changes\nare made.\n\nAn error will occur if JSON document is invalid, the path is invalid or if the\npath contains a * or ** wildcard.\n\nPath arguments are evaluated from left to right, with the result from the\nearlier evaluation being used as the value for the next.\n\nExamples\n--------\n\nSELECT JSON_REMOVE(\'{\"A\": 1, \"B\": 2, \"C\": {\"D\": 3}}\', \'$.C\');\n+-------------------------------------------------------+\n| JSON_REMOVE(\'{\"A\": 1, \"B\": 2, \"C\": {\"D\": 3}}\', \'$.C\') |\n+-------------------------------------------------------+\n| {\"A\": 1, \"B\": 2}                                      |\n+-------------------------------------------------------+\n\nSELECT JSON_REMOVE(\'[\"A\", \"B\", [\"C\", \"D\"], \"E\"]\', \'$[1]\');\n+----------------------------------------------------+\n| JSON_REMOVE(\'[\"A\", \"B\", [\"C\", \"D\"], \"E\"]\', \'$[1]\') |\n+----------------------------------------------------+\n| [\"A\", [\"C\", \"D\"], \"E\"]                             |\n+----------------------------------------------------+\n\nURL: https://mariadb.com/kb/en/json_remove/','','https://mariadb.com/kb/en/json_remove/'),(750,'JSON_REPLACE',40,'Syntax\n------\n\nJSON_REPLACE(json_doc, path, val[, path, val] ...)\n\nDescription\n-----------\n\nReplaces existing values in a JSON document, returning the result, or NULL if\nany of the arguments are NULL.\n\nAn error will occur if the JSON document is invalid, the path is invalid or if\nthe path contains a * or ** wildcard.\n\nPaths and values are evaluated from left to right, with the result from the\nearlier evaluation being used as the value for the next.\n\nJSON_REPLACE can only update data, while JSON_INSERT can only insert. JSON_SET\ncan update or insert data.\n\nExamples\n--------\n\nSELECT JSON_REPLACE(\'{ \"A\": 1, \"B\": [2, 3]}\', \'$.B[1]\', 4);\n+-----------------------------------------------------+\n| JSON_REPLACE(\'{ \"A\": 1, \"B\": [2, 3]}\', \'$.B[1]\', 4) |\n+-----------------------------------------------------+\n| { \"A\": 1, \"B\": [2, 4]}                              |\n+-----------------------------------------------------+\n\nURL: https://mariadb.com/kb/en/json_replace/','','https://mariadb.com/kb/en/json_replace/'),(751,'JSON_SEARCH',40,'Syntax\n------\n\nJSON_SEARCH(json_doc, return_arg, search_str[, escape_char[, path] ...])\n\nDescription\n-----------\n\nReturns the path to the given string within a JSON document, or NULL if any of\njson_doc, search_str or a path argument is NULL; if the search string is not\nfound, or if no path exists within the document.\n\nA warning will occur if the JSON document is not valid, any of the path\narguments are not valid, if return_arg is neither one nor all, or if the\nescape character is not a constant. NULL will be returned.\n\nreturn_arg can be one of two values:\n\n* \'one: Terminates after finding the first match, so will return one path\nstring. If there is more than one match, it is undefined which is considered\nfirst.\n* all: Returns all matching path strings, without duplicates. Multiple strings\nare autowrapped as an array. The order is undefined.\n\nExamples\n--------\n\nSET @json = \'[\"A\", [{\"B\": \"1\"}], {\"C\":\"AB\"}, {\"D\":\"BC\"}]\';\n\nSELECT JSON_SEARCH(@json, \'one\', \'AB\');\n+---------------------------------+\n| JSON_SEARCH(@json, \'one\', \'AB\') |\n+---------------------------------+\n| \"$[2].C\"                        |\n+---------------------------------+\n\nURL: https://mariadb.com/kb/en/json_search/','','https://mariadb.com/kb/en/json_search/'),(752,'JSON_SET',40,'Syntax\n------\n\nJSON_SET(json_doc, path, val[, path, val] ...)\n\nDescription\n-----------\n\nUpdates or inserts data into a JSON document, returning the result, or NULL if\nany of the arguments are NULL or the optional path fails to find an object.\n\nAn error will occur if the JSON document is invalid, the path is invalid or if\nthe path contains a * or wildcard.\n\nJSON_SET can update or insert data, while JSON_REPLACE can only update, and\nJSON_INSERT only insert.\n\nExamples\n--------\n\nSELECT JSON_SET(Priv, \'$.locked\', \'true\') FROM mysql.global_priv\n\nURL: https://mariadb.com/kb/en/json_set/','','https://mariadb.com/kb/en/json_set/'),(753,'JSON_TYPE',40,'Syntax\n------\n\nJSON_TYPE(json_val)\n\nDescription\n-----------\n\nReturns the type of a JSON value (as a string), or NULL if the argument is\nnull.\n\nAn error will occur if the argument is an invalid JSON value.\n\nThe following is a complete list of the possible return types:\n\n+-----------------------------------+-----------------+-----------------------+\n| Return type                       | Value           | Example               |\n+-----------------------------------+-----------------+-----------------------+\n| ARRAY                             | JSON array      | [1, 2, {\"key\":        |\n|                                   |                 | \"value\"}]             |\n+-----------------------------------+-----------------+-----------------------+\n| OBJECT                            | JSON object     | {\"key\":\"value\"}       |\n+-----------------------------------+-----------------+-----------------------+\n| BOOLEAN                           | JSON            | true, false           |\n|                                   | true/false      |                       |\n|                                   | literals        |                       |\n+-----------------------------------+-----------------+-----------------------+\n| DOUBLE                            | A number with   | 1.2                   |\n|                                   | at least one    |                       |\n|                                   | floating point  |                       |\n|                                   | decimal.        |                       |\n+-----------------------------------+-----------------+-----------------------+\n| INTEGER                           | A number        | 1                     |\n|                                   | without a       |                       |\n|                                   | floating point  |                       |\n|                                   | decimal.        |                       |\n+-----------------------------------+-----------------+-----------------------+\n| NULL                              | JSON null       | null                  |\n|                                   | literal (this   |                       |\n|                                   | is returned as  |                       |\n|                                   | a string, not   |                       |\n|                                   | to be confused  |                       |\n|                                   | with the SQL    |                       |\n|                                   | NULL value!)    |                       |\n+-----------------------------------+-----------------+-----------------------+\n| STRING                            | JSON String     | \"a sample string\"     |\n+-----------------------------------+-----------------+-----------------------+\n\nExamples\n--------\n\nSELECT JSON_TYPE(\'{\"A\": 1, \"B\": 2, \"C\": 3}\');\n+---------------------------------------+\n| JSON_TYPE(\'{\"A\": 1, \"B\": 2, \"C\": 3}\') |\n+---------------------------------------+\n| OBJECT                                |\n+---------------------------------------+\n\nURL: https://mariadb.com/kb/en/json_type/','','https://mariadb.com/kb/en/json_type/'),(754,'JSON_UNQUOTE',40,'Syntax\n------\n\nJSON_UNQUOTE(val)\n\nDescription\n-----------\n\nUnquotes a JSON value, returning a string, or NULL if the argument is null.\n\nAn error will occur if the given value begins and ends with double quotes and\nis an invalid JSON string literal.\n\nIf the given value is not a JSON string, value is passed through unmodified.\n\nCertain character sequences have special meanings within a string. Usually, a\nbackslash is ignored, but the escape sequences in the table below are\nrecognised by MariaDB, unless the SQL Mode is set to NO_BACKSLASH_ESCAPES SQL.\n\n+-----------------------------------------------+-----------------------------+\n| Escape sequence                               | Character                   |\n+-----------------------------------------------+-----------------------------+\n| \\\"                                            | Double quote (\")            |\n+-----------------------------------------------+-----------------------------+\n| \\b                                            | Backslash                   |\n+-----------------------------------------------+-----------------------------+\n| \\f                                            | Formfeed                    |\n+-----------------------------------------------+-----------------------------+\n| \\n                                            | Newline (linefeed)          |\n+-----------------------------------------------+-----------------------------+\n| \\r                                            | Carriage return             |\n+-----------------------------------------------+-----------------------------+\n| \\t                                            | Tab                         |\n+-----------------------------------------------+-----------------------------+\n| \\\\                                            | Backslash (\\)               |\n+-----------------------------------------------+-----------------------------+\n| \\uXXXX                                        | UTF-8 bytes for Unicode     |\n|                                               | value XXXX                  |\n+-----------------------------------------------+-----------------------------+\n\nExamples\n--------\n\nSELECT JSON_UNQUOTE(\'\"Monty\"\');\n+-------------------------+\n| JSON_UNQUOTE(\'\"Monty\"\') |\n+-------------------------+\n| Monty                   |\n+-------------------------+\n\nWith the default SQL Mode:\n\nSELECT JSON_UNQUOTE(\'Si\\bng\\ting\');\n+-----------------------------+\n| JSON_UNQUOTE(\'Si\\bng\\ting\') |\n+-----------------------------+\n| Sng	ing                   |\n+-----------------------------+\n\nSetting NO_BACKSLASH_ESCAPES:\n\nSET @@sql_mode = \'NO_BACKSLASH_ESCAPES\';\n\nSELECT JSON_UNQUOTE(\'Si\\bng\\ting\');\n+-----------------------------+\n| JSON_UNQUOTE(\'Si\\bng\\ting\') |\n+-----------------------------+\n| Si\\bng\\ting                 |\n+-----------------------------+\n\nURL: https://mariadb.com/kb/en/json_unquote/','','https://mariadb.com/kb/en/json_unquote/'),(755,'JSON_VALID',40,'Syntax\n------\n\nJSON_VALID(value)\n\nDescription\n-----------\n\nIndicates whether the given value is a valid JSON document or not. Returns 1\nif valid, 0 if not, and NULL if the argument is NULL.\n\nFrom MariaDB 10.4.3, the JSON_VALID function is automatically used as a CHECK\nconstraint for the JSON data type alias in order to ensure that a valid json\ndocument is inserted.\n\nExamples\n--------\n\nSELECT JSON_VALID(\'{\"id\": 1, \"name\": \"Monty\"}\');\n+------------------------------------------+\n| JSON_VALID(\'{\"id\": 1, \"name\": \"Monty\"}\') |\n+------------------------------------------+\n|                                        1 |\n+------------------------------------------+\n\nSELECT JSON_VALID(\'{\"id\": 1, \"name\": \"Monty\", \"oddfield\"}\');\n+------------------------------------------------------+\n| JSON_VALID(\'{\"id\": 1, \"name\": \"Monty\", \"oddfield\"}\') |\n+------------------------------------------------------+\n|                                                    0 |\n+------------------------------------------------------+\n\nURL: https://mariadb.com/kb/en/json_valid/','','https://mariadb.com/kb/en/json_valid/'),(756,'JSON_VALUE',40,'Syntax\n------\n\nJSON_VALUE(json_doc, path)\n\nDescription\n-----------\n\nGiven a JSON document, returns the scalar specified by the path. Returns NULL\nif not given a valid JSON document, or if there is no match.\n\nExamples\n--------\n\nselect json_value(\'{\"key1\":123}\', \'$.key1\');\n+--------------------------------------+\n| json_value(\'{\"key1\":123}\', \'$.key1\') |\n+--------------------------------------+\n| 123                                  |\n+--------------------------------------+\n\nselect json_value(\'{\"key1\": [1,2,3], \"key1\":123}\', \'$.key1\');\n+-------------------------------------------------------+\n| json_value(\'{\"key1\": [1,2,3], \"key1\":123}\', \'$.key1\') |\n+-------------------------------------------------------+\n| 123                                                   |\n+-------------------------------------------------------+\n\nIn the SET statement below, two escape characters are needed, as a single\nescape character would be applied by the SQL parser in the SET statement, and\nthe escaped character would not form part of the saved value.\n\nSET @json = \'{\"key1\":\"60\\\\\" Table\", \"key2\":\"1\"}\';\n\nSELECT JSON_VALUE(@json,\'$.key1\') AS Name , json_value(@json,\'$.key2\') as ID;\n+-----------+------+\n| Name      | ID   |\n+-----------+------+\n| 60\" Table | 1    |\n+-----------+------+\n\nURL: https://mariadb.com/kb/en/json_value/','','https://mariadb.com/kb/en/json_value/'),(757,'Window Functions Overview',41,'Introduction\n------------\n\nWindow functions allow calculations to be performed across a set of rows\nrelated to the current row.\n\nSyntax\n------\n\nfunction (expression) OVER (\n [ PARTITION BY expression_list ]\n [ ORDER BY order_list [ frame_clause ] ] )\n\nfunction:\n A valid window function\n\nexpression_list:\n expression | column_name [, expr_list ]\n\norder_list:\n expression | column_name [ ASC | DESC ]\n [, ... ]\n\nframe_clause:\n {ROWS | RANGE} {frame_border | BETWEEN frame_border AND frame_border}\n\nframe_border:\n | UNBOUNDED PRECEDING\n | UNBOUNDED FOLLOWING\n | CURRENT ROW\n | expr PRECEDING\n | expr FOLLOWING\n\nDescription\n-----------\n\nIn some ways, window functions are similar to aggregate functions in that they\nperform calculations across a set of rows. However, unlike aggregate\nfunctions, the output is not grouped into a single row.\n\nNon-aggregate window functions include\n\n* CUME_DIST\n* DENSE_RANK\n* FIRST_VALUE\n* LAG\n* LAST_VALUE\n* LEAD\n* MEDIAN\n* NTH_VALUE\n* NTILE\n* PERCENT_RANK\n* PERCENTILE_CONT\n* PERCENTILE_DISC\n* RANK, ROW_NUMBER\n\nAggregate functions that can also be used as window functions include\n\n* AVG\n* BIT_AND\n* BIT_OR\n* BIT_XOR\n* COUNT\n* MAX\n* MIN\n* STD\n* STDDEV\n* STDDEV_POP\n* STDDEV_SAMP\n* SUM\n* VAR_POP\n* VAR_SAMP\n* VARIANCE\n\nWindow function queries are characterised by the OVER keyword, following which\nthe set of rows used for the calculation is specified. By default, the set of\nrows used for the calculation (the \"window) is the entire dataset, which can\nbe ordered with the ORDER BY clause. The PARTITION BY clause is used to reduce\nthe window to a particular group within the dataset.\n\nFor example, given the following data:\n\nCREATE TABLE student (name CHAR(10), test CHAR(10), score TINYINT);\n\nINSERT INTO student VALUES \n (\'Chun\', \'SQL\', 75), (\'Chun\', \'Tuning\', 73),\n (\'Esben\', \'SQL\', 43), (\'Esben\', \'Tuning\', 31),\n (\'Kaolin\', \'SQL\', 56), (\'Kaolin\', \'Tuning\', 88),\n (\'Tatiana\', \'SQL\', 87), (\'Tatiana\', \'Tuning\', 83);\n\nthe following two queries return the average partitioned by test and by name\nrespectively:\n\nSELECT name, test, score, AVG(score) OVER (PARTITION BY test) \n AS average_by_test FROM student;\n+---------+--------+-------+-----------------+\n| name    | test   | score | average_by_test |\n+---------+--------+-------+-----------------+\n| Chun    | SQL    |    75 |         65.2500 |\n| Chun    | Tuning |    73 |         68.7500 |\n| Esben   | SQL    |    43 |         65.2500 |\n| Esben   | Tuning |    31 |         68.7500 |\n| Kaolin  | SQL    |    56 |         65.2500 |\n| Kaolin  | Tuning |    88 |         68.7500 |\n| Tatiana | SQL    |    87 |         65.2500 |\n| Tatiana | Tuning |    83 |         68.7500 |\n+---------+--------+-------+-----------------+\n\nSELECT name, test, score, AVG(score) OVER (PARTITION BY name) \n AS average_by_name FROM student;\n+---------+--------+-------+-----------------+\n| name    | test   | score | average_by_name |\n+---------+--------+-------+-----------------+\n| Chun    | SQL    |    75 |         74.0000 |\n| Chun    | Tuning |    73 |         74.0000 |\n| Esben   | SQL    |    43 |         37.0000 |\n| Esben   | Tuning |    31 |         37.0000 |\n| Kaolin  | SQL    |    56 |         72.0000 |\n| Kaolin  | Tuning |    88 |         72.0000 |\n| Tatiana | SQL    |    87 |         85.0000 |\n| Tatiana | Tuning |    83 |         85.0000 |\n+---------+--------+-------+-----------------+\n\nIt is also possible to specify which rows to include for the window function\n(for example, the current row and all preceding rows). See Window Frames for\nmore details.\n\nScope\n-----\n\nWindow functions were introduced in SQL:2003, and their definition was\nexpanded in subsequent versions of the standard. The last expansion was in the\nlatest version of the standard, SQL:2011.\n\nMost database products support a subset of the standard, they implement some\nfunctions defined as late as in SQL:2011, and at the same time leave some\nparts of SQL:2008 unimplemented.\n\nMariaDB:\n\n* Supports ROWS and RANGE-type frames\nAll kinds of frame bounds are supported, including RANGE PRECEDING|FOLLOWING n\nframe bounds (unlike PostgreSQL or MS SQL Server)\nDoes not yet support DATE[TIME] datatype and arithmetic for RANGE-type frames\n(MDEV-9727)\n\n* Does not support GROUPS-type frames (it seems that no popular database\nsupports it, either)\n\n* Does not support frame exclusion (no other database seems to support it,\neither) (MDEV-9724)\n* Does not support explicit NULLS FIRST or NULLS LAST.\n* Does not support nested navigation in window functions (this is\nVALUE_OF(expr AT row_marker [, default_value) syntax)\n\n* The following window functions are supported:\n\"Streamable\" window functions: ROW_NUMBER, RANK, DENSE_RANK, \nWindow functions that can be streamed once the number of rows in partition is\nknown: PERCENT_RANK, CUME_DIST, NTILE\n\n* Aggregate functions that are currently supported as window functions are:\nCOUNT, SUM, AVG, BIT_OR, BIT_AND, BIT_XOR.\n* Aggregate functions with the DISTINCT specifier (e.g. COUNT( DISTINCT x))\nare not supported as window functions.\n\nLinks\n-----\n\n* MDEV-6115 is the main jira task for window functions development. Other\ntasks are are attached as sub-tasks\n* bb-10.2-mdev9543 is the feature tree for window functions. Development is\nongoing, and this tree has the newest changes.\n* Testcases are in mysql-test/t/win*.test\n\nExamples\n--------\n\nGiven the following sample data:\n\nCREATE TABLE users (\n email VARCHAR(30),\n first_name VARCHAR(30),\n last_name VARCHAR(30),\n account_type VARCHAR(30)\n);\n\nINSERT INTO users VALUES \n (\'admin@boss.org\', \'Admin\', \'Boss\', \'admin\'),\n (\'bob.carlsen@foo.bar\', \'Bob\', \'Carlsen\', \'regular\'),\n (\'eddie.stevens@data.org\', \'Eddie\', \'Stevens\', \'regular\'),\n (\'john.smith@xyz.org\', \'John\', \'Smith\', \'regular\'),\n (\'root@boss.org\', \'Root\', \'Chief\', \'admin\')\n\nFirst, let\'s order the records by email alphabetically, giving each an\nascending rnum value starting with 1. This will make use of the ROW_NUMBER\nwindow function:\n\nSELECT row_number() OVER (ORDER BY email) AS rnum,\n  email, first_name, last_name, account_type\nFROM users ORDER BY email;\n+------+------------------------+------------+-----------+--------------+\n| rnum | email                  | first_name | last_name | account_type |\n+------+------------------------+------------+-----------+--------------+\n|    1 | admin@boss.org         | Admin      | Boss      | admin        |\n|    2 | bob.carlsen@foo.bar    | Bob        | Carlsen   | regular      |\n|    3 | eddie.stevens@data.org | Eddie      | Stevens   | regular      |\n|    4 | john.smith@xyz.org     | John       | Smith     | regular      |\n|    5 | root@boss.org          | Root       | Chief     | admin        |\n+------+------------------------+------------+-----------+--------------\n\nWe can generate separate sequences based on account type, using the PARTITION\nBY clause:\n\nSELECT row_number() OVER (PARTITION BY account_type ORDER BY email) AS rnum, \n email, first_name, last_name, account_type\nFROM users ORDER BY account_type,email;\n+------+------------------------+------------+-----------+--------------+\n| rnum | email                  | first_name | last_name | account_type |\n+------+------------------------+------------+-----------+--------------+\n|    1 | admin@boss.org         | Admin      | Boss      | admin        |\n|    2 | root@boss.org          | Root       | Chief     | admin        |\n|    1 | bob.carlsen@foo.bar    | Bob        | Carlsen   | regular      |\n|    2 | eddie.stevens@data.org | Eddie      | Stevens   | regular      |\n|    3 | john.smith@xyz.org     | John       | Smith     | regular      |\n+------+------------------------+------------+-----------+--------------+\n\nGiven the following structure and data, we want to find the top 5 salaries\nfrom each department.\n\nCREATE TABLE employee_salaries (dept VARCHAR(20), name VARCHAR(20), salary\nINT(11));\n\nINSERT INTO employee_salaries VALUES\n(\'Engineering\', \'Dharma\', 3500),\n(\'Engineering\', \'Binh\', 3000),\n(\'Engineering\', \'Adalynn\', 2800),\n(\'Engineering\', \'Samuel\', 2500),\n(\'Engineering\', \'Cveta\', 2200),\n(\'Engineering\', \'Ebele\', 1800),\n(\'Sales\', \'Carbry\', 500),\n(\'Sales\', \'Clytemnestra\', 400),\n(\'Sales\', \'Juraj\', 300),\n(\'Sales\', \'Kalpana\', 300),\n(\'Sales\', \'Svantepolk\', 250),\n(\'Sales\', \'Angelo\', 200);\n\nWe could do this without using window functions, as follows:\n\nselect dept, name, salary\nfrom employee_salaries as t1\nwhere (select count(t2.salary)\n   from employee_salaries as t2\n   where t1.name != t2.name and\n      t1.dept = t2.dept and\n      t2.salary > t1.salary) < 5\norder by dept, salary desc;\n\n+-------------+--------------+--------+\n| dept        | name         | salary |\n+-------------+--------------+--------+\n| Engineering | Dharma       |   3500 |\n| Engineering | Binh         |   3000 |\n| Engineering | Adalynn      |   2800 |\n| Engineering | Samuel       |   2500 |\n| Engineering | Cveta        |   2200 |\n| Sales       | Carbry       |    500 |\n| Sales       | Clytemnestra |    400 |\n| Sales       | Juraj        |    300 |\n| Sales       | Kalpana      |    300 |\n| Sales       | Svantepolk   |    250 |\n+-------------+--------------+--------+\n\nThis has a number of disadvantages:\n\n* if there is no index, the query could take a long time if the\nemployee_salary_table is large\n* Adding and maintaining indexes adds overhead, and even with indexes on dept\nand salary, each subquery execution adds overhead by performing a lookup\nthrough the index.\n\nLet\'s try achieve the same with window functions. First, generate a rank for\nall employees, using the RANK function.\n\nselect rank() over (partition by dept order by salary desc) as ranking,\n  dept, name, salary\n  from employee_salaries\n  order by dept, ranking;\n+---------+-------------+--------------+--------+\n| ranking | dept        | name         | salary |\n+---------+-------------+--------------+--------+\n|       1 | Engineering | Dharma       |   3500 |\n|       2 | Engineering | Binh         |   3000 |\n|       3 | Engineering | Adalynn      |   2800 |\n|       4 | Engineering | Samuel       |   2500 |\n|       5 | Engineering | Cveta        |   2200 |\n|       6 | Engineering | Ebele        |   1800 |\n|       1 | Sales       | Carbry       |    500 |\n|       2 | Sales       | Clytemnestra |    400 |\n|       3 | Sales       | Juraj        |    300 |\n|       3 | Sales       | Kalpana      |    300 |\n|       5 | Sales       | Svantepolk   |    250 |\n|       6 | Sales       | Angelo       |    200 |\n+---------+-------------+--------------+--------+\n\nEach department has a separate sequence of ranks due to the PARTITION BY\nclause. This particular sequence of values for rank() is given by the ORDER BY\nclause inside the window function’s OVER clause. Finally, to get our results\nin a readable format we order the data by dept and the newly generated ranking\ncolumn.\n\nNow, we need to reduce the results to find only the top 5 per department. Here\nis a common mistake:\n\nselect\nrank() over (partition by dept order by salary desc) as ranking,\ndept, name, salary\nfrom employee_salaries\nwhere ranking <= 5\norder by dept, ranking;\n\nERROR 1054 (42S22): Unknown column \'ranking\' in \'where clause\'\n\nTrying to filter only the first 5 values per department by putting a where\nclause in the statement does not work, due to the way window functions are\ncomputed. The computation of window functions happens after all WHERE, GROUP\nBY and HAVING clauses have been completed, right before ORDER BY, so the WHERE\nclause has no idea that the ranking column exists. It is only present after we\nhave filtered and grouped all the rows.\n\nTo counteract this problem, we need to wrap our query into a derived table. We\ncan then attach a where clause to it:\n\nselect *from (select rank() over (partition by dept order by salary desc) as\nranking,\n dept, name, salary\nfrom employee_salaries) as salary_ranks\nwhere (salary_ranks.ranking <= 5)\n order by dept, ranking;\n+---------+-------------+--------------+--------+\n| ranking | dept        | name         | salary |\n+---------+-------------+--------------+--------+\n|       1 | Engineering | Dharma       |   3500 |\n|       2 | Engineering | Binh         |   3000 |\n|       3 | Engineering | Adalynn      |   2800 |\n|       4 | Engineering | Samuel       |   2500 |\n|       5 | Engineering | Cveta        |   2200 |\n|       1 | Sales       | Carbry       |    500 |\n|       2 | Sales       | Clytemnestra |    400 |\n|       3 | Sales       | Juraj        |    300 |\n|       3 | Sales       | Kalpana      |    300 |\n|       5 | Sales       | Svantepolk   |    250 |\n+---------+-------------+--------------+--------+\n\nURL: https://mariadb.com/kb/en/window-functions-overview/','','https://mariadb.com/kb/en/window-functions-overview/'),(758,'CUME_DIST',41,'Syntax\n------\n\nCUME_DIST() OVER ( \n [ PARTITION BY partition_expression ]\n [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nCUME_DIST() is a window function that returns the cumulative distribution of a\ngiven row. The following formula is used to calculate the value:\n\n(number of rows <= current row) / (total rows)\n\nExamples\n--------\n\ncreate table t1 (\n pk int primary key,\n a int,\n b int\n);\n\ninsert into t1 values\n( 1 , 0, 10),\n( 2 , 0, 10),\n( 3 , 1, 10),\n( 4 , 1, 10),\n( 8 , 2, 10),\n( 5 , 2, 20),\n( 6 , 2, 20),\n( 7 , 2, 20),\n( 9 , 4, 20),\n(10 , 4, 20);\n\nselect pk, a, b,\n  rank() over (order by a) as rank,\n  percent_rank() over (order by a) as pct_rank,\n  cume_dist() over (order by a) as cume_dist\nfrom t1;\n+----+------+------+------+--------------+--------------+\n| pk | a    | b    | rank | pct_rank     | cume_dist    |\n+----+------+------+------+--------------+--------------+\n|  1 |    0 |   10 |    1 | 0.0000000000 | 0.2000000000 |\n|  2 |    0 |   10 |    1 | 0.0000000000 | 0.2000000000 |\n|  3 |    1 |   10 |    3 | 0.2222222222 | 0.4000000000 |\n|  4 |    1 |   10 |    3 | 0.2222222222 | 0.4000000000 |\n|  5 |    2 |   20 |    5 | 0.4444444444 | 0.8000000000 |\n|  6 |    2 |   20 |    5 | 0.4444444444 | 0.8000000000 |\n|  7 |    2 |   20 |    5 | 0.4444444444 | 0.8000000000 |\n|  8 |    2 |   10 |    5 | 0.4444444444 | 0.8000000000 |\n|  9 |    4 |   20 |    9 | 0.8888888889 | 1.0000000000 |\n| 10 |    4 |   20 |    9 | 0.8888888889 | 1.0000000000 |\n+----+------+------+------+--------------+--------------+\n\nselect pk, a, b,\n   percent_rank() over (order by pk) as pct_rank,\n   cume_dist() over (order by pk) as cume_dist\nfrom t1 order by pk;\n+----+------+------+--------------+--------------+\n| pk | a    | b    | pct_rank     | cume_dist    |\n+----+------+------+--------------+--------------+\n|  1 |    0 |   10 | 0.0000000000 | 0.1000000000 |\n|  2 |    0 |   10 | 0.1111111111 | 0.2000000000 |\n|  3 |    1 |   10 | 0.2222222222 | 0.3000000000 |\n|  4 |    1 |   10 | 0.3333333333 | 0.4000000000 |\n|  5 |    2 |   20 | 0.4444444444 | 0.5000000000 |\n|  6 |    2 |   20 | 0.5555555556 | 0.6000000000 |\n|  7 |    2 |   20 | 0.6666666667 | 0.7000000000 |\n|  8 |    2 |   10 | 0.7777777778 | 0.8000000000 |\n|  9 |    4 |   20 | 0.8888888889 | 0.9000000000 |\n| 10 |    4 |   20 | 1.0000000000 | 1.0000000000 |\n+----+------+------+--------------+--------------+\n\nselect pk, a, b,\n    percent_rank() over (partition by a order by a) as pct_rank,\n    cume_dist() over (partition by a order by a) as cume_dist\nfrom t1;\n+----+------+------+--------------+--------------+\n| pk | a    | b    | pct_rank     | cume_dist    |\n+----+------+------+--------------+--------------+\n|  1 |    0 |   10 | 0.0000000000 | 1.0000000000 |\n|  2 |    0 |   10 | 0.0000000000 | 1.0000000000 |\n|  3 |    1 |   10 | 0.0000000000 | 1.0000000000 |\n|  4 |    1 |   10 | 0.0000000000 | 1.0000000000 |\n|  5 |    2 |   20 | 0.0000000000 | 1.0000000000 |\n|  6 |    2 |   20 | 0.0000000000 | 1.0000000000 |\n|  7 |    2 |   20 | 0.0000000000 | 1.0000000000 |\n|  8 |    2 |   10 | 0.0000000000 | 1.0000000000 |\n|  9 |    4 |   20 | 0.0000000000 | 1.0000000000 |\n| 10 |    4 |   20 | 0.0000000000 | 1.0000000000 |\n+----+------+------+--------------+--------------+\n\nURL: https://mariadb.com/kb/en/cume_dist/','','https://mariadb.com/kb/en/cume_dist/'),(759,'DENSE_RANK',41,'Syntax\n------\n\nDENSE_RANK() OVER (\n [ PARTITION BY partition_expression ]\n [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nDENSE_RANK() is a window function that displays the number of a given row,\nstarting at one and following the ORDER BY sequence of the window function,\nwith identical values receiving the same result. Unlike the RANK() function,\nthere are no skipped values if the preceding results are identical. It is also\nsimilar to the ROW_NUMBER() function except that in that function, identical\nvalues will receive a different row number for each result.\n\nExamples\n--------\n\nThe distinction between DENSE_RANK(), RANK() and ROW_NUMBER():\n\nCREATE TABLE student(course VARCHAR(10), mark int, name varchar(10));\n\nINSERT INTO student VALUES \n (\'Maths\', 60, \'Thulile\'),\n (\'Maths\', 60, \'Pritha\'),\n (\'Maths\', 70, \'Voitto\'),\n (\'Maths\', 55, \'Chun\'),\n (\'Biology\', 60, \'Bilal\'),\n (\'Biology\', 70, \'Roger\');\n\nSELECT \n RANK() OVER (PARTITION BY course ORDER BY mark DESC) AS rank,\n DENSE_RANK() OVER (PARTITION BY course ORDER BY mark DESC) AS dense_rank,\n ROW_NUMBER() OVER (PARTITION BY course ORDER BY mark DESC) AS row_num,\n course, mark, name\nFROM student ORDER BY course, mark DESC;\n+------+------------+---------+---------+------+---------+\n| rank | dense_rank | row_num | course  | mark | name    |\n+------+------------+---------+---------+------+---------+\n|    1 |          1 |       1 | Biology |   70 | Roger   |\n|    2 |          2 |       2 | Biology |   60 | Bilal   |\n|    1 |          1 |       1 | Maths   |   70 | Voitto  |\n|    2 |          2 |       2 | Maths   |   60 | Thulile |\n|    2 |          2 |       3 | Maths   |   60 | Pritha  |\n|    4 |          3 |       4 | Maths   |   55 | Chun    |\n+------+------------+---------+---------+------+---------+\n\nURL: https://mariadb.com/kb/en/dense_rank/','','https://mariadb.com/kb/en/dense_rank/'),(760,'FIRST_VALUE',41,'Syntax\n------\n\nFIRST_VALUE(expr) OVER (\n [ PARTITION BY partition_expression ]\n [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nFIRST_VALUE returns the first result from an ordered set, or NULL if no such\nresult exists.\n\nExamples\n--------\n\nCREATE TABLE t1 (\n pk int primary key,\n a int,\n b int,\n c char(10),\n d decimal(10, 3),\n e real\n);\n\nINSERT INTO t1 VALUES\n( 1, 0, 1,    \'one\',    0.1,  0.001),\n( 2, 0, 2,    \'two\',    0.2,  0.002),\n( 3, 0, 3,    \'three\',  0.3,  0.003),\n( 4, 1, 2,    \'three\',  0.4,  0.004),\n( 5, 1, 1,    \'two\',    0.5,  0.005),\n( 6, 1, 1,    \'one\',    0.6,  0.006),\n( 7, 2, NULL, \'n_one\',  0.5,  0.007),\n( 8, 2, 1,    \'n_two\',  NULL, 0.008),\n( 9, 2, 2,    NULL,     0.7,  0.009),\n(10, 2, 0,    \'n_four\', 0.8,  0.010),\n(11, 2, 10,   NULL,     0.9,  NULL);\n\nSELECT pk, FIRST_VALUE(pk) OVER (ORDER BY pk) AS first_asc,\n     LAST_VALUE(pk) OVER (ORDER BY pk) AS last_asc,\n     FIRST_VALUE(pk) OVER (ORDER BY pk DESC) AS first_desc,\n     LAST_VALUE(pk) OVER (ORDER BY pk DESC) AS last_desc\nFROM t1\nORDER BY pk DESC;\n\n+----+-----------+----------+------------+-----------+\n| pk | first_asc | last_asc | first_desc | last_desc |\n+----+-----------+----------+------------+-----------+\n| 11 |         1 |       11 |         11 |        11 |\n| 10 |         1 |       10 |         11 |        10 |\n|  9 |         1 |        9 |         11 |         9 |\n|  8 |         1 |        8 |         11 |         8 |\n|  7 |         1 |        7 |         11 |         7 |\n|  6 |         1 |        6 |         11 |         6 |\n|  5 |         1 |        5 |         11 |         5 |\n|  4 |         1 |        4 |         11 |         4 |\n|  3 |         1 |        3 |         11 |         3 |\n|  2 |         1 |        2 |         11 |         2 |\n|  1 |         1 |        1 |         11 |         1 |\n+----+-----------+----------+------------+-----------+\n\nCREATE OR REPLACE TABLE t1 (i int);\nINSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);\n\nSELECT i,\n FIRST_VALUE(i) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW and 1 FOLLOWING) AS\nf_1f,\n LAST_VALUE(i) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW and 1 FOLLOWING) AS\nl_1f,\n FIRST_VALUE(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS\nf_1p1f,\n LAST_VALUE(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS\nf_1p1f,\n FIRST_VALUE(i) OVER (ORDER BY i ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) AS\nf_2p1p,\n LAST_VALUE(i) OVER (ORDER BY i ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING) AS\nf_2p1p,\n FIRST_VALUE(i) OVER (ORDER BY i ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING) AS\nf_1f2f,\n LAST_VALUE(i) OVER (ORDER BY i ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING) AS\nf_1f2f\nFROM t1;\n\n+------+------+------+--------+--------+--------+--------+--------+--------+\n| i    | f_1f | l_1f | f_1p1f | f_1p1f | f_2p1p | f_2p1p | f_1f2f | f_1f2f |\n+------+------+------+--------+--------+--------+--------+--------+--------+\n|    1 |    1 |    2 |      1 |      2 |   NULL |   NULL |      2 |      3 |\n|    2 |    2 |    3 |      1 |      3 |      1 |      1 |      3 |      4 |\n|    3 |    3 |    4 |      2 |      4 |      1 |      2 |      4 |      5 |\n|    4 |    4 |    5 |      3 |      5 |      2 |      3 |      5 |      6 |\n|    5 |    5 |    6 |      4 |      6 |      3 |      4 |      6 |      7 |\n|    6 |    6 |    7 |      5 |      7 |      4 |      5 |      7 |      8 |\n|    7 |    7 |    8 |      6 |      8 |      5 |      6 |      8 |      9 |\n|    8 |    8 |    9 |      7 |      9 |      6 |      7 |      9 |     10 |\n|    9 |    9 |   10 |      8 |     10 |      7 |      8 |     10 |     10 |\n|   10 |   10 |   10 |      9 |     10 |      8 |      9 |   NULL |   NULL |\n+------+------+------+--------+--------+--------+--------+--------+--------+\n\nURL: https://mariadb.com/kb/en/first_value/','','https://mariadb.com/kb/en/first_value/'),(761,'LAG',41,'Syntax\n------\n\nLAG (expr[, offset]) OVER ( \n [ PARTITION BY partition_expression ]\n < ORDER BY order_list >\n)\n\nDescription\n-----------\n\nThe LAG function accesses data from a previous row according to the ORDER BY\nclause without the need for a self-join. The specific row is determined by the\noffset (default 1), which specifies the number of rows behind the current row\nto use. An offset of 0 is the current row.\n\nExamples\n--------\n\nCREATE TABLE t1 (pk int primary key, a int, b int, c char(10), d decimal(10,\n3), e real);\n\nINSERT INTO t1 VALUES\n ( 1, 0, 1,    \'one\',    0.1,  0.001),\n ( 2, 0, 2,    \'two\',    0.2,  0.002),\n ( 3, 0, 3,    \'three\',  0.3,  0.003),\n ( 4, 1, 2,    \'three\',  0.4,  0.004),\n ( 5, 1, 1,    \'two\',    0.5,  0.005),\n ( 6, 1, 1,    \'one\',    0.6,  0.006),\n ( 7, 2, NULL, \'n_one\',  0.5,  0.007),\n ( 8, 2, 1,    \'n_two\',  NULL, 0.008),\n ( 9, 2, 2,    NULL,     0.7,  0.009),\n (10, 2, 0,    \'n_four\', 0.8,  0.010),\n (11, 2, 10,   NULL,     0.9,  NULL);\n\nSELECT pk, LAG(pk) OVER (ORDER BY pk) AS l,\n LAG(pk,1) OVER (ORDER BY pk) AS l1,\n LAG(pk,2) OVER (ORDER BY pk) AS l2,\n LAG(pk,0) OVER (ORDER BY pk) AS l0,\n LAG(pk,-1) OVER (ORDER BY pk) AS lm1,\n LAG(pk,-2) OVER (ORDER BY pk) AS lm2\nFROM t1;\n+----+------+------+------+------+------+------+\n| pk | l    | l1   | l2   | l0   | lm1  | lm2  |\n+----+------+------+------+------+------+------+\n|  1 | NULL | NULL | NULL |    1 |    2 |    3 |\n|  2 |    1 |    1 | NULL |    2 |    3 |    4 |\n|  3 |    2 |    2 |    1 |    3 |    4 |    5 |\n|  4 |    3 |    3 |    2 |    4 |    5 |    6 |\n|  5 |    4 |    4 |    3 |    5 |    6 |    7 |\n|  6 |    5 |    5 |    4 |    6 |    7 |    8 |\n|  7 |    6 |    6 |    5 |    7 |    8 |    9 |\n|  8 |    7 |    7 |    6 |    8 |    9 |   10 |\n|  9 |    8 |    8 |    7 |    9 |   10 |   11 |\n| 10 |    9 |    9 |    8 |   10 |   11 | NULL |\n| 11 |   10 |   10 |    9 |   11 | NULL | NULL |\n+----+------+------+------+------+------+------+\n\nURL: https://mariadb.com/kb/en/lag/','','https://mariadb.com/kb/en/lag/'),(762,'LEAD',41,'Syntax\n------\n\nLEAD (expr[, offset]) OVER ( \n [ PARTITION BY partition_expression ]\n [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nThe LEAD function accesses data from a following row in the same result set\nwithout the need for a self-join. The specific row is determined by the offset\n(default 1), which specifies the number of rows ahead the current row to use.\nAn offset of 0 is the current row.\n\nExample\n-------\n\nCREATE TABLE t1 (pk int primary key, a int, b int, c char(10), d decimal(10,\n3), e real);\n\nINSERT INTO t1 VALUES\n ( 1, 0, 1,    \'one\',    0.1,  0.001),\n ( 2, 0, 2,    \'two\',    0.2,  0.002),\n ( 3, 0, 3,    \'three\',  0.3,  0.003),\n ( 4, 1, 2,    \'three\',  0.4,  0.004),\n ( 5, 1, 1,    \'two\',    0.5,  0.005),\n ( 6, 1, 1,    \'one\',    0.6,  0.006),\n ( 7, 2, NULL, \'n_one\',  0.5,  0.007),\n ( 8, 2, 1,    \'n_two\',  NULL, 0.008),\n ( 9, 2, 2,    NULL,     0.7,  0.009),\n (10, 2, 0,    \'n_four\', 0.8,  0.010),\n (11, 2, 10,   NULL,     0.9,  NULL);\n\nSELECT pk, LEAD(pk) OVER (ORDER BY pk) AS l,\n LEAD(pk,1) OVER (ORDER BY pk) AS l1,\n LEAD(pk,2) OVER (ORDER BY pk) AS l2,\n LEAD(pk,0) OVER (ORDER BY pk) AS l0,\n LEAD(pk,-1) OVER (ORDER BY pk) AS lm1,\n LEAD(pk,-2) OVER (ORDER BY pk) AS lm2\nFROM t1;\n+----+------+------+------+------+------+------+\n| pk | l    | l1   | l2   | l0   | lm1  | lm2  |\n+----+------+------+------+------+------+------+\n|  1 |    2 |    2 |    3 |    1 | NULL | NULL |\n|  2 |    3 |    3 |    4 |    2 |    1 | NULL |\n|  3 |    4 |    4 |    5 |    3 |    2 |    1 |\n|  4 |    5 |    5 |    6 |    4 |    3 |    2 |\n|  5 |    6 |    6 |    7 |    5 |    4 |    3 |\n|  6 |    7 |    7 |    8 |    6 |    5 |    4 |\n|  7 |    8 |    8 |    9 |    7 |    6 |    5 |\n|  8 |    9 |    9 |   10 |    8 |    7 |    6 |\n|  9 |   10 |   10 |   11 |    9 |    8 |    7 |\n| 10 |   11 |   11 | NULL |   10 |    9 |    8 |\n| 11 | NULL | NULL | NULL |   11 |   10 |    9 |\n+----+------+------+------+------+------+------+\n\nURL: https://mariadb.com/kb/en/lead/','','https://mariadb.com/kb/en/lead/'),(763,'Median Window Function',41,'MariaDB starting with 10.3.3\n----------------------------\nThe MEDIAN() window function was first introduced with in MariaDB 10.3.3.\n\nSyntax\n------\n\nMEDIAN(median expression) OVER (\n [ PARTITION BY partition_expression ]\n)\n\nDescription\n-----------\n\nMEDIAN() is a window function that returns the median value of a range of\nvalues.\n\nIt is a specific case of PERCENTILE_CONT, with an argument of 0.5 and the\nORDER BY column the one in MEDIAN\'s argument.\n\nMEDIAN(<median-arg>) OVER ( [ PARTITION BY partition_expression] )\n\nIs equivalent to:\n\nPERCENTILE_CONT(0.5) WITHIN \n GROUP (ORDER BY <median-arg>) OVER ( [ PARTITION BY partition_expression ])\n\nExamples\n--------\n\nCREATE TABLE book_rating (name CHAR(30), star_rating TINYINT);\n\nINSERT INTO book_rating VALUES (\'Lord of the Ladybirds\', 5);\nINSERT INTO book_rating VALUES (\'Lord of the Ladybirds\', 3);\nINSERT INTO book_rating VALUES (\'Lady of the Flies\', 1);\nINSERT INTO book_rating VALUES (\'Lady of the Flies\', 2);\nINSERT INTO book_rating VALUES (\'Lady of the Flies\', 5);\n\nSELECT name, median(star_rating) OVER (PARTITION BY name) FROM book_rating;\n+-----------------------+----------------------------------------------+\n| name                  | median(star_rating) OVER (PARTITION BY name) |\n+-----------------------+----------------------------------------------+\n| Lord of the Ladybirds |                                 4.0000000000 |\n| Lord of the Ladybirds |                                 4.0000000000 |\n| Lady of the Flies     |                                 2.0000000000 |\n| Lady of the Flies     |                                 2.0000000000 |\n| Lady of the Flies     |                                 2.0000000000 |\n+-----------------------+----------------------------------------------+\n\nURL: https://mariadb.com/kb/en/median/','','https://mariadb.com/kb/en/median/'),(764,'NTH_VALUE',41,'Syntax\n------\n\nNTH_VALUE (expr[, num_row]) OVER ( \n [ PARTITION BY partition_expression ]\n [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nThe NTH_VALUE function returns the value evaluated at row number num_row of\nthe window frame, starting from 1, or NULL if the row does not exist.\n\nURL: https://mariadb.com/kb/en/nth_value/','','https://mariadb.com/kb/en/nth_value/'),(765,'NTILE',41,'Syntax\n------\n\nNTILE (expr) OVER ( \n [ PARTITION BY partition_expression ]\n [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nNTILE() is a window function that returns an integer indicating which group a\ngiven row falls into. The number of groups is specified in the argument\n(expr), starting at one. Ordered rows in the partition are divided into the\nspecified number of groups with as equal a size as possible.\n\nExamples\n--------\n\ncreate table t1 (\n  pk int primary key,\n  a int,\n  b int\n );\n\ninsert into t1 values\n  (11 , 0, 10),\n  (12 , 0, 10),\n  (13 , 1, 10),\n  (14 , 1, 10),\n  (18 , 2, 10),\n  (15 , 2, 20),\n  (16 , 2, 20),\n  (17 , 2, 20),\n  (19 , 4, 20),\n  (20 , 4, 20);\n\nselect pk, a, b,\n  ntile(1) over (order by pk)\n from t1;\n+----+------+------+-----------------------------+\n| pk | a    | b    | ntile(1) over (order by pk) |\n+----+------+------+-----------------------------+\n| 11 |    0 |   10 |                           1 |\n| 12 |    0 |   10 |                           1 |\n| 13 |    1 |   10 |                           1 |\n| 14 |    1 |   10 |                           1 |\n| 15 |    2 |   20 |                           1 |\n| 16 |    2 |   20 |                           1 |\n| 17 |    2 |   20 |                           1 |\n| 18 |    2 |   10 |                           1 |\n| 19 |    4 |   20 |                           1 |\n| 20 |    4 |   20 |                           1 |\n+----+------+------+-----------------------------+\n\nselect pk, a, b,\n  ntile(4) over (order by pk)\n from t1;\n+----+------+------+-----------------------------+\n| pk | a    | b    | ntile(4) over (order by pk) |\n+----+------+------+-----------------------------+\n| 11 |    0 |   10 |                           1 |\n| 12 |    0 |   10 |                           1 |\n| 13 |    1 |   10 |                           1 |\n| 14 |    1 |   10 |                           2 |\n| 15 |    2 |   20 |                           2 |\n| 16 |    2 |   20 |                           2 |\n| 17 |    2 |   20 |                           3 |\n| 18 |    2 |   10 |                           3 |\n| 19 |    4 |   20 |                           4 |\n| 20 |    4 |   20 |                           4 |\n+----+------+------+-----------------------------+\n\nURL: https://mariadb.com/kb/en/ntile/','','https://mariadb.com/kb/en/ntile/'),(766,'PERCENT_RANK',41,'Syntax\n------\n\nPERCENT_RANK() OVER (\n [ PARTITION BY partition_expression ]\n [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nPERCENT_RANK() is a window function that returns the relative percent rank of\na given row. The following formula is used to calculate the percent rank:\n\n(rank - 1) / (number of rows in the window or partition - 1)\n\nExamples\n--------\n\ncreate table t1 (\n pk int primary key,\n a int,\n b int\n);\n\ninsert into t1 values\n( 1 , 0, 10),\n( 2 , 0, 10),\n( 3 , 1, 10),\n( 4 , 1, 10),\n( 8 , 2, 10),\n( 5 , 2, 20),\n( 6 , 2, 20),\n( 7 , 2, 20),\n( 9 , 4, 20),\n(10 , 4, 20);\n\nselect pk, a, b,\n  rank() over (order by a) as rank,\n  percent_rank() over (order by a) as pct_rank,\n  cume_dist() over (order by a) as cume_dist\nfrom t1;\n+----+------+------+------+--------------+--------------+\n| pk | a    | b    | rank | pct_rank     | cume_dist    |\n+----+------+------+------+--------------+--------------+\n|  1 |    0 |   10 |    1 | 0.0000000000 | 0.2000000000 |\n|  2 |    0 |   10 |    1 | 0.0000000000 | 0.2000000000 |\n|  3 |    1 |   10 |    3 | 0.2222222222 | 0.4000000000 |\n|  4 |    1 |   10 |    3 | 0.2222222222 | 0.4000000000 |\n|  5 |    2 |   20 |    5 | 0.4444444444 | 0.8000000000 |\n|  6 |    2 |   20 |    5 | 0.4444444444 | 0.8000000000 |\n|  7 |    2 |   20 |    5 | 0.4444444444 | 0.8000000000 |\n|  8 |    2 |   10 |    5 | 0.4444444444 | 0.8000000000 |\n|  9 |    4 |   20 |    9 | 0.8888888889 | 1.0000000000 |\n| 10 |    4 |   20 |    9 | 0.8888888889 | 1.0000000000 |\n+----+------+------+------+--------------+--------------+\n\nselect pk, a, b,\n   percent_rank() over (order by pk) as pct_rank,\n   cume_dist() over (order by pk) as cume_dist\nfrom t1 order by pk;\n+----+------+------+--------------+--------------+\n| pk | a    | b    | pct_rank     | cume_dist    |\n+----+------+------+--------------+--------------+\n|  1 |    0 |   10 | 0.0000000000 | 0.1000000000 |\n|  2 |    0 |   10 | 0.1111111111 | 0.2000000000 |\n|  3 |    1 |   10 | 0.2222222222 | 0.3000000000 |\n|  4 |    1 |   10 | 0.3333333333 | 0.4000000000 |\n|  5 |    2 |   20 | 0.4444444444 | 0.5000000000 |\n|  6 |    2 |   20 | 0.5555555556 | 0.6000000000 |\n|  7 |    2 |   20 | 0.6666666667 | 0.7000000000 |\n|  8 |    2 |   10 | 0.7777777778 | 0.8000000000 |\n|  9 |    4 |   20 | 0.8888888889 | 0.9000000000 |\n| 10 |    4 |   20 | 1.0000000000 | 1.0000000000 |\n+----+------+------+--------------+--------------+\n\nselect pk, a, b,\n    percent_rank() over (partition by a order by a) as pct_rank,\n    cume_dist() over (partition by a order by a) as cume_dist\nfrom t1;\n+----+------+------+--------------+--------------+\n| pk | a    | b    | pct_rank     | cume_dist    |\n+----+------+------+--------------+--------------+\n|  1 |    0 |   10 | 0.0000000000 | 1.0000000000 |\n|  2 |    0 |   10 | 0.0000000000 | 1.0000000000 |\n|  3 |    1 |   10 | 0.0000000000 | 1.0000000000 |\n|  4 |    1 |   10 | 0.0000000000 | 1.0000000000 |\n|  5 |    2 |   20 | 0.0000000000 | 1.0000000000 |\n|  6 |    2 |   20 | 0.0000000000 | 1.0000000000 |\n|  7 |    2 |   20 | 0.0000000000 | 1.0000000000 |\n|  8 |    2 |   10 | 0.0000000000 | 1.0000000000 |\n|  9 |    4 |   20 | 0.0000000000 | 1.0000000000 |\n| 10 |    4 |   20 | 0.0000000000 | 1.0000000000 |\n+----+------+------+--------------+--------------+\n\nURL: https://mariadb.com/kb/en/percent_rank/','','https://mariadb.com/kb/en/percent_rank/'),(767,'PERCENTILE_CONT',41,'MariaDB starting with 10.3.3\n----------------------------\nThe PERCENTILE_CONT() window function was first introduced with in MariaDB\n10.3.3.\n\nSyntax\n------\n\nDescription\n-----------\n\nPERCENTILE_CONT() (standing for continuous percentile) is a window function\nwhich returns a value which corresponds to the given fraction in the sort\norder. If required, it will interpolate between adjacent input items.\n\nEssentially, the following process is followed to find the value to return:\n\n* Get the number of rows in the partition, denoted by N\n* RN = p*(N-1), where p denotes the argument to the PERCENTILE_CONT function\n* calculate the FRN(floor row number) and CRN(column row number for the group(\nFRN= floor(RN) and CRN = ceil(RN))\n* look up rows FRN and CRN\n* If (CRN = FRN = RN) then the result is (value of expression from row at RN)\n* Otherwise the result is\n* (CRN - RN) * (value of expression for row at FRN) +\n* (RN - FRN) * (value of expression for row at CRN)\n\nThe MEDIAN function is a specific case of PERCENTILE_CONT, equivalent to\nPERCENTILE_CONT(0.5).\n\nExamples\n--------\n\nCREATE TABLE book_rating (name CHAR(30), star_rating TINYINT);\n\nINSERT INTO book_rating VALUES (\'Lord of the Ladybirds\', 5);\nINSERT INTO book_rating VALUES (\'Lord of the Ladybirds\', 3);\nINSERT INTO book_rating VALUES (\'Lady of the Flies\', 1);\nINSERT INTO book_rating VALUES (\'Lady of the Flies\', 2);\nINSERT INTO book_rating VALUES (\'Lady of the Flies\', 5);\n\nSELECT name, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY star_rating) \n OVER (PARTITION BY name) AS pc\n FROM book_rating;\n+-----------------------+--------------+\n| name                  | pc           |\n+-----------------------+--------------+\n| Lord of the Ladybirds | 4.0000000000 |\n| Lord of the Ladybirds | 4.0000000000 |\n| Lady of the Flies     | 2.0000000000 |\n| Lady of the Flies     | 2.0000000000 |\n| Lady of the Flies     | 2.0000000000 |\n+-----------------------+--------------+\n\nSELECT name, PERCENTILE_CONT(1) WITHIN GROUP (ORDER BY star_rating) \n OVER (PARTITION BY name) AS pc\n FROM book_rating;\n+-----------------------+--------------+\n| name                  | pc           |\n+-----------------------+--------------+\n| Lord of the Ladybirds | 5.0000000000 |\n| Lord of the Ladybirds | 5.0000000000 |\n| Lady of the Flies     | 5.0000000000 |\n| Lady of the Flies     | 5.0000000000 |\n| Lady of the Flies     | 5.0000000000 |\n+-----------------------+--------------+\n\nSELECT name, PERCENTILE_CONT(0) WITHIN GROUP (ORDER BY star_rating) \n OVER (PARTITION BY name) AS pc\n FROM book_rating;\n+-----------------------+--------------+\n| name                  | pc           |\n+-----------------------+--------------+\n| Lord of the Ladybirds | 3.0000000000 |\n| Lord of the Ladybirds | 3.0000000000 |\n| Lady of the Flies     | 1.0000000000 |\n| Lady of the Flies     | 1.0000000000 |\n| Lady of the Flies     | 1.0000000000 |\n+-----------------------+--------------+\n\nSELECT name, PERCENTILE_CONT(0.6) WITHIN GROUP (ORDER BY star_rating) \n OVER (PARTITION BY name) AS pc\n FROM book_rating;\n+-----------------------+--------------+\n| name                  | pc           |\n+-----------------------+--------------+\n| Lord of the Ladybirds | 4.2000000000 |\n| Lord of the Ladybirds | 4.2000000000 |\n| Lady of the Flies     | 2.6000000000 |\n| Lady of the Flies     | 2.6000000000 |\n| Lady of the Flies     | 2.6000000000 |\n+-----------------------+--------------+\n\nURL: https://mariadb.com/kb/en/percentile_cont/','','https://mariadb.com/kb/en/percentile_cont/'),(768,'PERCENTILE_DISC',41,'MariaDB starting with 10.3.3\n----------------------------\nThe PERCENTILE_DISC() window function was first introduced with in MariaDB\n10.3.3.\n\nSyntax\n------\n\nDescription\n-----------\n\nPERCENTILE_DISC() (standing for discrete percentile) is a window function\nwhich returns the first value in the set whose ordered position is the same or\nmore than the specified fraction.\n\nEssentially, the following process is followed to find the value to return:\n\n* Get the number of rows in the partition.\n* Walk through the partition, in order, until finding the the first row with\nCUME_DIST() >= function_argument.\n\nExamples\n--------\n\nCREATE TABLE book_rating (name CHAR(30), star_rating TINYINT);\n\nINSERT INTO book_rating VALUES (\'Lord of the Ladybirds\', 5);\nINSERT INTO book_rating VALUES (\'Lord of the Ladybirds\', 3);\nINSERT INTO book_rating VALUES (\'Lady of the Flies\', 1);\nINSERT INTO book_rating VALUES (\'Lady of the Flies\', 2);\nINSERT INTO book_rating VALUES (\'Lady of the Flies\', 5);\n\nSELECT name, PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY star_rating)\n OVER (PARTITION BY name) AS pc FROM book_rating;\n+-----------------------+------+\n| name                  | pc   |\n+-----------------------+------+\n| Lord of the Ladybirds |    3 |\n| Lord of the Ladybirds |    3 |\n| Lady of the Flies     |    2 |\n| Lady of the Flies     |    2 |\n| Lady of the Flies     |    2 |\n+-----------------------+------+\n5 rows in set (0.000 sec)\n\nSELECT name, PERCENTILE_DISC(0) WITHIN GROUP (ORDER BY star_rating) \n OVER (PARTITION BY name) AS pc FROM book_rating;\n+-----------------------+------+\n| name                  | pc   |\n+-----------------------+------+\n| Lord of the Ladybirds |    3 |\n| Lord of the Ladybirds |    3 |\n| Lady of the Flies     |    1 |\n| Lady of the Flies     |    1 |\n| Lady of the Flies     |    1 |\n+-----------------------+------+\n5 rows in set (0.000 sec)\n\nSELECT name, PERCENTILE_DISC(1) WITHIN GROUP (ORDER BY star_rating) \n OVER (PARTITION BY name) AS pc FROM book_rating;\n+-----------------------+------+\n| name                  | pc   |\n+-----------------------+------+\n| Lord of the Ladybirds |    5 |\n| Lord of the Ladybirds |    5 |\n| Lady of the Flies     |    5 |\n| Lady of the Flies     |    5 |\n| Lady of the Flies     |    5 |\n+-----------------------+------+\n5 rows in set (0.000 sec)\n\nSELECT name, PERCENTILE_DISC(0.6) WITHIN GROUP (ORDER BY star_rating) \n OVER (PARTITION BY name) AS pc FROM book_rating;\n+-----------------------+------+\n| name                  | pc   |\n+-----------------------+------+\n| Lord of the Ladybirds |    5 |\n| Lord of the Ladybirds |    5 |\n| Lady of the Flies     |    2 |\n| Lady of the Flies     |    2 |\n| Lady of the Flies     |    2 |\n+-----------------------+------\n\nURL: https://mariadb.com/kb/en/percentile_disc/','','https://mariadb.com/kb/en/percentile_disc/'),(769,'RANK',41,'Syntax\n------\n\nRANK() OVER (\n [ PARTITION BY partition_expression ]\n [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nRANK() is a window function that displays the number of a given row, starting\nat one and following the ORDER BY sequence of the window function, with\nidentical values receiving the same result. It is similar to the ROW_NUMBER()\nfunction except that in that function, identical values will receive a\ndifferent row number for each result.\n\nExamples\n--------\n\nThe distinction between DENSE_RANK(), RANK() and ROW_NUMBER():\n\nCREATE TABLE student(course VARCHAR(10), mark int, name varchar(10));\n\nINSERT INTO student VALUES \n (\'Maths\', 60, \'Thulile\'),\n (\'Maths\', 60, \'Pritha\'),\n (\'Maths\', 70, \'Voitto\'),\n (\'Maths\', 55, \'Chun\'),\n (\'Biology\', 60, \'Bilal\'),\n (\'Biology\', 70, \'Roger\');\n\nSELECT \n RANK() OVER (PARTITION BY course ORDER BY mark DESC) AS rank,\n DENSE_RANK() OVER (PARTITION BY course ORDER BY mark DESC) AS dense_rank,\n ROW_NUMBER() OVER (PARTITION BY course ORDER BY mark DESC) AS row_num,\n course, mark, name\nFROM student ORDER BY course, mark DESC;\n+------+------------+---------+---------+------+---------+\n| rank | dense_rank | row_num | course  | mark | name    |\n+------+------------+---------+---------+------+---------+\n|    1 |          1 |       1 | Biology |   70 | Roger   |\n|    2 |          2 |       2 | Biology |   60 | Bilal   |\n|    1 |          1 |       1 | Maths   |   70 | Voitto  |\n|    2 |          2 |       2 | Maths   |   60 | Thulile |\n|    2 |          2 |       3 | Maths   |   60 | Pritha  |\n|    4 |          3 |       4 | Maths   |   55 | Chun    |\n+------+------------+---------+---------+------+---------+\n\nURL: https://mariadb.com/kb/en/rank/','','https://mariadb.com/kb/en/rank/'),(770,'ROW_NUMBER',41,'Syntax\n------\n\nROW_NUMBER() OVER (\n [ PARTITION BY partition_expression ]\n [ ORDER BY order_list ]\n)\n\nDescription\n-----------\n\nROW_NUMBER() is a window function that displays the number of a given row,\nstarting at one and following the ORDER BY sequence of the window function,\nwith identical values receiving different row numbers. It is similar to the\nRANK() and DENSE_RANK() functions except that in that function, identical\nvalues will receive the same rank for each result.\n\nExamples\n--------\n\nThe distinction between DENSE_RANK(), RANK() and ROW_NUMBER():\n\nCREATE TABLE student(course VARCHAR(10), mark int, name varchar(10));\n\nINSERT INTO student VALUES \n (\'Maths\', 60, \'Thulile\'),\n (\'Maths\', 60, \'Pritha\'),\n (\'Maths\', 70, \'Voitto\'),\n (\'Maths\', 55, \'Chun\'),\n (\'Biology\', 60, \'Bilal\'),\n (\'Biology\', 70, \'Roger\');\n\nSELECT \n RANK() OVER (PARTITION BY course ORDER BY mark DESC) AS rank,\n DENSE_RANK() OVER (PARTITION BY course ORDER BY mark DESC) AS dense_rank,\n ROW_NUMBER() OVER (PARTITION BY course ORDER BY mark DESC) AS row_num,\n course, mark, name\nFROM student ORDER BY course, mark DESC;\n+------+------------+---------+---------+------+---------+\n| rank | dense_rank | row_num | course  | mark | name    |\n+------+------------+---------+---------+------+---------+\n|    1 |          1 |       1 | Biology |   70 | Roger   |\n|    2 |          2 |       2 | Biology |   60 | Bilal   |\n|    1 |          1 |       1 | Maths   |   70 | Voitto  |\n|    2 |          2 |       2 | Maths   |   60 | Thulile |\n|    2 |          2 |       3 | Maths   |   60 | Pritha  |\n|    4 |          3 |       4 | Maths   |   55 | Chun    |\n+------+------------+---------+---------+------+---------+\n\nURL: https://mariadb.com/kb/en/row_number/','','https://mariadb.com/kb/en/row_number/'),(771,'Aggregate Functions as Window Functions',41,'It is possible to use aggregate functions as window functions. An aggregate\nfunction used as a window function must have the OVER clause. For example,\nhere\'s COUNT() used as a window function:\n\nselect COUNT(*) over  (order by column) from table;\n\nMariaDB currently allows these aggregate functions to be used as window\nfunctions:\n\n* AVG\n* BIT_AND\n* BIT_OR\n* BIT_XOR\n* COUNT\n* JSON_ARRAYAGG\n* JSON_OBJECTAGG\n* MAX\n* MIN\n* STD\n* STDDEV\n* STDDEV_POP\n* STDDEV_SAMP\n* SUM\n* VAR_POP\n* VAR_SAMP\n* VARIANCE\n\nURL: https://mariadb.com/kb/en/aggregate-functions-as-window-functions/','','https://mariadb.com/kb/en/aggregate-functions-as-window-functions/'),(772,'ColumnStore Window Functions',41,'Introduction\n------------\n\nMariaDB ColumnStore provides support for window functions broadly following\nthe SQL 2003 specification. A window function allows for calculations relating\nto a window of data surrounding the current row in a result set. This\ncapability provides for simplified queries in support of common business\nquestions such as cumulative totals, rolling averages, and top 10 lists.\n\nAggregate functions are utilized for window functions however differ in\nbehavior from a group by query because the rows remain ungrouped. This\nprovides support for cumulative sums and rolling averages, for example.\n\nTwo key concepts for window functions are Partition and Frame:\n\n* A Partition is a group of rows, or window, that have the same value for a\nspecific column, for example a Partition can be created over a time period\nsuch as a quarter or lookup values.\n* The Frame for each row  is a subset of the row\'s Partition. The frame\ntypically is dynamic allowing for a sliding frame of rows within the\nPartition. The Frame determines the range of rows for the windowing function.\nA Frame could be defined as the last X rows and next Y rows all the way up to\nthe entire Partition.\n\nWindow functions are applied after joins, group by, and having clauses are\ncalculated.\n\nSyntax\n------\n\nA window function is applied in the select clause using the following syntax:\n\nfunction_name ([expression [, expression ... ]]) OVER ( window_definition )\n\nwhere window_definition is defined as:\n\n[ PARTITION BY expression [, ...] ]\n[ ORDER BY expression [ ASC | DESC ] [ NULLS { FIRST | LAST } ] [, ...] ]\n[ frame_clause ]\n\nPARTITION BY:\n\n* Divides the window result set into groups based on one or more expressions.\n* An expression may be a constant, column, and non window function expressions.\n* A query is not limited to a single partition by clause. Different partition\nclauses can be used across different window function applications.\n* The partition by columns do not need to be in the select list but do need to\nbe available from the query result set.\n* If there is no PARTITION BY clause, all rows of the result set define the\ngroup.\n\nORDER BY\n\n* Defines the ordering of values within the partition.\n* Can be ordered by multiple keys which may be a constant, column or non\nwindow function expression.\n* The order by columns do not need to be in the select list but need to be\navailable from the query result set.\n* Use of a select column alias from the query is not supported.\n* ASC (default) and DESC options allow for ordering ascending or descending.\n* NULLS FIRST and NULL_LAST options specify whether null values come first or\nlast in the ordering sequence. NULLS_FIRST is the default for ASC order, and\nNULLS_LAST is the default for DESC order.\n\nand the optional frame_clause is defined as:\n\n{ RANGE | ROWS } frame_start\n{ RANGE | ROWS } BETWEEN frame_start AND frame_end\n\nand the optional frame_start and frame_end are defined as (value being a\nnumeric expression):\n\nUNBOUNDED PRECEDING\nvalue PRECEDING\nCURRENT ROW\nvalue FOLLOWING\nUNBOUNDED FOLLOWING\n\nRANGE/ROWS:\n\n* Defines the windowing clause for calculating the set of rows that the\nfunction applies to for calculating a given rows window function result.\n* Requires an ORDER BY clause to define the row order for the window.\n* ROWS specify the window in physical units, i.e. result set rows and must be\na constant or expression evaluating to a positive numeric value.\n* RANGE specifies the window as a logical offset. If the the expression\nevaluates to a numeric value then the ORDER BY expression must be a numeric or\nDATE type. If the expression evaluates to an interval value then the ORDER BY\nexpression must be a DATE data type.\n* UNBOUNDED PRECEDING indicates the window starts at the first row of the\npartition.\n* UNBOUNDED FOLLOWING indicates the window ends at the last row of the\npartition.\n* CURRENT ROW specifies the window start or ends at the current row or value.\n* If omitted, the default is ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.\n\nSupported Functions\n-------------------\n\n+--------------------------------+-------------------------------------------+\n| Function                       | Description                               |\n+--------------------------------+-------------------------------------------+\n| AVG()                          | The average of all input values.          |\n+--------------------------------+-------------------------------------------+\n| COUNT()                        | Number of input rows.                     |\n+--------------------------------+-------------------------------------------+\n| CUME_DIST()                    | Calculates the cumulative distribution,   |\n|                                | or relative rank, of the current row to   |\n|                                | other rows in the same partition. Number  |\n|                                | of peer or preceding rows / number of     |\n|                                | rows in partition.                        |\n+--------------------------------+-------------------------------------------+\n| DENSE_RANK()                   | Ranks items in a group leaving no gaps    |\n|                                | in ranking sequence when there are ties.  |\n+--------------------------------+-------------------------------------------+\n| FIRST_VALUE()                  | The value evaluated at the row that is    |\n|                                | the first row of the window frame         |\n|                                | (counting from 1); null if no such row.   |\n+--------------------------------+-------------------------------------------+\n| LAG()                          | The value evaluated at the row that is    |\n|                                | offset rows before the current row        |\n|                                | within the partition; if there is no      |\n|                                | such row, instead return default. Both    |\n|                                | offset and default are evaluated with     |\n|                                | respect to the current row. If omitted,   |\n|                                | offset defaults to 1 and default to       |\n|                                | null. LAG provides access to more than    |\n|                                | one row of a table at the same time       |\n|                                | without a self-join. Given a series of    |\n|                                | rows returned from a query and a          |\n|                                | position of the cursor, LAG provides      |\n|                                | access to a row at a given physical       |\n|                                | offset prior to that position.            |\n+--------------------------------+-------------------------------------------+\n| LAST_VALUE()                   | The value evaluated at the row that is    |\n|                                | the last row of the window frame          |\n|                                | (counting from 1); null if no such row.   |\n+--------------------------------+-------------------------------------------+\n| LEAD()                         | Provides access to a row at a given       |\n|                                | physical offset beyond that position.     |\n|                                | Returns value evaluated at the row that   |\n|                                | is offset rows after the current row      |\n|                                | within the partition; if there is no      |\n|                                | such row, instead return default. Both    |\n|                                | offset and default are evaluated with     |\n|                                | respect to the current row. If omitted,   |\n|                                | offset defaults to 1 and default to null. |\n+--------------------------------+-------------------------------------------+\n| MAX()                          | Maximum value of expression across all    |\n|                                | input values.                             |\n+--------------------------------+-------------------------------------------+\n| MEDIAN()                       | An inverse distribution function that     |\n|                                | assumes a continuous distribution model.  |\n|                                | It takes a numeric or datetime value and  |\n|                                | returns the middle value or an            |\n|                                | interpolated value that would be the      |\n|                                | middle value once the values are sorted.  |\n|                                | Nulls are ignored in the calculation.     |\n+--------------------------------+-------------------------------------------+\n| MIN()                          | Minimum value of expression across all    |\n|                                | input values.                             |\n+--------------------------------+-------------------------------------------+\n| NTH_VALUE()                    | The value evaluated at the row that is    |\n|                                | the nth row of the window frame           |\n|                                | (counting from 1); null if no such row.   |\n+--------------------------------+-------------------------------------------+\n| NTILE()                        | Divides an ordered data set into a        |\n|                                | number of buckets indicated by expr and   |\n|                                | assigns the appropriate bucket number to  |\n|                                | each row. The buckets are numbered 1      |\n|                                | through expr. The expr value must         |\n|                                | resolve to a positive constant for each   |\n|                                | partition. Integer ranging from 1 to the  |\n|                                | argument value, dividing the partition    |\n|                                | as equally as possible.                   |\n+--------------------------------+-------------------------------------------+\n| PERCENT_RANK()                 | relative rank of the current row: (rank   |\n|                                | - 1) / (total rows - 1).                  |\n+--------------------------------+-------------------------------------------+\n| PERCENTILE_CONT()              | An inverse distribution function that     |\n|                                | assumes a continuous distribution model.  |\n|                                | It takes a percentile value and a sort    |\n|                                | specification, and returns an             |\n|                                | interpolated value that would fall into   |\n|                                | that percentile value with respect to     |\n|                                | the sort specification. Nulls are         |\n|                                | ignored in the calculation.               |\n+--------------------------------+-------------------------------------------+\n| PERCENTILE_DISC()              | An inverse distribution function that     |\n|                                | assumes a discrete distribution model.    |\n|                                | It takes a percentile value and a sort    |\n|                                | specification and returns an element      |\n|                                | from the set. Nulls are ignored in the    |\n|                                | calculation.                              |\n+--------------------------------+-------------------------------------------+\n| RANK()                         | rank of the current row with gaps; same   |\n|                                | as row_number of its first peer.          |\n+--------------------------------+-------------------------------------------+\n| ROW_NUMBER()                   | number of the current row within its      |\n|                                | partition, counting from 1                |\n+--------------------------------+-------------------------------------------+\n| STDDEV() STDDEV_POP()          | Computes the population standard          |\n|                                | deviation and returns the square root of  |\n|                                | the population variance.                  |\n+--------------------------------+-------------------------------------------+\n| STDDEV_SAMP()                  | Computes the cumulative sample standard   |\n|                                | deviation and returns the square root of  |\n|                                | the sample variance.                      |\n+--------------------------------+-------------------------------------------+\n| SUM()                          | Sum of expression across all input        |\n|                                | values.                                   |\n+--------------------------------+-------------------------------------------+\n| VARIANCE() VAR_POP()           | Population variance of the input values   |\n|                                | (square of the population standard        |\n|                                | deviation).                               |\n+--------------------------------+-------------------------------------------+\n| VAR_SAMP()                     | Sample variance of the input values       |\n|                                | (square of the sample standard            |\n|                                | deviation).                               |\n+--------------------------------+-------------------------------------------+\n\nExamples\n--------\n\nExample Schema\n--------------\n\nThe examples are all based on the following simplified sales opportunity table:\n\ncreate table opportunities (\nid int,\naccountName varchar(20),\nname varchar(128),\nowner varchar(7),\namount decimal(10,2),\ncloseDate date,\nstageName varchar(11)\n) engine=columnstore;\n\nSome example values are (thanks to https://www.mockaroo.com for sample data\ngeneration):\n\n+----+---------------+------+--------+---------+-------------+-------------+\n| id | accountName   | name | owner  | amount  | closeDate   | stageName   |\n+----+---------------+------+--------+---------+-------------+-------------+\n| 1  | Browseblab    | Mult | Bob    | 26444.8 | 2016-10-20  | Negotiating |\n|    |               | -lat |        |         |             |             |\n|    |               | ral  |        |         |             |             |\n|    |               | exec |        |         |             |             |\n|    |               | tive |        |         |             |             |\n|    |               | func |        |         |             |             |\n|    |               | ion  |        |         |             |             |\n+----+---------------+------+--------+---------+-------------+-------------+\n| 2  | Mita          | Orga | Maria  | 477878. | 2016-11-28  | ClosedWon   |\n|    |               | ic   |        | 1       |             |             |\n|    |               | dema |        |         |             |             |\n|    |               | d-dr |        |         |             |             |\n|    |               | ven  |        |         |             |             |\n|    |               | benc |        |         |             |             |\n|    |               | mark |        |         |             |             |\n+----+---------------+------+--------+---------+-------------+-------------+\n| 3  | Miboo         | De-e | Olivie | 80181.7 | 2017-01-05  | ClosedWon   |\n|    |               | gine |        |         |             |             |\n|    |               | red  |        |         |             |             |\n|    |               | hybr |        |         |             |             |\n|    |               | d    |        |         |             |             |\n|    |               | grou |        |         |             |             |\n|    |               | ware |        |         |             |             |\n+----+---------------+------+--------+---------+-------------+-------------+\n| 4  | Youbridge     | Ente | Chris  | 946245. | 2016-07-02  | ClosedWon   |\n|    |               | pris |        | 9       |             |             |\n|    |               | -wid |        |         |             |             |\n|    |               |      |        |         |             |             |\n|    |               | bott |        |         |             |             |\n|    |               | m-li |        |         |             |             |\n|    |               | e    |        |         |             |             |\n|    |               | Grap |        |         |             |             |\n|    |               | ic   |        |         |             |             |\n|    |               | Inte |        |         |             |             |\n|    |               | face |        |         |             |             |\n+----+---------------+------+--------+---------+-------------+-------------+\n| 5  | Skyba         | Reve | Maria  | 696241. | 2017-02-17  | Negotiating |\n|    |               | se-e |        | 2       |             |             |\n|    |               | gine |        |         |             |             |\n|    |               | red  |        |         |             |             |\n|    |               | fres |        |         |             |             |\n|    |               | -thi |        |         |             |             |\n|    |               | king |        |         |             |             |\n|    |               | stan |        |         |             |             |\n|    |               | ardi |        |         |             |             |\n|    |               | atio |        |         |             |             |\n|    |               |      |        |         |             |             |\n+----+---------------+------+--------+---------+-------------+-------------+\n| 6  | Eayo          | Fund | Bob    | 765605. | 2016-08-27  | Prospecting |\n|    |               | ment |        | 2       |             |             |\n|    |               | l    |        |         |             |             |\n|    |               | well |        |         |             |             |\n|    |               | modu |        |         |             |             |\n|    |               | ated |        |         |             |             |\n|    |               | arti |        |         |             |             |\n|    |               | icia |        |         |             |             |\n|    |               |      |        |         |             |             |\n|    |               | inte |        |         |             |             |\n|    |               | lige |        |         |             |             |\n|    |               | ce   |        |         |             |             |\n+----+---------------+------+--------+---------+-------------+-------------+\n| 7  | Yotz          | Exte | Chris  | 319624. | 2017-01-06  | ClosedLost  |\n|    |               | ded  |        | 0       |             |             |\n|    |               | seco |        |         |             |             |\n|    |               | dary |        |         |             |             |\n|    |               | infr |        |         |             |             |\n|    |               | stru |        |         |             |             |\n|    |               | ture |        |         |             |             |\n+----+---------------+------+--------+---------+-------------+-------------+\n| 8  | Oloo          | Conf | Chris  | 321016. | 2017-03-08  | ClosedLost  |\n|    |               | gura |        | 6       |             |             |\n|    |               | le   |        |         |             |             |\n|    |               | web- |        |         |             |             |\n|    |               | nabl |        |         |             |             |\n|    |               | d    |        |         |             |             |\n|    |               | data |        |         |             |             |\n|    |               | ware |        |         |             |             |\n|    |               | ouse |        |         |             |             |\n+----+---------------+------+--------+---------+-------------+-------------+\n| 9  | Kaymbo        | Mult | Bob    | 690881. | 2017-01-02  | Developing  |\n|    |               | -lat |        | 1       |             |             |\n|    |               | ral  |        |         |             |             |\n|    |               | web- |        |         |             |             |\n|    |               | nabl |        |         |             |             |\n|    |               | d    |        |         |             |             |\n|    |               | defi |        |         |             |             |\n|    |               | itio |        |         |             |             |\n|    |               |      |        |         |             |             |\n+----+---------------+------+--------+---------+-------------+-------------+\n| 10 | Rhyloo        | Publ | Chris  | 965477. | 2016-11-07  | Prospecting |\n|    |               | c-ke |        | 4       |             |             |\n|    |               |      |        |         |             |             |\n|    |               | cohe |        |         |             |             |\n|    |               | ent  |        |         |             |             |\n|    |               | infr |        |         |             |             |\n|    |               | stru |        |         |             |             |\n|    |               | ture |        |         |             |             |\n+----+---------------+------+--------+---------+-------------+-------------+\n\nThe schema, sample data, and queries are available as an attachment to this\narticle.\n\nCumulative Sum and Running Max Example\n--------------------------------------\n\nWindow functions can be used to achieve cumulative / running calculations on a\ndetail report. In this case a won opportunity report for a 7 day period adds\ncolumns to show the accumulated won amount as well as the current highest\nopportunity amount in preceding rows.\n\nselect owner, \naccountName, \nCloseDate, \namount, \nsum(amount) over (order by CloseDate rows between unbounded preceding and\ncurrent row) cumeWon, \nmax(amount) over (order by CloseDate rows between unbounded preceding and\ncurrent row) runningMax\nfrom opportunities \nwhere stageName=\'ClosedWon\' \nand closeDate >= \'2016-10-02\' and closeDate <= \'2016-10-09\' \norder by CloseDate;\n\nwith example results:\n\n+--------+---------------+-------------+---------+----------+--------------+\n| owner  | accountName   | CloseDate   | amount  | cumeWon  | runningMax   |\n+--------+---------------+-------------+---------+----------+--------------+\n| Bill   | Babbleopia    | 2016-10-02  | 437636. | 437636.4 | 437636.47    |\n|        |               |             | 7       |          |              |\n+--------+---------------+-------------+---------+----------+--------------+\n| Bill   | Thoughtworks  | 2016-10-04  | 146086. | 583722.9 | 437636.47    |\n|        |               |             | 1       |          |              |\n+--------+---------------+-------------+---------+----------+--------------+\n| Olivie | Devpulse      | 2016-10-05  | 834235. | 1417958. | 834235.93    |\n|        |               |             | 3       | 1        |              |\n+--------+---------------+-------------+---------+----------+--------------+\n| Chris  | Linkbridge    | 2016-10-07  | 539977. | 2458738. | 834235.93    |\n|        |               |             | 5       | 5        |              |\n+--------+---------------+-------------+---------+----------+--------------+\n| Olivie | Trupe         | 2016-10-07  | 500802. | 1918761. | 834235.93    |\n|        |               |             | 9       | 0        |              |\n+--------+---------------+-------------+---------+----------+--------------+\n| Bill   | Latz          | 2016-10-08  | 857254. | 3315993. | 857254.87    |\n|        |               |             | 7       | 2        |              |\n+--------+---------------+-------------+---------+----------+--------------+\n| Chris  | Avamm         | 2016-10-09  | 699566. | 4015560. | 857254.87    |\n|        |               |             | 6       | 8        |              |\n+--------+---------------+-------------+---------+----------+--------------+\n\nPartitioned Cumulative Sum and Running Max Example\n--------------------------------------------------\n\nThe above example can be partitioned, so that the window functions are over a\nparticular field grouping such as owner and accumulate within that grouping.\nThis is achieved by adding the syntax \"partition by <columns>\" in the window\nfunction clause.\n\nselect owner,  \naccountName,  \nCloseDate,  \namount,  \nsum(amount) over (partition by owner order by CloseDate rows between unbounded\npreceding and current row) cumeWon,  \nmax(amount) over (partition by owner order by CloseDate rows between unbounded\npreceding and current row) runningMax \nfrom opportunities  \nwhere stageName=\'ClosedWon\' \nand closeDate >= \'2016-10-02\' and closeDate <= \'2016-10-09\'  \norder by owner, CloseDate;\n\nwith example results:\n\n+--------+---------------+-------------+---------+----------+--------------+\n| owner  | accountName   | CloseDate   | amount  | cumeWon  | runningMax   |\n+--------+---------------+-------------+---------+----------+--------------+\n| Bill   | Babbleopia    | 2016-10-02  | 437636. | 437636.4 | 437636.47    |\n|        |               |             | 7       |          |              |\n+--------+---------------+-------------+---------+----------+--------------+\n| Bill   | Thoughtworks  | 2016-10-04  | 146086. | 583722.9 | 437636.47    |\n|        |               |             | 1       |          |              |\n+--------+---------------+-------------+---------+----------+--------------+\n| Bill   | Latz          | 2016-10-08  | 857254. | 1440977. | 857254.87    |\n|        |               |             | 7       | 5        |              |\n+--------+---------------+-------------+---------+----------+--------------+\n| Chris  | Linkbridge    | 2016-10-07  | 539977. | 539977.4 | 539977.45    |\n|        |               |             | 5       |          |              |\n+--------+---------------+-------------+---------+----------+--------------+\n| Chris  | Avamm         | 2016-10-09  | 699566. | 1239544. | 699566.86    |\n|        |               |             | 6       | 1        |              |\n+--------+---------------+-------------+---------+----------+--------------+\n| Olivie | Devpulse      | 2016-10-05  | 834235. | 834235.9 | 834235.93    |\n|        |               |             | 3       |          |              |\n+--------+---------------+-------------+---------+----------+--------------+\n| Olivie | Trupe         | 2016-10-07  | 500802. | 1335038. | 834235.93    |\n|        |               |             | 9       | 2        |              |\n+--------+---------------+-------------+---------+----------+--------------+\n\nRanking / Top Results\n---------------------\n\nThe rank window function allows for ranking or assigning a numeric order value\nbased on the window function definition. Using the Rank() function will result\nin the same value for ties / equal values and the next rank value skipped. The\nDense_Rank() function behaves similarly except the next consecutive number is\nused after a tie rather than skipped. The Row_Number() function will provide a\nunique ordering value. The example query shows the Rank() function being\napplied to rank sales reps by the number of opportunities for Q4 2016.\n\nselect owner, \nwonCount, \nrank() over (order by wonCount desc) rank \nfrom (\n select owner,\n count(*) wonCount\n from opportunities\n where stageName=\'ClosedWon\'\n and closeDate >= \'2016-10-01\' and closeDate < \'2016-12-31\'\n group by owner\n) t\norder by rank;\n\nwith example results (note the query is technically incorrect by using\ncloseDate < \'2016-12-31\' however this creates a tie scenario for illustrative\npurposes):\n\n+----------------------+----------------------------------+------------------+\n| owner                | wonCount                         | rank             |\n+----------------------+----------------------------------+------------------+\n| Bill                 | 19                               | 1                |\n+----------------------+----------------------------------+------------------+\n| Chris                | 15                               | 2                |\n+----------------------+----------------------------------+------------------+\n| Maria                | 14                               | 3                |\n+----------------------+----------------------------------+------------------+\n| Bob                  | 14                               | 3                |\n+----------------------+----------------------------------+------------------+\n| Olivier              | 10                               | 5                |\n+----------------------+----------------------------------+------------------+\n\nIf the dense_rank function is used the rank values would be 1,2,3,3,4 and for\nthe row_number function the values would be 1,2,3,4,5.\n\nFirst and Last Values\n---------------------\n\nThe first_value and last_value functions allow determining the first and last\nvalues of a given range. Combined with a group by this allows summarizing\nopening and closing values. The example shows a more complex case where\ndetailed information is presented for first and last opportunity by quarter.\n\nselect a.year, \na.quarter, \nf.accountName firstAccountName, \nf.owner firstOwner, \nf.amount firstAmount, \nl.accountName lastAccountName, \nl.owner lastOwner, \nl.amount lastAmount \nfrom (\n select year,\n quarter,\n min(firstId) firstId,\n min(lastId) lastId\n from (\n  select year(closeDate) year,\n  quarter(closeDate) quarter,\n  first_value(id) over (partition by year(closeDate), quarter(closeDate)\norder by closeDate rows between unbounded preceding and current row) firstId, \n  last_value(id) over (partition by year(closeDate), quarter(closeDate)\norder by closeDate rows between current row and unbounded following) lastId \n  from opportunities  where stageName=\'ClosedWon\'\n ) t\n group by year, quarter order by year,quarter\n) a \njoin opportunities f on a.firstId = f.id \njoin opportunities l on a.lastId = l.id \norder by year, quarter;\n\nwith example results:\n\n+----+------+------------+--------+---------+-----------+-------+--------+\n| ye | quar | firstAccou | firstO | firstAm | lastAccou | lastO | lastAm |\n| r  | er   | tName      | ner    | unt     | tName     | ner   | unt    |\n+----+------+------------+--------+---------+-----------+-------+--------+\n| 20 | 3    | Skidoo     | Bill   | 523295. | Skipstorm | Bill  | 151420 |\n| 6  |      |            |        | 7       |           |       | 86     |\n+----+------+------------+--------+---------+-----------+-------+--------+\n| 20 | 4    | Skimia     | Chris  | 961513. | Avamm     | Maria | 112493 |\n| 6  |      |            |        | 9       |           |       | 65     |\n+----+------+------------+--------+---------+-----------+-------+--------+\n| 20 | 1    | Yombu      | Bob    | 536875. | Skaboo    | Chris | 270273 |\n| 7  |      |            |        | 1       |           |       | 08     |\n+----+------+------------+--------+---------+-----------+-------+--------+\n\nPrior and Next Example\n----------------------\n\nSometimes it useful to understand the previous and next values in the context\nof a given row. The lag and lead window functions provide this capability. By\ndefault the offset is one providing the prior or next value but can also be\nprovided to get a larger offset. The example query is a report of\nopportunities by account name showing the opportunity amount, and the prior\nand next opportunity amount for that account by close date.\n\nselect accountName, \ncloseDate,  \namount currentOppAmount, \nlag(amount) over (partition by accountName order by closeDate) priorAmount,\nlead(amount) over (partition by accountName order by closeDate) nextAmount \nfrom opportunities \norder by accountName, closeDate \nlimit 9;\n\nwith example results:\n\n+--------------+-----------+-------------------+--------------+-------------+\n| accountName  | closeDate | currentOppAmount  | priorAmount  | nextAmount  |\n+--------------+-----------+-------------------+--------------+-------------+\n| Abata        | 2016-09-1 | 645098.45         | NULL         | 161086.82   |\n|              |           |                   |              |             |\n+--------------+-----------+-------------------+--------------+-------------+\n| Abata        | 2016-10-1 | 161086.82         | 645098.45    | 350235.75   |\n|              |           |                   |              |             |\n+--------------+-----------+-------------------+--------------+-------------+\n| Abata        | 2016-12-1 | 350235.75         | 161086.82    | 878595.89   |\n|              |           |                   |              |             |\n+--------------+-----------+-------------------+--------------+-------------+\n| Abata        | 2016-12-3 | 878595.89         | 350235.75    | 922322.39   |\n|              |           |                   |              |             |\n+--------------+-----------+-------------------+--------------+-------------+\n| Abata        | 2017-01-2 | 922322.39         | 878595.89    | NULL        |\n|              |           |                   |              |             |\n+--------------+-----------+-------------------+--------------+-------------+\n| Abatz        | 2016-10-1 | 795424.15         | NULL         | NULL        |\n|              |           |                   |              |             |\n+--------------+-----------+-------------------+--------------+-------------+\n| Agimba       | 2016-07-0 | 288974.84         | NULL         | 914461.49   |\n|              |           |                   |              |             |\n+--------------+-----------+-------------------+--------------+-------------+\n| Agimba       | 2016-09-0 | 914461.49         | 288974.84    | 176645.52   |\n|              |           |                   |              |             |\n+--------------+-----------+-------------------+--------------+-------------+\n| Agimba       | 2016-09-2 | 176645.52         | 914461.49    | NULL        |\n|              |           |                   |              |             |\n+--------------+-----------+-------------------+--------------+-------------+\n\nQuartiles Example\n-----------------\n\nThe NTile window function allows for breaking up a data set into portions\nassigned a numeric value to each portion of the range. NTile(4) breaks the\ndata up into quartiles (4 sets). The example query produces a report of all\nopportunities summarizing the quartile boundaries of amount values.\n\nselect t.quartile, \nmin(t.amount) min, \nmax(t.amount) max \nfrom (\n select amount,\n ntile(4) over (order by amount asc) quartile\n from opportunities\n where closeDate >= \'2016-10-01\' and closeDate <= \'2016-12-31\'\n ) t\ngroup by quartile \norder by quartile;\n\nWith example results:\n\n+-----------------------------------------+----------------+----------------+\n| quartile                                | min            | max            |\n+-----------------------------------------+----------------+----------------+\n| 1                                       | 6337.15        | 287634.01      |\n+-----------------------------------------+----------------+----------------+\n| 2                                       | 288796.14      | 539977.45      |\n+-----------------------------------------+----------------+----------------+\n| 3                                       | 540070.04      | 748727.51      |\n+-----------------------------------------+----------------+----------------+\n| 4                                       | 753670.77      | 998864.47      |\n+-----------------------------------------+----------------+----------------+\n\nPercentile Example\n------------------\n\nThe percentile functions have a slightly different syntax from other window\nfunctions as can be seen in the example below. These functions can be only\napplied against numeric values. The argument to the function is the percentile\nto evaluate. Following \'within group\' is the sort expression which indicates\nthe sort column and optionally order. Finally after \'over\' is an optional\npartition by clause, for no partition clause use \'over ()\'. The example below\nutilizes the value 0.5 to calculate the median opportunity amount in the rows.\nThe values differ sometimes because percentile_cont will return the average of\nthe 2 middle rows for an even data set while percentile_desc returns the first\nencountered in the sort.\n\nselect owner,  \naccountName,  \nCloseDate,  \namount,\npercentile_cont(0.5) within group (order by amount) over (partition by owner)\npct_cont,\npercentile_disc(0.5) within group (order by amount) over (partition by owner)\npct_disc\nfrom opportunities  \nwhere stageName=\'ClosedWon\' \nand closeDate >= \'2016-10-02\' and closeDate <= \'2016-10-09\'  \norder by owner, CloseDate;\n\nWith example results:\n\n+--------+----------------+-------------+---------+------------+------------+\n| owner  | accountName    | CloseDate   | amount  | pct_cont   | pct_disc   |\n+--------+----------------+-------------+---------+------------+------------+\n| Bill   | Babbleopia     | 2016-10-02  | 437636. | 437636.470 | 437636.47  |\n|        |                |             | 7       | 000000     |            |\n+--------+----------------+-------------+---------+------------+------------+\n| Bill   | Thoughtworks   | 2016-10-04  | 146086. | 437636.470 | 437636.47  |\n|        |                |             | 1       | 000000     |            |\n+--------+----------------+-------------+---------+------------+------------+\n| Bill   | Latz           | 2016-10-08  | 857254. | 437636.470 | 437636.47  |\n|        |                |             | 7       | 000000     |            |\n+--------+----------------+-------------+---------+------------+------------+\n| Chris  | Linkbridge     | 2016-10-07  | 539977. | 619772.155 | 539977.45  |\n|        |                |             | 5       | 000000     |            |\n+--------+----------------+-------------+---------+------------+------------+\n| Chris  | Avamm          | 2016-10-09  | 699566. | 619772.155 | 539977.45  |\n|        |                |             | 6       | 000000     |            |\n+--------+----------------+-------------+---------+------------+------------+\n| Olivie | Devpulse       | 2016-10-05  | 834235. | 667519.110 | 500802.29  |\n|        |                |             | 3       | 000000     |            |\n+--------+----------------+-------------+---------+------------+------------+\n| Olivie | Trupe          | 2016-10-07  | 500802. | 667519.110 | 500802.29  |\n|        |                |             | 9       | 000000     |            |\n+--------+----------------+-------------+---------+------------+------------+\n\nURL: https://mariadb.com/kb/en/window-functions-columnstore-window-functions/','','https://mariadb.com/kb/en/window-functions-columnstore-window-functions/'),(773,'Window Frames',41,'Syntax\n------\n\nframe_clause:\n {ROWS | RANGE} {frame_border | BETWEEN frame_border AND frame_border}\n\nframe_border:\n | UNBOUNDED PRECEDING\n | UNBOUNDED FOLLOWING\n | CURRENT ROW\n | expr PRECEDING\n | expr FOLLOWING\n\nDescription\n-----------\n\nA basic overview of window functions is described in Window Functions\nOverview. Window frames expand this functionality by allowing the function to\ninclude a specified a number of rows around the current row.\n\nThese include:\n\n* All rows before the current row (UNBOUNDED PRECEDING), for example RANGE\nBETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n* All rows after the current row (UNBOUNDED FOLLOWING), for example RANGE\nBETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING\n* A set number of rows before the current row (expr PRECEDING) for example\nRANGE BETWEEN 6 PRECEDING AND CURRENT ROW\n* A set number of rows after the current row (expr PRECEDING AND expr\nFOLLOWING)  for example RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING\n* A specified number of rows both before and after the current row, for\nexample RANGE BETWEEN 6 PRECEDING AND 3 FOLLOWING\n\nThe following functions operate on window frames:\n\n* AVG\n* BIT_AND\n* BIT_OR\n* BIT_XOR\n* COUNT\n* LEAD\n* MAX\n* MIN\n* NTILE\n* STD\n* STDDEV\n* STDDEV_POP\n* STDDEV_SAMP\n* SUM\n* VAR_POP\n* VAR_SAMP\n* VARIANCE\n\nWindow frames are determined by the frame_clause in the window function\nrequest.\n\nTake the following example:\n\nCREATE TABLE `student_test` (\n name char(10),\n test char(10),\n score tinyint(4)\n);\n\nINSERT INTO student_test VALUES \n  (\'Chun\', \'SQL\', 75), (\'Chun\', \'Tuning\', 73),\n  (\'Esben\', \'SQL\', 43), (\'Esben\', \'Tuning\', 31),\n  (\'Kaolin\', \'SQL\', 56), (\'Kaolin\', \'Tuning\', 88),\n  (\'Tatiana\', \'SQL\', 87);\n\nSELECT name, test, score, SUM(score) \n OVER () AS total_score\n FROM student_test;\n+---------+--------+-------+-------------+\n| name    | test   | score | total_score |\n+---------+--------+-------+-------------+\n| Chun    | SQL    |    75 |         453 |\n| Chun    | Tuning |    73 |         453 |\n| Esben   | SQL    |    43 |         453 |\n| Esben   | Tuning |    31 |         453 |\n| Kaolin  | SQL    |    56 |         453 |\n| Kaolin  | Tuning |    88 |         453 |\n| Tatiana | SQL    |    87 |         453 |\n+---------+--------+-------+-------------+\n\nBy not specifying an OVER clause, the SUM function is run over the entire\ndataset. However, if we specify an ORDER BY condition based on score (and\norder the entire result in the same way for clarity), the following result is\nreturned:\n\nSELECT name, test, score, SUM(score) \n OVER (ORDER BY score) AS total_score\n FROM student_test ORDER BY score;\n+---------+--------+-------+-------------+\n| name    | test   | score | total_score |\n+---------+--------+-------+-------------+\n| Esben   | Tuning |    31 |          31 |\n| Esben   | SQL    |    43 |          74 |\n| Kaolin  | SQL    |    56 |         130 |\n| Chun    | Tuning |    73 |         203 |\n| Chun    | SQL    |    75 |         278 |\n| Tatiana | SQL    |    87 |         365 |\n| Kaolin  | Tuning |    88 |         453 |\n+---------+--------+-------+-------------+\n\nThe total_score column represents a running total of the current row, and all\nprevious rows. The window frame in this example expands as the function\nproceeds.\n\nThe above query makes use of the default to define the window frame. It could\nbe written explicitly as follows:\n\nSELECT name, test, score, SUM(score) \n OVER (ORDER BY score RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS\ntotal_score \n FROM student_test ORDER BY score;\n+---------+--------+-------+-------------+\n| name    | test   | score | total_score |\n+---------+--------+-------+-------------+\n| Esben   | Tuning |    31 |          31 |\n| Esben   | SQL    |    43 |          74 |\n| Kaolin  | SQL    |    56 |         130 |\n| Chun    | Tuning |    73 |         203 |\n| Chun    | SQL    |    75 |         278 |\n| Tatiana | SQL    |    87 |         365 |\n| Kaolin  | Tuning |    88 |         453 |\n+---------+--------+-------+-------------+\n\nLet\'s look at some alternatives:\n\nFirstly, applying the window function to the current row and all following\nrows can be done with the use of UNBOUNDED FOLLOWING:\n\nSELECT name, test, score, SUM(score) \n OVER (ORDER BY score RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS\ntotal_score \n FROM student_test ORDER BY score;\n+---------+--------+-------+-------------+\n| name    | test   | score | total_score |\n+---------+--------+-------+-------------+\n| Esben   | Tuning |    31 |         453 |\n| Esben   | SQL    |    43 |         422 |\n| Kaolin  | SQL    |    56 |         379 |\n| Chun    | Tuning |    73 |         323 |\n| Chun    | SQL    |    75 |         250 |\n| Tatiana | SQL    |    87 |         175 |\n| Kaolin  | Tuning |    88 |          88 |\n+---------+--------+-------+-------------+\n\nIt\'s possible to specify a number of rows, rather than the entire unbounded\nfollowing or preceding set. The following example takes the current row, as\nwell as the previous row:\n\nSELECT name, test, score, SUM(score) \n OVER (ORDER BY score ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS\ntotal_score \n FROM student_test ORDER BY score;\n+---------+--------+-------+-------------+\n| name    | test   | score | total_score |\n+---------+--------+-------+-------------+\n| Esben   | Tuning |    31 |          31 |\n| Esben   | SQL    |    43 |          74 |\n| Kaolin  | SQL    |    56 |          99 |\n| Chun    | Tuning |    73 |         129 |\n| Chun    | SQL    |    75 |         148 |\n| Tatiana | SQL    |    87 |         162 |\n| Kaolin  | Tuning |    88 |         175 |\n+---------+--------+-------+-------------+\n\nThe current row and the following row:\n\nSELECT name, test, score, SUM(score) \n OVER (ORDER BY score ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS\ntotal_score \n FROM student_test ORDER BY score;\n+---------+--------+-------+-------------+\n| name    | test   | score | total_score |\n+---------+--------+-------+-------------+\n| Esben   | Tuning |    31 |          74 |\n| Esben   | SQL    |    43 |         130 |\n| Kaolin  | SQL    |    56 |         172 |\n| Chun    | Tuning |    73 |         204 |\n| Chun    | SQL    |    75 |         235 |\n| Tatiana | SQL    |    87 |         250 |\n| Kaolin  | Tuning |    88 |         175 |\n+---------+--------+-------+-------------+\n\nURL: https://mariadb.com/kb/en/window-frames/','','https://mariadb.com/kb/en/window-frames/'),(774,'SPIDER_BG_DIRECT_SQL',42,'Syntax\n------\n\nSPIDER_BG_DIRECT_SQL(\'sql\', \'tmp_table_list\', \'parameters\')\n\nDescription\n-----------\n\nExecutes the given SQL statement in the background on the remote server, as\ndefined in the parameters listing. If the query returns a result-set, it\nsttores the results in the given temporary table. When the given SQL statement\nexecutes successfully, this function returns the number of called UDF\'s. It\nreturns 0 when the given SQL statement fails.\n\nThis function is a UDF installed with the Spider storage engine.\n\nExamples\n--------\n\nSELECT SPIDER_BG_DIRECT_SQL(\'SELECT * FROM example_table\',  \'\', \n \'srv \"node1\", port \"8607\"\') AS \"Direct Query\";\n+--------------+\n| Direct Query | \n+--------------+\n|            1 |\n+--------------+\n\nParameters\n----------\n\nerror_rw_mode\n-------------\n\n* Description: Returns empty results on network error.\n0 : Return error on getting network error.\n1: Return 0 records on getting network error.\n\n* Default Table Value: 0\n* DSN Parameter Name: erwm\n\nURL: https://mariadb.com/kb/en/spider_bg_direct_sql/','','https://mariadb.com/kb/en/spider_bg_direct_sql/'),(775,'SPIDER_COPY_TABLES',42,'Syntax\n------\n\nSPIDER_COPY_TABLES(spider_table_name, \n source_link_id, destination_link_id_list [,parameters])\n\nDescription\n-----------\n\nA UDF installed with the Spider Storage Engine, this function copies table\ndata from source_link_id to destination_link_id_list. The service does not\nneed to be stopped in order to copy.\n\nIf the Spider table is partitioned, the name must be of the format\ntable_name#P#partition_name. The partition name can be viewed in the\nmysql.spider_tables table, for example:\n\nSELECT table_name FROM mysql.spider_tables;\n+-------------+\n| table_name  |\n+-------------+\n| spt_a#P#pt1 |\n| spt_a#P#pt2 |\n| spt_a#P#pt3 |\n+-------------+\n\nReturns 1 if the data was copied successfully, or 0 if copying the data failed.\n\nURL: https://mariadb.com/kb/en/spider_copy_tables/','','https://mariadb.com/kb/en/spider_copy_tables/'),(776,'SPIDER_DIRECT_SQL',42,'Syntax\n------\n\nSPIDER_DIRECT_SQL(\'sql\', \'tmp_table_list\', \'parameters\')\n\nDescription\n-----------\n\nA UDF installed with the Spider Storage Engine, this function is used to\nexecute the SQL string sql on the remote server, as defined in parameters. If\nany resultsets are returned, they are stored in the tmp_table_list.\n\nThe function returns 1 if the SQL executes successfully, or 0 if it fails.\n\nExamples\n--------\n\nSELECT SPIDER_DIRECT_SQL(\'SELECT * FROM s\', \'\', \'srv \"node1\", port \"8607\"\');\n+----------------------------------------------------------------------+\n| SPIDER_DIRECT_SQL(\'SELECT * FROM s\', \'\', \'srv \"node1\", port \"8607\"\') |\n+----------------------------------------------------------------------+\n|                                                                    1 |\n+----------------------------------------------------------------------+\n\nURL: https://mariadb.com/kb/en/spider_direct_sql/','','https://mariadb.com/kb/en/spider_direct_sql/'),(777,'SPIDER_FLUSH_TABLE_MON_CACHE',42,'Syntax\n------\n\nSPIDER_FLUSH_TABLE_MON_CACHE()\n\nDescription\n-----------\n\nA UDF installed with the Spider Storage Engine, this function is used for\nrefreshing monitoring server information. It returns a value of 1.\n\nExamples\n--------\n\nSELECT SPIDER_FLUSH_TABLE_MON_CACHE();\n+--------------------------------+\n| SPIDER_FLUSH_TABLE_MON_CACHE() |\n+--------------------------------+\n|                              1 |\n+--------------------------------+\n\nURL: https://mariadb.com/kb/en/spider_flush_table_mon_cache/','','https://mariadb.com/kb/en/spider_flush_table_mon_cache/'),(778,'COLUMN_ADD',43,'Syntax\n------\n\nCOLUMN_ADD(dyncol_blob, column_nr, value [as type], [column_nr, value [as\ntype]]...);\nCOLUMN_ADD(dyncol_blob, column_name, value [as type], [column_name, value [as\ntype]]...);\n\nDescription\n-----------\n\nAdds or updates dynamic columns.\n\n* dyncol_blob must be either a valid dynamic columns blob (for example,\nCOLUMN_CREATE returns such blob), or an empty string.\n* column_name specifies the name of the column to be added. If dyncol_blob\nalready has a column with this name, it will be overwritten.\n* value specifies the new value for the column.  Passing a NULL value will\ncause the column to be deleted.\n* as type is optional. See #datatypes section for a discussion about types.\n\nThe return value is a dynamic column blob after the modifications.\n\nExamples\n--------\n\nUPDATE t1 SET dyncol_blob=COLUMN_ADD(dyncol_blob, \"column_name\", \"value\")\nWHERE id=1;\n\nNote: COLUMN_ADD() is a regular function (just like CONCAT()), hence, in order\nto update the value in the table you have to use the UPDATE ... SET\ndynamic_col=COLUMN_ADD(dynamic_col, ....) pattern.\n\nURL: https://mariadb.com/kb/en/column_add/','','https://mariadb.com/kb/en/column_add/'),(779,'COLUMN_CHECK',43,'Syntax\n------\n\nCOLUMN_CHECK(dyncol_blob);\n\nDescription\n-----------\n\nCheck if dyncol_blob is a valid packed dynamic columns blob. Return value of 1\nmeans the blob is valid, return value of 0 means it is not.\n\nRationale: Normally, one works with valid dynamic column blobs. Functions like\nCOLUMN_CREATE, COLUMN_ADD, COLUMN_DELETE always return valid dynamic column\nblobs. However, if a dynamic column blob is accidentally truncated, or\ntranscoded from one character set to another, it will be corrupted. This\nfunction can be used to check if a value in a blob field is a valid dynamic\ncolumn blob.\n\nURL: https://mariadb.com/kb/en/column_check/','','https://mariadb.com/kb/en/column_check/'),(780,'COLUMN_CREATE',43,'Syntax\n------\n\nCOLUMN_CREATE(column_nr, value [as type], [column_nr, value [as type]]...);\nCOLUMN_CREATE(column_name, value [as type], [column_name, value [as type]]...);\n\nDescription\n-----------\n\nReturns a dynamic columns blob that stores the specified columns with values.\n\nThe return value is suitable for\n\n* storing in a table\n* further modification with other dynamic columns functions\n\nThe as type part allows one to specify the value type. In most cases, this is\nredundant because MariaDB will be able to deduce the type of the value.\nExplicit type specification may be needed when the type of the value is not\napparent. For example, a literal \'2012-12-01\' has a CHAR type by default, one\nwill need to specify \'2012-12-01\' AS DATE to have it stored as a date. See\nDynamic Columns:Datatypes for further details.\n\nExamples\n--------\n\nINSERT INTO tbl SET dyncol_blob=COLUMN_CREATE(\"column_name\", \"value\");\n\nURL: https://mariadb.com/kb/en/column_create/','','https://mariadb.com/kb/en/column_create/'),(781,'COLUMN_DELETE',43,'Syntax\n------\n\nCOLUMN_DELETE(dyncol_blob, column_nr, column_nr...);\nCOLUMN_DELETE(dyncol_blob, column_name, column_name...);\n\nDescription\n-----------\n\nDeletes a dynamic column with the specified name. Multiple names can be given.\nThe return value is a dynamic column blob after the modification.\n\nURL: https://mariadb.com/kb/en/column_delete/','','https://mariadb.com/kb/en/column_delete/'),(782,'COLUMN_EXISTS',43,'Syntax\n------\n\nCOLUMN_EXISTS(dyncol_blob, column_nr);\nCOLUMN_EXISTS(dyncol_blob, column_name);\n\nDescription\n-----------\n\nChecks if a column with name column_name exists in dyncol_blob. If yes, return\n1, otherwise return 0. See dynamic columns for more information.\n\nURL: https://mariadb.com/kb/en/column_exists/','','https://mariadb.com/kb/en/column_exists/'),(783,'COLUMN_GET',43,'Syntax\n------\n\nCOLUMN_GET(dyncol_blob, column_nr as type);\nCOLUMN_GET(dyncol_blob, column_name as type);\n\nDescription\n-----------\n\nGets the value of a dynamic column by its name. If no column with the given\nname exists, NULL will be returned.\n\ncolumn_name as type requires that one specify the datatype of the dynamic\ncolumn they are reading.\n\nThis may seem counter-intuitive: why would one need to specify which datatype\nthey\'re retrieving? Can\'t the dynamic columns system figure the datatype from\nthe data being stored?\n\nThe answer is: SQL is a statically-typed language. The SQL interpreter needs\nto know the datatypes of all expressions before the query is run (for example,\nwhen one is using prepared statements and runs \"select COLUMN_GET(...)\", the\nprepared statement API requires the server to inform the client about the\ndatatype of the column being read before the query is executed and the server\ncan see what datatype the column actually has).\n\nLengths\n-------\n\nIf you\'re running queries like:\n\nSELECT COLUMN_GET(blob, \'colname\' as CHAR) ...\n\nwithout specifying a maximum length (i.e. using as CHAR, not as CHAR(n)),\nMariaDB will report the maximum length of the resultset column to be\n16,777,216. This may cause excessive memory usage in some client libraries,\nbecause they try to pre-allocate a buffer of maximum resultset width. To avoid\nthis problem, use CHAR(n) whenever you\'re using COLUMN_GET in the select list.\n\nSee Dynamic Columns:Datatypes for more information about datatypes.\n\nURL: https://mariadb.com/kb/en/column_get/','','https://mariadb.com/kb/en/column_get/'),(784,'COLUMN_JSON',43,'Syntax\n------\n\nCOLUMN_JSON(dyncol_blob)\n\nDescription\n-----------\n\nReturns a JSON representation of data in dyncol_blob. Can also be used to\ndisplay nested columns. See dynamic columns for more information.\n\nExample\n-------\n\nselect item_name, COLUMN_JSON(dynamic_cols) from assets;\n+-----------------+----------------------------------------+\n| item_name       | COLUMN_JSON(dynamic_cols)              |\n+-----------------+----------------------------------------+\n| MariaDB T-shirt | {\"size\":\"XL\",\"color\":\"blue\"}           |\n| Thinkpad Laptop | {\"color\":\"black\",\"warranty\":\"3 years\"} |\n+-----------------+----------------------------------------+\n\nLimitation: COLUMN_JSON will decode nested dynamic columns at a nesting level\nof not more than 10 levels deep. Dynamic columns that are nested deeper than\n10 levels will be shown as BINARY string, without encoding.\n\nURL: https://mariadb.com/kb/en/column_json/','','https://mariadb.com/kb/en/column_json/'),(785,'COLUMN_LIST',43,'Syntax\n------\n\nCOLUMN_LIST(dyncol_blob);\n\nDescription\n-----------\n\nReturns a comma-separated list of column names. The names are quoted with\nbackticks.\n\nSee dynamic columns for more information.\n\nURL: https://mariadb.com/kb/en/column_list/','','https://mariadb.com/kb/en/column_list/'),(786,'System-Versioned Tables',44,'MariaDB supports temporal data tables in the form of system-versioning tables\n(allowing you to query and operate on historic data, discussed below),\napplication-time periods (allow you to query and operate on a temporal range\nof data), and bitemporal tables (which combine both system-versioning and\napplication-time periods).\n\nSystem-Versioned Tables\n-----------------------\n\nSystem-versioned tables store the history of all changes, not only data which\nis currently valid. This allows data analysis for any point in time, auditing\nof changes and comparison of data from different points in time. Typical uses\ncases are:\n\n* Forensic analysis & legal requirements to store data for N years.\n* Data analytics (retrospective, trends etc.), e.g. to get your staff\ninformation as of one year ago.\n* Point-in-time recovery - recover a table state as of particular point in\ntime.\n\nSystem-versioned tables were first introduced in the SQL:2011 standard.\n\nCreating a System-Versioned Table\n---------------------------------\n\nThe CREATE TABLE syntax has been extended to permit creating a\nsystem-versioned table. To be system-versioned, according to SQL:2011, a table\nmust have two generated columns, a period, and a special table option clause:\n\nCREATE TABLE t(\n x INT,\n start_timestamp TIMESTAMP(6) GENERATED ALWAYS AS ROW START,\n end_timestamp TIMESTAMP(6) GENERATED ALWAYS AS ROW END,\n PERIOD FOR SYSTEM_TIME(start_timestamp, end_timestamp)\n) WITH SYSTEM VERSIONING;\n\nIn MariaDB one can also use a simplified syntax:\n\nCREATE TABLE t (\n x INT\n) WITH SYSTEM VERSIONING;\n\nIn the latter case no extra columns will be created and they won\'t clutter the\noutput of, say, SELECT * FROM t. The versioning information will still be\nstored, and it can be accessed via the pseudo-columns ROW_START and ROW_END:\n\nSELECT x, ROW_START, ROW_END FROM t;\n\nAdding or Removing System Versioning To/From a Table\n----------------------------------------------------\n\nAn existing table can be altered to enable system versioning for it.\n\nCREATE TABLE t(\n x INT\n);\n\nALTER TABLE t ADD SYSTEM VERSIONING;\n\nSHOW CREATE TABLE t\\G\n*************************** 1. row ***************************\n   Table: t\nCreate Table: CREATE TABLE `t` (\n `x` int(11) DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING\n\nSimilarly, system versioning can be removed from a table:\n\nALTER TABLE t DROP SYSTEM VERSIONING;\n\nSHOW CREATE TABLE t\\G\n*************************** 1. row ***************************\n   Table: t\nCreate Table: CREATE TABLE `t` (\n `x` int(11) DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=latin1\n\nOne can also add system versioning with all columns created explicitly:\n\nALTER TABLE t ADD COLUMN ts TIMESTAMP(6) GENERATED ALWAYS AS ROW START,\n       ADD COLUMN te TIMESTAMP(6) GENERATED ALWAYS AS ROW END,\n       ADD PERIOD FOR SYSTEM_TIME(ts, te),\n       ADD SYSTEM VERSIONING;\n\nSHOW CREATE TABLE t\\G\n*************************** 1. row ***************************\n   Table: t\nCreate Table: CREATE TABLE `t` (\n `x` int(11) DEFAULT NULL,\n `ts` timestamp(6) GENERATED ALWAYS AS ROW START,\n `te` timestamp(6) GENERATED ALWAYS AS ROW END,\n PERIOD FOR SYSTEM_TIME (`ts`, `te`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING\n\nInserting Data\n--------------\n\nWhen data is inserted into a system-versioned table, it is given a row_start\nvalue of the current timestamp, and a row_end value of\nFROM_UNIXTIME(2147483647.999999). The current timestamp can be adjusted by\nsetting the timestamp system variable, for example:\n\nSELECT NOW();\n+---------------------+\n| NOW()               |\n+---------------------+\n| 2022-10-24 23:09:38 |\n+---------------------+\n\nINSERT INTO t VALUES(1);\n\nSET @@timestamp = UNIX_TIMESTAMP(\'2033-10-24\');\n\nINSERT INTO t VALUES(2);\n\nSET @@timestamp = default;\n\nINSERT INTO t VALUES(3);\n\nSELECT a,row_start,row_end FROM t;\n+------+----------------------------+----------------------------+\n| a    | row_start                  | row_end                    |\n+------+----------------------------+----------------------------+\n|    1 | 2022-10-24 23:09:38.951347 | 2038-01-19 05:14:07.999999 |\n|    2 | 2033-10-24 00:00:00.000000 | 2038-01-19 05:14:07.999999 |\n|    3 | 2022-10-24 23:09:38.961857 | 2038-01-19 05:14:07.999999 |\n+------+----------------------------+----------------------------+\n\nQuerying Historical Data\n------------------------\n\nSELECT\n------\n\nTo query the historical data one uses the clause FOR SYSTEM_TIME directly\nafter the table name (before the table alias, if any). SQL:2011 provides three\nsyntactic extensions:\n\n* AS OF is used to see the table as it was at a specific point in time in the\npast:\n\nSELECT * FROM t FOR SYSTEM_TIME AS OF TIMESTAMP\'2016-10-09 08:07:06\';\n\n* BETWEEN start AND end will show all rows that were visible at any point\nbetween two specified points in time. It works inclusively, a row visible\nexactly at start or exactly at end will be shown too.\n\nSELECT * FROM t FOR SYSTEM_TIME BETWEEN (NOW() - INTERVAL 1 YEAR) AND NOW();\n\n* FROM start TO end will also show all rows that were visible at any point\nbetween two specified points in time, including start, but excluding end.\n\nSELECT * FROM t FOR SYSTEM_TIME FROM \'2016-01-01 00:00:00\' TO \'2017-01-01\n00:00:00\';\n\nAdditionally MariaDB implements a non-standard extension:\n\n* ALL will show all rows, historical and current.\n\nSELECT * FROM t FOR SYSTEM_TIME ALL;\n\nIf the FOR SYSTEM_TIME clause is not used, the table will show the current\ndata. This is usually the same as if one had specified FOR SYSTEM_TIME AS OF\nCURRENT_TIMESTAMP, unless one has adjusted the row_start value (until MariaDB\n10.11, only possible by setting the secure_timestamp variable). For example:\n\nCREATE OR REPLACE TABLE t (a int) WITH SYSTEM VERSIONING;\n\nSELECT NOW();\n+---------------------+\n| NOW()               |\n+---------------------+\n| 2022-10-24 23:43:37 |\n+---------------------+\n\nINSERT INTO t VALUES (1);\n\nSET @@timestamp = UNIX_TIMESTAMP(\'2033-03-03\');\n\nINSERT INTO t VALUES (2);\n\nDELETE FROM t;\n\nSET @@timestamp = default;\n\nSELECT a, row_start, row_end FROM t FOR SYSTEM_TIME ALL;\n+------+----------------------------+----------------------------+\n| a    | row_start                  | row_end                    |\n+------+----------------------------+----------------------------+\n|    1 | 2022-10-24 23:43:37.192725 | 2033-03-03 00:00:00.000000 |\n|    2 | 2033-03-03 00:00:00.000000 | 2033-03-03 00:00:00.000000 |\n+------+----------------------------+----------------------------+\n2 rows in set (0.000 sec)\n\nSELECT a, row_start, row_end FROM t FOR SYSTEM_TIME AS OF CURRENT_TIMESTAMP;\n+------+----------------------------+----------------------------+\n| a    | row_start                  | row_end                    |\n+------+----------------------------+----------------------------+\n|    1 | 2022-10-24 23:43:37.192725 | 2033-03-03 00:00:00.000000 |\n+------+----------------------------+----------------------------+\n1 row in set (0.000 sec)\n\nSELECT a, row_start, row_end FROM t;\nEmpty set (0.001 sec)\n\nViews and Subqueries\n--------------------\n\nWhen a system-versioned tables is used in a view or in a subquery in the from\nclause, FOR SYSTEM_TIME can be used directly in the view or subquery body, or\n(non-standard) applied to the whole view when it\'s being used in a SELECT:\n\nCREATE VIEW v1 AS SELECT * FROM t FOR SYSTEM_TIME AS OF TIMESTAMP\'2016-10-09\n08:07:06\';\n\nOr\n\nCREATE VIEW v1 AS SELECT * FROM t;\nSELECT * FROM v1 FOR SYSTEM_TIME AS OF TIMESTAMP\'2016-10-09 08:07:06\';\n\nUse in Replication and Binary Logs\n----------------------------------\n\nTables that use system-versioning implicitly add the row_end column to the\nPrimary Key. While this is generally not an issue for most use cases, it can\nlead to problems when re-applying write statements from the binary log or in\nreplication environments, where a primary retries an SQL statement on the\nreplica.\n\nSpecifically, these writes include a value on the row_end column containing\nthe timestamp from when the write was initially made. The re-occurrence of the\nPrimary Key with the old system-versioning columns raises an error due to the\nduplication.\n\nTo mitigate this with MariaDB Replication, set the secure_timestamp system\nvariable to YES on the replica. When set, the replica uses its own system\nclock when applying to the row log, meaning that the primary can retry as many\ntimes as needed without causing a conflict. The retries generate new\nhistorical rows with new values for the row_start and row_end columns.\n\nTransaction-Precise History in InnoDB\n-------------------------------------\n\nA point in time when a row was inserted or deleted does not necessarily mean\nthat a change became visible at the same moment. With transactional tables, a\nrow might have been inserted in a long transaction, and became visible hours\nafter it was inserted.\n\nFor some applications — for example, when doing data analytics on one-year-old\ndata — this distinction does not matter much. For others — forensic analysis —\nit might be crucial.\n\nMariaDB supports transaction-precise history (only for the InnoDB storage\nengine) that allows seeing the data exactly as it would\'ve been seen by a new\nconnection doing a SELECT at the specified point in time — rows inserted\nbefore that point, but committed after will not be shown.\n\nTo use transaction-precise history, InnoDB needs to remember not timestamps,\nbut transaction identifier per row. This is done by creating generated columns\nas BIGINT UNSIGNED, not TIMESTAMP(6):\n\nCREATE TABLE t(\n x INT,\n start_trxid BIGINT UNSIGNED GENERATED ALWAYS AS ROW START,\n end_trxid BIGINT UNSIGNED GENERATED ALWAYS AS ROW END,\n PERIOD FOR SYSTEM_TIME(start_trxid, end_trxid)\n) WITH SYSTEM VERSIONING;\n\nThese columns must be specified explicitly, but they can be made INVISIBLE to\navoid cluttering SELECT * output.\n\nWhen one uses transaction-precise history, one can optionally use transaction\nidentifiers in the FOR SYSTEM_TIME clause:\n\nSELECT * FROM t FOR SYSTEM_TIME AS OF TRANSACTION 12345;\n\nThis will show the data, exactly as it was seen by the transaction with the\nidentifier 12345.\n\nStoring the History Separately\n------------------------------\n\nWhen the history is stored together with the current data, it increases the\nsize of the table, so current data queries — table scans and index searches —\nwill take more time, because they will need to skip over historical data. If\nmost queries on that table use only current data, it might make sense to store\nthe history separately, to reduce the overhead from versioning.\n\nThis is done by partitioning the table by SYSTEM_TIME. Because of the\npartition pruning optimization, all current data queries will only access one\npartition, the one that stores current data.\n\nThis example shows how to create such a partitioned table:\n\nCREATE TABLE t (x INT) WITH SYSTEM VERSIONING\n PARTITION BY SYSTEM_TIME (\n  PARTITION p_hist HISTORY,\n  PARTITION p_cur CURRENT\n );\n\nIn this example all history will be stored in the partition p_hist while all\ncurrent data will be in the partition p_cur. The table must have exactly one\ncurrent partition and at least one historical partition.\n\nPartitioning by SYSTEM_TIME also supports automatic partition rotation. One\ncan rotate historical partitions by time or by size. This example shows how to\nrotate partitions by size:\n\nCREATE TABLE t (x INT) WITH SYSTEM VERSIONING\n PARTITION BY SYSTEM_TIME LIMIT 100000 (\n  PARTITION p0 HISTORY,\n  PARTITION p1 HISTORY,\n  PARTITION pcur CURRENT\n );\n\nMariaDB will start writing history rows into partition p0, and when it reaches\na size of 100000 rows, MariaDB will switch to partition p1. There are only two\nhistorical partitions, so when p1 overflows, MariaDB will issue a warning, but\nwill continue writing into it.\n\nSimilarly, one can rotate partitions by time:\n\nCREATE TABLE t (x INT) WITH SYSTEM VERSIONING\n PARTITION BY SYSTEM_TIME INTERVAL 1 WEEK (\n  PARTITION p0 HISTORY,\n  PARTITION p1 HISTORY,\n  PARTITION p2 HISTORY,\n  PARTITION pcur CURRENT\n );\n\nThis means that the history for the first week after the table was created\nwill be stored in p0. The history for the second week — in p1, and all later\nhistory will go into p2. One can see the exact rotation time for each\npartition in the INFORMATION_SCHEMA.PARTITIONS table.\n\nIt is possible to combine partitioning by SYSTEM_TIME and subpartitions:\n\nCREATE TABLE t (x INT) WITH SYSTEM VERSIONING\n PARTITION BY SYSTEM_TIME\n  SUBPARTITION BY KEY (x)\n  SUBPARTITIONS 4 (\n  PARTITION ph HISTORY,\n  PARTITION pc CURRENT\n );\n\nDefault Partitions\n------------------\n\nMariaDB starting with 10.5.0\n----------------------------\nSince partitioning by current and historical data is such a typical usecase,\nfrom MariaDB 10.5, it is possible to use a simplified statement to do so. For\nexample, instead of\n\nCREATE TABLE t (x INT) WITH SYSTEM VERSIONING \n PARTITION BY SYSTEM_TIME (\n  PARTITION p0 HISTORY,\n  PARTITION pn CURRENT\n);\n\nyou can use\n\nCREATE TABLE t (x INT) WITH SYSTEM VERSIONING \n PARTITION BY SYSTEM_TIME;\n\nYou can also specify the number of partitions, which is useful if you want to\nrotate history by time, for example:\n\nCREATE TABLE t (x INT) WITH SYSTEM VERSIONING \n PARTITION BY SYSTEM_TIME\n  INTERVAL 1 MONTH\n  PARTITIONS 12;\n\nSpecifying the number of partitions without specifying a rotation condition\nwill result in a warning:\n\nCREATE OR REPLACE TABLE t (x INT) WITH SYSTEM VERSIONING\n PARTITION BY SYSTEM_TIME PARTITIONS 12;\nQuery OK, 0 rows affected, 1 warning (0.518 sec)\n\nWarning (Code 4115): Maybe missing parameters: no rotation condition for\nmultiple HISTORY partitions.\n\nwhile specifying only 1 partition will result in an error:\n\nCREATE OR REPLACE TABLE t (x INT) WITH SYSTEM VERSIONING\n PARTITION BY SYSTEM_TIME PARTITIONS 1;\nERROR 4128 (HY000): Wrong partitions for `t`: must have at least one HISTORY\nand exactly one last CURRENT\n\nAutomatically Creating Partitions\n---------------------------------\n\nMariaDB starting with 10.9.1\n----------------------------\nFrom MariaDB 10.9.1, the AUTO keyword can be used to automatically create\nhistory partitions.\n\nFor example\n\nCREATE TABLE t1 (x int) WITH SYSTEM VERSIONING\n  PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR AUTO;\n\nCREATE TABLE t1 (x int) WITH SYSTEM VERSIONING\n PARTITION BY SYSTEM_TIME INTERVAL 1 MONTH\n STARTS \'2021-01-01 00:00:00\' AUTO PARTITIONS 12;\n\nCREATE TABLE t1 (x int) WITH SYSTEM VERSIONING\n PARTITION BY SYSTEM_TIME LIMIT 1000 AUTO;\n\nOr with explicit partitions:\n\nCREATE TABLE t1 (x int) WITH SYSTEM VERSIONING\n PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR AUTO\n (PARTITION p0 HISTORY, PARTITION pn CURRENT);\n\nTo disable or enable auto-creation one can use ALTER TABLE by adding or\nremoving AUTO from the partitioning specification:\n\nCREATE TABLE t1 (x int) WITH SYSTEM VERSIONING\n PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR AUTO;\n\n# Disables auto-creation:\nALTER TABLE t1 PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR;\n\n# Enables auto-creation:\nALTER TABLE t1 PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR AUTO;\n\nIf the rest of the partitioning specification is identical to CREATE TABLE, no\nrepartitioning will be done (for details see MDEV-27328).\n\nRemoving Old History\n--------------------\n\nBecause it stores all the history, a system-versioned table might grow very\nlarge over time. There are many options to trim down the space and remove the\nold history.\n\nOne can completely drop the versioning from the table and add it back again,\nthis will delete all the history:\n\nALTER TABLE t DROP SYSTEM VERSIONING;\nALTER TABLE t ADD SYSTEM VERSIONING;\n\nIt might be a rather time-consuming operation, though, as the table will need\nto be rebuilt, possibly twice (depending on the storage engine).\n\nAnother option would be to use partitioning and drop some of historical\npartitions:\n\nALTER TABLE t DROP PARTITION p0;\n\nNote, that one cannot drop a current partition or the only historical\npartition.\n\nAnd the third option; one can use a variant of the DELETE statement to prune\nthe history:\n\nDELETE HISTORY FROM t;\n\nor only old history up to a specific point in time:\n\nDELETE HISTORY FROM t BEFORE SYSTEM_TIME \'2016-10-09 08:07:06\';\n\nor to a specific transaction (with BEFORE SYSTEM_TIME TRANSACTION xxx).\n\nTo protect the integrity of the history, this statement requires a special\nDELETE HISTORY privilege.\n\nCurrently, using the DELETE HISTORY statement with a BEFORE SYSTEM_TIME\ngreater than the ROW_END of the active records (as a TIMESTAMP, this has a\nmaximum value of \'2038-01-19 03:14:07\' UTC) will result in the historical\nrecords being dropped, and the active records being deleted and moved to\nhistory. See MDEV-25468.\n\nPrior to MariaDB 10.4.5, the TRUNCATE TABLE statement drops all historical\nrecords from a system-versioned-table.\n\nFrom MariaDB 10.4.5, historic data is protected from TRUNCATE statements, as\nper the SQL standard, and an Error 4137 is instead raised:\n\nTRUNCATE t;\nERROR 4137 (HY000): System-versioned tables do not support TRUNCATE TABLE\n\nExcluding Columns From Versioning\n---------------------------------\n\nAnother MariaDB extension allows to version only a subset of columns in a\ntable. This is useful, for example, if you have a table with user information\nthat should be versioned, but one column is, let\'s say, a login counter that\nis incremented often and is not interesting to version. Such a column can be\nexcluded from versioning by declaring it WITHOUT VERSIONING\n\nCREATE TABLE t (\n x INT,\n y INT WITHOUT SYSTEM VERSIONING\n) WITH SYSTEM VERSIONING;\n\nA column can also be declared WITH VERSIONING, that will automatically make\nthe table versioned. The statement below is equivalent to the one above:\n\nCREATE TABLE t (\n x INT WITH SYSTEM VERSIONING,\n y INT\n);\n\nChanges in other sections: https://mariadb.com/kb/en/create-table/\nhttps://mariadb.com/kb/en/alter-table/ https://mariadb.com/kb/en/join-syntax/\nhttps://mariadb.com/kb/en/partitioning-types-overview/\nhttps://mariadb.com/kb/en/date-and-time-units/\nhttps://mariadb.com/kb/en/delete/ https://mariadb.com/kb/en/grant/\n\nthey all reference back to this page\n\nAlso, TODO:\n\n* limitations (size, speed, adding history to unique not nullable columns)\n\nSystem Variables\n----------------\n\nThere are a number of system variables related to system-versioned tables:\n\nsystem_versioning_alter_history\n-------------------------------\n\n* Description: SQL:2011 does not allow ALTER TABLE on system-versioned tables.\nWhen this variable is set to ERROR, an attempt to alter a system-versioned\ntable will result in an error. When this variable is set to KEEP, ALTER TABLE\nwill be allowed, but the history will become incorrect — querying historical\ndata will show the new table structure. This mode is still useful, for\nexample, when adding new columns to a table. Note that if historical data\ncontains or would contain nulls, attempting to ALTER these columns to be NOT\nNULL will return an error (or warning if strict_mode is not set).\n* Commandline: --system-versioning-alter-history=value\n* Scope: Global, Session\n* Dynamic: Yes\n* Type: Enum\n* Default Value: ERROR\n* Valid Values: ERROR, KEEP\n\nsystem_versioning_asof\n----------------------\n\n* Description: If set to a specific timestamp value, an implicit FOR\nSYSTEM_TIME AS OF clause will be applied to all queries. This is useful if one\nwants to do many queries for history at the specific point in time. Set it to\nDEFAULT to restore the default behavior. Has no effect on DML, so queries such\nas INSERT .. SELECT and REPLACE .. SELECT need to state AS OF explicitly.\n* Commandline: None\n* Scope: Global, Session\n* Dynamic: Yes\n* Type: Varchar\n* Default Value: DEFAULT\n\nsystem_versioning_innodb_algorithm_simple\n-----------------------------------------\n\n* Description: Never fully implemented and removed in the following release.\n* Commandline: --system-versioning-innodb-algorithm-simple[={0|1}]\n* Scope: Global, Session\n* Dynamic: Yes\n* Type: Boolean\n* Default Value: ON\n* Introduced: MariaDB 10.3.4\n* Removed: MariaDB 10.3.5\n\nsystem_versioning_insert_history\n--------------------------------\n\n* Description: Allows direct inserts into ROW_START and ROW_END columns if\nsecure_timestamp allows changing timestamp.\n* Commandline: --system-versioning-insert-history[={0|1}]\n* Scope: Global, Session\n* Dynamic: Yes\n* Type: Boolean\n* Default Value: OFF\n* Introduced: MariaDB 10.11.0\n\nLimitations\n-----------\n\n* Versioning clauses can not be applied to generated (virtual and persistent)\ncolumns.\n* Before MariaDB 10.11, mariadb-dump did not read historical rows from\nversioned tables, and so historical data would not be backed up. Also, a\nrestore of the timestamps would not be possible as they cannot be defined by\nan insert/a user. From MariaDB 10.11, use the -H or --dump-history options to\ninclude the history.\n\nURL: https://mariadb.com/kb/en/system-versioned-tables/','','https://mariadb.com/kb/en/system-versioned-tables/'),(787,'ST_AsGeoJSON',45,'Syntax\n------\n\nST_AsGeoJSON(g[, max_decimals[, options]])\n\nDescription\n-----------\n\nReturns the given geometry g as a GeoJSON element. The optional max_decimals\nlimits the maximum number of decimals displayed.\n\nThe optional options flag can be set to 1 to add a bounding box to the output.\n\nExamples\n--------\n\nSELECT ST_AsGeoJSON(ST_GeomFromText(\'POINT(5.3 7.2)\'));\n+-------------------------------------------------+\n| ST_AsGeoJSON(ST_GeomFromText(\'POINT(5.3 7.2)\')) |\n+-------------------------------------------------+\n| {\"type\": \"Point\", \"coordinates\": [5.3, 7.2]}    |\n+-------------------------------------------------+\n\nURL: https://mariadb.com/kb/en/geojson-st_asgeojson/','','https://mariadb.com/kb/en/geojson-st_asgeojson/'),(788,'ST_GeomFromGeoJSON',45,'MariaDB starting with 10.2.4\n----------------------------\nST_GeomFromGeoJSON was added in MariaDB 10.2.4\n\nSyntax\n------\n\nST_GeomFromGeoJSON(g[, option])\n\nDescription\n-----------\n\nGiven a GeoJSON input g, returns a geometry object. The option specifies what\nto do if g contains geometries with coordinate dimensions higher than 2.\n\n+---------------------------+------------------------------------------------+\n| Option                    | Description                                    |\n+---------------------------+------------------------------------------------+\n| 1                         | Return an error (the default)                  |\n+---------------------------+------------------------------------------------+\n| 2 - 4                     | The document is accepted, but the coordinates  |\n|                           | for higher coordinate dimensions are stripped  |\n|                           | off.                                           |\n+---------------------------+------------------------------------------------+\n\nNote that this function did not work correctly before MariaDB 10.2.8 - see\nMDEV-12180.\n\nExamples\n--------\n\nSET @j = \'{ \"type\": \"Point\", \"coordinates\": [5.3, 15.0]}\';\n\nSELECT ST_AsText(ST_GeomFromGeoJSON(@j));\n+-----------------------------------+\n| ST_AsText(ST_GeomFromGeoJSON(@j)) |\n+-----------------------------------+\n| POINT(5.3 15)                     |\n+-----------------------------------+\n\nURL: https://mariadb.com/kb/en/st_geomfromgeojson/','','https://mariadb.com/kb/en/st_geomfromgeojson/'),(789,'Operator Precedence',46,'The precedence is the order in which the SQL operators are evaluated.\n\nThe following list shows the SQL operator precedence. Operators that appear\nfirst in the list have a higher precedence. Operators which are listed\ntogether have the same precedence.\n\n* INTERVAL\n* BINARY, COLLATE\n* !\n* - (unary minus), [[bitwise-not|]] (unary bit inversion)\n* || (string concatenation)\n* ^\n* *, /, DIV, %, MOD\n* -, +\n* <<, >>\n* &\n* |\n* = (comparison), <=>, >=, >, <=, <, <>, !=, IS, LIKE, REGEXP, IN\n* BETWEEN, CASE, WHEN, THEN, ELSE, END\n* NOT\n* &&, AND\n* XOR\n* || (logical or), OR\n* = (assignment), :=\n\nFunctions precedence is always higher than operators precedence.\n\nIn this page CASE refers to the CASE operator, not to the CASE statement.\n\nIf the HIGH_NOT_PRECEDENCE SQL_MODE is set, NOT has the same precedence as !.\n\nThe || operator\'s precedence, as well as its meaning, depends on the\nPIPES_AS_CONCAT SQL_MODE flag: if it is on, || can be used to concatenate\nstrings (like the CONCAT() function) and has a higher precedence.\n\nThe = operator\'s precedence depends on the context - it is higher when = is\nused as a comparison operator.\n\nParenthesis can be used to modify the operators precedence in an expression.\n\nShort-circuit evaluation\n------------------------\n\nThe AND, OR, && and || operators support short-circuit evaluation. This means\nthat, in some cases, the expression on the right of those operators is not\nevaluated, because its result cannot affect the result. In the following\ncases, short-circuit evaluation is used and x() is not evaluated:\n\n* FALSE AND x()\n* FALSE && x()\n* TRUE OR x()\n* TRUE || x()\n* NULL BETWEEN x() AND x()\n\nNote however that the short-circuit evaluation does not apply to NULL AND x().\nAlso, BETWEEN\'s right operands are not evaluated if the left operand is NULL,\nbut in all other cases all the operands are evaluated.\n\nThis is a speed optimization. Also, since functions can have side-effects,\nthis behavior can be used to choose whether execute them or not using a\nconcise syntax:\n\nSELECT some_function() OR log_error();\n\nURL: https://mariadb.com/kb/en/operator-precedence/','','https://mariadb.com/kb/en/operator-precedence/'),(790,'Addition Operator (+)',47,'Syntax\n------\n\n+\n\nDescription\n-----------\n\nAddition.\n\nIf both operands are integers, the result is calculated with BIGINT precision.\nIf either integer is unsigned, the result is also an unsigned integer.\n\nFor real or string operands, the operand with the highest precision determines\nthe result precision.\n\nExamples\n--------\n\nSELECT 3+5;\n+-----+\n| 3+5 |\n+-----+\n|   8 |\n+-----+\n\nURL: https://mariadb.com/kb/en/addition-operator/','','https://mariadb.com/kb/en/addition-operator/'),(791,'Division Operator (/)',47,'Syntax\n------\n\n/\n\nDescription\n-----------\n\nDivision operator. Dividing by zero will return NULL. By default, returns four\ndigits after the decimal. This is determined by the server system variable\ndiv_precision_increment which by default is four. It can be set from 0 to 30.\n\nDividing by zero returns NULL. If the ERROR_ON_DIVISION_BY_ZERO SQL_MODE is\nused (the default since MariaDB 10.2.4), a division by zero also produces a\nwarning.\n\nExamples\n--------\n\nSELECT 4/5;\n+--------+\n| 4/5    |\n+--------+\n| 0.8000 |\n+--------+\n\nSELECT 300/(2-2);\n+-----------+\n| 300/(2-2) |\n+-----------+\n|      NULL |\n+-----------+\n\nSELECT 300/7;\n+---------+\n| 300/7   |\n+---------+\n| 42.8571 |\n+---------+\n\nChanging div_precision_increment for the session from the default of four to\nsix:\n\nSET div_precision_increment = 6;\n\nSELECT 300/7;\n+-----------+\n| 300/7     |\n+-----------+\n| 42.857143 |\n+-----------+\n\nSELECT 300/7;\n+-----------+\n| 300/7     |\n+-----------+\n| 42.857143 |\n+-----------+\n\nURL: https://mariadb.com/kb/en/division-operator/','','https://mariadb.com/kb/en/division-operator/'),(792,'Modulo Operator (%)',47,'Syntax\n------\n\nN % M\n\nDescription\n-----------\n\nModulo operator. Returns the remainder of N divided by M. See also MOD.\n\nExamples\n--------\n\nSELECT 1042 % 50;\n+-----------+\n| 1042 % 50 |\n+-----------+\n|        42 |\n+-----------+\n\nURL: https://mariadb.com/kb/en/modulo-operator/','','https://mariadb.com/kb/en/modulo-operator/'),(793,'Multiplication Operator (*)',47,'Syntax\n------\n\n*\n\nDescription\n-----------\n\nMultiplication operator.\n\nExamples\n--------\n\nSELECT 7*6;\n+-----+\n| 7*6 |\n+-----+\n|  42 |\n+-----+\n\nSELECT 1234567890*9876543210;\n+-----------------------+\n| 1234567890*9876543210 |\n+-----------------------+\n|  -6253480962446024716 |\n+-----------------------+\n\nSELECT 18014398509481984*18014398509481984.0;\n+---------------------------------------+\n| 18014398509481984*18014398509481984.0 |\n+---------------------------------------+\n|   324518553658426726783156020576256.0 |\n+---------------------------------------+\n\nSELECT 18014398509481984*18014398509481984;\n+-------------------------------------+\n| 18014398509481984*18014398509481984 |\n+-------------------------------------+\n|                                   0 |\n+-------------------------------------+\n\nURL: https://mariadb.com/kb/en/multiplication-operator/','','https://mariadb.com/kb/en/multiplication-operator/'),(794,'Subtraction Operator (-)',47,'Syntax\n------\n\n-\n\nDescription\n-----------\n\nSubtraction. The operator is also used as the unary minus for changing sign.\n\nIf both operands are integers, the result is calculated with BIGINT precision.\nIf either integer is unsigned, the result is also an unsigned integer, unless\nthe NO_UNSIGNED_SUBTRACTION SQL_MODE is enabled, in which case the result is\nalways signed.\n\nFor real or string operands, the operand with the highest precision determines\nthe result precision.\n\nExamples\n--------\n\nSELECT 96-9;\n+------+\n| 96-9 |\n+------+\n|   87 |\n+------+\n\nSELECT 15-17;\n+-------+\n| 15-17 |\n+-------+\n|    -2 |\n+-------+\n\nSELECT 3.66 + 1.333;\n+--------------+\n| 3.66 + 1.333 |\n+--------------+\n|        4.993 |\n+--------------+\n\nUnary minus:\n\nSELECT - (3+5);\n+---------+\n| - (3+5) |\n+---------+\n|      -8 |\n+---------+\n\nURL: https://mariadb.com/kb/en/subtraction-operator-/','','https://mariadb.com/kb/en/subtraction-operator-/'),(795,'CHANGE MASTER TO',48,'The terms master and slave have historically been used in replication, but the\nterms terms primary and replica are now preferred. The old terms are used\nstill used in parts of the documentation, and in MariaDB commands, although\nMariaDB 10.5 has begun the process of renaming. The documentation process is\nongoing. See MDEV-18777 to follow progress on this effort.\n\nSyntax\n------\n\nCHANGE MASTER [\'connection_name\'] TO master_def  [, master_def] ... \n [FOR CHANNEL \'channel_name\']\n\nmaster_def:\n  MASTER_BIND = \'interface_name\'\n | MASTER_HOST = \'host_name\'\n | MASTER_USER = \'user_name\'\n | MASTER_PASSWORD = \'password\'\n | MASTER_PORT = port_num\n | MASTER_CONNECT_RETRY = interval\n | MASTER_HEARTBEAT_PERIOD = interval\n | MASTER_LOG_FILE = \'master_log_name\'\n | MASTER_LOG_POS = master_log_pos\n | RELAY_LOG_FILE = \'relay_log_name\'\n | RELAY_LOG_POS = relay_log_pos\n | MASTER_DELAY = interval\n | MASTER_SSL = {0|1}\n | MASTER_SSL_CA = \'ca_file_name\'\n | MASTER_SSL_CAPATH = \'ca_directory_name\'\n | MASTER_SSL_CERT = \'cert_file_name\'\n | MASTER_SSL_CRL = \'crl_file_name\'\n | MASTER_SSL_CRLPATH = \'crl_directory_name\'\n | MASTER_SSL_KEY = \'key_file_name\'\n | MASTER_SSL_CIPHER = \'cipher_list\'\n | MASTER_SSL_VERIFY_SERVER_CERT = {0|1}\n | MASTER_USE_GTID = {current_pos|slave_pos|no}\n | MASTER_DEMOTE_TO_SLAVE = bool\n | IGNORE_SERVER_IDS = (server_id_list)\n | DO_DOMAIN_IDS = ([N,..])\n | IGNORE_DOMAIN_IDS = ([N,..])\n\nDescription\n-----------\n\nThe CHANGE MASTER statement sets the options that a replica uses to connect to\nand replicate from a primary.\n\nMariaDB starting with 10.7.0\n----------------------------\nThe FOR CHANNEL keyword was added for MySQL compatibility. This is identical\nto using the channel_name directly after CHANGE MASTER.\n\nMulti-Source Replication\n------------------------\n\nIf you are using multi-source replication, then you need to specify a\nconnection name when you execute CHANGE MASTER. There are two ways to do this:\n\n* Setting the default_master_connection system variable prior to executing\nCHANGE MASTER.\n* Setting the connection_name parameter when executing CHANGE MASTER.\n\ndefault_master_connection\n-------------------------\n\nSET default_master_connection = \'gandalf\';\nSTOP SLAVE;\nCHANGE MASTER TO \n MASTER_PASSWORD=\'new3cret\';\nSTART SLAVE;\n\nconnection_name\n---------------\n\nSTOP SLAVE \'gandalf\';\nCHANGE MASTER \'gandalf\' TO \n MASTER_PASSWORD=\'new3cret\';\nSTART SLAVE \'gandalf\';\n\nOptions\n-------\n\nConnection Options\n------------------\n\nMASTER_USER\n-----------\n\nThe MASTER_USER option for CHANGE MASTER defines the user account that the\nreplica will use to connect to the primary.\n\nThis user account will need the REPLICATION SLAVE privilege (or, from MariaDB\n10.5.1, the REPLICATION REPLICA on the primary.\n\nFor example:\n\nSTOP SLAVE;\nCHANGE MASTER TO\n MASTER_USER=\'repl\',\n MASTER_PASSWORD=\'new3cret\';\nSTART SLAVE;\n\nThe maximum length of the MASTER_USER string is 96 characters until MariaDB\n10.5, and 128 characters from MariaDB 10.6.\n\nMASTER_PASSWORD\n---------------\n\nThe MASTER_USER option for CHANGE MASTER defines the password that the replica\nwill use to connect to the primary as the user account defined by the\nMASTER_USER option.\n\nFor example:\n\nSTOP SLAVE;\nCHANGE MASTER TO \n MASTER_PASSWORD=\'new3cret\';\nSTART SLAVE;\n\nThe maximum length of the MASTER_PASSWORD string is 32 characters. The\neffective maximum length of the string depends on how many bytes are used per\ncharacter and can be up to 96 characters.\n\nDue to MDEV-29994, the password can be silently truncated to 41 characters\nwhen MariaDB is restarted. For this reason it is recommended to use a password\nthat is shorter than this.\n\nMASTER_HOST\n-----------\n\nThe MASTER_HOST option for CHANGE MASTER defines the hostname or IP address of\nthe primary.\n\nIf you set the value of the MASTER_HOST option to the empty string, then that\nis not the same as not setting the option\'s value at all. If you set the value\nof the MASTER_HOST option to the empty string, then the CHANGE MASTER command\nwill fail with an error. In MariaDB 5.3 and before, if you set the value of\nthe MASTER_HOST option to the empty string, then the CHANGE MASTER command\nwould succeed, but the subsequent START SLAVE command would fail.\n\nFor example:\n\nSTOP SLAVE;\nCHANGE MASTER TO\n MASTER_HOST=\'dbserver1.example.com\',\n MASTER_USER=\'repl\',\n MASTER_PASSWORD=\'new3cret\',\n MASTER_USE_GTID=slave_pos;\nSTART SLAVE;\n\nIf you set the value of the MASTER_HOST option in a CHANGE MASTER command,\nthen the replica assumes that the primary is different from before, even if\nyou set the value of this option to the same value it had previously. In this\nscenario, the replica will consider the old values for the primary\'s binary\nlog file name and position to be invalid for the new primary. As a side\neffect, if you do not explicitly set the values of the MASTER_LOG_FILE and\nMASTER_LOG_POS options in the statement, then the statement will be implicitly\nappended with MASTER_LOG_FILE=\'\' and MASTER_LOG_POS=4. However, if you enable\nGTID mode for replication by setting the MASTER_USE_GTID option to some value\nother than no in the statement, then these values will effectively be ignored\nanyway.\n\nReplicas cannot connect to primaries using Unix socket files or Windows named\npipes. The replica must connect to the primary using TCP/IP.\n\nThe maximum length of the MASTER_HOST string is 60 characters until MariaDB\n10.5, and 255 characters from MariaDB 10.6.\n\nMASTER_PORT\n-----------\n\nThe MASTER_PORT option for CHANGE MASTER defines the TCP/IP port of the\nprimary.\n\nFor example:\n\nSTOP SLAVE;\nCHANGE MASTER TO\n MASTER_HOST=\'dbserver1.example.com\',\n MASTER_PORT=3307,\n MASTER_USER=\'repl\',\n MASTER_PASSWORD=\'new3cret\',\n MASTER_USE_GTID=slave_pos;\nSTART SLAVE;\n\nIf you set the value of the MASTER_PORT option in a CHANGE MASTER command,\nthen the replica assumes that the primary is different from before, even if\nyou set the value of this option to the same value it had previously. In this\nscenario, the replica will consider the old values for the primary\'s binary\nlog file name and position to be invalid for the new primary. As a side\neffect, if you do not explicitly set the values of the MASTER_LOG_FILE and\nMASTER_LOG_POS options in the statement, then the statement will be implicitly\nappended with MASTER_LOG_FILE=\'\' and MASTER_LOG_POS=4. However, if you enable\nGTID mode for replication by setting the MASTER_USE_GTID option to some value\nother than no in the statement, then these values will effectively be ignored\nanyway.\n\nReplicas cannot connect to primaries using Unix socket files or Windows named\npipes. The replica must connect to the primary using TCP/IP.\n\nMASTER_CONNECT_RETRY\n--------------------\n\nThe MASTER_CONNECT_RETRY option for CHANGE MASTER defines how many seconds\nthat the replica will wait between connection retries. The default is 60.\n\nSTOP SLAVE;\nCHANGE MASTER TO \n MASTER_CONNECT_RETRY=20;\nSTART SLAVE;\n\nThe number of connection attempts is limited by the master_retry_count option.\nIt can be set either on the command-line or in a server option group in an\noption file prior to starting up the server. For example:\n\n[mariadb]\n...\nmaster_retry_count=4294967295\n\nMASTER_BIND\n-----------\n\nThe MASTER_BIND option for CHANGE MASTER is only supported by MySQL 5.6.2 and\nlater and by MySQL NDB Cluster 7.3.1 and later. This option is not supported\nby MariaDB. See MDEV-19248 for more information.\n\nThe MASTER_BIND option for CHANGE MASTER can be used on replicas that have\nmultiple network interfaces to choose which network interface the replica will\nuse to connect to the primary.\n\nMASTER_HEARTBEAT_PERIOD\n-----------------------\n\nThe MASTER_HEARTBEAT_PERIOD option for CHANGE MASTER can be used to set the\ninterval in seconds between replication heartbeats. Whenever the primary\'s\nbinary log is updated with an event, the waiting period for the next heartbeat\nis reset.\n\nThis option\'s interval argument has the following characteristics:\n\n* It is a decimal value with a range of 0 to 4294967 seconds.\n* It has a resolution of hundredths of a second.\n* Its smallest valid non-zero value is 0.001.\n* Its default value is the value of the slave_net_timeout system variable\ndivided by 2.\n* If it\'s set to 0, then heartbeats are disabled.\n\nHeartbeats are sent by the primary only if there are no unsent events in the\nbinary log file for a period longer than the interval.\n\nIf the RESET SLAVE statement is executed, then the heartbeat interval is reset\nto the default.\n\nIf the slave_net_timeout system variable is set to a value that is lower than\nthe current heartbeat interval, then a warning will be issued.\n\nTLS Options\n-----------\n\nThe TLS options are used for providing information about TLS. The options can\nbe set even on replicas that are compiled without TLS support. The TLS options\nare saved to either the default master.info file or the file that is\nconfigured by the master_info_file option, but these TLS options are ignored\nunless the replica supports TLS.\n\nSee Replication with Secure Connections for more information.\n\nMASTER_SSL\n----------\n\nThe MASTER_SSL option for CHANGE MASTER tells the replica whether to force TLS\nfor the connection. The valid values are 0 or 1.\n\nFor example:\n\nSTOP SLAVE;\nCHANGE MASTER TO\n MASTER_SSL=1;\nSTART SLAVE;\n\nMASTER_SSL_CA\n-------------\n\nThe MASTER_SSL_CA option for CHANGE MASTER defines a path to a PEM file that\nshould contain one or more X509 certificates for trusted Certificate\nAuthorities (CAs) to use for TLS. This option requires that you use the\nabsolute path, not a relative path. This option implies the MASTER_SSL option.\n\nFor example:\n\nSTOP SLAVE;\nCHANGE MASTER TO\n MASTER_SSL_CERT=\'/etc/my.cnf.d/certificates/server-cert.pem\',\n MASTER_SSL_KEY=\'/etc/my.cnf.d/certificates/server-key.pem\',\n MASTER_SSL_CA=\'/etc/my.cnf.d/certificates/ca.pem\',\n MASTER_SSL_VERIFY_SERVER_CERT=1;\nSTART SLAVE;\n\nSee Secure Connections Overview: Certificate Authorities (CAs) for more\ninformation.\n\nThe maximum length of MASTER_SSL_CA string is 511 characters.\n\nMASTER_SSL_CAPATH\n-----------------\n\nThe MASTER_SSL_CAPATH option for CHANGE MASTER defines a path to a directory\nthat contains one or more PEM files that should each contain one X509\ncertificate for a trusted Certificate Authority (CA) to use for TLS. This\noption requires that you use the absolute path, not a relative path. The\ndirectory specified by this option needs to be run through the openssl rehash\ncommand. This option implies the MASTER_SSL option.\n\nFor example:\n\nSTOP SLAVE;\nCHANGE MASTER TO\n MASTER_SSL_CERT=\'/etc/my.cnf.d/certificates/server-cert.pem\',\n MASTER_SSL_KEY=\'/etc/my.cnf.d/certificates/server-key.pem\',\n MASTER_SSL_CAPATH=\'/etc/my.cnf.d/certificates/ca/\',\n MASTER_SSL_VERIFY_SERVER_CERT=1;\nSTART SLAVE;\n\nSee Secure Connections Overview: Certificate Authorities (CAs) for more\ninformation.\n\nThe maximum length of MASTER_SSL_CA_PATH string is 511 characters.\n\nMASTER_SSL_CERT\n---------------\n\nThe MASTER_SSL_CERT option for CHANGE MASTER defines a path to the X509\ncertificate file to use for TLS. This option requires that you use the\nabsolute path, not a relative path. This option implies the MASTER_SSL option.\n\nFor example:\n\nSTOP SLAVE;\nCHANGE MASTER TO\n MASTER_SSL_CERT=\'/etc/my.cnf.d/certificates/server-cert.pem\',\n MASTER_SSL_KEY=\'/etc/my.cnf.d/certificates/server-key.pem\',\n MASTER_SSL_CA=\'/etc/my.cnf.d/certificates/ca.pem\',\n MASTER_SSL_VERIFY_SERVER_CERT=1;\nSTART SLAVE;\n\nThe maximum length of MASTER_SSL_CERT string is 511 characters.\n\nMASTER_SSL_CRL\n--------------\n\nThe MASTER_SSL_CRL option for CHANGE MASTER defines a path to a PEM file that\nshould contain one or more revoked X509 certificates to use for TLS. This\noption requires that you use the absolute path, not a relative path.\n\nThis option is only supported if the server was built with OpenSSL. If the\nserver was built with yaSSL, then this option is not supported. See TLS and\nCryptography Libraries Used by MariaDB for more information about which\nlibraries are used on which platforms.\n\nFor example:\n\nSTOP SLAVE;\nCHANGE MASTER TO\n MASTER_SSL_CERT=\'/etc/my.cnf.d/certificates/server-cert.pem\',\n MASTER_SSL_KEY=\'/etc/my.cnf.d/certificates/server-key.pem\',\n MASTER_SSL_CA=\'/etc/my.cnf.d/certificates/ca.pem\',\n MASTER_SSL_VERIFY_SERVER_CERT=1,\n MASTER_SSL_CRL=\'/etc/my.cnf.d/certificates/crl.pem\';\nSTART SLAVE;\n\nSee Secure Connections Overview: Certificate Revocation Lists (CRLs) for more\ninformation.\n\nThe maximum length of MASTER_SSL_CRL string is 511 characters.\n\nMASTER_SSL_CRLPATH\n------------------\n\nThe MASTER_SSL_CRLPATH option for CHANGE MASTER defines a path to a directory\nthat contains one or more PEM files that should each contain one revoked X509\ncertificate to use for TLS. This option requires that you use the absolute\npath, not a relative path. The directory specified by this variable needs to\nbe run through the openssl rehash command.\n\nThis option is only supported if the server was built with OpenSSL. If the\nserver was built with yaSSL, then this option is not supported. See TLS and\nCryptography Libraries Used by MariaDB for more information about which\nlibraries are used on which platforms.\n\nFor example:\n\nSTOP SLAVE;\nCHANGE MASTER TO\n MASTER_SSL_CERT=\'/etc/my.cnf.d/certificates/server-cert.pem\',\n MASTER_SSL_KEY=\'/etc/my.cnf.d/certificates/server-key.pem\',\n MASTER_SSL_CA=\'/etc/my.cnf.d/certificates/ca.pem\',\n MASTER_SSL_VERIFY_SERVER_CERT=1,\n MASTER_SSL_CRLPATH=\'/etc/my.cnf.d/certificates/crl/\';\nSTART SLAVE;\n\nSee Secure Connections Overview: Certificate Revocation Lists (CRLs) for more\ninformation.\n\nThe maximum length of MASTER_SSL_CRL_PATH string is 511 characters.\n\nMASTER_SSL_KEY\n--------------\n\nThe MASTER_SSL_KEY option for CHANGE MASTER defines a path to a private key\nfile to use for TLS. This option requires that you use the absolute path, not\na relative path. This option implies the MASTER_SSL option.\n\nFor example:\n\nSTOP SLAVE;\nCHANGE MASTER TO\n MASTER_SSL_CERT=\'/etc/my.cnf.d/certificates/server-cert.pem\',\n MASTER_SSL_KEY=\'/etc/my.cnf.d/certificates/server-key.pem\',\n MASTER_SSL_CA=\'/etc/my.cnf.d/certificates/ca.pem\',\n MASTER_SSL_VERIFY_SERVER_CERT=1;\nSTART SLAVE;\n\nThe maximum length of MASTER_SSL_KEY string is 511 characters.\n\nMASTER_SSL_CIPHER\n-----------------\n\nThe MASTER_SSL_CIPHER option for CHANGE MASTER defines the list of permitted\nciphers or cipher suites to use for TLS. Besides cipher names, if MariaDB was\ncompiled with OpenSSL, this option could be set to \"SSLv3\" or \"TLSv1.2\" to\nallow all SSLv3 or all TLSv1.2 ciphers. Note that the TLSv1.3 ciphers cannot\nbe excluded when using OpenSSL, even by using this option. See Using TLSv1.3\nfor details. This option implies the MASTER_SSL option.\n\nFor example:\n\nSTOP SLAVE;\nCHANGE MASTER TO\n MASTER_SSL_CERT=\'/etc/my.cnf.d/certificates/server-cert.pem\',\n MASTER_SSL_KEY=\'/etc/my.cnf.d/certificates/server-key.pem\',\n MASTER_SSL_CA=\'/etc/my.cnf.d/certificates/ca.pem\',\n MASTER_SSL_VERIFY_SERVER_CERT=1,\n MASTER_SSL_CIPHER=\'TLSv1.2\';\nSTART SLAVE;\n\nThe maximum length of MASTER_SSL_CIPHER string is 511 characters.\n\nMASTER_SSL_VERIFY_SERVER_CERT\n-----------------------------\n\nThe MASTER_SSL_VERIFY_SERVER_CERT option for CHANGE MASTER enables server\ncertificate verification. This option is disabled by default.\n\nFor example:\n\nSTOP SLAVE;\nCHANGE MASTER TO\n MASTER_SSL_CERT=\'/etc/my.cnf.d/certificates/server-cert.pem\',\n MASTER_SSL_KEY=\'/etc/my.cnf.d/certificates/server-key.pem\',\n MASTER_SSL_CA=\'/etc/my.cnf.d/certificates/ca.pem\',\n MASTER_SSL_VERIFY_SERVER_CERT=1;\nSTART SLAVE;\n\nSee Secure Connections Overview: Server Certificate Verification for more\ninformation.\n\nBinary Log Options\n------------------\n\nThese options are related to the binary log position on the primary.\n\nMASTER_LOG_FILE\n---------------\n\nThe MASTER_LOG_FILE option for CHANGE MASTER can be used along with\nMASTER_LOG_POS to specify the coordinates at which the replica\'s I/O thread\nshould begin reading from the primary\'s binary logs the next time the thread\nstarts.\n\nFor example:\n\nSTOP SLAVE;\nCHANGE MASTER TO\n MASTER_LOG_FILE=\'master2-bin.001\',\n MASTER_LOG_POS=4;\nSTART SLAVE;\n\nThe MASTER_LOG_FILE and MASTER_LOG_POS options cannot be specified if the\nRELAY_LOG_FILE and RELAY_LOG_POS options were also specified.\n\nThe MASTER_LOG_FILE and MASTER_LOG_POS options are effectively ignored if you\nenable GTID mode for replication by setting the MASTER_USE_GTID option to some\nvalue other than no in the statement.\n\nMASTER_LOG_POS\n--------------\n\nThe MASTER_LOG_POS option for CHANGE MASTER can be used along with\nMASTER_LOG_FILE to specify the coordinates at which the replica\'s I/O thread\nshould begin reading from the primary\'s binary logs the next time the thread\nstarts.\n\nFor example:\n\nSTOP SLAVE;\nCHANGE MASTER TO\n MASTER_LOG_FILE=\'master2-bin.001\',\n MASTER_LOG_POS=4;\nSTART SLAVE;\n\nThe MASTER_LOG_FILE and MASTER_LOG_POS options cannot be specified if the\nRELAY_LOG_FILE and RELAY_LOG_POS options were also specified.\n\nThe MASTER_LOG_FILE and MASTER_LOG_POS options are effectively ignored if you\nenable GTID mode for replication by setting the MASTER_USE_GTID option to some\nvalue other than no in the statement.\n\nRelay Log Options\n-----------------\n\nThese options are related to the relay log position on the replica.\n\nRELAY_LOG_FILE\n--------------\n\nThe RELAY_LOG_FILE option for CHANGE MASTER can be used along with the\nRELAY_LOG_POS option to specify the coordinates at which the replica\'s SQL\nthread should begin reading from the relay log the next time the thread starts.\n\nThe CHANGE MASTER statement usually deletes all relay log files. However, if\nthe RELAY_LOG_FILE and/or RELAY_LOG_POS options are specified, then existing\nrelay log files are kept.\n\nWhen you want to change the relay log position, you only need to stop the\nreplica\'s SQL thread. The replica\'s I/O thread can continue running. The STOP\nSLAVE and START SLAVE statements support the SQL_THREAD option for this\nscenario. For example:\n\nSTOP SLAVE SQL_THREAD;\nCHANGE MASTER TO\n RELAY_LOG_FILE=\'slave-relay-bin.006\',\n RELAY_LOG_POS=4025;\nSTART SLAVE SQL_THREAD;\n\nWhen the value of this option is changed, the metadata about the replica\'s SQL\nthread\'s position in the relay logs will also be changed in the relay-log.info\nfile or the file that is configured by the relay_log_info_file system variable.\n\nThe RELAY_LOG_FILE and RELAY_LOG_POS options cannot be specified if the\nMASTER_LOG_FILE and MASTER_LOG_POS options were also specified.\n\nRELAY_LOG_POS\n-------------\n\nThe RELAY_LOG_POS option for CHANGE MASTER can be used along with the\nRELAY_LOG_FILE option to specify the coordinates at which the replica\'s SQL\nthread should begin reading from the relay log the next time the thread starts.\n\nThe CHANGE MASTER statement usually deletes all relay log files. However, if\nthe RELAY_LOG_FILE and/or RELAY_LOG_POS options are specified, then existing\nrelay log files are kept.\n\nWhen you want to change the relay log position, you only need to stop the\nreplica\'s SQL thread. The replica\'s I/O thread can continue running. The STOP\nSLAVE and START SLAVE statements support the SQL_THREAD option for this\nscenario. For example:\n\nSTOP SLAVE SQL_THREAD;\nCHANGE MASTER TO\n RELAY_LOG_FILE=\'slave-relay-bin.006\',\n RELAY_LOG_POS=4025;\nSTART SLAVE SQL_THREAD;\n\nWhen the value of this option is changed, the metadata about the replica\'s SQL\nthread\'s position in the relay logs will also be changed in the relay-log.info\nfile or the file that is configured by the relay_log_info_file system variable.\n\nThe RELAY_LOG_FILE and RELAY_LOG_POS options cannot be specified if the\nMASTER_LOG_FILE and MASTER_LOG_POS options were also specified.\n\nGTID Options\n------------\n\nMASTER_USE_GTID\n---------------\n\nThe MASTER_USE_GTID option for CHANGE MASTER can be used to configure the\nreplica to use the global transaction ID (GTID) when connecting to a primary.\nThe possible values are:\n\n* current_pos - Replicate in GTID mode and use gtid_current_pos as the\nposition to start downloading transactions from the primary. Deprecated from\nMariaDB 10.10. Using to transition to primary can break the replication state\nif the replica executes local transactions due to actively updating\ngtid_current_pos with gtid_binlog_pos and gtid_slave_pos. Use the new, safe,\nMASTER_DEMOTE_TO_SLAVE=<bool> option instead.\n* slave_pos - Replicate in GTID mode and use gtid_slave_pos as the position to\nstart downloading transactions from the primary. From MariaDB 10.5.1,\nreplica_pos is an alias for slave_pos.\n* no - Don\'t replicate in GTID mode.\n\nMASTER_DEMOTE_TO_SLAVE\n----------------------\n\nMariaDB starting with 10.10\n---------------------------\nUsed to transition a primary to become a replica. Replaces the old\nMASTER_USE_GTID=current_pos with a safe alternative by forcing users to set\nUsing_Gtid=Slave_Pos and merging gtid_binlog_pos into gtid_slave_pos once at\nCHANGE MASTER TO time. If gtid_slave_pos is more recent than gtid_binlog_pos\n(as in the case of chain replication), the replication state should be\npreserved.\n\nFor example:\n\nSTOP SLAVE;\nCHANGE MASTER TO\n MASTER_USE_GTID = current_pos;\nSTART SLAVE;\n\nOr:\n\nSTOP SLAVE;\nSET GLOBAL gtid_slave_pos=\'0-1-153\';\nCHANGE MASTER TO\n MASTER_USE_GTID = slave_pos;\nSTART SLAVE;\n\nReplication Filter Options\n--------------------------\n\nAlso see Replication filters.\n\nIGNORE_SERVER_IDS\n-----------------\n\nThe IGNORE_SERVER_IDS option for CHANGE MASTER can be used to configure a\nreplica to ignore binary log events that originated from certain servers.\nFiltered binary log events will not get logged to the replica’s relay log, and\nthey will not be applied by the replica.\n\nThe option\'s value can be specified by providing a comma-separated list of\nserver_id values. For example:\n\nSTOP SLAVE;\nCHANGE MASTER TO \n IGNORE_SERVER_IDS = (3,5);\nSTART SLAVE;\n\nIf you would like to clear a previously set list, then you can set the value\nto an empty list. For example:\n\nSTOP SLAVE;\nCHANGE MASTER TO \n IGNORE_SERVER_IDS = ();\nSTART SLAVE;\n\nDO_DOMAIN_IDS\n-------------\n\nThe DO_DOMAIN_IDS option for CHANGE MASTER can be used to configure a replica\nto only apply binary log events if the transaction\'s GTID is in a specific\ngtid_domain_id value. Filtered binary log events will not get logged to the\nreplica’s relay log, and they will not be applied by the replica.\n\nThe option\'s value can be specified by providing a comma-separated list of\ngtid_domain_id values. Duplicate values are automatically ignored. For example:\n\nSTOP SLAVE;\nCHANGE MASTER TO \n DO_DOMAIN_IDS = (1,2);\nSTART SLAVE;\n\nIf you would like to clear a previously set list, then you can set the value\nto an empty list. For example:\n\nSTOP SLAVE;\nCHANGE MASTER TO \n DO_DOMAIN_IDS = ();\nSTART SLAVE;\n\nThe DO_DOMAIN_IDS option and the IGNORE_DOMAIN_IDS option cannot both be set\nto non-empty values at the same time. If you want to set the DO_DOMAIN_IDS\noption, and the IGNORE_DOMAIN_IDS option was previously set, then you need to\nclear the value of the IGNORE_DOMAIN_IDS option. For example:\n\nSTOP SLAVE;\nCHANGE MASTER TO \n IGNORE_DOMAIN_IDS = (),\n DO_DOMAIN_IDS = (1,2);\nSTART SLAVE;\n\nThe DO_DOMAIN_IDS option can only be specified if the replica is replicating\nin GTID mode. Therefore, the MASTER_USE_GTID option must also be set to some\nvalue other than no in order to use this option.\n\nIGNORE_DOMAIN_IDS\n-----------------\n\nThe IGNORE_DOMAIN_IDS option for CHANGE MASTER can be used to configure a\nreplica to ignore binary log events if the transaction\'s GTID is in a specific\ngtid_domain_id value. Filtered binary log events will not get logged to the\nreplica’s relay log, and they will not be applied by the replica.\n\nThe option\'s value can be specified by providing a comma-separated list of\ngtid_domain_id values. Duplicate values are automatically ignored. For example:\n\nSTOP SLAVE;\nCHANGE MASTER TO \n IGNORE_DOMAIN_IDS = (1,2);\nSTART SLAVE;\n\nIf you would like to clear a previously set list, then you can set the value\nto an empty list. For example:\n\nSTOP SLAVE;\nCHANGE MASTER TO \n IGNORE_DOMAIN_IDS = ();\nSTART SLAVE;\n\nThe DO_DOMAIN_IDS option and the IGNORE_DOMAIN_IDS option cannot both be set\nto non-empty values at the same time. If you want to set the IGNORE_DOMAIN_IDS\noption, and the DO_DOMAIN_IDS option was previously set, then you need to\nclear the value of the DO_DOMAIN_IDS option. For example:\n\nSTOP SLAVE;\nCHANGE MASTER TO \n DO_DOMAIN_IDS = (),\n IGNORE_DOMAIN_IDS = (1,2);\nSTART SLAVE;\n\nThe IGNORE_DOMAIN_IDS option can only be specified if the replica is\nreplicating in GTID mode. Therefore, the MASTER_USE_GTID option must also be\nset to some value other than no in order to use this option.\n\nDelayed Replication Options\n---------------------------\n\nMASTER_DELAY\n------------\n\nThe MASTER_DELAY option for CHANGE MASTER can be used to enable delayed\nreplication. This option specifies the time in seconds (at least) that a\nreplica should lag behind the primary up to a maximum value of 2147483647, or\nabout 68 years. Before executing an event, the replica will first wait, if\nnecessary, until the given time has passed since the event was created on the\nprimary. The result is that the replica will reflect the state of the primary\nsome time back in the past. The default is zero, no delay.\n\nSTOP SLAVE;\nCHANGE MASTER TO \n MASTER_DELAY=3600;\nSTART SLAVE;\n\nChanging Option Values\n----------------------\n\nIf you don\'t specify a given option when executing the CHANGE MASTER\nstatement, then the option keeps its old value in most cases. Most of the\ntime, there is no need to specify the options that do not need to change. For\nexample, if the password for the user account that the replica uses to connect\nto its primary has changed, but no other options need to change, then you can\njust change the MASTER_PASSWORD option by executing the following commands:\n\nSTOP SLAVE;\nCHANGE MASTER TO \n MASTER_PASSWORD=\'new3cret\';\nSTART SLAVE;\n\nThere are some cases where options are implicitly reset, such as when the\nMASTER_HOST and MASTER_PORT options are changed.\n\nOption Persistence\n------------------\n\nThe values of the MASTER_LOG_FILE and MASTER_LOG_POS options (i.e. the binary\nlog position on the primary) and most other options are written to either the\ndefault master.info file or the file that is configured by the\nmaster_info_file option. The replica\'s I/O thread keeps this binary log\nposition updated as it downloads events only when MASTER_USE_GTID option is\nset to NO. Otherwise the file is not updated on a per event basis.\n\nThe master_info_file option can be set either on the command-line or in a\nserver option group in an option file prior to starting up the server. For\nexample:\n\n[mariadb]\n...\nmaster_info_file=/mariadb/myserver1-master.info\n\nThe values of the RELAY_LOG_FILE and RELAY_LOG_POS options (i.e. the relay log\nposition) are written to either the default relay-log.info file or the file\nthat is configured by the relay_log_info_file system variable. The replica\'s\nSQL thread keeps this relay log position updated as it applies events.\n\nThe relay_log_info_file system variable can be set either on the command-line\nor in a server option group in an option file prior to starting up the server.\nFor example:\n\n[mariadb]\n...\nrelay_log_info_file=/mariadb/myserver1-relay-log.info\n\nGTID Persistence\n----------------\n\nIf the replica is replicating binary log events that contain GTIDs, then the\nreplica\'s SQL thread will write every GTID that it applies to the\nmysql.gtid_slave_pos table. This GTID can be inspected and modified through\nthe gtid_slave_pos system variable.\n\nIf the replica has the log_slave_updates system variable enabled and if the\nreplica has the binary log enabled, then every write by the replica\'s SQL\nthread will also go into the replica\'s binary log. This means that GTIDs of\nreplicated transactions would be reflected in the value of the gtid_binlog_pos\nsystem variable.\n\nCreating a Replica from a Backup\n--------------------------------\n\nThe CHANGE MASTER statement is useful for setting up a replica when you have a\nbackup of the primary and you also have the binary log position or GTID\nposition corresponding to the backup.\n\nAfter restoring the backup on the replica, you could execute something like\nthis to use the binary log position:\n\nCHANGE MASTER TO\n MASTER_LOG_FILE=\'master2-bin.001\',\n MASTER_LOG_POS=4;\nSTART SLAVE;\n\nOr you could execute something like this to use the GTID position:\n\nSET GLOBAL gtid_slave_pos=\'0-1-153\';\nCHANGE MASTER TO\n MASTER_USE_GTID=slave_pos;\nSTART SLAVE;\n\nSee Setting up a Replication Slave with Mariabackup for more information on\nhow to do this with Mariabackup.\n\nExample\n-------\n\nThe following example changes the primary and primary\'s binary log\ncoordinates. This is used when you want to set up the replica to replicate the\nprimary:\n\nCHANGE MASTER TO\n MASTER_HOST=\'master2.mycompany.com\',\n MASTER_USER=\'replication\',\n MASTER_PASSWORD=\'bigs3cret\',\n MASTER_PORT=3306,\n MASTER_LOG_FILE=\'master2-bin.001\',\n MASTER_LOG_POS=4,\n MASTER_CONNECT_RETRY=10;\nSTART SLAVE;\n\nURL: https://mariadb.com/kb/en/change-master-to/','','https://mariadb.com/kb/en/change-master-to/'),(796,'START SLAVE',48,'The terms master and slave have historically been used in replication, but the\nterms terms primary and replica are now preferred. The old terms are used\nstill used in parts of the documentation, and in MariaDB commands, although\nMariaDB 10.5 has begun the process of renaming. The documentation process is\nongoing. See MDEV-18777 to follow progress on this effort.\n\nSyntax\n------\n\nSTART SLAVE [\"connection_name\"] [thread_type [, thread_type] ... ] [FOR\nCHANNEL \"connection_name\"]\nSTART SLAVE [\"connection_name\"] [SQL_THREAD] UNTIL                \n  MASTER_LOG_FILE = \'log_name\', MASTER_LOG_POS = log_pos [FOR CHANNEL\n\"connection_name\"]\nSTART SLAVE [\"connection_name\"] [SQL_THREAD] UNTIL\n  RELAY_LOG_FILE = \'log_name\', RELAY_LOG_POS = log_pos [FOR CHANNEL\n\"connection_name\"]\nSTART SLAVE [\"connection_name\"] [SQL_THREAD] UNTIL\n  MASTER_GTID_POS = <GTID position> [FOR CHANNEL \"connection_name\"]\nSTART ALL SLAVES [thread_type [, thread_type]]\n\nSTART REPLICA [\"connection_name\"] [thread_type [, thread_type] ... ] -- from\n10.5.1\nSTART REPLICA [\"connection_name\"] [SQL_THREAD] UNTIL                \n  MASTER_LOG_FILE = \'log_name\', MASTER_LOG_POS = log_pos -- from 10.5.1\nSTART REPLICA [\"connection_name\"] [SQL_THREAD] UNTIL\n  RELAY_LOG_FILE = \'log_name\', RELAY_LOG_POS = log_pos -- from 10.5.1\nSTART REPLICA [\"connection_name\"] [SQL_THREAD] UNTIL\n  MASTER_GTID_POS = <GTID position> -- from 10.5.1\nSTART ALL REPLICAS [thread_type [, thread_type]] -- from 10.5.1\n\nthread_type: IO_THREAD | SQL_THREAD\n\nDescription\n-----------\n\nSTART SLAVE (START REPLICA from MariaDB 10.5.1) with no thread_type options\nstarts both of the replica threads (see replication). The I/O thread reads\nevents from the primary server and stores them in the relay log. The SQL\nthread reads events from the relay log and executes them. START SLAVE requires\nthe SUPER privilege, or, from MariaDB 10.5.2, the REPLICATION SLAVE ADMIN\nprivilege.\n\nIf START SLAVE succeeds in starting the replica threads, it returns without\nany error. However, even in that case, it might be that the replica threads\nstart and then later stop (for example, because they do not manage to connect\nto the primary or read its binary log, or some other problem). START SLAVE\ndoes not warn you about this. You must check the replica\'s error log for error\nmessages generated by the replica threads, or check that they are running\nsatisfactorily with SHOW SLAVE STATUS (SHOW REPLICA STATUS from MariaDB\n10.5.1).\n\nSTART SLAVE UNTIL\n-----------------\n\nSTART SLAVE UNTIL refers to the SQL_THREAD replica position at which the\nSQL_THREAD replication will halt. If SQL_THREAD isn\'t specified both threads\nare started.\n\nSTART SLAVE UNTIL master_gtid_pos=xxx is also supported. See Global\nTransaction ID/START SLAVE UNTIL master_gtid_pos=xxx for more details.\n\nconnection_name\n---------------\n\nIf there is only one nameless primary, or the default primary (as specified by\nthe default_master_connection system variable) is intended, connection_name\ncan be omitted. If provided, the START SLAVE statement will apply to the\nspecified primary. connection_name is case-insensitive.\n\nMariaDB starting with 10.7.0\n----------------------------\nThe FOR CHANNEL keyword was added for MySQL compatibility. This is identical\nas using the channel_name directly after START SLAVE.\n\nSTART ALL SLAVES\n----------------\n\nSTART ALL SLAVES starts all configured replicas (replicas with master_host not\nempty) that were not started before. It will give a note for all started\nconnections. You can check the notes with SHOW WARNINGS.\n\nSTART REPLICA\n-------------\n\nMariaDB starting with 10.5.1\n----------------------------\nSTART REPLICA is an alias for START SLAVE from MariaDB 10.5.1.\n\nURL: https://mariadb.com/kb/en/start-replica/','','https://mariadb.com/kb/en/start-replica/'),(797,'STOP SLAVE',48,'The terms master and slave have historically been used in replication, but the\nterms terms primary and replica are now preferred. The old terms are used\nstill used in parts of the documentation, and in MariaDB commands, although\nMariaDB 10.5 has begun the process of renaming. The documentation process is\nongoing. See MDEV-18777 to follow progress on this effort.\n\nSyntax\n------\n\nSTOP SLAVE [\"connection_name\"] [thread_type [, thread_type] ... ] [FOR CHANNEL\n\"connection_name\"]\n\nSTOP ALL SLAVES [thread_type [, thread_type]]\n\nSTOP REPLICA [\"connection_name\"] [thread_type [, thread_type] ... ] -- from\n10.5.1\n\nSTOP ALL REPLICAS [thread_type [, thread_type]] -- from 10.5.1\n\nthread_type: IO_THREAD | SQL_THREAD\n\nDescription\n-----------\n\nStops the replica threads. STOP SLAVE requires the SUPER privilege, or, from\nMariaDB 10.5.2, the REPLICATION SLAVE ADMIN privilege.\n\nLike START SLAVE, this statement may be used with the IO_THREAD and SQL_THREAD\noptions to name the thread or threads to be stopped. In almost all cases, one\nnever need to use the thread_type options.\n\nSTOP SLAVE waits until any current replication event group affecting one or\nmore non-transactional tables has finished executing (if there is any such\nreplication group), or until the user issues a KILL QUERY or KILL CONNECTION\nstatement.\n\nNote that STOP SLAVE doesn\'t delete the connection permanently. Next time you\nexecute START SLAVE or the MariaDB server restarts, the replica connection is\nrestored with it\'s original arguments. If you want to delete a connection, you\nshould execute RESET SLAVE.\n\nSTOP ALL SLAVES\n---------------\n\nSTOP ALL SLAVES stops all your running replicas. It will give you a note for\nevery stopped connection. You can check the notes with SHOW WARNINGS.\n\nconnection_name\n---------------\n\nThe connection_name option is used for multi-source replication.\n\nIf there is only one nameless master, or the default master (as specified by\nthe default_master_connection system variable) is intended, connection_name\ncan be omitted. If provided, the STOP SLAVE statement will apply to the\nspecified master. connection_name is case-insensitive.\n\nMariaDB starting with 10.7.0\n----------------------------\nThe FOR CHANNEL keyword was added for MySQL compatibility. This is identical\nas using the channel_name directly after STOP SLAVE.\n\nSTOP REPLICA\n------------\n\nMariaDB starting with 10.5.1\n----------------------------\nSTOP REPLICA is an alias for STOP SLAVE from MariaDB 10.5.1.\n\nURL: https://mariadb.com/kb/en/stop-replica/','','https://mariadb.com/kb/en/stop-replica/'),(798,'RESET REPLICA/SLAVE',48,'The terms master and slave have historically been used in replication, but the\nterms terms primary and replica are now preferred. The old terms are used\nstill used in parts of the documentation, and in MariaDB commands, although\nMariaDB 10.5 has begun the process of renaming. The documentation process is\nongoing. See MDEV-18777 to follow progress on this effort.\n\nSyntax\n------\n\nRESET REPLICA [\"connection_name\"] [ALL]  [FOR CHANNEL \"connection_name\"] --\nfrom MariaDB 10.5.1         \nRESET SLAVE [\"connection_name\"] [ALL]  [FOR CHANNEL \"connection_name\"]\n\nDescription\n-----------\n\nRESET REPLICA/SLAVE makes the replica forget its replication position in the\nmaster\'s binary log. This statement is meant to be used for a clean start. It\ndeletes the master.info and relay-log.info files, all the relay log files, and\nstarts a new relay log file. To use RESET REPLICA/SLAVE, the replica threads\nmust be stopped (use STOP REPLICA/SLAVE if necessary).\n\nNote: All relay log files are deleted, even if they have not been completely\nexecuted by the slave SQL thread. (This is a condition likely to exist on a\nreplication slave if you have issued a STOP REPLICA/SLAVE statement or if the\nslave is highly loaded.)\n\nNote: RESET REPLICA does not reset the global gtid_slave_pos variable. This\nmeans that a replica server configured with CHANGE MASTER TO\nMASTER_USE_GTID=slave_pos will not receive events with GTIDs occurring before\nthe state saved in gtid_slave_pos. If the intent is to reprocess these events,\ngtid_slave_pos must be manually reset, e.g. by executing set global\ngtid_slave_pos=\"\".\n\nConnection information stored in the master.info file is immediately reset\nusing any values specified in the corresponding startup options. This\ninformation includes values such as master host, master port, master user, and\nmaster password. If the replica SQL thread was in the middle of replicating\ntemporary tables when it was stopped, and RESET REPLICA/SLAVE is issued, these\nreplicated temporary tables are deleted on the slave.\n\nThe ALL also resets the PORT, HOST, USER and PASSWORD parameters for the\nslave. If you are using a connection name, it will permanently delete it and\nit will not show up anymore in SHOW ALL REPLICAS/SLAVE STATUS.\n\nconnection_name\n---------------\n\nThe connection_name option is used for multi-source replication.\n\nIf there is only one nameless primary, or the default primary (as specified by\nthe default_master_connection system variable) is intended, connection_name\ncan be omitted. If provided, the RESET REPLICA/SLAVE statement will apply to\nthe specified primary. connection_name is case-insensitive.\n\nMariaDB starting with 10.7.0\n----------------------------\nThe FOR CHANNEL keyword was added for MySQL compatibility. This is identical\nas using the channel_name directly after RESET REPLICA.\n\nRESET REPLICA\n-------------\n\nMariaDB starting with 10.5.1\n----------------------------\nRESET REPLICA is an alias for RESET SLAVE from MariaDB 10.5.1.\n\nURL: https://mariadb.com/kb/en/reset-replica/','','https://mariadb.com/kb/en/reset-replica/'),(799,'RESET MASTER',48,'RESET MASTER [TO #]\n\nDeletes all binary log files listed in the index file, resets the binary log\nindex file to be empty, and creates a new binary log file with a suffix of\n.000001.\n\nIf TO # is given, then the first new binary log file will start from number #.\n\nThis statement is for use only when the master is started for the first time,\nand should never be used if any slaves are actively replicating from the\nbinary log.\n\nURL: https://mariadb.com/kb/en/reset-master/','','https://mariadb.com/kb/en/reset-master/'),(800,'EXECUTE Statement',49,'Syntax\n------\n\nEXECUTE stmt_name\n  [USING expression[, expression] ...]\n\nMariaDB starting with 10.2.3\n----------------------------\nEXECUTE with expression as parameters was introduced in MariaDB 10.2.3. Before\nthat one could only use variables (@var_name) as parameters.\n\nDescription\n-----------\n\nAfter preparing a statement with PREPARE, you execute it with an EXECUTE\nstatement that refers to the prepared statement name. If the prepared\nstatement contains any parameter markers, you must supply a USING clause that\nlists user variables containing the values to be bound to the parameters.\nParameter values can be supplied only by user variables, and the USING clause\nmust name exactly as many variables as the number of parameter markers in the\nstatement.\n\nYou can execute a given prepared statement multiple times, passing different\nvariables to it or setting the variables to different values before each\nexecution.\n\nIf the specified statement has not been PREPAREd, an error similar to the\nfollowing is produced:\n\nERROR 1243 (HY000): Unknown prepared statement handler (stmt_name) given to\nEXECUTE\n\nExample\n-------\n\nSee example in PREPARE.\n\nURL: https://mariadb.com/kb/en/execute-statement/','','https://mariadb.com/kb/en/execute-statement/'),(801,'PREPARE Statement',49,'Syntax\n------\n\nPREPARE stmt_name FROM preparable_stmt\n\nDescription\n-----------\n\nThe PREPARE statement prepares a statement and assigns it a name, stmt_name,\nby which to refer to the statement later. Statement names are not case\nsensitive. preparable_stmt is either a string literal or a user variable (not\na local variable, an SQL expression or a subquery) that contains the text of\nthe statement. The text must represent a single SQL statement, not multiple\nstatements. Within the statement, \"?\" characters can be used as parameter\nmarkers to indicate where data values are to be bound to the query later when\nyou execute it. The \"?\" characters should not be enclosed within quotes, even\nif you intend to bind them to string values. Parameter markers can be used\nonly where expressions should appear, not for SQL keywords, identifiers, and\nso forth.\n\nThe scope of a prepared statement is the session within which it is created.\nOther sessions cannot see it.\n\nIf a prepared statement with the given name already exists, it is deallocated\nimplicitly before the new statement is prepared. This means that if the new\nstatement contains an error and cannot be prepared, an error is returned and\nno statement with the given name exists.\n\nPrepared statements can be PREPAREd and EXECUTEd in a stored procedure, but\nnot in a stored function or trigger. Also, even if the statement is PREPAREd\nin a procedure, it will not be deallocated when the procedure execution ends.\n\nA prepared statement can access user-defined variables, but not local\nvariables or procedure\'s parameters.\n\nIf the prepared statement contains a syntax error, PREPARE will fail. As a\nside effect, stored procedures can use it to check if a statement is valid.\nFor example:\n\nCREATE PROCEDURE `test_stmt`(IN sql_text TEXT)\nBEGIN\n    DECLARE EXIT HANDLER FOR SQLEXCEPTION\n    BEGIN\n        SELECT CONCAT(sql_text, \' is not valid\');\n    END;\n    SET @SQL := sql_text;\n    PREPARE stmt FROM @SQL;\n    DEALLOCATE PREPARE stmt;\nEND;\n\nThe FOUND_ROWS() and ROW_COUNT() functions, if called immediatly after\nEXECUTE, return the number of rows read or affected by the prepared\nstatements; however, if they are called after DEALLOCATE PREPARE, they provide\ninformation about this statement. If the prepared statement produces errors or\nwarnings, GET DIAGNOSTICS return information about them. DEALLOCATE PREPARE\nshouldn\'t clear the diagnostics area, unless it produces an error.\n\nA prepared statement is executed with EXECUTE and released with DEALLOCATE\nPREPARE.\n\nThe max_prepared_stmt_count server system variable determines the number of\nallowed prepared statements that can be prepared on the server. If it is set\nto 0, prepared statements are not allowed. If the limit is reached, an error\nsimilar to the following will be produced:\n\nERROR 1461 (42000): Can\'t create more than max_prepared_stmt_count statements \n (current value: 0)\n\nOracle Mode\n-----------\n\nMariaDB starting with 10.3\n--------------------------\nIn Oracle mode from MariaDB 10.3, PREPARE stmt FROM \'SELECT :1, :2\' is used,\ninstead of ?.\n\nPermitted Statements\n--------------------\n\nMariaDB starting with 10.6.2\n----------------------------\nAll statements can be prepared, except PREPARE, EXECUTE, and DEALLOCATE / DROP\nPREPARE.\n\nPrior to this, not all statements can be prepared. Only the following SQL\ncommands are permitted:\n\n* ALTER TABLE\n* ANALYZE TABLE\n* BINLOG\n* CACHE INDEX\n* CALL\n* CHANGE MASTER\n* CHECKSUM {TABLE | TABLES}\n* COMMIT\n* {CREATE | DROP} DATABASE\n* {CREATE | DROP} INDEX\n* {CREATE | RENAME | DROP} TABLE\n* {CREATE | RENAME | DROP} USER\n* {CREATE | DROP} VIEW\n* DELETE\n* DESCRIBE\n* DO\n* EXPLAIN\n* FLUSH {TABLE | TABLES | TABLES WITH READ LOCK | HOSTS | PRIVILEGES | LOGS |\nSTATUS | \n MASTER | SLAVE | DES_KEY_FILE | USER_RESOURCES | QUERY CACHE |\nTABLE_STATISTICS | \n INDEX_STATISTICS | USER_STATISTICS | CLIENT_STATISTICS}\n* GRANT\n* INSERT\n* INSTALL {PLUGIN | SONAME}\n* HANDLER READ\n* KILL\n* LOAD INDEX INTO CACHE\n* OPTIMIZE TABLE\n* REPAIR TABLE\n* REPLACE\n* RESET {MASTER | SLAVE | QUERY CACHE}\n* REVOKE\n* ROLLBACK\n* SELECT\n* SET\n* SET GLOBAL SQL_SLAVE_SKIP_COUNTER\n* SET ROLE\n* SET SQL_LOG_BIN\n* SET TRANSACTION ISOLATION LEVEL\n* SHOW EXPLAIN\n* SHOW {DATABASES | TABLES | OPEN TABLES | TABLE STATUS | COLUMNS | INDEX |\nTRIGGERS | \n EVENTS | GRANTS | CHARACTER SET | COLLATION | ENGINES | PLUGINS [SONAME] |\nPRIVILEGES | \n PROCESSLIST | PROFILE | PROFILES | VARIABLES | STATUS | WARNINGS | ERRORS |\n TABLE_STATISTICS | INDEX_STATISTICS | USER_STATISTICS | CLIENT_STATISTICS |\nAUTHORS | \n CONTRIBUTORS}\n* SHOW CREATE {DATABASE | TABLE | VIEW | PROCEDURE | FUNCTION | TRIGGER |\nEVENT}\n* SHOW {FUNCTION | PROCEDURE} CODE\n* SHOW BINLOG EVENTS\n* SHOW SLAVE HOSTS\n* SHOW {MASTER | BINARY} LOGS\n* SHOW {MASTER | SLAVE | TABLES | INNODB | FUNCTION | PROCEDURE} STATUS\n* SLAVE {START | STOP}\n* TRUNCATE TABLE\n* SHUTDOWN\n* UNINSTALL {PLUGIN | SONAME}\n* UPDATE\n\nSynonyms are not listed here, but can be used. For example, DESC can be used\ninstead of DESCRIBE.\n\nCompound statements can be prepared too.\n\nNote that if a statement can be run in a stored routine, it will work even if\nit is called by a prepared statement. For example, SIGNAL can\'t be directly\nprepared. However, it is allowed in stored routines. If the x() procedure\ncontains SIGNAL, you can still prepare and execute the \'CALL x();\' prepared\nstatement.\n\nPREPARE supports most kinds of expressions as well, for example:\n\nPREPARE stmt FROM CONCAT(\'SELECT * FROM \', table_name);\n\nWhen PREPARE is used with a statement which is not supported, the following\nerror is produced:\n\nERROR 1295 (HY000): This command is not supported in the prepared statement\nprotocol yet\n\nExample\n-------\n\ncreate table t1 (a int,b char(10));\ninsert into t1 values (1,\"one\"),(2, \"two\"),(3,\"three\");\nprepare test from \"select * from t1 where a=?\";\nset @param=2;\nexecute test using @param;\n+------+------+\n| a    | b    |\n+------+------+\n|    2 | two  |\n+------+------+\nset @param=3;\nexecute test using @param;\n+------+-------+\n| a    | b     |\n+------+-------+\n|    3 | three |\n+------+-------+\ndeallocate prepare test;\n\nSince identifiers are not permitted as prepared statements parameters,\nsometimes it is necessary to dynamically compose an SQL statement. This\ntechnique is called dynamic SQL). The following example shows how to use\ndynamic SQL:\n\nCREATE PROCEDURE test.stmt_test(IN tab_name VARCHAR(64))\nBEGIN\n	SET @sql = CONCAT(\'SELECT COUNT(*) FROM \', tab_name);\n	PREPARE stmt FROM @sql;\n	EXECUTE stmt;\n	DEALLOCATE PREPARE stmt;\nEND;\n\nCALL test.stmt_test(\'mysql.user\');\n+----------+\n| COUNT(*) |\n+----------+\n|        4 |\n+----------+\n\nUse of variables in prepared statements:\n\nPREPARE stmt FROM \'SELECT @x;\';\n\nSET @x = 1;\n\nEXECUTE stmt;\n+------+\n| @x   |\n+------+\n|    1 |\n+------+\n\nSET @x = 0;\n\nEXECUTE stmt;\n+------+\n| @x   |\n+------+\n|    0 |\n+------+\n\nDEALLOCATE PREPARE stmt;\n\nURL: https://mariadb.com/kb/en/prepare-statement/','','https://mariadb.com/kb/en/prepare-statement/'),(802,'DEALLOCATE / DROP PREPARE',49,'Syntax\n------\n\n{DEALLOCATE | DROP} PREPARE stmt_name\n\nDescription\n-----------\n\nTo deallocate a prepared statement produced with PREPARE, use a DEALLOCATE\nPREPARE statement that refers to the prepared statement name.\n\nA prepared statement is implicitly deallocated when a new PREPARE command is\nissued. In that case, there is no need to use DEALLOCATE.\n\nAttempting to execute a prepared statement after deallocating it results in an\nerror, as if it was not prepared at all:\n\nERROR 1243 (HY000): Unknown prepared statement handler (stmt_name) given to\nEXECUTE\n\nIf the specified statement has not been PREPAREd, an error similar to the\nfollowing will be produced:\n\nERROR 1243 (HY000): Unknown prepared statement handler (stmt_name) given to\nDEALLOCATE PREPARE\n\nExample\n-------\n\nSee example in PREPARE.\n\nURL: https://mariadb.com/kb/en/deallocate-drop-prepare/','','https://mariadb.com/kb/en/deallocate-drop-prepare/'),(803,'EXECUTE IMMEDIATE',49,'MariaDB starting with 10.2.3\n----------------------------\nEXECUTE IMMEDIATE was introduced in MariaDB 10.2.3.\n\nSyntax\n------\n\nEXECUTE IMMEDIATE statement\n\nDescription\n-----------\n\nEXECUTE IMMEDIATE executes a dynamic SQL statement created on the fly, which\ncan reduce performance overhead.\n\nFor example:\n\nEXECUTE IMMEDIATE \'SELECT 1\'\n\nwhich is shorthand for:\n\nprepare stmt from \"select 1\";\nexecute stmt;\ndeallocate prepare stmt;\n\nEXECUTE IMMEDIATE supports complex expressions as prepare source and\nparameters:\n\nEXECUTE IMMEDIATE CONCAT(\'SELECT COUNT(*) FROM \', \'t1\', \' WHERE a=?\') USING\n5+5;\n\nLimitations: subselects and stored function calls are not supported as a\nprepare source.\n\nThe following examples return an error:\n\nCREATE OR REPLACE FUNCTION f1() RETURNS VARCHAR(64) RETURN \'SELECT * FROM t1\';\nEXECUTE IMMEDIATE f1();\nERROR 1970 (42000): EXECUTE IMMEDIATE does not support subqueries or stored\nfunctions\n\nEXECUTE IMMEDIATE (SELECT \'SELECT * FROM t1\');\nERROR 1064 (42000): You have an error in your SQL syntax; check the manual\nthat \n corresponds to your MariaDB server version for the right syntax to use near\n \'SELECT \'SELECT * FROM t1\')\' at line 1\n\nCREATE OR REPLACE FUNCTION f1() RETURNS INT RETURN 10;\nEXECUTE IMMEDIATE \'SELECT * FROM t1 WHERE a=?\' USING f1();\nERROR 1970 (42000): EXECUTE..USING does not support subqueries or stored\nfunctions\n\nEXECUTE IMMEDIATE \'SELECT * FROM t1 WHERE a=?\' USING (SELECT 10);\nERROR 1064 (42000): You have an error in your SQL syntax; check the manual\nthat \n corresponds to your MariaDB server version for the right syntax to use near\n \'SELECT 10)\' at line 1\n\nOne can use a user or an SP variable as a workaround:\n\nCREATE OR REPLACE FUNCTION f1() RETURNS VARCHAR(64) RETURN \'SELECT * FROM t1\';\nSET @stmt=f1();\nEXECUTE IMMEDIATE @stmt;\n\nSET @stmt=(SELECT \'SELECT 1\');\nEXECUTE IMMEDIATE @stmt;\n\nCREATE OR REPLACE FUNCTION f1() RETURNS INT RETURN 10;\nSET @param=f1();\nEXECUTE IMMEDIATE \'SELECT * FROM t1 WHERE a=?\' USING @param;\n\nSET @param=(SELECT 10);\nEXECUTE IMMEDIATE \'SELECT * FROM t1 WHERE a=?\' USING @param;\n\nEXECUTE IMMEDIATE supports user variables and SP variables as OUT parameters\n\nDELIMITER $$\nCREATE OR REPLACE PROCEDURE p1(OUT a INT)\nBEGIN\n SET a:= 10;\nEND;\n$$\nDELIMITER ;\nSET @a=2;\nEXECUTE IMMEDIATE \'CALL p1(?)\' USING @a;\nSELECT @a;\n+------+\n| @a   |\n+------+\n|   10 |\n+------+\n\nSimilar to PREPARE, EXECUTE IMMEDIATE is allowed in stored procedures but is\nnot allowed in stored functions.\n\nThis example uses EXECUTE IMMEDIATE inside a stored procedure:\n\nDELIMITER $$\nCREATE OR REPLACE PROCEDURE p1()\nBEGIN\n EXECUTE IMMEDIATE \'SELECT 1\';\nEND;\n$$\nDELIMITER ;\nCALL p1;\n+---+\n| 1 |\n+---+\n| 1 |\n+---+\n\nThis script returns an error:\n\nDELIMITER $$\nCREATE FUNCTION f1() RETURNS INT\nBEGIN\n EXECUTE IMMEDIATE \'DO 1\';\n RETURN 1;\nEND;\n$$\nERROR 1336 (0A000): Dynamic SQL is not allowed in stored function or trigger\n\nEXECUTE IMMEDIATE can use DEFAULT and IGNORE indicators as bind parameters:\n\nCREATE OR REPLACE TABLE t1 (a INT DEFAULT 10);\nEXECUTE IMMEDIATE \'INSERT INTO t1 VALUES (?)\' USING DEFAULT;\nSELECT * FROM t1;\n+------+\n| a    |\n+------+\n|   10 |\n+------+\n\nEXECUTE IMMEDIATE increments the Com_execute_immediate status variable, as\nwell as the Com_stmt_prepare, Com_stmt_execute and Com_stmt_close status\nvariables.\n\nNote, EXECUTE IMMEDIATE does not increment the Com_execute_sql status\nvariable. Com_execute_sql is used only for PREPARE..EXECUTE.\n\nThis session screenshot demonstrates how EXECUTE IMMEDIATE affects status\nvariables:\n\nSELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME RLIKE \n (\'COM_(EXECUTE|STMT_PREPARE|STMT_EXECUTE|STMT_CLOSE)\');\n\n+-----------------------+----------------+\n| VARIABLE_NAME         | VARIABLE_VALUE |\n+-----------------------+----------------+\n| COM_EXECUTE_IMMEDIATE | 0              |\n| COM_EXECUTE_SQL       | 0              |\n| COM_STMT_CLOSE        | 0              |\n| COM_STMT_EXECUTE      | 0              |\n| COM_STMT_PREPARE      | 0              |\n+-----------------------+----------------+\n\nEXECUTE IMMEDIATE \'SELECT 1\';\n+---+\n| 1 |\n+---+\n| 1 |\n+---+\n\nSELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME RLIKE \n (\'COM_(EXECUTE|STMT_PREPARE|STMT_EXECUTE|STMT_CLOSE)\');\n+-----------------------+----------------+\n| VARIABLE_NAME         | VARIABLE_VALUE |\n+-----------------------+----------------+\n| COM_EXECUTE_IMMEDIATE | 1              |\n| COM_EXECUTE_SQL       | 0              |\n| COM_STMT_CLOSE        | 1              |\n| COM_STMT_EXECUTE      | 1              |\n| COM_STMT_PREPARE      | 1              |\n+-----------------------+----------------+\n\nURL: https://mariadb.com/kb/en/execute-immediate/','','https://mariadb.com/kb/en/execute-immediate/');

--
-- Table structure for table `host`
--

CREATE TABLE `host` (
  `Host` char(60) NOT NULL DEFAULT '',
  `Db` char(64) NOT NULL DEFAULT '',
  `Select_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Insert_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Update_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Delete_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Create_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Drop_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Grant_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `References_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Index_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Alter_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Create_tmp_table_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Lock_tables_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Create_view_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Show_view_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Create_routine_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Alter_routine_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Execute_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Trigger_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  PRIMARY KEY (`Host`,`Db`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Host privileges;  Merged with database privileges';

--
-- Dumping data for table `host`
--


--
-- Table structure for table `index_stats`
--

CREATE TABLE `index_stats` (
  `db_name` varchar(64) NOT NULL,
  `table_name` varchar(64) NOT NULL,
  `index_name` varchar(64) NOT NULL,
  `prefix_arity` int(11) unsigned NOT NULL,
  `avg_frequency` decimal(12,4) DEFAULT NULL,
  PRIMARY KEY (`db_name`,`table_name`,`index_name`,`prefix_arity`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Indexes';

--
-- Dumping data for table `index_stats`
--


--
-- Table structure for table `innodb_index_stats`
--

CREATE TABLE `innodb_index_stats` (
  `database_name` varchar(64) NOT NULL,
  `table_name` varchar(199) NOT NULL,
  `index_name` varchar(64) NOT NULL,
  `last_update` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `stat_name` varchar(64) NOT NULL,
  `stat_value` bigint(20) unsigned NOT NULL,
  `sample_size` bigint(20) unsigned DEFAULT NULL,
  `stat_description` varchar(1024) NOT NULL,
  PRIMARY KEY (`database_name`,`table_name`,`index_name`,`stat_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;

--
-- Table structure for table `innodb_table_stats`
--

CREATE TABLE `innodb_table_stats` (
  `database_name` varchar(64) NOT NULL,
  `table_name` varchar(199) NOT NULL,
  `last_update` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `n_rows` bigint(20) unsigned NOT NULL,
  `clustered_index_size` bigint(20) unsigned NOT NULL,
  `sum_of_other_index_sizes` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`database_name`,`table_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;

--
-- Table structure for table `plugin`
--

CREATE TABLE `plugin` (
  `name` varchar(64) NOT NULL DEFAULT '',
  `dl` varchar(128) NOT NULL DEFAULT '',
  PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='MySQL plugins';

--
-- Dumping data for table `plugin`
--


--
-- Table structure for table `proc`
--

CREATE TABLE `proc` (
  `db` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
  `name` char(64) NOT NULL DEFAULT '',
  `type` enum('FUNCTION','PROCEDURE','PACKAGE','PACKAGE BODY') NOT NULL,
  `specific_name` char(64) NOT NULL DEFAULT '',
  `language` enum('SQL') NOT NULL DEFAULT 'SQL',
  `sql_data_access` enum('CONTAINS_SQL','NO_SQL','READS_SQL_DATA','MODIFIES_SQL_DATA') NOT NULL DEFAULT 'CONTAINS_SQL',
  `is_deterministic` enum('YES','NO') NOT NULL DEFAULT 'NO',
  `security_type` enum('INVOKER','DEFINER') NOT NULL DEFAULT 'DEFINER',
  `param_list` blob NOT NULL,
  `returns` longblob NOT NULL,
  `body` longblob NOT NULL,
  `definer` char(141) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
  `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `sql_mode` set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH','EMPTY_STRING_IS_NULL','SIMULTANEOUS_ASSIGNMENT') NOT NULL DEFAULT '',
  `comment` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `character_set_client` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `collation_connection` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `db_collation` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `body_utf8` longblob DEFAULT NULL,
  `aggregate` enum('NONE','GROUP') NOT NULL DEFAULT 'NONE',
  PRIMARY KEY (`db`,`name`,`type`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='Stored Procedures';

--
-- Dumping data for table `proc`
--

INSERT INTO `proc` VALUES ('mysql','AddGeometryColumn','PROCEDURE','AddGeometryColumn','SQL','CONTAINS_SQL','NO','INVOKER','catalog varchar(64), t_schema varchar(64),\n   t_name varchar(64), geometry_column varchar(64), t_srid int','','begin\n  set @qwe= concat(\'ALTER TABLE \', t_schema, \'.\', t_name, \' ADD \', geometry_column,\' GEOMETRY REF_SYSTEM_ID=\', t_srid); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end','root@localhost','2024-07-16 13:06:51','2024-07-16 13:06:51','','','utf8','utf8_general_ci','utf8mb4_general_ci','begin\n  set @qwe= concat(\'ALTER TABLE \', t_schema, \'.\', t_name, \' ADD \', geometry_column,\' GEOMETRY REF_SYSTEM_ID=\', t_srid); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end','NONE'),('mysql','DropGeometryColumn','PROCEDURE','DropGeometryColumn','SQL','CONTAINS_SQL','NO','INVOKER','catalog varchar(64), t_schema varchar(64),\n   t_name varchar(64), geometry_column varchar(64)','','begin\n  set @qwe= concat(\'ALTER TABLE \', t_schema, \'.\', t_name, \' DROP \', geometry_column); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end','root@localhost','2024-07-16 13:06:51','2024-07-16 13:06:51','','','utf8','utf8_general_ci','utf8mb4_general_ci','begin\n  set @qwe= concat(\'ALTER TABLE \', t_schema, \'.\', t_name, \' DROP \', geometry_column); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end','NONE');

--
-- Table structure for table `procs_priv`
--

CREATE TABLE `procs_priv` (
  `Host` char(60) NOT NULL DEFAULT '',
  `Db` char(64) NOT NULL DEFAULT '',
  `User` char(80) NOT NULL DEFAULT '',
  `Routine_name` char(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '',
  `Routine_type` enum('FUNCTION','PROCEDURE','PACKAGE','PACKAGE BODY') NOT NULL,
  `Grantor` char(141) NOT NULL DEFAULT '',
  `Proc_priv` set('Execute','Alter Routine','Grant') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '',
  `Timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`Host`,`Db`,`User`,`Routine_name`,`Routine_type`),
  KEY `Grantor` (`Grantor`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Procedure privileges';

--
-- Dumping data for table `procs_priv`
--


--
-- Table structure for table `proxies_priv`
--

CREATE TABLE `proxies_priv` (
  `Host` char(60) NOT NULL DEFAULT '',
  `User` char(80) NOT NULL DEFAULT '',
  `Proxied_host` char(60) NOT NULL DEFAULT '',
  `Proxied_user` char(80) NOT NULL DEFAULT '',
  `With_grant` tinyint(1) NOT NULL DEFAULT 0,
  `Grantor` char(141) NOT NULL DEFAULT '',
  `Timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`Host`,`User`,`Proxied_host`,`Proxied_user`),
  KEY `Grantor` (`Grantor`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='User proxy privileges';

--
-- Dumping data for table `proxies_priv`
--

INSERT INTO `proxies_priv` VALUES ('localhost','root','','',1,'','2024-07-16 13:06:51');

--
-- Table structure for table `roles_mapping`
--

CREATE TABLE `roles_mapping` (
  `Host` char(60) NOT NULL DEFAULT '',
  `User` char(80) NOT NULL DEFAULT '',
  `Role` char(80) NOT NULL DEFAULT '',
  `Admin_option` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  UNIQUE KEY `Host` (`Host`,`User`,`Role`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Granted roles';

--
-- Dumping data for table `roles_mapping`
--


--
-- Table structure for table `servers`
--

CREATE TABLE `servers` (
  `Server_name` char(64) NOT NULL DEFAULT '',
  `Host` varchar(2048) NOT NULL DEFAULT '',
  `Db` char(64) NOT NULL DEFAULT '',
  `Username` char(80) NOT NULL DEFAULT '',
  `Password` char(64) NOT NULL DEFAULT '',
  `Port` int(4) NOT NULL DEFAULT 0,
  `Socket` char(64) NOT NULL DEFAULT '',
  `Wrapper` char(64) NOT NULL DEFAULT '',
  `Owner` varchar(512) NOT NULL DEFAULT '',
  PRIMARY KEY (`Server_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='MySQL Foreign Servers table';

--
-- Dumping data for table `servers`
--


--
-- Table structure for table `table_stats`
--

CREATE TABLE `table_stats` (
  `db_name` varchar(64) NOT NULL,
  `table_name` varchar(64) NOT NULL,
  `cardinality` bigint(21) unsigned DEFAULT NULL,
  PRIMARY KEY (`db_name`,`table_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Tables';

--
-- Dumping data for table `table_stats`
--


--
-- Table structure for table `tables_priv`
--

CREATE TABLE `tables_priv` (
  `Host` char(60) NOT NULL DEFAULT '',
  `Db` char(64) NOT NULL DEFAULT '',
  `User` char(80) NOT NULL DEFAULT '',
  `Table_name` char(64) NOT NULL DEFAULT '',
  `Grantor` char(141) NOT NULL DEFAULT '',
  `Timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `Table_priv` set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger','Delete versioning rows') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '',
  `Column_priv` set('Select','Insert','Update','References') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`),
  KEY `Grantor` (`Grantor`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Table privileges';

--
-- Dumping data for table `tables_priv`
--


--
-- Table structure for table `time_zone`
--

CREATE TABLE `time_zone` (
  `Time_zone_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Use_leap_seconds` enum('Y','N') NOT NULL DEFAULT 'N',
  PRIMARY KEY (`Time_zone_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='Time zones';

--
-- Dumping data for table `time_zone`
--


--
-- Table structure for table `time_zone_leap_second`
--

CREATE TABLE `time_zone_leap_second` (
  `Transition_time` bigint(20) NOT NULL,
  `Correction` int(11) NOT NULL,
  PRIMARY KEY (`Transition_time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='Leap seconds information for time zones';

--
-- Dumping data for table `time_zone_leap_second`
--


--
-- Table structure for table `time_zone_name`
--

CREATE TABLE `time_zone_name` (
  `Name` char(64) NOT NULL,
  `Time_zone_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`Name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='Time zone names';

--
-- Dumping data for table `time_zone_name`
--


--
-- Table structure for table `time_zone_transition`
--

CREATE TABLE `time_zone_transition` (
  `Time_zone_id` int(10) unsigned NOT NULL,
  `Transition_time` bigint(20) NOT NULL,
  `Transition_type_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`Time_zone_id`,`Transition_time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='Time zone transitions';

--
-- Dumping data for table `time_zone_transition`
--


--
-- Table structure for table `time_zone_transition_type`
--

CREATE TABLE `time_zone_transition_type` (
  `Time_zone_id` int(10) unsigned NOT NULL,
  `Transition_type_id` int(10) unsigned NOT NULL,
  `Offset` int(11) NOT NULL DEFAULT 0,
  `Is_DST` tinyint(3) unsigned NOT NULL DEFAULT 0,
  `Abbreviation` char(8) NOT NULL DEFAULT '',
  PRIMARY KEY (`Time_zone_id`,`Transition_type_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='Time zone transition types';

--
-- Dumping data for table `time_zone_transition_type`
--


--
-- Table structure for table `user`
--

CREATE TABLE `user` (
  `Host` char(60) NOT NULL DEFAULT '',
  `User` char(80) NOT NULL DEFAULT '',
  `Password` char(41) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `Select_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Insert_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Update_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Delete_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Create_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Drop_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Reload_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Shutdown_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Process_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `File_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Grant_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `References_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Index_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Alter_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Show_db_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Super_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Create_tmp_table_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Lock_tables_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Execute_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Repl_slave_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Repl_client_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Create_view_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Show_view_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Create_routine_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Alter_routine_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Create_user_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Event_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Trigger_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Create_tablespace_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `Delete_history_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `ssl_type` enum('','ANY','X509','SPECIFIED') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '',
  `ssl_cipher` blob NOT NULL,
  `x509_issuer` blob NOT NULL,
  `x509_subject` blob NOT NULL,
  `max_questions` int(11) unsigned NOT NULL DEFAULT 0,
  `max_updates` int(11) unsigned NOT NULL DEFAULT 0,
  `max_connections` int(11) unsigned NOT NULL DEFAULT 0,
  `max_user_connections` int(11) NOT NULL DEFAULT 0,
  `plugin` char(64) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
  `authentication_string` text NOT NULL,
  `password_expired` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `is_role` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
  `default_role` char(80) NOT NULL DEFAULT '',
  `max_statement_time` decimal(12,6) NOT NULL DEFAULT 0.000000,
  PRIMARY KEY (`Host`,`User`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Users and global privileges';

--
-- Dumping data for table `user`
--

INSERT INTO `user` VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'unix_socket','','N','N','',0.000000);

--
-- Table structure for table `transaction_registry`
--

CREATE TABLE IF NOT EXISTS `transaction_registry` (
  `transaction_id` bigint(20) unsigned NOT NULL,
  `commit_id` bigint(20) unsigned NOT NULL,
  `begin_timestamp` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000',
  `commit_timestamp` timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000',
  `isolation_level` enum('READ-UNCOMMITTED','READ-COMMITTED','REPEATABLE-READ','SERIALIZABLE') NOT NULL,
  PRIMARY KEY (`transaction_id`),
  UNIQUE KEY `commit_id` (`commit_id`),
  KEY `begin_timestamp` (`begin_timestamp`),
  KEY `commit_timestamp` (`commit_timestamp`,`transaction_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;


