summaryrefslogtreecommitdiff
path: root/storage/federated
diff options
context:
space:
mode:
authorunknown <istruewing@synthia.local>2007-06-30 18:17:20 +0200
committerunknown <istruewing@synthia.local>2007-06-30 18:17:20 +0200
commitb83c28b2ae07410fedb923b1753ca50bbf2cf5cb (patch)
treeed92301678b1a1b883fd8e8bfcb7775f0df554da /storage/federated
parent6b1250587727a5b157432971529bf7895590d6a8 (diff)
downloadmariadb-git-b83c28b2ae07410fedb923b1753ca50bbf2cf5cb.tar.gz
Post-merge fixes.
sql/ha_partition.cc: Post-merge fixes. The new function HA_EXTRA_INSERT_WITH_UPDATE needs to be handled in ha_partition::extra(). storage/federated/ha_federated.cc: Post-merge fixes. Removed leftover characters. Added a missing brace. Fixed and improved parenthesis handling in ha_federated::append_stmt_insert(). Moved code from HA_EXTRA_RESET to ha_federated::reset(). storage/federated/ha_federated.h: Post-merge fixes. Changed byte to uchar. Added declaration for ha_federated::reset().
Diffstat (limited to 'storage/federated')
-rw-r--r--storage/federated/ha_federated.cc56
-rw-r--r--storage/federated/ha_federated.h7
2 files changed, 39 insertions, 24 deletions
diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc
index 18460ad4cfc..635a6fa79e0 100644
--- a/storage/federated/ha_federated.cc
+++ b/storage/federated/ha_federated.cc
@@ -608,7 +608,7 @@ static int check_foreign_data_source(FEDERATED_SHARE *share,
query.append(STRING_WITH_LEN("SELECT * FROM "));
append_ident(&query, share->table_name, share->table_name_length,
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()))
{
@@ -1572,7 +1572,7 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table)
/* chops off 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,
tmp_share.table_name_length, ident_quote_char);
@@ -1809,6 +1809,7 @@ bool ha_federated::append_stmt_insert(String *query)
char insert_buffer[FEDERATED_QUERY_BUFFER_SIZE];
Field **field;
uint tmp_length;
+ bool added_field= FALSE;
/* The main insert query string */
String insert_string(insert_buffer, sizeof(insert_buffer), &my_charset_bin);
@@ -1824,8 +1825,8 @@ bool ha_federated::append_stmt_insert(String *query)
insert_string.append(STRING_WITH_LEN("INSERT INTO "));
append_ident(&insert_string, share->table_name, share->table_name_length,
ident_quote_char);
- insert_string.append(FEDERATED_OPENPAREN);
- tmp_length= insert_string.length() - strlen(STRING_WITH_LEN(", "));
+ tmp_length= insert_string.length();
+ insert_string.append(STRING_WITH_LEN(" ("));
/*
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)
next field is in the write set
*/
insert_string.append(STRING_WITH_LEN(", "));
+ added_field= TRUE;
}
}
- /*
- remove trailing comma
- */
- insert_string.length(insert_string.length() - sizeof_trailing_comma);
-
- /*
- if there were no fields, we don't want to add a closing paren
- AND, we don't want to chop off the last char '('
- insert will be "INSERT INTO t1 VALUES ();"
- */
- if (insert_string.length() > tmp_length)
+ if (added_field)
+ {
+ /* Remove trailing comma. */
+ insert_string.length(insert_string.length() - sizeof_trailing_comma);
+ insert_string.append(STRING_WITH_LEN(") "));
+ }
+ else
{
- 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 "));
@@ -2371,6 +2370,7 @@ int ha_federated::delete_row(const uchar *buf)
delete_string.append(value_quote_char);
}
delete_string.append(STRING_WITH_LEN(" AND "));
+ }
}
// Remove trailing AND
@@ -2974,11 +2974,6 @@ int ha_federated::extra(ha_extra_function operation)
case HA_EXTRA_INSERT_WITH_UPDATE:
insert_dup_update= TRUE;
break;
- case HA_EXTRA_RESET:
- insert_dup_update= FALSE;
- ignore_duplicates= FALSE;
- replace_duplicates= FALSE;
- break;
default:
/* do nothing */
DBUG_PRINT("info",("unhandled operation: %d", (uint) 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
for cases where the optimizer realizes that all rows will be
diff --git a/storage/federated/ha_federated.h b/storage/federated/ha_federated.h
index 399451888e2..3443194817b 100644
--- a/storage/federated/ha_federated.h
+++ b/storage/federated/ha_federated.h
@@ -107,9 +107,9 @@ private:
bool append_stmt_insert(String *query);
- int read_next(byte *buf, MYSQL_RES *result);
- int index_read_idx_with_result_set(byte *buf, uint index,
- const byte *key,
+ int read_next(uchar *buf, MYSQL_RES *result);
+ int index_read_idx_with_result_set(uchar *buf, uint index,
+ const uchar *key,
uint key_len,
ha_rkey_function find_flag,
MYSQL_RES **result);
@@ -251,5 +251,6 @@ public:
int connection_rollback();
int connection_autocommit(bool state);
int execute_simple_query(const char *query, int len);
+ int reset(void);
};