~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/replication_services.cc

  • Committer: Jay Pipes
  • Date: 2009-12-11 21:21:33 UTC
  • mto: This revision was merged to the branch mainline in revision 1245.
  • Revision ID: jpipes@serialcoder-20091211212133-w5kiiz973mi5rhlx
Adds error for when a record is inserted into a table containing
no primary key and replication is enabled.  Adds a test case
verifying the error is thrown when an insert is attempted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
#include "drizzled/message/table.pb.h"
59
59
#include "drizzled/gettext.h"
60
60
#include "drizzled/session.h"
 
61
#include "drizzled/error.h"
61
62
 
62
63
#include <vector>
63
64
 
328
329
}
329
330
 
330
331
message::Statement &ReplicationServices::getInsertStatement(Session *in_session,
331
 
                                                            Table *in_table) const
 
332
                                                                 Table *in_table) const
332
333
{
333
334
  message::Statement *statement= in_session->getStatementMessage();
334
335
 
384
385
  }
385
386
}
386
387
 
387
 
void ReplicationServices::insertRecord(Session *in_session, Table *in_table)
 
388
bool ReplicationServices::insertRecord(Session *in_session, Table *in_table)
388
389
{
389
390
  if (! is_active)
390
 
    return;
 
391
    return false;
 
392
  /**
 
393
   * We do this check here because we don't want to even create a 
 
394
   * statement if there isn't a primary key on the table...
 
395
   *
 
396
   * @todo
 
397
   *
 
398
   * Multi-column primary keys are handled how exactly?
 
399
   */
 
400
  if (in_table->s->primary_key == MAX_KEY)
 
401
  {
 
402
    my_error(ER_NO_PRIMARY_KEY_ON_REPLICATED_TABLE, MYF(0));
 
403
    return true;
 
404
  }
391
405
 
392
406
  message::Statement &statement= getInsertStatement(in_session, in_table);
393
407
 
411
425
    record->add_insert_value(string_value->c_ptr(), string_value->length());
412
426
    string_value->free();
413
427
  }
 
428
  return false;
414
429
}
415
430
 
416
431
message::Statement &ReplicationServices::getUpdateStatement(Session *in_session,