How to fetch Mysql undo log infomartion like innodb_trx_undo - mysql

I want to get the undo log information but found innodb_trx_undo not exists。have any other tools can i use to anlaysis the undo log files?
mysql> select * from information_schema.innodb_trx_undo;
1109 - Unknown table 'innodb_trx_undo' in information_schema
mysql> select version()
-> ;
+------------+
| version() |
+------------+
| 5.7.36-log |
+------------+
1 row in set (0.01 sec)

Related

Tab completion in mysql command line

I tried to test mysql's functions with select from command line but find that tab completion does not work
mysql> select Now() as current_moment;
+---------------------+
| current_moment |
+---------------------+
| 2019-12-04 22:11:11 |
+---------------------+
1 row in set (0.00 sec)
mysql> select current_time;
+--------------+
| current_time |
+--------------+
| 22:11:27 |
+--------------+
1 row in set (0.00 sec)
If not reference to the manual, it seems very hard to play around with functions without the assistance of tab completion.
How could activate the tab completion.

how to use mysql rewriter plugin?

I am trying to use mysql default rewrite plugin as per their instructions but it is giving me some grief. Simply put after activating rules the plugin is simply not working.
Below is my table and rules but simply queries are not reporting correct results. Can someone tell me what am i doing wrong?
Thanks.
mysql> select creditcard_number from mihir_test.creditcard_info where name = "mihir";
+-------------------+
| creditcard_number |
+-------------------+
| 1234567890123456 |
+-------------------+
1 row in set, 1 warning (0.00 sec)
mysql> insert into query_rewrite.rewrite_rules ( pattern, replacement) values ( 'select creditcard_number from mihir_test.creditcard_info where name = ?', 'select name, creditcart_number from mihir_test.creditcard_info where name = ?' );
Query OK, 1 row affected, 1 warning (0.01 sec)
mysql>
mysql> CALL query_rewrite.flush_rewrite_rules();
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> select creditcard_number from mihir_test.creditcard_info where name = "mihir"; +-------------------+
| creditcard_number |
+-------------------+
| 1234567890123456 |
+-------------------+
1 row in set, 1 warning (0.00 sec)
mysql>

Error Code: 1264. Out of range value for column 'XXX' at row 1

My stored procedure has IN parameter for page number (IN page INT)
And everything works fine for any value <= 2147483647.
And if value is > 2147483647 I get error 1264.
All this happens on 5.6.26 Community Server compiled for Linux (x86_64) and the same for 5.6.24 Community Server compiled for Win64 (x86_64)
And all of the above is fine and I understand the error.
However, on server 5.6.30-1+deb.sury.org~xenial+2 (Ubuntu) compiled for debian-linux-gnu (x86_64) this is not reproduced. Input value is just cut to 2147483647 no matter what value I pass there.
What setting is responsible for this "auto max value cap"? How can I synchronize settings on different environments without re-installation to have the same behavior?
Thank you!
Check 5.1.7 Server SQL Modes.
mysql> SELECT ##GLOBAL.SQL_MODE, ##SESSION.SQL_MODE;
+--------------------------------------------+--------------------------------------------+
| ##GLOBAL.SQL_MODE | ##SESSION.SQL_MODE |
+--------------------------------------------+--------------------------------------------+
| STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION | STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION |
+--------------------------------------------+--------------------------------------------+
1 row in set (0.00 sec)
mysql> DELIMITER //
mysql> DROP PROCEDURE IF EXISTS `sp_test`//
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> CREATE PROCEDURE `sp_test`(IN `page` INT)
-> BEGIN
-> SELECT `page`;
-> END//
Query OK, 0 rows affected (0.00 sec)
mysql> DELIMITER ;
mysql> CALL `sp_test`(2147483647);
+------------+
| `page` |
+------------+
| 2147483647 |
+------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> CALL `sp_test`(2147483648);
ERROR 1264 (22003): Out of range value for column 'page' at row 1
mysql> SET ##SESSION.SQL_MODE = 'NO_ENGINE_SUBSTITUTION';
Query OK, 0 rows affected (0.00 sec)
mysql> select ##GLOBAL.SQL_MODE, ##SESSION.SQL_MODE;
+--------------------------------------------+------------------------+
| ##GLOBAL.SQL_MODE | ##SESSION.SQL_MODE |
+--------------------------------------------+------------------------+
| STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION | NO_ENGINE_SUBSTITUTION |
+--------------------------------------------+------------------------+
1 row in set (0.00 sec)
mysql> CALL `sp_test`(2147483648);
+------------+
| `page` |
+------------+
| 2147483647 |
+------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> SHOW WARNINGS;
+---------+------+-----------------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------------+
| Warning | 1264 | Out of range value for column 'page' at row 1 |
+---------+------+-----------------------------------------------+
1 row in set (0.00 sec)

How many GET_LOCKs can a MySQL handle?

How many GET_LOCKS can be handled by a mysql server - by the whole server. I wasn´t able to find anything about its limitations.
As per MySQL documentation GET_LOCK() you cannot hold more than one lock per connection.
As it says
If you have a lock obtained with GET_LOCK(), it is released when you
execute RELEASE_LOCK(), execute a new GET_LOCK(), or your connection
terminates (either normally or abnormally).
So essentially, it depends on No.Of connection. I would say the equation would
No.of GET_LOCK handled = NO.Of Connections handled
I see there is a bug logged where people suggested to have concurrent lock per connection. See here http://bugs.mysql.com/bug.php?id=1118
mysql> SELECT GET_LOCK('s',10);
+------------------+
| GET_LOCK('s',10) |
+------------------+
| 1 |
+------------------+
1 row in set (0.00 sec)
mysql> SELECT GET_LOCK('t',10);
+------------------+
| GET_LOCK('t',10) |
+------------------+
| 1 |
+------------------+
1 row in set (0.00 sec)
mysql> SELECT GET_LOCK('b',10);
+------------------+
| GET_LOCK('b',10) |
+------------------+
| 1 |
+------------------+
1 row in set (0.00 sec)
mysql> SELECT IS_FREE_LOCK('b');
+-------------------+
| IS_FREE_LOCK('b') |
+-------------------+
| 0 |
+-------------------+
1 row in set (0.00 sec)
mysql> SELECT IS_FREE_LOCK('t');
+-------------------+
| IS_FREE_LOCK('t') |
+-------------------+
| 1 |
+-------------------+
1 row in set (0.00 sec)
mysql> SELECT IS_FREE_LOCK('s');
+-------------------+
| IS_FREE_LOCK('s') |
+-------------------+
| 1 |
+-------------------+
1 row in set (0.00 sec)

MySQL: I want to insert file directories that have backslashes but when i look at the column i see no back slashes

I need to insert file directories into a column but when i select (*) after inserting them all the back slashes have gone. does anyone know how i can do this. it is not possible for me to escape the slashes as i have thousands of records. I thought mysql required the user to do this using a remove_slases or something in php
The easy way to do this in MySQL is by setting the NO_BACKSLASH_ESCAPES SQL mode. Do this for the session with SET SESSION sql_mode='NO_BACKSLASH_ESCAPES';
As such:
mysql> SELECT ##SESSION.sql_mode;
+--------------------+
| ##SESSION.sql_mode |
+--------------------+
| |
+--------------------+
1 row in set (0.00 sec)
mysql> select 'don\t';
+------+
| don |
+------+
| don |
+------+
1 row in set (0.00 sec)
mysql> SET SESSION sql_mode='NO_BACKSLASH_ESCAPES';
Query OK, 0 rows affected (0.00 sec)
mysql> select 'don\t';
+-------+
| don\t |
+-------+
| don\t |
+-------+
1 row in set (0.00 sec)
This allows you to insert c:\bla\tla\bla without the \b or \t being interpreted as a string literal. Also take a look at QUOTE() if you need 'escaping' alike mysql_real_escape_string
More information at http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html#sqlmode_no_backslash_escapes