~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

  • Committer: Brian Aker
  • Date: 2011-02-21 18:33:47 UTC
  • mto: (2187.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2188.
  • Revision ID: brian@tangent.org-20110221183347-37lw0bf0eizv0gxm
getLex() usage and fix for table_name creation during admin commands.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1768
1768
                                                            HA_CHECK_OPT *))
1769
1769
{
1770
1770
  TableList *table;
1771
 
  Select_Lex *select= &session->lex->select_lex;
 
1771
  Select_Lex *select= &session->getLex()->select_lex;
1772
1772
  List<Item> field_list;
1773
1773
  Item *item;
1774
 
  LEX *lex= session->lex;
1775
1774
  int result_code= 0;
1776
1775
  TransactionServices &transaction_services= TransactionServices::singleton();
1777
1776
  const CHARSET_INFO * const cs= system_charset_info;
1778
1777
 
1779
1778
  if (! session->endActiveTransaction())
1780
1779
    return 1;
 
1780
 
1781
1781
  field_list.push_back(item = new Item_empty_string("Table",
1782
1782
                                                    NAME_CHAR_LEN * 2,
1783
1783
                                                    cs));
1793
1793
 
1794
1794
  for (table= tables; table; table= table->next_local)
1795
1795
  {
1796
 
    char table_name[NAME_LEN*2+2];
 
1796
    identifier::Table table_identifier(table->getSchemaName(), table->getTableName());
 
1797
    std::string table_name;
1797
1798
    bool fatal_error=0;
1798
1799
 
1799
 
    snprintf(table_name, sizeof(table_name), "%s.%s", table->getSchemaName(), table->getTableName());
 
1800
    table_identifier.getSQLPath(table_name);
 
1801
 
1800
1802
    table->lock_type= lock_type;
1801
1803
    /* open only one table from local list of command */
1802
1804
    {
1811
1813
        so it have to be prepared.
1812
1814
        @todo Investigate if we can put extra tables into argument instead of using lex->query_tables
1813
1815
      */
1814
 
      lex->query_tables= table;
1815
 
      lex->query_tables_last= &table->next_global;
1816
 
      lex->query_tables_own_last= 0;
 
1816
      session->getLex()->query_tables= table;
 
1817
      session->getLex()->query_tables_last= &table->next_global;
 
1818
      session->getLex()->query_tables_own_last= 0;
1817
1819
      session->no_warnings_for_error= 0;
1818
1820
 
1819
1821
      session->openTablesLock(table);
1843
1845
    {
1844
1846
      char buff[FN_REFLEN + DRIZZLE_ERRMSG_SIZE];
1845
1847
      uint32_t length;
1846
 
      session->getClient()->store(table_name);
 
1848
      session->getClient()->store(table_name.c_str());
1847
1849
      session->getClient()->store(operator_name);
1848
1850
      session->getClient()->store(STRING_WITH_LEN("error"));
1849
1851
      length= snprintf(buff, sizeof(buff), ER(ER_OPEN_AS_READONLY),
1850
 
                       table_name);
 
1852
                       table_name.c_str());
1851
1853
      session->getClient()->store(buff, length);
1852
1854
      transaction_services.autocommitOrRollback(*session, false);
1853
1855
      session->endTransaction(COMMIT);
1854
1856
      session->close_thread_tables();
1855
 
      lex->reset_query_tables_list(false);
 
1857
      session->getLex()->reset_query_tables_list(false);
1856
1858
      table->table=0;                           // For query cache
1857
1859
      if (session->getClient()->flush())
1858
1860
        goto err;
1878
1880
 
1879
1881
send_result:
1880
1882
 
1881
 
    lex->cleanup_after_one_table_open();
 
1883
    session->getLex()->cleanup_after_one_table_open();
1882
1884
    session->clear_error();  // these errors shouldn't get client
1883
1885
    {
1884
1886
      List<DRIZZLE_ERROR>::iterator it(session->warn_list);
1885
1887
      DRIZZLE_ERROR *err;
1886
1888
      while ((err= it++))
1887
1889
      {
1888
 
        session->getClient()->store(table_name);
 
1890
        session->getClient()->store(table_name.c_str());
1889
1891
        session->getClient()->store(operator_name);
1890
1892
        session->getClient()->store(warning_level_names[err->level].str,
1891
1893
                               warning_level_names[err->level].length);
1895
1897
      }
1896
1898
      drizzle_reset_errors(session, true);
1897
1899
    }
1898
 
    session->getClient()->store(table_name);
 
1900
    session->getClient()->store(table_name.c_str());
1899
1901
    session->getClient()->store(operator_name);
1900
1902
 
1901
1903
    switch (result_code) {