~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/handler.cc

  • Committer: Brian Aker
  • Date: 2009-06-05 18:49:23 UTC
  • mfrom: (1039.3.19 handler-cleanup)
  • Revision ID: brian@gaz-20090605184923-36mbxlsxkocuco1w
Merge Stewart, fix LOCK (it was dead, only for dead RENAME SCHEMA code), and
fixed Sun Studio failure.

Show diffs side-by-side

added added

removed removed

Lines of Context:
516
516
}
517
517
 
518
518
/**
519
 
  @retval
520
 
    0   ok
521
 
  @retval
522
 
    1   error, transaction was rolled back
523
 
*/
524
 
int ha_prepare(Session *session)
525
 
{
526
 
  int error=0, all=1;
527
 
  Session_TRANS *trans=all ? &session->transaction.all : &session->transaction.stmt;
528
 
  Ha_trx_info *ha_info= trans->ha_list;
529
 
  if (ha_info)
530
 
  {
531
 
    for (; ha_info; ha_info= ha_info->next())
532
 
    {
533
 
      int err;
534
 
      StorageEngine *engine= ha_info->engine();
535
 
      status_var_increment(session->status_var.ha_prepare_count);
536
 
      if ((err= engine->prepare(session, all)))
537
 
      {
538
 
        my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
539
 
        ha_rollback_trans(session, all);
540
 
        error=1;
541
 
        break;
542
 
      }
543
 
      else
544
 
      {
545
 
        push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
546
 
                            ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA),
547
 
                            engine->getName().c_str());
548
 
      }
549
 
    }
550
 
  }
551
 
  return error;
552
 
}
553
 
 
554
 
/**
555
519
  Check if we can skip the two-phase commit.
556
520
 
557
521
  A helper function to evaluate if two-phase commit is mandatory.
1850
1814
  return(table->file->errkey);
1851
1815
}
1852
1816
 
1853
 
 
1854
 
/**
1855
 
  Delete all files with extension from bas_ext().
1856
 
 
1857
 
  @param name           Base name of table
1858
 
 
1859
 
  @note
1860
 
    We assume that the handler may return more extensions than
1861
 
    was actually used for the file.
1862
 
 
1863
 
  @retval
1864
 
    0   If we successfully deleted at least one file from base_ext and
1865
 
    didn't get any other errors than ENOENT
1866
 
  @retval
1867
 
    !0  Error
1868
 
*/
1869
 
int handler::delete_table(const char *name)
1870
 
{
1871
 
  int error= 0;
1872
 
  int enoent_or_zero= ENOENT;                   // Error if no file was deleted
1873
 
  char buff[FN_REFLEN];
1874
 
 
1875
 
  for (const char **ext=bas_ext(); *ext ; ext++)
1876
 
  {
1877
 
    fn_format(buff, name, "", *ext, MY_UNPACK_FILENAME|MY_APPEND_EXT);
1878
 
    if (my_delete_with_symlink(buff, MYF(0)))
1879
 
    {
1880
 
      if ((error= my_errno) != ENOENT)
1881
 
        break;
1882
 
    }
1883
 
    else
1884
 
      enoent_or_zero= 0;                        // No error for ENOENT
1885
 
    error= enoent_or_zero;
1886
 
  }
1887
 
  return error;
1888
 
}
1889
 
 
1890
 
 
1891
 
int handler::rename_table(const char * from, const char * to)
1892
 
{
1893
 
  int error= 0;
1894
 
  for (const char **ext= bas_ext(); *ext ; ext++)
1895
 
  {
1896
 
    if (rename_file_ext(from, to, *ext))
1897
 
    {
1898
 
      if ((error=my_errno) != ENOENT)
1899
 
        break;
1900
 
      error= 0;
1901
 
    }
1902
 
  }
1903
 
  return error;
1904
 
}
1905
 
 
1906
 
 
1907
1817
void handler::drop_table(const char *name)
1908
1818
{
1909
1819
  close();
1910
 
  delete_table(name);
 
1820
  engine->deleteTable(ha_session(), name);
1911
1821
}
1912
1822
 
1913
1823
 
1955
1865
      table_share can be NULL in ha_delete_table(). See implementation
1956
1866
      of standalone function ha_delete_table() in sql_base.cc.
1957
1867
    */
1958
 
    if (table_share == NULL || table_share->tmp_table == NO_TMP_TABLE)
 
1868
//    if (table_share == NULL || table_share->tmp_table == NO_TMP_TABLE)
1959
1869
      ha_info->set_trx_read_write();
1960
1870
  }
1961
1871
}
2131
2041
  prepare_for_alter();
2132
2042
}
2133
2043
 
2134
 
 
2135
 
/**
2136
 
  Rename table: public interface.
2137
 
 
2138
 
  @sa handler::rename_table()
2139
 
*/
2140
 
 
2141
 
int
2142
 
handler::ha_rename_table(const char *from, const char *to)
2143
 
{
2144
 
  mark_trx_read_write();
2145
 
 
2146
 
  return rename_table(from, to);
2147
 
}
2148
 
 
2149
 
 
2150
 
/**
2151
 
  Delete table: public interface.
2152
 
 
2153
 
  @sa handler::delete_table()
2154
 
*/
2155
 
 
2156
 
int
2157
 
handler::ha_delete_table(const char *name)
2158
 
{
2159
 
  mark_trx_read_write();
2160
 
 
2161
 
  return delete_table(name);
2162
 
}
2163
 
 
2164
 
 
2165
2044
/**
2166
2045
  Drop table in the engine: public interface.
2167
2046
 
2176
2055
  return drop_table(name);
2177
2056
}
2178
2057
 
2179
 
 
2180
 
/**
2181
 
  Create a table in the engine: public interface.
2182
 
 
2183
 
  @sa handler::create()
2184
 
*/
2185
 
 
2186
 
int
2187
 
handler::ha_create(const char *name, Table *form, HA_CREATE_INFO *create_info)
2188
 
{
2189
 
  mark_trx_read_write();
2190
 
 
2191
 
  return create(name, form, create_info);
2192
 
}
2193
 
 
2194
2058
/**
2195
2059
  Tell the storage engine that it is allowed to "disable transaction" in the
2196
2060
  handler. It is a hint that ACID is not required - it is used in NDB for