Commit ff60d07c authored by Will DeVries's avatar Will DeVries Committed by Sergei Petrunia

Fix more spacing issues and formatting issues.

parent e176abf3
...@@ -153,46 +153,46 @@ static MYSQL_THDVAR_UINT ...@@ -153,46 +153,46 @@ static MYSQL_THDVAR_UINT
// Per thread select handler knob // Per thread select handler knob
static MYSQL_THDVAR_BOOL( static MYSQL_THDVAR_BOOL(
select_handler, select_handler,
PLUGIN_VAR_NOCMDARG, PLUGIN_VAR_NOCMDARG,
"", "",
NULL, NULL,
NULL, NULL,
1 1
); );
// Per thread derived handler knob // Per thread derived handler knob
static MYSQL_THDVAR_BOOL( static MYSQL_THDVAR_BOOL(
derived_handler, derived_handler,
PLUGIN_VAR_NOCMDARG, PLUGIN_VAR_NOCMDARG,
"", "",
NULL, NULL,
NULL, NULL,
1 1
); );
static MYSQL_THDVAR_BOOL( static MYSQL_THDVAR_BOOL(
enable_direct_update, enable_direct_update,
PLUGIN_VAR_NOCMDARG, PLUGIN_VAR_NOCMDARG,
"", "",
NULL, NULL,
NULL, NULL,
1 1
); );
bool select_handler_setting(THD* thd) bool select_handler_setting(THD* thd)
{ {
return ( thd == NULL ) ? false : THDVAR(thd, select_handler); return ( thd == NULL ) ? false : THDVAR(thd, select_handler);
} }
bool derived_handler_setting(THD* thd) bool derived_handler_setting(THD* thd)
{ {
return ( thd == NULL ) ? false : THDVAR(thd, derived_handler); return ( thd == NULL ) ? false : THDVAR(thd, derived_handler);
} }
uint row_buffer_setting(THD* thd) uint row_buffer_setting(THD* thd)
{ {
return THDVAR(thd, row_buffer); return THDVAR(thd, row_buffer);
} }
/**************************************************************************** /****************************************************************************
...@@ -223,8 +223,8 @@ size_t estimate_row_size(TABLE *table) ...@@ -223,8 +223,8 @@ size_t estimate_row_size(TABLE *table)
**/ **/
static void decode_objectname(char *buf, const char *path, size_t buf_size) static void decode_objectname(char *buf, const char *path, size_t buf_size)
{ {
size_t new_path_len = filename_to_tablename(path, buf, buf_size); size_t new_path_len = filename_to_tablename(path, buf, buf_size);
buf[new_path_len] = '\0'; buf[new_path_len] = '\0';
} }
static void decode_file_path(const char *path, char *decoded_dbname, static void decode_file_path(const char *path, char *decoded_dbname,
...@@ -326,11 +326,11 @@ int ha_xpand::create(const char *name, TABLE *form, HA_CREATE_INFO *info) ...@@ -326,11 +326,11 @@ int ha_xpand::create(const char *name, TABLE *form, HA_CREATE_INFO *info)
// To syncronize the schemas of MDB FE and XPD BE. // To syncronize the schemas of MDB FE and XPD BE.
if (form->s && form->s->db.length) { if (form->s && form->s->db.length) {
String createdb_stmt; String createdb_stmt;
createdb_stmt.append("CREATE DATABASE IF NOT EXISTS `"); createdb_stmt.append("CREATE DATABASE IF NOT EXISTS `");
createdb_stmt.append(form->s->db.str, form->s->db.length); createdb_stmt.append(form->s->db.str, form->s->db.length);
createdb_stmt.append("`"); createdb_stmt.append("`");
trx->run_query(createdb_stmt); trx->run_query(createdb_stmt);
} }
error_code = trx->run_query(create_table_stmt); error_code = trx->run_query(create_table_stmt);
...@@ -489,8 +489,7 @@ int ha_xpand::write_row(const uchar *buf) ...@@ -489,8 +489,7 @@ int ha_xpand::write_row(const uchar *buf)
/* XXX: Xpand may needs to return HA_ERR_AUTOINC_ERANGE if we hit that /* XXX: Xpand may needs to return HA_ERR_AUTOINC_ERANGE if we hit that
error. */ error. */
ulonglong last_insert_id = 0; ulonglong last_insert_id = 0;
if ((error_code = trx->write_row(xpand_table_oid, if ((error_code = trx->write_row(xpand_table_oid, packed_new_row, packed_size,
packed_new_row, packed_size,
&last_insert_id))) &last_insert_id)))
goto err; goto err;
...@@ -687,8 +686,7 @@ int ha_xpand::info(uint flag) ...@@ -687,8 +686,7 @@ int ha_xpand::info(uint flag)
if (stats.records == 0) if (stats.records == 0)
stats.mean_rec_length = 0; stats.mean_rec_length = 0;
else else
stats.mean_rec_length = (ulong) stats.mean_rec_length = (ulong) (stats.data_file_length / stats.records);
(stats.data_file_length / stats.records);
} }
if (flag & HA_STATUS_CONST) if (flag & HA_STATUS_CONST)
...@@ -780,8 +778,7 @@ int ha_xpand::index_read(uchar * buf, const uchar * key, uint key_len, ...@@ -780,8 +778,7 @@ int ha_xpand::index_read(uchar * buf, const uchar * key, uint key_len,
table->read_set, packed_key, packed_key_len, table->read_set, packed_key, packed_key_len,
&rowdata, &rowdata_length); &rowdata, &rowdata_length);
if (!error_code) if (!error_code)
error_code = unpack_row_to_buf(rgi, table, buf, rowdata, error_code = unpack_row_to_buf(rgi, table, buf, rowdata, table->read_set,
table->read_set,
rowdata + rowdata_length); rowdata + rowdata_length);
} else { } else {
is_scan = true; is_scan = true;
...@@ -790,7 +787,7 @@ int ha_xpand::index_read(uchar * buf, const uchar * key, uint key_len, ...@@ -790,7 +787,7 @@ int ha_xpand::index_read(uchar * buf, const uchar * key, uint key_len,
&scan_fields, packed_key, packed_key_len, &scan_fields, packed_key, packed_key_len,
THDVAR(thd, row_buffer), &scan_cur); THDVAR(thd, row_buffer), &scan_cur);
if (!error_code) if (!error_code)
error_code = rnd_next(buf); error_code = rnd_next(buf);
} }
if (rowdata) if (rowdata)
...@@ -1056,7 +1053,7 @@ int ha_xpand::external_lock(THD *thd, int lock_type) ...@@ -1056,7 +1053,7 @@ int ha_xpand::external_lock(THD *thd, int lock_type)
int error_code; int error_code;
xpand_connection *trx = get_trx(thd, &error_code); xpand_connection *trx = get_trx(thd, &error_code);
if (error_code) if (error_code)
DBUG_RETURN(error_code); DBUG_RETURN(error_code);
if (lock_type == F_WRLCK) if (lock_type == F_WRLCK)
xpd_lock_type = XPAND_EXCLUSIVE; xpd_lock_type = XPAND_EXCLUSIVE;
...@@ -1069,7 +1066,7 @@ int ha_xpand::external_lock(THD *thd, int lock_type) ...@@ -1069,7 +1066,7 @@ int ha_xpand::external_lock(THD *thd, int lock_type)
if (!trx->has_open_transaction()) { if (!trx->has_open_transaction()) {
error_code = trx->begin_transaction_next(); error_code = trx->begin_transaction_next();
if (error_code) if (error_code)
DBUG_RETURN(error_code); DBUG_RETURN(error_code);
} }
trans_register_ha(thd, FALSE, xpand_hton); trans_register_ha(thd, FALSE, xpand_hton);
...@@ -1349,18 +1346,18 @@ static struct st_mysql_storage_engine xpand_storage_engine = ...@@ -1349,18 +1346,18 @@ static struct st_mysql_storage_engine xpand_storage_engine =
maria_declare_plugin(xpand) maria_declare_plugin(xpand)
{ {
MYSQL_STORAGE_ENGINE_PLUGIN, /* Plugin Type */ MYSQL_STORAGE_ENGINE_PLUGIN, /* Plugin Type */
&xpand_storage_engine, /* Plugin Descriptor */ &xpand_storage_engine, /* Plugin Descriptor */
"XPAND", /* Plugin Name */ "XPAND", /* Plugin Name */
"MariaDB", /* Plugin Author */ "MariaDB", /* Plugin Author */
"Xpand storage engine", /* Plugin Description */ "Xpand storage engine", /* Plugin Description */
PLUGIN_LICENSE_GPL, /* Plugin Licence */ PLUGIN_LICENSE_GPL, /* Plugin Licence */
xpand_init, /* Plugin Entry Point */ xpand_init, /* Plugin Entry Point */
xpand_deinit, /* Plugin Deinitializer */ xpand_deinit, /* Plugin Deinitializer */
0x0001, /* Hex Version Number (0.1) */ 0x0001, /* Hex Version Number (0.1) */
NULL /* xpand_status_vars */, /* Status Variables */ NULL /* xpand_status_vars */, /* Status Variables */
xpand_system_variables, /* System Variables */ xpand_system_variables, /* System Variables */
"0.1", /* String Version */ "0.1", /* String Version */
MariaDB_PLUGIN_MATURITY_EXPERIMENTAL /* Maturity Level */ MariaDB_PLUGIN_MATURITY_EXPERIMENTAL /* Maturity Level */
} }
maria_declare_plugin_end; maria_declare_plugin_end;
...@@ -30,7 +30,8 @@ extern uint xpand_row_buffer; ...@@ -30,7 +30,8 @@ extern uint xpand_row_buffer;
* metadata_size int or -1 in case of error * metadata_size int or -1 in case of error
************************************************************/ ************************************************************/
int get_field_types(THD *thd, TABLE *table__, SELECT_LEX *sl, uchar *fieldtype, int get_field_types(THD *thd, TABLE *table__, SELECT_LEX *sl, uchar *fieldtype,
uchar *field_metadata, uchar *null_bits, const int num_null_bytes, const uint fields_count) uchar *field_metadata, uchar *null_bits,
const int num_null_bytes, const uint fields_count)
{ {
int field_metadata_size = 0; int field_metadata_size = 0;
int metadata_index = 0; int metadata_index = 0;
...@@ -85,7 +86,6 @@ int get_field_types(THD *thd, TABLE *table__, SELECT_LEX *sl, uchar *fieldtype, ...@@ -85,7 +86,6 @@ int get_field_types(THD *thd, TABLE *table__, SELECT_LEX *sl, uchar *fieldtype,
return field_metadata_size; return field_metadata_size;
} }
/*@brief create_xpand_select_handler- Creates handler*/ /*@brief create_xpand_select_handler- Creates handler*/
/************************************************************ /************************************************************
* DESCRIPTION: * DESCRIPTION:
...@@ -138,14 +138,15 @@ create_xpand_select_handler(THD* thd, SELECT_LEX* select_lex) ...@@ -138,14 +138,15 @@ create_xpand_select_handler(THD* thd, SELECT_LEX* select_lex)
&null_bits, num_null_bytes, &field_metadata, (items_number * 2), NULL); &null_bits, num_null_bytes, &field_metadata, (items_number * 2), NULL);
if (!meta_memory) { if (!meta_memory) {
// The only way to say something here is to raise warning // The only way to say something here is to raise warning
// b/c we will fallback to other access methods: derived handler or rowstore. // b/c we will fallback to other access methods: derived handler or rowstore.
goto err; goto err;
} }
if((field_metadata_size = if((field_metadata_size =
get_field_types(thd, NULL, select_lex, fieldtype, field_metadata, null_bits, num_null_bytes, items_number)) < 0) { get_field_types(thd, NULL, select_lex, fieldtype, field_metadata,
goto err; null_bits, num_null_bytes, items_number)) < 0) {
goto err;
} }
trx = get_trx(thd, &error_code); trx = get_trx(thd, &error_code);
...@@ -199,20 +200,20 @@ ha_xpand_select_handler::ha_xpand_select_handler( ...@@ -199,20 +200,20 @@ ha_xpand_select_handler::ha_xpand_select_handler(
**********************************************************/ **********************************************************/
ha_xpand_select_handler::~ha_xpand_select_handler() ha_xpand_select_handler::~ha_xpand_select_handler()
{ {
int error_code; int error_code;
xpand_connection *trx = get_trx(thd, &error_code); xpand_connection *trx = get_trx(thd, &error_code);
if (!trx) { if (!trx) {
// TBD Log this // TBD Log this
} }
if (trx && scan) if (trx && scan)
trx->scan_end(scan); trx->scan_end(scan);
// If the ::init_scan has been executed // If the ::init_scan has been executed
if (table__) if (table__)
my_bitmap_free(&scan_fields); my_bitmap_free(&scan_fields);
if (rgi) if (rgi)
remove_current_table_from_rpl_table_list(rgi); remove_current_table_from_rpl_table_list(rgi);
} }
/*@brief Initiate the query for select_handler */ /*@brief Initiate the query for select_handler */
...@@ -342,23 +343,20 @@ ha_xpand_derived_handler::ha_xpand_derived_handler( ...@@ -342,23 +343,20 @@ ha_xpand_derived_handler::ha_xpand_derived_handler(
**********************************************************/ **********************************************************/
ha_xpand_derived_handler::~ha_xpand_derived_handler() ha_xpand_derived_handler::~ha_xpand_derived_handler()
{ {
int error_code; int error_code;
xpand_connection *trx = get_trx(thd, &error_code);
if (!trx) {
// TBD Log this.
xpand_connection *trx = get_trx(thd, &error_code); }
if (!trx) { if (trx && scan)
// TBD Log this. trx->scan_end(scan);
}
if (trx && scan)
trx->scan_end(scan);
// If the ::init_scan has been executed // If the ::init_scan has been executed
if (table__) if (table__)
my_bitmap_free(&scan_fields); my_bitmap_free(&scan_fields);
if (rgi) if (rgi)
remove_current_table_from_rpl_table_list(rgi); remove_current_table_from_rpl_table_list(rgi);
} }
/*@brief Initiate the query for derived_handler */ /*@brief Initiate the query for derived_handler */
...@@ -395,7 +393,8 @@ int ha_xpand_derived_handler::init_scan() ...@@ -395,7 +393,8 @@ int ha_xpand_derived_handler::init_scan()
} }
if((field_metadata_size= if((field_metadata_size=
get_field_types(thd__, table, select, fieldtype, field_metadata, null_bits, num_null_bytes, items_number)) < 0) { get_field_types(thd__, table, select, fieldtype, field_metadata,
null_bits, num_null_bytes, items_number)) < 0) {
goto err; goto err;
} }
......
...@@ -16,20 +16,20 @@ Copyright (c) 2019, MariaDB Corporation. ...@@ -16,20 +16,20 @@ Copyright (c) 2019, MariaDB Corporation.
class ha_xpand_base_handler class ha_xpand_base_handler
{ {
// To simulate abstract class // To simulate abstract class
protected: protected:
ha_xpand_base_handler(): thd__(0),table__(0) {} ha_xpand_base_handler(): thd__(0),table__(0) {}
~ha_xpand_base_handler() {} ~ha_xpand_base_handler() {}
// Copies of pushdown handlers attributes // Copies of pushdown handlers attributes
// to use them in shared methods. // to use them in shared methods.
THD *thd__; THD *thd__;
TABLE *table__; TABLE *table__;
// The bitmap used to sent // The bitmap used to sent
MY_BITMAP scan_fields; MY_BITMAP scan_fields;
// Structures to unpack RBR rows from XPD BE // Structures to unpack RBR rows from XPD BE
rpl_group_info *rgi; rpl_group_info *rgi;
// XPD BE scan operation reference // XPD BE scan operation reference
xpand_connection_cursor *scan; xpand_connection_cursor *scan;
}; };
/*@brief select_handler class*/ /*@brief select_handler class*/
...@@ -44,15 +44,15 @@ class ha_xpand_select_handler: ...@@ -44,15 +44,15 @@ class ha_xpand_select_handler:
private ha_xpand_base_handler, private ha_xpand_base_handler,
public select_handler public select_handler
{ {
public: public:
ha_xpand_select_handler(THD* thd_arg, SELECT_LEX* sel, ha_xpand_select_handler(THD* thd_arg, SELECT_LEX* sel,
xpand_connection_cursor *scan); xpand_connection_cursor *scan);
~ha_xpand_select_handler(); ~ha_xpand_select_handler();
int init_scan(); int init_scan();
int next_row(); int next_row();
int end_scan(); int end_scan();
void print_error(int, unsigned long) {} void print_error(int, unsigned long) {}
}; };
/*@brief derived_handler class*/ /*@brief derived_handler class*/
...@@ -67,18 +67,17 @@ class ha_xpand_derived_handler: ...@@ -67,18 +67,17 @@ class ha_xpand_derived_handler:
private ha_xpand_base_handler, private ha_xpand_base_handler,
public derived_handler public derived_handler
{ {
public: public:
ha_xpand_derived_handler(THD* thd_arg, SELECT_LEX* sel, ha_xpand_derived_handler(THD* thd_arg, SELECT_LEX* sel,
xpand_connection_cursor *scan); xpand_connection_cursor *scan);
~ha_xpand_derived_handler(); ~ha_xpand_derived_handler();
int init_scan(); int init_scan();
int next_row(); int next_row();
int end_scan(); int end_scan();
void print_error(int, unsigned long) {} void print_error(int, unsigned long) {}
}; };
select_handler *create_xpand_select_handler(THD* thd, SELECT_LEX* select_lex); select_handler *create_xpand_select_handler(THD* thd, SELECT_LEX* select_lex);
derived_handler *create_xpand_derived_handler(THD* thd, TABLE_LIST *derived); derived_handler *create_xpand_derived_handler(THD* thd, TABLE_LIST *derived);
......
...@@ -240,8 +240,7 @@ int xpand_connection::send_command() ...@@ -240,8 +240,7 @@ int xpand_connection::send_command()
if (com_error) if (com_error)
{ {
int error_code = mysql_errno(&xpand_net); int error_code = mysql_errno(&xpand_net);
my_printf_error(error_code, my_printf_error(error_code, "Xpand error: %s", MYF(0),
"Xpand error: %s", MYF(0),
mysql_error(&xpand_net)); mysql_error(&xpand_net));
return error_code; return error_code;
} }
...@@ -256,8 +255,7 @@ int xpand_connection::read_query_response() ...@@ -256,8 +255,7 @@ int xpand_connection::read_query_response()
if (comerr) if (comerr)
{ {
error_code = mysql_errno(&xpand_net); error_code = mysql_errno(&xpand_net);
my_printf_error(error_code, my_printf_error(error_code, "Xpand error: %s", MYF(0),
"Xpand error: %s", MYF(0),
mysql_error(&xpand_net)); mysql_error(&xpand_net));
} }
...@@ -375,9 +373,8 @@ int xpand_connection::run_query(String &stmt) ...@@ -375,9 +373,8 @@ int xpand_connection::run_query(String &stmt)
return error_code; return error_code;
} }
int xpand_connection::write_row(ulonglong xpand_table_oid, int xpand_connection::write_row(ulonglong xpand_table_oid, uchar *packed_row,
uchar *packed_row, size_t packed_size, size_t packed_size, ulonglong *last_insert_id)
ulonglong *last_insert_id)
{ {
int error_code; int error_code;
command_length = 0; command_length = 0;
...@@ -405,11 +402,10 @@ int xpand_connection::write_row(ulonglong xpand_table_oid, ...@@ -405,11 +402,10 @@ int xpand_connection::write_row(ulonglong xpand_table_oid,
return error_code; return error_code;
} }
int xpand_connection::key_update(ulonglong xpand_table_oid, int xpand_connection::key_update(ulonglong xpand_table_oid, uchar *packed_key,
uchar *packed_key, size_t packed_key_length, size_t packed_key_length,
MY_BITMAP *update_set, MY_BITMAP *update_set, uchar *packed_new_data,
uchar *packed_new_data, size_t packed_new_length)
size_t packed_new_length)
{ {
int error_code; int error_code;
command_length = 0; command_length = 0;
...@@ -444,7 +440,7 @@ int xpand_connection::key_update(ulonglong xpand_table_oid, ...@@ -444,7 +440,7 @@ int xpand_connection::key_update(ulonglong xpand_table_oid,
} }
int xpand_connection::key_delete(ulonglong xpand_table_oid, int xpand_connection::key_delete(ulonglong xpand_table_oid,
uchar *packed_key, size_t packed_key_length) uchar *packed_key, size_t packed_key_length)
{ {
int error_code; int error_code;
command_length = 0; command_length = 0;
...@@ -665,8 +661,8 @@ int xpand_connection::allocate_cursor(MYSQL *xpand_net, ulong buffer_size, ...@@ -665,8 +661,8 @@ int xpand_connection::allocate_cursor(MYSQL *xpand_net, ulong buffer_size,
bool stmt_completed = FALSE; bool stmt_completed = FALSE;
int error_code = (*scan)->initialize(&stmt_completed); int error_code = (*scan)->initialize(&stmt_completed);
if (error_code) { if (error_code) {
delete *scan; delete *scan;
*scan = NULL; *scan = NULL;
} }
if (stmt_completed) if (stmt_completed)
...@@ -746,7 +742,8 @@ int xpand_connection::scan_query(String &stmt, uchar *fieldtype, uint fields, ...@@ -746,7 +742,8 @@ int xpand_connection::scan_query(String &stmt, uchar *fieldtype, uint fields,
if ((error_code = add_command_operand_str(fieldtype, fields))) if ((error_code = add_command_operand_str(fieldtype, fields)))
return error_code; return error_code;
if ((error_code = add_command_operand_str(field_metadata, field_metadata_size))) if ((error_code = add_command_operand_str(field_metadata,
field_metadata_size)))
return error_code; return error_code;
// This variable length string calls for an additional store w/o lcb lenth prefix. // This variable length string calls for an additional store w/o lcb lenth prefix.
...@@ -1129,7 +1126,7 @@ int xpand_connection::add_command_operand_str(const uchar *str, ...@@ -1129,7 +1126,7 @@ int xpand_connection::add_command_operand_str(const uchar *str,
return error_code; return error_code;
if (!str_length) if (!str_length)
return 0; return 0;
error_code = expand_command_buffer(str_length); error_code = expand_command_buffer(str_length);
if (error_code) if (error_code)
......
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