~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message/statement_transform.cc

MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
181
181
      }
182
182
    }
183
183
    break;
 
184
  case message::Statement::TRUNCATE_TABLE:
 
185
    {
 
186
      assert(source.has_truncate_table_statement());
 
187
      string destination;
 
188
      error= message::transformTruncateTableStatementToSql(source.truncate_table_statement(),
 
189
                                                           &destination,
 
190
                                                           sql_variant);
 
191
      sql_strings.push_back(destination);
 
192
    }
 
193
    break;
184
194
  case message::Statement::SET_VARIABLE:
185
195
    {
186
196
      assert(source.has_set_variable_statement());
633
643
}
634
644
 
635
645
enum message::TransformSqlError
 
646
message::transformTruncateTableStatementToSql(const message::TruncateTableStatement &statement,
 
647
                                              std::string *destination,
 
648
                                              enum message::TransformSqlVariant sql_variant)
 
649
{
 
650
  char quoted_identifier= '`';
 
651
  if (sql_variant == ANSI)
 
652
    quoted_identifier= '"';
 
653
 
 
654
  const message::TableMetadata &table_metadata= statement.table_metadata();
 
655
 
 
656
  destination->append("TRUNCATE TABLE ", 15);
 
657
  destination->push_back(quoted_identifier);
 
658
  destination->append(table_metadata.schema_name());
 
659
  destination->push_back(quoted_identifier);
 
660
  destination->push_back('.');
 
661
  destination->push_back(quoted_identifier);
 
662
  destination->append(table_metadata.table_name());
 
663
  destination->push_back(quoted_identifier);
 
664
 
 
665
  return NONE;
 
666
}
 
667
 
 
668
enum message::TransformSqlError
636
669
message::transformSetVariableStatementToSql(const message::SetVariableStatement &statement,
637
670
                                            std::string *destination,
638
671
                                            enum message::TransformSqlVariant sql_variant)