~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message/transaction.proto

  • Committer: Jay Pipes
  • Date: 2009-11-03 18:49:13 UTC
  • mto: (1234.1.1 push) (1237.2.10 push)
  • mto: This revision was merged to the branch mainline in revision 1206.
  • Revision ID: jpipes@serialcoder-20091103184913-12d2cehwq33jgcdn
This patch fixes a bug in the replication service and transaction
proto file that was occurring when an UPDATE statement was SETting
a field to a value by referencing the field itself.

For instance, imagine the following scenario:

CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, count INT NOT NULL);
INSERT INTO t1 (id, counter) VALUES (1,1),(2,2),(3,3);
UPDATE t1 SET counter = counter + 1 WHERE id IN (1,2);

Previously, the UpdateHeader message contained a single set_value
byte array containing the new value to set the field to.  However,
in scenarios such as the above, for each record being updated, the
value that the field would be set to is different.  Therefore, this
patch moves the set_value byte array from the UpdateHeader message
into the UpdateRecord message and names it after_value to match the
existing before_value byte array.

This patch adds a test case to the existing update.test case in the
transaction log suite and modifies the statement_transform library to
properly handle the above scenario.

Show diffs side-by-side

added added

removed removed

Lines of Context:
364
364
message UpdateRecord
365
365
{
366
366
  repeated bytes key_value = 1; /* The value of keys of updated records (unique or primary key) */
367
 
  repeated bytes before_value = 2; /* The value of the record before the update (optional) */
 
367
  repeated bytes after_value = 2; /* The value of the field after the update */
 
368
  repeated bytes before_value = 3; /* The value of the field before the update (optional) */
368
369
}
369
370
 
370
371
/*
372
373
 *
373
374
 * INSERT ... ON DUPLICATE KEY UPDATE
374
375
 * UPDATE
 
376
 * REPLACE INTO when the UPDATE optimization occurs.
375
377
 *
376
378
 * The statement is composed of a header (UpdateHeader) containing
377
379
 * metadata about affected tables and fields, as well as one or more data
388
390
  required TableMetadata table_metadata = 1; /* Minimal metadata about the table affected */
389
391
  repeated FieldMetadata key_field_metadata = 2; /* Collection of metadata about key fields */
390
392
  repeated FieldMetadata set_field_metadata = 3; /* Collection of metadata about fields affected */
391
 
  repeated bytes set_value = 4; /* The value of the field after the update */
392
393
}
393
394
 
394
395
message UpdateData