~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_base.cc

merged with up to date trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
#include <drizzled/lock.h>
46
46
#include <drizzled/plugin/listen.h>
47
47
#include "drizzled/cached_directory.h"
48
 
#include <drizzled/field/timestamp.h>
 
48
#include <drizzled/field/epoch.h>
49
49
#include <drizzled/field/null.h>
50
50
#include "drizzled/sql_table.h"
51
51
#include "drizzled/global_charset_info.h"
669
669
  /*
670
670
    Note that we need to hold table::Cache::singleton().mutex() while changing the
671
671
    open_tables list. Another thread may work on it.
672
 
    (See: table::Cache::singleton().removeTable(), mysql_wait_completed_table())
 
672
    (See: table::Cache::singleton().removeTable(), wait_completed_table())
673
673
    Closing a MERGE child before the parent would be fatal if the
674
674
    other thread tries to abort the MERGE lock in between.
675
675
  */
1504
1504
  /*
1505
1505
    Note that we need to hold table::Cache::singleton().mutex() while changing the
1506
1506
    open_tables list. Another thread may work on it.
1507
 
    (See: table::Cache::singleton().removeTable(), mysql_wait_completed_table())
 
1507
    (See: table::Cache::singleton().removeTable(), wait_completed_table())
1508
1508
    Closing a MERGE child before the parent would be fatal if the
1509
1509
    other thread tries to abort the MERGE lock in between.
1510
1510
  */
1633
1633
     * table/schema information via error messages
1634
1634
     */
1635
1635
    TableIdentifier the_table(tables->getSchemaName(), tables->getTableName());
1636
 
    if (not plugin::Authorization::isAuthorized(getSecurityContext(),
1637
 
                                                the_table))
 
1636
    if (not plugin::Authorization::isAuthorized(user(), the_table))
1638
1637
    {
1639
1638
      result= -1;                               // Fatal error
1640
1639
      break;
1919
1918
      current_bitmap= table->write_set;
1920
1919
    }
1921
1920
 
1922
 
    //if (current_bitmap->testAndSet(field->field_index))
1923
 
    if (current_bitmap->test(field->field_index))
 
1921
    //if (current_bitmap->testAndSet(field->position()))
 
1922
    if (current_bitmap->test(field->position()))
1924
1923
    {
1925
1924
      if (session->mark_used_columns == MARK_COLUMNS_WRITE)
1926
1925
        session->dup_field= field;
2230
2229
      {
2231
2230
        Table *table= field_to_set->getTable();
2232
2231
        if (session->mark_used_columns == MARK_COLUMNS_READ)
2233
 
          table->setReadSet(field_to_set->field_index);
 
2232
          table->setReadSet(field_to_set->position());
2234
2233
        else
2235
 
          table->setWriteSet(field_to_set->field_index);
 
2234
          table->setWriteSet(field_to_set->position());
2236
2235
      }
2237
2236
    }
2238
2237
  }
2904
2903
      {
2905
2904
        Table *table_1= nj_col_1->table_ref->table;
2906
2905
        /* Mark field_1 used for table cache. */
2907
 
        table_1->setReadSet(field_1->field_index);
 
2906
        table_1->setReadSet(field_1->position());
2908
2907
        table_1->covering_keys&= field_1->part_of_key;
2909
2908
        table_1->merge_keys|= field_1->part_of_key;
2910
2909
      }
2912
2911
      {
2913
2912
        Table *table_2= nj_col_2->table_ref->table;
2914
2913
        /* Mark field_2 used for table cache. */
2915
 
        table_2->setReadSet(field_2->field_index);
 
2914
        table_2->setReadSet(field_2->position());
2916
2915
        table_2->covering_keys&= field_2->part_of_key;
2917
2916
        table_2->merge_keys|= field_2->part_of_key;
2918
2917
      }
3658
3657
      if ((field= field_iterator.field()))
3659
3658
      {
3660
3659
        /* Mark fields as used to allow storage engine to optimze access */
3661
 
        field->getTable()->setReadSet(field->field_index);
 
3660
        field->getTable()->setReadSet(field->position());
3662
3661
        if (table)
3663
3662
        {
3664
3663
          table->covering_keys&= field->part_of_key;
3686
3685
        }
3687
3686
      }
3688
3687
      else
 
3688
      {
3689
3689
        session->used_tables|= item->used_tables();
 
3690
      }
 
3691
 
3690
3692
      session->lex->current_select->cur_pos_in_select_list++;
3691
3693
    }
3692
3694
    /*
3706
3708
    qualified '*', and all columns were coalesced, we have to give a more
3707
3709
    meaningful message than ER_BAD_TABLE_ERROR.
3708
3710
  */
3709
 
  if (!table_name)
 
3711
  if (not table_name)
 
3712
  {
3710
3713
    my_message(ER_NO_TABLES_USED, ER(ER_NO_TABLES_USED), MYF(0));
 
3714
  }
3711
3715
  else
 
3716
  {
3712
3717
    my_error(ER_BAD_TABLE_ERROR, MYF(0), table_name);
 
3718
  }
3713
3719
 
3714
3720
  return true;
3715
3721
}