AnonSec Shell
Server IP : 185.86.78.101  /  Your IP : 216.73.216.213
Web Server : Apache
System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /www/server/mysql/mysql-test/include/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /www/server/mysql/mysql-test/include/delete_all_rows.inc
# ==== Purpose ====
#
# This include will check if the optimized delete (delete_all_rows) was
# used or not varying the session sql_log_bin variable with 0 and 1.
#
# It is expected that the optimized delete (delete_all_rows) will be used:
# a) If binlog_format != ROW
# b) If binlog_format == ROW but the statement will not be binlogged
#
# The include, varying sql_log_bin with 0 and 1, creates a new table (t1),
# fills it with data, and deletes all t1 data with a single query.
#
# It uses an EXPLAIN to assert if delete_all_rows was used or not.
#
# The include also asserts if the statement was binlogged if it is expected
# to be.
#
# ==== Usage ====
#
# [--let $storage_engine= InnoDB | MyISAM]
# --source include/delete_all_rows.inc
#
# Parameters:
#   $storage_engine
#     The storage engine that will be used in the CREATE TABLE statements.
#     If not specified, InnoDB will be used.
#

if (!$storage_engine)
{
  --let $_storage_engine= InnoDB
}
if ($storage_engine)
{
  --let $_storage_engine= $storage_engine
}

##
## Determine if the server has the binary log enabled
##
--let $have_log_bin= query_get_value(SHOW GLOBAL VARIABLES LIKE 'log_bin', Value, 1)

# Create t1 and populate it
--eval CREATE TABLE t1 (c1 INT) ENGINE=$_storage_engine
INSERT INTO t1 VALUES (1), (2), (3);

##
## Session sql_log_bin = 0
##
--echo
SET sql_log_bin= 0;

# Assert that delete_all_rows() will be used
--let $explain_extra= query_get_value("EXPLAIN DELETE FROM t1", Extra, 1)
--let $assert_text= DELETE will use delete_all_rows
--let $assert_cond= "$explain_extra" = "Deleting all rows"
--source include/assert.inc

# Save current master position
if ($have_log_bin == ON)
{
  --let $saved_pos= query_get_value(SHOW MASTER STATUS, Position, 1)
}
DELETE FROM t1;

# Assert that this was not binlogged if binary log is enabled
if ($have_log_bin == ON)
{
  --let $current_pos= query_get_value(SHOW MASTER STATUS, Position, 1)
  --let $assert_text= DELETE was not binlogged
  --let $assert_cond= $current_pos = $saved_pos
  --source include/assert.inc
}

##
## Session sql_log_bin = 1
##
--echo
SET sql_log_bin= 1;
# Populate t1 again
INSERT INTO t1 VALUES (1), (2), (3);

# Assert if delete_all_rows() will be used or not
--let $explain_extra_expected= "Deleting all rows"
# The extra info in explain will be NULL if the statement is binlogged
# with binlog_format = ROW
--let $explain_extra= query_get_value("EXPLAIN DELETE FROM t1", Extra, 1)
--let $assert_text= DELETE will use delete_all_rows
if ($have_log_bin == ON)
{
  if (`SELECT @@GLOBAL.binlog_format = 'ROW'`)
  {
    --let $assert_text= DELETE will not use delete_all_rows
    --let $explain_extra_expected= "NULL"
  }
}
--let $assert_cond= "$explain_extra" = $explain_extra_expected
--source include/assert.inc

# Save current master position
if ($have_log_bin == ON)
{
  --let $saved_pos= query_get_value(SHOW MASTER STATUS, Position, 1)
}

DELETE FROM t1;
# Assert that this was binlogged if binary log is enabled
if ($have_log_bin == ON)
{
  --let $current_pos= query_get_value(SHOW MASTER STATUS, Position, 1)
  --let $assert_text= DELETE was binlogged
  --let $assert_cond= $current_pos > $saved_pos
  --source include/assert.inc
}

# Cleanup
DROP TABLE t1;

Anon7 - 2022
AnonSec Team