~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

  • Committer: Brian Aker
  • Date: 2010-02-25 07:54:52 UTC
  • mfrom: (1273.13.101 build)
  • Revision ID: brian@gaz-20100225075452-19eozreshbrerypu
Merge of all patches in build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
 
44
44
 
45
45
#include "drizzled/statement/alter_table.h"
46
 
#include "drizzled/plugin/info_schema_table.h"
47
46
#include "drizzled/sql_table.h"
48
47
#include "drizzled/pthread_globals.h"
49
48
 
86
85
    apply it to the table.
87
86
  */
88
87
  if (create_info->default_table_charset == NULL)
89
 
    create_info->default_table_charset= get_default_db_collation(db);
 
88
    create_info->default_table_charset= plugin::StorageEngine::getSchemaCollation(db);
90
89
}
91
90
 
92
91
/*
1613
1612
  }
1614
1613
 
1615
1614
  pthread_mutex_lock(&LOCK_open); /* CREATE TABLE (some confussion on naming, double check) */
1616
 
  if (!internal_tmp_table && ! lex_identified_temp_table)
 
1615
  if (not internal_tmp_table && not lex_identified_temp_table)
1617
1616
  {
1618
 
    if (plugin::StorageEngine::getTableDefinition(*session,
1619
 
                                                  identifier)==EEXIST)
 
1617
    if (plugin::StorageEngine::doesTableExist(*session,
 
1618
                                              identifier, false)==EEXIST)
1620
1619
    {
1621
1620
      if (is_if_not_exists)
1622
1621
      {
1627
1626
        create_info->table_existed= 1;          // Mark that table existed
1628
1627
      }
1629
1628
      else 
 
1629
      {
1630
1630
        my_error(ER_TABLE_EXISTS_ERROR, MYF(0), identifier.getTableName());
 
1631
      }
1631
1632
 
1632
1633
      goto unlock_and_end;
1633
1634
    }
1655
1656
    one else is attempting to discover the table. Since
1656
1657
    it's not on disk as a frm cursor, no one could be using it!
1657
1658
  */
1658
 
  if (! lex_identified_temp_table)
 
1659
  if (not lex_identified_temp_table)
1659
1660
  {
1660
 
    int retcode= plugin::StorageEngine::getTableDefinition(*session, identifier);
 
1661
    bool exists= plugin::StorageEngine::doesTableExist(*session, identifier, false);
1661
1662
 
1662
 
    switch (retcode)
 
1663
    if (exists)
1663
1664
    {
1664
 
      case ENOENT:
1665
 
        /* Normal case, no table exists. we can go and create it */
1666
 
        break;
1667
 
      case EEXIST:
1668
 
        if (is_if_not_exists)
1669
 
        {
1670
 
          error= false;
1671
 
          push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
1672
 
                              ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
1673
 
                              identifier.getTableName());
1674
 
          create_info->table_existed= 1;                // Mark that table existed
1675
 
          goto unlock_and_end;
1676
 
        }
1677
 
        my_error(ER_TABLE_EXISTS_ERROR, MYF(0), identifier.getTableName());
1678
 
        goto unlock_and_end;
1679
 
      default:
1680
 
        my_error(retcode, MYF(0), identifier.getTableName());
1681
 
        goto unlock_and_end;
 
1665
      if (is_if_not_exists)
 
1666
      {
 
1667
        error= false;
 
1668
        push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
 
1669
                            ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
 
1670
                            identifier.getTableName());
 
1671
        create_info->table_existed= 1;          // Mark that table existed
 
1672
        goto unlock_and_end;
 
1673
      }
 
1674
 
 
1675
      my_error(ER_TABLE_EXISTS_ERROR, MYF(0), identifier.getTableName());
 
1676
      goto unlock_and_end;
1682
1677
    }
1683
1678
  }
1684
1679
 
1691
1686
                       table_proto,
1692
1687
                       create_info, alter_info->create_list,
1693
1688
                       key_count, key_info_buffer))
 
1689
  {
1694
1690
    goto unlock_and_end;
 
1691
  }
1695
1692
 
1696
1693
  if (lex_identified_temp_table)
1697
1694
  {
1698
1695
    /* Open table and put in temporary table list */
1699
 
    if (!(session->open_temporary_table(identifier)))
 
1696
    if (not (session->open_temporary_table(identifier)))
1700
1697
    {
1701
1698
      (void) session->rm_temporary_table(create_info->db_type, identifier);
1702
1699
      goto unlock_and_end;
1710
1707
    - The binary log is not open.
1711
1708
    Otherwise, the statement shall be binlogged.
1712
1709
   */
1713
 
  if (!internal_tmp_table && ! lex_identified_temp_table)
 
1710
  if (not internal_tmp_table && not lex_identified_temp_table)
1714
1711
    write_bin_log(session, session->query.c_str());
1715
1712
  error= false;
1716
1713
unlock_and_end:
1719
1716
err:
1720
1717
  session->set_proc_info("After create");
1721
1718
  delete cursor;
 
1719
 
1722
1720
  return(error);
1723
1721
}
1724
1722