Skip to content

Commit

Permalink
New OPTIMIZE table statement.
Browse files Browse the repository at this point in the history
Add row(s) affected in response for all statements.
  • Loading branch information
matriv committed Jun 23, 2016
1 parent c2bb94a commit 58338c0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 22 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Expand Up @@ -5,6 +5,9 @@ Changes for crash
Unreleased
==========

- Implement OPTIMIZE table statement which optimizes tables and partitions
by merging the segments of which each table and partition consists.

- Fixed "read file" command (``\r``) for legacy Python 2.7

- Added a configuration file that stores default values for Crash. The file is
Expand Down
7 changes: 1 addition & 6 deletions src/crate/crash/command.py
Expand Up @@ -165,8 +165,6 @@ def inner_fn(self, *args):

class CrateCmd(object):

EXCLUDE_ROWCOUNT = ['create', 'alter', 'drop', 'refresh', 'set', 'reset']

def __init__(self,
output_writer=None,
connection=None,
Expand Down Expand Up @@ -367,10 +365,7 @@ def execute(self, statement):
self.pprint(cur.fetchall(), [c[0] for c in cur.description])
tmpl = '{command} {rowcount} row{s} in set{duration}'
else:
tmpl = '{command} OK'
if command.lower() not in self.EXCLUDE_ROWCOUNT:
tmpl += ', {rowcount} row{s} affected'
tmpl += '{duration}'
tmpl = '{command} OK, {rowcount} row{s} affected {duration}'
self.logger.info(tmpl.format(**print_vars))
return True

Expand Down
27 changes: 12 additions & 15 deletions src/crate/crash/output.txt
Expand Up @@ -12,16 +12,13 @@ Check the correct response status lines.
+------------------------+-----------+---------+-----------+---------+
CONNECT OKCLUSTER CHECK OK

**Make sure the response status line of DDL and a few other statements
that do not affect rows do not print ``affected rows``:**

``CREATE`` **does not** affect rows::
``CREATE``::

cr> create table test_table (
... name string,
... value float
... ) with (number_of_replicas='0');
CREATE OK (... sec)
CREATE OK, 1 row affected (... sec)

``INSERT`` **does** affect rows, check for singular/plural::

Expand All @@ -32,10 +29,10 @@ that do not affect rows do not print ``affected rows``:**
... ('bar', 0.2), ('foobar', 0.3);
INSERT OK, 2 rows affected (... sec)

``REFRESH`` **does not** affect rows::
``REFRESH``::

cr> refresh table test_table;
REFRESH OK (... sec)
REFRESH OK, ... affected (... sec)

``UPDATE`` **does** affect rows, check for singular/plural::

Expand All @@ -50,7 +47,7 @@ that do not affect rows do not print ``affected rows``:**
.. hide::

cr> refresh table test_table;
REFRESH OK (... sec)
REFRESH OK, ... affected (... sec)

``SELECT`` has a different status message format::

Expand All @@ -64,23 +61,23 @@ that do not affect rows do not print ``affected rows``:**
+------+-------+
SELECT 3 rows in set (... sec)

``ALTER TABLE`` **does not** affect any rows::
``ALTER TABLE``::

cr> alter table test_table set (refresh_interval=0);
ALTER OK (... sec)
ALTER OK, ... affected (... sec)

``SET`` and ``RESET`` **do not** affect rows::
``SET`` and ``RESET``::

cr> set global transient stats.enabled = true;
SET OK (... sec)
SET OK, 1 row affected (... sec)

cr> reset global stats.enabled;
RESET OK (... sec)
RESET OK, 1 row affected (... sec)

``DROP`` **does not** affect rows::
``DROP``::

cr> drop table test_table;
DROP OK (... sec)
DROP OK, 1 row affected (... sec)

Status messages show the first word only::

Expand Down
2 changes: 1 addition & 1 deletion src/crate/crash/repl.py
Expand Up @@ -108,7 +108,7 @@ class SQLCompleter(Completer):
"array", "blob", "primary key",
"analyzer", "extends", "tokenizer", "char_filters", "token_filters",
"number_of_replicas", "clustered",
"refresh", "alter",
"refresh", "optimize", "alter",
"sys", "doc", "blob",
]

Expand Down

0 comments on commit 58338c0

Please sign in to comment.