From 51cc817f8e2bab01ee028fbc1a0029a3f314d576 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 4 Jul 2022 09:59:01 +0200 Subject: Merging upstream version 1.12.0. Signed-off-by: Daniel Baumann --- iredis/redis_grammar.py | 107 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 80 insertions(+), 27 deletions(-) (limited to 'iredis/redis_grammar.py') diff --git a/iredis/redis_grammar.py b/iredis/redis_grammar.py index 666c0da..4e38540 100644 --- a/iredis/redis_grammar.py +++ b/iredis/redis_grammar.py @@ -18,6 +18,8 @@ CONST = { "withscores": "WITHSCORES", "limit": "LIMIT", "expiration": "EX PX", + "exat_const": "EXAT", + "pxat_const": "PXAT", "condition": "NX XX", "keepttl": "KEEPTTL", "operation": "AND OR XOR NOT", @@ -32,7 +34,7 @@ CONST = { "type": "string list set zset hash stream", "position_choice": "BEFORE AFTER", "error": "TIMEOUT ERROR", - "async": "ASYNC", + "async": "ASYNC SYNC", "conntype": "NORMAL MASTER REPLICA PUBSUB", "samples": "SAMPLES", "slotsubcmd": "IMPORTING MIGRATING NODE STABLE", @@ -45,6 +47,7 @@ CONST = { "on_off": "ON OFF", "const_id": "ID", "addr": "ADDR", + "laddr": "LADDR", "skipme": "SKIPME", "yes": "YES NO", "migratechoice": "COPY REPLACE", @@ -130,6 +133,13 @@ CONST = { "withmatchlen_const": "WITHMATCHLEN", "strings_const": "STRINGS", "rank_const": "RANK", + "lr_const": "LEFT RIGHT", + "pause_type": "WRITE ALL", + "db_const": "DB", + "replace_const": "REPLACE", + "to_const": "TO", + "timeout_const": "TIMEOUT", + "abort_const": "ABORT", } @@ -151,14 +161,16 @@ VALID_NODE = r"\w+" NUM = r"\d+" NNUM = r"-?\+?\(?\[?(\d+|inf)" # number cloud be negative _FLOAT = r"-?(\d|\.|e)+" +DOUBLE = r"\d*(\.\d+)?" LEXNUM = r"(\[\w+)|(\(\w+)|(\+)|(-)" SLOT = rf"(?P{VALID_SLOT})" SLOTS = rf"(?P{VALID_SLOT}(\s+{VALID_SLOT})*)" NODE = rf"(?P{VALID_NODE})" KEY = rf"(?P{VALID_TOKEN})" -PREFIX = rf"(?P{VALID_TOKEN})" KEYS = rf"(?P{VALID_TOKEN}(\s+{VALID_TOKEN})*)" +PREFIX = rf"(?P{VALID_TOKEN})" +PREFIXES = rf"(?P{VALID_TOKEN}(\s+{VALID_TOKEN})*?)" DESTINATION = rf"(?P{VALID_TOKEN})" NEWKEY = rf"(?P{VALID_TOKEN})" VALUE = rf"(?P{VALID_TOKEN})" @@ -205,13 +217,15 @@ PASSWORD = rf"(?P{VALID_TOKEN})" REPLICATIONID = rf"(?P{VALID_TOKEN})" INDEX = r"(?P(1[0-5]|\d))" CLIENTID = rf"(?P{NUM})" +CLIENTIDS = rf"(?P{NUM}(\s+{NUM})*)" + SECOND = rf"(?P{NUM})" -TIMESTAMP = rf"(?P{NUM})" +TIMESTAMP = r"(?P[T\d:>+*\-\$]+)" # TODO test lexer & completer for multi spaces in command # For now, redis command can have one space at most -COMMAND = "(\s* (?P[\w -]+))" +COMMAND = r"(\s* (?P[\w -]+))" MILLISECOND = rf"(?P{NUM})" -TIMESTAMPMS = rf"(?P{NUM})" +TIMESTAMPMS = r"(?P[T\d:>+*\-\$]+)" ANY = r"(?P.*)" # TODO deleted START = rf"(?P{NNUM})" END = rf"(?P{NNUM})" @@ -221,15 +235,24 @@ END = rf"(?P{NNUM})" # https://redis.io/topics/streams-intro#special-ids-in-the-streams-api # stream id, DO NOT use r"" here, or the \+ will be two string # NOTE: if miss the outer (), multi IDS won't work. -STREAM_ID = "(?P[T\d:>+*\-\$]+)" +STREAM_ID = r"(?P[T\d:>+*\-\$]+)" DELTA = rf"(?P{NNUM})" OFFSET = rf"(?P{NUM})" # string offset, can't be negative -SHARP_OFFSET = f"(?P\#?{NUM})" # for bitfield command +SHARP_OFFSET = rf"(?P\#?{NUM})" # for bitfield command +MIN = rf"(?P{NNUM})" +MAX = rf"(?P{NNUM})" +POSITION = rf"(?P{NNUM})" +SCORE = rf"(?P{_FLOAT})" +LEXMIN = rf"(?P{LEXNUM})" +LEXMAX = rf"(?P{LEXNUM})" +WEIGHTS = rf"(?P{_FLOAT}(\s+{_FLOAT})*)" +IP_PORT = rf"(?P{IP}:{PORT})" +HOST = rf"(?P{VALID_TOKEN})" MIN = rf"(?P{NNUM})" MAX = rf"(?P{NNUM})" POSITION = rf"(?P{NNUM})" -TIMEOUT = rf"(?P{NUM})" +TIMEOUT = rf"(?P{DOUBLE})" SCORE = rf"(?P{_FLOAT})" LEXMIN = rf"(?P{LEXNUM})" LEXMAX = rf"(?P{LEXNUM})" @@ -267,6 +290,7 @@ ON_OFF = rf"(?P{c('on_off')})" CONST_ID = rf"(?P{c('const_id')})" CONST_USER = rf"(?P{c('const_user')})" ADDR = rf"(?P{c('addr')})" +LADDR = rf"(?P{c('laddr')})" SKIPME = rf"(?P{c('skipme')})" YES = rf"(?P{c('yes')})" MIGRATECHOICE = rf"(?P{c('migratechoice')})" @@ -329,6 +353,16 @@ WITHMATCHLEN_CONST = rf"(?P{c('withmatchlen_const')})" STRINGS_CONST = rf"(?P{c('strings_const')})" RANK_CONST = rf"(?P{c('rank_const')})" +LR_CONST = rf"(?P{c('lr_const')})" +PAUSE_TYPE = rf"(?P{c('pause_type')})" +DB_CONST = rf"(?P{c('db_const')})" +REPLACE_CONST = rf"(?P{c('replace_const')})" +TO_CONST = rf"(?P{c('to_const')})" +TIMEOUT_CONST = rf"(?P{c('timeout_const')})" +ABORT_CONST = rf"(?P{c('abort_const')})" +PXAT_CONST = rf"(?P{c('pxat_const')})" +EXAT_CONST = rf"(?P{c('exat_const')})" + command_grammar = compile(COMMAND) # Here are the core grammars, those are tokens after ``command``. @@ -339,14 +373,6 @@ command_grammar = compile(COMMAND) GRAMMAR = { "command_key": rf"\s+ {KEY} \s*", "command_pattern": rf"\s+ {PATTERN} \s*", - "command_georadiusbymember": rf""" - \s+ {KEY} \s+ {MEMBER} - \s+ {FLOAT} \s+ {DISTUNIT} - (\s+ {GEOCHOICE})* - (\s+ {COUNT_CONST} \s+ {COUNT})? - (\s+ {ORDER})? - (\s+ {CONST_STORE} \s+ {KEY})? - (\s+ {CONST_STOREDIST} \s+ {KEY})? \s*""", "command_command": rf"\s+ {COMMAND} \s*", "command_slots": rf"\s+ {SLOTS} \s*", "command_node": rf"\s+ {NODE} \s*", @@ -370,8 +396,12 @@ GRAMMAR = { "command_messagex": rf"(\s+{MESSAGE})? \s*", "command_index": rf"\s+ {INDEX} \s*", "command_index_index": rf"\s+ {INDEX} \s+ {INDEX} \s*", - "command_type_conntype_x": rf""" - (\s+ {TYPE_CONST} \s+ {CONNTYPE})? \s*""", + "command_client_list": rf""" + ( + (\s+ {TYPE_CONST} \s+ {CONNTYPE})| + (\s+ {CONST_ID} \s+ {CLIENTIDS}) + )* + \s*""", "command_clientid_errorx": rf"\s+ {CLIENTID} (\s+ {ERROR})? \s*", "command_keys": rf"\s+ {KEYS} \s*", "command_key_value": rf"\s+ {KEY} \s+ {VALUE} \s*", @@ -388,7 +418,7 @@ GRAMMAR = { "command_key_newkey_timeout": rf"\s+ {KEY} \s+ {NEWKEY} \s+ {TIMEOUT} \s*", "command_keys_timeout": rf"\s+ {KEYS} \s+ {TIMEOUT} \s*", "command_count_timeout": rf"\s+ {COUNT} \s+ {TIMEOUT} \s*", - "command_timeout": rf"\s+ {TIMEOUT} \s*", + "command_pause": rf"\s+ {TIMEOUT} (\s+ {PAUSE_TYPE})? \s*", "command_key_positionchoice_pivot_value": rf""" \s+ {KEY} \s+ {POSITION_CHOICE} \s+ {VALUE} \s+ {VALUE} \s*""", "command_pass": rf"\s+ {ANY} \s*", @@ -420,10 +450,16 @@ GRAMMAR = { "command_key_members": rf"\s+ {KEY} \s+ {MEMBERS} \s*", "command_geodist": rf"\s+ {KEY} \s+ {MEMBER} \s+ {MEMBER} (\s+ {DISTUNIT})? \s*", "command_key_longitude_latitude_members": rf""" - \s+ {KEY} (\s+ {LONGITUDE} \s+ {LATITUDE} \s {MEMBER})+ \s*""", + \s+ {KEY} + (\s+ {CONDITION})? + (\s+ {CHANGED})? + (\s+ {LONGITUDE} \s+ {LATITUDE} \s {MEMBER})+ + \s*""", "command_destination_keys": rf"\s+ {DESTINATION} \s+ {KEYS} \s*", "command_object_key": rf"\s+ {OBJECT} \s+ {KEY} \s*", "command_key_member": rf"\s+ {KEY} \s+ {MEMBER} \s*", + "command_key_any": rf"\s+ {KEY} \s+ {ANY} \s*", + "command_key_key_any": rf"\s+ {KEY} \s+ {KEY} \s+ {ANY} \s*", "command_key_newkey_member": rf"\s+ {KEY} \s+ {NEWKEY} \s+ {MEMBER} \s*", "command_key_count_x": rf"\s+ {KEY} (\s+ {COUNT})? \s*", "command_key_min_max": rf"\s+ {KEY} \s+ {MIN} \s+ {MAX} \s*", @@ -459,6 +495,7 @@ GRAMMAR = { ( (\s+ {IP_PORT})| (\s+ {ADDR} \s+ {IP_PORT})| + (\s+ {LADDR} \s+ {IP_PORT})| (\s+ {CONST_ID} \s+ {CLIENTID})| (\s+ {TYPE_CONST} \s+ {CONNTYPE})| (\s+ {CONST_USER} \s+ {USERNAME})| @@ -474,12 +511,6 @@ GRAMMAR = { )? (\s+ {CONST_KEYS} \s+ {KEYS})? \s*""", - "command_radius": rf"""\s+ {KEY} - \s+ {LONGITUDE} \s+ {LATITUDE} \s+ {FLOAT} \s+ {DISTUNIT} - (\s+ {GEOCHOICE})* (\s+ {COUNT_CONST} \s+ {COUNT})? - (\s+ {ORDER})? - (\s+ {CONST_STORE} \s+ {KEY})? - (\s+ {CONST_STOREDIST} \s+ {KEY})? \s*""", "command_restore": rf"""\s+ {KEY} \s+ {TIMEOUT} \s+ {VALUE} (\s+ {SUBRESTORE} \s+ {SECOND})? \s*""", "command_pubsubcmd_channels": rf"\s+ {PUBSUBCMD} (\s+ {CHANNEL})+ \s*", @@ -573,7 +604,7 @@ GRAMMAR = { \s+ {ON_OFF} ( (\s+ {REDIRECT_CONST} \s+ {CLIENTID})| - (\s+ {PREFIX_CONST} \s+ {PREFIX})| + (\s+ {PREFIX_CONST} \s+ {PREFIXES})| (\s+ {BCAST_CONST})| (\s+ {OPTIN_CONST})| (\s+ {OPTOUT_CONST})| @@ -607,6 +638,28 @@ GRAMMAR = { (\s+ {MAXLEN} \s+ {LEN}) )* \s*""", + "command_key_key_lr_lr_timeout": rf""" + \s+ {KEY} \s+ {KEY} + \s+ {LR_CONST} \s+ {LR_CONST} + \s+ {TIMEOUT} \s*""", + "command_copy": rf""" + \s+ {KEY} \s+ {KEY} + (\s+ {DB_CONST} \s+ {INDEX})? + (\s+ {REPLACE_CONST})? + \s*""", + "command_failover": rf""" + (\s+ {TO_CONST} \s+ {HOST} \s+ {PORT} (\s+ {FORCE})? )? + (\s+ {ABORT_CONST})? + (\s+ {TIMEOUT_CONST} \s+ {MILLISECOND})? + \s*""", + "command_key_expire": rf""" + \s+ {KEY} + ( + (\s+ {EXPIRATION} \s+ {MILLISECOND})| + (\s+ {PXAT_CONST} \s+ {TIMESTAMPMS})| + (\s+ {EXAT_CONST} \s+ {TIMESTAMP}) + )? + \s*""", } pipeline = r"(?P\|.*)?" -- cgit v1.2.3