Commit 9cdf5eee authored by Sergey Petrunya's avatar Sergey Petrunya

MDEV-431: Cassandra storage engine

- Support "DELETE FROM cassandra_table"
parent ab281741
......@@ -22,4 +22,7 @@ select * from t1;
rowkey data1 data2
data1-value 123456
data1-value2 34543
delete from t1;
select * from t1;
rowkey data1 data2
drop table t1;
......@@ -55,6 +55,11 @@ create table t1 (rowkey char(36) primary key, data1 varchar(60), data2 bigint) e
insert into t1 values ('rowkey10', 'data1-value', 123456);
insert into t1 values ('rowkey11', 'data1-value2', 34543);
select * from t1;
# Check if deletion works
delete from t1;
select * from t1;
drop table t1;
############################################################################
......
......@@ -95,6 +95,8 @@ class Cassandra_se_impl: public Cassandra_se_interface
/* Setup that's necessary before a multi-row read. (todo: use it before point lookups, too) */
void clear_read_columns();
void add_read_column(const char *name);
bool truncate();
};
......@@ -398,3 +400,23 @@ void Cassandra_se_impl::add_read_column(const char *name_arg)
slice_pred.column_names.push_back(name);
}
bool Cassandra_se_impl::truncate()
{
bool res= true;
try {
cass->truncate(column_family);
res= false;
} catch (InvalidRequestException ire) {
print_error("%s [%s]", ire.what(), ire.why.c_str());
} catch (UnavailableException ue) {
print_error("UnavailableException: %s", ue.what());
} catch (TimedOutException te) {
print_error("TimedOutException: %s", te.what());
}
return res;
}
......@@ -44,7 +44,8 @@ class Cassandra_se_interface
/* read_set setup */
virtual void clear_read_columns()=0;
virtual void add_read_column(const char *name)=0;
virtual bool truncate()=0;
/* Passing error messages up to ha_cassandra */
char err_buffer[512];
const char *error_str() { return err_buffer; }
......
......@@ -746,6 +746,18 @@ int ha_cassandra::rnd_next(uchar *buf)
DBUG_RETURN(rc);
}
int ha_cassandra::delete_all_rows()
{
bool bres;
DBUG_ENTER("ha_cassandra::delete_all_rows");
bres= se->truncate();
DBUG_RETURN(bres? HA_ERR_INTERNAL_ERROR: 0);
}
/////////////////////////////////////////////////////////////////////////////
// Dummy implementations start
/////////////////////////////////////////////////////////////////////////////
......@@ -861,13 +873,6 @@ int ha_cassandra::delete_row(const uchar *buf)
}
int ha_cassandra::delete_all_rows()
{
DBUG_ENTER("ha_cassandra::delete_all_rows");
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
}
/**
check_if_incompatible_data() called if ALTER TABLE can't detect otherwise
if new and old definition are compatible
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment