~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/handler.h

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-13 00:53:34 UTC
  • mto: (1126.9.2 captain-20090915-01)
  • mto: This revision was merged to the branch mainline in revision 1133.
  • Revision ID: osullivan.padraig@gmail.com-20090913005334-6wio2sbjugskfbm3
Added calls to the connection start/end dtrace probes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef DRIZZLED_CURSOR_H
21
 
#define DRIZZLED_CURSOR_H
 
20
#ifndef DRIZZLED_HANDLER_H
 
21
#define DRIZZLED_HANDLER_H
22
22
 
23
23
#include <drizzled/xid.h>
24
24
#include <drizzled/discrete_interval.h>
25
 
#include <drizzled/table_identifier.h>
26
 
 
27
 
/* Definitions for parameters to do with Cursor-routines */
28
 
 
29
 
#include <drizzled/thr_lock.h>
 
25
 
 
26
/* Definitions for parameters to do with handler-routines */
 
27
 
 
28
#include <mysys/thr_lock.h>
 
29
#include <mysys/hash.h>
30
30
#include <drizzled/sql_string.h>
31
31
#include <drizzled/sql_list.h>
32
32
#include <drizzled/plugin/storage_engine.h>
39
39
/* Bits to show what an alter table will do */
40
40
#include <drizzled/sql_bitmap.h>
41
41
 
 
42
#include <drizzled/handler.h>
 
43
 
42
44
#include <bitset>
43
45
#include <algorithm>
44
46
 
45
 
namespace drizzled
46
 
{
47
 
 
48
47
#define HA_MAX_ALTER_FLAGS 40
49
 
 
50
 
 
51
48
typedef std::bitset<HA_MAX_ALTER_FLAGS> HA_ALTER_FLAGS;
52
49
 
53
 
extern uint64_t refresh_version;  /* Increments on each reload */
 
50
extern drizzled::atomic<uint32_t> refresh_version;  /* Increments on each reload */
54
51
 
55
52
 
56
53
typedef bool (*qc_engine_callback)(Session *session, char *table_key,
58
55
                                      uint64_t *engine_data);
59
56
 
60
57
 
61
 
/* The Cursor for a table type.  Will be included in the Table structure */
 
58
/* The handler for a table type.  Will be included in the Table structure */
62
59
 
63
60
class Table;
64
61
class TableList;
73
70
 
74
71
class LEX;
75
72
class Select_Lex;
76
 
class AlterInfo;
 
73
class Alter_info;
77
74
class select_result;
78
75
class CreateField;
79
76
class sys_var_str;
81
78
typedef struct st_sort_field SORT_FIELD;
82
79
 
83
80
typedef List<Item> List_item;
 
81
 
 
82
typedef struct st_savepoint SAVEPOINT;
 
83
extern uint32_t savepoint_alloc_size;
84
84
extern KEY_CREATE_INFO default_key_create_info;
85
85
 
86
86
/* Forward declaration for condition pushdown to storage engine */
87
87
typedef class Item COND;
88
88
 
89
 
typedef struct system_status_var system_status_var;
 
89
typedef struct system_status_var SSV;
90
90
 
91
 
namespace optimizer
92
 
{
93
 
  class CostVector;
94
 
}
 
91
class COST_VECT;
95
92
 
96
93
uint32_t calculate_key_len(Table *, uint, const unsigned char *, key_part_map);
97
94
/*
115
112
}
116
113
 
117
114
/**
118
 
  The Cursor class is the interface for dynamically loadable
 
115
  The handler class is the interface for dynamically loadable
119
116
  storage engines. Do not add ifdefs and take care when adding or
120
117
  changing virtual functions to avoid vtable confusion
121
118
 
125
122
     storage engine
126
123
 
127
124
  2. KeyTupleFormat - used to pass index search tuples (aka "keys") to
128
 
     storage engine. See optimizer/range.cc for description of this format.
 
125
     storage engine. See opt_range.cc for description of this format.
129
126
 
130
127
  TableRecordFormat
131
128
  =================
162
159
  must be set to 0.
163
160
*/
164
161
 
165
 
class Cursor :public memory::SqlAlloc
 
162
class handler :public Sql_alloc
166
163
{
 
164
public:
 
165
  typedef uint64_t Table_flags;
 
166
 
167
167
protected:
168
168
  TableShare *table_share;   /* The table definition */
169
169
  Table *table;               /* The current open table */
 
170
  Table_flags cached_table_flags;       /* Set on init() and open() */
170
171
 
171
172
  ha_rows estimation_rows_to_insert;
172
173
public:
173
 
  plugin::StorageEngine *engine;      /* storage engine of this Cursor */
174
 
  inline plugin::StorageEngine *getEngine() const       /* table_type for handler */
175
 
  {
176
 
    return engine;
177
 
  }
178
 
  unsigned char *ref;                           /* Pointer to current row */
 
174
  StorageEngine *engine;      /* storage engine of this handler */
 
175
  unsigned char *ref;                           /* Pointer to current row */
179
176
  unsigned char *dup_ref;                       /* Pointer to duplicate row */
180
177
 
181
178
  ha_statistics stats;
224
221
    get_auto_increment().
225
222
  */
226
223
  uint64_t next_insert_id;
227
 
  uint64_t getNextInsertId()
228
 
  {
229
 
    return next_insert_id;
230
 
  }
231
 
 
232
224
  /**
233
225
    insert id for the current row (*autogenerated*; if not
234
226
    autogenerated, it's 0).
242
234
  */
243
235
  Discrete_interval auto_inc_interval_for_cur_row;
244
236
 
245
 
  Cursor(plugin::StorageEngine &engine_arg, TableShare &share_arg);
246
 
  virtual ~Cursor(void);
247
 
  virtual Cursor *clone(memory::Root *mem_root);
 
237
  handler(StorageEngine *engine_arg, TableShare *share_arg)
 
238
    :table_share(share_arg), table(0),
 
239
    estimation_rows_to_insert(0), engine(engine_arg),
 
240
    ref(0), in_range_check_pushed_down(false),
 
241
    key_used_on_scan(MAX_KEY), active_index(MAX_KEY),
 
242
    ref_length(sizeof(my_off_t)),
 
243
    inited(NONE),
 
244
    locked(false), implicit_emptied(0),
 
245
    next_insert_id(0), insert_id_for_cur_row(0)
 
246
    {}
 
247
  virtual ~handler(void);
 
248
  virtual handler *clone(MEM_ROOT *mem_root);
 
249
  /** This is called after create to allow us to set up cached variables */
 
250
  void init()
 
251
  {
 
252
    cached_table_flags= table_flags();
 
253
  }
248
254
 
249
255
  /* ha_ methods: pubilc wrappers for private virtual API */
250
256
 
257
263
 
258
264
  /* this is necessary in many places, e.g. in HANDLER command */
259
265
  int ha_index_or_rnd_end();
 
266
  Table_flags ha_table_flags() const;
260
267
 
261
268
  /**
262
269
    These functions represent the public interface to *users* of the
263
 
    Cursor class, hence they are *not* virtual. For the inheritance
 
270
    handler class, hence they are *not* virtual. For the inheritance
264
271
    interface, see the (private) functions write_row(), update_row(),
265
272
    and delete_row() below.
266
273
  */
275
282
 
276
283
  void ha_start_bulk_insert(ha_rows rows);
277
284
  int ha_end_bulk_insert();
 
285
  int ha_bulk_update_row(const unsigned char *old_data, unsigned char *new_data,
 
286
                         uint32_t *dup_key_found);
278
287
  int ha_delete_all_rows();
279
288
  int ha_reset_auto_increment(uint64_t value);
 
289
  int ha_optimize(Session* session, HA_CHECK_OPT* check_opt);
280
290
  int ha_analyze(Session* session, HA_CHECK_OPT* check_opt);
281
291
 
282
292
  int ha_disable_indexes(uint32_t mode);
283
293
  int ha_enable_indexes(uint32_t mode);
284
294
  int ha_discard_or_import_tablespace(bool discard);
285
 
  void closeMarkForDelete(const char *name);
 
295
  void ha_drop_table(const char *name);
286
296
 
287
297
  void adjust_next_insert_id_after_explicit_value(uint64_t nr);
288
298
  int update_auto_increment();
 
299
  void print_keydup_error(uint32_t key_nr, const char *msg);
 
300
  virtual void print_error(int error, myf errflag);
 
301
  virtual bool get_error_message(int error, String *buf);
 
302
  uint32_t get_dup_key(int error);
289
303
  virtual void change_table_ptr(Table *table_arg, TableShare *share);
290
304
 
291
305
  /* Estimates calculation */
299
313
  virtual ha_rows multi_range_read_info_const(uint32_t keyno, RANGE_SEQ_IF *seq,
300
314
                                              void *seq_init_param,
301
315
                                              uint32_t n_ranges, uint32_t *bufsz,
302
 
                                              uint32_t *flags, optimizer::CostVector *cost);
 
316
                                              uint32_t *flags, COST_VECT *cost);
303
317
  virtual int multi_range_read_info(uint32_t keyno, uint32_t n_ranges, uint32_t keys,
304
 
                                    uint32_t *bufsz, uint32_t *flags, optimizer::CostVector *cost);
 
318
                                    uint32_t *bufsz, uint32_t *flags, COST_VECT *cost);
305
319
  virtual int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
306
320
                                    uint32_t n_ranges, uint32_t mode,
307
321
                                    HANDLER_BUFFER *buf);
314
328
  /**
315
329
    This method is used to analyse the error to see whether the error
316
330
    is ignorable or not, certain handlers can have more error that are
317
 
    ignorable than others. E.g. the partition Cursor can get inserts
 
331
    ignorable than others. E.g. the partition handler can get inserts
318
332
    into a range where there is no partition and this is an ignorable
319
333
    error.
320
334
    HA_ERR_FOUND_DUP_UNIQUE is a special case in MyISAM that means the
328
342
    (table_flags() & (HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT)) != 0
329
343
  */
330
344
  virtual ha_rows records();
331
 
  virtual uint64_t tableSize();
332
 
  virtual uint64_t rowSize();
333
345
  /**
334
346
    Return upper bound of current number of records in the table
335
347
    (max. of how many records one will retrieve when doing a full table scan)
353
365
  virtual int close(void)=0;
354
366
 
355
367
  /**
 
368
    @retval  0   Bulk update used by handler
 
369
    @retval  1   Bulk update not used, normal operation used
 
370
  */
 
371
  virtual bool start_bulk_update() { return 1; }
 
372
  /**
 
373
    @retval  0   Bulk delete used by handler
 
374
    @retval  1   Bulk delete not used, normal operation used
 
375
  */
 
376
  virtual bool start_bulk_delete() { return 1; }
 
377
  /**
 
378
    After this call all outstanding updates must be performed. The number
 
379
    of duplicate key errors are reported in the duplicate key parameter.
 
380
    It is allowed to continue to the batched update after this call, the
 
381
    handler has to wait until end_bulk_update with changing state.
 
382
 
 
383
    @param    dup_key_found       Number of duplicate keys found
 
384
 
 
385
    @retval  0           Success
 
386
    @retval  >0          Error code
 
387
  */
 
388
  virtual int exec_bulk_update(uint32_t *)
 
389
  {
 
390
    assert(false);
 
391
    return HA_ERR_WRONG_COMMAND;
 
392
  }
 
393
  /**
 
394
    Perform any needed clean-up, no outstanding updates are there at the
 
395
    moment.
 
396
  */
 
397
  virtual void end_bulk_update() { return; }
 
398
  /**
 
399
    Execute all outstanding deletes and close down the bulk delete.
 
400
 
 
401
    @retval 0             Success
 
402
    @retval >0            Error code
 
403
  */
 
404
  virtual int end_bulk_delete()
 
405
  {
 
406
    assert(false);
 
407
    return HA_ERR_WRONG_COMMAND;
 
408
  }
 
409
  /**
356
410
     @brief
357
411
     Positions an index cursor to the index specified in the handle. Fetches the
358
412
     row if available. If the key value is null, begin at the first key of the
451
505
  */
452
506
  virtual void try_semi_consistent_read(bool) {}
453
507
  virtual void unlock_row(void) {}
 
508
  virtual int start_stmt(Session *, thr_lock_type)
 
509
  {return 0;}
454
510
  virtual void get_auto_increment(uint64_t offset, uint64_t increment,
455
511
                                  uint64_t nb_desired_values,
456
512
                                  uint64_t *first_value,
457
 
                                  uint64_t *nb_reserved_values)= 0;
458
 
 
 
513
                                  uint64_t *nb_reserved_values);
459
514
  void set_next_insert_id(uint64_t id)
460
515
  {
461
516
    next_insert_id= id;
504
559
  { return 0; }
505
560
  virtual uint32_t referenced_by_foreign_key() { return 0;}
506
561
  virtual void free_foreign_key_create_info(char *) {}
507
 
  /** The following can be called without an open Cursor */
 
562
  /** The following can be called without an open handler */
 
563
 
 
564
  virtual uint32_t index_flags(uint32_t idx, uint32_t part, bool all_parts) const =0;
508
565
 
509
566
  virtual int add_index(Table *, KEY *, uint32_t)
510
567
  { return (HA_ERR_WRONG_COMMAND); }
513
570
  virtual int final_drop_index(Table *)
514
571
  { return (HA_ERR_WRONG_COMMAND); }
515
572
 
 
573
  uint32_t max_record_length() const
 
574
  { return std::min((unsigned int)HA_MAX_REC_LENGTH, max_supported_record_length()); }
 
575
  uint32_t max_keys() const
 
576
  { return std::min((unsigned int)MAX_KEY, max_supported_keys()); }
 
577
  uint32_t max_key_parts() const
 
578
  { return std::min((unsigned int)MAX_REF_PARTS, max_supported_key_parts()); }
 
579
  uint32_t max_key_length() const
 
580
  { return std::min((unsigned int)MAX_KEY_LENGTH, max_supported_key_length()); }
 
581
  uint32_t max_key_part_length(void) const
 
582
  { return std::min((unsigned int)MAX_KEY_LENGTH, max_supported_key_part_length()); }
 
583
 
 
584
  virtual uint32_t max_supported_record_length(void) const
 
585
  { return HA_MAX_REC_LENGTH; }
 
586
  virtual uint32_t max_supported_keys(void) const { return 0; }
 
587
  virtual uint32_t max_supported_key_parts(void) const { return MAX_REF_PARTS; }
 
588
  virtual uint32_t max_supported_key_length(void) const { return MAX_KEY_LENGTH; }
 
589
  virtual uint32_t max_supported_key_part_length(void) const { return 255; }
 
590
 
 
591
  virtual bool low_byte_first(void) const { return 1; }
516
592
  virtual uint32_t checksum(void) const { return 0; }
 
593
  virtual bool is_crashed(void) const  { return 0; }
 
594
  virtual bool auto_repair(void) const { return 0; }
517
595
 
518
596
  /**
519
597
    Is not invoked for non-transactional temporary tables.
528
606
    than lock_count() claimed. This can happen when the MERGE children
529
607
    are not attached when this is called from another thread.
530
608
  */
531
 
  virtual THR_LOCK_DATA **store_lock(Session *,
 
609
  virtual THR_LOCK_DATA **store_lock(Session *session,
532
610
                                     THR_LOCK_DATA **to,
533
 
                                     enum thr_lock_type)
534
 
  {
535
 
    assert(0); // Impossible programming situation
536
 
 
537
 
    return(to);
538
 
  }
 
611
                                     enum thr_lock_type lock_type)=0;
539
612
 
540
613
 /*
541
614
   @retval true   Primary key (if there is one) is clustered
548
621
   return memcmp(ref1, ref2, ref_length);
549
622
 }
550
623
 
551
 
  virtual bool isOrdered(void)
 
624
  /**
 
625
    Lock table.
 
626
 
 
627
    @param    session                     Thread handle
 
628
    @param    lock_type               HA_LOCK_IN_SHARE_MODE     (F_RDLCK)
 
629
                                      HA_LOCK_IN_EXCLUSIVE_MODE (F_WRLCK)
 
630
    @param    lock_timeout            -1 default timeout
 
631
                                      0  no wait
 
632
                                      >0 wait timeout in milliseconds.
 
633
 
 
634
   @note
 
635
      lock_timeout >0 is not used by MySQL currently. If the storage
 
636
      engine does not support NOWAIT (lock_timeout == 0) it should
 
637
      return an error. But if it does not support WAIT X (lock_timeout
 
638
      >0) it should treat it as lock_timeout == -1 and wait a default
 
639
      (or even hard-coded) timeout.
 
640
 
 
641
    @retval HA_ERR_WRONG_COMMAND      Storage engine does not support
 
642
                                      lock_table()
 
643
    @retval HA_ERR_UNSUPPORTED        Storage engine does not support NOWAIT
 
644
    @retval HA_ERR_LOCK_WAIT_TIMEOUT  Lock request timed out or
 
645
                                      lock conflict with NOWAIT option
 
646
    @retval HA_ERR_LOCK_DEADLOCK      Deadlock detected
 
647
  */
 
648
  virtual int lock_table(Session *, int, int)
552
649
  {
553
 
    return false;
 
650
    return HA_ERR_WRONG_COMMAND;
554
651
  }
555
652
 
556
 
 
557
653
protected:
558
654
  /* Service methods for use by storage engines. */
559
 
  void ha_statistic_increment(ulong system_status_var::*offset) const;
 
655
  void ha_statistic_increment(ulong SSV::*offset) const;
560
656
  void **ha_data(Session *) const;
561
657
  Session *ha_session(void) const;
562
658
 
563
659
private:
564
660
  /* Private helpers */
565
 
  inline void setTransactionReadWrite();
 
661
  inline void mark_trx_read_write();
566
662
private:
567
663
  /*
568
664
    Low-level primitives for storage engines.  These should be
603
699
    by that statement.
604
700
  */
605
701
  virtual int reset() { return 0; }
 
702
  virtual Table_flags table_flags(void) const= 0;
606
703
 
607
704
  /**
608
705
    Is not invoked for non-transactional temporary tables.
609
706
 
610
707
    Tells the storage engine that we intend to read or write data
611
 
    from the table. This call is prefixed with a call to Cursor::store_lock()
612
 
    and is invoked only for those Cursor instances that stored the lock.
 
708
    from the table. This call is prefixed with a call to handler::store_lock()
 
709
    and is invoked only for those handler instances that stored the lock.
613
710
 
614
711
    Calls to rnd_init/index_init are prefixed with this call. When table
615
712
    IO is complete, we call external_lock(F_UNLCK).
632
729
  }
633
730
  virtual void release_auto_increment(void) { return; };
634
731
  /** admin commands - called from mysql_admin_table */
635
 
  virtual int check(Session *)
 
732
  virtual int check(Session *, HA_CHECK_OPT *)
636
733
  { return HA_ADMIN_NOT_IMPLEMENTED; }
637
734
 
638
735
  virtual void start_bulk_insert(ha_rows)
642
739
                         uint32_t, enum ha_rkey_function)
643
740
   { return  HA_ERR_WRONG_COMMAND; }
644
741
  virtual int index_read_last(unsigned char *, const unsigned char *, uint32_t)
645
 
   { return (errno= HA_ERR_WRONG_COMMAND); }
 
742
   { return (my_errno= HA_ERR_WRONG_COMMAND); }
 
743
  /**
 
744
    This method is similar to update_row, however the handler doesn't need
 
745
    to execute the updates at this point in time. The handler can be certain
 
746
    that another call to bulk_update_row will occur OR a call to
 
747
    exec_bulk_update before the set of updates in this query is concluded.
 
748
 
 
749
    @param    old_data       Old record
 
750
    @param    new_data       New record
 
751
    @param    dup_key_found  Number of duplicate keys found
 
752
 
 
753
    @retval  0   Bulk delete used by handler
 
754
    @retval  1   Bulk delete not used, normal operation used
 
755
  */
 
756
  virtual int bulk_update_row(const unsigned char *, unsigned char *, uint32_t *)
 
757
  {
 
758
    assert(false);
 
759
    return HA_ERR_WRONG_COMMAND;
 
760
  }
646
761
  /**
647
762
    This is called to delete all rows in a table
648
 
    If the Cursor don't support this, then this function will
 
763
    If the handler don't support this, then this function will
649
764
    return HA_ERR_WRONG_COMMAND and MySQL will delete the rows one
650
765
    by one.
651
766
  */
652
767
  virtual int delete_all_rows(void)
653
 
  { return (errno=HA_ERR_WRONG_COMMAND); }
 
768
  { return (my_errno=HA_ERR_WRONG_COMMAND); }
654
769
  /**
655
770
    Reset the auto-increment counter to the given value, i.e. the next row
656
771
    inserted will get the given value. This is called e.g. after TRUNCATE
659
774
  */
660
775
  virtual int reset_auto_increment(uint64_t)
661
776
  { return HA_ERR_WRONG_COMMAND; }
662
 
 
663
 
  virtual int analyze(Session *)
 
777
  virtual int optimize(Session *, HA_CHECK_OPT *)
 
778
  { return HA_ADMIN_NOT_IMPLEMENTED; }
 
779
  virtual int analyze(Session *, HA_CHECK_OPT *)
664
780
  { return HA_ADMIN_NOT_IMPLEMENTED; }
665
781
 
666
782
  virtual int disable_indexes(uint32_t)
667
783
  { return HA_ERR_WRONG_COMMAND; }
668
 
 
669
784
  virtual int enable_indexes(uint32_t)
670
785
  { return HA_ERR_WRONG_COMMAND; }
671
 
 
672
786
  virtual int discard_or_import_tablespace(bool)
673
 
  { return (errno=HA_ERR_WRONG_COMMAND); }
674
 
 
675
 
  /* 
676
 
    @todo this is just for the HEAP engine, it should
677
 
    be removed at some point in the future (and
678
 
    no new engine should ever use it). Right
679
 
    now HEAP does rely on it, so we cannot remove it.
680
 
  */
 
787
  { return (my_errno=HA_ERR_WRONG_COMMAND); }
681
788
  virtual void drop_table(const char *name);
682
789
};
683
790
 
684
791
extern const char *ha_row_type[];
 
792
extern const char *tx_isolation_names[];
 
793
extern const char *binlog_format_names[];
 
794
extern TYPELIB tx_isolation_typelib;
 
795
extern uint32_t total_ha, total_ha_2pc;
 
796
 
 
797
       /* Wrapper functions */
 
798
#define ha_commit(session) (ha_commit_trans((session), true))
 
799
#define ha_rollback(session) (ha_rollback_trans((session), true))
685
800
 
686
801
/* basic stuff */
687
 
void ha_init_errors(void);
 
802
int ha_init_errors(void);
 
803
int ha_init(void);
 
804
int ha_end(void);
 
805
 
 
806
void add_storage_engine(StorageEngine *engine);
 
807
void remove_storage_engine(StorageEngine *engine);
 
808
 
 
809
void ha_close_connection(Session* session);
 
810
bool ha_flush_logs(StorageEngine *db_type);
 
811
void ha_drop_database(char* path);
 
812
int ha_create_table(Session *session, const char *path,
 
813
                    const char *db, const char *table_name,
 
814
                    HA_CREATE_INFO *create_info,
 
815
                    bool update_create_info,
 
816
                    drizzled::message::Table *table_proto);
 
817
int ha_delete_table(Session *session, const char *path,
 
818
                    const char *db, const char *alias, bool generate_warning);
 
819
 
 
820
/* statistics and info */
 
821
bool ha_show_status(Session *session, StorageEngine *db_type, enum ha_stat_type stat);
 
822
 
 
823
int ha_find_files(Session *session,const char *db,const char *path,
 
824
                  const char *wild, bool dir, List<LEX_STRING>* files);
 
825
 
 
826
/* report to InnoDB that control passes to the client */
 
827
int ha_release_temporary_latches(Session *session);
 
828
 
 
829
/* transactions: interface to StorageEngine functions */
 
830
int ha_start_consistent_snapshot(Session *session);
 
831
int ha_commit_or_rollback_by_xid(XID *xid, bool commit);
 
832
int ha_commit_one_phase(Session *session, bool all);
 
833
int ha_rollback_trans(Session *session, bool all);
 
834
int ha_recover(HASH *commit_list);
 
835
 
 
836
/* transactions: these functions never call StorageEngine functions directly */
 
837
int ha_commit_trans(Session *session, bool all);
 
838
int ha_autocommit_or_rollback(Session *session, int error);
 
839
int ha_enable_transaction(Session *session, bool on);
 
840
 
 
841
/* savepoints */
 
842
int ha_rollback_to_savepoint(Session *session, SAVEPOINT *sv);
 
843
int ha_savepoint(Session *session, SAVEPOINT *sv);
 
844
int ha_release_savepoint(Session *session, SAVEPOINT *sv);
 
845
 
 
846
/* these are called by storage engines */
 
847
void trans_register_ha(Session *session, bool all, StorageEngine *engine);
 
848
 
 
849
uint32_t filename_to_tablename(const char *from, char *to, uint32_t to_length);
 
850
bool tablename_to_filename(const char *from, char *to, size_t to_length);
 
851
 
 
852
 
 
853
/*
 
854
  Storage engine has to assume the transaction will end up with 2pc if
 
855
   - there is more than one 2pc-capable storage engine available
 
856
   - in the current transaction 2pc was not disabled yet
 
857
*/
 
858
#define trans_need_2pc(session, all)                   ((total_ha_2pc > 1) && \
 
859
        !((all ? &session->transaction.all : &session->transaction.stmt)->no_2pc))
 
860
 
 
861
 
 
862
bool mysql_xa_recover(Session *session);
688
863
 
689
864
SORT_FIELD * make_unireg_sortorder(order_st *order, uint32_t *length,
690
865
                                   SORT_FIELD *sortorder);
698
873
 
699
874
bool handle_select(Session *session, LEX *lex, select_result *result,
700
875
                   uint64_t setup_tables_done_option);
 
876
bool mysql_select(Session *session, Item ***rref_pointer_array,
 
877
                  TableList *tables, uint32_t wild_num,  List<Item> &list,
 
878
                  COND *conds, uint32_t og_num, order_st *order, order_st *group,
 
879
                  Item *having, uint64_t select_type,
 
880
                  select_result *result, Select_Lex_Unit *unit,
 
881
                  Select_Lex *select_lex);
701
882
void free_underlaid_joins(Session *session, Select_Lex *select);
 
883
bool mysql_explain_union(Session *session, Select_Lex_Unit *unit,
 
884
                         select_result *result);
 
885
int mysql_explain_select(Session *session, Select_Lex *sl, char const *type,
 
886
                         select_result *result);
702
887
 
703
888
bool mysql_handle_derived(LEX *lex, bool (*processor)(Session *session,
704
889
                                                      LEX *lex,
705
890
                                                      TableList *table));
706
891
bool mysql_derived_prepare(Session *session, LEX *lex, TableList *t);
707
892
bool mysql_derived_filling(Session *session, LEX *lex, TableList *t);
 
893
void sp_prepare_create_field(Session *session, CreateField *sql_field);
708
894
int prepare_create_field(CreateField *sql_field,
709
895
                         uint32_t *blob_columns,
710
 
                         int *timestamps, int *timestamps_with_niladic);
711
 
 
712
 
bool mysql_create_table(Session *session,
713
 
                        TableIdentifier &identifier,
 
896
                         int *timestamps, int *timestamps_with_niladic,
 
897
                         int64_t table_flags);
 
898
bool mysql_create_table(Session *session,const char *db, const char *table_name,
714
899
                        HA_CREATE_INFO *create_info,
715
 
                        message::Table &table_proto,
716
 
                        AlterInfo *alter_info,
717
 
                        bool tmp_table, uint32_t select_field_count,
718
 
                        bool is_if_not_exists);
719
 
 
720
 
bool mysql_create_table_no_lock(Session *session,
721
 
                                TableIdentifier &identifier,
 
900
                        drizzled::message::Table *table_proto,
 
901
                        Alter_info *alter_info,
 
902
                        bool tmp_table, uint32_t select_field_count);
 
903
bool mysql_create_table_no_lock(Session *session, const char *db,
 
904
                                const char *table_name,
722
905
                                HA_CREATE_INFO *create_info,
723
 
                                message::Table &table_proto,
724
 
                                AlterInfo *alter_info,
725
 
                                bool tmp_table, uint32_t select_field_count,
726
 
                                bool is_if_not_exists);
727
 
 
728
 
bool mysql_create_like_table(Session* session,
729
 
                             TableIdentifier &destination_identifier,
730
 
                             TableList* table, TableList* src_table,
731
 
                             message::Table &create_table_proto,
732
 
                             bool is_if_not_exists,
733
 
                             bool is_engine_set);
734
 
 
735
 
bool mysql_rename_table(plugin::StorageEngine *base,
736
 
                        TableIdentifier &old_identifier,
737
 
                        TableIdentifier &new_identifier,
738
 
                        uint32_t flags);
739
 
 
 
906
                                drizzled::message::Table *table_proto,
 
907
                                Alter_info *alter_info,
 
908
                                bool tmp_table, uint32_t select_field_count);
 
909
 
 
910
bool mysql_recreate_table(Session *session, TableList *table_list);
 
911
bool mysql_create_like_table(Session *session, TableList *table,
 
912
                             TableList *src_table,
 
913
                             HA_CREATE_INFO *create_info);
 
914
bool mysql_rename_table(StorageEngine *base, const char *old_db,
 
915
                        const char * old_name, const char *new_db,
 
916
                        const char * new_name, uint32_t flags);
740
917
bool mysql_prepare_update(Session *session, TableList *table_list,
741
918
                          Item **conds, uint32_t order_num, order_st *order);
742
919
int mysql_update(Session *session,TableList *tables,List<Item> &fields,
759
936
bool mysql_delete(Session *session, TableList *table_list, COND *conds,
760
937
                  SQL_LIST *order, ha_rows rows, uint64_t options,
761
938
                  bool reset_auto_increment);
762
 
bool mysql_truncate(Session& session, TableList *table_list);
 
939
bool mysql_truncate(Session *session, TableList *table_list, bool dont_send_ok);
763
940
TableShare *get_table_share(Session *session, TableList *table_list, char *key,
764
941
                             uint32_t key_length, uint32_t db_flags, int *error);
765
942
TableShare *get_cached_table_share(const char *db, const char *table_name);
796
973
Field *
797
974
find_field_in_table(Session *session, Table *table, const char *name, uint32_t length,
798
975
                    bool allow_rowid, uint32_t *cached_field_index_ptr);
799
 
 
800
 
} /* namespace drizzled */
801
 
 
802
 
#endif /* DRIZZLED_CURSOR_H */
 
976
Field *
 
977
find_field_in_table_sef(Table *table, const char *name);
 
978
 
 
979
 
 
980
#endif /* DRIZZLED_HANDLER_H */