[Commits] Rev 4590: LevelDB storage engine in file:///home/psergey/dev2/mysql-5.6-leveldb/

Sergey Petrunya psergey at askmonty.org
Fri Feb 1 19:50:24 EET 2013


At file:///home/psergey/dev2/mysql-5.6-leveldb/

------------------------------------------------------------
revno: 4590
revision-id: psergey at askmonty.org-20130201175022-e4rear7vfj1xll5f
parent: psergey at askmonty.org-20130201131827-1fauq5vi1ywq66ta
committer: Sergey Petrunya <psergey at askmonty.org>
branch nick: mysql-5.6-leveldb
timestamp: Fri 2013-02-01 21:50:22 +0400
message:
  LevelDB storage engine
  - Basic TRUNCATE TABLE support
  - Fix compile warnings
=== modified file 'mysql-test/r/leveldb.result'
--- a/mysql-test/r/leveldb.result	2013-02-01 13:18:27 +0000
+++ b/mysql-test/r/leveldb.result	2013-02-01 17:50:22 +0000
@@ -837,6 +837,5 @@ drop table t47;
 create table t48(pk int primary key auto_increment, col1 varchar(12)) engine=leveldb;
 set autocommit=0;
 truncate table t48;
-ERROR HY000: Table storage engine for 't48' doesn't have this option
 set autocommit=1;
 drop table t48;

=== modified file 'mysql-test/t/leveldb.test'
--- a/mysql-test/t/leveldb.test	2013-02-01 13:18:27 +0000
+++ b/mysql-test/t/leveldb.test	2013-02-01 17:50:22 +0000
@@ -733,7 +733,7 @@ drop table t47;
 --echo #
 create table t48(pk int primary key auto_increment, col1 varchar(12)) engine=leveldb;
 set autocommit=0;
---error ER_ILLEGAL_HA
+#--error ER_ILLEGAL_HA
 truncate table t48;
 set autocommit=1;
 drop table t48;

=== modified file 'storage/leveldb/ha_leveldb.cc'
--- a/storage/leveldb/ha_leveldb.cc	2013-02-01 13:18:27 +0000
+++ b/storage/leveldb/ha_leveldb.cc	2013-02-01 17:50:22 +0000
@@ -1838,6 +1838,14 @@ int ha_leveldb::delete_all_rows()
   DBUG_RETURN(HA_ERR_WRONG_COMMAND);
 }
 
+int ha_leveldb::truncate()
+{
+  mysql_mutex_lock(&tbl_def->mutex);
+  tbl_def->auto_incr_val= 1;
+  mysql_mutex_unlock(&tbl_def->mutex);
+  remove_rows(tbl_def);
+  return 0;
+}
 
 /*
   Delete the row we've last read. Ignore the parameter.
@@ -2169,6 +2177,19 @@ int ha_leveldb::delete_table(const char 
   if (!(tbl= ddl_manager.find((uchar*)strbuf.c_ptr(), strbuf.length())))
     DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
 
+  remove_rows(tbl);
+
+  /* 
+    Remove the table entry in data dictionary (this will also remove it from
+    the persistent data dictionary).
+  */
+  ddl_manager.remove(tbl, ldb_dict, true);
+
+  DBUG_RETURN(0);
+}
+
+void ha_leveldb::remove_rows(LDBSE_TABLE_DEF *tbl)
+{
   leveldb::Iterator* it= ldb->NewIterator(leveldb::ReadOptions());
   
   char key_buf[MAX_KEY_LENGTH];
@@ -2193,17 +2214,8 @@ int ha_leveldb::delete_table(const char 
     }
   }
   delete it;
-
-  /* 
-    Remove the table entry in data dictionary (this will also remove it from
-    the persistent data dictionary).
-  */
-  ddl_manager.remove(tbl, ldb_dict, true);
-
-  DBUG_RETURN(0);
 }
 
-
 int ha_leveldb::rename_table(const char *from, const char *to)
 {
   StringBuffer<256> from_str;

=== modified file 'storage/leveldb/ha_leveldb.h'
--- a/storage/leveldb/ha_leveldb.h	2013-02-01 15:34:02 +0000
+++ b/storage/leveldb/ha_leveldb.h	2013-02-01 17:50:22 +0000
@@ -248,6 +248,9 @@ class ha_leveldb: public handler
   int extra(enum ha_extra_function operation);
   int external_lock(THD *thd, int lock_type);
   int delete_all_rows(void);
+  int truncate();
+
+  void remove_rows(LDBSE_TABLE_DEF *tbl);
   ha_rows records_in_range(uint inx, key_range *min_key,
                            key_range *max_key);
   int delete_table(const char *from);

=== modified file 'storage/leveldb/ldb_datadic.cc'
--- a/storage/leveldb/ldb_datadic.cc	2013-02-01 13:18:27 +0000
+++ b/storage/leveldb/ldb_datadic.cc	2013-02-01 17:50:22 +0000
@@ -731,7 +731,7 @@ bool Keydef_store::init(leveldb::DB *ldb
 
     if (key.size() != LDBSE_KEYDEF::INDEX_NUMBER_SIZE + 1)
     {
-      sql_print_error("LevelDB: Key store got key of size %ld", key.size());
+      sql_print_error("LevelDB: Key store got key of size %d", (int)key.size());
       delete it;
       return true;
     }



More information about the commits mailing list