Post-merge fixes.

parent bc3e18cd
...@@ -4714,6 +4714,12 @@ void ha_partition::get_dynamic_partition_info(PARTITION_INFO *stat_info, ...@@ -4714,6 +4714,12 @@ void ha_partition::get_dynamic_partition_info(PARTITION_INFO *stat_info,
HA_EXTRA_KEY_CACHE: HA_EXTRA_KEY_CACHE:
HA_EXTRA_NO_KEY_CACHE: HA_EXTRA_NO_KEY_CACHE:
This parameters are no longer used and could be removed. This parameters are no longer used and could be removed.
7) Parameters only used by federated tables for query processing
----------------------------------------------------------------
HA_EXTRA_INSERT_WITH_UPDATE:
Inform handler that an "INSERT...ON DUPLICATE KEY UPDATE" will be
executed. This condition is unset by HA_EXTRA_NO_IGNORE_DUP_KEY.
*/ */
int ha_partition::extra(enum ha_extra_function operation) int ha_partition::extra(enum ha_extra_function operation)
...@@ -4795,6 +4801,9 @@ int ha_partition::extra(enum ha_extra_function operation) ...@@ -4795,6 +4801,9 @@ int ha_partition::extra(enum ha_extra_function operation)
*/ */
break; break;
} }
/* Category 7), used by federated handlers */
case HA_EXTRA_INSERT_WITH_UPDATE:
DBUG_RETURN(loop_extra(operation));
default: default:
{ {
/* Temporary crash to discover what is wrong */ /* Temporary crash to discover what is wrong */
......
...@@ -608,7 +608,7 @@ static int check_foreign_data_source(FEDERATED_SHARE *share, ...@@ -608,7 +608,7 @@ static int check_foreign_data_source(FEDERATED_SHARE *share,
query.append(STRING_WITH_LEN("SELECT * FROM ")); query.append(STRING_WITH_LEN("SELECT * FROM "));
append_ident(&query, share->table_name, share->table_name_length, append_ident(&query, share->table_name, share->table_name_length,
ident_quote_char); ident_quote_char);
query.append(STRING_WITH_LEN(" WHERE 1=0"); query.append(STRING_WITH_LEN(" WHERE 1=0"));
if (mysql_real_query(mysql, query.ptr(), query.length())) if (mysql_real_query(mysql, query.ptr(), query.length()))
{ {
...@@ -1572,7 +1572,7 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table) ...@@ -1572,7 +1572,7 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table)
/* chops off trailing comma */ /* chops off trailing comma */
query.length(query.length() - sizeof_trailing_comma); query.length(query.length() - sizeof_trailing_comma);
query.append(STRING_WITH_LEN(" FROM `")); query.append(STRING_WITH_LEN(" FROM "));
append_ident(&query, tmp_share.table_name, append_ident(&query, tmp_share.table_name,
tmp_share.table_name_length, ident_quote_char); tmp_share.table_name_length, ident_quote_char);
...@@ -1809,6 +1809,7 @@ bool ha_federated::append_stmt_insert(String *query) ...@@ -1809,6 +1809,7 @@ bool ha_federated::append_stmt_insert(String *query)
char insert_buffer[FEDERATED_QUERY_BUFFER_SIZE]; char insert_buffer[FEDERATED_QUERY_BUFFER_SIZE];
Field **field; Field **field;
uint tmp_length; uint tmp_length;
bool added_field= FALSE;
/* The main insert query string */ /* The main insert query string */
String insert_string(insert_buffer, sizeof(insert_buffer), &my_charset_bin); String insert_string(insert_buffer, sizeof(insert_buffer), &my_charset_bin);
...@@ -1824,8 +1825,8 @@ bool ha_federated::append_stmt_insert(String *query) ...@@ -1824,8 +1825,8 @@ bool ha_federated::append_stmt_insert(String *query)
insert_string.append(STRING_WITH_LEN("INSERT INTO ")); insert_string.append(STRING_WITH_LEN("INSERT INTO "));
append_ident(&insert_string, share->table_name, share->table_name_length, append_ident(&insert_string, share->table_name, share->table_name_length,
ident_quote_char); ident_quote_char);
insert_string.append(FEDERATED_OPENPAREN); tmp_length= insert_string.length();
tmp_length= insert_string.length() - strlen(STRING_WITH_LEN(", ")); insert_string.append(STRING_WITH_LEN(" ("));
/* /*
loop through the field pointer array, add any fields to both the values loop through the field pointer array, add any fields to both the values
...@@ -1846,22 +1847,20 @@ bool ha_federated::append_stmt_insert(String *query) ...@@ -1846,22 +1847,20 @@ bool ha_federated::append_stmt_insert(String *query)
next field is in the write set next field is in the write set
*/ */
insert_string.append(STRING_WITH_LEN(", ")); insert_string.append(STRING_WITH_LEN(", "));
added_field= TRUE;
} }
} }
/* if (added_field)
remove trailing comma {
*/ /* Remove trailing comma. */
insert_string.length(insert_string.length() - sizeof_trailing_comma); insert_string.length(insert_string.length() - sizeof_trailing_comma);
insert_string.append(STRING_WITH_LEN(") "));
/* }
if there were no fields, we don't want to add a closing paren else
AND, we don't want to chop off the last char '('
insert will be "INSERT INTO t1 VALUES ();"
*/
if (insert_string.length() > tmp_length)
{ {
insert_string.append(STRING_WITH_LEN(") "); /* If there were no fields, we don't want to add a closing paren. */
insert_string.length(tmp_length);
} }
insert_string.append(STRING_WITH_LEN(" VALUES ")); insert_string.append(STRING_WITH_LEN(" VALUES "));
...@@ -2371,6 +2370,7 @@ int ha_federated::delete_row(const uchar *buf) ...@@ -2371,6 +2370,7 @@ int ha_federated::delete_row(const uchar *buf)
delete_string.append(value_quote_char); delete_string.append(value_quote_char);
} }
delete_string.append(STRING_WITH_LEN(" AND ")); delete_string.append(STRING_WITH_LEN(" AND "));
}
} }
// Remove trailing AND // Remove trailing AND
...@@ -2974,11 +2974,6 @@ int ha_federated::extra(ha_extra_function operation) ...@@ -2974,11 +2974,6 @@ int ha_federated::extra(ha_extra_function operation)
case HA_EXTRA_INSERT_WITH_UPDATE: case HA_EXTRA_INSERT_WITH_UPDATE:
insert_dup_update= TRUE; insert_dup_update= TRUE;
break; break;
case HA_EXTRA_RESET:
insert_dup_update= FALSE;
ignore_duplicates= FALSE;
replace_duplicates= FALSE;
break;
default: default:
/* do nothing */ /* do nothing */
DBUG_PRINT("info",("unhandled operation: %d", (uint) operation)); DBUG_PRINT("info",("unhandled operation: %d", (uint) operation));
...@@ -2987,6 +2982,25 @@ int ha_federated::extra(ha_extra_function operation) ...@@ -2987,6 +2982,25 @@ int ha_federated::extra(ha_extra_function operation)
} }
/**
@brief Reset state of file to after 'open'.
@detail This function is called after every statement for all tables
used by that statement.
@return Operation status
@retval 0 OK
*/
int ha_federated::reset(void)
{
insert_dup_update= FALSE;
ignore_duplicates= FALSE;
replace_duplicates= FALSE;
return 0;
}
/* /*
Used to delete all rows in a table. Both for cases of truncate and Used to delete all rows in a table. Both for cases of truncate and
for cases where the optimizer realizes that all rows will be for cases where the optimizer realizes that all rows will be
......
...@@ -107,9 +107,9 @@ class ha_federated: public handler ...@@ -107,9 +107,9 @@ class ha_federated: public handler
bool append_stmt_insert(String *query); bool append_stmt_insert(String *query);
int read_next(byte *buf, MYSQL_RES *result); int read_next(uchar *buf, MYSQL_RES *result);
int index_read_idx_with_result_set(byte *buf, uint index, int index_read_idx_with_result_set(uchar *buf, uint index,
const byte *key, const uchar *key,
uint key_len, uint key_len,
ha_rkey_function find_flag, ha_rkey_function find_flag,
MYSQL_RES **result); MYSQL_RES **result);
...@@ -251,5 +251,6 @@ class ha_federated: public handler ...@@ -251,5 +251,6 @@ class ha_federated: public handler
int connection_rollback(); int connection_rollback();
int connection_autocommit(bool state); int connection_autocommit(bool state);
int execute_simple_query(const char *query, int len); int execute_simple_query(const char *query, int len);
int reset(void);
}; };
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