29
29
"""Various MySQL constants and character sets
30
30
"""
31
31
32
+ import six
32
33
import ssl
34
+ import warnings
33
35
34
36
from .errors import ProgrammingError
35
37
from .charsets import MYSQL_CHARACTER_SETS
@@ -97,6 +99,12 @@ def flag_is_set(flag, flags):
97
99
return False
98
100
99
101
102
+ def _obsolete_option (name , new_name , value ):
103
+ warnings .warn ('The option "{}" has been deprecated, use "{}" instead.'
104
+ '' .format (name , new_name ), category = DeprecationWarning )
105
+ return value
106
+
107
+
100
108
class _Constants (object ):
101
109
"""
102
110
Base class for constants
@@ -532,7 +540,14 @@ class ServerFlag(_Flags):
532
540
}
533
541
534
542
535
- class RefreshOption (_Constants ):
543
+ class RefreshOption_meta (type ):
544
+ @property
545
+ def SLAVE (self ):
546
+ return _obsolete_option ("RefreshOption.SLAVE" , "RefreshOption.REPLICA" ,
547
+ RefreshOption .REPLICA )
548
+
549
+
550
+ class RefreshOption (six .with_metaclass (RefreshOption_meta , _Constants )):
536
551
"""MySQL Refresh command options
537
552
538
553
Options used when sending the COM_REFRESH server command.
@@ -550,10 +565,11 @@ class RefreshOption(_Constants):
550
565
'GRANT' : (1 << 0 , 'Refresh grant tables' ),
551
566
'LOG' : (1 << 1 , 'Start on new log file' ),
552
567
'TABLES' : (1 << 2 , 'close all tables' ),
553
- 'HOSTS ' : (1 << 3 , 'Flush host cache' ),
568
+ 'HOST ' : (1 << 3 , 'Flush host cache' ),
554
569
'STATUS' : (1 << 4 , 'Flush status variables' ),
555
570
'THREADS' : (1 << 5 , 'Flush thread cache' ),
556
571
'REPLICA' : (1 << 6 , 'Reset source info and restart replica thread' ),
572
+ 'SLAVE' : (1 << 6 , 'Deprecated option; use REPLICA instead.' ),
557
573
}
558
574
559
575
0 commit comments