Hi, Sachin! On Apr 16, Sachin Setia wrote:
Hi Sergei! As I already told you i was building prototype.It is some what completed apart from one thing comparing of two field values. the difficulty is how to get data length of field from table->record[1]. I will try to solve it.
Do you mean, a length of the blob value? Try field->get_length()
One more thing actually i got how mysql hide field. For example condsider three fields hash,data,data. mysql field pointer point at second field not at hash field and hash field ptr is stored in table->hash_field can we do something similar to store hash fields(if we make array of hashes in case of more than one unique).But will adding member variable cause problem? what do you think?
Well, yes, that would work. But I see few other features where field hiding might be useful, and in these cases this simple trick with moving table->field pointer will not work, unfortunately. So we might need something more complex. But, again, this is not a most important part of this project, so don't start from it. In fact, I'm rather interested to know about the adaptive hashing that you've mentioned. Can you tell me more about it, please?
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index ac2162b..291a3e2 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8956,6 +8964,31 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values, goto err; field->set_explicit_default(value); } + table->file->ha_index_init(0,0); + res = table->file->ha_index_read_map(table->record[1],hash_field->ptr,HA_WHOLE_KEY,HA_READ_KEY_EXACT); + while(!res){ + //compare the record if not sure how to compare it so just assume it works + diff = table->record[1]-table->record[0]; + src_length = blob_field->data_length(); + //dest_length = blob_field->data_length(table->record[1]); // i dont know how to get the length from record 1 + // so i am enable to do this + // then we can comapare records using + //field->cmp_max + //this is mysql code + /* if (!(table->distinct ? + table_rec_cmp(table) : + group_rec_cmp(table->group, table->record[0], table->record[1]))) + return false; // skip it + res= table->file->ha_index_next_same(table->record[1], + table->hash_field->ptr, + sizeof(hash)); */ + //fetch the next record + res= table->file->ha_index_next_same(table->record[1], + hash_field->ptr, + 8); + + }
not quite, you should check unique constraints in fill_record(). This should happen when the row is actually inserted or updated. A good place for this check, I'd say, is handler::ha_write_row() and handler::ha_update_row(). Regards, Sergei Chief Architect MariaDB and security@mariadb.org