Commit 41c6b844 authored by Yuchen Pei's avatar Yuchen Pei Committed by Sergei Golubchik

MDEV-15696 Implement SHOW CREATE SERVER

One change is that if the port is not supplied or out of bound, the
old behaviour is to print 3306. The new behaviour is to not print
it (if not supplied) or the out of bound value.
parent 698e8fa3
......@@ -5139,33 +5139,25 @@ static int dump_all_udfs()
static int dump_all_servers()
{
/* No create server yet - MDEV-15696 */
MYSQL_ROW row;
MYSQL_RES *tableres;
MYSQL_FIELD *f;
unsigned int num_fields, i;
my_bool comma_prepend= 0;
const char *qstring;
MYSQL_RES *tableres, *serverres;
if (mysql_query_with_error_report(mysql, &tableres, "SELECT * FROM mysql.servers"))
if (mysql_query_with_error_report(mysql, &tableres,
"SELECT Server_name FROM mysql.servers"))
return 1;
num_fields= mysql_num_fields(tableres);
while ((row= mysql_fetch_row(tableres)))
{
fprintf(md_result_file,"CREATE %sSERVER %s%s FOREIGN DATA WRAPPER %s OPTIONS (",
/* row[0] is the server name */
char buff[20+FN_REFLEN];
my_snprintf(buff, sizeof(buff), "show create server %s", row[0]);
if (mysql_query_with_error_report(mysql, &serverres, buff))
return 1;
row= mysql_fetch_row(serverres);
row[1]+= 14; /* strlen("CREATE SERVER ") == 14 */
fprintf(md_result_file, "CREATE %sSERVER %s%s\n",
opt_replace_into ? "/*M!100103 OR REPLACE */ ": "",
opt_ignore ? "/*M!100103 IF NOT EXISTS */ " : "", row[0], row[7]);
for (i= 1; i < num_fields; i++)
{
if (i == 7 || row[i][0] == '\0') /* Wrapper or empty string */
continue;
f= &tableres->fields[i];
qstring= (f->type == MYSQL_TYPE_STRING || f->type == MYSQL_TYPE_VAR_STRING) ? "'" : "";
fprintf(md_result_file, "%s%s %s%s%s",
(comma_prepend ? ", " : ""), f->name, qstring, row[i], qstring);
comma_prepend= 1;
}
fputs(");\n", md_result_file);
opt_ignore ? "/*M!100103 IF NOT EXISTS */ " : "", row[1]);
mysql_free_result(serverres);
}
mysql_free_result(tableres);
......
......@@ -1907,7 +1907,7 @@ performance-schema-max-socket-classes 10
performance-schema-max-socket-instances -1
performance-schema-max-sql-text-length 1024
performance-schema-max-stage-classes 160
performance-schema-max-statement-classes 222
performance-schema-max-statement-classes 223
performance-schema-max-statement-stack 10
performance-schema-max-table-handles -1
performance-schema-max-table-instances -1
......
......@@ -6,7 +6,7 @@
mysql.time_zone_transition 3719776009
-mysql.plugin 1587119305
+mysql.plugin 2184891911
mysql.servers 2180549486
mysql.servers 3232626815
-mysql.func 3241572444
+mysql.func 310494789
mysql.innodb_table_stats 1972297402
......@@ -17,8 +17,8 @@
mysql.roles_mapping 2510045525
mysql.time_zone_transition 3719776009
-mysql.plugin 1587119305
+mysql.plugin 2180549486
mysql.servers 2079085450
+mysql.plugin 2184891911
mysql.servers 3232626815
-mysql.func 3241572444
+mysql.func 310494789
mysql.innodb_table_stats 1972297402
......
......@@ -90,7 +90,7 @@ SET ROLE NONE;
DROP ROLE mariadb_dump_import_role;
/*M!100203 EXECUTE IMMEDIATE CONCAT('SET ROLE ', @current_role) */;
CREATE FUNCTION metaphon RETURNS STRING SONAME 'UDF_EXAMPLE_LIB';
CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS (Host 'localhost', Port 3306);
CREATE SERVER `s1` FOREIGN DATA WRAPPER mysql OPTIONS (Host 'localhost');
USE mysql;
......@@ -710,7 +710,7 @@ DROP ROLE mariadb_dump_import_role;
/*M!100203 EXECUTE IMMEDIATE CONCAT('SET ROLE ', @current_role) */;
/*!50701 DROP FUNCTION IF EXISTS metaphon */;
CREATE /*M!100103 OR REPLACE */ FUNCTION metaphon RETURNS STRING SONAME 'UDF_EXAMPLE_LIB';
CREATE /*M!100103 OR REPLACE */ SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS (Host 'localhost', Port 3306);
CREATE /*M!100103 OR REPLACE */ SERVER `s1` FOREIGN DATA WRAPPER mysql OPTIONS (Host 'localhost');
USE mysql;
......@@ -1307,7 +1307,7 @@ SET ROLE NONE;
DROP ROLE mariadb_dump_import_role;
/*M!100203 EXECUTE IMMEDIATE CONCAT('SET ROLE ', @current_role) */;
CREATE FUNCTION IF NOT EXISTS metaphon RETURNS STRING SONAME 'UDF_EXAMPLE_LIB';
CREATE SERVER /*M!100103 IF NOT EXISTS */ s1 FOREIGN DATA WRAPPER mysql OPTIONS (Host 'localhost', Port 3306);
CREATE SERVER /*M!100103 IF NOT EXISTS */ `s1` FOREIGN DATA WRAPPER mysql OPTIONS (Host 'localhost');
USE mysql;
......@@ -1865,7 +1865,7 @@ Table Checksum
mysql.roles_mapping 2510045525
mysql.time_zone_transition 3719776009
mysql.plugin 1587119305
mysql.servers 2180549486
mysql.servers 3232626815
mysql.func 3241572444
mysql.innodb_table_stats 1972297402
mysql.table_stats 1911089388
......@@ -1900,7 +1900,7 @@ Table Checksum
mysql.roles_mapping 2510045525
mysql.time_zone_transition 3719776009
mysql.plugin 1587119305
mysql.servers 2180549486
mysql.servers 3232626815
mysql.func 3241572444
mysql.innodb_table_stats 1972297402
mysql.table_stats 1911089388
......
......@@ -29,3 +29,38 @@ SELECT Socket FROM mysql.servers where Server_name = 's1';
Socket
/tmp/1234567890_1234567890_1234567890_1234567890_1234567890_1234567890.sock
DROP SERVER s1;
#
# MDEV-34716 - Arbitrary OPTIONS for CREATE SERVER
# MDEV-15696 - SHOW CREATE SERVER
#
create server srv foreign data wrapper mysql options
(host "localhost", port 12345, wait_what "it's all good");
show create server srv;
Server Create Server
srv CREATE SERVER `srv` FOREIGN DATA WRAPPER mysql OPTIONS (host 'localhost', port '12345', wait_what 'it''s all good');
create or replace server srv foreign data wrapper Foo options
(host "somewhere.else", port 54321, wait_what "it's all good", foo 'bar');
show create server srv;
Server Create Server
srv CREATE SERVER `srv` FOREIGN DATA WRAPPER Foo OPTIONS (host 'somewhere.else', port '54321', wait_what 'it''s all good', foo 'bar');
alter server srv options (socket "sock", port 123, foo "", bar ")\"{");
show create server srv;
Server Create Server
srv CREATE SERVER `srv` FOREIGN DATA WRAPPER Foo OPTIONS (host 'somewhere.else', wait_what 'it''s all good', socket 'sock', port '123', foo '', bar ')"{');
alter server srv options (socket "sock", port 123, bar "quux");
show create server srv;
Server Create Server
srv CREATE SERVER `srv` FOREIGN DATA WRAPPER Foo OPTIONS (host 'somewhere.else', wait_what 'it''s all good', foo '', socket 'sock', port '123', bar 'quux');
create or replace server srv foreign data wrapper foo options
(host "localhost", port "12345");
create or replace server srv foreign data wrapper mysql options
(host "localhost", port "bar321");
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '"bar321")' at line 2
create or replace server srv foreign data wrapper mysql options
(host "localhost", port "123bar");
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '"123bar")' at line 2
create or replace server srv foreign data wrapper mysql options
(host "localhost", port "0");
show create server nonexist;
ERROR HY000: The foreign server name you are trying to reference does not exist. Data source error: nonexist
drop server srv;
......@@ -26,3 +26,41 @@ DROP SERVER s1;
CREATE SERVER s1 FOREIGN DATA WRAPPER mysql OPTIONS(SOCKET '/tmp/1234567890_1234567890_1234567890_1234567890_1234567890_1234567890.sock');
SELECT Socket FROM mysql.servers where Server_name = 's1';
DROP SERVER s1;
--echo #
--echo # MDEV-34716 - Arbitrary OPTIONS for CREATE SERVER
--echo # MDEV-15696 - SHOW CREATE SERVER
--echo #
create server srv foreign data wrapper mysql options
(host "localhost", port 12345, wait_what "it's all good");
show create server srv;
create or replace server srv foreign data wrapper Foo options
(host "somewhere.else", port 54321, wait_what "it's all good", foo 'bar');
show create server srv;
alter server srv options (socket "sock", port 123, foo "", bar ")\"{");
show create server srv;
alter server srv options (socket "sock", port 123, bar "quux");
show create server srv;
create or replace server srv foreign data wrapper foo options
(host "localhost", port "12345");
--error ER_PARSE_ERROR
create or replace server srv foreign data wrapper mysql options
(host "localhost", port "bar321");
--error ER_PARSE_ERROR
create or replace server srv foreign data wrapper mysql options
(host "localhost", port "123bar");
create or replace server srv foreign data wrapper mysql options
(host "localhost", port "0");
--error ER_FOREIGN_SERVER_DOESNT_EXIST
show create server nonexist;
drop server srv;
......@@ -146,11 +146,12 @@ def mysql roles_mapping Role 3 '' NO char 128 384 NULL NULL NULL utf8mb3 utf8mb3
def mysql roles_mapping User 2 '' NO char 128 384 NULL NULL NULL utf8mb3 utf8mb3_bin char(128) PRI NEVER NULL NO NO
def mysql servers Db 3 '' NO char 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(64) NEVER NULL NO NO
def mysql servers Host 2 '' NO varchar 2048 6144 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(2048) NEVER NULL NO NO
def mysql servers Options 10 '{}' NO longtext 4294967295 4294967295 NULL NULL NULL utf8mb4 utf8mb4_bin longtext NEVER NULL NO NO
def mysql servers Owner 9 '' NO varchar 512 1536 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(512) NEVER NULL NO NO
def mysql servers Password 5 '' NO char 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(64) NEVER NULL NO NO
def mysql servers Port 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(4) NEVER NULL NO NO
def mysql servers Server_name 1 '' NO char 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(64) PRI NEVER NULL NO NO
def mysql servers Socket 7 '' NO char 108 324 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(64) NEVER NULL NO NO
def mysql servers Socket 7 '' NO char 108 324 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(108) NEVER NULL NO NO
def mysql servers Username 4 '' NO char 128 384 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(128) NEVER NULL NO NO
def mysql servers Wrapper 8 '' NO char 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci char(64) NEVER NULL NO NO
def mysql slow_log db 7 NULL NO varchar 512 1536 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(512) NEVER NULL NO NO
......@@ -475,9 +476,10 @@ NULL mysql proxies_priv Timestamp timestamp NULL NULL NULL NULL timestamp
3.0000 mysql servers Username char 128 384 utf8mb3 utf8mb3_general_ci char(128)
3.0000 mysql servers Password char 64 192 utf8mb3 utf8mb3_general_ci char(64)
NULL mysql servers Port int NULL NULL NULL NULL int(4)
3.0000 mysql servers Socket char 108 324 utf8mb3 utf8mb3_general_ci char(64)
3.0000 mysql servers Socket char 108 324 utf8mb3 utf8mb3_general_ci char(108)
3.0000 mysql servers Wrapper char 64 192 utf8mb3 utf8mb3_general_ci char(64)
3.0000 mysql servers Owner varchar 512 1536 utf8mb3 utf8mb3_general_ci varchar(512)
1.0000 mysql servers Options longtext 4294967295 4294967295 utf8mb4 utf8mb4_bin longtext
NULL mysql slow_log start_time timestamp NULL NULL NULL NULL timestamp(6)
1.0000 mysql slow_log user_host mediumtext 16777215 16777215 utf8mb3 utf8mb3_general_ci mediumtext
NULL mysql slow_log query_time time NULL NULL NULL NULL time(6)
......
......@@ -30,6 +30,7 @@ def mysql PRIMARY mysql proc PRIMARY KEY
def mysql PRIMARY mysql procs_priv PRIMARY KEY
def mysql PRIMARY mysql proxies_priv PRIMARY KEY
def mysql Host mysql roles_mapping UNIQUE
def mysql Options mysql servers CHECK
def mysql PRIMARY mysql servers PRIMARY KEY
def mysql PRIMARY mysql tables_priv PRIMARY KEY
def mysql PRIMARY mysql table_stats PRIMARY KEY
......@@ -68,6 +69,7 @@ def mysql PRIMARY mysql proc PRIMARY KEY
def mysql PRIMARY mysql procs_priv PRIMARY KEY
def mysql PRIMARY mysql proxies_priv PRIMARY KEY
def mysql Host mysql roles_mapping UNIQUE
def mysql Options mysql servers CHECK
def mysql PRIMARY mysql servers PRIMARY KEY
def mysql PRIMARY mysql tables_priv PRIMARY KEY
def mysql PRIMARY mysql table_stats PRIMARY KEY
......
......@@ -515,7 +515,7 @@ TABLE_SCHEMA mysql
TABLE_NAME servers
TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA
VERSION 10
VERSION 11
ROW_FORMAT DYNAMIC_OR_PAGE
TABLE_ROWS #TBLR#
AVG_ROW_LENGTH #ARL#
......@@ -1304,7 +1304,7 @@ TABLE_SCHEMA mysql
TABLE_NAME servers
TABLE_TYPE BASE TABLE
ENGINE MYISAM_OR_MARIA
VERSION 10
VERSION 11
ROW_FORMAT DYNAMIC_OR_PAGE
TABLE_ROWS #TBLR#
AVG_ROW_LENGTH #ARL#
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 1
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -251,7 +251,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -57,7 +57,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 0
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 0
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 0
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 0
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 0
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 10
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -135,7 +135,7 @@ performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_sql_text_length 1024
performance_schema_max_stage_classes 160
performance_schema_max_statement_classes 222
performance_schema_max_statement_classes 223
performance_schema_max_statement_stack 2
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
......
......@@ -3569,6 +3569,7 @@ SHOW_VAR com_status_vars[]= {
{"show_create_package", STMT_STATUS(SQLCOM_SHOW_CREATE_PACKAGE)},
{"show_create_package_body",STMT_STATUS(SQLCOM_SHOW_CREATE_PACKAGE_BODY)},
{"show_create_proc", STMT_STATUS(SQLCOM_SHOW_CREATE_PROC)},
{"show_create_server", STMT_STATUS(SQLCOM_SHOW_CREATE_SERVER)},
{"show_create_table", STMT_STATUS(SQLCOM_SHOW_CREATE)},
{"show_create_trigger", STMT_STATUS(SQLCOM_SHOW_CREATE_TRIGGER)},
{"show_create_user", STMT_STATUS(SQLCOM_SHOW_CREATE_USER)},
......
......@@ -111,6 +111,7 @@ enum enum_sql_command {
SQLCOM_SHOW_STATUS_PACKAGE_BODY,
SQLCOM_SHOW_PACKAGE_BODY_CODE,
SQLCOM_BACKUP, SQLCOM_BACKUP_LOCK,
SQLCOM_SHOW_CREATE_SERVER,
/*
When a command is added here, be sure it's also added in mysqld.cc
......
......@@ -5089,6 +5089,10 @@ mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt)
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
res= show_create_db(thd, lex);
break;
case SQLCOM_SHOW_CREATE_SERVER:
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
res= mysql_show_create_server(thd, &lex->name);
break;
case SQLCOM_CREATE_EVENT:
case SQLCOM_ALTER_EVENT:
#ifdef HAVE_EVENT_SCHEDULER
......
......@@ -47,6 +47,7 @@
#include "sql_derived.h"
#include "sql_statistics.h"
#include "sql_connect.h"
#include "sql_servers.h"
#include "sql_repl.h" // rpl_load_gtid_state
#include "rpl_mi.h" // master_info_index
#include "authors.h"
......@@ -1520,6 +1521,61 @@ bool mysqld_show_create_db(THD *thd, LEX_CSTRING *dbname,
DBUG_RETURN(FALSE);
}
bool mysql_show_create_server(THD *thd, LEX_CSTRING *name)
{
MEM_ROOT *mem_root= thd->mem_root;
FOREIGN_SERVER *server, server_buf;
Protocol *protocol=thd->protocol;
List<Item> field_list;
char buff[4096];
String buffer(buff, sizeof(buff), system_charset_info);
DBUG_ENTER("mysql_show_create_server");
if (!(server= get_server_by_name(mem_root, name->str, &server_buf)))
{
my_error(ER_FOREIGN_SERVER_DOESNT_EXIST, MYF(0), name->str);
DBUG_RETURN(TRUE);
}
field_list.push_back(new (mem_root)
Item_empty_string(thd, "Server", NAME_CHAR_LEN),
mem_root);
field_list.push_back(new (mem_root)
Item_empty_string(thd, "Create Server", 1024),
mem_root);
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS |
Protocol::SEND_EOF))
DBUG_RETURN(TRUE);
protocol->prepare_for_resend();
protocol->store(name->str, name->length, system_charset_info);
buffer.length(0);
buffer.append(STRING_WITH_LEN("CREATE SERVER "));
append_identifier(thd, &buffer, name);
buffer.append(STRING_WITH_LEN(" FOREIGN DATA WRAPPER "));
buffer.append(server->scheme, strlen(server->scheme));
buffer.append(STRING_WITH_LEN(" OPTIONS ("));
engine_option_value* option= server->option_list;
bool first= true;
while (option)
{
if (!first)
buffer.append(STRING_WITH_LEN(", "));
buffer.append(option->name);
buffer.append(STRING_WITH_LEN(" "));
append_unescaped(&buffer, option->value.str, option->value.length);
first= false;
option= option->next;
}
buffer.append(STRING_WITH_LEN(");"));
protocol->store(buffer.ptr(), buffer.length(), buffer.charset());
if (protocol->write())
DBUG_RETURN(TRUE);
my_eof(thd);
DBUG_RETURN(FALSE);
}
/****************************************************************************
......
......@@ -109,6 +109,7 @@ void mysqld_show_create_db_get_fields(THD *thd, List<Item> *field_list);
bool mysqld_show_create_db(THD *thd, LEX_CSTRING *db_name,
LEX_CSTRING *orig_db_name,
const DDL_options_st &options);
bool mysql_show_create_server(THD *thd, LEX_CSTRING *name);
void mysqld_list_processes(THD *thd,const char *user,bool verbose);
int mysqld_show_status(THD *thd);
......
......@@ -14394,6 +14394,12 @@ show_param:
lex->sql_command = SQLCOM_SHOW_CREATE_PACKAGE_BODY;
lex->spname= $4;
}
| CREATE SERVER_SYM ident_or_text
{
LEX *lex= Lex;
lex->sql_command = SQLCOM_SHOW_CREATE_SERVER;
lex->name= $3;
}
| CREATE TRIGGER_SYM sp_name
{
LEX *lex= Lex;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment