For simplicity pytest launches my_server and mysql_server (inside docker). my_server connects to mysql_server (over host network), then he gets value of SELECT UNIX_TIMESTAMP(); from mysql_server process it to day of week, then prints number according to day of week:
('mon', 1667768400), # print 1
('tue', 1667854800), # print 2
('wed', 1667941200), # print 3
...
I'm looking for something like this, but I want to change it globally for all opened sessions:
-- one can connect to mysql and
-- change value for current session,
-- but I need to set it globally or
-- somehow change value for another
-- session.
-- for example for monday:
mysql> set session timestamp = 1667768400;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT UNIX_TIMESTAMP();
+------------------+
| UNIX_TIMESTAMP() |
+------------------+
| 1667768400 |
+------------------+
1 row in set (0.00 sec)
mysql> set global timestamp = 1667768400;
ERROR 1228 (HY000): Variable 'timestamp' is a SESSION variable and can't be used with SET GLOBAL
Notes:
- I can't change code inside
my_server, it's very expensive; - I can't change host machine timestamp, because such an action would require to run tests with sudo, which is strange requirement for a test.
Kind regards,
Oleg
set session timestampto its value.set session timestamponly for tests,my_serveris a production service, which doesn't need this setting for a session. No, proposing any manipulations with host default time is a bad practice. I want to change database properties, I thought I made it clear.