INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (328, 14, 'MASTER\\_POS\\_WAIT', 'Syntax\n------\n\nMASTER_POS_WAIT(log_name,log_pos[,timeout,["connection_name"]])\n\nDescription\n-----------\n\nThis function is useful in replication for controlling master/slave synchronization. It blocks until the slave has read and applied all updates up to the specified position (log_name,log_pos) in the binary log. The return value is the number of log events the slave had to wait for to advance to the specified position. The function returns NULL if the slave SQL thread is not started, the slave''s master information is not initialized, the arguments are incorrect, or an error occurs. It returns -1 if\\\nthe timeout has been exceeded. If the slave SQL thread stops whileMASTER_POS_WAIT() is waiting, the function returns NULL. If the slave is past the specified position, the function returns immediately.\n\nIf a timeout value is specified, MASTER_POS_WAIT() stops waiting when timeout seconds have elapsed. timeout must be greater than 0; a zero or negative timeout means no timeout.\n\nThe connection_name is used when you are using multi-source-replication. If you don''t specify it, it''s set to the value of the default_master_connection system variable.\n\nStatements using the MASTER_POS_WAIT() function are not safe for statement-based replication.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/master_pos_wait', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/master_pos_wait');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (329, 14, 'FORMAT\\_BYTES', 'Syntax\n------\n\nFORMAT_BYTES(double)\n\nDescription\n-----------\n\nGiven a byte count, returns a string consisting of a value and the units in a human-readable format. The units will be in bytes, KiB (kibibytes), MiB (mebibytes), GiB (gibibytes), TiB (tebibytes), PiB (pebibytes) or EiB (exbibytes).\n\nThe binary prefixes (kibi, mebi, gibi, tebi, pebi and exbi) were created in December 1998 by the International Electrotechnical Commission to avoid possible ambiguity, as the widely-used prefixes kilo, mega, giga, tera, peta and exa can be used to refer to both the power-of-10 decimal system multipliers and the power-of-two binary system multipliers.\n\nThis function is similar to the Sys Schema format_bytes function, except that function does not display exbibytes.\n\nExamples\n--------\n\nSELECT FORMAT_BYTES(1000)FORMAT_BYTES(1024);\n+--------------------+--------------------+\n| FORMAT_BYTES(1000) | FORMAT_BYTES(1024) |\n+--------------------+--------------------+\n| 1000 bytes         | 1.00 KiB           |\n+--------------------+--------------------+\n\nSELECT FORMAT_BYTES(1000000),FORMAT_BYTES(1048576);\n+-----------------------+-----------------------+\n| FORMAT_BYTES(1000000) | FORMAT_BYTES(1048576) |\n+-----------------------+-----------------------+\n| 976.56 KiB            | 1.00 MiB              |\n+-----------------------+-----------------------+\n\nSELECT FORMAT_BYTES(1000000000),FORMAT_BYTES(1073741874);\n+--------------------------+--------------------------+\n| FORMAT_BYTES(1000000000) | FORMAT_BYTES(1073741874) |\n+--------------------------+--------------------------+\n| 953.67 MiB               | 1.00 GiB                     |\n+--------------------------+--------------------------+\n\nSELECT FORMAT_BYTES(1000000000000),FORMAT_BYTES(1099511627776);\n+-----------------------------+-----------------------------+\n| FORMAT_BYTES(1000000000000) | FORMAT_BYTES(1099511627776) |\n+-----------------------------+-----------------------------+\n| 931.32 GiB                  | 1.00 TiB                    |\n+-----------------------------+-----------------------------+\n\nSELECT FORMAT_BYTES(1000000000000000),FORMAT_BYTES(1125899906842624);\n+--------------------------------+--------------------------------+\n| FORMAT_BYTES(1000000000000000) | FORMAT_BYTES(1125899906842624) |\n+--------------------------------+--------------------------------+\n| 909.49 TiB                     | 1.00 PiB                       |\n+--------------------------------+--------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/miscellaneous-functions-format_bytes', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/miscellaneous-functions-format_bytes');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (330, 14, 'NAME\\_CONST', 'Syntax\n------\n\nNAME_CONST(name,value)\n\nDescription\n-----------\n\nReturns the given value. When used to produce a result set column,NAME_CONST() causes the column to have the given name. The arguments should be constants.\n\nThis function is used internally when replicating stored procedures. It makes little sense to use it explicitly in SQL statements, and it was not supposed to be used like that.\n\n``sql\nSELECT NAME_CONST(''myname'', 14);\n+--------+\n| myname |\n+--------+\n|     14 |\n+--------+\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/name_const', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/name_const');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (331, 14, 'OLD\\_VALUE', 'Syntax\n------\n\nOLD_VALUE(val)\n\nDescription\n-----------\n\nIn the RETURNING clause of an UPDATE statement, OLD_VALUE() returns the value before the update. The function is meaningful only in this context.\n\nExamples\n--------\n\nUPDATE t SET a=a+1 RETURNING OLD_VALUE(a) AS old, a as new;\n+------+------+\n| old  | new  |\n+------+------+\n|    1 |    2 |\n+------+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/old-value', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/old-value');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (332, 14, 'RELEASE\\_ALL\\_LOCKS', 'Syntax\n------\n\nRELEASE_ALL_LOCKS()\n\nDescription\n-----------\n\nReleases all named locks held by the current session. Returns the number of locks released, or 0 if none were held.\n\nStatements using the RELEASE_ALL_LOCKS function are not safe for statement-based replication.\n\nExamples\n--------\n\nSELECT RELEASE_ALL_LOCKS();\n+---------------------+\n| RELEASE_ALL_LOCKS() | \n+---------------------+\n|                   0 |\n+---------------------+\n\nSELECT GET_LOCK(''lock1'',10);\n+----------------------+\n| GET_LOCK(''lock1'',10) |\n+----------------------+\n|                    1 |\n+----------------------+\n\nSELECT RELEASE_ALL_LOCKS();\n+---------------------+\n| RELEASE_ALL_LOCKS() | \n+---------------------+\n|                   1 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/release_all_locks', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/release_all_locks');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (333, 14, 'RELEASE\\_LOCK', 'Syntax\n------\n\nRELEASE_LOCK(str)\n\nDescription\n-----------\n\nReleases the lock named by the string str that was obtained with GET_LOCK(). Returns 1 if the lock was released, 0 if the lock was not established by this connection (in which case the lock is not released), and NULL if the named lock did not exist. The lock does not exist if it was never obtained by a call to GET_LOCK() or if it has previously been released.\n\nstr is case insensitive. If str is an empty string or NULL, RELEASE_LOCK() returns NULL and does nothing.\n\nStatements using the RELEASE_LOCK function are not safe for statement-based replication.\n\nThe DO statement is convenient to use with RELEASE_LOCK().\n\nExamples\n--------\n\nSELECT GET_LOCK(''lock1'',10);\n+----------------------+\n| GET_LOCK(''lock1'',10) |\n+----------------------+\n|                    1 |\n+----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/release_lock', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/release_lock');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (334, 14, 'SLEEP', 'Syntax\n------\n\nSLEEP(duration)\n\nDescription\n-----------\n\nSleeps (pauses) for the number of seconds given by the duration argument, then returns 0. If SLEEP() is interrupted, it returns 1. The duration may have a fractional part given in microseconds.\n\nStatements using the SLEEP() function are not safe for statement-based replication.\n\nExamples\n--------\n\nSELECT SLEEP(5.5);\n+------------+\n| SLEEP(5.5) |\n+------------+\n|          0 |\n+------------+\n1 row in set (5.50 sec)\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/sleep', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/sleep');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (335, 14, 'SYS\\_GUID', 'Syntax\n------\n\nSYS_GUID()\n\nDescription\n-----------\n\nReturns a 16-byte globally unique identifier (GUID), similar to the UUID function, but without the - character.\n\nExamples\n--------\n\nSELECT SYS_GUID();\n+----------------------------------+\n| SYS_GUID()                       |\n+----------------------------------+\n| 2C574E45BA2811EBB265F859713E4BE4 |\n+----------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/sys_guid', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/sys_guid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (336, 14, 'UUID', 'Syntax\n------\n\nUUID()\n\nDescription\n-----------\n\nReturns a Universally Unique Identifier (UUID) version 1. Functions to generate v4 and v7 UUIDs are available from MariaDB 11.7. See UUIDv4 and UUIDv7 respectively.\n\nA UUID is designed as a number that is globally unique in space and time. Two calls to UUID() are expected to generate two different values, even if these calls are performed on two separate computers that are not connected to each other.\n\nUUID() results are intended to be unique, but cannot always be relied upon to be unpredictable and unguessable.\n\nA UUID is a 128-bit number represented by a utf8 string of five hexadecimal numbers in aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee format:\n\n The first three numbers are generated from a timestamp.\n The fourth number preserves temporal uniqueness in case the timestamp value\\\n  loses monotonicity (for example, due to daylight saving time).\n* The fifth number is an IEEE 802 node number that provides spatial uniqueness.\\\n  A random number is substituted if the latter is not available (for example,\\\n  because the host computer has no Ethernet card, or we do not know how to find\\\n  the hardware address of an interface on your operating system). In this case,\\\n  spatial uniqueness cannot be guaranteed. Nevertheless, a collision should\\\n  have very low probability.\n\nCurrently, the MAC address of an interface is taken into account only on FreeBSD and Linux. On other operating systems, MariaDB uses a randomly generated 48-bit number.\n\nStatements using the UUID() function are not safe for statement-based replication.\n\nThe function generates a UUIDv1 and the results are generated according to the "DCE 1.1:Remote Procedure Call" (Appendix A) CAE (Common Applications Environment) Specifications published by The Open Group in October 1997 (Document Number C706).\n\nExamples\n--------\n\nSELECT UUID();\n+--------------------------------------+\n| UUID()                               |\n+--------------------------------------+\n| cd41294a-afb0-11df-bc9b-00241dd75637 |\n+--------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (337, 14, 'UUID\\_SHORT', 'Syntax\n------\n\nUUID_SHORT()\n\nDescription\n-----------\n\nReturns a "short" universally unique identifier as a 64-bit unsigned integer (rather than a string-form 128-bit identifier as returned by the UUID() function).\n\nThe value of UUID_SHORT() is guaranteed to be unique if the following conditions hold:\n\n The server_id of the current host is unique among your set of master and slave servers.\n server_id is between 0 and 255.\n You don''t set back your system time for your server between mariadbd restarts.\n You do not invoke UUID_SHORT() on average more than 16 million times per second between mariadbd restarts\n\nThe UUID_SHORT() return value is constructed this way:\n\n``sql\n(server_id & 255) << 56\n+ (server_startup_time_in_seconds << 24)\n+ incremented_variable++;\n``\n\nStatements using the UUID_SHORT() function are not safe for statement-based replication.\n\nExamples\n--------\n\nSELECT UUID_SHORT();\n+-------------------+\n| UUID_SHORT()      |\n+-------------------+\n| 21517162376069120 |\n+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_short', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_short');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (338, 14, 'UUID\\_v4', 'Syntax\n------\n\nUUID_v4()\n\nDescription\n-----------\n\nReturns a Universally Unique Identifier (UUID) version 4. To generate a version 1 UUID, see the UUID function. To generate a version 7 UUID, see UUIDv7.\n\nA UUID is designed as a number that is globally unique in space and time. Two calls to UUID() are expected to generate two different values, even if these calls are performed on two separate computers that are not connected to each other.\n\nUUID_v4() results are intended to be unique, but cannot always be relied upon to be unpredictable and unguessable.\n\nA UUID is a 128-bit number represented by a utf8 string of five hexadecimal numbers in aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee format.\n\nStatements using the UUID_v4() function are not safe for statement-based replication.\n\nExamples\n--------\n\nSELECT UUID(),UUID_v4(),UUID_v7()\\G \n************************ 1. row ************************\n  UUID(): 63ae8c92-799a-11ef-98b2-f859713e4be4\nUUID_v4(): a2443495-1b94-415b-b6fa-fe8e79ba4812\nUUID_v7(): 01921e85-f198-7490-9b89-7dd0d468543b\n\nCREATE TABLE t1 (a INT PRIMARY KEY NOT NULL, u UUID DEFAULT UUID_v4(), UNIQUE KEY(u));\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_v4', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_v4');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (339, 14, 'UUID\\_v7', 'Syntax\n------\n\nUUID_v7()\n\nDescription\n-----------\n\nReturns a Universally Unique Identifier (UUID) version 7. To generate a version 1 UUID, see the UUID function. To generate a version 4 UUID, see UUID_v4.\n\nA UUID is designed as a number that is globally unique in space and time. Two calls to UUID() are expected to generate two different values, even if these calls are performed on two separate computers that are not connected to each other.\n\nA UUID is a 128-bit number represented by a utf8 string of five hexadecimal numbers in aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee format.\n\nStatements using the UUID_v7() function are not safe for statement-based replication.\n\nExamples\n--------\n\nSELECT UUID(),UUID_v4(),UUID_v7()\\G \n************************ 1. row ************************\n  UUID(): 63ae8c92-799a-11ef-98b2-f859713e4be4\nUUID_v4(): a2443495-1b94-415b-b6fa-fe8e79ba4812\nUUID_v7(): 01921e85-f198-7490-9b89-7dd0d468543b\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_v7', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/uuid_v7');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (340, 14, 'VALUES / VALUE', 'Syntax\n------\n\nVALUE(col_name)\n\nDescription\n-----------\n\nIn an INSERT ... ON DUPLICATE KEY UPDATE statement, you can use the VALUES(col_name) function in the UPDATE clause to refer to column values from the INSERT portion of the statement. In other words, VALUES(col_name) in the UPDATE clause refers to the value of col_name that would be inserted, had no duplicate-key conflict occurred. This function is especially useful in multiple-row inserts.\n\nThe VALUES() function is meaningful only in INSERT ... ON DUPLICATE KEY UPDATE statements and returns NULL otherwise.\n\nThis function was renamed to VALUE(), because it''s incompatible with the standard Table Value Constructors syntax.\n\nThe VALUES() function can still be used but only in INSERT ... ON DUPLICATE KEY UPDATE statements; it''s a syntax error otherwise.\n\nExamples\n--------\n\nINSERT INTO t (a,b,c) VALUES (1,2,3),(4,5,6)\n    ON DUPLICATE KEY UPDATE c=VALUE(a)+VALUE(b);\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/values-value', '', 'https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/values-value');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (341, 35, 'COLUMN\\_ADD', 'Syntax\n------\n\nCOLUMN_ADD(dyncol_blob, column_nr, value [as type], [column_nr, value [as type]]...)\nCOLUMN_ADD(dyncol_blob, column_name, value [as type], [column_name, value [as type]]...)\n\nDescription\n-----------\n\nAdds or updates dynamic columns.\n\n dyncol_blob must be either a valid dynamic columns blob (for example, COLUMN_CREATE returns such blob), or an empty string.\n column_name specifies the name of the column to be added. If dyncol_blob already has a column with this name, it will be overwritten.\n value specifies the new value for the column. Passing a NULL value will cause 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") WHERE id=1;\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_add', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_add');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (342, 35, 'COLUMN\\_CHECK', '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 means the blob is valid, return value of 0 means it is not.\n\nRationale:\\\nNormally, one works with valid dynamic column blobs. Functions like COLUMN_CREATE, COLUMN_ADD, COLUMN_DELETE always return valid dynamic column blobs. However, if a dynamic column blob is accidentally truncated, or transcoded from one character set to another, it will be corrupted. This function can be used to check if a value in a blob field is a valid dynamic column blob.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_check', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_check');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (343, 35, 'COLUMN\\_CREATE', '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 redundant because MariaDB will be able to deduce the type of the value. Explicit type specification may be needed when the type of the value is not apparent. For example, a literal ''2012-12-01'' has a CHAR type by default, one will need to specify ''2012-12-01'' AS DATE to have it stored as a date. See Dynamic 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/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_create', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_create');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (344, 35, 'COLUMN\\_DELETE', '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. The return value is a dynamic column blob after the modification.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_delete', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_delete');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (345, 35, 'COLUMN\\_EXISTS', '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 1, otherwise return 0. See dynamic columns for more information.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_exists', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_exists');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (346, 35, 'COLUMN\\_GET', '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 name exists, NULL will be returned.\n\ncolumn_name as type requires that one specify the datatype of the dynamic column they are reading.\n\nThis may seem counter-intuitive: why would one need to specify which datatype they''re retrieving? Can''t the dynamic columns system figure the datatype from the data being stored?\n\nThe answer is: SQL is a statically-typed language. The SQL interpreter needs to know the datatypes of all expressions before the query is run (for example, when one is using prepared statements and runs "select COLUMN_GET(...)", the prepared statement API requires the server to inform the client about the datatype of the column being read before the query is executed and the server can see what datatype the column actually has).\n\nLengths\n\nSuppose running a query like this:\n\n``sql\nSELECT COLUMN_GET(BLOB, ''colname'' AS CHAR) ...\n`\n\nWithout specifying a maximum length (i.e. using as CHAR, not as CHAR(n)`), MariaDB will report the maximum length of the result set column to be 16,777,216. This may cause excessive memory usage in some client libraries, because they try to pre-allocate a buffer of maximum result set width. To avoid this 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/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_get', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_get');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (347, 35, 'COLUMN\\_JSON', '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 display nested columns. See dynamic columns for more information.\n\nExamples\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\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_json', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_json');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (348, 35, 'COLUMN\\_LIST', 'Syntax\n------\n\nCOLUMN_LIST(dyncol_blob);\n\nDescription\n-----------\n\nReturns a comma-separated list of column names. The names are quoted with backticks.\n\nSee dynamic columns for more information.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_list', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/dynamic-columns-functions/column_list');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (349, 35, 'WSREP\\_LAST\\_SEEN\\_GTID', 'Syntax\n------\n\nWSREP_LAST_SEEN_GTID()\n\nDescription\n-----------\n\nReturns the Global Transaction ID of the most recent write transaction observed by the client.\n\nThe result can be useful to determine the transaction to provide to WSREP_SYNC_WAIT_UPTO_GTID for waiting and unblocking purposes.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/galera-functions/wsrep_last_seen_gtid', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/galera-functions/wsrep_last_seen_gtid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (350, 35, 'WSREP\\_LAST\\_WRITTEN\\_GTID', 'Syntax\n------\n\nWSREP_LAST_WRITTEN_GTID()\n\nDescription\n-----------\n\nReturns the Global Transaction ID of the most recent write transaction performed by the client.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/galera-functions/wsrep_last_written_gtid', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/galera-functions/wsrep_last_written_gtid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (351, 35, 'WSREP\\_SYNC\\_WAIT\\_UPTO\\_GTID', 'Syntax\n------\n\nWSREP_SYNC_WAIT_UPTO_GTID(gtid[,timeout])\n\nDescription\n-----------\n\nBlocks the client until the transaction specified by the given Global Transaction ID is applied and committed by the node.\n\nThe optional _timeout_ argument can be used to specify a block timeout in seconds. If not provided, the timeout will be indefinite.\n\nReturns the node that applied and committed the Global Transaction ID, ER_LOCAL_WAIT_TIMEOUT if the function is timed out before this, or ER_WRONG_ARGUMENTS if the function is given an invalid GTID.\n\nThe result from WSREP_LAST_SEEN_GTID can be useful to determine the transaction to provide to WSREP_SYNC_WAIT_UPTO_GTID for waiting and unblocking purposes.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/galera-functions/wsrep_sync_wait_upto_gtid', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/galera-functions/wsrep_sync_wait_upto_gtid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (352, 35, 'Geographic Functions', 'Description\n-----------\n\nGeographic and geometry functions. See Geographic Features for a full discussion of MariaDB''s spatial extensions.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/geographic-functions', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/geographic-functions');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (353, 35, 'Differences between JSON\\_QUERY and JSON\\_VALUE', 'Description\n-----------\n\nThe primary difference between the two functions is that _JSON_QUERY_ returns an object or an array, while _JSON_VALUE_ returns a scalar.\n\nTake the following JSON document as an example:\n\n``sql\nSET @json=''{ "x": [0,1], "y": "[0,1]", "z": "Monty" }'';\n`\n\nNote that data member "x" is an array, and data members "y" and "z" are strings. The following examples demonstrate the differences between the two functions.\n\n`sql\nSELECT JSON_QUERY(@json,''$''), JSON_VALUE(@json,''$'');\n+--------------------------------------------+-----------------------+\n| JSON_QUERY(@json,''$'')                      | JSON_VALUE(@json,''$'') |\n+--------------------------------------------+-----------------------+\n| { "x": [0,1], "y": "[0,1]", "z": "Monty" } | NULL                  |\n+--------------------------------------------+-----------------------+\n\nSELECT JSON_QUERY(@json,''$.x''), JSON_VALUE(@json,''$.x'');\n+-------------------------+-------------------------+\n| JSON_QUERY(@json,''$.x'') | JSON_VALUE(@json,''$.x'') |\n+-------------------------+-------------------------+\n| [0,1]                   | NULL                    |\n+-------------------------+-------------------------+\n\nSELECT JSON_QUERY(@json,''$.y''), JSON_VALUE(@json,''$.y'');\n+-------------------------+-------------------------+\n| JSON_QUERY(@json,''$.y'') | JSON_VALUE(@json,''$.y'') |\n+-------------------------+-------------------------+\n| NULL                    | [0,1]                   |\n+-------------------------+-------------------------+\n\nSELECT JSON_QUERY(@json,''$.z''), JSON_VALUE(@json,''$.z'');\n+-------------------------+-------------------------+\n| JSON_QUERY(@json,''$.z'') | JSON_VALUE(@json,''$.z'') |\n+-------------------------+-------------------------+\n| NULL                    | Monty                   |\n+-------------------------+-------------------------+\n\nSELECT JSON_QUERY(@json,''$.x[0]''), JSON_VALUE(@json,''$.x[0]'');\n+----------------------------+----------------------------+\n| JSON_QUERY(@json,''$.x[0]'') | JSON_VALUE(@json,''$.x[0]'') |\n+----------------------------+----------------------------+\n| NULL                       | 0                          |\n+----------------------------+----------------------------+\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/differences-between-json_query-and-json_value', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/differences-between-json_query-and-json_value');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (354, 35, 'JSON Validation Function', 'Description\n-----------\n\nThe IS JSON is a variant of IS predicate that checks whether an expression contains valid JSON data, with optional constraints on JSON type (VALUE, ARRAY, OBJECT, SCALAR) and key uniqueness.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json-validation-function', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json-validation-function');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (355, 35, 'JSON\\_ARRAY', '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\nExamples\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/docs/server/reference/sql-functions/special-functions/json-functions/json_array', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (356, 35, 'JSON\\_ARRAY\\_APPEND', '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, returning the result, or NULL if any of the arguments are NULL.\n\nEvaluation is performed from left to right, with the resulting document from the previous pair becoming the new value against which the next pair is evaluated.\n\nIf the json_doc is not a valid JSON document, or if any of the paths are not valid, 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/docs/server/reference/sql-functions/special-functions/json-functions/json_array_append', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array_append');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (357, 35, 'JSON\\_ARRAY\\_INSERT', '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 if any of the arguments are NULL.\n\nEvaluation is performed from left to right, with the resulting document from the previous pair becoming the new value against which the next pair is evaluated.\n\nIf the json_doc is not a valid JSON document, or if any of the paths are not valid, 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/docs/server/reference/sql-functions/special-functions/json-functions/json_array_insert', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array_insert');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (358, 35, 'JSON\\_ARRAY\\_INTERSECT', 'Syntax\n------\n\nJSON_ARRAY_INTERSECT(arr1, arr2)\n\nDescription\n-----------\n\nFinds intersection between two json arrays and returns an array of items found in both array.\n\nExamples\n--------\n\nSET @json1= ''[1,2,3]'';\nSET @json2= ''[1,2,4]'';\n\nSELECT json_array_intersect(@json1, @json2); \n+--------------------------------------+\n| json_array_intersect(@json1, @json2) |\n+--------------------------------------+\n| [1, 2]                               |\n+--------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array_intersect', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_array_intersect');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (359, 35, 'JSON\\_ARRAYAGG', 'Syntax\n------\n\nJSON_ARRAYAGG(column_or_expression)\n\nDescription\n-----------\n\nJSON_ARRAYAGG returns a JSON array containing an element for each value in a given set of JSON or SQL values. It acts on a column or an expression that evaluates to a single value.\n\nThe maximum returned length in bytes is determined by the group_concat_max_len server system variable.\n\nReturns NULL in the case of an error, or if the result contains no rows.\n\nJSON_ARRAYAGG cannot currently be used as a window function.\n\nThe full syntax is as follows:\n\n``sql\nJSON_ARRAYAGG([DISTINCT] expr\n             [ORDER BY {unsigned_integer | col_name | expr}\n                 [ASC | DESC] [,col_name ...]]\n             [LIMIT {[offset,] row_count | row_count OFFSET offset}])\n``\n\nExamples\n--------\n\nCREATE TABLE t1 (a INT, b INT);\n\nINSERT INTO t1 VALUES (1, 1),(2, 1), (1, 1),(2, 1), (3, 2),(2, 2),(2, 2),(2, 2);\n\nSELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1;\n+-------------------+-------------------+\n| JSON_ARRAYAGG(a)  | JSON_ARRAYAGG(b)  |\n+-------------------+-------------------+\n| [1,2,1,2,3,2,2,2] | [1,1,1,1,2,2,2,2] |\n+-------------------+-------------------+\n\nSELECT JSON_ARRAYAGG(a), JSON_ARRAYAGG(b) FROM t1 GROUP BY b;\n+------------------+------------------+\n| JSON_ARRAYAGG(a) | JSON_ARRAYAGG(b) |\n+------------------+------------------+\n| [1,2,1,2]        | [1,1,1,1]        |\n| [3,2,2,2]        | [2,2,2,2]        |\n+------------------+------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_arrayagg', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_arrayagg');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (360, 35, 'JSON\\_COMPACT', '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\nExamples\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/docs/server/reference/sql-functions/special-functions/json-functions/json_compact', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_compact');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (361, 35, 'JSON\\_CONTAINS', '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 or, optionally, at the specified path within the document. Returns 1 if it does, 0 if not and NULL if any of the arguments are null. An error occurs if the 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/docs/server/reference/sql-functions/special-functions/json-functions/json_contains', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_contains');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (362, 35, 'JSON\\_CONTAINS\\_PATH', '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 or paths. Returns 1 if it does, 0 if not and NULL if any of the arguments are null.\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/docs/server/reference/sql-functions/special-functions/json-functions/json_contains_path', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_contains_path');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (363, 35, 'JSON\\_DEPTH', '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 is null. An error occurs if the argument is an invalid JSON document.\n\n Scalar values or empty arrays or objects have a depth of 1.\n Arrays with only scalar values and objects with only scalar values for all keys have depth of 1.\n* In all other cases, the depth can be 2 or greater.\n\nThere is no maximum depth level — it''s unlimited.\n\nFor more information, see this blog post.\n\nThe maximum depth is 32.\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/docs/server/reference/sql-functions/special-functions/json-functions/json_depth', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_depth');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (364, 35, 'JSON\\_DETAILED', 'Syntax\n------\n\nJSON_DETAILED(json_doc[, tab_size])\nJSON_PRETTY(json_doc[, tab_size])\n\nDescription\n-----------\n\nRepresents JSON in the most understandable way emphasizing nested structures.\n\nJSON_PRETTY is an alias for JSON_DETAILED .\n\nJSON_PRETTY is not available as an alias for JSON_DETAILED .\n\nExamples\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/docs/server/reference/sql-functions/special-functions/json-functions/json_detailed', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_detailed');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (365, 35, 'JSON\\_EQUALS', 'Syntax\n------\n\nJSON_EQUALS(json1, json2)\n\nDescription\n-----------\n\nChecks if there is equality between two json objects. Returns 1 if it there is, 0 if not, or NULL if any of the arguments are null.\n\nExamples\n--------\n\nSELECT JSON_EQUALS(''{"a"   :[1, 2, 3],"b":[4]}'', ''{"b":[4],"a":[1, 2, 3.0]}'');\n+------------------------------------------------------------------------+\n| JSON_EQUALS(''{"a"   :[1, 2, 3],"b":[4]}'', ''{"b":[4],"a":[1, 2, 3.0]}'') |\n+------------------------------------------------------------------------+\n|                                                                      1 |\n+------------------------------------------------------------------------+\n\nSELECT JSON_EQUALS(''{"a":[1, 2, 3]}'', ''{"a":[1, 2, 3.01]}'');\n+------------------------------------------------------+\n| JSON_EQUALS(''{"a":[1, 2, 3]}'', ''{"a":[1, 2, 3.01]}'') |\n+------------------------------------------------------+\n|                                                    0 |\n+------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_equals', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_equals');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (366, 35, 'JSON\\_EXISTS', 'Syntax\n------\n\nJSON_EXISTS(json_doc, json_path)\n\nDescription\n-----------\n\nDetermines whether json_doc has an element pointed to by path json_path. Returns 1 if the element exists, 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/docs/server/reference/sql-functions/special-functions/json-functions/json_exists', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_exists');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (367, 35, 'JSON\\_EXTRACT', '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 parts matching the path arguments. Returns all matched values; either as a single matched value, or, if the arguments could return multiple values, a result 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 occurs if any path argument is not a valid path, or if the json_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/docs/server/reference/sql-functions/special-functions/json-functions/json_extract', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_extract');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (368, 35, 'JSON\\_INSERT', '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 either of the _json_doc_ or _path_ arguments are null.\n\nAn error occurs if the JSON document is invalid, or if any of the paths are invalid or contain a  or * wildcard.\n\nJSON_INSERT can only insert data, while JSON_REPLACE can only update. JSON_SET can 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/docs/server/reference/sql-functions/special-functions/json-functions/json_insert', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_insert');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (369, 35, 'JSON\\_KEY\\_VALUE', 'Syntax\n------\n\nJSON_KEY_VALUE(obj, json_path)\n\nDescription\n-----------\n\nJSON_KEY_VALUE extracts key/value pairs from a JSON object. The JSON path parameter is used to only return key/value pairs for matching JSON objects.\n\nExamples\n--------\n\nSELECT JSON_KEY_VALUE(''[[1, {"key1":"val1", "key2":"val2"}, 3], 2, 3]'', ''$[0][1]'');\n+-----------------------------------------------------------------------------+\n| JSON_KEY_VALUE(''[[1, {"key1":"val1", "key2":"val2"}, 3], 2, 3]'', ''$[0][1]'') |\n+-----------------------------------------------------------------------------+\n| [{"key": "key1", "value": "val1"}, {"key": "key2", "value": "val2"}]        |\n+-----------------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_key_value', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_key_value');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (370, 35, 'JSON\\_KEYS', '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, if 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 array 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 object, 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 path 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/docs/server/reference/sql-functions/special-functions/json-functions/json_keys', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_keys');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (371, 35, 'JSON\\_LENGTH', '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 given, 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 does not identify a value in the document.\n\nAn error occurs if the JSON document is invalid, the path is invalid or if the 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\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_length', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_length');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (372, 35, 'JSON\\_LOOSE', 'Syntax\n------\n\nJSON_LOOSE(json_doc)\n\nDescription\n-----------\n\nAdds spaces to a JSON document to make it look more readable.\n\nExamples\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/docs/server/reference/sql-functions/special-functions/json-functions/json_loose', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_loose');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (373, 35, 'JSON\\_MERGE', '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 is deprecated. JSON_MERGE_PATCH is an RFC 7396-compliant replacement, and JSON_MERGE_PRESERVE is a synonym.\n\nExamples\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/docs/server/reference/sql-functions/special-functions/json-functions/json_merge', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_merge');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (374, 35, 'JSON\\_MERGE\\_PATCH', 'Syntax\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 argument is NULL.\n\nJSON_MERGE_PATCH is an RFC 7396-compliant replacement for JSON_MERGE, which is deprecated.\n\nUnlike JSON_MERGE_PRESERVE, members with duplicate keys are not preserved.\n\nExamples\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/docs/server/reference/sql-functions/special-functions/json-functions/json_merge_patch', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_merge_patch');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (375, 35, 'JSON\\_MERGE\\_PRESERVE', 'Syntax\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 argument is NULL.\n\nJSON_MERGE_PRESERVE is a synonym for JSON_MERGE, which has been deprecated.\n\nUnlike JSON_MERGE_PATCH, members with duplicate keys are preserved.\n\nExamples\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/docs/server/reference/sql-functions/special-functions/json-functions/json_merge_preserve', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_merge_preserve');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (376, 35, 'JSON\\_NORMALIZE', 'Syntax\n------\n\nJSON_NORMALIZE(json)\n\nDescription\n-----------\n\nRecursively sorts keys and removes spaces, allowing comparison of json documents for equality.\n\nExamples\n--------\n\nCREATE TABLE t1 (\n id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,\n val JSON,\n / other columns here /\n PRIMARY KEY (id)\n);\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_normalize', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_normalize');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (377, 35, 'JSON\\_OBJECT', '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 can be empty.\n\nAn error will occur if there are an odd number of arguments, or any key name is NULL.\n\nExamples\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/docs/server/reference/sql-functions/special-functions/json-functions/json_object', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_object');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (378, 35, 'JSON\\_OBJECT\\_FILTER\\_KEYS', 'Syntax\n------\n\nJSON_OBJECT_FILTER_KEYS(obj, array_keys)\n\nDescription\n-----------\n\nJSON_OBJECT_FILTER_KEYS returns a JSON object with keys from the object that are also present in the array as string. It is used when one wants to get key-value pair such that the keys are common but the values may not be common.\n\nExamples\n--------\n\nSET @obj1= ''{ "a": 1, "b": 2, "c": 3}'';\nSET @obj2= ''{"b" : 10, "c": 20, "d": 30}'';\nSELECT JSON_OBJECT_FILTER_KEYS (@obj1, JSON_ARRAY_INTERSECT(JSON_KEYS(@obj1), JSON_KEYS(@obj2)));\n+-------------------------------------------------------------------------------------------+\n| JSON_OBJECT_FILTER_KEYS (@obj1, JSON_ARRAY_INTERSECT(JSON_KEYS(@obj1), JSON_KEYS(@obj2))) |\n+-------------------------------------------------------------------------------------------+\n| {"b": 2, "c": 3}                                                                          |\n+-------------------------------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_object_filter_keys', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_object_filter_keys');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (379, 35, 'JSON\\_OBJECT\\_TO\\_ARRAY', 'Syntax\n------\n\nJSON_OBJECT_TO_ARRAY(Obj)\n\nDescription\n-----------\n\nIt is used to convert all JSON objects found in a JSON document to JSON arrays where each item in the outer array represents a single key-value pair from the object. It is used when we want not just common keys, but also common values. It can be used in conjunction with JSON_ARRAY_INTERSECT().\n\nExamples\n--------\n\nSET @obj1= ''{ "a": [1, 2, 3], "b": { "key1":"val1", "key2": {"key3":"val3"} }}'';\n\nSELECT JSON_OBJECT_TO_ARRAY(@obj1);\n+-----------------------------------------------------------------------+\n| JSON_OBJECT_TO_ARRAY(@obj1)                                           |\n+-----------------------------------------------------------------------+\n| [["a", [1, 2, 3]], ["b", {"key1": "val1", "key2": {"key3": "val3"}}]] |\n+-----------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_object_to_array', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_object_to_array');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (380, 35, 'JSON\\_OBJECTAGG', 'Syntax\n------\n\nJSON_OBJECTAGG(key, value)\n\nDescription\n-----------\n\nJSON_OBJECTAGG returns a JSON object containing key-value pairs. It takes two expressions that evaluate to a single value, or two column names, as arguments, the first used as a key, and the second as a value.\n\nThe maximum returned length in bytes is determined by the group_concat_max_len server system variable.\n\nReturns NULL in the case of an error, or if the result contains no rows.\n\nJSON_OBJECTAGG cannot currently be used as a window function.\n\nExamples\n--------\n\nSELECT * FROM t1;\n+------+-------+\n| a    | b     |\n+------+-------+\n|    1 | Hello |\n|    1 | World |\n|    2 | This  |\n+------+-------+\n\nSELECT JSON_OBJECTAGG(a, b) FROM t1;\n+----------------------------------------+\n| JSON_OBJECTAGG(a, b)                   |\n+----------------------------------------+\n| {"1":"Hello", "1":"World", "2":"This"} |\n+----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_objectagg', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_objectagg');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (381, 35, 'JSON\\_OVERLAPS', 'Syntax\n------\n\nJSON_OVERLAPS(json_doc1, json_doc2)\n\nDescription\n-----------\n\nJSON_OVERLAPS() compares two json documents and returns true if they have at least one common\\\nkey-value pair between two objects, array element common between two arrays, or array element common with scalar if one of the arguments is a scalar and other is an array. If two json documents are scalars, it returns true if they have same type and value.\n\nIf none of the above conditions are satisfied then it returns false.\n\nExamples\n--------\n\nSELECT JSON_OVERLAPS(''false'', ''false'');\n+---------------------------------+\n| JSON_OVERLAPS(''false'', ''false'') |\n+---------------------------------+\n| 1                               |\n+---------------------------------+\n\nSELECT JSON_OVERLAPS(''true'', ''["abc", 1, 2, true, false]'');\n+----------------------------------------------------+\n| JSON_OVERLAPS(''true'',''["abc", 1, 2, true, false]'') |\n+----------------------------------------------------+\n| 1                                                  |\n+----------------------------------------------------+\n\nSELECT JSON_OVERLAPS(''{"A": 1, "B": {"C":2}}'', ''{"A": 2, "B": {"C":2}}'') AS is_overlap;\n+---------------------+\n| is_overlap          |\n+---------------------+\n| 1                   |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_overlaps', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_overlaps');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (382, 35, 'JSON\\_PRETTY', 'Description\n-----------\n\nJSON_PRETTY is available from MariaDB 10.10.3, 10.9.5, 10.8.7, 10.7.8, 10.6.12, 10.5.19, and 10.4.28.\n\nJSON_PRETTY is an alias for JSON_DETAILED.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_pretty', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_pretty');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (383, 35, 'JSON\\_QUERY', '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. Returns 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/docs/server/reference/sql-functions/special-functions/json-functions/json_query', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_query');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (384, 35, 'JSON\\_QUOTE', 'Syntax\n------\n\nJSON_QUOTE(json_value)\n\nDescription\n-----------\n\nQuotes a string as a JSON value, usually for producing valid JSON string literals for inclusion in JSON documents. Wraps the string with double quote characters and escapes interior quotes and other special characters, returning a 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/docs/server/reference/sql-functions/special-functions/json-functions/json_quote', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_quote');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (385, 35, 'JSON\\_REMOVE', '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 arguments are null. If the element does not exist in the document, no changes are made.\n\nThe function returns NULL and throws a warning if the JSON document is invalid, the path is invalid, contains a range, or contains a  or * wildcard.\n\nPath arguments are evaluated from left to right, with the result from the earlier 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/docs/server/reference/sql-functions/special-functions/json-functions/json_remove', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_remove');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (386, 35, 'JSON\\_REPLACE', '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 any of the arguments are NULL.\n\nAn error will occur if the JSON document is invalid, the path is invalid or if the path contains a  or * wildcard.\n\nPaths and values are evaluated from left to right, with the result from the earlier evaluation being used as the value for the next.\n\nJSON_REPLACE can only update data, while JSON_INSERT can only insert. JSON_SET can 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/docs/server/reference/sql-functions/special-functions/json-functions/json_replace', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_replace');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (387, 35, 'JSON\\_SCHEMA\\_VALID', 'Syntax\n------\n\nJSON_SCHEMA_VALID(schema, json);\n\nDescription\n-----------\n\nJSON_SCHEMA_VALID allows MariaDB to support JSON schema validation. If a given json is valid against a schema it returns true. When JSON does not validate against the schema, it does not return a message about which keyword it failed against and only returns false.\n\nThe function supports JSON Schema Draft 2020 with a few exceptions:\n\n External resources are not supported.\n Hyper schema keywords are not supported.\n Formats like date, email etc are treated as annotations.\n\nExamples\n--------\n\nCREATE TABLE obj_table(val_obj JSON CHECK(JSON_SCHEMA_VALID(''{\n  "type":"object",\n    "properties": {\n      "number1":{\n        "type":"number",\n        "maximum":5,\n        "const":4\n      },\n      "string1":{\n        "type":"string",\n        "maxLength":5,\n        "minLength":3\n      },\n    "object1":{\n      "type":"object",\n       "properties":{\n         "key1": {"type":"string"},\n         "key2":{"type":"array"},\n         "key3":{"type":"number", "minimum":3}\n       },\n       "dependentRequired": { "key1":["key3"] }\n     }\n  },\n  "required":["number1","object1"]\n  }'', val_obj)));\n\nINSERT INTO obj_table VALUES(\n  ''{"number1":4, "string1":"abcd", \n  "object1":{"key1":"val1", "key2":[1,2,3, "string1"], "key3":4}}''\n);\n\nINSERT INTO obj_table VALUES(\n  ''{"number1":3, "string1":"abcd", \n  "object1":{"key1":"val1", "key2":[1,2,3, "string1"], "key3":4}}''\n);\nERROR 4025 (23000): CONSTRAINT obj_table.val_obj failed for test.obj_table\n\nSELECT  FROM obj_table;\n+--------------------------------------------------------------------------------------------------+\n| val_obj                                                                                          |\n+--------------------------------------------------------------------------------------------------+\n| {"number1":4, "string1":"abcd", "object1":{"key1":"val1", "key2":[1,2,3, "string1"], "key3":4}} |\n+--------------------------------------------------------------------------------------------------+\n\nSET @schema= ''{\n  "properties" : {\n    "number1":{ "maximum":10 },\n    "string1" : { "maxLength": 3} \n  }\n}'';\n\nSELECT JSON_SCHEMA_VALID(@schema, ''{ "number1":25, "string1":"ab" }'');\n+----------------------------------------------------------------+\n| JSON_SCHEMA_VALID(@schema, ''{ "number1":25, "string1":"ab" }'') |\n+----------------------------------------------------------------+\n|                                                              0 |\n+----------------------------------------------------------------+\n\nSELECT JSON_SCHEMA_VALID(@schema, ''{ "number1":10, "string1":"ab" }'');\n+----------------------------------------------------------------+\n| JSON_SCHEMA_VALID(@schema, ''{ "number1":10, "string1":"ab" }'') |\n+----------------------------------------------------------------+\n|                                                              1 |\n+----------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_schema_valid', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_schema_valid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (388, 35, 'JSON\\_SEARCH', '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 _json_doc_, _search_str_ or a path argument is NULL; if the search string is not found, or if no path exists within the document.\n\nA warning will occur if the JSON document is not valid, any of the path arguments are not valid, if _return_arg_ is neither _one_ nor _all_, or if the escape character is not a constant. NULL will be returned.\n\n_return_arg_ can be one of two values:\n\n ''one: Terminates after finding the first match, so will return one path string. If there is more than one match, it is undefined which is considered first.\n all: Returns all matching path strings, without duplicates. Multiple strings are 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/docs/server/reference/sql-functions/special-functions/json-functions/json_search', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_search');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (389, 35, 'JSON\\_SET', '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 any 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 the path contains a  or a wildcard\\\\.\\\\*\n\nJSON_SET can update or insert data, while JSON_REPLACE can only update, and JSON_INSERT only insert.\n\nExamples\n--------\n\nSELECT JSON_SET(Priv, ''$.locked'', ''true'') FROM mysql.global_priv\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_set', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_set');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (390, 35, 'JSON\\_TABLE', 'Syntax\n------\n\nJSON_TABLE(json_doc, \n          context_path COLUMNS (column_list)\n) [AS] alias\n\nDescription\n-----------\n\nJSON_TABLE can be used in contexts where a table reference can be used; in the FROM clause of a SELECT statement, and in multi-table UPDATE/DELETE statements.\n\njson_doc is the JSON document to extract data from. In the simplest case, it is a string literal containing JSON. In more complex cases it can be an arbitrary expression returning JSON. The expression may have references to columns of other tables. However, one can only refer to tables that precede this JSON_TABLE invocation. For RIGHT JOIN, it is assumed that its outer side precedes the inner. All tables in outer selects are also considered preceding.\n\ncontext_path is a JSON Path expression pointing to a collection of nodes in json_doc that will be used as the source of rows.\n\nThe COLUMNS clause declares the names and types of the columns that JSON_TABLE returns, as well as how the values of the columns are produced.\n\nColumn Definitions\n\nThe following types of columns are supported:\n\nPath Columns\n\n``sql\nname type PATH path_str [on_empty] [on_error]\n`\n\nLocates the JSON node pointed to by path_str and returns its value. The path_str is evaluated using the current row source node as the context node.\n\n`sql\nSET @json=''\n[\n  {"name":"Laptop", "color":"black", "price":"1000"},\n  {"name":"Jeans",  "color":"blue"}\n]'';\n\nSELECT  FROM json_table(@json, ''$[]'' \n  COLUMNS(\n   name  VARCHAR(10) path ''$.name'', \n   color VARCHAR(10) path ''$.color'',\n   price DECIMAL(8,2) path ''$.price'' ) \n) AS jt;\n+--------+-------+---------+\n| name   | color | price   |\n+--------+-------+---------+\n| Laptop | black | 1000.00 |\n| Jeans  | blue  |    NULL |\n+--------+-------+---------+\n`\n\nThe on_empty and on_error clauses specify the actions to be performed when the value was not found or there was an error condition. See the ON EMPTY and ON ERROR clauses section for details.\n\nORDINALITY Columns\n\n`sql\nname FOR ORDINALITY\n`\n\nCounts the rows, starting from 1.\n\nExample:\n\n`sql\nset @json=''\n[\n  {"name":"Laptop", "color":"black"},\n  {"name":"Jeans",  "color":"blue"}\n]'';\n\nselect  from json_table(@json, ''$[]'' \n  columns(\n   id for ordinality, \n   name  varchar(10) path ''$.name'')\n) as jt;\n+------+--------+\n| id   | name   |\n+------+--------+\n|    1 | Laptop |\n|    2 | Jeans  |\n+------+--------+\n`\n\nEXISTS PATH Columns\n\n`sql\nname type EXISTS PATH path_str\n`\n\nChecks whether the node pointed to by value_path exists. The value_path is evaluated using the current row source node as the context node.\n\n`sql\nset @json=''\n[\n  {"name":"Laptop", "color":"black", "price":1000},\n  {"name":"Jeans",  "color":"blue"}\n]'';\n\nselect  from json_table(@json, ''$[]'' \n  columns(\n   name  varchar(10) path ''$.name'',\n   has_price integer exists path ''$.price'')\n) as jt;\n+--------+-----------+\n| name   | has_price |\n+--------+-----------+\n| Laptop |         1 |\n| Jeans  |         0 |\n+--------+-----------+\n`\n\nNESTED PATHs\n\nNESTED PATH converts nested JSON structures into multiple rows.\n\n`sql\nNESTED PATH path COLUMNS (column_list)\n`\n\nIt finds the sequence of JSON nodes pointed to by path and uses it to produce rows. For each found node, a row is generated with column values as specified by the NESTED PATH''s COLUMNS clause. If path finds no nodes, only one row is generated with all columns having NULL values.\n\nFor example, consider a JSON document that contains an array of items, and each item, in turn, is expected to have an array of its available sizes:\n\n`json\nSET @json=''\n[\n  {"name":"Jeans",  "sizes": [32, 34, 36]},\n  {"name":"T-Shirt", "sizes":["Medium", "Large"]},\n  {"name":"Cellphone"}\n]'';\n`\n\nNESTED PATH allows one to produce a separate row for each size each item has:\n\n`sql\nselect  from json_table(@json, ''$[]'' \n  columns(\n    name  varchar(10) path ''$.name'', \n    nested path ''$.sizes[]'' columns (\n      size varchar(32) path ''$''\n    )\n  )\n) as jt;\n+-----------+--------+\n| name      | size   |\n+-----------+--------+\n| Jeans     | 32     |\n| Jeans     | 34     |\n| Jeans     | 36     |\n| T-Shirt   | Medium |\n| T-Shirt   | Large  |\n| Cellphone | NULL   |\n+-----------+--------+\n`\n\nNESTED PATH clauses can be nested within one another. They can also be located next to each other. In that case, the nested path clauses will produce records one at a time. The ones that are not producing records will have all columns set to NULL.\n\nExample:\n\n`sql\nset @json=''\n[\n  {"name":"Jeans",  "sizes": [32, 34, 36], "colors":["black", "blue"]}\n]'';\n\nselect  from json_table(@json, ''$[]'' \n  columns(\n    name  varchar(10) path ''$.name'', \n    nested path ''$.sizes[]'' columns (\n      size varchar(32) path ''$''\n    ),\n    nested path ''$.colors[]'' columns (\n      color varchar(32) path ''$''\n    )\n  )\n) as jt;\n\n+-------+------+-------+\n| name  | size | color |\n+-------+------+-------+\n| Jeans | 32   | NULL  |\n| Jeans | 34   | NULL  |\n| Jeans | 36   | NULL  |\n| Jeans | NULL | black |\n| Jeans | NULL | blue  |\n+-------+------+-------+\n`\n\nON EMPTY and ON ERROR Clauses\n\nThe ON EMPTY clause specifies what will be done when the element specified by the search path is missing in the JSON document.\n\n`sql\non_empty:\n    {NULL | DEFAULT string | ERROR} ON EMPTY\n`\n\nWhen ON EMPTY clause is not present, NULL ON EMPTY is implied.\n\n`sql\non_error:\n    {NULL | DEFAULT string | ERROR} ON ERROR\n`\n\nThe ON ERROR clause specifies what should be done if a JSON structure error occurs when trying to extract the value pointed to by the path expression. A JSON structure error here occurs only when one attempts to convert a JSON non-scalar (array or object) into a scalar value. When the ON ERROR clause is not present, NULL ON ERROR is implied.\n\nNote: A datatype conversion error (e.g. attempt to store a non-integer value into an integer field, or a varchar column being truncated) is not considered a JSON error and so will not trigger the ON ERROR behavior. It will produce warnings, in the same way as CAST(value AS datatype) would.\n\nReplication\n\nIn the current code, evaluation of JSON_TABLE is deterministic, that is, for a given input string JSON_TABLE will always produce the same set of rows in the same order. However, one can think of JSON documents that one can consider identical which will produce different output. In order to be future-proof and withstand changes like\n\n sorting JSON object members by name (like MySQL does);\n changing the way duplicate object members are handled the function is marked as unsafe for statement-based replication.\n\nExtracting a Subdocument into a Column\n\n`sql\nSELECT  FROM JSON_TABLE(''{"foo": [1,2,3,4]}'',''$'' columns( jscol json path ''$.foo'') ) AS T;\n+-----------+\n| jscol     |\n+-----------+\n| [1,2,3,4] |\n+-----------+\n`\n\nJSON_TABLE does not allow to extract a JSON "subdocument" into a JSON column.\n\n`sql\nSELECT * FROM JSON_TABLE(''{"foo": [1,2,3,4]}'',''$'' columns( jscol json path ''$.foo'') ) AS T;\n+-------+\n| jscol |\n+-------+\n| NULL  |\n+-------+\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_table', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_table');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (391, 35, 'JSON\\_TYPE', '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 null.\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| Return type | Value                                                                                         | Example                   |\n| ----------- | --------------------------------------------------------------------------------------------- | ------------------------- |\n| ARRAY       | JSON array                                                                                    | \\[1, 2, {"key": "value"}] |\n| OBJECT      | JSON object                                                                                   | {"key":"value"}           |\n| BOOLEAN     | JSON true/false literals                                                                      | true, false               |\n| DOUBLE      | A number with at least one floating point decimal.                                            | 1.2                       |\n| INTEGER     | A number without a floating point decimal.                                                    | 1                         |\n| NULL        | JSON null literal (this is returned as a string, not to be confused with the SQL NULL value!) | null                      |\n| STRING      | JSON String                                                                                   | "a sample string"         |\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/docs/server/reference/sql-functions/special-functions/json-functions/json_type', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_type');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (392, 35, 'JSON\\_UNQUOTE', '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 is 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 backslash is ignored, but the escape sequences in the table below are recognised by MariaDB, unless the SQL Mode is set to NO_BACKSLASH_ESCAPES .\n\n| Escape sequence | Character                          |\n| --------------- | ---------------------------------- |\n| "               | Double quote (")                   |\n| \\b              | Backslash                          |\n| \\f              | Formfeed                           |\n| \\n              | Newline (linefeed)                 |\n| \\r              | Carriage return                    |\n| \\t              | Tab                                |\n| \\\\              | Backslash ()                       |\n| \\uXXXX          | UTF-8 bytes for Unicode value XXXX |\n\nExamples\n--------\n\nSELECT JSON_UNQUOTE(''"Monty"'');\n+-------------------------+\n| JSON_UNQUOTE(''"Monty"'') |\n+-------------------------+\n| Monty                   |\n+-------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_unquote', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_unquote');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (393, 35, 'JSON\\_VALID', 'Syntax\n------\n\nJSON_VALID(value)\n\nDescription\n-----------\n\nIndicates whether the given value is a valid JSON document or not. Returns 1 if valid, 0 if not, and NULL if the argument is NULL.\n\nThe JSON_VALID function is automatically used as a CHECK constraint for the JSON data type alias in order to ensure that a valid json document is inserted.\n\nThe JSON_VALID function is not automatically used as a CHECK constraint for the JSON data type alias.\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/docs/server/reference/sql-functions/special-functions/json-functions/json_valid', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_valid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (394, 35, 'JSON\\_VALUE', '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 if 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\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_value', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_value');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (395, 35, 'JSONPath Expressions', 'Description\n-----------\n\nA number of JSON functions accept JSON Path expressions. MariaDB defines this path as follows:\n\nJSON Path Syntax\n\n``sql\npath : [''lax''] ''$'' [step]\n`\n\nThe path starts with an optional _path mode_. At the moment, MariaDB supports only the "lax" mode, which is also the mode that is used when it is not explicitly specified.\n\nThe $ symbol represents the context item. The search always starts from the context 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 JSON 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\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 name that''s not a valid identifier (that is, has space, dot, and/or other characters).\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 selected.\n\nArray Element Selector\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 zero.\n [] selects all elements in the array.\n\nIf the current item is an object (instead of an array), nothing will be selected.\n\nJSON path supports negative indexes in an array, ''last'' keyword and range notation (''to'' keyword) for accessing array elements. Negative indexes start 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\n`sql\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`\n\nJSON path does not support negative indexes in an array.\n\nThis produces output for first index of eighth from last element of a two dimensional array.\n\nNote: In range notation, when M > N ( when M,N are greater than or equal to 0) or (size of array - M or size of array - N when M, N are less than 0), then it is treated as an impossible range and NULL is returned.\n\n`sql\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`\n\nWildcard\n\nThe wildcard step, , recursively selects all child elements of the current element. Both array elements and object members are selected.\n\nThe wildcard step must not be the last step in the JSONPath expression. It must be followed by an array or object member selector step.\n\nFor example, this query selects all object members named price in the document:\n\n`sql\nSELECT json_extract(@json_doc, ''$.price'');\n`\n\nThis query, however, selects the second element in each of the arrays present in the document:\n\n`sql\nSELECT json_extract(@json_doc, ''$[2]'');\n`\n\nCompatibility\n\nMariaDB''s JSONPath syntax supports a subset of JSON Path''s definition in the SQL Standard. The most notable things not supported are the strict mode and filters.\n\nMariaDB''s JSONPath is close to MySQL''s JSONPath. The wildcard step (  ) is a non-standard extension that has the same meaning as in MySQL. The difference between MariaDB and MySQL''s JSONPath is: MySQL doesn''t allow one to specify the mode explicitly (but uses lax` mode implicitly).\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/jsonpath-expressions', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/jsonpath-expressions');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (396, 35, 'CUME\\_DIST', '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 given row. The following formula is used to calculate the value:\n\n``sql\n(number of rows <= current row) / (total rows)\n``\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/docs/server/reference/sql-functions/special-functions/window-functions/cume_dist', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/cume_dist');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (397, 35, 'DENSE\\_RANK', '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, starting at one and following the ORDER BY sequence of the window function, with identical values receiving the same result. Unlike the RANK() function, there are no skipped values if the preceding results are identical. It is also similar to the ROW_NUMBER() function except that in that function, identical values will receive a different row number for each result.\n\nExamples\n--------\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/docs/server/reference/sql-functions/special-functions/window-functions/dense_rank', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/dense_rank');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (398, 35, 'FIRST\\_VALUE', '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 result 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\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/first_value', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/first_value');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (399, 35, 'LAG', '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 clause without the need for a self-join. The specific row is determined by the _offset_ (default _1_), which specifies the number of rows behind the current row to 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, 3), 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/docs/server/reference/sql-functions/special-functions/window-functions/lag', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/lag');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (400, 35, 'LEAD', '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 without the need for a self-join. The specific row is determined by the _offset_ (default _1_), which specifies the number of rows ahead the current row to 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, 3), 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/docs/server/reference/sql-functions/special-functions/window-functions/lead', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/lead');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (401, 35, 'MEDIAN', 'Syntax\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 values.\n\nIt is a specific case of PERCENTILE_CONT, with an argument of 0.5 and the ORDER BY column the one in MEDIAN''s argument.\n\n``sql\nMEDIAN(<median-arg>) OVER ( [ PARTITION BY partition_expression] )\n`\n\nIs equivalent to:\n\n`sql\nPERCENTILE_CONT(0.5) WITHIN \n  GROUP (ORDER BY <median-arg>) OVER ( [ PARTITION BY partition_expression ])\n``\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/docs/server/reference/sql-functions/special-functions/window-functions/median', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/median');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (402, 35, 'NTH\\_VALUE', '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 the window frame, starting from 1, or NULL if the row does not exist.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/nth_value', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/nth_value');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (403, 35, 'NTILE', '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 given row falls into. The number of groups is specified in the argument (_expr_), starting at one. Ordered rows in the partition are divided into the specified 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/docs/server/reference/sql-functions/special-functions/window-functions/ntile', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/ntile');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (404, 35, 'PERCENT\\_RANK', '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 a given row. The following formula is used to calculate the percent rank:\n\n``sql\n(rank - 1) / (number of rows in the window or partition - 1)\n``\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/docs/server/reference/sql-functions/special-functions/window-functions/percent_rank', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/percent_rank');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (405, 35, 'PERCENTILE\\_CONT', 'Description\n-----------\n\nPERCENTILE_CONT() (standing for continuous percentile) is a window function which returns a value which corresponds to the given fraction in the sort order. 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 FRN as FRN=floor(RN) and CRN as 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 PERCENTILE_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/docs/server/reference/sql-functions/special-functions/window-functions/percentile_cont', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/percentile_cont');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (406, 35, 'PERCENTILE\\_DISC', 'Description\n-----------\n\nPERCENTILE_DISC() (standing for discrete percentile) is a window function which returns the first value in the set whose ordered position is the same or more 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 first row with CUME_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/docs/server/reference/sql-functions/special-functions/window-functions/percentile_disc', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/percentile_disc');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (407, 35, 'RANK', '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 at one and following the ORDER BY sequence of the window function, with identical values receiving the same result. It is similar to the ROW_NUMBER() function except that in that function, identical values will receive a different row number for each result.\n\nExamples\n--------\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/docs/server/reference/sql-functions/special-functions/window-functions/rank', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/rank');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (408, 35, 'ROW\\_NUMBER', '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, starting at one and following the ORDER BY sequence of the window function, with identical values receiving different row numbers. It is similar to the RANK() and DENSE_RANK() functions except that in that function, identical values will receive the same rank for each result.\n\nExamples\n--------\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/docs/server/reference/sql-functions/special-functions/window-functions/row_number', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/row_number');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (409, 35, 'Window Frames', 'Description\n-----------\n\nBasic Syntax\n\n``sql\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`\n\nHow Window Frames Work\n\nA basic overview of window functions is described in Window Functions Overview. Window frames define which rows contribute to the current result.\n\nWindow frames are used by aggregate window functions. They are defined by the frame clause inside OVER (...).\n\nOVER () uses the whole result set.\n\nFor aggregate window functions, OVER (ORDER BY ...) uses a running frame by default. In MariaDB, that default is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.\n\nFrame Bound Types\n\nCommon frame bounds include:\n\n All rows before the current row (UNBOUNDED PRECEDING), for example RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW .\n All rows after the current row (UNBOUNDED FOLLOWING), for example RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING .\n A set number of rows before the current row (expr PRECEDING), for example RANGE BETWEEN 6 PRECEDING AND CURRENT ROW .\n A set number of rows after the current row (expr FOLLOWING), for example RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING .\n* A specified number of rows both before and after the current row, for example RANGE BETWEEN 6 PRECEDING AND 3 FOLLOWING .\n\nROWS vs RANGE\n\nROWS counts physical rows. RANGE groups peer rows that share the same ORDER BY value.\n\nUse ROWS when you want strict row-by-row stepping. Use RANGE when tied sort values should be treated as one peer group.\n\nAggregate Functions Using Frames\n\nSee list here.\n\nExamples\n--------\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\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/window-frames', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/window-frames');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (410, 35, 'ColumnStore Window Functions', 'Description\n-----------\n\nIntroduction\n\nMariaDB ColumnStore provides support for window functions broadly following the SQL 2003 specification. A window function allows for calculations relating to a window of data surrounding the current row in a result set. This capability provides for simplified queries in support of common business questions such as cumulative totals, rolling averages, and top 10 lists.\n\nAggregate functions are utilized for window functions however differ in behavior from a group by query because the rows remain ungrouped. This provides 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 specific column, for example a Partition can be created over a time period such as a quarter or lookup values.\n The Frame for each row is a subset of the row''s Partition. The frame typically is dynamic allowing for a sliding frame of rows within the Partition. The Frame determines the range of rows for the windowing function. A Frame could be defined as the last X rows and next Y rows all the way up to the entire Partition.\n\nWindow functions are applied after joins, group by, and having clauses are calculated.\n\nSyntax\n\nA window function is applied in the select clause using the following syntax:\n\n``sql\nfunction_name ([expression [, expression ... ]]) OVER ( window_definition )\n`\n\nwhere _window_definition_ is defined as:\n\n`sql\n[ PARTITION BY expression [, ...] ]\n[ ORDER BY expression [ ASC | DESC ] [ NULLS { FIRST | LAST } ] [, ...] ]\n[ frame_clause ]\n`\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 clauses 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 be available from the query result set.\n If there is no PARTITION BY clause, all rows of the result set define the group.\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 window function expression.\n The order by columns do not need to be in the select list but need to be available 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 last in the ordering sequence. NULLS_FIRST is the default for ASC order, and NULLS_LAST is the default for DESC order.\n\nand the optional _frame_clause_ is defined as:\n\n`sql\n{ RANGE | ROWS } frame_start\n{ RANGE | ROWS } BETWEEN frame_start AND frame_end\n`\n\nand the optional _frame_start_ and _frame_end_ are defined as (value being a numeric expression):\n\n`sql\nUNBOUNDED PRECEDING\nvalue PRECEDING\nCURRENT ROW\nvalue FOLLOWING\nUNBOUNDED FOLLOWING\n`\n\nRANGE/ROWS:\n\n Defines the windowing clause for calculating the set of rows that the function 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 a constant or expression evaluating to a positive numeric value.\n RANGE specifies the window as a logical offset. If the expression evaluates to a numeric value then the ORDER BY expression must be a numeric or DATE type. If the expression evaluates to an interval value then the ORDER BY expression must be a DATE data type.\n UNBOUNDED PRECEDING indicates the window starts at the first row of the partition.\n UNBOUNDED FOLLOWING indicates the window ends at the last row of the partition.\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| Function               | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |\n| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| AVG()                  | The average of all input values.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |\n| COUNT()                | Number of input rows.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |\n| CUME_DIST()           | Calculates the cumulative distribution, or relative rank, of the current row to other rows in the same partition. Number of peer or preceding rows / number of rows in partition.                                                                                                                                                                                                                                                                                                                                                  |\n| DENSE_RANK()          | Ranks items in a group leaving no gaps in ranking sequence when there are ties.                                                                                                                                                                                                                                                                                                                                                                                                                                                    |\n| FIRST_VALUE()         | The value evaluated at the row that is the first row of the window frame (counting from 1); null if no such row.                                                                                                                                                                                                                                                                                                                                                                                                                   |\n| LAG()                  | The value evaluated at the row that is offset rows before the current row within the partition; if there is no such row, instead return default. Both offset and default are evaluated with respect to the current row. If omitted, offset defaults to 1 and default to null. LAG provides access to more than one row of a table at the same time without a self-join. Given a series of rows returned from a query and a position of the cursor, LAG provides access to a row at a given physical offset prior to that position. |\n| LAST_VALUE()          | The value evaluated at the row that is the last row of the window frame (counting from 1); null if no such row.                                                                                                                                                                                                                                                                                                                                                                                                                    |\n| LEAD()                 | Provides access to a row at a given physical offset beyond that position. Returns value evaluated at the row that is offset rows after the current row within the partition; if there is no such row, instead return default. Both offset and default are evaluated with respect to the current row. If omitted, offset defaults to 1 and default to null.                                                                                                                                                                         |\n| MAX()                  | Maximum value of expression across all input values.                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| MEDIAN()               | An inverse distribution function that assumes a continuous distribution model. It takes a numeric or datetime value and returns the middle value or an interpolated value that would be the middle value once the values are sorted. Nulls are ignored in the calculation.                                                                                                                                                                                                                                                         |\n| MIN()                  | Minimum value of expression across all input values.                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| NTH_VALUE()           | The value evaluated at the row that is the nth row of the window frame (counting from 1); null if no such row.                                                                                                                                                                                                                                                                                                                                                                                                                     |\n| NTILE()                | Divides an ordered data set into a number of buckets indicated by expr and assigns the appropriate bucket number to each row. The buckets are numbered 1 through expr. The expr value must resolve to a positive constant for each partition. Integer ranging from 1 to the argument value, dividing the partition as equally as possible.                                                                                                                                                                                         |\n| PERCENT_RANK()        | relative rank of the current row: (rank - 1) / (total rows - 1).                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |\n| PERCENTILE_CONT()     | An inverse distribution function that assumes a continuous distribution model. It takes a percentile value and a sort specification, and returns an interpolated value that would fall into that percentile value with respect to the sort specification. Nulls are ignored in the calculation.                                                                                                                                                                                                                                    |\n| PERCENTILE_DISC()     | An inverse distribution function that assumes a discrete distribution model. It takes a percentile value and a sort specification and returns an element from the set. Nulls are ignored in the calculation.                                                                                                                                                                                                                                                                                                                       |\n| RANK()                 | rank of the current row with gaps; same as row_number of its first peer.                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n| ROW_NUMBER()          | number of the current row within its partition, counting from 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |\n| STDDEV() STDDEV_POP() | Computes the population standard deviation a\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/window-functions-columnstore-window-functions');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (411, 35, 'Window Functions Overview', 'Description\n-----------\n\nWindow Functions\n\nWindow functions calculate across related rows without collapsing them. Unlike GROUP BY, they return one result for each input row.\n\nWhen to Use Window Functions\n\nUse window functions when you need to:\n\n Rank rows inside a group.\n Calculate running totals or moving averages.\n Compare a row with earlier or later rows.\n Return the top _N_ rows per group.\n\nBasic Syntax\n\n``sql\nwindow_function(expr) OVER (\n  [PARTITION BY expr [, ...]]\n  [ORDER BY expr [ASC | DESC] [, ...]]\n  [{ROWS | RANGE} frame_clause]\n)\n\nframe_clause:\n  {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`\n\nYou can also define a named window and reuse it:\n\n`sql\nSELECT\n  SUM(score) OVER w AS running_total,\n  AVG(score) OVER w AS running_avg\nFROM student\nWINDOW w AS (\n  ORDER BY score\n  ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n);\n`\n\nWindow Functions vs GROUP BY\n\nUse GROUP BY when you want one output row per group.\n\nUse a window function when you want to keep the original rows and add per-group or per-sequence calculations beside them.\n\n`sql\nSELECT test, AVG(score)\nFROM student\nGROUP BY test;\n`\n\nThis returns one row per test.\n\n`sql\nSELECT\n  name,\n  test,\n  score,\n  AVG(score) OVER (PARTITION BY test) AS avg_by_test\nFROM student;\n`\n\nThis returns every row, plus the average for that row''s test.\n\nHow OVER Works\n\nPARTITION BY\n\nPARTITION BY starts a new calculation for each group.\n\nORDER BY\n\nORDER BY defines the row sequence inside each partition.\n\nFrame\n\nThe frame controls which rows contribute to the current result. Aggregate window functions use frames. Ranking functions such as ROW_NUMBER() and RANK() do not.\n\nOVER () uses the whole result set.\n\nFor aggregate window functions, OVER (ORDER BY ...) uses a running frame by default. In MariaDB, that default is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.\n\nROWS vs RANGE\n\nROWS counts physical rows. RANGE groups peer rows that share the same ORDER BY value.\n\nUse ROWS when you need strict row-by-row stepping. Use RANGE when ties should be treated as one peer group.\n\n`sql\nCREATE TABLE t (score INT);\nINSERT INTO t VALUES (10), (10), (20);\n\nSELECT\n  score,\n  SUM(score) OVER (\n    ORDER BY score\n    ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n  ) AS rows_sum,\n  SUM(score) OVER (\n    ORDER BY score\n    RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n  ) AS range_sum\nFROM t;\n`\n\nThis produces different results for the duplicate 10 values:\n\n`\n+-------+----------+-----------+\n| score | rows_sum | range_sum |\n+-------+----------+-----------+\n|    10 |       10 |        20 |\n|    10 |       20 |        20 |\n|    20 |       40 |        40 |\n+-------+----------+-----------+\n`\n\nSupported Functions\n\nDedicated window functions include CUME_DIST, DENSE_RANK, FIRST_VALUE, LAG, LAST_VALUE, LEAD, MEDIAN, NTH_VALUE, NTILE, PERCENTILE_CONT, PERCENTILE_DISC, PERCENT_RANK, RANK, and ROW_NUMBER.\n\nAggregate functions that also work with OVER (...) include AVG, BIT_AND, BIT_OR, BIT_XOR, COUNT, MAX, MIN, STD, STDDEV, STDDEV_POP, STDDEV_SAMP, SUM, VAR_POP, VAR_SAMP, and VARIANCE.\n\nAggregate window functions do not support DISTINCT.\n\nAggregate Functions as Window Functions\n\nIt is possible to use aggregate functions as window functions. An aggregate function used as a window function must have the OVER clause. For example, here''s COUNT() used as a window function:\n\n`sql\nSELECT COUNT() OVER (ORDER BY column) FROM table;\n`\n\nCommon Pitfalls\n\n You cannot reference a window function in WHERE.\n Compute the window result in a subquery or CTE first.\n MariaDB does not support GROUPS frames.\n MariaDB does not support frame exclusion.\n MariaDB does not support explicit NULLS FIRST or NULLS LAST.\n RANGE frames do not support DATE or DATETIME arithmetic.\n\nWindow functions are evaluated after WHERE, GROUP BY, and HAVING. Filter the computed result in an outer query or CTE.\n\nOptimization\n\nWindow functions often need sorted input. Query shape can decide whether MariaDB can reuse an existing order or must sort again.\n\nGROUP BY Comes First\n\nIf a query uses both GROUP BY and window functions, MariaDB executes the grouping step first. The window step runs on the grouped result.\n\nThis affects index usage. An index that helps the base table scan does not automatically avoid later sorting for the window stage.\n\nWhen tuning this pattern, optimize the GROUP BY step first. Then check whether the window step still needs its own sort.\n\nSort Reuse Depends on Sort Keys\n\nIf the GROUP BY definition and the window''s PARTITION BY and ORDER BY definition use different sort keys, MariaDB usually needs another sort pass before evaluating the window functions.\n\nFor example, this shape can require an extra sort:\n\n`sql\nSELECT\n  dept,\n  month,\n  SUM(sales) AS monthly_sales,\n  ROW_NUMBER() OVER (\n    PARTITION BY dept\n    ORDER BY month\n  ) AS row_num\nFROM revenue\nGROUP BY month, dept;\n`\n\nThe grouped result is ordered by month, dept. The window step needs dept, month. Those orders do not match.\n\nMultiple Window Functions Can Share One Sort\n\nMultiple window functions can share the same sort pass when they use the same PARTITION BY and ORDER BY clause.\n\n`sql\nSELECT\n  dept,\n  month,\n  sales,\n  ROW_NUMBER() OVER (\n    PARTITION BY dept\n    ORDER BY month\n  ) AS row_num,\n  SUM(sales) OVER (\n    PARTITION BY dept\n    ORDER BY month\n    ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n  ) AS running_sales\nFROM revenue;\n`\n\nBoth window functions use the same partitioning and ordering. MariaDB can reuse the same sorted stream for both.\n\nPractical Tuning Tips\n\n Expect GROUP BY to shape the input seen by window functions.\n Align GROUP BY keys with the window sort keys when possible.\n Reuse the same PARTITION BY and ORDER BY` across multiple window functions.\n* Check the execution plan to see whether an extra sort is still present.\n\nExamples\n--------\n\nCREATE TABLE student (\n  name CHAR(10),\n  test CHAR(10),\n  score TINYINT\n);\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\nURL: https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/window-functions-overview', '', 'https://mariadb.com/docs/server/reference/sql-functions/special-functions/window-functions/window-functions-overview');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (412, 37, 'ASCII', 'Syntax\n------\n\nASCII(str)\n\nDescription\n-----------\n\nReturns the numeric ASCII value of the leftmost character of the string argument. Returns 0 if the given string is empty and NULL if it is NULL.\n\nASCII() works for 8-bit characters.\n\nExamples\n--------\n\nSELECT ASCII(9);\n+----------+\n| ASCII(9) |\n+----------+\n|       57 |\n+----------+\n\nSELECT ASCII(''9'');\n+------------+\n| ASCII(''9'') |\n+------------+\n|         57 |\n+------------+\n\nSELECT ASCII(''abc'');\n+--------------+\n| ASCII(''abc'') |\n+--------------+\n|           97 |\n+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/ascii', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/ascii');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (413, 37, 'BIN', 'Syntax\n------\n\nBIN(N)\n\nDescription\n-----------\n\nReturns a string representation of the binary value of the given longlong (that is, BIGINT) number. This is equivalent to CONV(N,10,2). The argument should be positive. If it is a FLOAT, it will be truncated. Returns NULL if the argument is NULL.\n\nExamples\n--------\n\nSELECT BIN(12);\n+---------+\n| BIN(12) |\n+---------+\n| 1100    |\n+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/bin', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/bin');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (414, 37, 'BINARY Operator', 'Syntax\n------\n\nBINARY\n\nDescription\n-----------\n\nThe BINARY operator casts the string following it to a binary string. This is an easy way to force a column comparison to be done byte by byte rather than character by character. This causes the comparison to be case sensitive even if the column isn''t defined as BINARY or BLOB.\n\nBINARY also causes trailing spaces to be significant.\n\nExamples\n--------\n\nSELECT ''a'' = ''A'';\n+-----------+\n| ''a'' = ''A'' |\n+-----------+\n|         1 |\n+-----------+\n\nSELECT BINARY ''a'' = ''A'';\n+------------------+\n| BINARY ''a'' = ''A'' |\n+------------------+\n|                0 |\n+------------------+\n\nSELECT ''a'' = ''a '';\n+------------+\n| ''a'' = ''a '' |\n+------------+\n|          1 |\n+------------+\n\nSELECT BINARY ''a'' = ''a '';\n+-------------------+\n| BINARY ''a'' = ''a '' |\n+-------------------+\n|                 0 |\n+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/binary-operator', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/binary-operator');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (415, 37, 'BIT\\_LENGTH', 'Syntax\n------\n\nBIT_LENGTH(str)\n\nDescription\n-----------\n\nReturns the length of the given string argument in bits. If the argument is not a string, it will be converted to string. If the argument is NULL, it returns NULL.\n\nExamples\n--------\n\nSELECT BIT_LENGTH(''text'');\n+--------------------+\n| BIT_LENGTH(''text'') |\n+--------------------+\n|                 32 |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/bit_length', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/bit_length');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (416, 37, 'CAST', 'Syntax\n------\n\nCAST(expr AS type)\n\nDescription\n-----------\n\nThe CAST() function takes a value of one data type and produces a value of another data type, similar to the CONVERT() function.\n\nThe type can be one of the following values:\n\n BINARY\n CHAR\n DATE\n DATETIME\n DECIMAL\n DOUBLE\n FLOAT\n INTEGER (short for SIGNED INTEGER )\n [SIGNED \\[INTEGER\\]](../../data-types/numeric-data-types/integer.md)\n [UNSIGNED \\[INTEGER\\]](../../data-types/numeric-data-types/integer.md)\n TIME\n VARCHAR\n* XMLTYPE (Available starting with MariaDB 12.3)\n\nThe main difference between CAST and CONVERT() is that CONVERT(expr,type) is ODBC syntax, while CAST(expr as type) and CONVERT(... USING ...) are SQL92 syntax.\n\nTo cast a value to a string data type while specifying the character set, use this extended syntax:\n\n``sql\n CAST(expr AS CHAR CHARACTER SET name)\n`\n\nSee the examples for casting to character sets.\n\nUsing an introducer like _utf8mb4''text'' is often more efficient than CAST(''text'' AS CHAR CHARACTER SET utf8mb4), but CAST is necessary when converting data types (like numbers to strings) into a specific encoding. See this example, too.\n\nYou can use the CAST() function with the INTERVAL` keyword.\n\nThis introduced an incompatibility with previous versions of MariaDB, and all versions of MySQL (see the example below).\n\nExamples\n--------\n\nSELECT CAST("abc" AS BINARY);\nSELECT CAST("1" AS UNSIGNED INTEGER);\nSELECT CAST(123 AS CHAR CHARACTER SET utf8)\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/cast', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/cast');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (417, 37, 'CHAR Function', 'Syntax\n------\n\nCHAR(N,... [USING charset_name])\n\nDescription\n-----------\n\nCHAR() interprets each argument as an INT and returns a string consisting of the characters given by the code values of those integers. NULL values are skipped. By default, CHAR() returns a binary string. To produce a string in a given character set, use the optional USING clause:\n\n``sql\nSELECT CHARSET(CHAR(0x65)), CHARSET(CHAR(0x65 USING utf8));\n+---------------------+--------------------------------+\n| CHARSET(CHAR(0x65)) | CHARSET(CHAR(0x65 USING utf8)) |\n+---------------------+--------------------------------+\n| binary              | utf8                           |\n+---------------------+--------------------------------+\n`\n\nIf USING is given and the result string is illegal for the given character set, a warning is issued. Also, if strict SQL mode is enabled, the result from CHAR() becomes NULL`.\n\nExamples\n--------\n\nSELECT CHAR(77,97,114,''105'',97,''68'',66);\n+----------------------------------+\n| CHAR(77,97,114,''105'',97,''68'',66) |\n+----------------------------------+\n| MariaDB                          |\n+----------------------------------+\n\nSELECT CHAR(77,77.3,''77.3'');\n+----------------------+\n| CHAR(77,77.3,''77.3'') |\n+----------------------+\n| MMM                  |\n+----------------------+\n1 row in set, 1 warning (0.00 sec)\n\nWarning (Code 1292): Truncated incorrect INTEGER value: ''77.3''\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/char-function', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/char-function');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (418, 37, 'CHAR\\_LENGTH', 'Syntax\n------\n\nCHAR_LENGTH(str)\nCHARACTER_LENGTH(str)\n\nDescription\n-----------\n\nReturns the length of the given string argument, measured in characters. A multi-byte character counts as a single character. This means that for a string containing five two-byte characters, LENGTH() (or OCTET_LENGTH() in Oracle mode) returns 10, whereas CHAR_LENGTH() returns 5. If the argument is NULL, it returns NULL.\n\nIf the argument is not a string value, it is converted into a string.\n\nIt is synonymous with the CHARACTER_LENGTH() function.\n\nExamples\n--------\n\nSELECT CHAR_LENGTH(''MariaDB'');\n+------------------------+\n| CHAR_LENGTH(''MariaDB'') |\n+------------------------+\n|                      7 |\n+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/char_length', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/char_length');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (419, 37, 'CHARACTER\\_LENGTH', 'Syntax\n------\n\nCHARACTER_LENGTH(str)\n\nDescription\n-----------\n\nCHARACTER_LENGTH() is a synonym for CHAR_LENGTH().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/character_length', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/character_length');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (420, 37, 'CHR', 'Syntax\n------\n\nCHR(N)\n\nDescription\n-----------\n\nCHR() interprets each argument N as an integer and returns a VARCHAR(1) string consisting of the character given by the code values of the integer. The character set and collation of the string are set according to the values of the character_set_database and collation_database system variables.\n\nCHR() is similar to the CHAR() function, but only accepts a single argument.\n\nCHR() is available in all sql_modes.\n\nExamples\n--------\n\nSELECT CHR(67);\n+---------+\n| CHR(67) |\n+---------+\n| C       |\n+---------+\n\nSELECT CHR(''67'');\n+-----------+\n| CHR(''67'') |\n+-----------+\n| C         |\n+-----------+\n\nSELECT CHR(''C'');\n+----------+\n| CHR(''C'') |\n+----------+\n|          |\n+----------+\n1 row in set, 1 warning (0.000 sec)\n\nSHOW WARNINGS;\n+---------+------+----------------------------------------+\n| Level   | Code | Message                                |\n+---------+------+----------------------------------------+\n| Warning | 1292 | Truncated incorrect INTEGER value: ''C'' |\n+---------+------+----------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/chr', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/chr');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (421, 37, 'CONCAT', 'Syntax\n------\n\nCONCAT(str1,str2,...)\n\nDescription\n-----------\n\nReturns the string that results from concatenating the arguments. May have one or more arguments. If all arguments are non-binary strings, the result is a non-binary string. If the arguments include any binary strings, the result is a binary string. A numeric argument is converted to its equivalent binary string form; if you want to avoid that, you can use an explicit type cast, as in this example:\n\n``sql\nSELECT CONCAT(CAST(int_col AS CHAR), char_col);\n`\n\nCONCAT() returns NULL if any argument is NULL.\n\nA NULL parameter hides all information contained in other parameters from the result. Sometimes this is not desirable; to avoid this, you can:\n\n Use the CONCAT_WS() function with an empty separator, because that function is NULL-safe.\n Use IFNULL() to turn NULLs into empty strings.\n\nOracle Mode\n\nIn Oracle mode, CONCAT` ignores null.\n\nExamples\n--------\n\nSELECT CONCAT(''Ma'', ''ria'', ''DB'');\n+---------------------------+\n| CONCAT(''Ma'', ''ria'', ''DB'') |\n+---------------------------+\n| MariaDB                   |\n+---------------------------+\n\nSELECT CONCAT(''Ma'', ''ria'', NULL, ''DB'');\n+---------------------------------+\n| CONCAT(''Ma'', ''ria'', NULL, ''DB'') |\n+---------------------------------+\n| NULL                            |\n+---------------------------------+\n\nSELECT CONCAT(42.0);\n+--------------+\n| CONCAT(42.0) |\n+--------------+\n| 42.0         |\n+--------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/concat', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/concat');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (422, 37, 'CONCAT\\_WS', 'Syntax\n------\n\nCONCAT_WS(separator,str1,str2,...)\n\nDescription\n-----------\n\nCONCAT_WS() stands for Concatenate With Separator and is a special form of CONCAT(). The first argument is the separator for the rest of the arguments. The separator is added between the strings to be concatenated. The separator can be a string, as can the rest of the arguments.\n\nIf the separator is NULL, the result is NULL; all other NULL values are skipped. This makes CONCAT_WS() suitable when you want to concatenate some values and avoid losing all information if one of them is NULL.\n\nExamples\n--------\n\nSELECT CONCAT_WS('','',''First name'',''Second name'',''Last Name'');\n+-------------------------------------------------------+\n| CONCAT_WS('','',''First name'',''Second name'',''Last Name'') |\n+-------------------------------------------------------+\n| First name,Second name,Last Name                      |\n+-------------------------------------------------------+\n\nSELECT CONCAT_WS(''-'',''Floor'',NULL,''Room'');\n+------------------------------------+\n| CONCAT_WS(''-'',''Floor'',NULL,''Room'') |\n+------------------------------------+\n| Floor-Room                         |\n+------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/concat_ws', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/concat_ws');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (423, 37, 'CONVERT', 'Syntax\n------\n\nCONVERT(expr,type), CONVERT(expr USING transcoding_name)\n\nDescription\n-----------\n\nThe CONVERT() and CAST() functions take a value of one type and produce a value of another type.\n\nThe type can be one of the following values:\n\n BINARY\n CHAR\n DATE\n DATETIME\n \\[DECIMAL [(M\\[,D\\])](../../data-types/numeric-data-types/decimal.md)]\n DOUBLE\n FLOAT\n INTEGER\n   Short for SIGNED INTEGER\n SIGNED \\[INTEGER]\n UNSIGNED \\[INTEGER]\n TIME\n* VARCHAR (in Oracle mode)\n\nNote that in MariaDB, INT and INTEGER are the same thing.\n\nBINARY produces a string with the BINARY data type. If the optional length is given, BINARY(N) causes the cast to use no more than N bytes of the argument. Values shorter than the given number in bytes are padded with 0x00 bytes to make them equal the length value.\n\nCHAR(N) causes the cast to use no more than the number of characters given in the argument.\n\nThe main difference between the CAST() and CONVERT() is that CONVERT(expr,type) is ODBC syntax while CAST(expr as type) and CONVERT(... USING ...) are SQL92 syntax.\n\nCONVERT() with USING is used to convert data between different character sets. In MariaDB, transcoding names are the same as the corresponding character set names. For example, this statement converts the string ''abc'' in the default character set to the corresponding string in the utf8 character set:\n\n``sql\nSELECT CONVERT(''abc'' USING utf8);\n``\n\nExamples\n--------\n\nSELECT enum_col FROM tbl_name \nORDER BY CAST(enum_col AS CHAR);\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/convert', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/convert');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (424, 37, 'ELT', 'Syntax\n------\n\nELT(N, str1[, str2, str3,...])\n\nDescription\n-----------\n\nTakes a numeric argument and a series of string arguments. Returns the string that corresponds to the given numeric position. For instance, it returns str1 if N is 1, str2 if N is 2, and so on. If the numeric argument is a FLOAT, MariaDB rounds it to the nearest INTEGER. If the numeric argument is less than 1, greater than the total number of arguments, or not a number, ELT() returns NULL. It must have at least two arguments.\n\nIt is complementary to the FIELD() function.\n\nExamples\n--------\n\nSELECT ELT(1, ''ej'', ''Heja'', ''hej'', ''foo'');\n+------------------------------------+\n| ELT(1, ''ej'', ''Heja'', ''hej'', ''foo'') |\n+------------------------------------+\n| ej                                 |\n+------------------------------------+\n\nSELECT ELT(4, ''ej'', ''Heja'', ''hej'', ''foo'');\n+------------------------------------+\n| ELT(4, ''ej'', ''Heja'', ''hej'', ''foo'') |\n+------------------------------------+\n| foo                                |\n+------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/elt', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/elt');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (425, 37, 'EXPORT\\_SET', 'Syntax\n------\n\nEXPORT_SET(bits, on, off[, separator[, number_of_bits]])\n\nDescription\n-----------\n\nTakes a minimum of three arguments. Returns a string where each bit in the given bits argument is returned, with the string values given for on and off.\n\nBits are examined from right to left, (from low-order to high-order bits). Strings are added to the result from left to right, separated by a separator string (defaults as '',''). You can optionally limit the number of bits the EXPORT_SET() function examines using the number_of_bits option.\n\nIf any of the arguments are set as NULL, the function returns NULL.\n\nExamples\n--------\n\nSELECT EXPORT_SET(5,''Y'',''N'','','',4);\n+-----------------------------+\n| EXPORT_SET(5,''Y'',''N'','','',4) |\n+-----------------------------+\n| Y,N,Y,N                     |\n+-----------------------------+\n\nSELECT EXPORT_SET(6,''1'',''0'','','',10);\n+------------------------------+\n| EXPORT_SET(6,''1'',''0'','','',10) |\n+------------------------------+\n| 0,1,1,0,0,0,0,0,0,0          |\n+------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/export_set', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/export_set');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (426, 37, 'EXTRACTVALUE', 'Syntax\n------\n\nEXTRACTVALUE(xml_frag, xpath_expr)\n\nDescription\n-----------\n\nThe EXTRACTVALUE() function takes two string arguments: a fragment of XML markup and an XPath expression, (also known as a locator). It returns the text (That is, CDDATA), of the first text node which is a child of the element or elements matching the XPath expression.\n\nIn cases where a valid XPath expression does not match any text nodes in a valid XML fragment, (including the implicit /text() expression), the EXTRACTVALUE() function returns an empty string.\n\nInvalid Arguments\n\nWhen either the XML fragment or the XPath expression is NULL, the EXTRACTVALUE() function returns NULL. When the XML fragment is invalid, it raises a warning Code 1525:\n\n``sql\nWarning (Code 1525): Incorrect XML value: ''parse error at line 1 pos 11: unexpected END-OF-INPUT''\n`\n\nWhen the XPath value is invalid, it generates an Error 1105:\n\n`sql\nERROR 1105 (HY000): XPATH syntax error: '')''\n`\n\nExplicit text() Expressions\n\nThis function is the equivalent of performing a match using the XPath expression after appending /text(). In other words:\n\n`sql\nSELECT\n   EXTRACTVALUE(''<cases><case>example</case></cases>'', ''/cases/case'') \n    AS ''Base Example'',\n   EXTRACTVALUE(''<cases><case>example</case></cases>'', ''/cases/case/text()'') \n    AS ''text() Example'';\n+--------------+----------------+\n| Base Example | text() Example |\n+--------------+----------------+\n| example      | example        |\n+--------------+----------------+\n`\n\nCount Matches\n\nWhen EXTRACTVALUE() returns multiple matches, it returns the content of the first child text node of each matching element, in the matched order, as a single, space-delimited string.\n\nBy design, the EXTRACTVALUE() function makes no distinction between a match on an empty element and no match at all. If you need to determine whether no matching element was found in the XML fragment or if an element was found that contained no child text nodes, use the XPath count() function.\n\nFor instance, when looking for a value that exists, but contains no child text nodes, you would get a count of the number of matching instances:\n\n`sql\nSELECT\n   EXTRACTVALUE(''<cases><case/></cases>'', ''/cases/case'') \n    AS ''Empty Example'',\n   EXTRACTVALUE(''<cases><case/></cases>'', ''count(/cases/case)'') \n    AS ''count() Example'';\n+---------------+-----------------+\n| Empty Example | count() Example |\n+---------------+-----------------+\n|               |               1 |\n+---------------+-----------------+\n`\n\nAlternatively, when looking for a value that doesn''t exist, count() returns 0.\n\n`sql\nSELECT\n   EXTRACTVALUE(''<cases><case/></cases>'', ''/cases/person'') \n    AS ''No Match Example'',\n   EXTRACTVALUE(''<cases><case/></cases>'', ''count(/cases/person)'') \n    AS ''count() Example'';\n+------------------+-----------------+\n| No Match Example | count() Example |\n+------------------+-----------------+\n|                  |                0|\n+------------------+-----------------+\n`\n\nMatches\n\nImportant: The EXTRACTVALUE() function only returns CDDATA. It does not return tags that the element might contain or the text that these child elements contain.\n\n`sql\nSELECT \n  EXTRACTVALUE(''<cases><case>Person<email>x@example.com</email></case></cases>'', ''/cases'')\n   AS Case;\n+--------+\n| Case   |\n+--------+\n| Person |\n+--------+\n`\n\nNote, in the above example, while the XPath expression matches to the parent <case> instance, it does not return the contained <email>` tag or its content.\n\nExamples\n--------\n\nSELECT\n    ExtractValue(''<a>ccc<b>ddd</b></a>'', ''/a'')            AS val1,\n    ExtractValue(''<a>ccc<b>ddd</b></a>'', ''/a/b'')          AS val2,\n    ExtractValue(''<a>ccc<b>ddd</b></a>'', ''//b'')           AS val3,\n    ExtractValue(''<a>ccc<b>ddd</b></a>'', ''/b'')            AS val4,\n    ExtractValue(''<a>ccc<b>ddd</b><b>eee</b></a>'', ''//b'') AS val5;\n+------+------+------+------+---------+\n| val1 | val2 | val3 | val4 | val5    |\n+------+------+------+------+---------+\n| ccc  | ddd  | ddd  |      | ddd eee |\n+------+------+------+------+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/extractvalue', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/extractvalue');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (427, 37, 'FIELD', 'Syntax\n------\n\nFIELD(pattern, str1[,str2,...])\n\nDescription\n-----------\n\nReturns the index position of the string or number matching the given pattern. Returns 0 in the event that none of the arguments match the pattern. Raises an Error 1582 if not given at least two arguments.\n\nWhen all arguments given to the FIELD() function are strings, they are treated as case-insensitive. When all the arguments are numbers, they are treated as numbers. Otherwise, they are treated as doubles.\n\nIf the given pattern occurs more than once, the FIELD() function only returns the index of the first instance. If the given pattern is NULL, the function returns 0, as a NULL pattern always fails to match.\n\nThis function is complementary to the ELT() function.\n\nExamples\n--------\n\nSELECT FIELD(''ej'', ''Hej'', ''ej'', ''Heja'', ''hej'', ''foo'') \n   AS ''Field Results'';\n+---------------+\n| Field Results | \n+---------------+\n|             2 |\n+---------------+\n\nSELECT FIELD(''fo'', ''Hej'', ''ej'', ''Heja'', ''hej'', ''foo'')\n   AS ''Field Results'';\n+---------------+\n| Field Results | \n+---------------+\n|             0 |\n+---------------+\n\nSELECT FIELD(1, 2, 3, 4, 5, 1) AS ''Field Results'';\n+---------------+\n| Field Results |\n+---------------+\n|             5 |\n+---------------+\n\nSELECT FIELD(NULL, 2, 3) AS ''Field Results'';\n+---------------+\n| Field Results |\n+---------------+\n|             0 |\n+---------------+\n\nSELECT FIELD(''fail'') AS ''Field Results'';\nError 1582 (42000): Incorrect parameter count in call\nto native function ''field''\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/field', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/field');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (428, 37, 'FIND\\_IN\\_SET', 'Syntax\n------\n\nFIND_IN_SET(pattern, strlist)\n\nDescription\n-----------\n\nReturns the index position where the given pattern occurs in a string list. The first argument is the pattern you want to search for. The second argument is a string containing comma-separated variables. If the second argument is of the SET data-type, the function is optimized to use bit arithmetic.\n\nIf the pattern does not occur in the string list or if the string list is an empty string, the function returns 0. If either argument is NULL, the function returns NULL. The function does not return the correct result if the pattern contains a comma (",") character.\n\nExamples\n--------\n\nSELECT FIND_IN_SET(''b'',''a,b,c,d'') AS "Found Results";\n+---------------+\n| Found Results |\n+---------------+\n|             2 |\n+---------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/find_in_set', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/find_in_set');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (429, 37, 'FORMAT', 'Description\n-----------\n\nFormats the given number for display as a string, adding separators to appropriate position and rounding the results to the given decimal position. For instance, it would format 15233.345 to 15,233.35.\n\nIf the given decimal position is 0, it rounds to return no decimal point or fractional part. You can optionally specify a locale value to format numbers to the pattern appropriate for the given region.\n\nExamples\n--------\n\nSELECT FORMAT(1234567890.09876543210, 4) AS ''Format'';\n+--------------------+\n| Format             |\n+--------------------+\n| 1,234,567,890.0988 |\n+--------------------+\n\nSELECT FORMAT(1234567.89, 4) AS ''Format'';\n+----------------+\n| Format         |\n+----------------+\n| 1,234,567.8900 |\n+----------------+\n\nSELECT FORMAT(1234567.89, 0) AS ''Format'';\n+-----------+\n| Format    |\n+-----------+\n| 1,234,568 |\n+-----------+\n\n-- Format number to German number formatting\nSELECT FORMAT(123456789,2,''de_DE'') AS ''Format'';\n+----------------+\n| Format         |\n+----------------+\n| 123.456.789,00 |\n+----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/format', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/format');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (430, 37, 'FROM\\_BASE64', 'Syntax\n------\n\nFROM_BASE64(str)\n\nDescription\n-----------\n\nDecodes the given base-64 encode string, returning the result as a binary string. Returns NULL if the given string is NULL or if it''s invalid.\n\nIt is the reverse of the TO_BASE64 function.\n\nThere are numerous methods to base-64 encode a string. MariaDB uses the following:\n\n It encodes alphabet value 64 as ''+''.\n It encodes alphabet value 63 as ''/''.\n It codes output in groups of four printable characters. Each three byte of data encoded uses four characters. If the final group is incomplete, it pads the difference with the ''='' character.\n It divides long output, adding a new line very 76 characters.\n* In decoding, it recognizes and ignores newlines, carriage returns, tabs and space whitespace characters.\n\n``sql\nSELECT TO_BASE64(''Maria'') AS ''Input'';\n+-----------+\n| Input     |\n+-----------+\n| TWFyaWE=  |\n+-----------+\n\nSELECT FROM_BASE64(''TWFyaWE='') AS ''Output'';\n+--------+\n| Output |\n+--------+\n| Maria  |\n+--------+\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/from_base64', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/from_base64');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (431, 37, 'HEX', 'Description\n-----------\n\nIf N_or_S is a number, returns a string representation of the hexadecimal value of N, where N is a longlong (BIGINT) number. This is equivalent to CONV(N,10,16).\n\nIf N_or_S is a string, returns a hexadecimal string representation ofN_or_S where each byte of each character in N_or_S is converted to two hexadecimal digits. If N_or_S is NULL, returns NULL. The inverse of this operation is performed by the UNHEX()\\\nfunction.\n\nHEX() with an INET6 argument returns a hexadecimal representation of the underlying 16-byte binary string.\n\nExamples\n--------\n\nSELECT HEX(255);\n+----------+\n| HEX(255) |\n+----------+\n| FF       |\n+----------+\n\nSELECT 0x4D617269614442;\n+------------------+\n| 0x4D617269614442 |\n+------------------+\n| MariaDB          |\n+------------------+\n\nSELECT HEX(''MariaDB'');\n+----------------+\n| HEX(''MariaDB'') |\n+----------------+\n| 4D617269614442 |\n+----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/hex', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/hex');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (432, 37, 'INSERT Function', 'Syntax\n------\n\nINSERT(str,pos,len,newstr)\n\nDescription\n-----------\n\nReturns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr. Returns the original string if pos is not within the length of the string.\\\nReplaces the rest of the string from position pos if len is not within the length of the rest of the string. Returns NULL if any argument is NULL.\n\nExamples\n--------\n\nSELECT INSERT(''Quadratic'', 3, 4, ''What'');\n+-----------------------------------+\n| INSERT(''Quadratic'', 3, 4, ''What'') |\n+-----------------------------------+\n| QuWhattic                         |\n+-----------------------------------+\n\nSELECT INSERT(''Quadratic'', -1, 4, ''What'');\n+------------------------------------+\n| INSERT(''Quadratic'', -1, 4, ''What'') |\n+------------------------------------+\n| Quadratic                          |\n+------------------------------------+\n\nSELECT INSERT(''Quadratic'', 3, 100, ''What'');\n+-------------------------------------+\n| INSERT(''Quadratic'', 3, 100, ''What'') |\n+-------------------------------------+\n| QuWhat                              |\n+-------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/insert-function', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/insert-function');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (433, 37, 'INSTR', 'Syntax\n------\n\nINSTR(str,substr)\n\nDescription\n-----------\n\nReturns the position of the first occurrence of substring _substr_ in string _str_. This is the same as the two-argument form of LOCATE(), except that the order of the arguments is reversed.\n\nINSTR() performs a case-insensitive search.\n\nIf any argument is NULL, returns NULL.\n\nExamples\n--------\n\nSELECT INSTR(''foobarbar'', ''bar'');\n+---------------------------+\n| INSTR(''foobarbar'', ''bar'') |\n+---------------------------+\n|                         4 |\n+---------------------------+\n\nSELECT INSTR(''My'', ''Maria'');\n+----------------------+\n| INSTR(''My'', ''Maria'') |\n+----------------------+\n|                    0 |\n+----------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/instr', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/instr');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (434, 37, 'LCASE', 'Syntax\n------\n\nLCASE(str)\n\nDescription\n-----------\n\nLCASE() is a synonym for LOWER().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/lcase', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/lcase');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (435, 37, 'LEFT', 'Syntax\n------\n\nLEFT(str,len)\n\nDescription\n-----------\n\nReturns the leftmost len characters from the string str, or NULL if any argument is NULL.\n\nExamples\n--------\n\nSELECT LEFT(''MariaDB'', 5);\n+--------------------+\n| LEFT(''MariaDB'', 5) |\n+--------------------+\n| Maria              |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/left', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/left');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (436, 37, 'LENGTH', 'Syntax\n------\n\nLENGTH(str)\n\nDescription\n-----------\n\nReturns the length of the string str.\n\nIn the default mode, when Oracle mode is not set, the length is measured in bytes. In this case, a multi-byte character counts as multiple bytes. LENGTH() returns the length in bytes, whereas CHAR_LENGTH() returns the number of characters. This means that, for a string containing five two-byte characters, LENGTH() returns 10, whereas CHAR_LENGTH() returns 5.\nWhen running Oracle mode, the length is measured in characters, and LENGTH is a synonym for CHAR_LENGTH().\n\nIf str is not a string value, it is converted into a string. If str is NULL, the function returns NULL.\n\nExamples\n--------\n\nSELECT LENGTH(''MariaDB'');\n+-------------------+\n| LENGTH(''MariaDB'') |\n+-------------------+\n|                 7 |\n+-------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/length', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/length');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (437, 37, 'LENGTHB', 'Syntax\n------\n\nLENGTHB(str)\n\nDescription\n-----------\n\nLENGTHB() returns the length of the given string, in bytes. When Oracle mode is not set, this is a synonym for LENGTH.\n\nA multi-byte character counts as multiple bytes. This means that for a string containing five two-byte characters, LENGTHB() returns 10, whereas CHAR_LENGTH() returns 5.\n\nIf str is not a string value, it is converted into a string. If str is NULL, the function returns NULL.\n\nExamples\n--------\n\nSELECT CHAR_LENGTH(''π''), LENGTH(''π''), LENGTHB(''π''), OCTET_LENGTH(''π'');\n+-------------------+--------------+---------------+--------------------+\n| CHAR_LENGTH(''π'')  | LENGTH(''π'')  | LENGTHB(''π'')  | OCTET_LENGTH(''π'')  |\n+-------------------+--------------+---------------+--------------------+\n|                 1 |            2 |             2 |                  2 |\n+-------------------+--------------+---------------+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/lengthb', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/lengthb');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (438, 37, 'LIKE', 'Description\n-----------\n\nTests whether _expr_ matches the pattern _pat_. Returns either 1 (TRUE) or 0 (FALSE).\\\nBoth _expr_ and _pat_ may be any valid expression and are evaluated to strings.\\\nPatterns may use the following wildcard characters:\n\n % matches any number of characters, including zero.\n _ matches any single character.\n\nUse NOT LIKE to test if a string does not match a pattern. This is equivalent to using\\\nthe NOT operator on the entire LIKE expression.\n\nIf either the expression or the pattern is NULL, the result is NULL.\n\nLIKE performs case-insensitive substring matches if the collation for the expression and pattern is case-insensitive. For case-sensitive matches, declare either argument to use a binary collation using collate, or coerce either of them to a BINARY string using CAST. Use SHOW COLLATION to get a list of\\\navailable collations. Collations ending in _bin are case-sensitive.\n\nNumeric arguments are coerced to binary strings.\n\nThe _ wildcard matches a single character, not byte. It will only match a multi-byte character\\\nif it is valid in the expression''s character set. For example, _ will match _utf8"€", but it\\\nwill not match _latin1"€" because the Euro sign is not a valid latin1 character. If necessary,\\\nuse CONVERT to use the expression in a different character set.\n\nIf you need to match the characters _ or %, you must escape them. By default, you can prefix the wildcard characters the backslash character \\ to escape them. The backslash is used both to encode special characters like newlines when a string is parsed as well as to escape wildcards in a pattern after parsing. Thus, to match an actual backslash, you sometimes need to double-escape it as "\\\\\\\\".\n\nTo avoid difficulties with the backslash character, you can change the wildcard escape character using ESCAPE in a LIKE expression. The argument to ESCAPE must be a single-character string.\n\nExamples\n--------\n\nCREATE TABLE t1 (d VARCHAR(16));\nINSERT INTO t1 VALUES \n  ("Monday"), ("Tuesday"), ("Wednesday"), \n  ("Thursday"), ("Friday"), ("Saturday"), ("Sunday");\nSELECT * FROM t1 WHERE d LIKE "T%";\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/like', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/like');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (439, 37, 'LOAD\\_FILE', 'Syntax\n------\n\nLOAD_FILE(file_name)\n\nDescription\n-----------\n\nReads the file and returns the file contents as a string. To use this function, the file must be located on the server host, you must specify the full path name to the file, and you must have the FILE privilege. The file must be readable by all and it must be less than the size, in bytes, of the max_allowed_packet system variable. If the secure_file_priv system variable is set to a non-empty directory name, the file to be loaded must be located in that directory.\n\nIf the file does not exist or cannot be read because one of the preceding conditions is not satisfied, the function returns NULL.\n\nThe character_set_filesystem system variable has controlled interpretation of file names that are given as literal strings.\n\nStatements using the LOAD_FILE() function are not safe for statement based replication. This is because the slave will execute the LOAD_FILE() command itself. If the file doesn''t exist on the slave, the function will return NULL.\n\nExamples\n--------\n\nUPDATE t SET blob_col=LOAD_FILE(''/tmp/picture'') WHERE id=1;\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/load_file', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/load_file');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (440, 37, 'LOCATE', 'Syntax\n------\n\nLOCATE(substr,str), LOCATE(substr,str,pos)\n\nDescription\n-----------\n\nThe first syntax returns the position of the first occurrence of substring substr in string str. The second syntax returns the position of the first occurrence of substring substr in string str, starting at position pos. Returns 0 if substr is not in str.\n\nLOCATE() performs a case-insensitive search.\n\nIf any argument is NULL, returns NULL.\n\nINSTR() is the same as the two-argument form of LOCATE(), except that the order of the arguments is reversed.\n\nExamples\n--------\n\nSELECT LOCATE(''bar'', ''foobarbar'');\n+----------------------------+\n| LOCATE(''bar'', ''foobarbar'') |\n+----------------------------+\n|                          4 |\n+----------------------------+\n\nSELECT LOCATE(''My'', ''Maria'');\n+-----------------------+\n| LOCATE(''My'', ''Maria'') |\n+-----------------------+\n|                     0 |\n+-----------------------+\n\nSELECT LOCATE(''bar'', ''foobarbar'', 5);\n+-------------------------------+\n| LOCATE(''bar'', ''foobarbar'', 5) |\n+-------------------------------+\n|                             7 |\n+-------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/locate', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/locate');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (441, 37, 'LOWER', 'Syntax\n------\n\nLOWER(str)\nLCASE(str)\n\nDescription\n-----------\n\nReturns the string str with all characters changed to lowercase according to the current character set mapping. The default is latin1 (cp1252 West European).\n\nLCASE is a synonym for LOWER .\n\nExamples\n--------\n\nSELECT LOWER(''QUADRATICALLY'');\n+------------------------+\n| LOWER(''QUADRATICALLY'') |\n+------------------------+\n| quadratically          |\n+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/lower', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/lower');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (442, 37, 'LPAD', 'Syntax\n------\n\nLPAD(str, len [,padstr])\n\nDescription\n-----------\n\nReturns the string str, left-padded with the string padstr to a length of len characters. If str is longer than len, the return value is shortened to len characters. If padstr is omitted, the LPAD function pads spaces.\n\nReturns NULL if given a NULL argument. If the result is empty (zero length), returns either an empty string or with SQL_MODE=Oracle, NULL.\n\nThe Oracle mode version of the function can be accessed outside of Oracle mode by using LPAD_ORACLE as the function name.\n\nExamples\n--------\n\nSELECT LPAD(''hello'',10,''.'');\n+----------------------+\n| LPAD(''hello'',10,''.'') |\n+----------------------+\n| .....hello           |\n+----------------------+\n\nSELECT LPAD(''hello'',2,''.'');\n+---------------------+\n| LPAD(''hello'',2,''.'') |\n+---------------------+\n| he                  |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/lpad', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/lpad');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (443, 37, 'LTRIM', 'Syntax\n------\n\nLTRIM(str)\n\nDescription\n-----------\n\nReturns the string str with leading space characters removed.\n\nReturns NULL if given a NULL argument. If the result is empty, returns either an empty string, or with SQL_MODE=Oracle, NULL.\n\nThe Oracle mode version of the function can be accessed outside of Oracle mode by using LTRIM_ORACLE as the function name.\n\nExamples\n--------\n\nSELECT QUOTE(LTRIM(''   MariaDB   ''));\n+-------------------------------+\n| QUOTE(LTRIM(''   MariaDB   '')) |\n+-------------------------------+\n| ''MariaDB   ''                  |\n+-------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/ltrim', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/ltrim');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (444, 37, 'MAKE\\_SET', 'Syntax\n------\n\nMAKE_SET(bits,str1,str2,...)\n\nDescription\n-----------\n\nReturns a set value (a string containing substrings separated by "," characters) consisting of the strings that have the corresponding bit in bits set. _str1_ corresponds to bit 0, _str2_ to bit 1, and so on. NULL\\\nvalues in _str1_, _str2_, ... are not appended to the result.\n\nExamples\n--------\n\nSELECT MAKE_SET(1,''a'',''b'',''c'');\n+-------------------------+\n| MAKE_SET(1,''a'',''b'',''c'') |\n+-------------------------+\n| a                       |\n+-------------------------+\n\nSELECT MAKE_SET(1 | 4,''hello'',''nice'',''world'');\n+----------------------------------------+\n| MAKE_SET(1 | 4,''hello'',''nice'',''world'') |\n+----------------------------------------+\n| hello,world                            |\n+----------------------------------------+\n\nSELECT MAKE_SET(1 | 4,''hello'',''nice'',NULL,''world'');\n+---------------------------------------------+\n| MAKE_SET(1 | 4,''hello'',''nice'',NULL,''world'') |\n+---------------------------------------------+\n| hello                                       |\n+---------------------------------------------+\n\nSELECT QUOTE(MAKE_SET(0,''a'',''b'',''c''));\n+--------------------------------+\n| QUOTE(MAKE_SET(0,''a'',''b'',''c'')) |\n+--------------------------------+\n| ''''                             |\n+--------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/make_set', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/make_set');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (445, 37, 'MATCH AGAINST', 'Syntax\n------\n\nMATCH (col1,col2,...) AGAINST (expr [search_modifier])\n\nDescription\n-----------\n\nA special construct used to perform a fulltext search on a fulltext index.\n\nSee Fulltext Index Overview for a full description, and Full-text Indexes for more articles on the topic.\n\nExamples\n--------\n\nCREATE TABLE ft_myisam(copy TEXT,FULLTEXT(copy)) ENGINE=MyISAM;\n\nINSERT INTO ft_myisam(copy) VALUES (''Once upon a time''), (''There was a wicked witch''), \n (''Who ate everybody up'');\n\nSELECT * FROM ft_myisam WHERE MATCH(copy) AGAINST(''wicked'');\n+--------------------------+\n| copy                     |\n+--------------------------+\n| There was a wicked witch |\n+--------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/match-against', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/match-against');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (446, 37, 'MID', 'Syntax\n------\n\nMID(str,pos,len)\n\nDescription\n-----------\n\nMID(str,pos,len) is a synonym for SUBSTRING(str,pos,len)!\n\nExamples\n--------\n\nSELECT MID(''abcd'',4,1);\n+-----------------+\n| MID(''abcd'',4,1) |\n+-----------------+\n| d               |\n+-----------------+\n\nSELECT MID(''abcd'',2,2);\n+-----------------+\n| MID(''abcd'',2,2) |\n+-----------------+\n| bc              |\n+-----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/mid', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/mid');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (447, 37, 'NATURAL\\_SORT\\_KEY', 'Syntax\n------\n\nNATURAL_SORT_KEY(str)\n\nDescription\n-----------\n\nThe NATURAL_SORT_KEY function is used for sorting that is closer to natural sorting. Strings are sorted in alphabetical order, while numbers are treated in a way such that, for example, 10 is greater than 2, whereas in other forms of sorting, 2 would be greater than 10, just like z is greater than ya.\n\nThere are multiple natural sort implementations, differing in the way they handle leading zeroes, fractions, i18n, negatives, decimals and so on.\n\nMariaDB''s implementation ignores leading zeroes when performing the sort.\n\nYou can use also use NATURAL_SORT_KEY with generated columns. The value is not stored permanently in the table. When using a generated column, the virtual column must be longer than the base column to cater for embedded numbers in the string and MDEV-24582.\n\nExamples\n--------\n\nCREATE TABLE t1 (c TEXT);\n\nINSERT INTO t1 VALUES (''b1''),(''a2''),(''a11''),(''a1'');\n\nSELECT c FROM t1;\n+------+\n| c    |\n+------+\n| b1   |\n| a2   |\n| a11  |\n| a1   |\n+------+\n\nSELECT c FROM t1 ORDER BY c;\n+------+\n| c    |\n+------+\n| a1   |\n| a11  |\n| a2   |\n| b1   |\n+------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/natural_sort_key', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/natural_sort_key');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (448, 37, 'NOT LIKE', 'Syntax\n------\n\nexpr NOT LIKE pat [ESCAPE ''escape_char'']\n\nDescription\n-----------\n\nThis is the same as [NOT (expr LIKE pat \\[ESCAPE ''escape_char''\\])](../../sql-structure/operators/logical-operators/not.md).\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/not-like', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/not-like');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (449, 37, 'NOT REGEXP', 'Syntax\n------\n\nexpr NOT REGEXP pat, expr NOT RLIKE pat\n\nDescription\n-----------\n\nThis is the same as NOT (expr REGEXP pat).\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/not-regexp', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/not-regexp');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (450, 37, 'OCTET\\_LENGTH', 'Description\n-----------\n\nOCTET_LENGTH() returns the length of the given string, in octets (bytes). This is a synonym for LENGTHB(), and, when Oracle mode is not set, a synonym for LENGTH().\n\nA multi-byte character counts as multiple bytes. This means that for a string containing five two-byte characters, OCTET_LENGTH() returns 10, whereas CHAR_LENGTH() returns 5.\n\nIf str is not a string value, it is converted into a string. If str is NULL, the function returns NULL.\n\nExamples\n--------\n\nSELECT CHAR_LENGTH(''π''), LENGTH(''π''), LENGTHB(''π''), OCTET_LENGTH(''π'');\n+-------------------+--------------+---------------+--------------------+\n| CHAR_LENGTH(''π'')  | LENGTH(''π'')  | LENGTHB(''π'')  | OCTET_LENGTH(''π'')  |\n+-------------------+--------------+---------------+--------------------+\n|                 1 |            2 |             2 |                  2 |\n+-------------------+--------------+---------------+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/octet_length', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/octet_length');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (451, 37, 'ORD', 'Syntax\n------\n\nORD(str)\n\nDescription\n-----------\n\nIf the leftmost character of the string str is a multi-byte character, returns the code for that character, calculated from the numeric values of its constituent bytes using this formula:\n\n``sql\n(1st byte code)\n+ (2nd byte code x 256)\n+ (3rd byte code x 256 x 256) ...\n`\n\nIf the leftmost character is not a multi-byte character, ORD()` returns the same value as the ASCII() function.\n\nExamples\n--------\n\nSELECT ORD(''2'');\n+----------+\n| ORD(''2'') |\n+----------+\n|       50 |\n+----------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/ord', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/ord');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (452, 37, 'POSITION', 'Syntax\n------\n\nPOSITION(substr IN str)\n\nDescription\n-----------\n\nPOSITION(substr IN str) is a synonym for LOCATE(substr,str).\n\nThe function is part of ODBC 3.0.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/position', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/position');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (453, 37, 'QUOTE', 'Syntax\n------\n\nQUOTE(str)\n\nDescription\n-----------\n\nQuotes a string to produce a result that can be used as a properly escaped data value in an SQL statement. The string is returned enclosed by single quotes and with each instance of single quote ("''"), backslash ("\\"),ASCII NUL, and Control-Z preceded by a backslash. If the argument is NULL, the return value is the word "NULL" without enclosing single quotes.\n\nExamples\n--------\n\nSELECT QUOTE("Don''t!");\n+-----------------+\n| QUOTE("Don''t!") |\n+-----------------+\n| ''Don\\''t!''       |\n+-----------------+\n\nSELECT QUOTE(NULL); \n+-------------+\n| QUOTE(NULL) |\n+-------------+\n| NULL        |\n+-------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/quote', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/quote');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (454, 37, 'PCRE - Perl Compatible Regular Expressions', 'Description\n-----------\n\nPCRE Versions\n\n| PCRE Version                         | Introduced                                                                                                                                                                                                                                                                                                                               | Maturity |\n| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |\n| PCRE2 10.34 | MariaDB 10.5.1                                                                                                                                                                                                                               | Stable   |\n| PCRE 8.43                            | MariaDB 10.1.39                                                                                                                                                                                                                             | Stable   |\n| PCRE 8.42                            | MariaDB 10.2.15, MariaDB 10.1.33, MariaDB 10.0.35 | Stable   |\n| PCRE 8.41                            | MariaDB 10.2.8, MariaDB 10.1.26, MariaDB 10.0.32   | Stable   |\n| PCRE 8.40                            | MariaDB 10.2.5, MariaDB 10.1.22, MariaDB 10.0.30   | Stable   |\n| PCRE 8.39                            | MariaDB 10.1.15, MariaDB 10.0.26                                                                                                               | Stable   |\n| PCRE 8.38                            | MariaDB 10.1.10, MariaDB 10.0.23                                                                                                               | Stable   |\n| PCRE 8.37                            | MariaDB 10.1.5, MariaDB 10.0.18                                                                                                                 | Stable   |\n| PCRE 8.36                            | MariaDB 10.1.2, MariaDB 10.0.15                                                                                                                 | Stable   |\n| PCRE 8.35                            | MariaDB 10.1.0, MariaDB 10.0.12                                                                                                                 | Stable   |\n| PCRE 8.34                            | MariaDB 10.0.8                                                                                                                                                                                                                               | Stable   |\n\nPCRE Enhancements\n\nMariaDB uses the PCRE library, which significantly improves the power of the REGEXP/RLIKE operator.\n\nThe switch to PCRE added a number of features, including recursive patterns, named capture, look-ahead and look-behind assertions, non-capturing groups, non-greedy quantifiers, Unicode character properties, extended syntax for characters and character classes, multi-line matching, and many other.\n\nThese functions work with regular expressions: REGEXP_REPLACE(), REGEXP_INSTR(), and REGEXP_SUBSTR().\n\nAlso, REGEXP/RLIKE, and the new functions, work correctly with all multi-byte character sets supported by MariaDB, including East-Asian character sets (big5, gb2313, gbk, eucjp, eucjpms, cp932, ujis, euckr), and Unicode character sets (utf8, utf8mb4, ucs2, utf16, utf16le, utf32).\n\nNew Regular Expression Functions\n\n REGEXP_REPLACE(subject, pattern, replace) - Replaces all occurrences of a pattern.\n REGEXP_INSTR(subject, pattern) - Position of the first appearance of a regex.\n REGEXP_SUBSTR(subject,pattern) - Returns the matching part of a string.\n\nSee the individual articles for more details and examples.\n\nPCRE Syntax\n\nIn most cases PCRE is backward compatible with the old POSIX 1003.2 compliant regexp library (see Regular Expressions Overview), so you won''t need to change your applications that use SQL queries with the REGEXP/RLIKE predicate.\n\nThis section briefly describes the most important extended PCRE features. For more details, please refer to the documentation on the PCRE site, or to the documentation which is bundled in the /pcre/doc/html/ directory of a MariaDB sources distribution. The pages pcresyntax.html and pcrepattern.html should be a good start. Regular-Expressions.Info is another good resource to learn about PCRE and regular expressions generally.\n\nSpecial Characters\n\nPCRE supports the following escape sequences to match special characters:\n\n| Sequence  | Description                                 |\n| --------- | ------------------------------------------- |\n| \\a        | 0x07 (BEL)                                  |\n| \\cx       | "control-x", where x is any ASCII character |\n| \\e        | 0x1B (escape)                               |\n| \\f        | 0x0C (form feed)                            |\n|           | 0x0A (newline)                              |\n|           | 0x0D (carriage return)                      |\n|           | 0x09 (TAB)                                  |\n| \\ddd      | character with octal code ddd               |\n| \\xhh      | character with hex code hh                  |\n| \\x{hhh..} | character with hex code hhh..               |\n\nNote, the backslash characters (here, and in all examples in the sections below) must be escaped with another backslash, unless you''re using the SQL_MODE NO_BACKSLASH_ESCAPES.\n\nThis example tests if a character has hex code 0x61:\n\n``sql\nSELECT ''a'' RLIKE ''\\\\x{61}'';\n-> 1\n`\n\nCharacter Classes\n\nPCRE supports the standard POSIX character classes such as alnum, alpha, blank, cntrl, digit, graph, lower, print, punct, space, upper, xdigit, with the following additional classes:\n\n| Class | Description                                                |\n| ----- | ---------------------------------------------------------- |\n| ascii | any ASCII character (0x00..0x7F)                           |\n| word  | any "word" character (a letter, a digit, or an underscore) |\n\nThis example checks if the string consists of ASCII characters only:\n\n`\nSELECT ''abc'' RLIKE ''^[[:ascii:]]+$'';\n-> 1\n`\n\nGeneric Character Types\n\nGeneric character types complement the POSIX character classes and serve to simplify writing patterns:\n\n| Class | Description                                                |\n| ----- | ---------------------------------------------------------- |\n| \\d    | a decimal digit (same as \\[:digit:])                       |\n| \\D    | a character that is not a decimal digit                    |\n| \\h    | a horizontal white space character                         |\n| \\H    | a character that is not a horizontal white space character |\n|       | a character that is not a new line                         |\n|       | a newline sequence                                         |\n| \\s    | a white space character                                    |\n| \\S    | a character that is not a white space character            |\n| \\v    | a vertical white space character                           |\n| \\V    | a character that is not a vertical white space character   |\n| \\w    | a "word" character (same as \\[:word:])                     |\n| \\W    | a "non-word" character                                     |\n\nThis example checks if the string consists of "word" characters only:\n\n`sql\nSELECT ''abc'' RLIKE ''^\\\\w+$'';\n-> 1\n`\n\nUnicode Character Properties\n\n\\p{xx} is a character with the xx property, and \\P{xx} is a character without the xx property.\n\nThe property names represented by xx above are limited to the Unicode script names, the general category properties, and "Any", which matches any character (including newline). Those that are not part of an identified script are lumped together as "Common".\n\nGeneral Category Properties For \\p and \\P\n\n| Property | Description           |\n| -------- | --------------------- |\n| C        | Other                 |\n| Cc       | Control               |\n| Cf       | Format                |\n| Cn       | Unassigned            |\n| Co       | Private use           |\n| Cs       | Surrogate             |\n| L        | Letter                |\n| Ll       | Lower case letter     |\n| Lm       | Modifier letter       |\n| Lo       | Other letter          |\n| Lt       | Title case letter     |\n| Lu       | Upper case letter     |\n| L&       | Ll, Lu, or Lt         |\n| M        | Mark                  |\n| Mc       | Spacing mark          |\n| Me       | Enclosing mark        |\n| Mn       | Non-spacing mark      |\n| N        | Number                |\n| Nd       | Decimal number        |\n| Nl       | Letter number         |\n| No       | Other number          |\n| P        | Punctuation           |\n| Pc       | Connector punctuation |\n| Pd       | Dash punctuation      |\n| Pe       | Close punctuation     |\n| Pf       | Final punctuation     |\n| Pi       | Initial punctuation   |\n| Po       | Other punctuation     |\n| Ps       | Open punctuation      |\n| S        | Symbol                |\n| Sc       | Currency symbol       |\n| Sk       | Modifier symbol       |\n| Sm       | Mathematical symbol   |\n| So       | Other symbol          |\n| Z        | Separator             |\n| Zl       | Line separator        |\n| Zp       | Paragraph separator   |\n| Zs       | Space separator       |\n\nThis example checks if the string consists only of characters with property N (number):\n\n`sql\nSELECT ''1¼①'' RLIKE ''^\\\\p{N}+$'';\n-> 1\n`\n\nSpecial Category Properties For \\p and \\P\n\n| Property | Description                                                       |\n| -------- | ----------------------------------------------------------------- |\n| Xan      | Alphanumeric: union of properties L and N                         |\n| Xps      | POSIX space: property Z or tab, NL, VT, FF, CR                    |\n| Xsp      | Perl space: property Z or tab, NL, FF, CR                         |\n| Xuc      | A character than can be represented by a Universal Character Name |\n| Xwd      | Perl word: property Xan or underscore                             |\n\nThe property Xuc matches any character that can be represented by a Universal Character Name (in C++ and other programming languages). These include $, @, \\\\\\, and all characters with Unicode code points greater than U+00A0, excluding the surrogates U+D800..U+DFFF.\n\nScript Names For \\p and \\P\n\nArabic, Armenian, Avestan, Balinese, Bamum, Batak, Bengali, Bopomofo, Brahmi, Braille, Buginese, Buhid, Canadian_Aboriginal, Carian, Chakma, Cham, Cherokee, Common, Coptic, Cuneiform, Cypriot, Cyrillic, Deseret, Devanagari, Egyptian_Hieroglyphs, Ethiopic, Georgian, Glagolitic, Gothic, Greek, Gujarati, Gurmukhi, Han, Hangul, Hanunoo, Hebrew, Hiragana, Imperial_Aramaic, Inherited, Inscriptional_Pahlavi, Inscriptional_Parthian, Javanese, Kaithi, Kannada, Katakana, Kayah_Li, Kharoshthi, Khmer, Lao, Latin, Lepcha, Limbu, Linear_B, Lisu, Lycian, Lydian, Malayalam, Mandaic, Meetei_Mayek, Meroitic_Cursive, Meroitic_Hieroglyphs, Miao, Mongolian, Myanmar, New_Tai_Lue, Nko, Ogham, Old_Italic, Old_Persian, Old_South_Arabian, Old_Turkic, Ol_Chiki, Oriya, Osmanya, Phags_Pa, Phoenician, Rejang, Runic, Samaritan, Saurashtra, Sharada, Shavian, Sinhala, Sora_Sompeng, Sundanese, Syloti_Nagri, Syriac, Tagalog, Tagbanwa, Tai_Le, Tai_Tham, Tai_Viet, Takri, Tamil, Telugu, Thaana, Thai, Tibetan, Tifinagh, Ugaritic, Vai, Yi.\n\nThis example checks if the string consists only of Greek characters:\n\n``sql\nSELECT ''ΣΦΩ'' RLIKE ''^\\\\p{Greek}+$'';\n-> 1\n`\n\nExtended Unicode Grapheme Sequence\n\nThe \\X escape sequence matches a character sequence that makes an "extended grapheme cluster", i.e. a composite character that consists of multiple Unicode code points.\n\nOne of the examples of a composite character can be a letter followed by non-spacing accent marks. This example demonstrates that U+0045 LATIN CAPITAL LETTER E followed by U+0302 COMBINING CIRCUMFLEX ACCENT followed by U+0323 COMBINING DOT BELOW together form an extended grapheme cluster:\n\n`sql\nSELECT _ucs2 0x004503020323 RLIKE ''^\\\\X$'';\n-> 1\n`\n\nSee the PCRE documentation for the other types of extended grapheme clusters.\n\nSimple Assertions\n\nAn assertion specifies a certain condition that must match at a particular point, but without consuming characters from the subject string. In addition to the standard POSIX simple assertions ^ (that matches at the beginning of a line) and $ (that matches at the end of a line), PCRE supports a number of other assertions:\n\n| Assertion | Description                                                                                |\n| --------- | ------------------------------------------------------------------------------------------ |\n| \\b        | matches at a word boundary                                                                 |\n| \\B        | matches when not at a word boundary                                                        |\n| \\A        | matches at the start of the subject                                                        |\n| \\Z        | matches at the end of the subject, also matches before a newline at the end of the subject |\n| \\z        | matches only at the end of the subject                                                     |\n| \\G        | matches at the first matching position in the subject                                      |\n\nThis example cuts a word that consists only of 3 characters from a string:\n\n`sql\nSELECT REGEXP_SUBSTR(''---abcd---xyz---'', ''\\\\b\\\\w{3}\\\\b'');\n-> xyz\n`\n\nNotice that the two \\b assertions checked the word boundaries but did not get into the matching pattern.\n\nThe \\b assertions work well in the beginning and the end of the subject string:\n\n`sql\nSELECT REGEXP_SUBSTR(''xyz'', ''\\\\b\\\\w{3}\\\\b'');\n-> xyz\n`\n\nBy default, the ^ and $ assertions have the same meaning with \\A, \\Z, and \\z. However, the meanings of ^ and $ can change in multiline mode (see below). By contrast, the meanings of \\A, \\Z, and \\z are always the same; they are independent of the multiline mode.\n\nOption Setting\n\nA number of options that control the default match behavior can be changed within the pattern by a sequence of option letters enclosed between (? and ).\n\n| Option  | Description                                                              |\n| ------- | ------------------------------------------------------------------------ |\n| (?i)    | case insensitive match                                                   |\n| (?m)    | multiline mode                                                           |\n| (?s)    | dotall mode (dot matches newline characters)                             |\n| (?x)    | extended (ignore white space)                                            |\n| (?U)    | ungreedy (lazy) ma\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/pcre');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (455, 37, 'REGEXP', 'Syntax\n------\n\nexpr REGEXP pat, expr RLIKE pat\n\nDescription\n-----------\n\nPerforms a pattern match of a string expression expr against a patternpat. The pattern can be an extended regular expression. See Regular Expressions Overview for details on the syntax for\\\nregular expressions (see also PCRE Regular Expressions).\n\nReturns 1 if expr matches pat or 0 if it doesn''t match. If either expr or pat are NULL, the result is NULL.\n\nThe negative form NOT REGEXP also exists, as an alias for NOT (string REGEXP pattern). RLIKE and NOT RLIKE are synonyms for REGEXP and NOT REGEXP, originally provided for mSQL compatibility.\n\nThe pattern need not be a literal string. For example, it can be specified as a string expression or table column.\n\nNote: Because MariaDB uses the C escape syntax in strings (for example, "\\n" to represent the newline character), you must double any "" that you use in your REGEXP strings.\n\nREGEXP is not case sensitive, except when used with binary strings.\n\nThe default_regex_flags variable addresses the remaining compatibilities between PCRE and the old regex library.\n\nExamples\n--------\n\nSELECT ''Monty!'' REGEXP ''m%y%%'';\n+-------------------------+\n| ''Monty!'' REGEXP ''m%y%%'' |\n+-------------------------+\n|                       0 |\n+-------------------------+\n\nSELECT ''Monty!'' REGEXP ''.'';\n+----------------------+\n| ''Monty!'' REGEXP ''.'' |\n+----------------------+\n|                    1 |\n+----------------------+\n\nSELECT ''new\\nline'' REGEXP ''new\\\\.\\\\line'';\n+---------------------------------------+\n| ''new\\nline'' REGEXP ''new\\\\.\\\\line'' |\n+---------------------------------------+\n|                                     1 |\n+---------------------------------------+\n\nSELECT ''a'' REGEXP ''A'', ''a'' REGEXP BINARY ''A'';\n+----------------+-----------------------+\n| ''a'' REGEXP ''A'' | ''a'' REGEXP BINARY ''A'' |\n+----------------+-----------------------+\n|              1 |                     0 |\n+----------------+-----------------------+\n\nSELECT ''a'' REGEXP ''^[a-d]'';\n+---------------------+\n| ''a'' REGEXP ''^[a-d]'' |\n+---------------------+\n|                   1 |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regexp', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regexp');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (456, 37, 'REGEXP\\_INSTR', 'Description\n-----------\n\nSyntax\n\n``sql\nREGEXP_INSTR(subject, pattern)\n`\n\nReturns the position of the first occurrence of the regular expression pattern in the string subject, or 0 if pattern was not found.\n\nThe positions start with 1 and are measured in characters (i.e. not in bytes), which is important for multi-byte character sets. You can cast a multi-byte character set to BINARY to get offsets in bytes.\n\nThe function follows the case sensitivity rules of the effective collation. Matching is performed case insensitively for case insensitive collations, and case sensitively for case sensitive collations and for binary data.\n\nThe collation case sensitivity can be overwritten using the (?i) and (?-i) PCRE flags.\n\nMariaDB uses the PCRE regular expression library for enhanced regular expression performance, and REGEXP_INSTR` was introduced as part of this enhancement.\n\nExamples\n--------\n\nSELECT REGEXP_INSTR(''abc'',''b'');\n-> 2\n\nSELECT REGEXP_INSTR(''abc'',''x'');\n-> 0\n\nSELECT REGEXP_INSTR(''BJÖRN'',''N'');\n-> 5\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regexp_instr', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regexp_instr');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (457, 37, 'REGEXP\\_REPLACE', 'Syntax\n------\n\nREGEXP_REPLACE(subject, pattern, replace)\n\nDescription\n-----------\n\nREGEXP_REPLACE returns the string subject with all occurrences of the regular expression pattern replaced by the string replace. If no occurrences are found, then subject is returned as is.\n\nThe replace string can have backreferences to the subexpressions in the form \\N, where N is a number from 1 to 9.\n\nThe function follows the case sensitivity rules of the effective collation. Matching is performed case insensitively for case insensitive collations, and case sensitively for case sensitive collations and for binary data.\n\nThe collation case sensitivity can be overwritten using the (?i) and (?-i) PCRE flags.\n\nMariaDB uses the PCRE regular expression library for enhanced regular expression performance, and REGEXP_REPLACE was introduced as part of this enhancement.\n\nThe default_regex_flags variable addresses the remaining compatibilities between PCRE and the old regex library.\n\nExamples\n--------\n\nSELECT REGEXP_REPLACE(''ab12cd'',''[0-9]'','''') AS remove_digits;\n-> abcd\n\nSELECT REGEXP_REPLACE(''<html><head><title>title</title><body>body</body></htm>'', ''<.+?>'','' '')\nAS strip_html;\n-> title  body\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regexp_replace', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regexp_replace');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (458, 37, 'REGEXP\\_SUBSTR', 'Syntax\n------\n\nREGEXP_SUBSTR(subject,pattern)\n\nDescription\n-----------\n\nReturns the part of the string subject that matches the regular expression pattern, or an empty string if pattern was not found.\n\nThe function follows the case sensitivity rules of the effective collation. Matching is performed case insensitively for case insensitive collations, and case sensitively for case sensitive collations and for binary data.\n\nThe collation case sensitivity can be overwritten using the (?i) and (?-i) PCRE flags.\n\nMariaDB uses the PCRE regular expression library for enhanced regular expression performance, and REGEXP_SUBSTR was introduced as part of this enhancement.\n\nThe default_regex_flags variable addresses the remaining compatibilities between PCRE and the old regex library.\n\nExamples\n--------\n\nSELECT REGEXP_SUBSTR(''ab12cd'',''[0-9]+'');\n-> 12\n\nSELECT REGEXP_SUBSTR(\n  ''See https://mariadb.org/en/foundation/ for details'',\n  ''https?://[^/]*'');\n-> https://mariadb.org\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regexp_substr', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regexp_substr');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (459, 37, 'Regular Expressions Overview', 'Description\n-----------\n\nRegular Expressions allow MariaDB to perform complex pattern matching on a string. In many cases, the simple pattern matching provided by LIKE is sufficient. LIKE performs two kinds of matches:\n\n _ - the underscore, matching a single character\n % - the percentage sign, matching any number of characters.\n\nIn other cases you may need more control over the returned matches, and will need to use regular expressions.\n\nRegular expression matches are performed with the REGEXP function. RLIKE is a synonym for REGEXP.\n\nComparisons are performed on the byte value, so characters that are treated as equivalent by a collation, but do not have the same byte-value, such as accented characters, could evaluate as unequal.\n\nWithout any special characters, a regular expression match is true if the characters match. The match is case-insensitive, except in the case of BINARY strings.\n\n``sql\nSELECT ''Maria'' REGEXP ''Maria'';\n+------------------------+\n| ''Maria'' REGEXP ''Maria'' |\n+------------------------+\n|                      1 |\n+------------------------+\n\nSELECT ''Maria'' REGEXP ''maria'';\n+------------------------+\n| ''Maria'' REGEXP ''maria'' |\n+------------------------+\n|                      1 |\n+------------------------+\n\nSELECT BINARY ''Maria'' REGEXP ''maria'';\n+-------------------------------+\n| BINARY ''Maria'' REGEXP ''maria'' |\n+-------------------------------+\n|                             0 |\n+-------------------------------+\n`\n\nNote that the word being matched must match the whole pattern:\n\n`sql\nSELECT ''Maria'' REGEXP ''Mari'';\n+-----------------------+\n| ''Maria'' REGEXP ''Mari'' |\n+-----------------------+\n|                     1 |\n+-----------------------+\n\nSELECT ''Mari'' REGEXP ''Maria'';\n+-----------------------+\n| ''Mari'' REGEXP ''Maria'' |\n+-----------------------+\n|                     0 |\n+-----------------------+\n`\n\nThe first returns true because the pattern "Mari" exists in the expression "Maria". When the order is reversed, the result is false, as the pattern "Maria" does not exist in the expression "Mari"\n\nA match can be performed against more than one word with the | character. For example:\n\n`sql\nSELECT ''Maria'' REGEXP ''Monty|Maria'';\n+------------------------------+\n| ''Maria'' REGEXP ''Monty|Maria'' |\n+------------------------------+\n|                            1 |\n+------------------------------+\n`\n\nSpecial Characters\n\nThe above examples introduce the syntax, but are not very useful on their own. It''s the special characters that give regular expressions their power.\n\n^\n\n^ matches the beginning of a string (inside square brackets it can also mean NOT - see below):\n\n`sql\nSELECT ''Maria'' REGEXP ''^Ma'';\n+----------------------+\n| ''Maria'' REGEXP ''^Ma'' |\n+----------------------+\n|                    1 |\n+----------------------+\n`\n\n$\n\n$ matches the end of a string:\n\n`sql\nSELECT ''Maria'' REGEXP ''ia$'';\n+----------------------+\n| ''Maria'' REGEXP ''ia$'' |\n+----------------------+\n|                    1 |\n+----------------------+\n`\n\n.\n\n. matches any single character:\n\n`sql\nSELECT ''Maria'' REGEXP ''Ma.ia'';\n+------------------------+\n| ''Maria'' REGEXP ''Ma.ia'' |\n+------------------------+\n|                      1 |\n+------------------------+\n\nSELECT ''Maria'' REGEXP ''Ma..ia'';\n+-------------------------+\n| ''Maria'' REGEXP ''Ma..ia'' |\n+-------------------------+\n|                       0 |\n+-------------------------+\n`\n\n\\\n\nx matches zero or more of a character x. In the examples below, it''s the r character.\n\n`sql\nSELECT ''Maria'' REGEXP ''Maria'';\n+-------------------------+\n| ''Maria'' REGEXP ''Maria'' |\n+-------------------------+\n|                       1 |\n+-------------------------+\n\nSELECT ''Maia'' REGEXP ''Maria'';\n+------------------------+\n| ''Maia'' REGEXP ''Maria'' |\n+------------------------+\n|                      1 |\n+------------------------+\n\nSELECT ''Marrria'' REGEXP ''Maria'';\n+---------------------------+\n| ''Marrria'' REGEXP ''Maria'' |\n+---------------------------+\n|                         1 |\n+---------------------------+\n`\n\n+\n\nx+ matches one or more of a character x. In the examples below, it''s the r character.\n\n`sql\nSELECT ''Maria'' REGEXP ''Mar+ia'';\n+-------------------------+\n| ''Maria'' REGEXP ''Mar+ia'' |\n+-------------------------+\n|                       1 |\n+-------------------------+\n\nSELECT ''Maia'' REGEXP ''Mar+ia'';\n+------------------------+\n| ''Maia'' REGEXP ''Mar+ia'' |\n+------------------------+\n|                      0 |\n+------------------------+\n\nSELECT ''Marrria'' REGEXP ''Mar+ia'';\n+---------------------------+\n| ''Marrria'' REGEXP ''Mar+ia'' |\n+---------------------------+\n|                         1 |\n+---------------------------+\n`\n\n?\n\nx? matches zero or one of a character x. In the examples below, it''s the r character.\n\n`sql\nSELECT ''Maria'' REGEXP ''Mar?ia'';\n+-------------------------+\n| ''Maria'' REGEXP ''Mar?ia'' |\n+-------------------------+\n|                       1 |\n+-------------------------+\n\nSELECT ''Maia'' REGEXP ''Mar?ia'';\n+------------------------+\n| ''Maia'' REGEXP ''Mar?ia'' |\n+------------------------+\n|                      1 |\n+------------------------+\n\nSELECT ''Marrria'' REGEXP ''Mar?ia'';\n+---------------------------+\n| ''Marrria'' REGEXP ''Mar?ia'' |\n+---------------------------+\n|                         0 |\n+---------------------------+\n`\n\n()\n\n(xyz) - combine a sequence, for example (xyz)+ or (xyz)\n\n`sql\nSELECT ''Maria'' REGEXP ''(ari)+'';\n+-------------------------+\n| ''Maria'' REGEXP ''(ari)+'' |\n+-------------------------+\n|                       1 |\n+-------------------------+\n`\n\n{}\n\nx{n} and x{m,n}\\\nThis notation is used to match many instances of the x. In the case of x{n} the match must be exactly that many times. In the case of x{m,n}, the match can occur from m to n times. For example, to match zero or one instance of the string ari (which is identical to (ari)?), the following can be used:\n\n`sql\nSELECT ''Maria'' REGEXP ''(ari){0,1}'';\n+-----------------------------+\n| ''Maria'' REGEXP ''(ari){0,1}'' |\n+-----------------------------+\n|                           1 |\n+-----------------------------+\n`\n\n\\[]\n\n[xy] groups characters for matching purposes. For example, to match either the p or the r character:\n\n`sql\nSELECT ''Maria'' REGEXP ''Ma[pr]ia'';\n+---------------------------+\n| ''Maria'' REGEXP ''Ma[pr]ia'' |\n+---------------------------+\n|                         1 |\n+---------------------------+\n`\n\nThe square brackets also permit a range match, for example, to match any character from a-z, [a-z] is used. Numeric ranges are also permitted.\n\n`sql\nSELECT ''Maria'' REGEXP ''Ma[a-z]ia'';\n+----------------------------+\n| ''Maria'' REGEXP ''Ma[a-z]ia'' |\n+----------------------------+\n|                          1 |\n+----------------------------+\n`\n\nThe following does not match, as r falls outside of the range a-p.\n\n`sql\nSELECT ''Maria'' REGEXP ''Ma[a-p]ia'';\n+----------------------------+\n| ''Maria'' REGEXP ''Ma[a-p]ia'' |\n+----------------------------+\n|                          0 |\n+----------------------------+\n`\n\n^\n\nThe ^ character means does NOT match, for example:\n\n`sql\nSELECT ''Maria'' REGEXP ''Ma[^p]ia'';\n+---------------------------+\n| ''Maria'' REGEXP ''Ma[^p]ia'' |\n+---------------------------+\n|                         1 |\n+---------------------------+\n\nSELECT ''Maria'' REGEXP ''Ma[^r]ia'';\n+---------------------------+\n| ''Maria'' REGEXP ''Ma[^r]ia'' |\n+---------------------------+\n|                         0 |\n+---------------------------+\n`\n\nThe [ and ] characters on their own can be literally matched inside a [] block, without escaping, as long as they immediately match the opening bracket:\n\n`sql\nSELECT ''[Maria'' REGEXP ''[[]'';\n+-----------------------+\n| ''[Maria'' REGEXP ''[[]'' |\n+-----------------------+\n|                     1 |\n+-----------------------+\n\nSELECT ''[Maria'' REGEXP ''[]]'';\n+-----------------------+\n| ''[Maria'' REGEXP ''[]]'' |\n+-----------------------+\n|                     0 |\n+-----------------------+\n\nSELECT '']Maria'' REGEXP ''[]]'';\n+-----------------------+\n| '']Maria'' REGEXP ''[]]'' |\n+-----------------------+\n|                     1 |\n+-----------------------+\n\nSELECT '']Maria'' REGEXP ''[]a]'';\n+------------------------+\n| '']Maria'' REGEXP ''[]a]'' |\n+------------------------+\n|                      1 |\n+------------------------+\n`\n\nIncorrect order, so no match:\n\n`sql\nSELECT '']Maria'' REGEXP ''[a]]'';\n+------------------------+\n| '']Maria'' REGEXP ''[a]]'' |\n+------------------------+\n|                      0 |\n+------------------------+\n`\n\nThe - character can also be matched in the same way:\n\n`sql\nSELECT ''-Maria'' REGEXP ''[1-10]'';\n+--------------------------+\n| ''-Maria'' REGEXP ''[1-10]'' |\n+--------------------------+\n|                        0 |\n+--------------------------+\n\nSELECT ''-Maria'' REGEXP ''[-1-10]'';\n+---------------------------+\n| ''-Maria'' REGEXP ''[-1-10]'' |\n+---------------------------+\n|                         1 |\n+---------------------------+\n`\n\nWord boundaries\n\nThe :<: and :>: patterns match the beginning and the end of a word respectively. For example:\n\n`sql\nSELECT ''How do I upgrade MariaDB?'' REGEXP ''[[:<:]]MariaDB[[:>:]]'';\n+------------------------------------------------------------+\n| ''How do I upgrade MariaDB?'' REGEXP ''[[:<:]]MariaDB[[:>:]]'' |\n+------------------------------------------------------------+\n|                                                          1 |\n+------------------------------------------------------------+\n\nSELECT ''How do I upgrade MariaDB?'' REGEXP ''[[:<:]]Maria[[:>:]]'';\n+----------------------------------------------------------+\n| ''How do I upgrade MariaDB?'' REGEXP ''[[:<:]]Maria[[:>:]]'' |\n+----------------------------------------------------------+\n|                                                        0 |\n+----------------------------------------------------------+\n`\n\nCharacter Classes\n\nThere are a number of shortcuts to match particular preset character classes. These are matched with the [:character_class:] pattern (inside a [] set). The following character classes exist:\n\n| Character Class | Description                              |\n| --------------- | ---------------------------------------- |\n| alnum           | Alphanumeric                             |\n| alpha           | Alphabetic                               |\n| blank           | Whitespace                               |\n| cntrl           | Control characters                       |\n| digit           | Digits                                   |\n| graph           | Graphic characters                       |\n| lower           | Lowercase alphabetic                     |\n| print           | Graphic or space characters              |\n| punct           | Punctuation                              |\n| space           | Space, tab, newline, and carriage return |\n| upper           | Uppercase alphabetic                     |\n| xdigit          | Hexadecimal digit                        |\n\nFor example:\n\n`sql\nSELECT ''Maria'' REGEXP ''Mar[[:alnum:]]'';\n+--------------------------------+\n| ''Maria'' REGEXP ''Mar[:alnum:]'' |\n+--------------------------------+\n|                              1 |\n+--------------------------------+\n`\n\nRemember that matches are by default case-insensitive, unless a binary string is used, so the following example, specifically looking for an uppercase, counter-intuitively matches a lowercase character:\n\n`sql\nSELECT ''Mari'' REGEXP ''Mar[[:upper:]]+'';\n+---------------------------------+\n| ''Mari'' REGEXP ''Mar[[:upper:]]+'' |\n+---------------------------------+\n|                               1 |\n+---------------------------------+\n\nSELECT BINARY ''Mari'' REGEXP ''Mar[[:upper:]]+'';\n+----------------------------------------+\n| BINARY ''Mari'' REGEXP ''Mar[[:upper:]]+'' |\n+----------------------------------------+\n|                                      0 |\n+----------------------------------------+\n`\n\nCharacter Names\n\nThere are also number of shortcuts to match particular preset character names. These are matched with the [.character.] pattern (inside a [] set). The following character classes exist:\n\n| Name                 | Character |\n| -------------------- | --------- |\n| NUL                  | 0         |\n| SOH                  | 001       |\n| STX                  | 002       |\n| ETX                  | 003       |\n| EOT                  | 004       |\n| ENQ                  | 005       |\n| ACK                  | 006       |\n| BEL                  | 007       |\n| alert                | 007       |\n| BS                   | 010       |\n| backspace            | ''\\b''      |\n| HT                   | 011       |\n| tab                  | ''\\t''      |\n| LF                   | 012       |\n| newline              | ''\\n''      |\n| VT                   | 013       |\n| vertical-tab         | ''\\v''      |\n| FF                   | 014       |\n| form-feed            | ''\\f''      |\n| CR                   | 015       |\n| carriage-return      | ''\\r''      |\n| SO                   | 016       |\n| SI                   | 017       |\n| DLE                  | 020       |\n| DC1                  | 021       |\n| DC2                  | 022       |\n| DC3                  | 023       |\n| DC4                  | 024       |\n| NAK                  | 025       |\n| SYN                  | 026       |\n| ETB                  | 027       |\n| CAN                  | 030       |\n| EM                   | 031       |\n| SUB                  | 032       |\n| ESC                  | 033       |\n| IS4                  | 034       |\n| FS                   | 034       |\n| IS3                  | 035       |\n| GS                   | 035       |\n| IS2                  | 036       |\n| RS                   | 036       |\n| IS1                  | 037       |\n| US                   | 037       |\n| space                | '' ''       |\n| exclamation-mark     | ''!''       |\n| quotation-mark       | ''"''       |\n| number-sign          | ''#''       |\n| dollar-sign          | ''$''       |\n| percent-sign         | ''%''       |\n| ampersand            | ''&''       |\n| apostrophe           | ''''''       |\n| left-parenthesis     | ''(''       |\n| right-parenthesis    | '')''       |\n| asterisk             | ''\\''      |\n| plus-sign            | ''+''       |\n| comma                | '',''       |\n| hyphen               | ''-''       |\n| hyphen-minus         | ''-''       |\n| period               | ''.''       |\n| full-stop            | ''.''       |\n| slash                | ''/''       |\n| solidus              | ''/''       |\n| zero                 | ''0''       |\n| one                  | ''1''       |\n| two                  | ''2''       |\n| three                | ''3''       |\n| four                 | ''4''       |\n| five                 | ''5''       |\n| six                  | ''6''       |\n| seven                | ''7''       |\n| eight                | ''8''       |\n| nine                 | ''9''       |\n| colon                | '':''       |\n| semicolon            | '';''       |\n| less-than-sign       | ''<''       |\n| equals-sign          | ''=''       |\n| greater-than-sign    | ''>''       |\n| question-mark        | ''?''       |\n| commercial-at        | ''@''       |\n| left-square-bracket  | ''\\[''      |\n| backslash            | ''''        |\n| reverse-solidus      | ''''        |\n| right-square-bracket | '']''\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/regular-expressions-overview');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (460, 37, 'RLIKE', 'Syntax\n------\n\nexpr REGEXP pat, expr RLIKE pat\n\nDescription\n-----------\n\nRLIKE is a synonym for REGEXP.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/rlike', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/regular-expressions-functions/rlike');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (461, 37, 'REPEAT Function', 'Syntax\n------\n\nREPEAT(str,count)\n\nDescription\n-----------\n\nReturns a string consisting of the string str repeated count times. Ifcount is less than 1, returns an empty string. Returns NULL if str orcount are NULL.\n\nExamples\n--------\n\nSELECT QUOTE(REPEAT(''MariaDB '',4));\n+------------------------------------+\n| QUOTE(REPEAT(''MariaDB '',4))        |\n+------------------------------------+\n| ''MariaDB MariaDB MariaDB MariaDB '' |\n+------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/repeat-function', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/repeat-function');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (462, 37, 'REPLACE Function', 'Syntax\n------\n\nREPLACE(str,from_str,to_str)\n\nDescription\n-----------\n\nReturns the string str with all occurrences of the string from_str replaced by the string to_str. REPLACE() performs a case-sensitive match when searching for from_str. If any argument is NULL, the function returns NULL.\n\nExamples\n--------\n\nSELECT REPLACE(''www.mariadb.org'', ''w'', ''Ww'');\n+---------------------------------------+\n| REPLACE(''www.mariadb.org'', ''w'', ''Ww'') |\n+---------------------------------------+\n| WwWwWw.mariadb.org                    |\n+---------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/replace-function', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/replace-function');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (463, 37, 'REVERSE', 'Syntax\n------\n\nREVERSE(str)\n\nDescription\n-----------\n\nReturns the string str with the order of the characters reversed. If the input string is NULL, the function returns NULL.\n\nExamples\n--------\n\nSELECT REVERSE(''desserts'');\n+---------------------+\n| REVERSE(''desserts'') |\n+---------------------+\n| stressed            |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/reverse', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/reverse');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (464, 37, 'RIGHT', 'Syntax\n------\n\nRIGHT(str,len)\n\nDescription\n-----------\n\nReturns the rightmost _len_ characters from the string _str_, or NULL if any argument is NULL.\n\nExamples\n--------\n\nSELECT RIGHT(''MariaDB'', 2);\n+---------------------+\n| RIGHT(''MariaDB'', 2) |\n+---------------------+\n| DB                  |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/right', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/right');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (465, 37, 'RPAD', 'Syntax\n------\n\nRPAD(str, len [, padstr])\n\nDescription\n-----------\n\nReturns the string str, right-padded with the string padstr to a length of len characters. If str is longer than len, the return value is shortened to len characters. If padstr is omitted, the RPAD function pads spaces.\n\nReturns NULL if given a NULL argument. If the result is empty (a length of zero), returns either an empty string, or, with SQL_MODE=Oracle, NULL.\n\nThe Oracle mode version of the function can be accessed outside of Oracle mode by using RPAD_ORACLE as the function name.\n\nExamples\n--------\n\nSELECT RPAD(''hello'',10,''.'');\n+----------------------+\n| RPAD(''hello'',10,''.'') |\n+----------------------+\n| hello.....           |\n+----------------------+\n\nSELECT RPAD(''hello'',2,''.'');\n+---------------------+\n| RPAD(''hello'',2,''.'') |\n+---------------------+\n| he                  |\n+---------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/rpad', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/rpad');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (466, 37, 'RTRIM', 'Syntax\n------\n\nRTRIM(str)\n\nDescription\n-----------\n\nReturns the string str with trailing space characters removed.\n\nReturns NULL if given a NULL argument. If the result is empty, returns either an empty string, or, with SQL_MODE=Oracle, NULL.\n\nThe Oracle mode version of the function can be accessed outside of Oracle mode by using RTRIM_ORACLE as the function name.\n\nExamples\n--------\n\nSELECT QUOTE(RTRIM(''MariaDB    ''));\n+-----------------------------+\n| QUOTE(RTRIM(''MariaDB    '')) |\n+-----------------------------+\n| ''MariaDB''                   |\n+-----------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/rtrim', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/rtrim');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (467, 37, 'SFORMAT', 'Description\n-----------\n\nThe SFORMAT function takes an input string and a formatting specification and returns the string formatted using the rules the user passed in the specification.\n\nIt uses the fmtlib library for Python-like (as well as Rust, C++20, etc) string formatting.\n\nOnly fmtlib 7.0.0+ is supported.\n\nThere is no native support for temporal and decimal values:\n\n TIME_RESULT is handled as STRING_RESULT.\n DECIMAL_RESULT is handled as REAL_RESULT.\n\nExamples\n--------\n\nSELECT SFORMAT("The answer is {}.", 42);\n+----------------------------------+\n| SFORMAT("The answer is {}.", 42) |\n+----------------------------------+\n| The answer is 42.                |\n+----------------------------------+\n\nCREATE TABLE test_sformat(mdb_release char(6), mdev int, feature char(20));\n\nINSERT INTO test_sformat VALUES(''10.7.0'', 25015, ''Python style sformat''), \n  (''10.7.0'', 4958, ''UUID'');\n\nSELECT * FROM test_sformat;\n+-------------+-------+----------------------+\n| mdb_release | mdev  | feature              |\n+-------------+-------+----------------------+\n| 10.7.0      | 25015 | Python style sformat |\n| 10.7.0      |  4958 | UUID                 |\n+-------------+-------+----------------------+\n\nSELECT SFORMAT(''MariaDB Server {} has a preview for MDEV-{} which is about {}'', \n  mdb_release, mdev, feature) AS ''Preview Release Examples''\n  FROM test_sformat;\n+----------------------------------------------------------------------------------------+\n| Preview Release Examples                                                               |\n+----------------------------------------------------------------------------------------+\n| MariaDB Server 10.7.0 has a preview for MDEV-25015 which is about Python style sformat |\n| MariaDB Server 10.7.0 has a preview for MDEV-4958 which is about UUID                  |\n+----------------------------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/sformat', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/sformat');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (468, 37, 'SOUNDEX', 'Syntax\n------\n\nSOUNDEX(str)\n\nDescription\n-----------\n\nReturns a soundex string from _str_. Two strings that sound almost the same should have identical soundex strings. A standard soundex string is four characters long, but the SOUNDEX() function returns an arbitrarily long string. You can use SUBSTRING() on the result to get a standard soundex string. All non-alphabetic characters in _str_ are ignored. All international alphabetic characters outside the A-Z range are treated as vowels.\n\nImportant: When using SOUNDEX(), you should be aware of the following details:\n\n This function, as currently implemented, is intended to work well with strings that are in the English language only. Strings in other languages may not produce reasonable results.\n This function implements the original Soundex algorithm, not the more popular enhanced version (also described by D. Knuth). The difference is that original version discards vowels first and duplicates second, whereas the enhanced version discards duplicates first and vowels second.\n\nExamples\n--------\n\nSOUNDEX(''Hello'');\n+------------------+\n| SOUNDEX(''Hello'') |\n+------------------+\n| H400             |\n+------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/soundex', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/soundex');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (469, 37, 'SOUNDS LIKE', 'Syntax\n------\n\nexpr1 SOUNDS LIKE expr2\n\nDescription\n-----------\n\nThis is the same as SOUNDEX(expr1) = SOUNDEX(expr2).\n\nExamples\n--------\n\nSELECT givenname, surname FROM users WHERE givenname SOUNDS LIKE "robert";\n+-----------+---------+\n| givenname | surname |\n+-----------+---------+\n| Roberto   | Castro  |\n+-----------+---------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/sounds-like', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/sounds-like');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (470, 37, 'SPACE', 'Syntax\n------\n\nSPACE(N)\n\nDescription\n-----------\n\nReturns a string consisting of _N_ space characters. If N is NULL, returns NULL.\n\nExamples\n--------\n\nSELECT QUOTE(SPACE(6));\n+-----------------+\n| QUOTE(SPACE(6)) |\n+-----------------+\n| ''      ''        |\n+-----------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/space', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/space');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (471, 37, 'STRCMP', 'Syntax\n------\n\nSTRCMP(expr1,expr2)\n\nDescription\n-----------\n\nSTRCMP() returns 0 if the strings are the same, -1 if the first argument is smaller than the second according to the current sort order, and 1 if the strings are otherwise not the same. Returns NULL is either argument is NULL.\n\nExamples\n--------\n\nSELECT STRCMP(''text'', ''text2'');\n+-------------------------+\n| STRCMP(''text'', ''text2'') |\n+-------------------------+\n|                      -1 |\n+-------------------------+\n\nSELECT STRCMP(''text2'', ''text'');\n+-------------------------+\n| STRCMP(''text2'', ''text'') |\n+-------------------------+\n|                       1 |\n+-------------------------+\n\nSELECT STRCMP(''text'', ''text'');\n+------------------------+\n| STRCMP(''text'', ''text'') |\n+------------------------+\n|                      0 |\n+------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/strcmp', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/strcmp');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (472, 37, 'SUBSTR', 'Description\n-----------\n\nSUBSTR() is a synonym for SUBSTRING().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/substr', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/substr');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (473, 37, 'SUBSTRING', 'Description\n-----------\n\nThe forms without a _len_ argument return a substring from string _str_ starting at position _pos_.\n\nThe forms with a _len_ argument return a substring _len_ characters long from string _str_, starting at position _pos_.\n\nThe forms that use _FROM_ are standard SQL syntax.\n\nIt is also possible to use a negative value for _pos_. In this case, the beginning of the substring is _pos_ characters from the end of the string, rather than the beginning. A negative value may be used for _pos_ in any of the forms of this function.\n\nBy default, the position of the first character in the string from which the substring is to be extracted is 1. If the value of _pos_ is 0, the result is empty string. For Oracle compatibility, when sql_mode is set to ''oracle'', position 0 is treated as position 1.\n\nIf any argument is NULL, returns NULL.\n\nThe optimizer can make use of an index for conditions like SUBSTR(indexed_column, 1, n) = const_string.\n\nThe optimizer cannot make use of an index if an indexed column is an argument of SUBSTR().\n\nExamples\n--------\n\nSELECT SUBSTRING(''Knowledgebase'',5);\n+------------------------------+\n| SUBSTRING(''Knowledgebase'',5) |\n+------------------------------+\n| ledgebase                    |\n+------------------------------+\n\nSELECT SUBSTRING(''MariaDB'' FROM 6);\n+-----------------------------+\n| SUBSTRING(''MariaDB'' FROM 6) |\n+-----------------------------+\n| DB                          |\n+-----------------------------+\n\nSELECT SUBSTRING(''Knowledgebase'',3,7);\n+--------------------------------+\n| SUBSTRING(''Knowledgebase'',3,7) |\n+--------------------------------+\n| owledge                        |\n+--------------------------------+\n\nSELECT SUBSTRING(''Knowledgebase'', -4);\n+--------------------------------+\n| SUBSTRING(''Knowledgebase'', -4) |\n+--------------------------------+\n| base                           |\n+--------------------------------+\n\nSELECT SUBSTRING(''Knowledgebase'', 0);\n+--------------------------------+\n| SUBSTRING(''Knowledgebase'', 0)  |\n+--------------------------------+\n|                                |\n+--------------------------------+\n\nSELECT SUBSTRING(''Knowledgebase'', -8, 4);\n+-----------------------------------+\n| SUBSTRING(''Knowledgebase'', -8, 4) |\n+-----------------------------------+\n| edge                              |\n+-----------------------------------+\n\nSELECT SUBSTRING(''Knowledgebase'' FROM -8 FOR 4);\n+------------------------------------------+\n| SUBSTRING(''Knowledgebase'' FROM -8 FOR 4) |\n+------------------------------------------+\n| edge                                     |\n+------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/substring', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/substring');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (474, 37, 'SUBSTRING\\_INDEX', 'Syntax\n------\n\nSUBSTRING_INDEX(str,delim,count)\n\nDescription\n-----------\n\nReturns the substring from string _str_ before count occurrences of the delimiter _delim_. If _count_ is positive, everything to the left of the final delimiter (counting from the left) is returned. If _count_ is negative, everything to the right of the final delimiter (counting from the right) is returned. SUBSTRING_INDEX() performs a case-sensitive match when searching for _delim_.\n\nIf any argument is NULL, returns NULL.\n\nFor example:\n\n``sql\nSUBSTRING_INDEX(''www.mariadb.org'', ''.'', 2)\n``\n\nIt means "Return all of the characters up to the 2nd occurrence of ."\n\nExamples\n--------\n\nSELECT SUBSTRING_INDEX(''www.mariadb.org'', ''.'', 2);\n+--------------------------------------------+\n| SUBSTRING_INDEX(''www.mariadb.org'', ''.'', 2) |\n+--------------------------------------------+\n| www.mariadb                                |\n+--------------------------------------------+\n\nSELECT SUBSTRING_INDEX(''www.mariadb.org'', ''.'', -2);\n+---------------------------------------------+\n| SUBSTRING_INDEX(''www.mariadb.org'', ''.'', -2) |\n+---------------------------------------------+\n| mariadb.org                                 |\n+---------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/substring_index', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/substring_index');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (475, 37, 'TO\\_BASE64', 'Syntax\n------\n\nTO_BASE64(str)\n\nDescription\n-----------\n\nConverts the string argument str to its base-64 encoded form, returning the result as a character string in the connection character set and collation.\n\nThe argument str will be converted to string first if it is not a string. A NULL argument will return a NULL result.\n\nThe reverse function, FROM_BASE64(), decodes an encoded base-64 string.\n\nThere are a numerous different methods to base-64 encode a string. The following are used by MariaDB and MySQL:\n\n Alphabet value 64 is encoded as ''+''.\n Alphabet value 63 is encoded as ''/''.\n Encoding output is made up of groups of four printable characters, with each three bytes of data encoded using four characters. If the final group is not complete, it is padded with ''='' characters to make up a length of four.\n To divide long output, a newline is added after every 76 characters.\n* Decoding will recognize and ignore newlines, carriage returns, tabs, and spaces.\n\nExamples\n--------\n\nSELECT TO_BASE64(''Maria'');\n+--------------------+\n| TO_BASE64(''Maria'') |\n+--------------------+\n| TWFyaWE=           |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/to_base64', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/to_base64');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (476, 37, 'TO\\_CHAR', 'Syntax\n------\n\nTO_CHAR(expr[, fmt])\n\nDescription\n-----------\n\nThe TO_CHAR function converts an _expr_ of type date, datetime, time or timestamp to a string. The optional _fmt_ argument supports YYY/YYY/YY/RRRR/RR/MM/MON/MONTH/MI/DD/DY/HH/HH12/HH24/SS and special characters. The default value is YYYY-MM-DD HH24:MI:SS. TO_CHAR also accepts FM in the format string, which disables padding of all components following it.\n\nFM can be specified multiple times, with each time disabling the previous state:\n\n An odd number of FMs disables padding.\n An even number of FMs enables padding.\n\nThese additional formats (for _fmt_) are available:\n\n FF[1-6] – Fractional seconds\n DDD – Day (1-366)\n IW – Week 1-53 according to ISO 8601\n I – 1-digit year according to ISO 8601\n IY – 2-digit year according to ISO 8601\n IYY – 3-digit year according to ISO 8601\n IYYY – 4-digit year according to ISO 8601\n SYYY – 4-digit year according to ISO 8601 (Oracle can use signed years)\n\nThe TO_CHAR function converts an _expr_ of type date, datetime, time or timestamp to a string. The optional _fmt_ argument supports YYY/YYY/YY/RRRR/RR/MM/MON/MONTH/MI/DD/DY/HH/HH12/HH24/SS and special characters. The default value is YYYY-MM-DD HH24:MI:SS. TO_CHAR also accepts FM in the format string, which disables padding of all components following it.\n\nFM can be specified multiple times, with each time disabling the previous state:\n\n An odd number of FMs disables padding.\n An even number of FMs enables padding.\n\nThe TO_CHAR function converts an _expr_ of type date, datetime, time or timestamp to a string. The optional _fmt_ argument supports YYY/YYY/YY/RRRR/RR/MM/MON/MONTH/MI/DD/DY/HH/HH12/HH24/SS and special characters. The default value is YYYY-MM-DD HH24:MI:SS.\n\nIn Oracle, TO_CHAR can also be used to convert numbers to strings, but this is not supported in MariaDB and gives an error.\n\nExamples\n--------\n\nSELECT TO_CHAR(''1980-01-11 04:50:39'', ''YYYY-MM-DD'');\n+----------------------------------------------+\n| TO_CHAR(''1980-01-11 04:50:39'', ''YYYY-MM-DD'') |\n+----------------------------------------------+\n| 1980-01-11                                   |\n+----------------------------------------------+\n\nSELECT TO_CHAR(''1980-01-11 04:50:39'', ''HH24-MI-SS'');\n+----------------------------------------------+\n| TO_CHAR(''1980-01-11 04:50:39'', ''HH24-MI-SS'') |\n+----------------------------------------------+\n| 04-50-39                                     |\n+----------------------------------------------+\n\nSELECT TO_CHAR(''00-01-01 00:00:00'', ''YY-MM-DD HH24:MI:SS'');\n+-----------------------------------------------------+\n| TO_CHAR(''00-01-01 00:00:00'', ''YY-MM-DD HH24:MI:SS'') |\n+-----------------------------------------------------+\n| 00-01-01 00:00:00                                   |\n+-----------------------------------------------------+\n\nSELECT TO_CHAR(''99-12-31 23:59:59'', ''YY-MM-DD HH24:MI:SS'');\n+-----------------------------------------------------+\n| TO_CHAR(''99-12-31 23:59:59'', ''YY-MM-DD HH24:MI:SS'') |\n+-----------------------------------------------------+\n| 99-12-31 23:59:59                                   |\n+-----------------------------------------------------+\n\nSELECT TO_CHAR(''9999-12-31 23:59:59'', ''YY-MM-DD HH24:MI:SS'');\n+-------------------------------------------------------+\n| TO_CHAR(''9999-12-31 23:59:59'', ''YY-MM-DD HH24:MI:SS'') |\n+-------------------------------------------------------+\n| 99-12-31 23:59:59                                     |\n+-------------------------------------------------------+\n\nSELECT TO_CHAR(''21-01-03 08:30:00'', ''Y-MONTH-DY HH:MI:SS'');\n+-----------------------------------------------------+\n| TO_CHAR(''21-01-03 08:30:00'', ''Y-MONTH-DY HH:MI:SS'') |\n+-----------------------------------------------------+\n| 1-January  -Sun 08:30:00                            |\n+-----------------------------------------------------+\n\nFrom MariaDB 12.0, FM removes following padding:\n\nSELECT CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''DAY''), ''/'');\n+---------------------------------------------------------+\n| CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''DAY''), ''/'') |\n+---------------------------------------------------------+\n| /Monday   /                                             |\n+---------------------------------------------------------+\n\nSELECT CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''FMDAY''), ''/'');\n+-----------------------------------------------------------+\n| CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''FMDAY''), ''/'') |\n+-----------------------------------------------------------+\n| /Monday/                                                  |\n+-----------------------------------------------------------+\n\nEven numbers of FM enable padding, while odd numbers disable it:\n\nSELECT CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''FMFMDAY''), ''/'');\n+-------------------------------------------------------------+\n| CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''FMFMDAY''), ''/'') |\n+-------------------------------------------------------------+\n| /Monday   /                                                 |\n+-------------------------------------------------------------+\n\nSELECT CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''FMFMFMDAY''), ''/'');\n+---------------------------------------------------------------+\n| CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''FMFMFMDAY''), ''/'') |\n+---------------------------------------------------------------+\n| /Monday/                                                      |\n+---------------------------------------------------------------+\n\nFM only suppresses following padding:\n\nSELECT CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''DAYFM''), ''/'');\n+-----------------------------------------------------------+\n| CONCAT(''/'', TO_CHAR(''2020-01-06 10:11:12'', ''DAYFM''), ''/'') |\n+-----------------------------------------------------------+\n| /Monday   /                                               |\n+-----------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/to_char', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/to_char');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (477, 37, 'TRIM', 'Syntax\n------\n\nTRIM_ORACLE([{BOTH | LEADING | TRAILING} [remstr] FROM] str), TRIM([remstr FROM] str)\n\nDescription\n-----------\n\nReturns the string str with all remstr prefixes or suffixes removed. If none of the specifiers BOTH, LEADING, or TRAILING is given, BOTH is assumed. remstr is optional and, if not specified, spaces are removed.\n\nReturns NULL if given a NULL argument. If the result is empty, returns either an empty string, or, with SQL_MODE=Oracle, NULL. SQL_MODE=Oracle is not set by default.\n\nThe Oracle mode version of the function can be accessed in any mode by using TRIM_ORACLE as the function name.\n\nExamples\n--------\n\nSELECT TRIM(''  bar   '')\\G\n************************ 1. row *********************\nTRIM(''  bar   ''): bar\n\nSELECT TRIM(LEADING ''x'' FROM ''xxxbarxxx'')\\G\n********************* 1. row *********************\nTRIM(LEADING ''x'' FROM ''xxxbarxxx''): barxxx\n\nSELECT TRIM(BOTH ''x'' FROM ''xxxbarxxx'')\\G\n********************* 1. row *********************\nTRIM(BOTH ''x'' FROM ''xxxbarxxx''): bar\n\nSELECT TRIM(TRAILING ''xyz'' FROM ''barxxyz'')\\G\n********************* 1. row ************************\nTRIM(TRAILING ''xyz'' FROM ''barxxyz''): barx\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/trim', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/trim');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (478, 37, 'TRIM\\_ORACLE', 'Description\n-----------\n\nTRIM_ORACLE is a synonym for the Oracle mode version of the TRIM function, and is available in all modes.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/trim_oracle', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/trim_oracle');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (479, 37, 'Type Conversion', 'Description\n-----------\n\nImplicit type conversion takes place when MariaDB is using operands or different types, in order to make the operands compatible.\n\nIt is best practice not to rely upon implicit conversion; rather use CAST to explicitly convert types.\n\nRules for Conversion on Comparison\n\n If either argument is NULL, the result of the comparison is NULL unless the NULL-safe <=> equality comparison operator is used.\n If both arguments are integers, they are compared as integers.\n If both arguments are strings, they are compared as strings.\n If one argument is decimal and the other argument is decimal or integer, they are compared as decimals.\n If one argument is decimal and the other argument is a floating point, they are compared as floating point values.\n If one argument is string and the other argument is integer, they are compared as decimals.\n If a hexadecimal argument is not compared to a number, it is treated as a binary string.\n If a constant is compared to a TIMESTAMP or DATETIME, the constant is converted to a timestamp, unless used as an argument to the IN function.\n In other cases, arguments are compared as floating point, or real, numbers.\n\nNote that if a string column is being compared with a numeric value, MariaDB will not use the index on the column, as there are numerous alternatives that may evaluate as equal (see examples below).\n\nComparison Examples\n\nConverting a string to a number:\n\n``sql\nSELECT 15+''15'';\n+---------+\n| 15+''15'' |\n+---------+\n|      30 |\n+---------+\n`\n\nConverting a number to a string:\n\n`sql\nSELECT CONCAT(15,''15'');\n+-----------------+\n| CONCAT(15,''15'') |\n+-----------------+\n| 1515            |\n+-----------------+\n`\n\nFloating point number errors:\n\n`sql\nSELECT ''9746718491924563214'' = 9746718491924563213;\n+---------------------------------------------+\n| ''9746718491924563214'' = 9746718491924563213 |\n+---------------------------------------------+\n|                                           1 |\n+---------------------------------------------+\n`\n\nNumeric equivalence with strings:\n\n`sql\nSELECT ''5'' = 5;\n+---------+\n| ''5'' = 5 |\n+---------+\n|       1 |\n+---------+\n\nSELECT ''   5'' = 5;\n+------------+\n| ''   5'' = 5 |\n+------------+\n|          1 |\n+------------+\n\nSELECT ''   5  '' = 5;\n+--------------+\n| ''   5  '' = 5 |\n+--------------+\n|            1 |\n+--------------+\n1 row in set, 1 warning (0.000 sec)\n\nSHOW WARNINGS;\n+-------+------+--------------------------------------------+\n| Level | Code | Message                                    |\n+-------+------+--------------------------------------------+\n| Note  | 1292 | Truncated incorrect DOUBLE value: ''   5  '' |\n+-------+------+--------------------------------------------+\n`\n\nAs a result of the above, MariaDB cannot use the index when comparing a string with a numeric value in the example below:\n\n`sql\nCREATE TABLE t (a VARCHAR(10), b VARCHAR(10), INDEX idx_a (a));\n\nINSERT INTO t VALUES \n  (''1'', ''1''), (''2'', ''2''), (''3'', ''3''), \n  (''4'', ''4''), (''5'', ''5''), (''1'', ''5'');\n\nEXPLAIN SELECT  FROM t WHERE a = ''3'' \\G\n************************ 1. row ***********************\n           id: 1\n  select_type: SIMPLE\n        table: t\n         type: ref\npossible_keys: idx_a\n          key: idx_a\n      key_len: 13\n          ref: const\n         rows: 1\n        Extra: Using index condition\n\nEXPLAIN SELECT  FROM t WHERE a = 3 \\G\n************************ 1. row ***********************\n           id: 1\n  select_type: SIMPLE\n        table: t\n         type: ALL\npossible_keys: idx_a\n          key: NULL\n      key_len: NULL\n          ref: NULL\n         rows: 6\n        Extra: Using where\n`\n\nRules for Conversion on Dyadic Arithmetic Operations\n\nImplicit type conversion also takes place on dyadic arithmetic operations (+,-,\\,/). MariaDB chooses the minimum data type that is guaranteed to fit the result and converts both arguments to the result data type.\n\nFor addition (+), subtraction (-) and multiplication (\\), the result data type is chosen as follows:\n\n If either of the arguments is an approximate number (float, double), the result is double.\n If either of the arguments is a string (char, varchar, text), the result is double.\n If either of the arguments is a decimal number, the result is decimal.\n If either of the arguments is of a temporal type with a non-zero fractional second precision (time(N), datetime(N), timestamp(N)), the result is decimal.\n If either of the arguments is of a temporal type with a zero fractional second precision (time(0), date, datetime(0), timestamp(0)), the result may vary between int, int unsigned, bigint or bigint unsigned, depending on the exact data type combination.\n If both arguments are integer numbers (tinyint, smallint, mediumint, bigint), the result may vary between int, int unsigned, bigint or bigint unsigned, depending of the exact data types and their signs.\n\nFor division (/), the result data type is chosen as follows:\n\n If either of the arguments is an approximate number (float, double), the result is double.\n If either of the arguments is a string (char, varchar, text), the result is double.\n Otherwise, the result is decimal.\n\nArithmetic Examples\n\nNote, the above rules mean that when an argument of a temporal data type appears in addition or subtraction, it''s treated as a number by default.\n\n`sql\nSELECT TIME''10:20:30'' + 1;\n+--------------------+\n| TIME''10:20:30'' + 1 |\n+--------------------+\n|             102031 |\n+--------------------+\n`\n\nIn order to do temporal addition or subtraction instead, use the DATE_ADD() or DATE_SUB() functions, or an INTERVAL expression as the second argument:\n\n`sql\nSELECT TIME''10:20:30'' + INTERVAL 1 SECOND;\n+------------------------------------+\n| TIME''10:20:30'' + INTERVAL 1 SECOND |\n+------------------------------------+\n| 10:20:31                           |\n+------------------------------------+\n`\n\n`sql\nSELECT "2.2" + 3;\n+-----------+\n| "2.2" + 3 |\n+-----------+\n|       5.2 |\n+-----------+\n\nSELECT 2.2 + 3;\n+---------+\n| 2.2 + 3 |\n+---------+\n| 5.2     |\n+---------+\n\nSELECT 2.2 / 3;\n+---------+\n| 2.2 / 3 |\n+---------+\n| 0.73333 |\n+---------+\n\nSELECT "2.2" / 3;\n+--------------------+\n| "2.2" / 3          |\n+--------------------+\n| 0.7333333333333334 |\n+--------------------+\n``\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/type-conversion', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/type-conversion');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (480, 37, 'UCASE', 'Syntax\n------\n\nUCASE(str)\n\nDescription\n-----------\n\nUCASE() is a synonym for UPPER().\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/ucase', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/ucase');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (481, 37, 'UNHEX', 'Syntax\n------\n\nUNHEX(str)\n\nDescription\n-----------\n\nPerforms the inverse operation of HEX(str). That is, it interprets each pair of hexadecimal digits in the argument as a number and converts it to the character represented by the number. The resulting\\\ncharacters are returned as a binary string.\n\nIf str is NULL, UNHEX() returns NULL.\n\nExamples\n--------\n\nSELECT HEX(''MariaDB'');\n+----------------+\n| HEX(''MariaDB'') |\n+----------------+\n| 4D617269614442 |\n+----------------+\n\nSELECT UNHEX(''4D617269614442'');\n+-------------------------+\n| UNHEX(''4D617269614442'') |\n+-------------------------+\n| MariaDB                 |\n+-------------------------+\n\nSELECT 0x4D617269614442;\n+------------------+\n| 0x4D617269614442 |\n+------------------+\n| MariaDB          |\n+------------------+\n\nSELECT UNHEX(HEX(''string''));\n+----------------------+\n| UNHEX(HEX(''string'')) |\n+----------------------+\n| string               |\n+----------------------+\n\nSELECT HEX(UNHEX(''1267''));\n+--------------------+\n| HEX(UNHEX(''1267'')) |\n+--------------------+\n| 1267               |\n+--------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/unhex', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/unhex');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (482, 37, 'UPDATEXML', 'Syntax\n------\n\nUpdateXML(xml_target, xpath_expr, new_xml)\n\nDescription\n-----------\n\nThis function replaces a single portion of a given fragment of XML markupxml_target with a new XML fragment new_xml, and then returns the changed XML. The portion of xml_target that is replaced matches an XPath expression xpath_expr supplied by the user. If no expression matching xpath_expr is found, or if multiple matches are found, the function returns the original xml_target XML fragment. All three arguments should be strings.\n\nExamples\n--------\n\nSELECT\n    UpdateXML(''<a><b>ccc</b><d></d></a>'', ''/a'', ''<e>fff</e>'') AS val1,\n    UpdateXML(''<a><b>ccc</b><d></d></a>'', ''/b'', ''<e>fff</e>'') AS val2,\n    UpdateXML(''<a><b>ccc</b><d></d></a>'', ''//b'', ''<e>fff</e>'') AS val3,\n    UpdateXML(''<a><b>ccc</b><d></d></a>'', ''/a/d'', ''<e>fff</e>'') AS val4,\n    UpdateXML(''<a><d></d><b>ccc</b><d></d></a>'', ''/a/d'', ''<e>fff</e>'') AS val5\n    \\G\n************************ 1. row ************************\nval1: <e>fff</e>\nval2: <a><b>ccc</b><d></d></a>\nval3: <a><e>fff</e><d></d></a>\nval4: <a><b>ccc</b><e>fff</e></a>\nval5: <a><d></d><b>ccc</b><d></d></a>\n1 row in set (0.00 sec)\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/updatexml', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/updatexml');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (483, 37, 'UPPER', 'Syntax\n------\n\nUPPER(str)\nUCASE(str)\n\nDescription\n-----------\n\nReturns the string str with all characters changed to uppercase according to the current character set mapping. The default is latin1 (cp1252 West European).\nThe result may depend on the collation and character set used.\nUCASE is a synonym.\n\n``sql\nSELECT UPPER(surname), givenname FROM users ORDER BY surname;\n+----------------+------------+\n| UPPER(surname) | givenname  |\n+----------------+------------+\n| ABEL           | Jacinto    |\n| CASTRO         | Robert     |\n| COSTA          | Phestos    |\n| MOSCHELLA      | Hippolytos |\n+----------------+------------+\n`\n\nUPPER()` is ineffective when applied to binary strings (BINARY, VARBINARY, BLOB). The description of LOWER() shows how to perform lettercase conversion of binary strings.\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/upper', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/upper');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (484, 37, 'WEIGHT\\_STRING', 'Syntax\n------\n\nWEIGHT_STRING(str [AS {CHAR|BINARY}(N)] [LEVEL levels] [flags])\n  levels: N [ASC|DESC|REVERSE] [, N [ASC|DESC|REVERSE]] ...\n\nDescription\n-----------\n\nReturns a binary string representing the string''s sorting and comparison value. A string with a lower result means that for sorting purposes the string appears before a string with a higher result.\n\nWEIGHT_STRING() is particularly useful when adding new collations, for testing purposes.\n\nIf str is a non-binary string (CHAR, VARCHAR or TEXT), WEIGHT_STRING returns the string''s collation weight. If str is a binary string (BINARY, VARBINARY or BLOB), the return value is simply the input value, since the weight for each byte in a binary string is the byte value.\n\nWEIGHT_STRING() returns NULL if given a NULL input.\n\nThe optional AS clause permits casting the input string to a binary or non-binary string, as well as to a particular length.\n\nAS BINARY(N) measures the length in bytes rather than characters, and right pads with 0x00 bytes to the desired length.\n\nAS CHAR(N) measures the length in characters, and right pads with spaces to the desired length.\n\nN has a minimum value of 1, and if it is less than the length of the input string, the string is truncated without warning.\n\nThe optional LEVEL clause specifies that the return value should contain weights for specific collation levels. The levels specifier can either be a single integer, a comma-separated list of integers, or a range of integers separated by a dash (whitespace is ignored). Integers can range from 1 to a maximum of 6, dependent on the collation, and need to be listed in ascending order.\n\nIf the LEVEL clause is no provided, a default of 1 to the maximum for the collation is assumed.\n\nIf the q is specified without using a range, an optional modifier is permitted.\n\nASC, the default, returns the weights without any modification.\n\nDESC returns bitwise-inverted weights.\n\nREVERSE returns the weights in reverse order.\n\nExamples\n--------\n\nSELECT HEX(WEIGHT_STRING(''x''));\n+-------------------------+\n| HEX(WEIGHT_STRING(''x'')) |\n+-------------------------+\n| 0058                    |\n+-------------------------+\n\nSELECT HEX(WEIGHT_STRING(''x'' AS BINARY(4)));\n+--------------------------------------+\n| HEX(WEIGHT_STRING(''x'' AS BINARY(4))) |\n+--------------------------------------+\n| 78000000                             |\n+--------------------------------------+\n\nSELECT HEX(WEIGHT_STRING(''x'' AS CHAR(4)));\n+------------------------------------+\n| HEX(WEIGHT_STRING(''x'' AS CHAR(4))) |\n+------------------------------------+\n| 0058002000200020                   |\n+------------------------------------+\n\nSELECT HEX(WEIGHT_STRING(0xaa22ee LEVEL 1));\n+--------------------------------------+\n| HEX(WEIGHT_STRING(0xaa22ee LEVEL 1)) |\n+--------------------------------------+\n| AA22EE                               |\n+--------------------------------------+\n\nSELECT HEX(WEIGHT_STRING(0xaa22ee LEVEL 1 DESC));\n+-------------------------------------------+\n| HEX(WEIGHT_STRING(0xaa22ee LEVEL 1 DESC)) |\n+-------------------------------------------+\n| 55DD11                                    |\n+-------------------------------------------+\n\nSELECT HEX(WEIGHT_STRING(0xaa22ee LEVEL 1 REVERSE));\n+----------------------------------------------+\n| HEX(WEIGHT_STRING(0xaa22ee LEVEL 1 REVERSE)) |\n+----------------------------------------------+\n| EE22AA                                       |\n+----------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/weight_string', '', 'https://mariadb.com/docs/server/reference/sql-functions/string-functions/weight_string');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (485, 35, 'VEC\\_DISTANCE\\_COSINE', 'Syntax\n------\n\nVEC_DISTANCE_COSINE(v, s)\n\nDescription\n-----------\n\nVEC_Distance_Cosine is an SQL function that calculates the Cosine distance between two (not necessarily normalized) vectors.\n\nVectors must be of the same length. A distance between two vectors of different lengths is not defined, and VEC_Distance_Cosine will return NULL in such cases.\n\nIf the vector index was not built for the cosine function (see CREATE TABLE with Vectors), the index is not used — a full table scan is performed instead. The VEC_DISTANCE function is a generic function that behaves either as VEC_DISTANCE_EUCLIDEAN or VEC_DISTANCE_COSINE, depending on the underlying index type.\n\nExamples\n--------\n\nSELECT VEC_DISTANCE_COSINE(vec_fromtext(''[1,2,3]''), vec_fromtext(''[3,5,7]''));\n+-----------------------------------------------------------------------+\n| VEC_DISTANCE_COSINE(vec_fromtext(''[1,2,3]''), vec_fromtext(''[3,5,7]'')) |\n+-----------------------------------------------------------------------+\n|                                                   0.00258509695694209 |\n+-----------------------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vec_distance_cosine', '', 'https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vec_distance_cosine');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (486, 35, 'VEC\\_DISTANCE\\_EUCLIDEAN', 'Syntax\n------\n\nVEC_DISTANCE_EUCLIDEAN(v, s)\n\nDescription\n-----------\n\nVEC_Distance_Euclidean is an SQL function that calculates a Euclidean (L2) distance between two points.\n\nVectors must be of the same length, a distance between two vectors of different lengths is not defined and VEC_Distance_Euclidean returns NULL in such cases.\n\nIf the vector index was not built for the euclidean function (see CREATE TABLE with Vectors), the index is not used, and a full table scan performed instead. The VEC_DISTANCE function is a generic function that behaves either as VEC_DISTANCE_EUCLIDEAN or VEC_DISTANCE_COSINE, depending on the underlying index type.\n\nExamples\n--------\n\nINSERT INTO v VALUES \n     (1, x''e360d63ebe554f3fcdbc523f4522193f5236083d''),\n     (2, x''f511303f72224a3fdd05fe3eb22a133ffae86a3f''),\n     (3,x''f09baa3ea172763f123def3e0c7fe53e288bf33e''),\n     (4,x''b97a523f2a193e3eb4f62e3f2d23583e9dd60d3f''),\n     (5,x''f7c5df3e984b2b3e65e59d3d7376db3eac63773e''),\n     (6,x''de01453ffa486d3f10aa4d3fdd66813c71cb163f''),\n     (7,x''76edfc3e4b57243f10f8423fb158713f020bda3e''),\n     (8,x''56926c3fdf098d3e2c8c5e3d1ad4953daa9d0b3e''),\n     (9,x''7b713f3e5258323f80d1113d673b2b3f66e3583f''),\n     (10,x''6ca1d43e9df91b3fe580da3e1c247d3f147cf33e'');\n\nSELECT id FROM v \n  ORDER BY VEC_Distance_Euclidean(v, x''6ca1d43e9df91b3fe580da3e1c247d3f147cf33e'');\n+----+\n| id |\n+----+\n| 10 |\n|  7 |\n|  3 |\n|  9 |\n|  2 |\n|  1 |\n|  5 |\n|  4 |\n|  6 |\n|  8 |\n+----+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vec_distance_euclidean', '', 'https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vec_distance_euclidean');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (487, 35, 'VEC\\_FromText', 'Syntax\n------\n\nVEC_FromText(s)\n\nDescription\n-----------\n\nVEC_FromText converts a text representation of the vector (json array of numbers) to a vector (little-endian IEEE float sequence of bytes, 4 bytes per float).\n\nExamples\n--------\n\nSELECT HEX(vec_fromtext(''[1,2,3]'')); \n+------------------------------+\n| HEX(vec_fromtext(''[1,2,3]'')) |\n+------------------------------+\n| 0000803F0000004000004040     |\n+------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vec_fromtext', '', 'https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vec_fromtext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (488, 35, 'VEC\\_ToText', 'Syntax\n------\n\nVEC_ToText(v)\n\nDescription\n-----------\n\nVEC_ToText converts a binary vector into a json array of numbers (floats). Returns NULL and throws a warning Error 4201 if given an invalid vector.\n\nExamples\n--------\n\nSELECT VEC_ToText(x''e360d63ebe554f3fcdbc523f4522193f5236083d'');\n+---------------------------------------------------------+\n| VEC_ToText(x''e360d63ebe554f3fcdbc523f4522193f5236083d'') |\n+---------------------------------------------------------+\n| [0.418708,0.809902,0.823193,0.598179,0.033255]          |\n+---------------------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vec_totext', '', 'https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vec_totext');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (489, 35, 'VEC\\_DISTANCE', 'Syntax\n------\n\nVEC_DISTANCE(v, s)\n\nDescription\n-----------\n\nVEC_DISTANCE is a generic function that behaves either as VEC_DISTANCE_EUCLIDEAN, calculating the Euclidean (L2) distance between two points. Or VEC_DISTANCE_COSINE, calculating the Cosine distance between two vectors, depending on the underlying index type.\n\nIf the underlying index cannot be determined, an error 4206 is returned:\n\n``sql\nERROR 4206 (HY000): Cannot determine distance type for VEC_DISTANCE, index is not found\n``\n\nExamples\n--------\n\nINSERT INTO v VALUES \n     (1, x''e360d63ebe554f3fcdbc523f4522193f5236083d''),\n     (2, x''f511303f72224a3fdd05fe3eb22a133ffae86a3f''),\n     (3,x''f09baa3ea172763f123def3e0c7fe53e288bf33e''),\n     (4,x''b97a523f2a193e3eb4f62e3f2d23583e9dd60d3f''),\n     (5,x''f7c5df3e984b2b3e65e59d3d7376db3eac63773e''),\n     (6,x''de01453ffa486d3f10aa4d3fdd66813c71cb163f''),\n     (7,x''76edfc3e4b57243f10f8423fb158713f020bda3e''),\n     (8,x''56926c3fdf098d3e2c8c5e3d1ad4953daa9d0b3e''),\n     (9,x''7b713f3e5258323f80d1113d673b2b3f66e3583f''),\n     (10,x''6ca1d43e9df91b3fe580da3e1c247d3f147cf33e'');\n\nSELECT id FROM v \n  ORDER BY VEC_DISTANCE(v, x''6ca1d43e9df91b3fe580da3e1c247d3f147cf33e'');\n+----+\n| id |\n+----+\n| 10 |\n|  7 |\n|  3 |\n|  9 |\n|  2 |\n|  1 |\n|  5 |\n|  4 |\n|  6 |\n|  8 |\n+----+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vector-functions-vec_distance', '', 'https://mariadb.com/docs/server/reference/sql-functions/vector-functions/vector-functions-vec_distance');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (490, 35, 'SQL Statements', 'Description\n-----------\n\ndata-definition\n\ndata-manipulation\n\naccount-management-sql-statements\n\nadministrative-sql-statements\n\nsql-functions\n\nprepared-statements\n\nprogrammatic-compound-statements\n\nstored-routines\n\ntable-statements\n\ntransactions\n\ncomment-syntax.md\n\nhelp-command.md\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/README', '', 'https://mariadb.com/docs/server/reference/sql-statements/README');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (491, 10, 'ALTER USER', 'Syntax\n------\n\nALTER USER [IF EXISTS] \n user_specification [,user_specification] ...\n  [REQUIRE {NONE | tls_option [[AND] tls_option] ...}]\n  [WITH resource_option [resource_option] ...]\n  [lock_option] [password_option] \n\nuser_specification:\n  username [authentication_option]\n\nauthentication_option:\n  IDENTIFIED BY ''password'' \n  | IDENTIFIED BY PASSWORD ''password_hash''\n  | IDENTIFIED {VIA|WITH} authentication_rule [OR authentication_rule] ... \n \nauthentication_rule:\n  authentication_plugin\n  | authentication_plugin {USING|AS} ''authentication_string''\n  | authentication_plugin {USING|AS} PASSWORD(''password'')\n\ntls_option\n  SSL \n  | X509\n  | CIPHER ''cipher''\n  | ISSUER ''issuer''\n  | SUBJECT ''subject''\n\nresource_option\n  MAX_QUERIES_PER_HOUR COUNT\n  | MAX_UPDATES_PER_HOUR COUNT\n  | MAX_CONNECTIONS_PER_HOUR COUNT\n  | MAX_USER_CONNECTIONS COUNT\n  | MAX_STATEMENT_TIME TIME\n\npassword_option:\n  PASSWORD EXPIRE\n  | PASSWORD EXPIRE DEFAULT\n  | PASSWORD EXPIRE NEVER\n  | PASSWORD EXPIRE INTERVAL N DAY\n\nlock_option:\n    ACCOUNT LOCK\n  | ACCOUNT UNLOCK\n}\n\nDescription\n-----------\n\nThe ALTER USER statement modifies existing MariaDB accounts. To use it, you must have the global CREATE USER privilege or the UPDATE privilege for the mysql database. The global READ_ONLY ADMIN privilege is also required if the read_only system variable is enabled.\n\nIf any of the specified user accounts do not yet exist, an error results. If an error occurs, ALTER USER will still modify the accounts that do not result in an error. Only one error is produced for all users which have not been modified.\n\nFor renaming an existing account (user name and/or host), see RENAME USER.\n\nIF EXISTS\n\nWhen the IF EXISTS clause is used, MariaDB will return a warning instead of an error for each specified user that does not exist.\n\nAccount Names\n\nFor ALTER USER statements, account names are specified as the username argument in the same way as they are for CREATE USER statements. See account names from the CREATE USER page for details on how account names are specified.\n\nCURRENT_USER or CURRENT_USER() can also be used to alter the account logged into the current session. For example, to change the current user''s password to mariadb:\n\n``sql\nALTER USER CURRENT_USER() IDENTIFIED BY ''mariadb'';\n`\n\nAuthentication Options\n\nFrom MariaDB 10.4, it is possible to use more than one authentication plugin for each user account. For example, this can be useful to slowly migrate users to the more secure ed25519 authentication plugin over time, while allowing the old mysql_native_password authentication plugin as an alternative for the transitional period. See Authentication from MariaDB 10.4 for more.\n\nWhen running ALTER USER, not specifying an authentication option in the IDENTIFIED VIA clause will remove that authentication method. (However this was not the case before MariaDB 10.4.13, see MDEV-21928)\n\nFor example, a user is created with the ability to authenticate via both a password and unix_socket:\n\n`sql\nCREATE USER ''bob''@''localhost'' \n  IDENTIFIED VIA mysql_native_password USING PASSWORD(''pwd'') \n  OR unix_socket;\n\nSHOW CREATE USER ''bob''@''localhost''\\G\n`\n\n`\n************************ 1. row ***********************\nCREATE USER for bob@localhost: CREATE USER bob@localhost \n  IDENTIFIED VIA mysql_native_password \n  USING ''975B2CD4FF9AE554FE8AD33168FBFC326D2021DD'' \n  OR unix_socket\n`\n\nIf the user''s password is updated, but unix_socket authentication is not specified in the IDENTIFIED VIA clause, unix_socket authentication will no longer be permitted.\n\n`sql\nALTER USER ''bob''@''localhost'' IDENTIFIED VIA mysql_native_password \n  USING PASSWORD(''pwd2'');\n\nSHOW CREATE USER ''bob''@''localhost''\\G\n`\n\n`\n************************ 1. row ***********************\nCREATE USER for bob@localhost: CREATE USER bob@localhost \n  IDENTIFIED BY PASSWORD ''38366FDA01695B6A5A9DD4E428D9FB8F7EB75512''\n`\n\nIDENTIFIED BY ''password''\n\nThe optional IDENTIFIED BY clause can be used to provide an account with a password. The password should be specified in plain text. It will be hashed by the PASSWORD function prior to being stored in the mysql.user view.\n\nFor example, if our password is mariadb, then we can set the account''s password with:\n\n`sql\nALTER USER foo2@test IDENTIFIED BY ''mariadb'';\n`\n\nIf you do not specify a password with the IDENTIFIED BY clause, the user\\\nwill be able to connect without a password. A blank password is not a wildcard\\\nto match any password. The user must connect without providing a password if no\\\npassword is set.\n\nThe only authentication plugins that this clause supports are mysql_native_password and mysql_old_password.\n\nIDENTIFIED BY PASSWORD ''password_hash''\n\nThe optional IDENTIFIED BY PASSWORD clause can be used to provide an account with a password that has already been hashed. The password should be specified as a hash that was provided by the PASSWORD#function. It will be stored in the mysql.user view as-is.\n\nFor example, if our password is mariadb, then we can find the hash with:\n\n`sql\nSELECT PASSWORD(''mariadb'');\n`\n\n`\n+-------------------------------------------+\n| PASSWORD(''mariadb'')                       |\n+-------------------------------------------+\n| 54958E764CE10E50764C2EECBB71D01F08549980 |\n+-------------------------------------------+\n`\n\nAnd then we can set an account''s password with the hash:\n\n`sql\nALTER USER foo2@test \n  IDENTIFIED BY PASSWORD ''54958E764CE10E50764C2EECBB71D01F08549980'';\n`\n\nIf you do not specify a password with the IDENTIFIED BY clause, the user\\\nwill be able to connect without a password. A blank password is not a wildcard\\\nto match any password. The user must connect without providing a password if no password is set.\n\nThe only authentication plugins that this clause supports are mysql_native_password and mysql_old_password.\n\nIDENTIFIED {VIA|WITH} authentication_plugin\n\nThe optional IDENTIFIED VIA authentication_plugin allows you to specify that the account should be authenticated by a specific authentication plugin. The plugin name must be an active authentication plugin as per SHOW PLUGINS. If it doesn''t show up in that output, then you will need to install it with INSTALL PLUGIN or INSTALL SONAME.\n\nFor example, this could be used with the PAM authentication plugin:\n\n`sql\nALTER USER foo2@test IDENTIFIED VIA pam;\n`\n\nSome authentication plugins allow additional arguments to be specified after a USING or AS keyword. For example, the PAM authentication plugin accepts a service name:\n\n`sql\nALTER USER foo2@test IDENTIFIED VIA pam USING ''mariadb'';\n`\n\nThe exact meaning of the additional argument would depend on the specific authentication plugin.\n\nThe USING or AS keyword can also be used to provide a plain-text password to a plugin if it''s provided as an argument to the PASSWORD() function. This is only valid for authentication plugins that have implemented a hook for the PASSWORD() function. For example, the ed25519 authentication plugin supports this:\n\n`sql\nALTER USER safe@''%'' IDENTIFIED VIA ed25519 USING PASSWORD(''secret'');\n`\n\nThe USING or AS keyword cannot be used to provide a plain-text password to a plugin if it''s provided as an argument to the PASSWORD() function.\n\nTLS Options\n\nBy default, MariaDB transmits data between the server and clients without encrypting it. This is generally acceptable when the server and client run on the same host or in networks where security is guaranteed through other means. However, in cases where the server and client exist on separate networks or they are in a high-risk network, the lack of encryption does introduce security concerns as a malicious actor could potentially eavesdrop on the traffic as it is sent over the network between them.\n\nTo mitigate this concern, MariaDB allows you to encrypt data in transit between the server and clients using the Transport Layer Security (TLS) protocol. TLS was formerly known as Secure Socket Layer (SSL), but strictly speaking the SSL protocol is a predecessor to TLS and, that version of the protocol is now considered insecure. The documentation still uses the term SSL often and for compatibility reasons TLS-related server system and status variables still use the prefix ssl_, but internally, MariaDB only supports its secure successors.\n\nSee Secure Connections Overview for more information about how to determine whether your MariaDB server has TLS support.\n\nYou can set certain TLS-related restrictions for specific user accounts. For instance, you might use this with user accounts that require access to sensitive data while sending it across networks that you do not control. These restrictions can be enabled for a user account with the CREATE USER, ALTER USER, or GRANT statements. The following options are available:\n\n| Option                    | Description                                                                                                                                                                                                                                                                                         |\n| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| REQUIRE NONE              | TLS is not required for this account, but can still be used.                                                                                                                                                                                                                                        |\n| REQUIRE SSL               | The account must use TLS, but no valid X509 certificate is required. This option cannot be combined with other TLS options.                                                                                                                                                                         |\n| REQUIRE X509              | The account must use TLS and must have a valid X509 certificate. This option implies REQUIRE SSL. This option cannot be combined with other TLS options.                                                                                                                                            |\n| REQUIRE ISSUER ''issuer''   | The account must use TLS and must have a valid X509 certificate. Also, the Certificate Authority must be the one specified via the string issuer. This option implies REQUIRE X509. This option can be combined with the SUBJECT, and CIPHER options in any order.                                  |\n| REQUIRE SUBJECT ''subject'' | The account must use TLS and must have a valid X509 certificate. Also, the certificate''s Subject must be the one specified via the string subject. This option implies REQUIRE X509. This option can be combined with the ISSUER, and CIPHER options in any order.                                  |\n| REQUIRE CIPHER ''cipher''   | The account must use TLS, but no valid X509 certificate is required. Also, the encryption used for the connection must use a specific cipher method specified in the string cipher. This option implies REQUIRE SSL. This option can be combined with the ISSUER, and SUBJECT options in any order. |\n\nThe REQUIRE keyword must be used only once for all specified options, and the AND keyword can be used to separate individual options, but it is not required.\n\nFor example, you can alter a user account to require these TLS options with the following:\n\n`sql\nALTER USER ''alice''@''%''\n REQUIRE SUBJECT ''/CN=alice/O=My Dom, Inc./C=US/ST=Oregon/L=Portland'' AND\n ISSUER ''/C=FI/ST=Somewhere/L=City/ O=Some Company/CN=Peter Parker/emailAddress=p.parker@marvel.com''\n AND CIPHER ''SHA-DES-CBC3-EDH-RSA'';\n`\n\nIf any of these options are set for a specific user account, then any client who tries to connect with that user account will have to be configured to connect with TLS.\n\nSee Securing Connections for Client and Server for information on how to enable TLS on the client and server.\n\nResource Limit Options\n\nIt is possible to set per-account limits for certain server resources. The following table shows the values that can be set per account:\n\n| Limit Type                  | Description                                                                                                                                                                                                                     |\n| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| MAX_QUERIES_PER_HOUR     | Number of statements that the account can issue per hour (including updates)                                                                                                                                                    |\n| MAX_UPDATES_PER_HOUR     | Number of updates (not queries) that the account can issue per hour                                                                                                                                                             |\n| MAX_CONNECTIONS_PER_HOUR | Number of connections that the account can start per hour                                                                                                                                                                       |\n| MAX_USER_CONNECTIONS      | Number of simultaneous connections that can be accepted from the same account; if it is 0, max_connections will be used instead; if max_connections is 0, there is no limit for this account''s simultaneous connections.      |\n| MAX_STATEMENT_TIME        | Timeout, in seconds, for statements executed by the user. See also Aborting Statements that Exceed a Certain Time to Execute. |\n\nIf any of these limits are set to 0, then there is no limit for that resource for that user.\n\nHere is an example showing how to set an account''s resource limits:\n\n`sql\nALTER USER ''someone''@''localhost'' WITH\n    MAX_USER_CONNECTIONS 10\n    MAX_QUERIES_PER_HOUR 200;\n`\n\nThe resources are tracked per account, which means ''user''@''server''; not per user name or per connection.\n\nThe count can be reset for all users using FLUSH USER_RESOURCES, FLUSH PRIVILEGES or mysqladmin reload.\n\nPer account resource limits are stored in the user table, in the mysql database. Columns used for resources limits are named max_questions, max_updates, max_connections (for MAX_CONNECTIONS_PER_HOUR), and max_user_connections (for MAX_USER_CONNECTIONS).\n\nPassword Expiry\n\nBesides automatic password expiry, as determined by default_password_lifetime, password expiry times can be set on an individual user basis, overriding the global setting, for example:\n\n`sql\nALTER USER ''monty''@''localhost'' PASSWORD EXPIRE INTERVAL 120 DAY;\nALTER USER ''monty''@''localhost'' PASSWORD EXPIRE NEVER;\nALTER USER ''monty''\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/alter-user');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (492, 10, 'CREATE ROLE', 'Description\n-----------\n\nThe CREATE ROLE statement creates one or more MariaDB roles. To use it, you must have the global CREATE USER privilege or the INSERT privilege for the mysql database. For each account, CREATE ROLE creates a new row in the mysql.user table that has no privileges, and with the corresponding is_role field set to Y. It also creates a record in the mysql.roles_mapping table.\n\nIf any of the specified roles already exist, ERROR 1396 (HY000) results. If an error occurs, CREATE ROLE will still create the roles that do not result in an error. The maximum length for a role is 128 characters. Role names can be quoted, as explained in the Identifier names page. Only one error is produced for all roles which have not been created:\n\n``\nERROR 1396 (HY000): Operation CREATE ROLE failed for ''a'',''b'',''c''\n`\n\nFailed CREATE or DROP operations, for both users and roles, produce the same error code.\n\nPUBLIC and NONE are reserved, and cannot be used as role names. NONE is used to unset a role and PUBLIC has a special use in other systems, such as Oracle, so is reserved for compatibility purposes.\n\nFor valid identifiers to use as role names, see Identifier Names.\n\nWITH ADMIN\n\nThe optional WITH ADMIN clause determines whether the current user, the current role or another user or role has use of the newly created role. If the clause is omitted, WITH ADMIN CURRENT_USER` is treated as the default, which means that the current user will be able to GRANT this role to users.\n\nExamples\n--------\n\nCREATE ROLE developer WITH ADMIN lorinda@localhost;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/create-role', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/create-role');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (493, 10, 'CREATE USER', 'Description\n-----------\n\nThe CREATE USER statement creates new MariaDB accounts. To use it, you must have the global CREATE USER privilege or the INSERT privilege for the mysql database.\n\nFor each account, CREATE USER creates a new row in the mysql.user view (and the underlying mysql.global_priv table) that has no privileges.\n\nFor each account, CREATE USER creates a new row in mysql.user table that has no privileges.\n\nIf any of the specified accounts, or any permissions for the specified accounts, already exist, then the server returns ERROR 1396 (HY000). If an error occurs, CREATE USER will still create the accounts that do not result in an error. Only one error is produced for all users which have not been created:\n\n``\nERROR 1396 (HY000): \n  Operation CREATE USER failed for ''u1''@''%'',''u2''@''%''\n`\n\nCREATE USER, DROP USER, CREATE ROLE, and DROP ROLE all produce the same error code when they fail.\n\nSee Account Names below for details on how account names are specified.\n\nOne can also create users with GRANT if SQL_MODE does not have NO_AUTO_CREATE_USER set. NO_AUTO_CREATE_USER is set by default.\n\nOR REPLACE\n\nIf the optional OR REPLACE clause is used, it is basically a shortcut for:\n\n`sql\nDROP USER IF EXISTS name;\nCREATE USER name ...;\n`\n\nFor example:\n\n`sql\nCREATE USER foo2@test IDENTIFIED BY ''password'';\nERROR 1396 (HY000): Operation CREATE USER failed for ''foo2''@''test''\n\nCREATE OR REPLACE USER foo2@test IDENTIFIED BY ''password'';\nQuery OK, 0 rows affected (0.00 sec)\n`\n\nIF NOT EXISTS\n\nWhen the IF NOT EXISTS clause is used, MariaDB will return a warning instead of an error if the specified user already exists.\n\nFor example:\n\n`sql\nCREATE USER foo2@test IDENTIFIED BY ''password'';\nERROR 1396 (HY000): Operation CREATE USER failed for ''foo2''@''test''\n\nCREATE USER IF NOT EXISTS foo2@test IDENTIFIED BY ''password'';\nQuery OK, 0 rows affected, 1 warning (0.00 sec)\n\nSHOW WARNINGS;\n+-------+------+----------------------------------------------------+\n| Level | Code | Message                                            |\n+-------+------+----------------------------------------------------+\n| Note  | 1973 | Can''t create user ''foo2''@''test''; it already exists |\n+-------+------+----------------------------------------------------+\n`\n\nAuthentication Options\n\nIf more than one authentication mechanism is declared using the OR keyword, the mechanisms are attempted in the order they are declared in the CREATE USER statement. As soon as one of the authentication mechanisms is successful, authentication is complete. If none of them is successful, the authentication has failed.\n\nIDENTIFIED BY ''password''\n\nThe optional IDENTIFIED BY clause can be used to provide an account with a password. The password should be specified in plain text. It will be hashed by the PASSWORD function prior to being stored in the mysql.user/mysql.global_priv_table table.\n\nFor example, if our password is mariadb, then we can create the user with:\n\n`sql\nCREATE USER foo2@test IDENTIFIED BY ''mariadb'';\n`\n\nIf you do not specify a password with the IDENTIFIED BY clause, the user\\\nwill be able to connect without a password. A blank password is not a wildcard\\\nto match any password. The user must connect without providing a password if no\\\npassword is set.\n\nThe only authentication plugins that this clause supports are mysql_native_password and mysql_old_password.\n\nIDENTIFIED BY PASSWORD ''password_hash''\n\nThe optional IDENTIFIED BY PASSWORD clause can be used to provide an account with a password that has already been hashed. The password should be specified as a hash that was provided by the PASSWORD function. It will be stored in the mysql.user/mysql.global_priv_table table as-is.\n\nFor example, if our password is mariadb, then we can find the hash with:\n\n`sql\nSELECT PASSWORD(''mariadb'');\n+-------------------------------------------+\n| PASSWORD(''mariadb'')                       |\n+-------------------------------------------+\n| 54958E764CE10E50764C2EECBB71D01F08549980 |\n+-------------------------------------------+\n1 row in set (0.00 sec)\n`\n\nAnd then we can create a user with the hash:\n\n`sql\nCREATE USER foo2@test IDENTIFIED BY PASSWORD ''54958E764CE10E50764C2EECBB71D01F08549980'';\n`\n\nIf you do not specify a password with the IDENTIFIED BY clause, the user will be able to connect without a password. A blank password is not a wildcard to match any password. The user must connect without providing a password if no password is set.\n\nThe only authentication plugins that this clause supports are mysql_native_password and mysql_old_password.\n\nIDENTIFIED {VIA|WITH} authentication_plugin\n\nThe optional IDENTIFIED VIA authentication_plugin allows you to specify that the account should be authenticated by a specific authentication plugin. The plugin name must be an active authentication plugin as per SHOW PLUGINS. If it doesn''t show up in that output, then you will need to install it with INSTALL PLUGIN or INSTALL SONAME.\n\nVIA and WITH are synonyms.\n\nFor example, this could be used with the PAM authentication plugin:\n\n`sql\nCREATE USER foo2@test IDENTIFIED VIA pam;\n`\n\nSome authentication plugins allow additional arguments to be specified after a USING or AS keyword. For example, the PAM authentication plugin accepts a service name:\n\n`sql\nCREATE USER foo2@test IDENTIFIED VIA pam USING ''mariadb'';\n`\n\nThe exact meaning of the additional argument would depend on the specific authentication plugin.\n\nThe USING or AS keyword can also be used to provide a plain-text password to a plugin if it''s provided as an argument to the PASSWORD() function. This is only valid for authentication plugins that have implemented a hook for the PASSWORD() function. For example, the ed25519 authentication plugin supports this:\n\n`sql\nCREATE USER safe@''%'' IDENTIFIED VIA ed25519 USING PASSWORD(''secret'');\n`\n\nOne can specify many authentication plugins, they all work as alternatives ways of authenticating a user:\n\n`sql\nCREATE USER safe@''%'' IDENTIFIED VIA ed25519 USING PASSWORD(''secret'') OR unix_socket;\n`\n\nBy default, when you create a user without specifying an authentication plugin, MariaDB uses the mysql_native_password plugin.\n\nTLS Options\n\nMariaDB allows you to encrypt data in transit between the server and clients using the Transport Layer Security (TLS) protocol. TLS was formerly known as Secure Socket Layer (SSL), but strictly speaking the SSL protocol is a predecessor to TLS and, that version of the protocol is now considered insecure. The documentation still uses the term SSL often and for compatibility reasons TLS-related server system and status variables still use the prefix ssl_, but internally, MariaDB only supports its secure successors.\n\nBy default, MariaDB transmits data between the server and clients without encrypting it. This is generally acceptable when the server and client run on the same host or in networks where security is guaranteed through other means. However, in cases where the server and client exist on separate networks or they are in a high-risk network, the lack of encryption does introduce security concerns as a malicious actor could potentially eavesdrop on the traffic as it is sent over the network between them.\n\nTo mitigate this concern, MariaDB allows you to encrypt data in transit between the server and clients using the Transport Layer Security (TLS) protocol. TLS was formerly known as Secure Socket Layer (SSL), but strictly speaking the SSL protocol is a predecessor to TLS and, that version of the protocol is now considered insecure. The documentation still uses the term SSL often and for compatibility reasons TLS-related server system and status variables still use the prefix ssl_, but internally, MariaDB only supports its secure successors.\n\nSee Secure Connections Overview for more information about how to determine whether your MariaDB server has TLS support.\n\nYou can set certain TLS-related restrictions for specific user accounts. For instance, you might use this with user accounts that require access to sensitive data while sending it across networks that you do not control. These restrictions can be enabled for a user account with the CREATE USER, ALTER USER, or GRANT statements. The following options are available:\n\n| Option                    | Description                                                                                                                                                                                                                                                                                         |\n| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| REQUIRE NONE              | TLS is not required for this account, but can still be used.                                                                                                                                                                                                                                        |\n| REQUIRE SSL               | The account must use TLS, but no valid X509 certificate is required. This option cannot be combined with other TLS options.                                                                                                                                                                         |\n| REQUIRE X509              | The account must use TLS and must have a valid X509 certificate. This option implies REQUIRE SSL. This option cannot be combined with other TLS options.                                                                                                                                            |\n| REQUIRE ISSUER ''issuer''   | The account must use TLS and must have a valid X509 certificate. Also, the Certificate Authority must be the one specified via the string issuer. This option implies REQUIRE X509. This option can be combined with the SUBJECT, and CIPHER options in any order.                                  |\n| REQUIRE SUBJECT ''subject'' | The account must use TLS and must have a valid X509 certificate. Also, the certificate''s Subject must be the one specified via the string subject. This option implies REQUIRE X509. This option can be combined with the ISSUER, and CIPHER options in any order.                                  |\n| REQUIRE CIPHER ''cipher''   | The account must use TLS, but no valid X509 certificate is required. Also, the encryption used for the connection must use a specific cipher method specified in the string cipher. This option implies REQUIRE SSL. This option can be combined with the ISSUER, and SUBJECT options in any order. |\n\nThe REQUIRE keyword must be used only once for all specified options, and the AND keyword can be used to separate individual options, but it is not required.\n\nFor example, you can create a user account that requires these TLS options with the following:\n\n`sql\nCREATE USER ''alice''@''%''\n REQUIRE SUBJECT ''/CN=alice/O=My Dom, Inc./C=US/ST=Oregon/L=Portland''\n AND ISSUER ''/C=FI/ST=Somewhere/L=City/ O=Some Company/CN=Peter Parker/emailAddress=p.parker@marvel.com''\n AND CIPHER ''SHA-DES-CBC3-EDH-RSA'';\n`\n\nIf any of these options are set for a specific user account, then any client who tries to connect with that user account will have to be configured to connect with TLS.\n\nSee Securing Connections for Client and Server for information on how to enable TLS on the client and server.\n\nResource Limit Options\n\nIt is possible to set per-account limits for certain server resources. The following table shows the values that can be set per account:\n\n| Limit Type                  | Decription                                                                                                                                                                                                                      |\n| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| MAX_QUERIES_PER_HOUR     | Number of statements that the account can issue per hour (including updates)                                                                                                                                                    |\n| MAX_UPDATES_PER_HOUR     | Number of updates (not queries) that the account can issue per hour                                                                                                                                                             |\n| MAX_CONNECTIONS_PER_HOUR | Number of connections that the account can start per hour                                                                                                                                                                       |\n| MAX_USER_CONNECTIONS      | Number of simultaneous connections that can be accepted from the same account; if it is 0, max_connections will be used instead; if max_connections is 0, there is no limit for this account''s simultaneous connections.      |\n| MAX_STATEMENT_TIME        | Timeout, in seconds, for statements executed by the user. See also Aborting Statements that Exceed a Certain Time to Execute. |\n\nIf any of these limits are set to 0, then there is no limit for that resource for that user.\n\nHere is an example showing how to create a user with resource limits:\n\n`sql\nCREATE USER ''someone''@''localhost'' WITH\n    MAX_USER_CONNECTIONS 10\n    MAX_QUERIES_PER_HOUR 200;\n`\n\nThe resources are tracked per account, which means ''user''@''server''; not per user name or per connection.\n\nThe count can be reset for all users using FLUSH USER_RESOURCES, FLUSH PRIVILEGES or mariadb-admin reload.\n\nPer account resource limits are stored in the user table, in the mysql database. Columns used for resources limits are named max_questions, max_updates, max_connections (for MAX_CONNECTIONS_PER_HOUR), and max_user_connections (for MAX_USER_CONNECTIONS).\n\nAccount Names\n\nAccount names have both a user name component and a host name component, and are specified as ''user_name''@''host_name''.\n\nThe user name and host name may be unquoted, quoted as strings using double quotes (") or\\\nsingle quotes (''), or quoted as identifiers using backticks (\\\\\\). You must use quotes\\\nwhen using special characters (such as a hyphen) or wildcard characters. If you quote, you\\\nmust quote the user name and host name separately (for example ''user_name''@''host_name'').\n\nHost Name Component\n\nIf the host name is not provided, it is assumed to be ''%''.\n\nHost names may contain the wildcard characters % and _. They are matched as if by\\\nthe LIKE clause. If you need to use a wildcard character literally (for example, to\\\nmatch a domain name with an underscore), prefix the character with a backslash. See LIKE\\\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/create-user');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (494, 10, 'DROP ROLE', 'Description\n-----------\n\nThe DROP ROLE statement removes one or more MariaDB roles. To use this statement, you must have the global CREATE USER privilege or the DELETE privilege for the mysql database.\n\nDROP ROLE does not disable roles for connections which selected them with SET ROLE. If a role has previously been set as a default role, DROP ROLE does not remove the record of the default role from the mysql.user table. If the role is subsequently recreated and granted, it will again be the user''s default. Use SET DEFAULT ROLE NONE to explicitly remove this.\n\nIf any of the specified user accounts do not exist, ERROR 1396 (HY000)results. If an error occurs, DROP ROLE will still drop the roles that do not result in an error. Only one error is produced for all roles which have not been dropped:\n\n``bnf\nERROR 1396 (HY000): Operation DROP ROLE failed for ''a'',''b'',''c''\n`\n\nFailed CREATE or DROP operations, for both users and roles, produce the same error code.\n\nIF EXISTS\n\nIf the IF EXISTS` clause is used, MariaDB will return a warning instead of an error if the role does not exist.\n\nExamples\n--------\n\nDROP ROLE journalist;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/drop-role', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/drop-role');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (495, 10, 'DROP USER', 'Syntax\n------\n\nDROP USER [IF EXISTS] user_name [, user_name] ... [FORCE]\n\nDescription\n-----------\n\nThe DROP USER statement removes one or more MariaDB accounts. It removes privilege rows for the account from all grant tables. To use this statement, you must have the global CREATE USER privilege or the DELETE privilege for the mysql database. Each account is named using the same format as for the CREATE USER statement; for example, ''jeffrey''@''localhost''. If you specify only the user name part of the account name, a host name part of ''%'' is used. For additional information about specifying account names, see CREATE USER.\n\nIf you specify an account that is currently connected, it is deleted, but the statement completes with a warning:\n\n``sql\nDropped users ''user''@''host[,...]'' have active connections. Use KILL CONNECTION if they should not be used anymore.\n`\n\nThis means that the user account with all its privileges is still active until the connection is terminated. As the warning implies, use a KILL CONNECTION statement to terminate a connection, or (more proactively) use the FORCE clause to forcibly close connections of the users named in the DROP USER statement. This ends connections, and immediately deletes the users.\n\nIn Oracle mode, if a user is connected, the DROP USER statement fails with an error:\n\n`sql\nOperation DROP USER failed for ''foo''@''localhost''.\n`\n\nAgain, use the FORCE clause to prevent that error.\n\nIf you specify an account that is currently connected, it is not deleted until the connection is closed. The connection is not automatically closed.\n\nHowever, a deleted user cannot initiate new connections any more.\n\nIf any of the specified user accounts do not exist, ERROR 1396 (HY000) results. If an error occurs, DROP USER still drops the accounts that do not result in an error. Only one error is produced for all users which have not been dropped:\n\n`bnf\nERROR 1396 (HY000): Operation DROP USER failed for ''u1''@''%'',''u2''@''%''\n`\n\nFailed CREATE or DROP operations, for both users and roles, produce the same error.\n\nIF EXISTS\n\nIf the IF EXISTS clause is used, MariaDB returns a note instead of an error if the user does not exist.\n\nThe CREATE USER statement creates new MariaDB accounts. To use it, you must have the global CREATE USER privilege or the INSERT privilege for the mysql database.\n\nIf the IF EXISTS` clause is used, MariaDB returns a note instead of an error if the user does not exist.\n\nExamples\n--------\n\nDROP USER bob;\n\nDROP USER foo2@localhost,foo2@''127.%'';\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/drop-user', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/drop-user');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (496, 10, 'GRANT', 'Description\n-----------\n\nThe GRANT statement allows you to grant privileges or roles to accounts. To use GRANT, you must have the GRANT OPTION privilege, and you must have the privileges that you are granting.\n\nUse the REVOKE statement to revoke privileges granted with the GRANT statement.\n\nUse the SHOW GRANTS statement to determine what privileges an account has.\n\nAccount Names\n\nFor GRANT statements, account names are specified as the username argument in the same way as they are for CREATE USER statements. See account names from the CREATE USER page for details on how account names are specified.\n\nImplicit Account Creation\n\nThe GRANT statement also allows you to implicitly create accounts in some cases.\n\nIf the account does not yet exist, then GRANT can implicitly create it. To implicitly create an account with GRANT, a user is required to have the same privileges that would be required to explicitly create the account with the CREATE USER statement.\n\nIf the NO_AUTO_CREATE_USER SQL_MODE is set, then accounts can only be created if authentication information is specified, or with a CREATE USER statement. If no authentication information is provided, GRANT will produce an error when the specified account does not exist, for example:\n\n``sql\nSHOW VARIABLES LIKE ''%sql_mode%'' ;\n`\n\n<pre><code><strong>+---------------+--------------------------------------------+\n</strong>| Variable_name | Value                                      |\n+---------------+--------------------------------------------+\n| sql_mode      | NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |\n+---------------+--------------------------------------------+\n</code></pre>\n\n`sql\nGRANT USAGE ON . TO ''user123''@''%'' IDENTIFIED BY '''';\n`\n\n`\nERROR 1133 (28000): Can''t find any matching row in the user table\n`\n\n`sql\nGRANT USAGE ON . TO ''user123''@''%'' \n  IDENTIFIED VIA PAM using ''mariadb'' require ssl ;\nQuery OK, 0 rows affected (0.00 sec)\n`\n\n`sql\nSELECT host, user FROM mysql.user WHERE user=''user123'' ;\n`\n\n`\n+------+----------+\n| host | user     |\n+------+----------+\n| %    | user123 |\n+------+----------+\n`\n\nPrivilege Levels\n\nPrivileges can be set globally, for an entire database, for a table or routine, or for individual columns in a table. Certain privileges can only be set at certain levels.\n\nGlobal privileges do not take effect immediately and are only applied to connections created after the GRANT statement was executed.\n\n Global privileges priv_type are granted using . for priv_level. Global privileges include privileges to administer the database and manage user accounts, as well as privileges for all tables, functions, and procedures. Global privileges are stored in mysql.global_priv table.\n Database privileges priv_type are granted using db_name. for priv_level, or using just  to use the current database. Database privileges include privileges to create tables and functions, as well as privileges for all tables, functions, and procedures in the database. Database privileges are stored in the mysql.db table.\n Table privileges priv_type are granted using db_name.tbl_namefor priv_level, or using just tbl_name to specify a table in the current database. The TABLE keyword is optional. Table privileges include the ability to select and change data in the table. Certain table privileges can be granted for individual columns.\n Column privileges priv_type are granted by specifying a table for priv_level and providing a column list after the privilege type. They allow you to control exactly which columns in a table users can select and change.\n Function privileges priv_type are granted using FUNCTION db_name.routine_name for priv_level, or using just FUNCTION routine_name to specify a function in the current database.\n Procedure privileges priv_type are granted using PROCEDURE db_name.routine_name for priv_level, or using just PROCEDURE routine_name to specify a procedure in the current database.\n\nThe USAGE Privilege\n\nThe USAGE privilege grants no real privileges. The SHOW GRANTS statement will show a global USAGE privilege for a newly-created user. You can use USAGE with the GRANT statement to change options like GRANT OPTIONand MAX_USER_CONNECTIONS without changing any account privileges.\n\nThe ALL PRIVILEGES Privilege\n\nThe ALL PRIVILEGES privilege grants all available privileges. Granting all privileges only affects the given privilege level. For example, granting all privileges on a table does not grant any privileges on the database or globally.\n\nUsing ALL PRIVILEGES does not grant the special GRANT OPTION privilege.\n\nYou can use ALL instead of ALL PRIVILEGES.\n\nThe GRANT OPTION Privilege\n\nUse the WITH GRANT OPTION clause to give users the ability to grant privileges to other users at the given privilege level. Users with the GRANT OPTION privilege can only grant privileges they have. They cannot grant privileges at a higher privilege level than they have the GRANT OPTION privilege.\n\nThe GRANT OPTION privilege cannot be set for individual columns. If you use WITH GRANT OPTION when specifying column privileges, the GRANT OPTION privilege will be granted for the entire table.\n\nUsing the WITH GRANT OPTION clause is equivalent to listing GRANT OPTION as a privilege.\n\nGlobal Privileges\n\nThe following table lists the privileges that can be granted globally. You can also grant all database, table, and function privileges globally. When granted globally, these privileges apply to all databases, tables, or functions, including those created later.\n\nTo set a global privilege, use . for _priv_level_.\n\nBINLOG ADMIN\n\nEnables administration of the binary log, including the PURGE BINARY LOGS statement and setting the system variables:\n\n binlog_annotate_row_events\n binlog_cache_size\n binlog_commit_wait_count\n binlog_commit_wait_usec\n binlog_direct_non_transactional_updates\n binlog_expire_logs_seconds\n binlog_file_cache_size\n binlog_format\n binlog_row_image\n binlog_row_metadata\n binlog_stmt_cache_size\n expire_logs_days\n log_bin_compress\n log_bin_compress_min_len\n log_bin_trust_function_creators\n max_binlog_cache_size\n max_binlog_size\n max_binlog_stmt_cache_size\n sql_log_bin and\n sync_binlog.\n\nBINLOG ADMIN isn''t available.\n\nBINLOG MONITOR\n\nNew name for REPLICATION CLIENT. REPLICATION CLIENT can still be used, though.\n\nUse REPLICATION CLIENT instead. SHOW SLAVE STATUS isn''t included in this privilege, and SLAVE MONITOR is required.\n\nPermits running SHOW commands related to the binary log, in particular the SHOW BINLOG STATUS and SHOW BINARY LOGS statements.\n\nBINLOG REPLAY\n\nEnables replaying the binary log with the BINLOG statement (generated by mariadb-binlog), executing SET timestamp when secure_timestamp is set to replication, and setting the session values of system variables usually included in BINLOG output, in particular:\n\n gtid_domain_id\n gtid_seq_no\n pseudo_thread_id\n server_id.\n\nBINLOG REPLAY isn''t available.\n\nCONNECTION ADMIN\n\nEnables administering connection resource limit options. This includes ignoring the limits specified by max_user_connections and max_password_errors, and allowing one extra connection over max_connections\n\nThe statements specified in init_connect are not executed, killing connections and queries owned by other users is permitted. The following connection-related system variables can be changed:\n\n connect_timeout\n disconnect_on_expired_password\n extra_max_connections\n init_connect\n max_connections\n max_connect_errors\n max_password_errors\n proxy_protocol_networks\n secure_auth\n slow_launch_time\n thread_pool_exact_stats\n thread_pool_dedicated_listener\n thread_pool_idle_timeout\n thread_pool_max_threads\n thread_pool_min_threads\n thread_pool_oversubscribe\n thread_pool_prio_kickup_timer\n thread_pool_priority\n thread_pool_size, and\n thread_pool_stall_limit.\n\nCREATE USER\n\nCreate a user using the CREATE USER statement, or implicitly create a user with the GRANT statement.\n\nFEDERATED ADMIN\n\nExecute CREATE SERVER, ALTER SERVER, and DROP SERVER statements.\n\nFEDERATED ADMIN is not available.\n\nFILE\n\nRead and write files on the server, using statements like LOAD DATA INFILE or functions like LOAD_FILE(). Also needed to create CONNECT outward tables. MariaDB server must have the permissions to access those files.\n\nGRANT OPTION\n\nGrant global privileges. You can only grant privileges that you have.\n\nPROCESS\n\nShow information about the active processes, for example via SHOW PROCESSLIST or mariadb-admin processlist. If you have the PROCESS privilege, you can see all threads. Otherwise, you can see only your own threads (that is, threads associated with the MariaDB account that you are using).\n\nREAD_ONLY ADMIN\n\nUser ignores the read_only system variable, and can perform write operations even when the read_only option is active.\n\nA user with that privilege can also change the (global) value of read_only.\n\nThe READ_ONLY ADMIN privilege has been removed from SUPER. The benefit of this is that one can remove the READ_ONLY ADMIN privilege from all users and ensure that no one can make any changes on any non-temporary tables. This is useful on slaves when one wants to ensure that the slave is kept identical to the master.\n\nUser ignores the read_only system variable, and can perform write operations even when the read_only option is active.\n\nA user with that privilege can also change the (global) value of read_only.\n\nThe READ_ONLY ADMIN privilege is included in SUPER.\n\nREAD_ONLY ADMIN isn''t available.\n\nRELOAD\n\nExecute FLUSH statements or equivalent mariadb-admin commands.\n\nREPLICATION CLIENT\n\nExecute SHOW MASTER STATUS and SHOW BINARY LOGS informative statements. Renamed to BINLOG MONITOR (but still supported as an alias for compatibility reasons).\n\nExecute SHOW MASTER STATUS and SHOW BINARY LOGS informative statements. SHOW SLAVE STATUS is part of REPLICATION CLIENT.\n\nExecute SHOW MASTER STATUS and SHOW BINARY LOGS informative statements. Using BINLOG MONITOR instead is still supported as an alias.\n\nExecute SHOW MASTER STATUS and SHOW BINARY LOGS informative statements. Renamed to BINLOG MONITOR in MariaDB 10.5.2 (but still supported as an alias for compatibility reasons). SHOW SLAVE STATUS was part of REPLICATION CLIENT prior to MariaDB 10.5.\n\nREPLICATION MASTER ADMIN\n\nPermits administration of master servers, including the SHOW SLAVE HOSTS statement, and setting the gtid_binlog_state, gtid_domain_id, master_verify_checksum and server_id system variables.\n\nREPLICATION MASTER ADMIN is not available.\n\nSLAVE MONITOR\n\nPermit SHOW REPLICA STATUS and SHOW RELAYLOG EVENTS.\n\nSee _Reasoning_ tab as to why this was implemented.\n\nWhen a user would upgrade from an older major release to a MariaDB 10.5 minor release prior to MariaDB 10.5.9, certain user accounts would lose capabilities. For example, a user account that had the REPLICATION CLIENT privilege in older major releases could run SHOW REPLICA STATUS, but after upgrading to a MariaDB 10.5 minor release prior to MariaDB 10.5.9, they could no longer run SHOW REPLICA STATUS, because that statement was changed to require the REPLICATION SLAVE ADMIN privilege.\n\nThis issue is fixed in MariaDB 10.5.9 with this new privilege, which now grants the user the ability to execute SHOW [ALL] (SLAVE | REPLICA) STATUS.\n\nWhen a database is upgraded from an older major release to MariaDB Server 10.5.9 or later, any user accounts with the REPLICATION CLIENT or REPLICATION SLAVE privileges will automatically be granted the new SLAVE MONITOR privilege. The privilege fix occurs when the server is started up, not when mariadb-upgrade is performed.\n\nHowever, when a database is upgraded from an early 10.5 minor release to 10.5.9 and later, the user will have to fix any user account privileges manually.\n\nSLAVE MONITOR is not available.\n\nREPLICATION REPLICA\n\nSynonym for REPLICATION SLAVE.\n\nREPLICATION REPLICA is not available.\n\nREPLICATION SLAVE\n\nAccounts used by slave servers on the master need this privilege. This is needed to get the updates made on the master. REPLICATION REPLICA is an alias for REPLICATION SLAVE.\n\nAccounts used by slave servers on the master need this privilege. This is needed to get the updates made on the master.\n\nREPLICATION SLAVE ADMIN\n\nPermits administering slave servers, including START REPLICA/SLAVE, STOP REPLICA/SLAVE, CHANGE MASTER, SHOW REPLICA/SLAVE STATUS, SHOW RELAYLOG EVENTS statements, replaying the binary log with the BINLOG statement (generated by mariadb-binlog), and setting the system variables:\n\n gtid_cleanup_batch_size\n gtid_ignore_duplicates\n gtid_pos_auto_engines\n gtid_slave_pos\n gtid_strict_mode\n init_slave\n read_binlog_speed_limit\n relay_log_purge\n relay_log_recovery\n replicate_do_db\n replicate_do_table\n replicate_events_marked_for_skip\n replicate_ignore_db\n replicate_ignore_table\n replicate_wild_do_table\n replicate_wild_ignore_table\n slave_compressed_protocol\n slave_ddl_exec_mode\n slave_domain_parallel_threads\n slave_exec_mode\n slave_max_allowed_packet\n slave_net_timeout\n slave_parallel_max_queued\n slave_parallel_mode\n slave_parallel_threads\n slave_parallel_workers\n slave_run_triggers_for_rbr\n slave_sql_verify_checksum\n slave_transaction_retry_interval\n slave_type_conversions\n sync_master_info\n sync_relay_log, and\n sync_relay_log_info.\n\nREPLICATION SLAVE ADMIN is not available.\n\nSET USER\n\nEnables setting the DEFINER when creating triggers, views, stored functions and stored procedures.\n\nSET USER isn''t available.\n\nSHOW DATABASES\n\nList all databases using the SHOW DATABASES statement. Without the SHOW DATABASES privilege, you can still issue the SHOW DATABASES statement, but it will only list databases containing tables on which you have privileges.\n\nSHUTDOWN\n\nShut down the server using SHUTDOWN or the mariadb-admin shutdown command.\n\nSUPER\n\nExecute superuser statements: CHANGE MASTER TO, KILL (users who do not have this privilege can only KILL their own threads), PURGE LOGS, SET global system variables, or the mariadb-admin debug command. Also, this permission allows the user to write data even if the read_only startup option is set, enable or disable logging, enable or disable replication on slave, specify a DEFINER for statements that support that clause, connect once reaching the MAX_CONNECTIONS. If a statement has been specified for the init-connect mariadbd option, that command will not be executed when a user with SUPER privileges connects to the server.\n\nThe SUPER privilege has been split into multiple smaller privileges to allow for more fine-grained privileges (MDEV-21743). The privileges are:\n\n SET USER\n FEDERATED ADMIN\n CONNECTION ADMIN\n REPLICATION SLAVE ADMIN\n BINLOG ADMIN\n BINLOG REPLAY\n SLAVE MONITOR\n BINLOG MONITOR\n REPLICATION MASTER ADMIN\n READ_ONLY ADMIN\n\nThese grants are no longer a part of SUPER and need to be granted separately.\n\nThe READ_ONLY ADMIN privilege has been removed from SUPER. The benefit of this is that one can remove the READ_ONLY ADMIN privilege from all users and ensure that no one can make any changes on any non-temporary tables. This is useful on\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/grant');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (497, 10, 'RENAME USER', 'Description\n-----------\n\nThe RENAME USER statement renames existing MariaDB accounts. To use it, you must have the global CREATE USER privilege or the UPDATE privilege for the mysql database. Each account is named using the same format as for the CREATE USER statement; for example, ''jeffrey''@''localhost''.\\\nIf you specify only the user name part of the account name, a host name part of ''%'' is used.\n\nIf any of the old user accounts do not exist or any of the new user accounts already exist, ERROR 1396 (HY000) results. If an error occurs, RENAME USERwill still rename the accounts that do not result in an error.\n\nFor modifying an existing account, see ALTER USER.\n\nExamples\n--------\n\nCREATE USER ''donald'', ''mickey'';\nRENAME USER ''donald'' TO ''duck''@''localhost'', ''mickey'' TO ''mouse''@''localhost'';\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/rename-user', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/rename-user');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (498, 10, 'REVOKE', 'Description\n-----------\n\nThe REVOKE statement enables system administrators to revoke privileges (or roles - see section below) from MariaDB accounts. Each account is named using the same format as for the GRANT statement; for example, jeffrey@localhost. If you specify only the user name part of the account name, a host name part of % is used. For details on the levels at which privileges exist, the available priv_type and priv_level values, and the syntax for specifying users and passwords, see GRANT.\n\nTo use the first syntax (REVOKE ... ON ... FROM ...), you must have the GRANT OPTION privilege, and you must have the privileges that you are revoking. Also, remember to specify the ON clause (in many cases, ON . to revoke privileges for all objects):\n\n``sql\nREVOKE ALL ON . FROM ''myuser''@''localhost'';\n`\n\nThis leaves the USAGE privilege, and can leave other privileges, too. For that reason, the second syntax (REVOKE ALL PRIVILEGES, GRANT OPTION FROM ...) is preferable, which drops all global, database, table, column, and routine privileges for the named user or users:\n\n`sql\nREVOKE ALL PRIVILEGES, GRANT OPTION FROM user [, user] ...\n`\n\nTo use this REVOKE syntax, you must have the global CREATE USER privilege or the UPDATE privilege for the mysql database. See GRANT. For that syntax, the ON . clause must not be used (it yields an error).\n\nRevoking all privileges doesn''t remove _all_ privileges, not even with the second syntax. The user still keeps the USAGE privilege, making it possible to connect to the server (but nothing else). To remove that privilege, too, remove the user entirely with a DROP USER` statement.\n\nExamples\n--------\n\nREVOKE SUPER ON . FROM ''myuser''@''localhost'';\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/revoke', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/revoke');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (499, 10, 'SET DEFAULT ROLE', 'Description\n-----------\n\nThe SET DEFAULT ROLE statement sets a default role for a specified (or current) user. A default role is automatically enabled when a user connects (an implicit SET ROLE statement is executed immediately after a connection is established).\n\nTo be able to set a role as a default, the role must already have been granted to that user, and one needs the privileges to enable this role (if you cannot do SET ROLE X, you won''t be able to do SET DEFAULT ROLE X). To set a default role for another user one needs to have write access to the mysql database.\n\nTo remove a user''s default role, use SET DEFAULT ROLE NONE [ FOR user@host ]. The record of the default role is not removed if the role is dropped or revoked, so if the role is subsequently re-created or granted, it will again be the user''s default role.\n\nThe default role is stored in the default_role column in the mysql.user table/view, as well as in the Information Schema APPLICABLE_ROLES table, so these can be viewed to see which role has been assigned to a user as the default.\n\nExamples\n--------\n\nSET DEFAULT ROLE journalist;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/set-default-role', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/set-default-role');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (500, 10, 'SET PASSWORD', 'Syntax\n------\n\nSET PASSWORD [FOR user] =\n    {\n        PASSWORD(''some password'')\n      | OLD_PASSWORD(''some password'')\n      | ''encrypted password''\n    }\n\nDescription\n-----------\n\nThe SET PASSWORD statement assigns a password to an existing MariaDB user account.\n\nIf the password is specified using the PASSWORD() or OLD_PASSWORD() function, the literal text of the password should be given. If the password is specified without using either function, the password should be the already-encrypted password value as returned by PASSWORD().\n\nOLD_PASSWORD() should only be used if your MariaDB/MySQL clients are very old (< 4.0.0).\n\nWith no FOR clause, this statement sets the password for the current user. Any client that has connected to the server using a non-anonymous account can change the password for that account.\n\nWith a FOR clause, this statement sets the password for a specific account on the current server host. Only clients that have the UPDATE privilege for the mysql database can do this. The user value should be given in user_name@host_name format, where user_name and host_name are exactly as they are listed in the User and Host columns of the mysql.user table (or view in current versions) entry.\n\nThe argument to PASSWORD() and the password given to MariaDB clients can be of arbitrary length.\n\nAuthentication Plugin Support\n\nSET PASSWORD (with or without PASSWORD()) works for accounts authenticated via any authentication plugin that supports passwords stored in the mysql.global_priv table.\n\nThe ed25519, mysql_native_password, and mysql_old_password authentication plugins store passwords in the mysql.global_priv table.\n\nIf you run SET PASSWORD on an account that authenticates with one of these authentication plugins that stores passwords in the mysql.global_priv table, then the PASSWORD() function is evaluated by the specific authentication plugin used by the account. The authentication plugin hashes the password with a method that is compatible with that specific authentication plugin.\n\nThe unix_socket, named_pipe, gssapi, and pam authentication plugins do not store passwords in the mysql.global_priv table. These authentication plugins rely on other methods to authenticate the user.\n\nIf you attempt to run SET PASSWORD on an account that authenticates with one of these authentication plugins that doesn''t store a password in the mysql.global_priv table, then MariaDB Server will issue an error like the following:\n\n``\nSET PASSWORD IS ignored FOR users authenticating via unix_socket plugin\n``\n\nSee Authentication from MariaDB 10.4 for an overview of authentication changes in MariaDB.\n\nPasswordless User Accounts\n\nUser accounts do not always require passwords to login.\n\nThe unix_socket , named_pipe and gssapi authentication plugins do not require a password to authenticate the user.\n\nThe pam authentication plugin may or may not require a password to authenticate the user, depending on the specific configuration.\n\nThe mysql_native_password and mysql_old_password authentication plugins require passwords for authentication, but the password can be blank. In that case, no password is required.\n\nIf you provide a password while attempting to log into the server as an account that doesn''t require a password, then MariaDB server will simply ignore the password.\n\nA user account can be defined to use multiple authentication plugins in a specific order of preference. This specific scenario may be more noticeable in these versions, since an account could be associated with some authentication plugins that require a password, and some that do not.\n\nExamples\n--------\n\nSET PASSWORD FOR ''bob''@''%.loc.gov'' = PASSWORD(''newpass'');\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/set-password', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/set-password');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (501, 10, 'SET ROLE', 'Description\n-----------\n\nOnly one role can be current at a time. Executing SET ROLE replaces the current role; it does not add to a list of current roles. This is SQL Standard compliant behavior which differs from MySQL, where you may have several current roles at a time.\n\nThe SET ROLE statement switches the current role for the session, enabling its associated permissions. To have no current role, set NONE.\n\nIf a role that doesn''t exist, or to which the user has not been assigned, is specified, an ERROR 1959 (OP000): Invalid role specification error occurs.\n\nAn automatic SET ROLE is implicitly performed when a user connects if that user has been assigned a default role. See SET DEFAULT ROLE.\n\nExamples\n--------\n\n--Checking the current role status\nSELECT CURRENT_ROLE;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/set-role', '', 'https://mariadb.com/docs/server/reference/sql-statements/account-management-sql-statements/set-role');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (502, 26, 'ANALYZE FORMAT=JSON', 'Description\n-----------\n\nANALYZE FORMAT=JSON is a mix of the EXPLAIN FORMAT=JSON and ANALYZE statement features. The ANALYZE FORMAT=JSON $statement will execute $statement, and then print the output of EXPLAIN FORMAT=JSON, amended with data from the query execution.\n\nBasic Execution Data\n\nYou can get the following also from tabular ANALYZE statement form:\n\n r_rows is provided for any node that reads rows. It shows how many rows were read, on average.\n r_filtered is provided whenever there is a condition that is checked. It shows the percentage of rows left after checking the condition.\n\nAdvanced Execution Data\n\nThe most important data not available in the regular tabular ANALYZE statement are:\n\n r_loops field. This shows how many times the node was executed. Most query plan elements have this field.\n r_total_time_ms field. It shows how much time in total, in milliseconds, was spent executing this node. If the node has subnodes, their execution time is included.\n   For UPDATE and DELETE statements, top-level query_block.r_total_time_ms does include the time to make row deletions/updates but does NOT include the time to commit the changes.\n r_buffer_size field. Query plan nodes that make use of buffers report the size of buffer that was used.\n\nInnoDB engine statistics\n\nStarting from MariaDB 10.6.15, MariaDB 10.8.8, MariaDB 10.9.8, MariaDB 10.10.6, MariaDB 10.11.5, MariaDB 11.0.3, MariaDB 11.1.2 and MariaDB 11.2.1 (MDEV-31577), the following statistics are reported for InnoDB tables:\n\n``json\n"r_engine_stats": {\n        "pages_accessed":  integer,\n        "pages_updated": integer,\n        "pages_read_count": integer,\n        "pages_prefetch_read_count": integer,\n        "pages_read_time_ms": double,\n        "old_rows_read": integer\n      }\n`\n\nOnly non-zero members are printed.\n\n pages_accessed is the total number of buffer pool pages accessed when reading this table.\n pages_updated is the total number of buffer pool pages that were modified during the execution of the statement.\n pages_read_count is the number of pages that InnoDB had to read from disk for this table. If the query touches "hot" data in the InnoDB buffer pool, this value will be 0 and not present.\n pages_prefetch_read_count Number of pages for which read-ahead was initiated. Not all such pages will necessarily be accessed.\n pages_read_time_ms is the total time spent reading the table.\n old_rows_read is the number of old row versions that InnoDB had to read. Old row version is the version of the row that is not visible to this transaction.\n\nSHOW ANALYZE FORMAT=JSON\n\nMariaDB starting with 10.9\n\nSHOW ANALYZE FORMAT=JSON for <connection_id>\\\nextends ANALYZE [FORMAT=JSON] <select> to allow one to analyze a query currently running in another connection.\n\nData About Individual Query Plan Nodes\n\n filesort node reports whether sorting was done with LIMIT n parameter, and how many rows were in the sort result.\n block-nl-join node has r_loops field, which allows to tell whether Using join buffer was efficient.\n range-checked-for-each-record reports counters that show the result of the check.\n expression-cache is used for subqueries, and it reports how many times the cache was used, and what cache hit ratio was.\n* union_result node has r_rows` so one can see how many rows were produced after UNION operation and so forth.\n\nUse Cases\n\nSee Examples of ANALYZE FORMAT=JSON.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/analyze-and-explain-statements/analyze-format-json', '', 'https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/analyze-and-explain-statements/analyze-format-json');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (503, 26, 'ANALYZE FORMAT=JSON Examples', 'Examples\n--------\n\nANALYZE FORMAT=JSON\nSELECT COUNT()\nFROM customer\nWHERE\n  (SELECT SUM(o_totalprice) FROM orders WHERE o_custkey=c_custkey) > 10001000;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/analyze-and-explain-statements/analyze-formatjson-examples', '', 'https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/analyze-and-explain-statements/analyze-formatjson-examples');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (504, 26, 'ANALYZE: Interpreting rows and filtered members', 'Description\n-----------\n\nThis article describes how to interpret r_rows and r_filtered members in ANALYZE FORMAT=JSON when an index-based access method is used.\n\nIndex-based access method\n\nIndex-based access method may employ some or all of the following:\n\n Index Condition Pushdown\n Rowid Filtering\n attached_condition checking\n\nConsider a table access which does all three:\n\n``json\n"table": {\n    "table_name": "t1",\n    "access_type": "range",\n    "possible_keys": ...,\n    "key": "INDEX1",\n    ...\n    "rowid_filter": {\n      ...\n      "r_selectivity_pct": n.nnn,\n    },\n    ...\n    "rows": 123,\n    "r_rows": 125,\n    ...\n    "filtered": 8.476269722,\n    "r_filtered": 100,\n    "index_condition": "cond1",\n    "attached_condition": "cond2"\n  }\n`\n\nThe access is performed as follows:\n\nAccess diagram\n\n!index-read-diagram-3\n\nStatistics values in MariaDB before 11.5\n\nIn MariaDB versions before 11.5, the counters were counted as follows:\n\n!index-read-stats-old\n\nthat is,\n\n r_rows is counted after Index Condition Pushdown check and Rowid Filter check.\n r_filtered only counts selectivity of the attached_condition.\n selectivity of the Rowid Filter is in rowid_filter.r_selectivity_pct.\n\nStatistics values in MariaDB 11.5 and later versions\n\nStarting from MariaDB 11.5 (MDEV-18478), the row counters are:\n\n r_index_rows counts the number of enumerated index tuples, before any checks are made\n r_rows is the same as before - number of rows after index checks.\n\nThe selectivity counters are:\n\n r_icp_filtered is the percentage of records left after pushed index condition check.\n rowid_filter.r_selectivity_pct shows selectivity of Rowid Filter, as before.\n r_filtered is the selectivity of attached_condition check, as before.\n r_total_filtered is the combined selectivity of all checks.\n\n!index-read-stats-new\n\nANALYZE output members\n\nin ANALYZE FORMAT=JSON output these members are placed as follows:\n\n`json\n"table": {\n    "table_name": ...,\n\n    "rows": 426,\n    "r_index_rows": 349,\n    "r_rows": 34,\n`\n\nWhenever applicable, r_index_rows is shown. It is comparable with rows - both are numbers of rows to enumerate before any filtering is done.\\\nIf r_index_rows is not shown, r_rows shows the number of records enumerated.\n\nThen, filtering members:\n\n`json\n...\n    "filtered": 8.476269722,\n    "r_total_filtered": 9.742120344,\n`\n\nfiltered is comparable with r_total_filtered: both show total amount of filtering.\n\n`json\n...\n    "index_condition": "lineitem.l_quantity > 47",\n    "r_icp_filtered": 100,\n`\n\nICP and its observed filtering. The optimizer doesn''t compute an estimate for this currently.\n\n`json\n...\n    "attached_condition": "lineitem.l_shipDATE between ''1997-01-01'' and ''1997-06-30''",\n    "r_filtered": 100\n`\n\nattached_condition` and its observed filtering.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/analyze-and-explain-statements/analyze-interpreting-rows-and-filtered-members', '', 'https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/analyze-and-explain-statements/analyze-interpreting-rows-and-filtered-members');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (505, 26, 'ANALYZE Statement', 'Description\n-----------\n\nThe ANALYZE statement is similar to the EXPLAIN statement. ANALYZE statement will invoke the optimizer, execute the statement, and then produce EXPLAIN output instead of the result set. The EXPLAIN output will be annotated with statistics from statement execution.\n\nThis lets one check how close the optimizer''s estimates about the query plan are to the reality. ANALYZE produces an overview, while the ANALYZE FORMAT=JSON command provides a more detailed view of the query plan and the query execution.\n\nThe syntax is\n\n``sql\nANALYZE explainable_statement;\n`\n\nwhere the statement is any statement for which one can run EXPLAIN.\n\nCommand Output\n\nConsider an example:\n\n`sql\nANALYZE SELECT  FROM tbl1 \nWHERE key1 \n  BETWEEN 10 AND 200 AND \n  col1 LIKE ''foo%''\\G\n`\n\n`\n*********************** 1. row ***********************\n           id: 1\n  select_type: SIMPLE\n        table: tbl1\n         type: range\npossible_keys: key1\n          key: key1\n      key_len: 5\n          ref: NULL\n         rows: 181\n       r_rows: 181\n     filtered: 100.00\n   r_filtered: 10.50\n        Extra: Using index condition; Using where\n`\n\nCompared to EXPLAIN, ANALYZE produces two extra columns:\n\n r_rows is an observation-based counterpart of the rows column. It shows how many rows were actually read from the table.\n r_filtered is an observation-based counterpart of the filtered column. It shows which fraction of rows was left after applying the WHERE condition.\n\n> These r_rows and r_filtered columns are also included in the EXPLAIN output written to the slow query log in MariaDB 10.1.0 and later. This explains why, even though they are not displayed by a standard EXPLAIN statement, some columns may appear in slow query log data.\n\nInterpreting the Output\n\nJoins\n\nLet''s consider a more complicated example.\n\n`sql\nANALYZE SELECT \nFROM orders, customer \nWHERE\n  customer.c_custkey=orders.o_custkey AND\n  customer.c_acctbal < 0 AND\n  orders.o_totalprice > 2001000\n`\n\n`\n+----+-------------+----------+------+---------------+-------------+---------+--------------------+--------+--------+----------+------------+-------------+\n| id | select_type | table    | type | possible_keys | key         | key_len | ref                | rows   | r_rows | filtered | r_filtered | Extra       |\n+----+-------------+----------+------+---------------+-------------+---------+--------------------+--------+--------+----------+------------+-------------+\n|  1 | SIMPLE      | customer | ALL  | PRIMARY,...   | NULL        | NULL    | NULL               | 149095 | 150000 |    18.08 |       9.13 | Using where |\n|  1 | SIMPLE      | orders   | ref  | i_o_custkey   | i_o_custkey | 5       | customer.c_custkey |      7 |     10 |   100.00 |      30.03 | Using where |\n+----+-------------+----------+------+---------------+-------------+---------+--------------------+--------+--------+----------+------------+-------------+\n`\n\nHere, one can see that\n\n For table customer, customer.rows=149095, customer.r_rows=150000. The estimate for number of rows we will read was fairly precise\n customer.filtered=18.08, customer.r_filtered=9.13. The optimizer somewhat overestimated the number of records that will match selectivity of condition attached to customer table (in general, when you have a full scan and r_filtered is less than 15%, it''s time to consider adding an appropriate index).\n For table orders, orders.rows=7, orders.r_rows=10. This means that on average, there are 7 orders for a given c_custkey, but in our case there were 10, which is close to the expectation (when this number is consistently far from the expectation, it may be time to run ANALYZE TABLE, or even edit the table statistics manually to get better query plans).\n orders.filtered=100, orders.r_filtered=30.03. The optimizer didn''t have any way to estimate which fraction of records will be left after it checks the condition that is attached to table orders (it''s orders.o_totalprice > 200\\1000). So, it used 100%. In reality, it is 30%. 30% is typically not selective enough to warrant adding new indexes. For joins with many tables, it might be worth to collect and use column statistics for columns in question, this may help the optimizer to pick a better query plan.\n\nMeaning of NULL in r_rows and r_filtered\n\nLet''s modify the previous example slightly\n\n`sql\nANALYZE SELECT  \nFROM orders, customer \nWHERE\n  customer.c_custkey=orders.o_custkey AND\n  customer.c_acctbal < -0 AND \n  customer.c_comment LIKE ''%foo%'' AND\n  orders.o_totalprice > 2001000;\n`\n\n`\n+----+-------------+----------+------+---------------+-------------+---------+--------------------+--------+--------+----------+------------+-------------+\n| id | select_type | table    | type | possible_keys | key         | key_len | ref                | rows   | r_rows | filtered | r_filtered | Extra       |\n+----+-------------+----------+------+---------------+-------------+---------+--------------------+--------+--------+----------+------------+-------------+\n|  1 | SIMPLE      | customer | ALL  | PRIMARY,...   | NULL        | NULL    | NULL               | 149095 | 150000 |    18.08 |       0.00 | Using where |\n|  1 | SIMPLE      | orders   | ref  | i_o_custkey   | i_o_custkey | 5       | customer.c_custkey |      7 |   NULL |   100.00 |       NULL | Using where |\n+----+-------------+----------+------+---------------+-------------+---------+--------------------+--------+--------+----------+------------+-------------+\n`\n\nThe output of orders.r_rows=NULL and orders.r_filtered=NULL shows that the table orders was never scanned. Indeed, we can also see customer.r_filtered=0.00. This shows that a part of WHERE attached to table customer was never satisfied (or, satisfied in less than 0.01% of cases).\n\nANALYZE FORMAT=JSON\n\nANALYZE FORMAT=JSON produces JSON output. It produces much more information than tabular ANALYZE.\n\nNotes\n\n ANALYZE UPDATE or ANALYZE DELETE will actually make updates/deletes (ANALYZE SELECT will perform the select operation and then discard the resultset).\n PostgreSQL has a similar command, EXPLAIN ANALYZE.\n* The EXPLAIN in the slow query log feature allows MariaDB to have ANALYZE` output of slow queries printed into the slow query log (see MDEV-6388).\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/analyze-and-explain-statements/analyze-statement', '', 'https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/analyze-and-explain-statements/analyze-statement');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (506, 26, 'EXPLAIN ANALYZE', 'Description\n-----------\n\nOutdated syntax\n\nThe syntax for the EXPLAIN ANALYZE feature was changed to ANALYZE statement, available since MariaDB 10.1.0. See ANALYZE statement.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/analyze-and-explain-statements/explain-analyze', '', 'https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/analyze-and-explain-statements/explain-analyze');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (507, 26, 'EXPLAIN FORMAT=JSON', 'Description\n-----------\n\nSynopsis\n\nEXPLAIN FORMAT=JSON is a variant of EXPLAIN command that produces output in JSON form. The output always has one row which has only one column titled "JSON". The contents are a JSON representation of the query plan:\n\n``sql\nEXPLAIN FORMAT=JSON SELECT  FROM t1 WHERE col1=1\\G\n`\n\n`\n*********************** 1. row ***********************\nEXPLAIN: {\n  "query_block": {\n    "select_id": 1,\n    "table": {\n      "table_name": "t1",\n      "access_type": "ALL",\n      "rows": 1000,\n      "filtered": 100,\n      "attached_condition": "(t1.col1 = 1)"\n    }\n  }\n}\n`\n\nOutput is different from MySQL\n\nThe output of MariaDB''s EXPLAIN FORMAT=JSON is different from EXPLAIN FORMAT=JSON in MySQL. The reasons for that are:\n\n MySQL''s output has deficiencies.\n The output of MySQL''s EXPLAIN FORMAT=JSON` is not defined. Even MySQL Workbench has trouble parsing it (see this blog post).\n MariaDB has query optimizations that MySQL does not have. This means that MariaDB generates query plans that MySQL does not generate.\n\nOutput Format\n\nTODO: MariaDB''s output format description.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/analyze-and-explain-statements/explain-format-json', '', 'https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/analyze-and-explain-statements/explain-format-json');
INSERT INTO help_topic (help_topic_id, help_category_id, name, description, example, url) VALUES (508, 26, 'EXPLAIN', 'Syntax\n------\n\nEXPLAIN tbl_name [col_name | wildcard]\n\nDescription\n-----------\n\nThe EXPLAIN statement can be used either as a synonym for DESCRIBE, or as a way to obtain information about how MariaDB executes a SELECT, UPDATE or DELETE statement:\n\n ''EXPLAIN tbl_name'' is synonymous with DESCRIBE or SHOW COLUMNS ... FROM _mytable_.\n When you precede a SELECT, UPDATE or a DELETE statement with the keyword EXPLAIN, MariaDB displays information from the optimizer about the query execution plan. That is, MariaDB explains how it would process the SELECT, UPDATE or DELETE, including information about how tables are joined and in which order. EXPLAIN EXTENDED can be used to provide additional information.\n EXPLAIN PARTITIONS is useful only when examining queries involving partitioned tables. For details, see Partition pruning and selection.\n The ANALYZE statement is similar to EXPLAIN, but it runs the query rather than only estimating the execution path. Hence, the ANALYZE statement provides both estimated and real execution statistics. This includes the r_rows and r_filtered columns, which reflect the actual number of rows evaluated and filtered during query execution.\n EXPLAIN output can be printed in the slow query log. See EXPLAIN in the Slow Query Log for details.\n EXPLAIN FOR CONNECTION is an alias for SHOW EXPLAIN FOR.\n\nSHOW EXPLAIN shows the output of a running statement. In some cases, its output can be closer to reality than EXPLAIN.\n\nThe ANALYZE statement runs a statement and returns information about its execution plan. It also shows additional columns, to check how much the optimizer''s estimation about filtering and found rows are close to reality.\n\nThere is an online EXPLAIN Analyzer that you can use to share EXPLAIN and EXPLAIN EXTENDED output with others.\n\nEXPLAIN can acquire metadata locks in the same way that SELECT does, as it needs to know table metadata and, sometimes, data as well.\n\nColumns in EXPLAIN ... SELECT\n\n| Column name    | Description                                                                                         |\n| -------------- | --------------------------------------------------------------------------------------------------- |\n| id             | Sequence number that shows in which order tables are joined.                                        |\n| select_type   | What kind of SELECT the table comes from.                                                         |\n| table          | Alias name of table. Materialized temporary tables for sub queries are named <subquery#>          |\n| type           | How rows are found from the table (join type).                                                      |\n| possible_keys | keys in table that could be used to find rows in the table                                          |\n| key            | The name of the key that is used to retrieve rows. NULL means no key was used.                    |\n| key_len       | How many bytes of the key that was used (shows if we are using only parts of the multi-column key). |\n| ref            | The reference that is used as the key value.                                                        |\n| rows           | An estimate of how many rows we will find in the table for each key lookup.                         |\n| Extra          | Extra information about this join.                                                                  |\n\nHere are descriptions of the values for some of the more complex columns in EXPLAIN ... SELECT:\n\nSelect_type Column\n\nThe select_type column can have the following values:\n\n| Value                | Description                                                                                                                                                                                     | Comment                                                                                                                                                                              |\n| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| DEPENDENT SUBQUERY   | The SUBQUERY is DEPENDENT.                                                                                                                                                                  |                                                                                                                                                                                      |\n| DEPENDENT UNION      | The UNION is DEPENDENT.                                                                                                                                                                     |                                                                                                                                                                                      |\n| DERIVED              | The SELECT is DERIVED from the PRIMARY.                                                                                                                                                   |                                                                                                                                                                                      |\n| MATERIALIZED         | The SUBQUERY is MATERIALIZED.                     | Materialized tables will be populated at first access and will be accessed by the primary key (= one key lookup). Number of rows in EXPLAIN shows the cost of populating the table |\n| PRIMARY              | The SELECT is in the outermost query, but there is also a SUBQUERY within it.                                                                                                               |                                                                                                                                                                                      |\n| SIMPLE               | It is a simple SELECT query without any SUBQUERY or UNION.                                                                                                                                |                                                                                                                                                                                      |\n| SUBQUERY             | The SELECT is a SUBQUERY of the PRIMARY.                                                                                                                                                  |                                                                                                                                                                                      |\n| UNCACHEABLE SUBQUERY | The SUBQUERY is UNCACHEABLE.                                                                                                                                                                |                                                                                                                                                                                      |\n| UNCACHEABLE UNION    | The UNION is UNCACHEABLE.                                                                                                                                                                   |                                                                                                                                                                                      |\n| UNION                | The SELECT is a UNION of the PRIMARY.                                                                                                                                                     |                                                                                                                                                                                      |\n| UNION RESULT         | The result of the UNION.                                                                                                                                                                      |                                                                                                                                                                                      |\n| LATERAL DERIVED      | The SELECT uses a Lateral Derived optimization |                                                                                                                                                                                      |\n\nType Column\n\nThis column contains information on how the table is accessed.\n\n| Value            | Description                                                                                                                                                                                                                      |\n| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| ALL              | A full table scan is done for the table (all rows are read). This is bad if the table is large and the table is joined against a previous table! This happens when the optimizer could not find any usable index to access rows. |\n| const            | There is only one possibly matching row in the table. The row is read before the optimization phase and all columns in the table are treated as constants.                                                                       |\n| eq_ref          | A unique index is used to find the rows. This is the best possible plan to find the row.                                                                                                                                         |\n| filter           | A second index is being used with the Rowid Filtering Optimization.                                                |\n| fulltext         | A fulltext index is used to access the rows.                                                                                                                                                                                     |\n| index_merge     | A ''range'' access is done for several index and the found rows are merged. The key column shows which keys are used.                                                                                                              |\n| index_subquery  | This is similar as ref, but used for sub queries that are transformed to key lookups.                                                                                                                                            |\n| index            | A full scan over the used index. Better than ALL but still bad if index is large and the table is joined against a previous table.                                                                                             |\n| range            | The table will be accessed with a key over one or more value ranges.                                                                                                                                                             |\n| ref_or_null    | Like ''ref'' but in addition another search for the ''null'' value is done if the first value was not found. This happens usually with sub queries.                                                                                  |\n| ref              | A non unique index or prefix of an unique index is used to find the rows. Good if the prefix doesn''t match many rows.                                                                                                            |\n| system           | The table has 0 or 1 rows.                                                                                                                                                                                                       |\n| unique_subquery | This is similar as eq_ref, but used for sub queries that are transformed to key lookups                                                                                                                                         |\n\nExtra Column\n\nThis column consists of one or more of the following values, separated by '';''\n\n_Note that some of these values are detected after the optimization phase._\n\nThe optimization phase can do the following changes to the WHERE clause:\n\n Add the expressions from the ON and USING clauses to the WHERE clause.\n Constant propagation: If there is column=constant, replace all column instances with this constant.\n Replace all columns from ''const'' tables with their values.\n Remove the used key columns from the WHERE (as this will be tested as part of the key lookup).\n Remove impossible constant sub expressions. For example WHERE ''(a=1 and a=2) OR b=1'' becomes ''b=1''.\n Replace columns with other columns that has identical values: Example: WHERE a=b and a=c may be treated as ''WHERE a=b and a=c and b=c''.\n Add extra conditions to detect impossible row conditions earlier. This happens mainly with OUTER JOIN where we in some cases add detection of NULL values in the WHERE (Part of ''Not exists'' optimization). This can cause an unexpected ''Using where'' in the Extra column.\n For each table level we remove expressions that have already been tested when we read the previous row. Example: When joining tables t1 with t2 using the following WHERE ''t1.a=1 and t1.a=t2.b'', we don''t have to test ''t1.a=1'' when checking rows in t2 as we already know that this expression is true.\n\n| Value                                                | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n| ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| const row not found\n\n[Truncated — full content at mariadb.com/docs]', '', 'https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/analyze-and-explain-statements/explain');
