Hi!
>>>>> "Benjamin" == Benjamin Pflugmann <philemon@stripped> writes:
Benjamin> Hi.
Benjamin> Another question. I have tried to figure this out for over half an
Benjamin> hour now and don't get it. If I start to annoy you, just tell me and I
Benjamin> will search for some longer.
To send an email after figuring half and hour is ok.
Benjamin> The problem is within the intended ha_myisammrg::write_row:
Benjamin> --- mysql-3.23.40/sql/ha_myisammrg.cc Wed Jul 18 23:19:10 2001
Benjamin> +++ mysql-3.23.40-philemon/sql/ha_myisammrg.cc Thu Aug 30 04:36:49 2001
Benjamin> @@ -67,5 +67,11 @@
Benjamin> int ha_myisammrg::write_row(byte * buf)
Benjamin> {
Benjamin> - return (my_errno=HA_ERR_WRONG_COMMAND);
Benjamin> + statistic_increment(ha_write_count,&LOCK_status);
Benjamin> + if (table->time_stamp)
Benjamin> + update_timestamp(buf+table->time_stamp-1);
Benjamin> + if (table->next_number_field && buf == table->record[0])
Benjamin> + return (my_errno=HA_ERR_WRONG_COMMAND);
Benjamin> + /* update_auto_increment(); [phi] have to check this before allowing it
> */
Benjamin> + return myrg_write(file,buf);
Benjamin> }
Benjamin> This is mainly taken from ha_myisam::write_row and I just assured that
Benjamin> everything still makes sense. My problem with that is, that I cannot
Benjamin> figure out what "buf == table->record[0]" is intended to do/mean. I
Benjamin> understand that table->record[0] seems to be a pointer to a "row".
Benjamin> But what does the comparison mean (i.e. when is
Benjamin> (buf == table->record[0]) true and when false?) and at which place in
Benjamin> the source is table->record[0] set to the relevant value?
Every table object has 3 record object associated with it:
table->record[0] A changed record or a record with new values
table->record[1] Records are read into this
table->record[2] An record with default values
In almost all cases in MySQL we are using table->record[0] to write
new rows.
The only case when we are not is when copying a row from a table to
another (Ie: We are writing an unchanged row (record[1]) to another
identical table). In this case we should not update the
auto_increment column.
The check in the original code is:
if (table->next_number_field && buf == table->record[0])
update_auto_increment();
I have now added the following comment to the code:
/*
If we have an auto_increment column and we are writing a changed row
or a new row, then update the auto_increment value in the record.
*/
Regards,
Monty