403Webshell
Server IP : 104.21.38.3  /  Your IP : 172.68.164.152
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 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 : ON
Directory :  /www/server/mysql/src/mysql-test/suite/sysschema/t/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/server/mysql/src/mysql-test/suite/sysschema/t/v_statements_with_full_table_scans.test
-- source include/not_embedded.inc
-- source ../include/ps_truncate_all_tables.inc
# Performance schema tracks prepared statements separately, and does not 
# yet have a summary view that we can use for this view.
# Until then, we disable this test with --ps-protocol
-- source include/no_protocol.inc

# Tests for sys schema
# Verify the sys.statements_with_full_table_scans view

# Ensure structure changes don't slip in
DESC sys.statements_with_full_table_scans;

# Make sure view select does not error, but ignore results
--disable_result_log
SELECT * FROM sys.statements_with_full_table_scans;
--enable_result_log


# Ensure structure changes don't slip in
DESC sys.x$statements_with_full_table_scans;

# Make sure view select does not error, but ignore results
--disable_result_log
SELECT * FROM sys.x$statements_with_full_table_scans;
--enable_result_log

# Create a dummy table, force some full table scans, verify the results
CREATE DATABASE v_statements_with_full_table_scans;

CREATE TABLE v_statements_with_full_table_scans.t (i BIGINT AUTO_INCREMENT PRIMARY KEY, j BIGINT) ENGINE = innodb;

INSERT INTO v_statements_with_full_table_scans.t (j) VALUES (1), (2), (3);

INSERT INTO v_statements_with_full_table_scans.t (j) (SELECT j*2 FROM v_statements_with_full_table_scans.t);

INSERT INTO v_statements_with_full_table_scans.t (j) (SELECT j*2 FROM v_statements_with_full_table_scans.t);

INSERT INTO v_statements_with_full_table_scans.t (j) (SELECT j*2 FROM v_statements_with_full_table_scans.t);

INSERT INTO v_statements_with_full_table_scans.t (j) (SELECT j*2 FROM v_statements_with_full_table_scans.t);

INSERT INTO v_statements_with_full_table_scans.t (j) (SELECT j*2 FROM v_statements_with_full_table_scans.t);

INSERT INTO v_statements_with_full_table_scans.t (j) (SELECT j*2 FROM v_statements_with_full_table_scans.t);

INSERT INTO v_statements_with_full_table_scans.t (j) (SELECT j*2 FROM v_statements_with_full_table_scans.t);

INSERT INTO v_statements_with_full_table_scans.t (j) (SELECT j*2 FROM v_statements_with_full_table_scans.t);

# The table should now have 768 rows

# Now truncate the P_S tables, to get fresh results
CALL sys.ps_truncate_all_tables(false);

# Following returns 28 rows, but should full scan as j has no index
# Using RAND() to force no query caching, so ignore results, they are not important
--disable_result_log
SELECT i, j, RAND() FROM v_statements_with_full_table_scans.t WHERE j = 12;
--enable_result_log

# Now verify the statement shows up in the views with the right row count (should be 768)
SELECT db, query, rows_examined FROM sys.statements_with_full_table_scans WHERE query LIKE '%v_statements_with_full_table_scans%' ORDER BY rows_examined DESC;

SELECT db, query, rows_examined FROM sys.x$statements_with_full_table_scans WHERE query LIKE '%v_statements_with_full_table_scans%' ORDER BY rows_examined DESC;

# Scan again
--disable_result_log
SELECT i, j, RAND() FROM v_statements_with_full_table_scans.t WHERE j = 12;
--enable_result_log

# Now verify that double the amount of rows for the statement should be shown as scanned (should be 1536)
SELECT db, query, rows_examined FROM sys.statements_with_full_table_scans WHERE query LIKE '%v_statements_with_full_table_scans%' ORDER BY rows_examined DESC;

SELECT db, query, rows_examined FROM sys.x$statements_with_full_table_scans WHERE query LIKE '%v_statements_with_full_table_scans%' ORDER BY rows_examined DESC;

# Do a point lookup
SELECT * FROM v_statements_with_full_table_scans.t WHERE i = 10;

# The number of rows scanned should not have changed (should still be 1536)
SELECT db, query, rows_examined FROM sys.statements_with_full_table_scans WHERE query LIKE '%v_statements_with_full_table_scans%' ORDER BY rows_examined DESC;

SELECT db, query, rows_examined FROM sys.x$statements_with_full_table_scans WHERE query LIKE '%v_statements_with_full_table_scans%' ORDER BY rows_examined DESC;

# Cleanup
DROP DATABASE v_statements_with_full_table_scans;

Youez - 2016 - github.com/yon3zu
LinuXploit