~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/show.cc

  • Committer: Brian Aker
  • Date: 2009-11-20 19:07:14 UTC
  • mfrom: (1223.1.5 push)
  • Revision ID: brian@gaz-20091120190714-dhr3lgqxrt7dq1fc
Collected Merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
190
190
}
191
191
 
192
192
 
193
 
bool drizzled_show_create(Session *session, TableList *table_list)
 
193
bool drizzled_show_create(Session *session, TableList *table_list, bool is_if_not_exists)
194
194
{
195
195
  char buff[2048];
196
196
  String buffer(buff, sizeof(buff), system_charset_info);
212
212
 
213
213
  buffer.length(0);
214
214
 
215
 
  if (store_create_info(table_list, &buffer, NULL))
 
215
  if (store_create_info(table_list, &buffer, is_if_not_exists))
216
216
    return true;
217
217
 
218
218
  List<Item> field_list;
250
250
  Resulting statement is stored in the string pointed by @c buffer. The string
251
251
  is emptied first and its character set is set to the system character set.
252
252
 
253
 
  If HA_LEX_CREATE_IF_NOT_EXISTS flag is set in @c create_info->options, then
 
253
  If is_if_not_exists is set, then
254
254
  the resulting CREATE statement contains "IF NOT EXISTS" clause. Other flags
255
255
  in @c create_options are ignored.
256
256
 
418
418
                      for.
419
419
    packet            Pointer to a string where statement will be
420
420
                      written.
421
 
    create_info_arg   Pointer to create information that can be used
422
 
                      to tailor the format of the statement.  Can be
423
 
                      NULL, in which case only SQL_MODE is considered
424
 
                      when building the statement.
425
421
 
426
422
  NOTE
427
423
    Currently always return 0, but might return error code in the
431
427
    0       OK
432
428
 */
433
429
 
434
 
int store_create_info(TableList *table_list, String *packet, HA_CREATE_INFO *create_info_arg)
 
430
int store_create_info(TableList *table_list, String *packet, bool is_if_not_exists)
435
431
{
436
432
  List<Item> field_list;
437
433
  char tmp[MAX_FIELD_WIDTH], *for_str, def_value_buf[MAX_FIELD_WIDTH];
455
451
    packet->append(STRING_WITH_LEN("CREATE TEMPORARY TABLE "));
456
452
  else
457
453
    packet->append(STRING_WITH_LEN("CREATE TABLE "));
458
 
  if (create_info_arg &&
459
 
      (create_info_arg->options & HA_LEX_CREATE_IF_NOT_EXISTS))
 
454
  if (is_if_not_exists)
460
455
    packet->append(STRING_WITH_LEN("IF NOT EXISTS "));
461
456
  if (table_list->schema_table)
462
457
    alias= table_list->schema_table->getTableName().c_str();
630
625
      to the CREATE TABLE statement
631
626
    */
632
627
 
633
 
    /*
634
 
      IF   check_create_info
635
 
      THEN add ENGINE only if it was used when creating the table
 
628
    /* 
 
629
      We should always store engine since we will now be 
 
630
      making sure engines accept options (aka... no
 
631
      dangling arguments for engines.
636
632
    */
637
 
    if (!create_info_arg ||
638
 
        (create_info_arg->used_fields & HA_CREATE_USED_ENGINE))
639
 
    {
640
 
      packet->append(STRING_WITH_LEN(" ENGINE="));
641
 
      packet->append(cursor->engine->getName().c_str());
642
 
    }
 
633
    packet->append(STRING_WITH_LEN(" ENGINE="));
 
634
    packet->append(cursor->engine->getName().c_str());
643
635
 
644
636
    if (share->db_create_options & HA_OPTION_PACK_KEYS)
645
637
      packet->append(STRING_WITH_LEN(" PACK_KEYS=1"));