~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cursor.h

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
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>
28
29
 
29
30
/* Definitions for parameters to do with Cursor-routines */
30
31
 
31
32
#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>
35
34
#include <drizzled/handler_structs.h>
36
35
#include <drizzled/ha_statistics.h>
37
36
#include <drizzled/atomics.h>
38
37
 
39
 
#include <drizzled/message/table.pb.h>
 
38
#include <drizzled/message/table.h>
40
39
 
41
40
#include <bitset>
42
41
#include <algorithm>
43
42
 
 
43
#include "drizzled/visibility.h"
 
44
 
44
45
namespace drizzled
45
46
{
46
47
 
48
49
 
49
50
typedef std::bitset<HA_MAX_ALTER_FLAGS> HA_ALTER_FLAGS;
50
51
 
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;
 
52
class AlterInfo;
 
53
class CreateField;
57
54
class ForeignKeyInfo;
58
 
struct Order;
59
 
 
60
55
class Item;
61
 
 
 
56
class Item_ident;
62
57
class LEX;
63
58
class Select_Lex;
64
 
class AlterInfo;
 
59
class Select_Lex_Unit;
 
60
class String;
 
61
class Table;
 
62
class TableList;
 
63
class TableShare;
65
64
class select_result;
66
 
class CreateField;
67
65
class sys_var_str;
68
 
class Item_ident;
 
66
struct Order;
69
67
 
70
68
typedef List<Item> List_item;
71
69
extern KEY_CREATE_INFO default_key_create_info;
75
73
 
76
74
typedef struct system_status_var system_status_var;
77
75
 
78
 
namespace optimizer
79
 
{
80
 
  class CostVector;
81
 
}
 
76
namespace optimizer { class CostVector; }
 
77
namespace plugin { class StorageEngine; }
82
78
 
83
79
/*
84
80
  bitmap with first N+1 bits set
143
139
  If a blob column has NULL value, then its length and blob data pointer
144
140
  must be set to 0.
145
141
*/
146
 
class Cursor
 
142
class DRIZZLED_API Cursor
147
143
{
 
144
  friend class SEAPITesterCursor;
148
145
  Table &table;               /* The current open table */
149
146
  plugin::StorageEngine &engine;      /* storage engine of this Cursor */
150
147
 
212
209
  }
213
210
 
214
211
  /**
 
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
  /**
215
220
    insert id for the current row (*autogenerated*; if not
216
221
    autogenerated, it's 0).
217
222
    At first successful insertion, this variable is stored into
230
235
 
231
236
  /* ha_ methods: pubilc wrappers for private virtual API */
232
237
 
233
 
  int ha_open(const TableIdentifier &identifier, int mode, int test_if_locked);
234
 
  int startIndexScan(uint32_t idx, bool sorted);
 
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));
235
240
  int endIndexScan();
236
 
  int startTableScan(bool scan);
 
241
  int startTableScan(bool scan) __attribute__ ((warn_unused_result));
237
242
  int endTableScan();
238
243
  int ha_reset();
239
244
 
247
252
    and doDeleteRecord() below.
248
253
  */
249
254
  int ha_external_lock(Session *session, int lock_type);
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);
 
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));
253
258
  void ha_release_auto_increment();
254
259
 
255
260
  /** to be actually called to get 'check()' functionality*/
349
354
                                 const unsigned char * key,
350
355
                                 key_part_map keypart_map,
351
356
                                 enum ha_rkey_function find_flag);
352
 
  virtual int index_next(unsigned char *)
 
357
  virtual int index_next(unsigned char *) __attribute__ ((warn_unused_result))
353
358
   { return  HA_ERR_WRONG_COMMAND; }
354
359
  virtual int index_prev(unsigned char *)
355
360
   { return  HA_ERR_WRONG_COMMAND; }
523
528
  */
524
529
 
525
530
  virtual int open(const char *, int , uint32_t ) { assert(0); return -1; }
526
 
  virtual int doOpen(const TableIdentifier &identifier, int mode, uint32_t test_if_locked);
 
531
  virtual int doOpen(const identifier::Table &identifier, int mode, uint32_t test_if_locked);
527
532
  virtual int doStartIndexScan(uint32_t idx, bool)
528
533
  { active_index= idx; return 0; }
529
534
  virtual int doEndIndexScan() { active_index= MAX_KEY; return 0; }
534
539
    if rnd_init allocates the cursor, second call should position it
535
540
    to the start of the table, no need to deallocate and allocate it again
536
541
  */
537
 
  virtual int doStartTableScan(bool scan)= 0;
 
542
  virtual int doStartTableScan(bool scan) __attribute__ ((warn_unused_result)) = 0;
538
543
  virtual int doEndTableScan() { return 0; }
539
544
  virtual int doInsertRecord(unsigned char *)
540
545
  {
654
659
                   uint64_t setup_tables_done_option);
655
660
void free_underlaid_joins(Session *session, Select_Lex *select);
656
661
 
657
 
bool mysql_handle_derived(LEX *lex, bool (*processor)(Session *session,
 
662
bool handle_derived(LEX *lex, bool (*processor)(Session *session,
658
663
                                                      LEX *lex,
659
664
                                                      TableList *table));
660
 
bool mysql_derived_prepare(Session *session, LEX *lex, TableList *t);
661
 
bool mysql_derived_filling(Session *session, LEX *lex, TableList *t);
 
665
bool derived_prepare(Session *session, LEX *lex, TableList *t);
 
666
bool derived_filling(Session *session, LEX *lex, TableList *t);
662
667
int prepare_create_field(CreateField *sql_field,
663
668
                         uint32_t *blob_columns,
664
669
                         int *timestamps, int *timestamps_with_niladic);
665
670
 
666
 
bool mysql_create_table(Session *session,
667
 
                        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
 
                                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
 
                             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,
 
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,
690
695
                        plugin::StorageEngine *base,
691
 
                        TableIdentifier &old_identifier,
692
 
                        TableIdentifier &new_identifier);
 
696
                        const identifier::Table &old_identifier,
 
697
                        const identifier::Table &new_identifier);
693
698
 
694
 
bool mysql_prepare_update(Session *session, TableList *table_list,
 
699
bool prepare_update(Session *session, TableList *table_list,
695
700
                          Item **conds, uint32_t order_num, Order *order);
696
 
int mysql_update(Session *session,TableList *tables,List<Item> &fields,
 
701
int update_query(Session *session,TableList *tables,List<Item> &fields,
697
702
                 List<Item> &values,COND *conds,
698
703
                 uint32_t order_num, Order *order, ha_rows limit,
699
704
                 enum enum_duplicates handle_duplicates, bool ignore);
700
 
bool mysql_prepare_insert(Session *session, TableList *table_list, Table *table,
 
705
bool prepare_insert(Session *session, TableList *table_list, Table *table,
701
706
                          List<Item> &fields, List_item *values,
702
707
                          List<Item> &update_fields,
703
708
                          List<Item> &update_values, enum_duplicates duplic,
704
709
                          COND **where, bool select_insert,
705
710
                          bool check_fields, bool abort_on_warning);
706
 
bool mysql_insert(Session *session,TableList *table,List<Item> &fields,
 
711
bool insert_query(Session *session,TableList *table,List<Item> &fields,
707
712
                  List<List_item> &values, List<Item> &update_fields,
708
713
                  List<Item> &update_values, enum_duplicates flag,
709
714
                  bool ignore);
710
715
int check_that_all_fields_are_given_values(Session *session, Table *entry,
711
716
                                           TableList *table_list);
712
 
int mysql_prepare_delete(Session *session, TableList *table_list, Item **conds);
713
 
bool mysql_delete(Session *session, TableList *table_list, COND *conds,
 
717
int prepare_delete(Session *session, TableList *table_list, Item **conds);
 
718
bool delete_query(Session *session, TableList *table_list, COND *conds,
714
719
                  SQL_LIST *order, ha_rows rows, uint64_t options,
715
720
                  bool reset_auto_increment);
716
 
bool mysql_truncate(Session& session, TableList *table_list);
 
721
bool truncate(Session& session, TableList *table_list);
717
722
TableShare *get_table_share(Session *session, TableList *table_list, char *key,
718
723
                             uint32_t key_length, uint32_t db_flags, int *error);
719
724
TableShare *get_cached_table_share(const char *db, const char *table_name);
722
727
void close_handle_and_leave_table_as_lock(Table *table);
723
728
bool wait_for_tables(Session *session);
724
729
bool table_is_used(Table *table, bool wait_for_name_lock);
725
 
Table *drop_locked_tables(Session *session, const drizzled::TableIdentifier &identifier);
726
 
void abort_locked_tables(Session *session, const drizzled::TableIdentifier &identifier);
 
730
Table *drop_locked_tables(Session *session, const drizzled::identifier::Table &identifier);
 
731
void abort_locked_tables(Session *session, const drizzled::identifier::Table &identifier);
727
732
extern Field *not_found_field;
728
733
extern Field *view_ref_found;
729
734