mirror of https://github.com/apache/cassandra
Merge branch 'cassandra-3.11' into trunk
This commit is contained in:
commit
6d324f9d76
|
|
@ -218,6 +218,8 @@ Merged from 2.2:
|
|||
* Fix race that prevents submitting compaction for a table when executor is full (CASSANDRA-13801)
|
||||
* Rely on the JVM to handle OutOfMemoryErrors (CASSANDRA-13006)
|
||||
* Grab refs during scrub/index redistribution/cleanup (CASSANDRA-13873)
|
||||
Merged from 2.1:
|
||||
* More PEP8 compliance for cqlsh
|
||||
|
||||
|
||||
3.11.1
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@ def find_zip(libprefix):
|
|||
if zips:
|
||||
return max(zips) # probably the highest version, if multiple
|
||||
|
||||
|
||||
cql_zip = find_zip(CQL_LIB_PREFIX)
|
||||
if cql_zip:
|
||||
ver = os.path.splitext(os.path.basename(cql_zip))[0][len(CQL_LIB_PREFIX):]
|
||||
|
|
@ -373,6 +374,8 @@ def show_warning_without_quoting_line(message, category, filename, lineno, file=
|
|||
file.write(warnings.formatwarning(message, category, filename, lineno, line=''))
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
|
||||
warnings.showwarning = show_warning_without_quoting_line
|
||||
warnings.filterwarnings('always', category=cql3handling.UnexpectedTableStructure)
|
||||
|
||||
|
|
@ -2366,12 +2369,12 @@ def main(options, hostname, port):
|
|||
if options.timezone:
|
||||
try:
|
||||
timezone = pytz.timezone(options.timezone)
|
||||
except:
|
||||
except Exception:
|
||||
sys.stderr.write("Warning: could not recognize timezone '%s' specified in cqlshrc\n\n" % (options.timezone))
|
||||
if 'TZ' in os.environ:
|
||||
try:
|
||||
timezone = pytz.timezone(os.environ['TZ'])
|
||||
except:
|
||||
except Exception:
|
||||
sys.stderr.write("Warning: could not recognize timezone '%s' from environment value TZ\n\n" % (os.environ['TZ']))
|
||||
except ImportError:
|
||||
sys.stderr.write("Warning: Timezone defined and 'pytz' module for timezone conversion not installed. Timestamps will be displayed in UTC timezone.\n\n")
|
||||
|
|
@ -2428,6 +2431,7 @@ def main(options, hostname, port):
|
|||
if batch_mode and shell.statement_error:
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
# always call this regardless of module name: when a sub-process is spawned
|
||||
# on Windows then the module name is not __main__, see CASSANDRA-9304
|
||||
insert_driver_hooks()
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ class SendingChannels(object):
|
|||
for ch in self.channels:
|
||||
try:
|
||||
ch.close()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
|
|
@ -222,7 +222,7 @@ class ReceivingChannels(object):
|
|||
for ch in self.channels:
|
||||
try:
|
||||
ch.close()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
|
|
@ -2147,8 +2147,8 @@ class ImportConversion(object):
|
|||
pk_values = []
|
||||
for i in partition_key_indexes:
|
||||
val = serialize(i, row[i])
|
||||
l = len(val)
|
||||
pk_values.append(struct.pack(">H%dsB" % l, l, val, 0))
|
||||
length = len(val)
|
||||
pk_values.append(struct.pack(">H%dsB" % length, length, val, 0))
|
||||
return b"".join(pk_values)
|
||||
|
||||
if len(partition_key_indexes) == 1:
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ class UnexpectedTableStructure(UserWarning):
|
|||
def __str__(self):
|
||||
return 'Unexpected table structure; may not translate correctly to CQL. ' + self.msg
|
||||
|
||||
|
||||
SYSTEM_KEYSPACES = ('system', 'system_schema', 'system_traces', 'system_auth', 'system_distributed')
|
||||
NONALTERBALE_KEYSPACES = ('system', 'system_schema')
|
||||
|
||||
|
|
@ -143,6 +144,7 @@ class Cql3ParsingRuleSet(CqlParsingRuleSet):
|
|||
cqlword = cqlword[1:-1].replace("''", "'")
|
||||
return cqlword
|
||||
|
||||
|
||||
CqlRuleSet = Cql3ParsingRuleSet()
|
||||
|
||||
# convenience for remainder of module
|
||||
|
|
@ -376,6 +378,7 @@ def prop_equals_completer(ctxt, cass):
|
|||
return ()
|
||||
return ['=']
|
||||
|
||||
|
||||
completer_for('property', 'propeq')(prop_equals_completer)
|
||||
|
||||
|
||||
|
|
@ -598,6 +601,7 @@ def alterable_ks_name_completer(ctxt, cass):
|
|||
def cf_ks_name_completer(ctxt, cass):
|
||||
return [maybe_escape_name(ks) + '.' for ks in cass.get_keyspace_names()]
|
||||
|
||||
|
||||
completer_for('columnFamilyName', 'ksname')(cf_ks_name_completer)
|
||||
completer_for('materializedViewName', 'ksname')(cf_ks_name_completer)
|
||||
|
||||
|
|
@ -608,6 +612,7 @@ def cf_ks_dot_completer(ctxt, cass):
|
|||
return ['.']
|
||||
return []
|
||||
|
||||
|
||||
completer_for('columnFamilyName', 'dot')(cf_ks_dot_completer)
|
||||
completer_for('materializedViewName', 'dot')(cf_ks_dot_completer)
|
||||
|
||||
|
|
@ -639,6 +644,7 @@ def mv_name_completer(ctxt, cass):
|
|||
raise
|
||||
return map(maybe_escape_name, mvnames)
|
||||
|
||||
|
||||
completer_for('userTypeName', 'ksname')(cf_ks_name_completer)
|
||||
|
||||
completer_for('userTypeName', 'dot')(cf_ks_dot_completer)
|
||||
|
|
@ -691,6 +697,7 @@ def working_on_keyspace(ctxt):
|
|||
return True
|
||||
return False
|
||||
|
||||
|
||||
syntax_rules += r'''
|
||||
<useStatement> ::= "USE" <keyspaceName>
|
||||
;
|
||||
|
|
@ -851,6 +858,7 @@ def select_relation_lhs_completer(ctxt, cass):
|
|||
filterable.add(idx.index_options["target"])
|
||||
return map(maybe_escape_name, filterable)
|
||||
|
||||
|
||||
explain_completion('selector', 'colname')
|
||||
|
||||
syntax_rules += r'''
|
||||
|
|
@ -925,6 +933,7 @@ def insert_option_completer(ctxt, cass):
|
|||
opts.discard(opt.split()[0])
|
||||
return opts
|
||||
|
||||
|
||||
syntax_rules += r'''
|
||||
<updateStatement> ::= "UPDATE" cf=<columnFamilyName>
|
||||
( "USING" [updateopt]=<usingOption>
|
||||
|
|
@ -1131,6 +1140,7 @@ def batch_opt_completer(ctxt, cass):
|
|||
opts.discard(opt.split()[0])
|
||||
return opts
|
||||
|
||||
|
||||
syntax_rules += r'''
|
||||
<truncateStatement> ::= "TRUNCATE" ("COLUMNFAMILY" | "TABLE")? cf=<columnFamilyName>
|
||||
;
|
||||
|
|
@ -1150,6 +1160,7 @@ def create_ks_wat_completer(ctxt, cass):
|
|||
return ['KEYSPACE']
|
||||
return ['KEYSPACE', 'SCHEMA']
|
||||
|
||||
|
||||
syntax_rules += r'''
|
||||
<createColumnFamilyStatement> ::= "CREATE" wat=( "COLUMNFAMILY" | "TABLE" ) ("IF" "NOT" "EXISTS")?
|
||||
( ks=<nonSystemKeyspaceName> dot="." )? cf=<cfOrKsName>
|
||||
|
|
@ -1198,6 +1209,7 @@ def create_cf_wat_completer(ctxt, cass):
|
|||
return ['TABLE']
|
||||
return ['TABLE', 'COLUMNFAMILY']
|
||||
|
||||
|
||||
explain_completion('createColumnFamilyStatement', 'cf', '<new_table_name>')
|
||||
explain_completion('compositeKeyCfSpec', 'newcolname', '<new_column_name>')
|
||||
|
||||
|
|
@ -1252,6 +1264,7 @@ def create_cf_composite_primary_key_comma_completer(ctxt, cass):
|
|||
return ()
|
||||
return [',']
|
||||
|
||||
|
||||
syntax_rules += r'''
|
||||
|
||||
<idxName> ::= <identifier>
|
||||
|
|
@ -1315,6 +1328,7 @@ def create_index_col_completer(ctxt, cass):
|
|||
colnames = [cd.name for cd in layout.columns.values() if cd.name not in idx_targets]
|
||||
return map(maybe_escape_name, colnames)
|
||||
|
||||
|
||||
syntax_rules += r'''
|
||||
<dropKeyspaceStatement> ::= "DROP" "KEYSPACE" ("IF" "EXISTS")? ksname=<nonSystemKeyspaceName>
|
||||
;
|
||||
|
|
@ -1372,6 +1386,7 @@ def idx_ks_idx_name_completer(ctxt, cass):
|
|||
raise
|
||||
return map(maybe_escape_name, idxnames)
|
||||
|
||||
|
||||
syntax_rules += r'''
|
||||
<alterTableStatement> ::= "ALTER" wat=( "COLUMNFAMILY" | "TABLE" ) cf=<columnFamilyName>
|
||||
<alterInstructions>
|
||||
|
|
@ -1406,6 +1421,7 @@ def alter_type_field_completer(ctxt, cass):
|
|||
fields = [tuple[0] for tuple in layout]
|
||||
return map(maybe_escape_name, fields)
|
||||
|
||||
|
||||
explain_completion('alterInstructions', 'newcol', '<new_column_name>')
|
||||
explain_completion('alterTypeInstructions', 'newcol', '<new_field_name>')
|
||||
|
||||
|
|
@ -1555,6 +1571,7 @@ def rolename_completer(ctxt, cass):
|
|||
session = cass.session
|
||||
return [maybe_quote(row[0].replace("'", "''")) for row in session.execute("LIST ROLES")]
|
||||
|
||||
|
||||
syntax_rules += r'''
|
||||
<createTriggerStatement> ::= "CREATE" "TRIGGER" ( "IF" "NOT" "EXISTS" )? <cident>
|
||||
"ON" cf=<columnFamilyName> "USING" class=<stringLiteral>
|
||||
|
|
@ -1578,6 +1595,7 @@ def drop_trigger_completer(ctxt, cass):
|
|||
names = get_trigger_names(ctxt, cass)
|
||||
return map(maybe_escape_name, names)
|
||||
|
||||
|
||||
# END SYNTAX/COMPLETION RULE DEFINITIONS
|
||||
|
||||
CqlRuleSet.append_rules(syntax_rules)
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ class FormattedValue:
|
|||
"""
|
||||
return self.coloredval + self._pad(width, fill)
|
||||
|
||||
|
||||
DEFAULT_VALUE_COLORS = dict(
|
||||
default=YELLOW,
|
||||
text=YELLOW,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ def _show_control_chars(match):
|
|||
txt = txt[1:-1]
|
||||
return txt
|
||||
|
||||
|
||||
bits_to_turn_red_re = re.compile(r'\\([^uUx]|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{2}|U[0-9a-fA-F]{8})')
|
||||
|
||||
|
||||
|
|
@ -56,6 +57,7 @@ def _make_turn_bits_red_f(color1, color2):
|
|||
return color1 + txt + color2
|
||||
return _turn_bits_red
|
||||
|
||||
|
||||
default_null_placeholder = 'null'
|
||||
default_float_precision = 3
|
||||
default_colormap = DEFAULT_VALUE_COLORS
|
||||
|
|
@ -100,6 +102,7 @@ def color_text(bval, colormap, displaywidth=None):
|
|||
displaywidth -= bval.count(r'\\')
|
||||
return FormattedValue(bval, coloredval, displaywidth)
|
||||
|
||||
|
||||
DEFAULT_NANOTIME_FORMAT = '%H:%M:%S.%N'
|
||||
DEFAULT_DATE_FORMAT = '%Y-%m-%d'
|
||||
|
||||
|
|
@ -206,6 +209,7 @@ def format_value_default(val, colormap, **_):
|
|||
bval = controlchars_re.sub(_show_control_chars, escapedval)
|
||||
return bval if colormap is NO_COLOR_MAP else color_text(bval, colormap)
|
||||
|
||||
|
||||
# Mapping cql type base names ("int", "map", etc) to formatter functions,
|
||||
# making format_value a generic function
|
||||
_formatters = {}
|
||||
|
|
@ -237,6 +241,8 @@ def formatter_for(typname):
|
|||
def format_value_blob(val, colormap, **_):
|
||||
bval = '0x' + binascii.hexlify(val)
|
||||
return colorme(bval, colormap, 'blob')
|
||||
|
||||
|
||||
formatter_for('buffer')(format_value_blob)
|
||||
formatter_for('blob')(format_value_blob)
|
||||
|
||||
|
|
@ -259,6 +265,7 @@ def format_value_decimal(val, float_precision, colormap, decimal_sep=None, thous
|
|||
def format_value_uuid(val, colormap, **_):
|
||||
return format_python_formatted_type(val, colormap, 'uuid')
|
||||
|
||||
|
||||
formatter_for('timeuuid')(format_value_uuid)
|
||||
|
||||
|
||||
|
|
@ -273,6 +280,7 @@ def format_value_boolean(val, colormap, boolean_styles=None, **_):
|
|||
val = boolean_styles[0] if val else boolean_styles[1]
|
||||
return format_python_formatted_type(val, colormap, 'boolean')
|
||||
|
||||
|
||||
formatter_for('boolean')(format_value_boolean)
|
||||
|
||||
|
||||
|
|
@ -302,6 +310,7 @@ def format_floating_point_type(val, colormap, float_precision, decimal_sep=None,
|
|||
|
||||
return colorme(bval, colormap, 'float')
|
||||
|
||||
|
||||
formatter_for('float')(format_floating_point_type)
|
||||
formatter_for('double')(format_floating_point_type)
|
||||
|
||||
|
|
@ -311,6 +320,7 @@ def format_integer_type(val, colormap, thousands_sep=None, **_):
|
|||
bval = format_integer_with_thousands_sep(val, thousands_sep) if thousands_sep else str(val)
|
||||
return colorme(bval, colormap, 'int')
|
||||
|
||||
|
||||
# We can get rid of this in cassandra-2.2
|
||||
if sys.version_info >= (2, 7):
|
||||
def format_integer_with_thousands_sep(val, thousands_sep=','):
|
||||
|
|
@ -348,6 +358,7 @@ def format_value_timestamp(val, colormap, date_time_format, quote=False, **_):
|
|||
bval = "'%s'" % bval
|
||||
return colorme(bval, colormap, 'timestamp')
|
||||
|
||||
|
||||
formatter_for('timestamp')(format_value_timestamp)
|
||||
|
||||
|
||||
|
|
@ -366,6 +377,7 @@ def strftime(time_format, seconds, microseconds=0, timezone=None):
|
|||
# able to correctly import timestamps exported as milliseconds since the epoch.
|
||||
return '%d' % (seconds * 1000.0)
|
||||
|
||||
|
||||
microseconds_regex = re.compile("(.*)(?:\.(\d{1,6}))(.*)")
|
||||
|
||||
|
||||
|
|
@ -475,6 +487,7 @@ def format_value_text(val, encoding, colormap, quote=False, **_):
|
|||
|
||||
return bval if colormap is NO_COLOR_MAP else color_text(bval, colormap, wcwidth.wcswidth(bval.decode(encoding)))
|
||||
|
||||
|
||||
# name alias
|
||||
formatter_for('unicode')(format_value_text)
|
||||
formatter_for('text')(format_value_text)
|
||||
|
|
@ -522,6 +535,8 @@ def format_value_set(val, cqltype, encoding, colormap, date_time_format, float_p
|
|||
return format_simple_collection(sorted(val), cqltype, '{', '}', encoding, colormap,
|
||||
date_time_format, float_precision, nullval,
|
||||
decimal_sep, thousands_sep, boolean_styles)
|
||||
|
||||
|
||||
formatter_for('frozenset')(format_value_set)
|
||||
formatter_for('sortedset')(format_value_set)
|
||||
formatter_for('SortedSet')(format_value_set)
|
||||
|
|
@ -548,6 +563,8 @@ def format_value_map(val, cqltype, encoding, colormap, date_time_format, float_p
|
|||
+ rb
|
||||
displaywidth = 4 * len(subs) + sum(k.displaywidth + v.displaywidth for (k, v) in subs)
|
||||
return FormattedValue(bval, coloredval, displaywidth)
|
||||
|
||||
|
||||
formatter_for('OrderedDict')(format_value_map)
|
||||
formatter_for('OrderedMap')(format_value_map)
|
||||
formatter_for('OrderedMapSerializedKey')(format_value_map)
|
||||
|
|
@ -581,6 +598,7 @@ def format_value_utype(val, cqltype, encoding, colormap, date_time_format, float
|
|||
displaywidth = 4 * len(subs) + sum(k.displaywidth + v.displaywidth for (k, v) in subs)
|
||||
return FormattedValue(bval, coloredval, displaywidth)
|
||||
|
||||
|
||||
NANOS_PER_MICRO = 1000
|
||||
NANOS_PER_MILLI = 1000 * NANOS_PER_MICRO
|
||||
NANOS_PER_SECOND = 1000 * NANOS_PER_MILLI
|
||||
|
|
|
|||
|
|
@ -518,6 +518,7 @@ class ParsingRuleSet:
|
|||
pattern.match(ctxt, completions)
|
||||
return completions
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ def bisearch(ucs, table):
|
|||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
# The following two functions define the column width of an ISO 10646
|
||||
# character as follows:
|
||||
#
|
||||
|
|
@ -178,6 +179,7 @@ combining = (
|
|||
(0xE0100, 0xE01EF)
|
||||
)
|
||||
|
||||
|
||||
# sorted list of non-overlapping intervals of East Asian Ambiguous
|
||||
# characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c"
|
||||
ambiguous = (
|
||||
|
|
@ -321,6 +323,7 @@ def wcwidth_cjk(c):
|
|||
def wcswidth_cjk(s):
|
||||
return mk_wcswidth_cjk(map(ord, s))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
samples = (
|
||||
('MUSIC SHARP SIGN', 1),
|
||||
|
|
|
|||
Loading…
Reference in New Issue