~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message/statement_transform.cc

  • Committer: David Shrewsbury
  • Date: 2011-01-13 18:43:55 UTC
  • mto: (2081.1.2 drizzle)
  • mto: This revision was merged to the branch mainline in revision 2082.
  • Revision ID: shrewsbury.dave@gmail.com-20110113184355-wsmu0grg7tkxwdsc
Push ALTER SCHEMA through replication stream as proper GPB message instead of RAW_SQL.

Show diffs side-by-side

added added

removed removed

Lines of Context:
318
318
      sql_strings.push_back(destination);
319
319
    }
320
320
    break;
 
321
  case Statement::ALTER_SCHEMA:
 
322
    {
 
323
      assert(source.has_alter_schema_statement());
 
324
      string destination;
 
325
      error= transformAlterSchemaStatementToSql(source.alter_schema_statement(),
 
326
                                                destination,
 
327
                                                sql_variant);
 
328
      sql_strings.push_back(destination);
 
329
    }
 
330
    break;
321
331
  case Statement::SET_VARIABLE:
322
332
    {
323
333
      assert(source.has_set_variable_statement());
806
816
}
807
817
 
808
818
enum TransformSqlError
 
819
transformAlterSchemaStatementToSql(const AlterSchemaStatement &statement,
 
820
                                   string &destination,
 
821
                                   enum TransformSqlVariant sql_variant)
 
822
{
 
823
  const Schema &before= statement.before();
 
824
  const Schema &after= statement.after();
 
825
 
 
826
  /* Make sure we are given the before and after for the same object */
 
827
  if (before.uuid() != after.uuid())
 
828
    return UUID_MISMATCH;
 
829
 
 
830
  char quoted_identifier= '`';
 
831
  if (sql_variant == ANSI)
 
832
    quoted_identifier= '"';
 
833
 
 
834
  destination.append("ALTER SCHEMA ");
 
835
  destination.push_back(quoted_identifier);
 
836
  destination.append(before.name());
 
837
  destination.push_back(quoted_identifier);
 
838
 
 
839
  /*
 
840
   * Diff our schemas. Currently, only collation can change so a
 
841
   * diff of the two structures is not really necessary.
 
842
   */
 
843
  destination.append(" COLLATE = ");
 
844
  destination.append(after.collation());
 
845
 
 
846
  return NONE;
 
847
}
 
848
 
 
849
enum TransformSqlError
809
850
transformDropSchemaStatementToSql(const DropSchemaStatement &statement,
810
851
                                  string &destination,
811
852
                                  enum TransformSqlVariant sql_variant)