mirror of https://github.com/apache/cassandra
Merge branch 'cassandra-2.1' into cassandra-2.2
This commit is contained in:
commit
503aec74a5
|
|
@ -3,6 +3,8 @@
|
|||
* 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 (CASSANDRA-14021)
|
||||
|
||||
2.2.11
|
||||
* Safely handle empty buffers when outputting to JSON (CASSANDRA-13868)
|
||||
|
|
|
|||
|
|
@ -122,6 +122,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):]
|
||||
|
|
@ -582,6 +583,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)
|
||||
|
||||
|
|
@ -2518,12 +2521,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")
|
||||
|
|
@ -2578,6 +2581,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()
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ class SendingChannels(object):
|
|||
for ch in self.channels:
|
||||
try:
|
||||
ch.close()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
|
|
@ -221,7 +221,7 @@ class ReceivingChannels(object):
|
|||
for ch in self.channels:
|
||||
try:
|
||||
ch.close()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
|
|
@ -2054,8 +2054,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_traces', 'system_auth', 'system_distributed')
|
||||
NONALTERBALE_KEYSPACES = ('system')
|
||||
|
||||
|
|
@ -115,6 +116,7 @@ class Cql3ParsingRuleSet(CqlParsingRuleSet):
|
|||
cqlword = cqlword[1:-1].replace("''", "'")
|
||||
return cqlword
|
||||
|
||||
|
||||
CqlRuleSet = Cql3ParsingRuleSet()
|
||||
|
||||
# convenience for remainder of module
|
||||
|
|
@ -344,6 +346,7 @@ def prop_equals_completer(ctxt, cass):
|
|||
return ()
|
||||
return ['=']
|
||||
|
||||
|
||||
completer_for('property', 'propeq')(prop_equals_completer)
|
||||
|
||||
|
||||
|
|
@ -568,6 +571,7 @@ def 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)
|
||||
|
||||
|
||||
|
|
@ -577,6 +581,7 @@ def cf_ks_dot_completer(ctxt, cass):
|
|||
return ['.']
|
||||
return []
|
||||
|
||||
|
||||
completer_for('columnFamilyName', 'dot')(cf_ks_dot_completer)
|
||||
|
||||
|
||||
|
|
@ -593,6 +598,7 @@ def cf_name_completer(ctxt, cass):
|
|||
raise
|
||||
return map(maybe_escape_name, cfnames)
|
||||
|
||||
|
||||
completer_for('userTypeName', 'ksname')(cf_ks_name_completer)
|
||||
|
||||
completer_for('userTypeName', 'dot')(cf_ks_dot_completer)
|
||||
|
|
@ -645,6 +651,7 @@ def working_on_keyspace(ctxt):
|
|||
return True
|
||||
return False
|
||||
|
||||
|
||||
syntax_rules += r'''
|
||||
<useStatement> ::= "USE" <keyspaceName>
|
||||
;
|
||||
|
|
@ -789,6 +796,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'''
|
||||
|
|
@ -864,6 +872,7 @@ def insert_option_completer(ctxt, cass):
|
|||
opts.discard(opt.split()[0])
|
||||
return opts
|
||||
|
||||
|
||||
syntax_rules += r'''
|
||||
<updateStatement> ::= "UPDATE" cf=<columnFamilyName>
|
||||
( "USING" [updateopt]=<usingOption>
|
||||
|
|
@ -956,6 +965,7 @@ def update_indexbracket_completer(ctxt, cass):
|
|||
return ['[']
|
||||
return []
|
||||
|
||||
|
||||
syntax_rules += r'''
|
||||
<deleteStatement> ::= "DELETE" ( <deleteSelector> ( "," <deleteSelector> )* )?
|
||||
"FROM" cf=<columnFamilyName>
|
||||
|
|
@ -983,6 +993,7 @@ def delete_delcol_completer(ctxt, cass):
|
|||
layout = get_table_meta(ctxt, cass)
|
||||
return map(maybe_escape_name, regular_column_names(layout))
|
||||
|
||||
|
||||
syntax_rules += r'''
|
||||
<batchStatement> ::= "BEGIN" ( "UNLOGGED" | "COUNTER" )? "BATCH"
|
||||
( "USING" [batchopt]=<usingOption>
|
||||
|
|
@ -1005,6 +1016,7 @@ def batch_opt_completer(ctxt, cass):
|
|||
opts.discard(opt.split()[0])
|
||||
return opts
|
||||
|
||||
|
||||
syntax_rules += r'''
|
||||
<truncateStatement> ::= "TRUNCATE" ("COLUMNFAMILY" | "TABLE")? cf=<columnFamilyName>
|
||||
;
|
||||
|
|
@ -1024,6 +1036,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>
|
||||
|
|
@ -1072,6 +1085,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>')
|
||||
|
||||
|
|
@ -1126,6 +1140,7 @@ def create_cf_composite_primary_key_comma_completer(ctxt, cass):
|
|||
return ()
|
||||
return [',']
|
||||
|
||||
|
||||
syntax_rules += r'''
|
||||
|
||||
<idxName> ::= <identifier>
|
||||
|
|
@ -1184,6 +1199,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>
|
||||
;
|
||||
|
|
@ -1238,6 +1254,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>
|
||||
|
|
@ -1274,6 +1291,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>')
|
||||
|
||||
|
|
@ -1417,6 +1435,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>
|
||||
|
|
@ -1440,6 +1459,7 @@ def alter_type_field_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,
|
||||
|
|
|
|||
|
|
@ -42,6 +42,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})')
|
||||
|
||||
|
||||
|
|
@ -53,6 +54,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
|
||||
|
|
@ -97,6 +99,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'
|
||||
DEFAULT_TIMESTAMP_FORMAT = '%Y-%m-%d %H:%M:%S%z'
|
||||
|
|
@ -121,6 +124,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 = {}
|
||||
|
|
@ -148,6 +152,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)
|
||||
|
||||
|
||||
|
|
@ -208,6 +214,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)
|
||||
|
||||
|
||||
|
|
@ -216,6 +223,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=','):
|
||||
|
|
@ -271,6 +279,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)
|
||||
|
||||
|
|
@ -316,6 +325,8 @@ def format_value_set(val, encoding, colormap, date_time_format, float_precision,
|
|||
return format_simple_collection(sorted(val), '{', '}', 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)
|
||||
|
|
@ -342,6 +353,8 @@ def format_value_map(val, encoding, colormap, date_time_format, float_precision,
|
|||
+ 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)
|
||||
|
|
|
|||
|
|
@ -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