diff options
author | unknown <patg@govinda.patg.net> | 2006-07-17 16:45:04 -0700 |
---|---|---|
committer | unknown <patg@govinda.patg.net> | 2006-07-17 16:45:04 -0700 |
commit | 469813c7f3022035a1e577abbd21c44827b4cf6c (patch) | |
tree | 56999ccaddd110568aa40c01eb4b66814bfd6257 /sql/ha_federated.cc | |
parent | 5ac016a8147602703aae069c076e6b75a3ab5723 (diff) | |
download | mariadb-git-469813c7f3022035a1e577abbd21c44827b4cf6c.tar.gz |
"BUG #18764: Delete conditions causing inconsistencies in Federated tables"
Removed logic in ha_federated::write_row, which checks field query ids in the
loop which builds the query to run on the remote server.
mysql-test/r/federated.result:
"BUG #18764: Delete conditions causing inconsistencies in Federated tables"
New test results for test that verifies that one can insert to rows using
"insert into... select * from..", delete
them by id, then immediately insert them in the same way they were originally
inserted.
mysql-test/t/federated.test:
"BUG #18764: Delete conditions causing inconsistencies in Federated tables"
New test that verifies that one can insert to rows using
"insert into... select * from..", delete
them by id, then immediately insert them in the same way they were originally
inserted.
sql/ha_federated.cc:
"BUG #18764: Delete conditions causing inconsistencies in Federated tables"
Removed the logic in ha_federated::write_row which checked the query id of
each field and compared it to the thread query id.
Each field has a query id, and the problem used to be that if I did an insert
no fields specified, the field value would contain the last inserted value
for that field. The way to work around this was to see if the query id for
that field was the same as the current query id or of the rest of the field
query ids. If it wasn't, that told me the query didn't have the field value
specified.
Somewhere from when I wrote that code to now the problem went away, and there
was no longer the need for this logic.
Also removed the bool "has_fields", which needs not exist and using
table->s->fields is sufficient.
Diffstat (limited to 'sql/ha_federated.cc')
-rw-r--r-- | sql/ha_federated.cc | 89 |
1 files changed, 23 insertions, 66 deletions
diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index 11f676d9cf6..abdcb6dc9c0 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -1559,10 +1559,6 @@ inline uint field_in_record_is_null(TABLE *table, int ha_federated::write_row(byte *buf) { - bool has_fields= FALSE; - uint all_fields_have_same_query_id= 1; - ulong current_query_id= 1; - ulong tmp_query_id= 1; char insert_buffer[FEDERATED_QUERY_BUFFER_SIZE]; char values_buffer[FEDERATED_QUERY_BUFFER_SIZE]; char insert_field_value_buffer[STRING_BUFFER_USUAL_SIZE]; @@ -1580,24 +1576,12 @@ int ha_federated::write_row(byte *buf) insert_string.length(0); insert_field_value_string.length(0); DBUG_ENTER("ha_federated::write_row"); - DBUG_PRINT("info", - ("table charset name %s csname %s", - table->s->table_charset->name, - table->s->table_charset->csname)); statistic_increment(table->in_use->status_var.ha_write_count, &LOCK_status); if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT) table->timestamp_field->set_time(); /* - get the current query id - the fields that we add to the insert - statement to send to the foreign will not be appended unless they match - this query id - */ - current_query_id= table->in_use->query_id; - DBUG_PRINT("info", ("current query id %d", current_query_id)); - - /* start both our field and field values strings */ insert_string.append(FEDERATED_INSERT); @@ -1610,63 +1594,36 @@ int ha_federated::write_row(byte *buf) values_string.append(FEDERATED_OPENPAREN); /* - Even if one field is different, all_fields_same_query_id can't remain - 0 if it remains 0, then that means no fields were specified in the query - such as in the case of INSERT INTO table VALUES (val1, val2, valN) - - */ - for (field= table->field; *field; field++) - { - if (field > table->field && tmp_query_id != (*field)->query_id) - all_fields_have_same_query_id= 0; - - tmp_query_id= (*field)->query_id; - } - /* loop through the field pointer array, add any fields to both the values list and the fields list that match the current query id - - You might ask "Why an index variable (has_fields) ?" My answer is that - we need to count how many fields we actually need */ for (field= table->field; *field; field++) { - /* if there is a query id and if it's equal to the current query id */ - if (((*field)->query_id && (*field)->query_id == current_query_id) - || all_fields_have_same_query_id) + if ((*field)->is_null()) + insert_field_value_string.append(FEDERATED_NULL); + else { - /* - There are some fields. This will be used later to determine - whether to chop off commas and parens. - */ - has_fields= TRUE; - - if ((*field)->is_null()) - insert_field_value_string.append(FEDERATED_NULL); - else - { - (*field)->val_str(&insert_field_value_string); - /* quote these fields if they require it */ - (*field)->quote_data(&insert_field_value_string); - } - /* append the field name */ - insert_string.append((*field)->field_name); + (*field)->val_str(&insert_field_value_string); + /* quote these fields if they require it */ + (*field)->quote_data(&insert_field_value_string); + } + /* append the field name */ + insert_string.append((*field)->field_name); - /* append the value */ - values_string.append(insert_field_value_string); - insert_field_value_string.length(0); + /* append the value */ + values_string.append(insert_field_value_string); + insert_field_value_string.length(0); - /* append commas between both fields and fieldnames */ - /* - unfortunately, we can't use the logic - if *(fields + 1) to make the following - appends conditional because we may not append - if the next field doesn't match the condition: - (((*field)->query_id && (*field)->query_id == current_query_id) - */ - insert_string.append(FEDERATED_COMMA); - values_string.append(FEDERATED_COMMA); - } + /* append commas between both fields and fieldnames */ + /* + unfortunately, we can't use the logic + if *(fields + 1) to make the following + appends conditional because we may not append + if the next field doesn't match the condition: + (((*field)->query_id && (*field)->query_id == current_query_id) + */ + insert_string.append(FEDERATED_COMMA); + values_string.append(FEDERATED_COMMA); } /* @@ -1678,7 +1635,7 @@ int ha_federated::write_row(byte *buf) AND, we don't want to chop off the last char '(' insert will be "INSERT INTO t1 VALUES ();" */ - if (has_fields) + if (table->s->fields) { /* chops off leading commas */ values_string.length(values_string.length() - strlen(FEDERATED_COMMA)); |