1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Merge 10.7 into 10.8

This commit is contained in:
Marko Mäkelä
2022-04-27 10:43:00 +03:00
301 changed files with 9772 additions and 8644 deletions

View File

@@ -19,7 +19,7 @@ DELIMITER $$
CREATE DEFINER='mariadb.sys'@'localhost' PROCEDURE table_exists (
IN in_db VARCHAR(64), IN in_table VARCHAR(64),
OUT out_exists ENUM('', 'BASE TABLE', 'VIEW', 'TEMPORARY')
OUT out_exists ENUM('', 'BASE TABLE', 'VIEW', 'TEMPORARY', 'SEQUENCE', 'SYSTEM VIEW')
)
COMMENT '
Description
@@ -41,10 +41,12 @@ CREATE DEFINER='mariadb.sys'@'localhost' PROCEDURE table_exists (
out_exists ENUM('''', ''BASE TABLE'', ''VIEW'', ''TEMPORARY''):
The return value: whether the table exists. The value is one of:
* '''' - the table does not exist neither as a base table, view, nor temporary table.
* ''BASE TABLE'' - the table name exists as a permanent base table table.
* ''VIEW'' - the table name exists as a view.
* ''TEMPORARY'' - the table name exists as a temporary table.
* '''' - the table does not exist neither as a base table, view, sequence nor temporary table.
* ''BASE TABLE'' - the table name exists as a permanent base table table.
* ''VIEW'' - the table name exists as a view.
* ''TEMPORARY'' - the table name exists as a temporary table.
* ''SEQUENCE'' - the table name exists as a sequence.
* ''SYSTEM VIEW'' - the table name exists as a system view.
Example
--------
@@ -96,6 +98,26 @@ CREATE DEFINER='mariadb.sys'@'localhost' PROCEDURE table_exists (
+---------+
1 row in set (0.00 sec)
MariaDB [sys]> CALL sys.table_exists(''db1'', ''s'', @exists); SELECT @exists;
Query OK, 0 rows affected (0.006 sec)
+----------+
| @exists |
+----------+
| SEQUENCE |
+----------+
1 row in set (0.000 sec)
MariaDB [sys]> CALL table_exists(''information_schema'', ''user_variables'', @exists); SELECT @exists;
Query OK, 0 rows affected (0.003 sec)
+-------------+
| @exists |
+-------------+
| SYSTEM VIEW |
+-------------+
1 row in set (0.001 sec)
mysql> CALL sys.table_exists(''db1'', ''t3'', @exists); SELECT @exists;
Query OK, 0 rows affected (0.01 sec)
@@ -111,6 +133,9 @@ CREATE DEFINER='mariadb.sys'@'localhost' PROCEDURE table_exists (
CONTAINS SQL
BEGIN
DECLARE v_error BOOLEAN DEFAULT FALSE;
DECLARE v_table_type VARCHAR(16) DEFAULT '';
DECLARE v_system_db BOOLEAN
DEFAULT LOWER(in_db) IN ('information_schema', 'performance_schema');
DECLARE CONTINUE HANDLER FOR 1050 SET v_error = TRUE;
DECLARE CONTINUE HANDLER FOR 1146 SET v_error = TRUE;
@@ -120,29 +145,41 @@ BEGIN
IF (EXISTS(SELECT 1 FROM information_schema.TABLES WHERE TABLE_SCHEMA = in_db AND TABLE_NAME = in_table)) THEN
-- Unfortunately the only way to determine whether there is also a temporary table is to try to create
-- a temporary table with the same name. If it succeeds the table didn't exist as a temporary table.
SET @sys.tmp.table_exists.SQL = CONCAT('CREATE TEMPORARY TABLE `', in_db, '`.`', in_table, '` (id INT PRIMARY KEY)');
PREPARE stmt_create_table FROM @sys.tmp.table_exists.SQL;
EXECUTE stmt_create_table;
DEALLOCATE PREPARE stmt_create_table;
IF (v_error) THEN
SET out_exists = 'TEMPORARY';
ELSE
IF v_system_db = FALSE THEN
SET @sys.tmp.table_exists.SQL = CONCAT('CREATE TEMPORARY TABLE `', in_db, '`.`', in_table, '` (id INT PRIMARY KEY)');
PREPARE stmt_create_table FROM @sys.tmp.table_exists.SQL;
EXECUTE stmt_create_table;
DEALLOCATE PREPARE stmt_create_table;
-- The temporary table was created, i.e. it didn't exist. Remove it again so we don't leave garbage around.
SET @sys.tmp.table_exists.SQL = CONCAT('DROP TEMPORARY TABLE `', in_db, '`.`', in_table, '`');
PREPARE stmt_drop_table FROM @sys.tmp.table_exists.SQL;
EXECUTE stmt_drop_table;
DEALLOCATE PREPARE stmt_drop_table;
SET out_exists = (SELECT TABLE_TYPE FROM information_schema.TABLES WHERE TABLE_SCHEMA = in_db AND TABLE_NAME = in_table);
END IF;
IF (v_error) THEN
SET out_exists = 'TEMPORARY';
ELSE
SET v_table_type = (SELECT TABLE_TYPE FROM information_schema.TABLES WHERE TABLE_SCHEMA = in_db AND TABLE_NAME = in_table);
-- Don't fail on table_type='SYSTEM VERSIONED'
-- but return 'BASE TABLE' for compatibility with existing tooling
IF v_table_type = 'SYSTEM VERSIONED' THEN
SET out_exists = 'BASE TABLE';
ELSE
SET out_exists = v_table_type;
END IF;
END IF;
ELSE
-- Check whether a temporary table exists with the same name.
-- If it does it's possible to SELECT from the table without causing an error.
-- If it does not exist even a PREPARE using the table will fail.
SET @sys.tmp.table_exists.SQL = CONCAT('SELECT COUNT(*) FROM `', in_db, '`.`', in_table, '`');
PREPARE stmt_select FROM @sys.tmp.table_exists.SQL;
IF (NOT v_error) THEN
DEALLOCATE PREPARE stmt_select;
SET out_exists = 'TEMPORARY';
IF v_system_db = FALSE THEN
SET @sys.tmp.table_exists.SQL = CONCAT('SELECT COUNT(*) FROM `', in_db, '`.`', in_table, '`');
PREPARE stmt_select FROM @sys.tmp.table_exists.SQL;
IF (NOT v_error) THEN
DEALLOCATE PREPARE stmt_select;
SET out_exists = 'TEMPORARY';
END IF;
END IF;
END IF;
END$$

View File

@@ -535,7 +535,14 @@ read_cnf()
ssystag=$(parse_cnf mysqld_safe syslog-tag "${SST_SYSLOG_TAG:-}")
ssystag="$ssystag-"
sstlogarchive=$(parse_cnf sst sst-log-archive 1)
sstlogarchivedir=$(parse_cnf sst sst-log-archive-dir '/tmp/sst_log_archive')
sstlogarchivedir=""
if [ $sstlogarchive -ne 0 ]; then
sstlogarchivedir=$(parse_cnf sst sst-log-archive-dir \
'/tmp/sst_log_archive')
if [ -n "$sstlogarchivedir" ]; then
sstlogarchivedir=$(trim_dir "$sstlogarchivedir")
fi
fi
if [ $speciald -eq 0 ]; then
wsrep_log_error \
@@ -879,7 +886,15 @@ else
if [ -n "$sstlogarchivedir" ]; then
if [ ! -d "$sstlogarchivedir" ]; then
mkdir -p "$sstlogarchivedir"
if ! mkdir -p "$sstlogarchivedir"; then
sstlogarchivedir=""
wsrep_log_warning \
"Unable to create '$sstlogarchivedir' directory"
fi
elif [ ! -w "$sstlogarchivedir" ]; then
sstlogarchivedir=""
wsrep_log_warning \
"The '$sstlogarchivedir' directory is not writtable"
fi
fi
@@ -891,8 +906,8 @@ else
newfile="$INNOAPPLYLOG.$ARCHIVETIMESTAMP"
fi
wsrep_log_info "Moving '$INNOAPPLYLOG' to '$newfile'"
mv "$INNOAPPLYLOG" "$newfile"
gzip "$newfile"
mv "$INNOAPPLYLOG" "$newfile" && gzip "$newfile" || \
wsrep_log_warning "Failed to archive log file ('$newfile')"
fi
if [ -e "$INNOMOVELOG" ]; then
@@ -903,8 +918,8 @@ else
newfile="$INNOMOVELOG.$ARCHIVETIMESTAMP"
fi
wsrep_log_info "Moving '$INNOMOVELOG' to '$newfile'"
mv "$INNOMOVELOG" "$newfile"
gzip "$newfile"
mv "$INNOMOVELOG" "$newfile" && gzip "$newfile" || \
wsrep_log_warning "Failed to archive log file ('$newfile')"
fi
if [ -e "$INNOBACKUPLOG" ]; then
@@ -915,8 +930,8 @@ else
newfile="$INNOBACKUPLOG.$ARCHIVETIMESTAMP"
fi
wsrep_log_info "Moving '$INNOBACKUPLOG' to '$newfile'"
mv "$INNOBACKUPLOG" "$newfile"
gzip "$newfile"
mv "$INNOBACKUPLOG" "$newfile" && gzip "$newfile" || \
wsrep_log_warning "Failed to archive log file ('$newfile')"
fi
fi
INNOAPPLY="> '$INNOAPPLYLOG' 2>&1"