~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cursor.h

  • Committer: Brian Aker
  • Date: 2010-12-19 06:20:54 UTC
  • mfrom: (2005.1.1 bug673105)
  • Revision ID: brian@tangent.org-20101219062054-1kt0l3dxs4z2z8md
Merge Dave.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <drizzled/identifier.h>
26
26
#include <drizzled/definitions.h>
27
27
#include <drizzled/key_map.h>
28
 
#include <drizzled/error_t.h>
29
28
 
30
29
/* Definitions for parameters to do with Cursor-routines */
31
30
 
32
31
#include <drizzled/thr_lock.h>
 
32
#include <drizzled/sql_string.h>
33
33
#include <drizzled/sql_list.h>
 
34
#include <drizzled/plugin/storage_engine.h>
34
35
#include <drizzled/handler_structs.h>
35
36
#include <drizzled/ha_statistics.h>
36
37
#include <drizzled/atomics.h>
37
38
 
38
 
#include <drizzled/message/table.h>
 
39
#include <drizzled/message/table.pb.h>
39
40
 
40
41
#include <bitset>
41
42
#include <algorithm>
42
43
 
43
 
#include "drizzled/visibility.h"
44
 
 
45
44
namespace drizzled
46
45
{
47
46
 
49
48
 
50
49
typedef std::bitset<HA_MAX_ALTER_FLAGS> HA_ALTER_FLAGS;
51
50
 
52
 
class AlterInfo;
53
 
class CreateField;
 
51
extern uint64_t refresh_version;  /* Increments on each reload */
 
52
 
 
53
class Table;
 
54
class TableList;
 
55
class TableShare;
 
56
class Select_Lex_Unit;
54
57
class ForeignKeyInfo;
 
58
struct Order;
 
59
 
55
60
class Item;
56
 
class Item_ident;
 
61
 
57
62
class LEX;
58
63
class Select_Lex;
59
 
class Select_Lex_Unit;
60
 
class String;
61
 
class Table;
62
 
class TableList;
63
 
class TableShare;
 
64
class AlterInfo;
64
65
class select_result;
 
66
class CreateField;
65
67
class sys_var_str;
66
 
struct Order;
 
68
class Item_ident;
67
69
 
68
70
typedef List<Item> List_item;
69
71
extern KEY_CREATE_INFO default_key_create_info;
73
75
 
74
76
typedef struct system_status_var system_status_var;
75
77
 
76
 
namespace optimizer { class CostVector; }
77
 
namespace plugin { class StorageEngine; }
 
78
namespace optimizer
 
79
{
 
80
  class CostVector;
 
81
}
78
82
 
79
83
/*
80
84
  bitmap with first N+1 bits set
139
143
  If a blob column has NULL value, then its length and blob data pointer
140
144
  must be set to 0.
141
145
*/
142
 
class DRIZZLED_API Cursor
 
146
class Cursor
143
147
{
144
 
  friend class SEAPITesterCursor;
145
148
  Table &table;               /* The current open table */
146
149
  plugin::StorageEngine &engine;      /* storage engine of this Cursor */
147
150
 
209
212
  }
210
213
 
211
214
  /**
212
 
    Used by SHOW TABLE STATUS to get the current auto_inc from the engine
213
 
  */
214
 
  uint64_t getAutoIncrement()
215
 
  {
216
 
    return stats.auto_increment_value;
217
 
  }
218
 
 
219
 
  /**
220
215
    insert id for the current row (*autogenerated*; if not
221
216
    autogenerated, it's 0).
222
217
    At first successful insertion, this variable is stored into
235
230
 
236
231
  /* ha_ methods: pubilc wrappers for private virtual API */
237
232
 
238
 
  int ha_open(const identifier::Table &identifier, int mode, int test_if_locked);
239
 
  int startIndexScan(uint32_t idx, bool sorted) __attribute__ ((warn_unused_result));
 
233
  int ha_open(const TableIdentifier &identifier, int mode, int test_if_locked);
 
234
  int startIndexScan(uint32_t idx, bool sorted);
240
235
  int endIndexScan();
241
 
  int startTableScan(bool scan) __attribute__ ((warn_unused_result));
 
236
  int startTableScan(bool scan);
242
237
  int endTableScan();
243
238
  int ha_reset();
244
239
 
252
247
    and doDeleteRecord() below.
253
248
  */
254
249
  int ha_external_lock(Session *session, int lock_type);
255
 
  int insertRecord(unsigned char * buf) __attribute__ ((warn_unused_result));
256
 
  int updateRecord(const unsigned char * old_data, unsigned char * new_data) __attribute__ ((warn_unused_result));
257
 
  int deleteRecord(const unsigned char * buf) __attribute__ ((warn_unused_result));
 
250
  int insertRecord(unsigned char * buf);
 
251
  int updateRecord(const unsigned char * old_data, unsigned char * new_data);
 
252
  int deleteRecord(const unsigned char * buf);
258
253
  void ha_release_auto_increment();
259
254
 
260
255
  /** to be actually called to get 'check()' functionality*/
354
349
                                 const unsigned char * key,
355
350
                                 key_part_map keypart_map,
356
351
                                 enum ha_rkey_function find_flag);
357
 
  virtual int index_next(unsigned char *) __attribute__ ((warn_unused_result))
 
352
  virtual int index_next(unsigned char *)
358
353
   { return  HA_ERR_WRONG_COMMAND; }
359
354
  virtual int index_prev(unsigned char *)
360
355
   { return  HA_ERR_WRONG_COMMAND; }
528
523
  */
529
524
 
530
525
  virtual int open(const char *, int , uint32_t ) { assert(0); return -1; }
531
 
  virtual int doOpen(const identifier::Table &identifier, int mode, uint32_t test_if_locked);
 
526
  virtual int doOpen(const TableIdentifier &identifier, int mode, uint32_t test_if_locked);
532
527
  virtual int doStartIndexScan(uint32_t idx, bool)
533
528
  { active_index= idx; return 0; }
534
529
  virtual int doEndIndexScan() { active_index= MAX_KEY; return 0; }
539
534
    if rnd_init allocates the cursor, second call should position it
540
535
    to the start of the table, no need to deallocate and allocate it again
541
536
  */
542
 
  virtual int doStartTableScan(bool scan) __attribute__ ((warn_unused_result)) = 0;
 
537
  virtual int doStartTableScan(bool scan)= 0;
543
538
  virtual int doEndTableScan() { return 0; }
544
539
  virtual int doInsertRecord(unsigned char *)
545
540
  {
659
654
                   uint64_t setup_tables_done_option);
660
655
void free_underlaid_joins(Session *session, Select_Lex *select);
661
656
 
662
 
bool handle_derived(LEX *lex, bool (*processor)(Session *session,
 
657
bool mysql_handle_derived(LEX *lex, bool (*processor)(Session *session,
663
658
                                                      LEX *lex,
664
659
                                                      TableList *table));
665
 
bool derived_prepare(Session *session, LEX *lex, TableList *t);
666
 
bool derived_filling(Session *session, LEX *lex, TableList *t);
 
660
bool mysql_derived_prepare(Session *session, LEX *lex, TableList *t);
 
661
bool mysql_derived_filling(Session *session, LEX *lex, TableList *t);
667
662
int prepare_create_field(CreateField *sql_field,
668
663
                         uint32_t *blob_columns,
669
664
                         int *timestamps, int *timestamps_with_niladic);
670
665
 
671
 
bool create_table(Session *session,
672
 
                  const identifier::Table &identifier,
673
 
                  HA_CREATE_INFO *create_info,
674
 
                  message::Table &table_proto,
675
 
                  AlterInfo *alter_info,
676
 
                  bool tmp_table, uint32_t select_field_count,
677
 
                  bool is_if_not_exists);
678
 
 
679
 
bool create_table_no_lock(Session *session,
680
 
                          const identifier::Table &identifier,
681
 
                          HA_CREATE_INFO *create_info,
682
 
                          message::Table &table_proto,
683
 
                          AlterInfo *alter_info,
684
 
                          bool tmp_table, uint32_t select_field_count,
685
 
                          bool is_if_not_exists);
686
 
 
687
 
bool create_like_table(Session* session,
688
 
                       identifier::Table::const_reference destination_identifier,
689
 
                       identifier::Table::const_reference source_identifier,
690
 
                       message::Table &create_table_proto,
691
 
                       bool is_if_not_exists,
692
 
                       bool is_engine_set);
693
 
 
694
 
bool rename_table(Session &session,
 
666
bool mysql_create_table(Session *session,
 
667
                        const TableIdentifier &identifier,
 
668
                        HA_CREATE_INFO *create_info,
 
669
                        message::Table &table_proto,
 
670
                        AlterInfo *alter_info,
 
671
                        bool tmp_table, uint32_t select_field_count,
 
672
                        bool is_if_not_exists);
 
673
 
 
674
bool mysql_create_table_no_lock(Session *session,
 
675
                                const TableIdentifier &identifier,
 
676
                                HA_CREATE_INFO *create_info,
 
677
                                message::Table &table_proto,
 
678
                                AlterInfo *alter_info,
 
679
                                bool tmp_table, uint32_t select_field_count,
 
680
                                bool is_if_not_exists);
 
681
 
 
682
bool mysql_create_like_table(Session* session,
 
683
                             const TableIdentifier &destination_identifier,
 
684
                             TableList* table, TableList* src_table,
 
685
                             message::Table &create_table_proto,
 
686
                             bool is_if_not_exists,
 
687
                             bool is_engine_set);
 
688
 
 
689
bool mysql_rename_table(Session &session,
695
690
                        plugin::StorageEngine *base,
696
 
                        const identifier::Table &old_identifier,
697
 
                        const identifier::Table &new_identifier);
 
691
                        const TableIdentifier &old_identifier,
 
692
                        const TableIdentifier &new_identifier);
698
693
 
699
 
bool prepare_update(Session *session, TableList *table_list,
 
694
bool mysql_prepare_update(Session *session, TableList *table_list,
700
695
                          Item **conds, uint32_t order_num, Order *order);
701
 
int update_query(Session *session,TableList *tables,List<Item> &fields,
 
696
int mysql_update(Session *session,TableList *tables,List<Item> &fields,
702
697
                 List<Item> &values,COND *conds,
703
698
                 uint32_t order_num, Order *order, ha_rows limit,
704
699
                 enum enum_duplicates handle_duplicates, bool ignore);
705
 
bool prepare_insert(Session *session, TableList *table_list, Table *table,
 
700
bool mysql_prepare_insert(Session *session, TableList *table_list, Table *table,
706
701
                          List<Item> &fields, List_item *values,
707
702
                          List<Item> &update_fields,
708
703
                          List<Item> &update_values, enum_duplicates duplic,
709
704
                          COND **where, bool select_insert,
710
705
                          bool check_fields, bool abort_on_warning);
711
 
bool insert_query(Session *session,TableList *table,List<Item> &fields,
 
706
bool mysql_insert(Session *session,TableList *table,List<Item> &fields,
712
707
                  List<List_item> &values, List<Item> &update_fields,
713
708
                  List<Item> &update_values, enum_duplicates flag,
714
709
                  bool ignore);
715
710
int check_that_all_fields_are_given_values(Session *session, Table *entry,
716
711
                                           TableList *table_list);
717
 
int prepare_delete(Session *session, TableList *table_list, Item **conds);
718
 
bool delete_query(Session *session, TableList *table_list, COND *conds,
 
712
int mysql_prepare_delete(Session *session, TableList *table_list, Item **conds);
 
713
bool mysql_delete(Session *session, TableList *table_list, COND *conds,
719
714
                  SQL_LIST *order, ha_rows rows, uint64_t options,
720
715
                  bool reset_auto_increment);
721
 
bool truncate(Session& session, TableList *table_list);
 
716
bool mysql_truncate(Session& session, TableList *table_list);
722
717
TableShare *get_table_share(Session *session, TableList *table_list, char *key,
723
718
                             uint32_t key_length, uint32_t db_flags, int *error);
724
719
TableShare *get_cached_table_share(const char *db, const char *table_name);
727
722
void close_handle_and_leave_table_as_lock(Table *table);
728
723
bool wait_for_tables(Session *session);
729
724
bool table_is_used(Table *table, bool wait_for_name_lock);
730
 
Table *drop_locked_tables(Session *session, const drizzled::identifier::Table &identifier);
731
 
void abort_locked_tables(Session *session, const drizzled::identifier::Table &identifier);
 
725
Table *drop_locked_tables(Session *session, const drizzled::TableIdentifier &identifier);
 
726
void abort_locked_tables(Session *session, const drizzled::TableIdentifier &identifier);
732
727
extern Field *not_found_field;
733
728
extern Field *view_ref_found;
734
729