Commit 28c9e1a5 authored by Sergey Petrunya's avatar Sergey Petrunya

Cassandra Storage Engine: Address review feedback part #3

- Cleanup ha_cassandra::store_lock()
- Remove dummy ha_cassandra::delete_table()
- Add HA_TABLE_SCAN_ON_INDEX to table_flags()
parent 6b47b2fe
...@@ -1605,7 +1605,10 @@ int ha_cassandra::index_read_map(uchar *buf, const uchar *key, ...@@ -1605,7 +1605,10 @@ int ha_cassandra::index_read_map(uchar *buf, const uchar *key,
DBUG_ENTER("ha_cassandra::index_read_map"); DBUG_ENTER("ha_cassandra::index_read_map");
if (find_flag != HA_READ_KEY_EXACT) if (find_flag != HA_READ_KEY_EXACT)
{
DBUG_ASSERT(0); /* Non-equality lookups should never be done */
DBUG_RETURN(HA_ERR_WRONG_COMMAND); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
}
uint key_len= calculate_key_len(table, active_index, key, keypart_map); uint key_len= calculate_key_len(table, active_index, key, keypart_map);
store_key_image_to_rec(table->field[0], (uchar*)key, key_len); store_key_image_to_rec(table->field[0], (uchar*)key, key_len);
...@@ -2470,7 +2473,16 @@ err: ...@@ -2470,7 +2473,16 @@ err:
} }
/* The following function was copied from ha_blackhole::store_lock: */ /*
We can't really have any locks for Cassandra Storage Engine. We're reading
from Cassandra cluster, and other clients can asynchronously modify the data.
We can enforce locking within this process, but this will not be useful.
Thus, store_lock() should express that:
- Writes do not block other writes
- Reads should not block anything either, including INSERTs.
*/
THR_LOCK_DATA **ha_cassandra::store_lock(THD *thd, THR_LOCK_DATA **ha_cassandra::store_lock(THD *thd,
THR_LOCK_DATA **to, THR_LOCK_DATA **to,
enum thr_lock_type lock_type) enum thr_lock_type lock_type)
...@@ -2478,27 +2490,13 @@ THR_LOCK_DATA **ha_cassandra::store_lock(THD *thd, ...@@ -2478,27 +2490,13 @@ THR_LOCK_DATA **ha_cassandra::store_lock(THD *thd,
DBUG_ENTER("ha_cassandra::store_lock"); DBUG_ENTER("ha_cassandra::store_lock");
if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)
{ {
/* /* Writes allow other writes */
Here is where we get into the guts of a row level lock.
If TL_UNLOCK is set
If we are not doing a LOCK TABLE or DISCARD/IMPORT
TABLESPACE, then allow multiple writers
*/
if ((lock_type >= TL_WRITE_CONCURRENT_INSERT && if ((lock_type >= TL_WRITE_CONCURRENT_INSERT &&
lock_type <= TL_WRITE) && !thd_in_lock_tables(thd) lock_type <= TL_WRITE))
&& !thd_tablespace_op(thd))
lock_type = TL_WRITE_ALLOW_WRITE; lock_type = TL_WRITE_ALLOW_WRITE;
/* /* Reads allow everything, including INSERTs */
In queries of type INSERT INTO t1 SELECT ... FROM t2 ... if (lock_type == TL_READ_NO_INSERT)
MySQL would use the lock TL_READ_NO_INSERT on t2, and that
would conflict with TL_WRITE_ALLOW_WRITE, blocking all inserts
to t2. Convert the lock to a normal read lock to allow
concurrent inserts to t2.
*/
if (lock_type == TL_READ_NO_INSERT && !thd_in_lock_tables(thd))
lock_type = TL_READ; lock_type = TL_READ;
lock.type= lock_type; lock.type= lock_type;
...@@ -2516,17 +2514,6 @@ ha_rows ha_cassandra::records_in_range(uint inx, key_range *min_key, ...@@ -2516,17 +2514,6 @@ ha_rows ha_cassandra::records_in_range(uint inx, key_range *min_key,
} }
int ha_cassandra::delete_table(const char *name)
{
DBUG_ENTER("ha_cassandra::delete_table");
/*
Cassandra table is just a view. Dropping it doesn't affect the underlying
column family, so we do nothing here.
*/
DBUG_RETURN(0);
}
/** /**
check_if_incompatible_data() called if ALTER TABLE can't detect otherwise check_if_incompatible_data() called if ALTER TABLE can't detect otherwise
if new and old definition are compatible if new and old definition are compatible
......
...@@ -145,7 +145,8 @@ public: ...@@ -145,7 +145,8 @@ public:
HA_REQUIRE_PRIMARY_KEY | HA_REQUIRE_PRIMARY_KEY |
HA_PRIMARY_KEY_IN_READ_INDEX | HA_PRIMARY_KEY_IN_READ_INDEX |
HA_PRIMARY_KEY_REQUIRED_FOR_POSITION | HA_PRIMARY_KEY_REQUIRED_FOR_POSITION |
HA_NO_AUTO_INCREMENT; HA_NO_AUTO_INCREMENT |
HA_TABLE_SCAN_ON_INDEX;
} }
/** @brief /** @brief
...@@ -258,7 +259,6 @@ public: ...@@ -258,7 +259,6 @@ public:
int delete_all_rows(void); int delete_all_rows(void);
ha_rows records_in_range(uint inx, key_range *min_key, ha_rows records_in_range(uint inx, key_range *min_key,
key_range *max_key); key_range *max_key);
int delete_table(const char *from);
int create(const char *name, TABLE *form, int create(const char *name, TABLE *form,
HA_CREATE_INFO *create_info); ///< required HA_CREATE_INFO *create_info); ///< required
bool check_if_incompatible_data(HA_CREATE_INFO *info, bool check_if_incompatible_data(HA_CREATE_INFO *info,
......
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