~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/sql_class.h

  • Committer: Monty Taylor
  • Date: 2008-07-05 11:20:18 UTC
  • mto: This revision was merged to the branch mainline in revision 62.
  • Revision ID: monty@inaugust.com-20080705112018-fr12kkmgphtu7m29
Changes so that removal of duplicate curr_dir from my_sys.h work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
 
1
/* Copyright (C) 2000-2006 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
19
15
 
20
16
 
21
17
/* Classes in mysql */
22
 
#include <drizzled/global.h>
 
18
 
 
19
#ifdef USE_PRAGMA_INTERFACE
 
20
#pragma interface                       /* gcc class implementation */
 
21
#endif
 
22
 
 
23
#include <mysql/plugin_audit.h>
23
24
#include "log.h"
24
25
#include "rpl_tblmap.h"
25
26
 
52
53
 
53
54
#define TC_HEURISTIC_RECOVER_COMMIT   1
54
55
#define TC_HEURISTIC_RECOVER_ROLLBACK 2
55
 
extern uint32_t tc_heuristic_recover;
 
56
extern uint tc_heuristic_recover;
56
57
 
57
58
typedef struct st_user_var_events
58
59
{
60
61
  char *value;
61
62
  ulong length;
62
63
  Item_result type;
63
 
  uint32_t charset_number;
 
64
  uint charset_number;
64
65
} BINLOG_USER_VAR_EVENT;
65
66
 
66
67
#define RP_LOCK_LOG_IS_ALREADY_LOCKED 1
98
99
class Key_part_spec :public Sql_alloc {
99
100
public:
100
101
  LEX_STRING field_name;
101
 
  uint32_t length;
102
 
  Key_part_spec(const LEX_STRING &name, uint32_t len)
 
102
  uint length;
 
103
  Key_part_spec(const LEX_STRING &name, uint len)
103
104
    : field_name(name), length(len)
104
105
  {}
105
 
  Key_part_spec(const char *name, const size_t name_len, uint32_t len)
 
106
  Key_part_spec(const char *name, const size_t name_len, uint len)
106
107
    : length(len)
107
108
  { field_name.str= (char *)name; field_name.length= name_len; }
108
109
  bool operator==(const Key_part_spec& other) const;
198
199
 
199
200
  Table_ident *ref_table;
200
201
  List<Key_part_spec> ref_columns;
201
 
  uint32_t delete_opt, update_opt, match_opt;
 
202
  uint delete_opt, update_opt, match_opt;
202
203
  Foreign_key(const LEX_STRING &name_arg, List<Key_part_spec> &cols,
203
204
              Table_ident *table,   List<Key_part_spec> &ref_cols,
204
 
              uint32_t delete_opt_arg, uint32_t update_opt_arg, uint32_t match_opt_arg)
 
205
              uint delete_opt_arg, uint update_opt_arg, uint match_opt_arg)
205
206
    :Key(FOREIGN_KEY, name_arg, &default_key_create_info, 0, cols),
206
207
    ref_table(table), ref_columns(ref_cols),
207
208
    delete_opt(delete_opt_arg), update_opt(update_opt_arg),
214
215
  */
215
216
  virtual Key *clone(MEM_ROOT *mem_root) const
216
217
  { return new (mem_root) Foreign_key(*this, mem_root); }
217
 
  /* Used to validate foreign key options */
218
 
  bool validate(List<Create_field> &table_fields);
219
218
};
220
219
 
221
220
typedef struct st_mysql_lock
222
221
{
223
 
  Table **table;
224
 
  uint32_t table_count,lock_count;
 
222
  TABLE **table;
 
223
  uint table_count,lock_count;
225
224
  THR_LOCK_DATA **locks;
226
 
} DRIZZLE_LOCK;
 
225
} MYSQL_LOCK;
227
226
 
228
227
 
229
228
class LEX_COLUMN : public Sql_alloc
230
229
{
231
230
public:
232
231
  String column;
233
 
  uint32_t rights;
 
232
  uint rights;
234
233
  LEX_COLUMN (const String& x,const  uint& y ): column (x),rights (y) {}
235
234
};
236
235
 
 
236
/**
 
237
  Query_cache_tls -- query cache thread local data.
 
238
*/
 
239
 
 
240
struct Query_cache_block;
 
241
 
 
242
struct Query_cache_tls
 
243
{
 
244
  /*
 
245
    'first_query_block' should be accessed only via query cache
 
246
    functions and methods to maintain proper locking.
 
247
  */
 
248
  Query_cache_block *first_query_block;
 
249
  void set_first_query_block(Query_cache_block *first_query_block_arg)
 
250
  {
 
251
    first_query_block= first_query_block_arg;
 
252
  }
 
253
 
 
254
  Query_cache_tls() :first_query_block(NULL) {}
 
255
};
 
256
 
 
257
#include "sql_lex.h"                            /* Must be here */
 
258
 
237
259
class select_result;
238
260
class Time_zone;
239
261
 
240
262
#define THD_SENTRY_MAGIC 0xfeedd1ff
241
263
#define THD_SENTRY_GONE  0xdeadbeef
242
264
 
243
 
#define THD_CHECK_SENTRY(thd) assert(thd->dbug_sentry == THD_SENTRY_MAGIC)
 
265
#define THD_CHECK_SENTRY(thd) DBUG_ASSERT(thd->dbug_sentry == THD_SENTRY_MAGIC)
244
266
 
245
267
struct system_variables
246
268
{
255
277
  */ 
256
278
  ulong dynamic_variables_version;
257
279
  char* dynamic_variables_ptr;
258
 
  uint32_t dynamic_variables_head;  /* largest valid variable offset */
259
 
  uint32_t dynamic_variables_size;  /* how many bytes are in use */
 
280
  uint dynamic_variables_head;  /* largest valid variable offset */
 
281
  uint dynamic_variables_size;  /* how many bytes are in use */
260
282
  
261
 
  uint64_t myisam_max_extra_sort_file_size;
262
 
  uint64_t myisam_max_sort_file_size;
263
 
  uint64_t max_heap_table_size;
264
 
  uint64_t tmp_table_size;
265
 
  uint64_t long_query_time;
 
283
  ulonglong myisam_max_extra_sort_file_size;
 
284
  ulonglong myisam_max_sort_file_size;
 
285
  ulonglong max_heap_table_size;
 
286
  ulonglong tmp_table_size;
 
287
  ulonglong long_query_time;
266
288
  ha_rows select_limit;
267
289
  ha_rows max_join_size;
268
290
  ulong auto_increment_increment, auto_increment_offset;
322
344
  */
323
345
  my_thread_id pseudo_thread_id;
324
346
 
325
 
  bool low_priority_updates;
326
 
  bool new_mode;
 
347
  my_bool low_priority_updates;
 
348
  my_bool new_mode;
327
349
  /* 
328
350
    compatibility option:
329
351
      - index usage hints (USE INDEX without a FOR clause) behave as in 5.0 
330
352
  */
331
 
  bool old_mode;
332
 
  bool engine_condition_pushdown;
333
 
  bool keep_files_on_create;
 
353
  my_bool old_mode;
 
354
  my_bool query_cache_wlock_invalidate;
 
355
  my_bool engine_condition_pushdown;
 
356
  my_bool keep_files_on_create;
334
357
 
335
 
  bool old_alter_table;
 
358
  my_bool old_alter_table;
 
359
  my_bool old_passwords;
336
360
 
337
361
  plugin_ref table_plugin;
338
362
 
339
363
  /* Only charset part of these variables is sensible */
340
 
  const CHARSET_INFO  *character_set_filesystem;
341
 
  const CHARSET_INFO  *character_set_client;
342
 
  const CHARSET_INFO  *character_set_results;
 
364
  CHARSET_INFO  *character_set_filesystem;
 
365
  CHARSET_INFO  *character_set_client;
 
366
  CHARSET_INFO  *character_set_results;
343
367
 
344
368
  /* Both charset and collation parts of these variables are important */
345
 
  const CHARSET_INFO    *collation_server;
346
 
  const CHARSET_INFO    *collation_database;
347
 
  const CHARSET_INFO  *collation_connection;
 
369
  CHARSET_INFO  *collation_server;
 
370
  CHARSET_INFO  *collation_database;
 
371
  CHARSET_INFO  *collation_connection;
348
372
 
349
373
  /* Locale Support */
350
374
  MY_LOCALE *lc_time_names;
351
375
 
352
376
  Time_zone *time_zone;
353
377
 
354
 
  /* DATE, DATETIME and DRIZZLE_TIME formats */
 
378
  /* DATE, DATETIME and MYSQL_TIME formats */
355
379
  DATE_TIME_FORMAT *date_format;
356
380
  DATE_TIME_FORMAT *datetime_format;
357
381
  DATE_TIME_FORMAT *time_format;
358
 
  bool sysdate_is_now;
 
382
  my_bool sysdate_is_now;
359
383
 
360
384
};
361
385
 
362
 
#include "sql_lex.h"  /* only for SQLCOM_END */
363
386
 
364
387
/* per thread status variables */
365
388
 
366
389
typedef struct system_status_var
367
390
{
368
 
  uint64_t bytes_received;
369
 
  uint64_t bytes_sent;
 
391
  ulonglong bytes_received;
 
392
  ulonglong bytes_sent;
370
393
  ulong com_other;
371
394
  ulong com_stat[(uint) SQLCOM_END];
372
395
  ulong created_tmp_disk_tables;
444
467
 
445
468
void mark_transaction_to_rollback(THD *thd, bool all);
446
469
 
447
 
#ifdef DRIZZLE_SERVER
 
470
#ifdef MYSQL_SERVER
 
471
 
 
472
void free_tmp_table(THD *thd, TABLE *entry);
 
473
 
 
474
 
 
475
/* The following macro is to make init of Query_arena simpler */
 
476
#ifndef DBUG_OFF
 
477
#define INIT_ARENA_DBUG_INFO is_backup_arena= 0
 
478
#else
 
479
#define INIT_ARENA_DBUG_INFO
 
480
#endif
448
481
 
449
482
class Query_arena
450
483
{
455
488
  */
456
489
  Item *free_list;
457
490
  MEM_ROOT *mem_root;                   // Pointer to current memroot
458
 
 
459
 
  Query_arena(MEM_ROOT *mem_root_arg) :
460
 
    free_list(0), mem_root(mem_root_arg)
461
 
  { }
 
491
#ifndef DBUG_OFF
 
492
  bool is_backup_arena; /* True if this arena is used for backup. */
 
493
#endif
 
494
  /*
 
495
    The states relfects three diffrent life cycles for three
 
496
    different types of statements:
 
497
    Prepared statement: INITIALIZED -> PREPARED -> EXECUTED.
 
498
    Stored procedure:   INITIALIZED_FOR_SP -> EXECUTED.
 
499
    Other statements:   CONVENTIONAL_EXECUTION never changes.
 
500
  */
 
501
  enum enum_state
 
502
  {
 
503
    INITIALIZED= 0, INITIALIZED_FOR_SP= 1, PREPARED= 2,
 
504
    CONVENTIONAL_EXECUTION= 3, EXECUTED= 4, ERROR= -1
 
505
  };
 
506
 
 
507
  enum_state state;
 
508
 
 
509
  /* We build without RTTI, so dynamic_cast can't be used. */
 
510
  enum Type
 
511
  {
 
512
    STATEMENT, PREPARED_STATEMENT, STORED_PROCEDURE
 
513
  };
 
514
 
 
515
  Query_arena(MEM_ROOT *mem_root_arg, enum enum_state state_arg) :
 
516
    free_list(0), mem_root(mem_root_arg), state(state_arg)
 
517
  { INIT_ARENA_DBUG_INFO; }
462
518
  /*
463
519
    This constructor is used only when Query_arena is created as
464
520
    backup storage for another instance of Query_arena.
465
521
  */
466
 
  Query_arena() { }
 
522
  Query_arena() { INIT_ARENA_DBUG_INFO; }
467
523
 
468
524
  virtual ~Query_arena() {};
469
525
 
 
526
  inline bool is_conventional() const
 
527
  { assert(state == CONVENTIONAL_EXECUTION); return state == CONVENTIONAL_EXECUTION; }
 
528
 
470
529
  inline void* alloc(size_t size) { return alloc_root(mem_root,size); }
471
530
  inline void* calloc(size_t size)
472
531
  {
473
532
    void *ptr;
474
533
    if ((ptr=alloc_root(mem_root,size)))
475
 
      memset(ptr, 0, size);
 
534
      bzero(ptr, size);
476
535
    return ptr;
477
536
  }
478
537
  inline char *strdup(const char *str)
481
540
  { return strmake_root(mem_root,str,size); }
482
541
  inline void *memdup(const void *str, size_t size)
483
542
  { return memdup_root(mem_root,str,size); }
484
 
  inline void *memdup_w_gap(const void *str, size_t size, uint32_t gap)
 
543
  inline void *memdup_w_gap(const void *str, size_t size, uint gap)
485
544
  {
486
545
    void *ptr;
487
546
    if ((ptr= alloc_root(mem_root,size+gap)))
489
548
    return ptr;
490
549
  }
491
550
 
 
551
  void set_query_arena(Query_arena *set);
 
552
 
492
553
  void free_items();
 
554
  /* Close the active state associated with execution of this statement */
 
555
  virtual void cleanup_stmt();
493
556
};
494
557
 
495
558
 
530
593
  */
531
594
  enum enum_mark_columns mark_used_columns;
532
595
 
 
596
  LEX_STRING name; /* name for named prepared statements */
533
597
  LEX *lex;                                     // parse tree descriptor
534
598
  /*
535
599
    Points to the query associated with this statement. It's const, but
554
618
    STATUS.
555
619
  */
556
620
  char *query;
557
 
  uint32_t query_length;                          // current query length
 
621
  uint32 query_length;                          // current query length
558
622
 
559
623
  /**
560
624
    Name of the current (default) database.
570
634
  */
571
635
 
572
636
  char *db;
573
 
  uint32_t db_length;
 
637
  uint db_length;
574
638
 
575
639
public:
576
640
 
577
641
  /* This constructor is called for backup statements */
578
642
  Statement() {}
579
643
 
580
 
  Statement(LEX *lex_arg, MEM_ROOT *mem_root_arg, ulong id_arg);
 
644
  Statement(LEX *lex_arg, MEM_ROOT *mem_root_arg,
 
645
            enum enum_state state_arg, ulong id_arg);
581
646
  ~Statement() {}
 
647
 
 
648
  /* Assign execution context (note: not all members) of given stmt to self */
 
649
  void set_statement(Statement *stmt);
 
650
  void set_n_backup_statement(Statement *stmt, Statement *backup);
 
651
  void restore_backup_statement(Statement *stmt, Statement *backup);
582
652
};
583
653
 
584
654
struct st_savepoint {
585
655
  struct st_savepoint *prev;
586
656
  char                *name;
587
 
  uint32_t                 length;
 
657
  uint                 length;
588
658
  Ha_trx_info         *ha_list;
589
659
};
590
660
 
622
692
    priv_user - The user privilege we are using. May be "" for anonymous user.
623
693
    ip - client IP
624
694
  */
625
 
  char *user; 
626
 
  char *ip;
 
695
  char   *host, *user, *priv_user, *ip;
 
696
  /* The host privilege we are using */
 
697
  char   priv_host[MAX_HOSTNAME];
 
698
  /* points to host if host is available, otherwise points to ip */
 
699
  const char *host_or_ip;
 
700
  ulong db_access;                     /* Privileges for current db */
627
701
 
628
702
  void init();
629
703
  void destroy();
630
704
  void skip_grants();
631
705
  inline char *priv_host_name()
632
706
  {
633
 
    return (ip ? ip : (char *)"%");
 
707
    return (*priv_host ? priv_host : (char *)"%");
634
708
  }
635
709
};
636
710
 
659
733
    List of regular tables in use by this thread. Contains temporary and
660
734
    base tables that were opened with @see open_tables().
661
735
  */
662
 
  Table *open_tables;
 
736
  TABLE *open_tables;
663
737
  /**
664
738
    List of temporary tables used by this thread. Contains user-level
665
739
    temporary tables, created with CREATE TEMPORARY TABLE, and
667
741
    or for an intermediate table used in ALTER.
668
742
    XXX Why are internal temporary tables added to this list?
669
743
  */
670
 
  Table *temporary_tables;
 
744
  TABLE *temporary_tables;
671
745
  /**
672
746
    List of tables that were opened with HANDLER OPEN and are
673
747
    still in use by this thread.
674
748
  */
675
 
  Table *handler_tables;
676
 
  Table *derived_tables;
 
749
  TABLE *handler_tables;
 
750
  TABLE *derived_tables;
677
751
  /*
678
752
    During a MySQL session, one can lock tables in two modes: automatic
679
753
    or manual. In automatic mode all necessary tables are locked just before
687
761
    the 'LOCK_TABLES' chapter of the MySQL manual.
688
762
    See also lock_tables() for details.
689
763
  */
690
 
  DRIZZLE_LOCK *lock;
 
764
  MYSQL_LOCK *lock;
691
765
  /*
692
766
    Tables that were locked with explicit or implicit LOCK TABLES.
693
767
    (Implicit LOCK TABLES happens when we are prelocking tables for
694
768
     execution of statement which uses stored routines. See description
695
769
     THD::prelocked_mode for more info.)
696
770
  */
697
 
  DRIZZLE_LOCK *locked_tables;
 
771
  MYSQL_LOCK *locked_tables;
698
772
 
699
773
  /*
700
774
    CREATE-SELECT keeps an extra lock for the table being
701
775
    created. This field is used to keep the extra lock available for
702
776
    lower level routines, which would otherwise miss that lock.
703
777
   */
704
 
  DRIZZLE_LOCK *extra_lock;
 
778
  MYSQL_LOCK *extra_lock;
705
779
 
706
780
  ulong version;
707
 
  uint32_t current_tablenr;
 
781
  uint current_tablenr;
708
782
 
709
783
  enum enum_flags {
710
784
    BACKUPS_AVAIL = (1U << 0)     /* There are backups available */
713
787
  /*
714
788
    Flags with information about the open tables state.
715
789
  */
716
 
  uint32_t state_flags;
 
790
  uint state_flags;
717
791
 
718
792
  /*
719
793
    This constructor serves for creation of Open_tables_state instances
736
810
  }
737
811
};
738
812
 
 
813
/**
 
814
  @class Sub_statement_state
 
815
  @brief Used to save context when executing a function or trigger
 
816
*/
 
817
 
 
818
/* Defines used for Sub_statement_state::in_sub_stmt */
 
819
 
 
820
#define SUB_STMT_TRIGGER 1
 
821
#define SUB_STMT_FUNCTION 2
 
822
 
 
823
 
 
824
class Sub_statement_state
 
825
{
 
826
public:
 
827
  ulonglong options;
 
828
  ulonglong first_successful_insert_id_in_prev_stmt;
 
829
  ulonglong first_successful_insert_id_in_cur_stmt, insert_id_for_cur_row;
 
830
  Discrete_interval auto_inc_interval_for_cur_row;
 
831
  Discrete_intervals_list auto_inc_intervals_forced;
 
832
  ulonglong limit_found_rows;
 
833
  ha_rows    cuted_fields, sent_row_count, examined_row_count;
 
834
  ulong client_capabilities;
 
835
  uint in_sub_stmt;
 
836
  bool enable_slow_log;
 
837
  bool last_insert_id_used;
 
838
  SAVEPOINT *savepoints;
 
839
};
 
840
 
739
841
 
740
842
/* Flags for the THD::system_thread variable */
741
843
enum enum_thread_type
742
844
{
743
 
  NON_SYSTEM_THREAD,
744
 
  SYSTEM_THREAD_SLAVE_IO,
745
 
  SYSTEM_THREAD_SLAVE_SQL
 
845
  NON_SYSTEM_THREAD= 0,
 
846
  SYSTEM_THREAD_DELAYED_INSERT= 1,
 
847
  SYSTEM_THREAD_SLAVE_IO= 2,
 
848
  SYSTEM_THREAD_SLAVE_SQL= 4,
 
849
  SYSTEM_THREAD_NDBCLUSTER_BINLOG= 8,
 
850
  SYSTEM_THREAD_EVENT_SCHEDULER= 16,
 
851
  SYSTEM_THREAD_EVENT_WORKER= 32,
 
852
  SYSTEM_THREAD_BACKUP= 64
746
853
};
747
854
 
748
855
 
783
890
    @param thd the calling thread
784
891
    @return true if the error is handled
785
892
  */
786
 
  virtual bool handle_error(uint32_t sql_errno,
 
893
  virtual bool handle_error(uint sql_errno,
787
894
                            const char *message,
788
 
                            DRIZZLE_ERROR::enum_warning_level level,
 
895
                            MYSQL_ERROR::enum_warning_level level,
789
896
                            THD *thd) = 0;
790
897
};
791
898
 
819
926
  bool can_overwrite_status;
820
927
 
821
928
  void set_ok_status(THD *thd, ha_rows affected_rows_arg,
822
 
                     uint64_t last_insert_id_arg,
 
929
                     ulonglong last_insert_id_arg,
823
930
                     const char *message);
824
931
  void set_eof_status(THD *thd);
825
 
  void set_error_status(THD *thd, uint32_t sql_errno_arg, const char *message_arg);
 
932
  void set_error_status(THD *thd, uint sql_errno_arg, const char *message_arg);
826
933
 
827
934
  void disable_status();
828
935
 
836
943
  enum_diagnostics_status status() const { return m_status; }
837
944
 
838
945
  const char *message() const
839
 
  { assert(m_status == DA_ERROR || m_status == DA_OK); return m_message; }
840
 
 
841
 
  uint32_t sql_errno() const
842
 
  { assert(m_status == DA_ERROR); return m_sql_errno; }
843
 
 
844
 
  uint32_t server_status() const
 
946
  { DBUG_ASSERT(m_status == DA_ERROR || m_status == DA_OK); return m_message; }
 
947
 
 
948
  uint sql_errno() const
 
949
  { DBUG_ASSERT(m_status == DA_ERROR); return m_sql_errno; }
 
950
 
 
951
  uint server_status() const
845
952
  {
846
 
    assert(m_status == DA_OK || m_status == DA_EOF);
 
953
    DBUG_ASSERT(m_status == DA_OK || m_status == DA_EOF);
847
954
    return m_server_status;
848
955
  }
849
956
 
850
957
  ha_rows affected_rows() const
851
 
  { assert(m_status == DA_OK); return m_affected_rows; }
852
 
 
853
 
  uint64_t last_insert_id() const
854
 
  { assert(m_status == DA_OK); return m_last_insert_id; }
855
 
 
856
 
  uint32_t total_warn_count() const
 
958
  { DBUG_ASSERT(m_status == DA_OK); return m_affected_rows; }
 
959
 
 
960
  ulonglong last_insert_id() const
 
961
  { DBUG_ASSERT(m_status == DA_OK); return m_last_insert_id; }
 
962
 
 
963
  uint total_warn_count() const
857
964
  {
858
 
    assert(m_status == DA_OK || m_status == DA_EOF);
 
965
    DBUG_ASSERT(m_status == DA_OK || m_status == DA_EOF);
859
966
    return m_total_warn_count;
860
967
  }
861
968
 
863
970
 
864
971
private:
865
972
  /** Message buffer. Can be used by OK or ERROR status. */
866
 
  char m_message[DRIZZLE_ERRMSG_SIZE];
 
973
  char m_message[MYSQL_ERRMSG_SIZE];
867
974
  /**
868
975
    SQL error number. One of ER_ codes from share/errmsg.txt.
869
976
    Set by set_error_status.
870
977
  */
871
 
  uint32_t m_sql_errno;
 
978
  uint m_sql_errno;
872
979
 
873
980
  /**
874
981
    Copied from thd->server_status when the diagnostics area is assigned.
878
985
    thd->server_status&= ~...
879
986
    Assigned by OK, EOF or ERROR.
880
987
  */
881
 
  uint32_t m_server_status;
 
988
  uint m_server_status;
882
989
  /**
883
990
    The number of rows affected by the last statement. This is
884
991
    semantically close to thd->row_count_func, but has a different
896
1003
    thd->first_successful_insert_id_in_prev_stmt, which is used
897
1004
    to implement LAST_INSERT_ID().
898
1005
  */
899
 
  uint64_t   m_last_insert_id;
 
1006
  ulonglong   m_last_insert_id;
900
1007
  /** The total number of warnings. */
901
1008
  uint       m_total_warn_count;
902
1009
  enum_diagnostics_status m_status;
1006
1113
    Set it using the  thd_proc_info(THD *thread, const char *message)
1007
1114
    macro/function.
1008
1115
  */
1009
 
  void        set_proc_info(const char *info) { proc_info= info; }
1010
 
  const char* get_proc_info() const { return proc_info; }
 
1116
#ifndef DBUG_OFF
 
1117
  #define THD_SET_PROC_INFO(thd, info) \
 
1118
    (thd)->set_proc_info(__FILE__, __LINE__, (info))
 
1119
 
 
1120
  void set_proc_info(const char* file, int line, const char* info);
 
1121
#else
 
1122
  #define THD_SET_PROC_INFO(thd, info) \
 
1123
    (thd)->proc_info= (info)
 
1124
#endif
 
1125
 
 
1126
  inline const char* get_proc_info() { return proc_info;}
 
1127
 
 
1128
  /* left public for the the storage engines, please avoid direct use */
 
1129
  const char *proc_info;
1011
1130
 
1012
1131
  /*
1013
1132
    Used in error messages to tell user in what part of MySQL we found an
1026
1145
    points to a lock object if the lock is present. See item_func.cc and
1027
1146
    chapter 'Miscellaneous functions', for functions GET_LOCK, RELEASE_LOCK. 
1028
1147
  */
1029
 
  uint32_t dbug_sentry; // watch out for memory corruption
 
1148
#ifndef DBUG_OFF
 
1149
  uint dbug_sentry; // watch out for memory corruption
 
1150
#endif
1030
1151
  struct st_my_thread_var *mysys_var;
1031
1152
  /*
1032
1153
    Type of current query: COM_STMT_PREPARE, COM_QUERY, etc. Set from
1033
1154
    first byte of the packet in do_command()
1034
1155
  */
1035
1156
  enum enum_server_command command;
1036
 
  uint32_t     server_id;
1037
 
  uint32_t     file_id;                 // for LOAD DATA INFILE
 
1157
  uint32     server_id;
 
1158
  uint32     file_id;                   // for LOAD DATA INFILE
1038
1159
  /* remote (peer) port */
1039
 
  uint16_t peer_port;
 
1160
  uint16 peer_port;
1040
1161
  time_t     start_time, user_time;
1041
 
  uint64_t  connect_utime, thr_create_utime; // track down slow pthread_create
1042
 
  uint64_t  start_utime, utime_after_lock;
 
1162
  ulonglong  connect_utime, thr_create_utime; // track down slow pthread_create
 
1163
  ulonglong  start_utime, utime_after_lock;
1043
1164
  
1044
1165
  thr_lock_type update_lock_default;
1045
1166
 
 
1167
  /* <> 0 if we are inside of trigger or stored function. */
 
1168
  uint in_sub_stmt;
 
1169
 
1046
1170
  /* container for handler's private per-connection data */
1047
1171
  Ha_data ha_data[MAX_HA];
1048
1172
 
1049
1173
  /* Place to store various things */
1050
1174
  void *thd_marker;
 
1175
#ifndef MYSQL_CLIENT
1051
1176
  int binlog_setup_trx_data();
1052
1177
 
1053
1178
  /*
1055
1180
  */
1056
1181
  void binlog_start_trans_and_stmt();
1057
1182
  void binlog_set_stmt_begin();
1058
 
  int binlog_write_table_map(Table *table, bool is_transactional);
1059
 
  int binlog_write_row(Table* table, bool is_transactional,
1060
 
                       const unsigned char *new_data);
1061
 
  int binlog_delete_row(Table* table, bool is_transactional,
1062
 
                        const unsigned char *old_data);
1063
 
  int binlog_update_row(Table* table, bool is_transactional,
1064
 
                        const unsigned char *old_data, const unsigned char *new_data);
 
1183
  int binlog_write_table_map(TABLE *table, bool is_transactional);
 
1184
  int binlog_write_row(TABLE* table, bool is_transactional,
 
1185
                       const uchar *new_data);
 
1186
  int binlog_delete_row(TABLE* table, bool is_transactional,
 
1187
                        const uchar *old_data);
 
1188
  int binlog_update_row(TABLE* table, bool is_transactional,
 
1189
                        const uchar *old_data, const uchar *new_data);
1065
1190
 
1066
 
  void set_server_id(uint32_t sid) { server_id = sid; }
 
1191
  void set_server_id(uint32 sid) { server_id = sid; }
1067
1192
 
1068
1193
  /*
1069
1194
    Member functions to handle pending event for row-level logging.
1070
1195
  */
1071
1196
  template <class RowsEventT> Rows_log_event*
1072
 
    binlog_prepare_pending_rows_event(Table* table, uint32_t serv_id,
 
1197
    binlog_prepare_pending_rows_event(TABLE* table, uint32 serv_id,
1073
1198
                                      size_t needed,
1074
1199
                                      bool is_transactional,
1075
1200
                                      RowsEventT* hint);
1078
1203
  int binlog_flush_pending_rows_event(bool stmt_end);
1079
1204
 
1080
1205
private:
1081
 
  uint32_t binlog_table_maps; // Number of table maps currently in the binlog
 
1206
  uint binlog_table_maps; // Number of table maps currently in the binlog
1082
1207
 
1083
1208
  enum enum_binlog_flag {
1084
1209
    BINLOG_FLAG_UNSAFE_STMT_PRINTED,
1089
1214
     Flags with per-thread information regarding the status of the
1090
1215
     binary log.
1091
1216
   */
1092
 
  uint32_t binlog_flags;
 
1217
  uint32 binlog_flags;
1093
1218
public:
1094
 
  uint32_t get_binlog_table_maps() const {
 
1219
  uint get_binlog_table_maps() const {
1095
1220
    return binlog_table_maps;
1096
1221
  }
1097
1222
  void clear_binlog_table_maps() {
1098
1223
    binlog_table_maps= 0;
1099
1224
  }
 
1225
#endif /* MYSQL_CLIENT */
1100
1226
 
1101
1227
public:
1102
1228
 
1113
1239
       List contain only transactional tables, that not invalidated in query
1114
1240
       cache (instead of full list of changed in transaction tables).
1115
1241
    */
1116
 
    CHANGED_TableList* changed_tables;
 
1242
    CHANGED_TABLE_LIST* changed_tables;
1117
1243
    MEM_ROOT mem_root; // Transaction-life memory allocation pool
1118
1244
    void cleanup()
1119
1245
    {
1123
1249
    }
1124
1250
    st_transactions()
1125
1251
    {
1126
 
      memset(this, 0, sizeof(*this));
 
1252
      bzero((char*)this, sizeof(*this));
1127
1253
      xid_state.xid.null();
1128
1254
      init_sql_alloc(&mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0);
1129
1255
    }
1130
1256
  } transaction;
1131
1257
  Field      *dup_field;
1132
1258
  sigset_t signals;
 
1259
#ifdef SIGNAL_WITH_VIO_CLOSE
 
1260
  Vio* active_vio;
 
1261
#endif
1133
1262
  /*
1134
1263
    This is to track items changed during execution of a prepared
1135
1264
    statement/stored procedure. It's created by
1139
1268
  */
1140
1269
  Item_change_list change_list;
1141
1270
 
 
1271
  /*
 
1272
    A permanent memory area of the statement. For conventional
 
1273
    execution, the parsed tree and execution runtime reside in the same
 
1274
    memory root. In this case stmt_arena points to THD. In case of
 
1275
    a prepared statement or a stored procedure statement, thd->mem_root
 
1276
    conventionally points to runtime memory, and thd->stmt_arena
 
1277
    points to the memory of the PS/SP, where the parsed tree of the
 
1278
    statement resides. Whenever you need to perform a permanent
 
1279
    transformation of a parsed tree, you should allocate new memory in
 
1280
    stmt_arena, to allow correct re-execution of PS/SP.
 
1281
    Note: in the parser, stmt_arena == thd, even for PS/SP.
 
1282
  */
 
1283
  Query_arena *stmt_arena;
1142
1284
  /* Tells if LAST_INSERT_ID(#) was called for the current statement */
1143
1285
  bool arg_of_last_insert_id_function;
1144
1286
  /*
1153
1295
    It can also be set by SET LAST_INSERT_ID=# or SELECT LAST_INSERT_ID(#).
1154
1296
    It is returned by LAST_INSERT_ID().
1155
1297
  */
1156
 
  uint64_t  first_successful_insert_id_in_prev_stmt;
 
1298
  ulonglong  first_successful_insert_id_in_prev_stmt;
1157
1299
  /*
1158
1300
    Variant of the above, used for storing in statement-based binlog. The
1159
1301
    difference is that the one above can change as the execution of a stored
1160
1302
    function progresses, while the one below is set once and then does not
1161
1303
    change (which is the value which statement-based binlog needs).
1162
1304
  */
1163
 
  uint64_t  first_successful_insert_id_in_prev_stmt_for_binlog;
 
1305
  ulonglong  first_successful_insert_id_in_prev_stmt_for_binlog;
1164
1306
  /*
1165
1307
    This is the first autogenerated insert id which was *successfully*
1166
1308
    inserted by the current statement. It is maintained only to set
1167
1309
    first_successful_insert_id_in_prev_stmt when statement ends.
1168
1310
  */
1169
 
  uint64_t  first_successful_insert_id_in_cur_stmt;
 
1311
  ulonglong  first_successful_insert_id_in_cur_stmt;
1170
1312
  /*
1171
1313
    We follow this logic:
1172
1314
    - when stmt starts, first_successful_insert_id_in_prev_stmt contains the
1246
1388
    mode, row-based binlogging is used for such cases where two
1247
1389
    auto_increment columns are inserted.
1248
1390
  */
1249
 
  inline void record_first_successful_insert_id_in_cur_stmt(uint64_t id_arg)
 
1391
  inline void record_first_successful_insert_id_in_cur_stmt(ulonglong id_arg)
1250
1392
  {
1251
1393
    if (first_successful_insert_id_in_cur_stmt == 0)
1252
1394
      first_successful_insert_id_in_cur_stmt= id_arg;
1253
1395
  }
1254
 
  inline uint64_t read_first_successful_insert_id_in_prev_stmt(void)
 
1396
  inline ulonglong read_first_successful_insert_id_in_prev_stmt(void)
1255
1397
  {
1256
1398
    if (!stmt_depends_on_first_successful_insert_id_in_prev_stmt)
1257
1399
    {
1267
1409
    (mysqlbinlog). We'll soon add a variant which can take many intervals in
1268
1410
    argument.
1269
1411
  */
1270
 
  inline void force_one_auto_inc_interval(uint64_t next_id)
 
1412
  inline void force_one_auto_inc_interval(ulonglong next_id)
1271
1413
  {
1272
1414
    auto_inc_intervals_forced.empty(); // in case of multiple SET INSERT_ID
1273
 
    auto_inc_intervals_forced.append(next_id, UINT64_MAX, 0);
 
1415
    auto_inc_intervals_forced.append(next_id, ULONGLONG_MAX, 0);
1274
1416
  }
1275
1417
 
1276
 
  uint64_t  limit_found_rows;
1277
 
  uint64_t  options;           /* Bitmap of states */
1278
 
  int64_t   row_count_func;    /* For the ROW_COUNT() function */
 
1418
  ulonglong  limit_found_rows;
 
1419
  ulonglong  options;           /* Bitmap of states */
 
1420
  longlong   row_count_func;    /* For the ROW_COUNT() function */
1279
1421
  ha_rows    cuted_fields;
1280
1422
 
1281
1423
  /*
1297
1439
  */
1298
1440
  table_map  used_tables;
1299
1441
  USER_CONN *user_connect;
1300
 
  const CHARSET_INFO *db_charset;
 
1442
  CHARSET_INFO *db_charset;
1301
1443
  /*
1302
1444
    FIXME: this, and some other variables like 'count_cuted_fields'
1303
1445
    maybe should be statement/cursor local, that is, moved to Statement
1304
1446
    class. With current implementation warnings produced in each prepared
1305
1447
    statement/cursor settle here.
1306
1448
  */
1307
 
  List       <DRIZZLE_ERROR> warn_list;
1308
 
  uint       warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_END];
 
1449
  List       <MYSQL_ERROR> warn_list;
 
1450
  uint       warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_END];
1309
1451
  uint       total_warn_count;
1310
1452
  Diagnostics_area main_da;
1311
1453
 
1336
1478
  uint       tmp_table, global_read_lock;
1337
1479
  uint       server_status,open_options;
1338
1480
  enum enum_thread_type system_thread;
1339
 
  uint32_t       select_number;             //number of select (used for EXPLAIN)
 
1481
  uint       select_number;             //number of select (used for EXPLAIN)
1340
1482
  /* variables.transaction_isolation is reset to this after each commit */
1341
1483
  enum_tx_isolation session_tx_isolation;
1342
1484
  enum_check_fields count_cuted_fields;
1364
1506
  bool       last_cuted_field;
1365
1507
  bool       no_errors, password;
1366
1508
  /**
1367
 
    Set to true if execution of the current compound statement
 
1509
    Set to TRUE if execution of the current compound statement
1368
1510
    can not continue. In particular, disables activation of
1369
1511
    CONTINUE or EXIT handlers of stored routines.
1370
1512
    Reset in the end of processing of the current user request, in
1378
1520
  */
1379
1521
  bool       transaction_rollback_request;
1380
1522
  /**
1381
 
    true if we are in a sub-statement and the current error can
 
1523
    TRUE if we are in a sub-statement and the current error can
1382
1524
    not be safely recovered until we left the sub-statement mode.
1383
1525
    In particular, disables activation of CONTINUE and EXIT
1384
1526
    handlers inside sub-statements. E.g. if it is a deadlock
1386
1528
    raised (traditionally, MySQL first has to close all the reads
1387
1529
    via @see handler::ha_index_or_rnd_end() and only then perform
1388
1530
    the rollback).
1389
 
    Reset to false when we leave the sub-statement mode.
 
1531
    Reset to FALSE when we leave the sub-statement mode.
1390
1532
  */
1391
1533
  bool       is_fatal_sub_stmt_error;
1392
1534
  bool       query_start_used, rand_used, time_zone_used;
1400
1542
    it returned an error on master, and this is OK on the slave.
1401
1543
  */
1402
1544
  bool       is_slave_error;
1403
 
  bool       cleanup_done;
 
1545
  bool       bootstrap, cleanup_done;
1404
1546
  
1405
1547
  /**  is set if some thread specific value(s) used in a statement. */
1406
1548
  bool       thread_specific_used;
1407
1549
  bool       charset_is_system_charset, charset_is_collation_connection;
1408
1550
  bool       charset_is_character_set_filesystem;
 
1551
  bool       enable_slow_log;   /* enable slow log for current statement */
1409
1552
  bool       abort_on_warning;
1410
1553
  bool       got_warning;       /* Set on call to push_warning() */
1411
1554
  bool       no_warnings_for_error; /* no warnings on call to my_error() */
1412
1555
  /* set during loop of derived table processing */
1413
1556
  bool       derived_tables_processing;
1414
 
  bool    tablespace_op;        /* This is true in DISCARD/IMPORT TABLESPACE */
 
1557
  my_bool    tablespace_op;     /* This is TRUE in DISCARD/IMPORT TABLESPACE */
1415
1558
 
1416
1559
  /*
1417
1560
    If we do a purge of binary logs, log index info of the threads
1423
1566
  /* Used by the sys_var class to store temporary values */
1424
1567
  union
1425
1568
  {
1426
 
    bool   bool_value;
 
1569
    my_bool   my_bool_value;
1427
1570
    long      long_value;
1428
1571
    ulong     ulong_value;
1429
 
    uint64_t uint64_t_value;
 
1572
    ulonglong ulonglong_value;
1430
1573
  } sys_var_tmp;
1431
1574
  
1432
1575
  struct {
1437
1580
    */
1438
1581
    bool do_union;
1439
1582
    /*
1440
 
      If true, at least one mysql_bin_log::write(Log_event) call has been
 
1583
      If TRUE, at least one mysql_bin_log::write(Log_event) call has been
1441
1584
      made after last mysql_bin_log.start_union_events() call.
1442
1585
    */
1443
1586
    bool unioned_events;
1444
1587
    /*
1445
 
      If true, at least one mysql_bin_log::write(Log_event e), where 
1446
 
      e.cache_stmt == true call has been made after last 
 
1588
      If TRUE, at least one mysql_bin_log::write(Log_event e), where 
 
1589
      e.cache_stmt == TRUE call has been made after last 
1447
1590
      mysql_bin_log.start_union_events() call.
1448
1591
    */
1449
1592
    bool unioned_events_trans;
1464
1607
  */
1465
1608
  Lex_input_stream *m_lip;
1466
1609
 
 
1610
  /*
 
1611
    @todo The following is a work around for online backup and the DDL blocker.
 
1612
          It should be removed when the generalized solution is in place.
 
1613
          This is needed to ensure the restore (which uses DDL) is not blocked
 
1614
          when the DDL blocker is engaged.
 
1615
  */
 
1616
  my_bool DDL_exception; // Allow some DDL if there is an exception
 
1617
 
1467
1618
  THD();
1468
1619
  ~THD();
1469
1620
 
1482
1633
  void cleanup(void);
1483
1634
  void cleanup_after_query();
1484
1635
  bool store_globals();
 
1636
#ifdef SIGNAL_WITH_VIO_CLOSE
 
1637
  inline void set_active_vio(Vio* vio)
 
1638
  {
 
1639
    pthread_mutex_lock(&LOCK_delete);
 
1640
    active_vio = vio;
 
1641
    pthread_mutex_unlock(&LOCK_delete);
 
1642
  }
 
1643
  inline void clear_active_vio()
 
1644
  {
 
1645
    pthread_mutex_lock(&LOCK_delete);
 
1646
    active_vio = 0;
 
1647
    pthread_mutex_unlock(&LOCK_delete);
 
1648
  }
 
1649
  void close_active_vio();
 
1650
#endif
1485
1651
  void awake(THD::killed_state state_to_set);
1486
1652
 
 
1653
#ifndef MYSQL_CLIENT
1487
1654
  enum enum_binlog_query_type {
1488
1655
    /*
1489
1656
      The query can be logged row-based or statement-based
1499
1666
      The query represents a change to a table in the "mysql"
1500
1667
      database and is currently mapped to ROW_QUERY_TYPE.
1501
1668
    */
1502
 
    DRIZZLE_QUERY_TYPE,
 
1669
    MYSQL_QUERY_TYPE,
1503
1670
    QUERY_TYPE_COUNT
1504
1671
  };
1505
1672
  
1507
1674
                   char const *query, ulong query_len,
1508
1675
                   bool is_trans, bool suppress_use,
1509
1676
                   THD::killed_state killed_err_arg= THD::KILLED_NO_VALUE);
 
1677
#endif
1510
1678
 
1511
1679
  /*
1512
1680
    For enter_cond() / exit_cond() to work the mutex must be got before
1520
1688
    safe_mutex_assert_owner(mutex);
1521
1689
    mysys_var->current_mutex = mutex;
1522
1690
    mysys_var->current_cond = cond;
1523
 
    this->set_proc_info(msg);
 
1691
    thd_proc_info(this, msg);
1524
1692
    return old_msg;
1525
1693
  }
1526
1694
  inline void exit_cond(const char* old_msg)
1535
1703
    pthread_mutex_lock(&mysys_var->mutex);
1536
1704
    mysys_var->current_mutex = 0;
1537
1705
    mysys_var->current_cond = 0;
1538
 
    this->set_proc_info(old_msg);
 
1706
    thd_proc_info(this, old_msg);
1539
1707
    pthread_mutex_unlock(&mysys_var->mutex);
1540
1708
  }
1541
1709
  inline time_t query_start() { query_start_used=1; return start_time; }
1556
1724
    start_utime= utime_after_lock= my_micro_time();
1557
1725
  }
1558
1726
  void set_time_after_lock()  { utime_after_lock= my_micro_time(); }
1559
 
  uint64_t current_utime()  { return my_micro_time(); }
1560
 
  inline uint64_t found_rows(void)
 
1727
  ulonglong current_utime()  { return my_micro_time(); }
 
1728
  inline ulonglong found_rows(void)
1561
1729
  {
1562
1730
    return limit_found_rows;
1563
1731
  }
1575
1743
  }
1576
1744
 
1577
1745
  LEX_STRING *make_lex_string(LEX_STRING *lex_str,
1578
 
                              const char* str, uint32_t length,
 
1746
                              const char* str, uint length,
1579
1747
                              bool allocate_lex_string);
1580
1748
 
1581
 
  bool convert_string(LEX_STRING *to, const CHARSET_INFO * const to_cs,
1582
 
                      const char *from, uint32_t from_length,
1583
 
                      const CHARSET_INFO * const from_cs);
1584
 
 
1585
 
  bool convert_string(String *s, const CHARSET_INFO * const from_cs, const CHARSET_INFO * const to_cs);
1586
 
 
1587
 
  void add_changed_table(Table *table);
 
1749
  bool convert_string(LEX_STRING *to, CHARSET_INFO *to_cs,
 
1750
                      const char *from, uint from_length,
 
1751
                      CHARSET_INFO *from_cs);
 
1752
 
 
1753
  bool convert_string(String *s, CHARSET_INFO *from_cs, CHARSET_INFO *to_cs);
 
1754
 
 
1755
  void add_changed_table(TABLE *table);
1588
1756
  void add_changed_table(const char *key, long key_length);
1589
 
  CHANGED_TableList * changed_table_dup(const char *key, long key_length);
 
1757
  CHANGED_TABLE_LIST * changed_table_dup(const char *key, long key_length);
1590
1758
  int send_explain_fields(select_result *result);
1591
1759
  /**
1592
1760
    Clear the current error, if any.
1597
1765
  */
1598
1766
  inline void clear_error()
1599
1767
  {
 
1768
    DBUG_ENTER("clear_error");
1600
1769
    if (main_da.is_error())
1601
1770
      main_da.reset_diagnostics_area();
1602
1771
    is_slave_error= 0;
1603
 
    return;
 
1772
    DBUG_VOID_RETURN;
1604
1773
  }
1605
1774
  inline bool vio_ok() const { return net.vio != 0; }
1606
 
 
 
1775
  /** Return FALSE if connection to client is broken. */
 
1776
  bool vio_is_connected();
1607
1777
  /**
1608
1778
    Mark the current error as fatal. Warning: this does not
1609
1779
    set any error, it sets a property of the error, so must be
1611
1781
  */
1612
1782
  inline void fatal_error()
1613
1783
  {
1614
 
    assert(main_da.is_error());
 
1784
    DBUG_ASSERT(main_da.is_error());
1615
1785
    is_fatal_error= 1;
 
1786
    DBUG_PRINT("error",("Fatal error set"));
1616
1787
  }
1617
1788
  /**
1618
 
    true if there is an error in the error stack.
 
1789
    TRUE if there is an error in the error stack.
1619
1790
 
1620
1791
    Please use this method instead of direct access to
1621
1792
    net.report_error.
1622
1793
 
1623
 
    If true, the current (sub)-statement should be aborted.
 
1794
    If TRUE, the current (sub)-statement should be aborted.
1624
1795
    The main difference between this member and is_fatal_error
1625
1796
    is that a fatal error can not be handled by a stored
1626
1797
    procedure continue handler, whereas a normal error can.
1628
1799
    To raise this flag, use my_error().
1629
1800
  */
1630
1801
  inline bool is_error() const { return main_da.is_error(); }
1631
 
  inline const CHARSET_INFO *charset() { return variables.character_set_client; }
 
1802
  inline CHARSET_INFO *charset() { return variables.character_set_client; }
1632
1803
  void update_charset();
1633
1804
 
1634
1805
  void change_item_tree(Item **place, Item *new_value)
1635
1806
  {
 
1807
    /* TODO: check for OOM condition here */
 
1808
    if (!stmt_arena->is_conventional())
 
1809
      nocheck_register_item_tree_change(place, *place, mem_root);
1636
1810
    *place= new_value;
1637
1811
  }
1638
1812
  void nocheck_register_item_tree_change(Item **place, Item *old_value,
1649
1823
    killed_state killed_val; /* to cache the volatile 'killed' */
1650
1824
    return (killed_val= killed) != KILL_BAD_DATA ? killed_val : 0;
1651
1825
  }
1652
 
  void send_kill_message() const;
1653
 
  /* return true if we will abort query if we make a warning now */
 
1826
  inline void send_kill_message() const
 
1827
  {
 
1828
    int err= killed_errno();
 
1829
    if (err)
 
1830
      my_message(err, ER(err), MYF(0));
 
1831
  }
 
1832
  /* return TRUE if we will abort query if we make a warning now */
1654
1833
  inline bool really_abort_on_warning()
1655
1834
  {
1656
1835
    return (abort_on_warning);
1657
1836
  }
1658
1837
  void set_status_var_init();
 
1838
  bool is_context_analysis_only()
 
1839
    { return lex->view_prepare_mode; }
1659
1840
  void reset_n_backup_open_tables_state(Open_tables_state *backup);
1660
1841
  void restore_backup_open_tables_state(Open_tables_state *backup);
 
1842
  void restore_sub_statement_state(Sub_statement_state *backup);
 
1843
  void set_n_backup_active_arena(Query_arena *set, Query_arena *backup);
 
1844
  void restore_active_arena(Query_arena *set, Query_arena *backup);
1661
1845
 
1662
1846
  inline void set_current_stmt_binlog_row_based_if_mixed()
1663
1847
  {
1664
 
    if (variables.binlog_format == BINLOG_FORMAT_MIXED)
1665
 
      current_stmt_binlog_row_based= true;
 
1848
    /*
 
1849
      If in a stored/function trigger, the caller should already have done the
 
1850
      change. We test in_sub_stmt to prevent introducing bugs where people
 
1851
      wouldn't ensure that, and would switch to row-based mode in the middle
 
1852
      of executing a stored function/trigger (which is too late, see also
 
1853
      reset_current_stmt_binlog_row_based()); this condition will make their
 
1854
      tests fail and so force them to propagate the
 
1855
      lex->binlog_row_based_if_mixed upwards to the caller.
 
1856
    */
 
1857
    if ((variables.binlog_format == BINLOG_FORMAT_MIXED) &&
 
1858
        (in_sub_stmt == 0))
 
1859
      current_stmt_binlog_row_based= TRUE;
1666
1860
  }
1667
1861
  inline void set_current_stmt_binlog_row_based()
1668
1862
  {
1669
 
    current_stmt_binlog_row_based= true;
 
1863
    current_stmt_binlog_row_based= TRUE;
1670
1864
  }
1671
1865
  inline void clear_current_stmt_binlog_row_based()
1672
1866
  {
1673
 
    current_stmt_binlog_row_based= false;
 
1867
    current_stmt_binlog_row_based= FALSE;
1674
1868
  }
1675
1869
  inline void reset_current_stmt_binlog_row_based()
1676
1870
  {
1680
1874
      CREATE TEMPORARY TABLE t SELECT UUID(); # row-based
1681
1875
      # and row-based does not store updates to temp tables
1682
1876
      # in the binlog.
 
1877
      INSERT INTO u SELECT * FROM t; # stmt-based
 
1878
      and then the INSERT will fail as data inserted into t was not logged.
 
1879
      So we continue with row-based until the temp table is dropped.
 
1880
      If we are in a stored function or trigger, we mustn't reset in the
 
1881
      middle of its execution (as the binary logging way of a stored function
 
1882
      or trigger is decided when it starts executing, depending for example on
 
1883
      the caller (for a stored function: if caller is SELECT or
 
1884
      INSERT/UPDATE/DELETE...).
1683
1885
 
1684
1886
      Don't reset binlog format for NDB binlog injector thread.
1685
1887
    */
1686
 
    if (temporary_tables == NULL)
 
1888
    if ((temporary_tables == NULL) && (in_sub_stmt == 0) &&
 
1889
        (system_thread != SYSTEM_THREAD_NDBCLUSTER_BINLOG))
1687
1890
    {
1688
1891
      current_stmt_binlog_row_based= 
1689
1892
        test(variables.binlog_format == BINLOG_FORMAT_ROW);
1698
1901
 
1699
1902
    Initialize the current database from a NULL-terminated string with
1700
1903
    length. If we run out of memory, we free the current database and
1701
 
    return true.  This way the user will notice the error as there will be
 
1904
    return TRUE.  This way the user will notice the error as there will be
1702
1905
    no current database selected (in addition to the error message set by
1703
1906
    malloc).
1704
1907
 
1708
1911
    will be made private and more convenient interface will be provided.
1709
1912
 
1710
1913
    @return Operation status
1711
 
      @retval false Success
1712
 
      @retval true  Out-of-memory error
 
1914
      @retval FALSE Success
 
1915
      @retval TRUE  Out-of-memory error
1713
1916
  */
1714
1917
  bool set_db(const char *new_db, size_t new_db_len)
1715
1918
  {
1718
1921
      memcpy(db, new_db, new_db_len+1);
1719
1922
    else
1720
1923
    {
1721
 
      if (db)
1722
 
        free(db);
 
1924
      x_free(db);
1723
1925
      if (new_db)
1724
1926
        db= my_strndup(new_db, new_db_len, MYF(MY_WME | ME_FATALERROR));
1725
1927
      else
1750
1952
    allocate memory for a deep copy: current database may be freed after
1751
1953
    a statement is parsed but before it's executed.
1752
1954
  */
1753
 
  bool copy_db_to(char **p_db, size_t *p_db_length);
 
1955
  bool copy_db_to(char **p_db, size_t *p_db_length)
 
1956
  {
 
1957
    if (db == NULL)
 
1958
    {
 
1959
      my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
 
1960
      return TRUE;
 
1961
    }
 
1962
    *p_db= strmake(db, db_length);
 
1963
    *p_db_length= db_length;
 
1964
    return FALSE;
 
1965
  }
1754
1966
  thd_scheduler scheduler;
1755
1967
 
1756
1968
public:
1766
1978
    @param level the error level
1767
1979
    @return true if the error is handled
1768
1980
  */
1769
 
  virtual bool handle_error(uint32_t sql_errno, const char *message,
1770
 
                            DRIZZLE_ERROR::enum_warning_level level);
 
1981
  virtual bool handle_error(uint sql_errno, const char *message,
 
1982
                            MYSQL_ERROR::enum_warning_level level);
1771
1983
 
1772
1984
  /**
1773
1985
    Remove the error handler last pushed.
1775
1987
  void pop_internal_handler();
1776
1988
 
1777
1989
private:
1778
 
  const char *proc_info;
1779
 
 
1780
1990
  /** The current internal error handler for this thread, or NULL. */
1781
1991
  Internal_error_handler *m_internal_handler;
1782
1992
  /**
1801
2011
/** A short cut for thd->main_da.set_ok_status(). */
1802
2012
 
1803
2013
inline void
1804
 
my_ok(THD *thd, ha_rows affected_rows= 0, uint64_t id= 0,
 
2014
my_ok(THD *thd, ha_rows affected_rows= 0, ulonglong id= 0,
1805
2015
        const char *message= NULL)
1806
2016
{
1807
2017
  thd->main_da.set_ok_status(thd, affected_rows, id, message);
1817
2027
}
1818
2028
 
1819
2029
#define tmp_disable_binlog(A)       \
1820
 
  {uint64_t tmp_disable_binlog__save_options= (A)->options; \
 
2030
  {ulonglong tmp_disable_binlog__save_options= (A)->options; \
1821
2031
  (A)->options&= ~OPTION_BIN_LOG
1822
2032
 
1823
2033
#define reenable_binlog(A)   (A)->options= tmp_disable_binlog__save_options;}
1838
2048
  bool opt_enclosed;
1839
2049
  bool dumpfile;
1840
2050
  ulong skip_lines;
1841
 
  const CHARSET_INFO *cs;
 
2051
  CHARSET_INFO *cs;
1842
2052
  sql_exchange(char *name, bool dumpfile_flag,
1843
2053
               enum_filetype filetype_arg= FILETYPE_CSV);
1844
2054
};
1858
2068
public:
1859
2069
  select_result();
1860
2070
  virtual ~select_result() {};
1861
 
  virtual int prepare(List<Item> &list __attribute__((unused)),
1862
 
                      SELECT_LEX_UNIT *u)
 
2071
  virtual int prepare(List<Item> &list, SELECT_LEX_UNIT *u)
1863
2072
  {
1864
2073
    unit= u;
1865
2074
    return 0;
1870
2079
    we need to know number of columns in the result set (if
1871
2080
    there is a result set) apart from sending columns metadata.
1872
2081
  */
1873
 
  virtual uint32_t field_count(List<Item> &fields) const
 
2082
  virtual uint field_count(List<Item> &fields) const
1874
2083
  { return fields.elements; }
1875
 
  virtual bool send_fields(List<Item> &list, uint32_t flags)=0;
 
2084
  virtual bool send_fields(List<Item> &list, uint flags)=0;
1876
2085
  virtual bool send_data(List<Item> &items)=0;
1877
 
  virtual bool initialize_tables (JOIN  __attribute__((unused)) *join=0)
1878
 
  { return 0; }
1879
 
  virtual void send_error(uint32_t errcode,const char *err);
 
2086
  virtual bool initialize_tables (JOIN *join=0) { return 0; }
 
2087
  virtual void send_error(uint errcode,const char *err);
1880
2088
  virtual bool send_eof()=0;
1881
2089
  /**
1882
2090
    Check if this query returns a result set and therefore is allowed in
1883
2091
    cursors and set an error message if it is not the case.
1884
2092
 
1885
 
    @retval false     success
1886
 
    @retval true      error, an error message is set
 
2093
    @retval FALSE     success
 
2094
    @retval TRUE      error, an error message is set
1887
2095
  */
1888
2096
  virtual bool check_simple_select() const;
1889
2097
  virtual void abort() {}
1907
2115
{
1908
2116
public:
1909
2117
  select_result_interceptor() {}              /* Remove gcc warning */
1910
 
  uint32_t field_count(List<Item> &fields __attribute__((unused))) const
1911
 
  { return 0; }
1912
 
  bool send_fields(List<Item> &fields __attribute__((unused)),
1913
 
                   uint32_t flag __attribute__((unused))) { return false; }
 
2118
  uint field_count(List<Item> &fields) const { return 0; }
 
2119
  bool send_fields(List<Item> &fields, uint flag) { return FALSE; }
1914
2120
};
1915
2121
 
1916
2122
 
1922
2128
  */
1923
2129
  bool is_result_set_started;
1924
2130
public:
1925
 
  select_send() :is_result_set_started(false) {}
1926
 
  bool send_fields(List<Item> &list, uint32_t flags);
 
2131
  select_send() :is_result_set_started(FALSE) {}
 
2132
  bool send_fields(List<Item> &list, uint flags);
1927
2133
  bool send_data(List<Item> &items);
1928
2134
  bool send_eof();
1929
 
  virtual bool check_simple_select() const { return false; }
 
2135
  virtual bool check_simple_select() const { return FALSE; }
1930
2136
  void abort();
1931
2137
  virtual void cleanup();
1932
2138
};
1944
2150
  select_to_file(sql_exchange *ex) :exchange(ex), file(-1),row_count(0L)
1945
2151
  { path[0]=0; }
1946
2152
  ~select_to_file();
1947
 
  void send_error(uint32_t errcode,const char *err);
 
2153
  void send_error(uint errcode,const char *err);
1948
2154
  bool send_eof();
1949
2155
  void cleanup();
1950
2156
};
1960
2166
 
1961
2167
 
1962
2168
class select_export :public select_to_file {
1963
 
  uint32_t field_term_length;
 
2169
  uint field_term_length;
1964
2170
  int field_sep_char,escape_char,line_sep_char;
1965
2171
  int field_term_char; // first char of FIELDS TERMINATED BY or MAX_INT
1966
2172
  /*
2000
2206
 
2001
2207
class select_insert :public select_result_interceptor {
2002
2208
 public:
2003
 
  TableList *table_list;
2004
 
  Table *table;
 
2209
  TABLE_LIST *table_list;
 
2210
  TABLE *table;
2005
2211
  List<Item> *fields;
2006
 
  uint64_t autoinc_value_of_last_inserted_row; // autogenerated or not
 
2212
  ulonglong autoinc_value_of_last_inserted_row; // autogenerated or not
2007
2213
  COPY_INFO info;
2008
2214
  bool insert_into_view;
2009
 
  select_insert(TableList *table_list_par,
2010
 
                Table *table_par, List<Item> *fields_par,
 
2215
  select_insert(TABLE_LIST *table_list_par,
 
2216
                TABLE *table_par, List<Item> *fields_par,
2011
2217
                List<Item> *update_fields, List<Item> *update_values,
2012
2218
                enum_duplicates duplic, bool ignore);
2013
2219
  ~select_insert();
2016
2222
  bool send_data(List<Item> &items);
2017
2223
  virtual void store_values(List<Item> &values);
2018
2224
  virtual bool can_rollback_data() { return 0; }
2019
 
  void send_error(uint32_t errcode,const char *err);
 
2225
  void send_error(uint errcode,const char *err);
2020
2226
  bool send_eof();
2021
2227
  void abort();
2022
2228
  /* not implemented: select_insert is never re-used in prepared statements */
2025
2231
 
2026
2232
 
2027
2233
class select_create: public select_insert {
2028
 
  order_st *group;
2029
 
  TableList *create_table;
 
2234
  ORDER *group;
 
2235
  TABLE_LIST *create_table;
2030
2236
  HA_CREATE_INFO *create_info;
2031
 
  TableList *select_tables;
 
2237
  TABLE_LIST *select_tables;
2032
2238
  Alter_info *alter_info;
2033
2239
  Field **field;
2034
2240
  /* lock data for tmp table */
2035
 
  DRIZZLE_LOCK *m_lock;
 
2241
  MYSQL_LOCK *m_lock;
2036
2242
  /* m_lock or thd->extra_lock */
2037
 
  DRIZZLE_LOCK **m_plock;
 
2243
  MYSQL_LOCK **m_plock;
2038
2244
public:
2039
 
  select_create (TableList *table_arg,
 
2245
  select_create (TABLE_LIST *table_arg,
2040
2246
                 HA_CREATE_INFO *create_info_par,
2041
2247
                 Alter_info *alter_info_arg,
2042
2248
                 List<Item> &select_fields,enum_duplicates duplic, bool ignore,
2043
 
                 TableList *select_tables_arg)
 
2249
                 TABLE_LIST *select_tables_arg)
2044
2250
    :select_insert (NULL, NULL, &select_fields, 0, 0, duplic, ignore),
2045
2251
    create_table(table_arg),
2046
2252
    create_info(create_info_par),
2050
2256
    {}
2051
2257
  int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
2052
2258
 
2053
 
  void binlog_show_create_table(Table **tables, uint32_t count);
 
2259
  void binlog_show_create_table(TABLE **tables, uint count);
2054
2260
  void store_values(List<Item> &values);
2055
 
  void send_error(uint32_t errcode,const char *err);
 
2261
  void send_error(uint errcode,const char *err);
2056
2262
  bool send_eof();
2057
2263
  void abort();
2058
2264
  virtual bool can_rollback_data() { return 1; }
2063
2269
  int prepare2(void) { return 0; }
2064
2270
};
2065
2271
 
2066
 
#include <storage/myisam/myisam.h>
 
2272
#include <myisam.h>
2067
2273
 
2068
2274
/* 
2069
2275
  Param to create temporary tables when doing SELECT:s 
2083
2289
  List<Item> save_copy_funcs;
2084
2290
  Copy_field *copy_field, *copy_field_end;
2085
2291
  Copy_field *save_copy_field, *save_copy_field_end;
2086
 
  unsigned char     *group_buff;
 
2292
  uchar     *group_buff;
2087
2293
  Item      **items_to_copy;                    /* Fields in tmp table */
2088
2294
  MI_COLUMNDEF *recinfo,*start_recinfo;
2089
2295
  KEY *keyinfo;
2090
2296
  ha_rows end_write_records;
2091
2297
  uint  field_count,sum_func_count,func_count;
2092
 
  uint32_t  hidden_field_count;
 
2298
  uint  hidden_field_count;
2093
2299
  uint  group_parts,group_length,group_null_parts;
2094
2300
  uint  quick_group;
2095
2301
  bool  using_indirect_summary_function;
2096
2302
  /* If >0 convert all blob fields to varchar(convert_blob_length) */
2097
 
  uint32_t  convert_blob_length; 
2098
 
  const CHARSET_INFO *table_charset; 
 
2303
  uint  convert_blob_length; 
 
2304
  CHARSET_INFO *table_charset; 
2099
2305
  bool schema_table;
2100
2306
  /*
2101
2307
    True if GROUP BY and its aggregate functions are already computed
2106
2312
  bool precomputed_group_by;
2107
2313
  bool force_copy_fields;
2108
2314
  /*
2109
 
    If true, create_tmp_field called from create_tmp_table will convert
 
2315
    If TRUE, create_tmp_field called from create_tmp_table will convert
2110
2316
    all BIT fields to 64-bit longs. This is a workaround the limitation
2111
2317
    that MEMORY tables cannot index BIT columns.
2112
2318
  */
2137
2343
{
2138
2344
  TMP_TABLE_PARAM tmp_table_param;
2139
2345
public:
2140
 
  Table *table;
 
2346
  TABLE *table;
2141
2347
 
2142
2348
  select_union() :table(0) {}
2143
2349
  int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
2146
2352
  bool flush();
2147
2353
  void cleanup();
2148
2354
  bool create_result_table(THD *thd, List<Item> *column_types,
2149
 
                           bool is_distinct, uint64_t options,
 
2355
                           bool is_distinct, ulonglong options,
2150
2356
                           const char *alias, bool bit_fields_as_long);
2151
2357
};
2152
2358
 
2204
2410
  Field *field;                         /* Field to sort */
2205
2411
  Item  *item;                          /* Item if not sorting fields */
2206
2412
  uint   length;                        /* Length of sort field */
2207
 
  uint32_t   suffix_length;                 /* Length suffix (0-4) */
 
2413
  uint   suffix_length;                 /* Length suffix (0-4) */
2208
2414
  Item_result result_type;              /* Type of item */
2209
2415
  bool reverse;                         /* if descending sort */
2210
2416
  bool need_strxnfrm;                   /* If we have to use strxnfrm() */
2212
2418
 
2213
2419
 
2214
2420
typedef struct st_sort_buffer {
2215
 
  uint32_t index;                                       /* 0 or 1 */
2216
 
  uint32_t sort_orders;
2217
 
  uint32_t change_pos;                          /* If sort-fields changed */
 
2421
  uint index;                                   /* 0 or 1 */
 
2422
  uint sort_orders;
 
2423
  uint change_pos;                              /* If sort-fields changed */
2218
2424
  char **buff;
2219
2425
  SORT_FIELD *sortorder;
2220
2426
} SORT_BUFFER;
2274
2480
  Item_result type;
2275
2481
  bool unsigned_flag;
2276
2482
 
2277
 
  double val_real(bool *null_value);
2278
 
  int64_t val_int(bool *null_value) const;
2279
 
  String *val_str(bool *null_value, String *str, uint32_t decimals);
2280
 
  my_decimal *val_decimal(bool *null_value, my_decimal *result);
 
2483
  double val_real(my_bool *null_value);
 
2484
  longlong val_int(my_bool *null_value) const;
 
2485
  String *val_str(my_bool *null_value, String *str, uint decimals);
 
2486
  my_decimal *val_decimal(my_bool *null_value, my_decimal *result);
2281
2487
  DTCollation collation;
2282
2488
};
2283
2489
 
2293
2499
{
2294
2500
  DYNAMIC_ARRAY file_ptrs;
2295
2501
  ulong max_elements;
2296
 
  uint64_t max_in_memory_size;
 
2502
  ulonglong max_in_memory_size;
2297
2503
  IO_CACHE file;
2298
2504
  TREE tree;
2299
 
  unsigned char *record_pointers;
 
2505
  uchar *record_pointers;
2300
2506
  bool flush();
2301
 
  uint32_t size;
 
2507
  uint size;
2302
2508
 
2303
2509
public:
2304
2510
  ulong elements;
2305
2511
  Unique(qsort_cmp2 comp_func, void *comp_func_fixed_arg,
2306
 
         uint32_t size_arg, uint64_t max_in_memory_size_arg);
 
2512
         uint size_arg, ulonglong max_in_memory_size_arg);
2307
2513
  ~Unique();
2308
2514
  ulong elements_in_tree() { return tree.elements_in_tree; }
2309
2515
  inline bool unique_add(void *ptr)
2310
2516
  {
 
2517
    DBUG_ENTER("unique_add");
 
2518
    DBUG_PRINT("info", ("tree %u - %lu", tree.elements_in_tree, max_elements));
2311
2519
    if (tree.elements_in_tree > max_elements && flush())
2312
 
      return(1);
2313
 
    return(!tree_insert(&tree, ptr, 0, tree.custom_arg));
 
2520
      DBUG_RETURN(1);
 
2521
    DBUG_RETURN(!tree_insert(&tree, ptr, 0, tree.custom_arg));
2314
2522
  }
2315
2523
 
2316
 
  bool get(Table *table);
2317
 
  static double get_use_cost(uint32_t *buffer, uint32_t nkeys, uint32_t key_size, 
2318
 
                             uint64_t max_in_memory_size);
2319
 
  inline static int get_cost_calc_buff_size(ulong nkeys, uint32_t key_size, 
2320
 
                                            uint64_t max_in_memory_size)
 
2524
  bool get(TABLE *table);
 
2525
  static double get_use_cost(uint *buffer, uint nkeys, uint key_size, 
 
2526
                             ulonglong max_in_memory_size);
 
2527
  inline static int get_cost_calc_buff_size(ulong nkeys, uint key_size, 
 
2528
                                            ulonglong max_in_memory_size)
2321
2529
  {
2322
 
    register uint64_t max_elems_in_tree=
 
2530
    register ulonglong max_elems_in_tree=
2323
2531
      (1 + max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+key_size));
2324
2532
    return (int) (sizeof(uint)*(1 + nkeys/max_elems_in_tree));
2325
2533
  }
2327
2535
  void reset();
2328
2536
  bool walk(tree_walk_action action, void *walk_action_arg);
2329
2537
 
2330
 
  friend int unique_write_to_file(unsigned char* key, element_count count, Unique *unique);
2331
 
  friend int unique_write_to_ptrs(unsigned char* key, element_count count, Unique *unique);
 
2538
  friend int unique_write_to_file(uchar* key, element_count count, Unique *unique);
 
2539
  friend int unique_write_to_ptrs(uchar* key, element_count count, Unique *unique);
2332
2540
};
2333
2541
 
2334
2542
 
2335
2543
class multi_delete :public select_result_interceptor
2336
2544
{
2337
 
  TableList *delete_tables, *table_being_deleted;
 
2545
  TABLE_LIST *delete_tables, *table_being_deleted;
2338
2546
  Unique **tempfiles;
2339
2547
  ha_rows deleted, found;
2340
 
  uint32_t num_of_tables;
 
2548
  uint num_of_tables;
2341
2549
  int error;
2342
2550
  bool do_delete;
2343
2551
  /* True if at least one table we delete from is transactional */
2352
2560
  bool error_handled;
2353
2561
 
2354
2562
public:
2355
 
  multi_delete(TableList *dt, uint32_t num_of_tables);
 
2563
  multi_delete(TABLE_LIST *dt, uint num_of_tables);
2356
2564
  ~multi_delete();
2357
2565
  int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
2358
2566
  bool send_data(List<Item> &items);
2359
2567
  bool initialize_tables (JOIN *join);
2360
 
  void send_error(uint32_t errcode,const char *err);
 
2568
  void send_error(uint errcode,const char *err);
2361
2569
  int  do_deletes();
2362
2570
  bool send_eof();
2363
2571
  virtual void abort();
2366
2574
 
2367
2575
class multi_update :public select_result_interceptor
2368
2576
{
2369
 
  TableList *all_tables; /* query/update command tables */
2370
 
  TableList *leaves;     /* list of leves of join table tree */
2371
 
  TableList *update_tables, *table_being_updated;
2372
 
  Table **tmp_tables, *main_table, *table_to_update;
 
2577
  TABLE_LIST *all_tables; /* query/update command tables */
 
2578
  TABLE_LIST *leaves;     /* list of leves of join table tree */
 
2579
  TABLE_LIST *update_tables, *table_being_updated;
 
2580
  TABLE **tmp_tables, *main_table, *table_to_update;
2373
2581
  TMP_TABLE_PARAM *tmp_table_param;
2374
2582
  ha_rows updated, found;
2375
2583
  List <Item> *fields, *values;
2376
2584
  List <Item> **fields_for_table, **values_for_table;
2377
 
  uint32_t table_count;
 
2585
  uint table_count;
2378
2586
  /*
2379
2587
   List of tables referenced in the CHECK OPTION condition of
2380
2588
   the updated view excluding the updated table. 
2381
2589
  */
2382
 
  List <Table> unupdated_check_opt_tables;
 
2590
  List <TABLE> unupdated_check_opt_tables;
2383
2591
  Copy_field *copy_field;
2384
2592
  enum enum_duplicates handle_duplicates;
2385
2593
  bool do_update, trans_safe;
2393
2601
  bool error_handled;
2394
2602
 
2395
2603
public:
2396
 
  multi_update(TableList *ut, TableList *leaves_list,
 
2604
  multi_update(TABLE_LIST *ut, TABLE_LIST *leaves_list,
2397
2605
               List<Item> *fields, List<Item> *values,
2398
2606
               enum_duplicates handle_duplicates, bool ignore);
2399
2607
  ~multi_update();
2400
2608
  int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
2401
2609
  bool send_data(List<Item> &items);
2402
2610
  bool initialize_tables (JOIN *join);
2403
 
  void send_error(uint32_t errcode,const char *err);
 
2611
  void send_error(uint errcode,const char *err);
2404
2612
  int  do_updates();
2405
2613
  bool send_eof();
2406
2614
  virtual void abort();
2410
2618
public:
2411
2619
  LEX_STRING s;
2412
2620
  bool local;
2413
 
  uint32_t offset;
 
2621
  uint offset;
2414
2622
  enum_field_types type;
2415
 
  my_var (LEX_STRING& j, bool i, uint32_t o, enum_field_types t)
 
2623
  my_var (LEX_STRING& j, bool i, uint o, enum_field_types t)
2416
2624
    :s(j), local(i), offset(o), type(t)
2417
2625
  {}
2418
2626
  ~my_var() {}
2445
2653
 
2446
2654
void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var,
2447
2655
                        STATUS_VAR *dec_var);
 
2656
void mark_transaction_to_rollback(THD *thd, bool all);
2448
2657
 
2449
 
#endif /* DRIZZLE_SERVER */
 
2658
#endif /* MYSQL_SERVER */