[Commits] Rev 3487: MDEV-431: Cassandra storage engine in file:///data0/psergey/dev2/5.5-cassandra-r01/

Sergey Petrunya psergey at askmonty.org
Sat Aug 18 20:29:31 EEST 2012


At file:///data0/psergey/dev2/5.5-cassandra-r01/

------------------------------------------------------------
revno: 3487
revision-id: psergey at askmonty.org-20120818172931-fhf3hhwmshl164dr
parent: psergey at askmonty.org-20120818172150-fnccxt4rh7s7zqqw
committer: Sergey Petrunya <psergey at askmonty.org>
branch nick: 5.5-cassandra-r01
timestamp: Sat 2012-08-18 21:29:31 +0400
message:
  MDEV-431: Cassandra storage engine
  - Support "DELETE FROM cassandra_table"
=== modified file 'mysql-test/r/cassandra.result'
--- a/mysql-test/r/cassandra.result	2012-08-18 17:21:50 +0000
+++ b/mysql-test/r/cassandra.result	2012-08-18 17:29:31 +0000
@@ -22,4 +22,7 @@
 rowkey	data1	data2
 	data1-value	123456
 	data1-value2	34543
+delete from t1;
+select * from t1;
+rowkey	data1	data2
 drop table t1;

=== modified file 'mysql-test/t/cassandra.test'
--- a/mysql-test/t/cassandra.test	2012-08-18 17:21:50 +0000
+++ b/mysql-test/t/cassandra.test	2012-08-18 17:29:31 +0000
@@ -55,6 +55,11 @@
 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;
 
 ############################################################################

=== modified file 'storage/cassandra/cassandra_se.cc'
--- a/storage/cassandra/cassandra_se.cc	2012-08-18 17:21:50 +0000
+++ b/storage/cassandra/cassandra_se.cc	2012-08-18 17:29:31 +0000
@@ -95,6 +95,8 @@
   /* 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 @@
   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;
+}
+

=== modified file 'storage/cassandra/cassandra_se.h'
--- a/storage/cassandra/cassandra_se.h	2012-08-18 17:21:50 +0000
+++ b/storage/cassandra/cassandra_se.h	2012-08-18 17:29:31 +0000
@@ -44,7 +44,8 @@
   /* 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; }

=== modified file 'storage/cassandra/ha_cassandra.cc'
--- a/storage/cassandra/ha_cassandra.cc	2012-08-18 17:21:50 +0000
+++ b/storage/cassandra/ha_cassandra.cc	2012-08-18 17:29:31 +0000
@@ -746,6 +746,18 @@
   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_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



More information about the commits mailing list