~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_class.h

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
 
53
53
#define TC_HEURISTIC_RECOVER_COMMIT   1
54
54
#define TC_HEURISTIC_RECOVER_ROLLBACK 2
55
 
extern uint tc_heuristic_recover;
 
55
extern uint32_t tc_heuristic_recover;
56
56
 
57
57
typedef struct st_user_var_events
58
58
{
60
60
  char *value;
61
61
  ulong length;
62
62
  Item_result type;
63
 
  uint charset_number;
 
63
  uint32_t charset_number;
64
64
} BINLOG_USER_VAR_EVENT;
65
65
 
66
66
#define RP_LOCK_LOG_IS_ALREADY_LOCKED 1
98
98
class Key_part_spec :public Sql_alloc {
99
99
public:
100
100
  LEX_STRING field_name;
101
 
  uint length;
102
 
  Key_part_spec(const LEX_STRING &name, uint len)
 
101
  uint32_t length;
 
102
  Key_part_spec(const LEX_STRING &name, uint32_t len)
103
103
    : field_name(name), length(len)
104
104
  {}
105
 
  Key_part_spec(const char *name, const size_t name_len, uint len)
 
105
  Key_part_spec(const char *name, const size_t name_len, uint32_t len)
106
106
    : length(len)
107
107
  { field_name.str= (char *)name; field_name.length= name_len; }
108
108
  bool operator==(const Key_part_spec& other) const;
198
198
 
199
199
  Table_ident *ref_table;
200
200
  List<Key_part_spec> ref_columns;
201
 
  uint delete_opt, update_opt, match_opt;
 
201
  uint32_t delete_opt, update_opt, match_opt;
202
202
  Foreign_key(const LEX_STRING &name_arg, List<Key_part_spec> &cols,
203
203
              Table_ident *table,   List<Key_part_spec> &ref_cols,
204
 
              uint delete_opt_arg, uint update_opt_arg, uint match_opt_arg)
 
204
              uint32_t delete_opt_arg, uint32_t update_opt_arg, uint32_t match_opt_arg)
205
205
    :Key(FOREIGN_KEY, name_arg, &default_key_create_info, 0, cols),
206
206
    ref_table(table), ref_columns(ref_cols),
207
207
    delete_opt(delete_opt_arg), update_opt(update_opt_arg),
219
219
typedef struct st_mysql_lock
220
220
{
221
221
  Table **table;
222
 
  uint table_count,lock_count;
 
222
  uint32_t table_count,lock_count;
223
223
  THR_LOCK_DATA **locks;
224
224
} DRIZZLE_LOCK;
225
225
 
228
228
{
229
229
public:
230
230
  String column;
231
 
  uint rights;
 
231
  uint32_t rights;
232
232
  LEX_COLUMN (const String& x,const  uint& y ): column (x),rights (y) {}
233
233
};
234
234
 
253
253
  */ 
254
254
  ulong dynamic_variables_version;
255
255
  char* dynamic_variables_ptr;
256
 
  uint dynamic_variables_head;  /* largest valid variable offset */
257
 
  uint dynamic_variables_size;  /* how many bytes are in use */
 
256
  uint32_t dynamic_variables_head;  /* largest valid variable offset */
 
257
  uint32_t dynamic_variables_size;  /* how many bytes are in use */
258
258
  
259
259
  uint64_t myisam_max_extra_sort_file_size;
260
260
  uint64_t myisam_max_sort_file_size;
479
479
  { return strmake_root(mem_root,str,size); }
480
480
  inline void *memdup(const void *str, size_t size)
481
481
  { return memdup_root(mem_root,str,size); }
482
 
  inline void *memdup_w_gap(const void *str, size_t size, uint gap)
 
482
  inline void *memdup_w_gap(const void *str, size_t size, uint32_t gap)
483
483
  {
484
484
    void *ptr;
485
485
    if ((ptr= alloc_root(mem_root,size+gap)))
568
568
  */
569
569
 
570
570
  char *db;
571
 
  uint db_length;
 
571
  uint32_t db_length;
572
572
 
573
573
public:
574
574
 
582
582
struct st_savepoint {
583
583
  struct st_savepoint *prev;
584
584
  char                *name;
585
 
  uint                 length;
 
585
  uint32_t                 length;
586
586
  Ha_trx_info         *ha_list;
587
587
};
588
588
 
702
702
  DRIZZLE_LOCK *extra_lock;
703
703
 
704
704
  ulong version;
705
 
  uint current_tablenr;
 
705
  uint32_t current_tablenr;
706
706
 
707
707
  enum enum_flags {
708
708
    BACKUPS_AVAIL = (1U << 0)     /* There are backups available */
711
711
  /*
712
712
    Flags with information about the open tables state.
713
713
  */
714
 
  uint state_flags;
 
714
  uint32_t state_flags;
715
715
 
716
716
  /*
717
717
    This constructor serves for creation of Open_tables_state instances
781
781
    @param thd the calling thread
782
782
    @return true if the error is handled
783
783
  */
784
 
  virtual bool handle_error(uint sql_errno,
 
784
  virtual bool handle_error(uint32_t sql_errno,
785
785
                            const char *message,
786
786
                            DRIZZLE_ERROR::enum_warning_level level,
787
787
                            THD *thd) = 0;
820
820
                     uint64_t last_insert_id_arg,
821
821
                     const char *message);
822
822
  void set_eof_status(THD *thd);
823
 
  void set_error_status(THD *thd, uint sql_errno_arg, const char *message_arg);
 
823
  void set_error_status(THD *thd, uint32_t sql_errno_arg, const char *message_arg);
824
824
 
825
825
  void disable_status();
826
826
 
836
836
  const char *message() const
837
837
  { assert(m_status == DA_ERROR || m_status == DA_OK); return m_message; }
838
838
 
839
 
  uint sql_errno() const
 
839
  uint32_t sql_errno() const
840
840
  { assert(m_status == DA_ERROR); return m_sql_errno; }
841
841
 
842
 
  uint server_status() const
 
842
  uint32_t server_status() const
843
843
  {
844
844
    assert(m_status == DA_OK || m_status == DA_EOF);
845
845
    return m_server_status;
851
851
  uint64_t last_insert_id() const
852
852
  { assert(m_status == DA_OK); return m_last_insert_id; }
853
853
 
854
 
  uint total_warn_count() const
 
854
  uint32_t total_warn_count() const
855
855
  {
856
856
    assert(m_status == DA_OK || m_status == DA_EOF);
857
857
    return m_total_warn_count;
866
866
    SQL error number. One of ER_ codes from share/errmsg.txt.
867
867
    Set by set_error_status.
868
868
  */
869
 
  uint m_sql_errno;
 
869
  uint32_t m_sql_errno;
870
870
 
871
871
  /**
872
872
    Copied from thd->server_status when the diagnostics area is assigned.
876
876
    thd->server_status&= ~...
877
877
    Assigned by OK, EOF or ERROR.
878
878
  */
879
 
  uint m_server_status;
 
879
  uint32_t m_server_status;
880
880
  /**
881
881
    The number of rows affected by the last statement. This is
882
882
    semantically close to thd->row_count_func, but has a different
1024
1024
    points to a lock object if the lock is present. See item_func.cc and
1025
1025
    chapter 'Miscellaneous functions', for functions GET_LOCK, RELEASE_LOCK. 
1026
1026
  */
1027
 
  uint dbug_sentry; // watch out for memory corruption
 
1027
  uint32_t dbug_sentry; // watch out for memory corruption
1028
1028
  struct st_my_thread_var *mysys_var;
1029
1029
  /*
1030
1030
    Type of current query: COM_STMT_PREPARE, COM_QUERY, etc. Set from
1042
1042
  thr_lock_type update_lock_default;
1043
1043
 
1044
1044
  /* <> 0 if we are inside of trigger or stored function. */
1045
 
  uint in_sub_stmt;
 
1045
  uint32_t in_sub_stmt;
1046
1046
 
1047
1047
  /* container for handler's private per-connection data */
1048
1048
  Ha_data ha_data[MAX_HA];
1079
1079
  int binlog_flush_pending_rows_event(bool stmt_end);
1080
1080
 
1081
1081
private:
1082
 
  uint binlog_table_maps; // Number of table maps currently in the binlog
 
1082
  uint32_t binlog_table_maps; // Number of table maps currently in the binlog
1083
1083
 
1084
1084
  enum enum_binlog_flag {
1085
1085
    BINLOG_FLAG_UNSAFE_STMT_PRINTED,
1092
1092
   */
1093
1093
  uint32_t binlog_flags;
1094
1094
public:
1095
 
  uint get_binlog_table_maps() const {
 
1095
  uint32_t get_binlog_table_maps() const {
1096
1096
    return binlog_table_maps;
1097
1097
  }
1098
1098
  void clear_binlog_table_maps() {
1337
1337
  uint       tmp_table, global_read_lock;
1338
1338
  uint       server_status,open_options;
1339
1339
  enum enum_thread_type system_thread;
1340
 
  uint       select_number;             //number of select (used for EXPLAIN)
 
1340
  uint32_t       select_number;             //number of select (used for EXPLAIN)
1341
1341
  /* variables.transaction_isolation is reset to this after each commit */
1342
1342
  enum_tx_isolation session_tx_isolation;
1343
1343
  enum_check_fields count_cuted_fields;
1577
1577
  }
1578
1578
 
1579
1579
  LEX_STRING *make_lex_string(LEX_STRING *lex_str,
1580
 
                              const char* str, uint length,
 
1580
                              const char* str, uint32_t length,
1581
1581
                              bool allocate_lex_string);
1582
1582
 
1583
1583
  bool convert_string(LEX_STRING *to, const CHARSET_INFO * const to_cs,
1584
 
                      const char *from, uint from_length,
 
1584
                      const char *from, uint32_t from_length,
1585
1585
                      const CHARSET_INFO * const from_cs);
1586
1586
 
1587
1587
  bool convert_string(String *s, const CHARSET_INFO * const from_cs, const CHARSET_INFO * const to_cs);
1786
1786
    @param level the error level
1787
1787
    @return true if the error is handled
1788
1788
  */
1789
 
  virtual bool handle_error(uint sql_errno, const char *message,
 
1789
  virtual bool handle_error(uint32_t sql_errno, const char *message,
1790
1790
                            DRIZZLE_ERROR::enum_warning_level level);
1791
1791
 
1792
1792
  /**
1890
1890
    we need to know number of columns in the result set (if
1891
1891
    there is a result set) apart from sending columns metadata.
1892
1892
  */
1893
 
  virtual uint field_count(List<Item> &fields) const
 
1893
  virtual uint32_t field_count(List<Item> &fields) const
1894
1894
  { return fields.elements; }
1895
 
  virtual bool send_fields(List<Item> &list, uint flags)=0;
 
1895
  virtual bool send_fields(List<Item> &list, uint32_t flags)=0;
1896
1896
  virtual bool send_data(List<Item> &items)=0;
1897
1897
  virtual bool initialize_tables (JOIN  __attribute__((unused)) *join=0)
1898
1898
  { return 0; }
1899
 
  virtual void send_error(uint errcode,const char *err);
 
1899
  virtual void send_error(uint32_t errcode,const char *err);
1900
1900
  virtual bool send_eof()=0;
1901
1901
  /**
1902
1902
    Check if this query returns a result set and therefore is allowed in
1927
1927
{
1928
1928
public:
1929
1929
  select_result_interceptor() {}              /* Remove gcc warning */
1930
 
  uint field_count(List<Item> &fields __attribute__((unused))) const
 
1930
  uint32_t field_count(List<Item> &fields __attribute__((unused))) const
1931
1931
  { return 0; }
1932
1932
  bool send_fields(List<Item> &fields __attribute__((unused)),
1933
 
                   uint flag __attribute__((unused))) { return false; }
 
1933
                   uint32_t flag __attribute__((unused))) { return false; }
1934
1934
};
1935
1935
 
1936
1936
 
1943
1943
  bool is_result_set_started;
1944
1944
public:
1945
1945
  select_send() :is_result_set_started(false) {}
1946
 
  bool send_fields(List<Item> &list, uint flags);
 
1946
  bool send_fields(List<Item> &list, uint32_t flags);
1947
1947
  bool send_data(List<Item> &items);
1948
1948
  bool send_eof();
1949
1949
  virtual bool check_simple_select() const { return false; }
1964
1964
  select_to_file(sql_exchange *ex) :exchange(ex), file(-1),row_count(0L)
1965
1965
  { path[0]=0; }
1966
1966
  ~select_to_file();
1967
 
  void send_error(uint errcode,const char *err);
 
1967
  void send_error(uint32_t errcode,const char *err);
1968
1968
  bool send_eof();
1969
1969
  void cleanup();
1970
1970
};
1980
1980
 
1981
1981
 
1982
1982
class select_export :public select_to_file {
1983
 
  uint field_term_length;
 
1983
  uint32_t field_term_length;
1984
1984
  int field_sep_char,escape_char,line_sep_char;
1985
1985
  int field_term_char; // first char of FIELDS TERMINATED BY or MAX_INT
1986
1986
  /*
2036
2036
  bool send_data(List<Item> &items);
2037
2037
  virtual void store_values(List<Item> &values);
2038
2038
  virtual bool can_rollback_data() { return 0; }
2039
 
  void send_error(uint errcode,const char *err);
 
2039
  void send_error(uint32_t errcode,const char *err);
2040
2040
  bool send_eof();
2041
2041
  void abort();
2042
2042
  /* not implemented: select_insert is never re-used in prepared statements */
2070
2070
    {}
2071
2071
  int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
2072
2072
 
2073
 
  void binlog_show_create_table(Table **tables, uint count);
 
2073
  void binlog_show_create_table(Table **tables, uint32_t count);
2074
2074
  void store_values(List<Item> &values);
2075
 
  void send_error(uint errcode,const char *err);
 
2075
  void send_error(uint32_t errcode,const char *err);
2076
2076
  bool send_eof();
2077
2077
  void abort();
2078
2078
  virtual bool can_rollback_data() { return 1; }
2109
2109
  KEY *keyinfo;
2110
2110
  ha_rows end_write_records;
2111
2111
  uint  field_count,sum_func_count,func_count;
2112
 
  uint  hidden_field_count;
 
2112
  uint32_t  hidden_field_count;
2113
2113
  uint  group_parts,group_length,group_null_parts;
2114
2114
  uint  quick_group;
2115
2115
  bool  using_indirect_summary_function;
2116
2116
  /* If >0 convert all blob fields to varchar(convert_blob_length) */
2117
 
  uint  convert_blob_length; 
 
2117
  uint32_t  convert_blob_length; 
2118
2118
  const CHARSET_INFO *table_charset; 
2119
2119
  bool schema_table;
2120
2120
  /*
2224
2224
  Field *field;                         /* Field to sort */
2225
2225
  Item  *item;                          /* Item if not sorting fields */
2226
2226
  uint   length;                        /* Length of sort field */
2227
 
  uint   suffix_length;                 /* Length suffix (0-4) */
 
2227
  uint32_t   suffix_length;                 /* Length suffix (0-4) */
2228
2228
  Item_result result_type;              /* Type of item */
2229
2229
  bool reverse;                         /* if descending sort */
2230
2230
  bool need_strxnfrm;                   /* If we have to use strxnfrm() */
2232
2232
 
2233
2233
 
2234
2234
typedef struct st_sort_buffer {
2235
 
  uint index;                                   /* 0 or 1 */
2236
 
  uint sort_orders;
2237
 
  uint change_pos;                              /* If sort-fields changed */
 
2235
  uint32_t index;                                       /* 0 or 1 */
 
2236
  uint32_t sort_orders;
 
2237
  uint32_t change_pos;                          /* If sort-fields changed */
2238
2238
  char **buff;
2239
2239
  SORT_FIELD *sortorder;
2240
2240
} SORT_BUFFER;
2296
2296
 
2297
2297
  double val_real(bool *null_value);
2298
2298
  int64_t val_int(bool *null_value) const;
2299
 
  String *val_str(bool *null_value, String *str, uint decimals);
 
2299
  String *val_str(bool *null_value, String *str, uint32_t decimals);
2300
2300
  my_decimal *val_decimal(bool *null_value, my_decimal *result);
2301
2301
  DTCollation collation;
2302
2302
};
2318
2318
  TREE tree;
2319
2319
  unsigned char *record_pointers;
2320
2320
  bool flush();
2321
 
  uint size;
 
2321
  uint32_t size;
2322
2322
 
2323
2323
public:
2324
2324
  ulong elements;
2325
2325
  Unique(qsort_cmp2 comp_func, void *comp_func_fixed_arg,
2326
 
         uint size_arg, uint64_t max_in_memory_size_arg);
 
2326
         uint32_t size_arg, uint64_t max_in_memory_size_arg);
2327
2327
  ~Unique();
2328
2328
  ulong elements_in_tree() { return tree.elements_in_tree; }
2329
2329
  inline bool unique_add(void *ptr)
2334
2334
  }
2335
2335
 
2336
2336
  bool get(Table *table);
2337
 
  static double get_use_cost(uint *buffer, uint nkeys, uint key_size, 
 
2337
  static double get_use_cost(uint32_t *buffer, uint32_t nkeys, uint32_t key_size, 
2338
2338
                             uint64_t max_in_memory_size);
2339
 
  inline static int get_cost_calc_buff_size(ulong nkeys, uint key_size, 
 
2339
  inline static int get_cost_calc_buff_size(ulong nkeys, uint32_t key_size, 
2340
2340
                                            uint64_t max_in_memory_size)
2341
2341
  {
2342
2342
    register uint64_t max_elems_in_tree=
2357
2357
  TableList *delete_tables, *table_being_deleted;
2358
2358
  Unique **tempfiles;
2359
2359
  ha_rows deleted, found;
2360
 
  uint num_of_tables;
 
2360
  uint32_t num_of_tables;
2361
2361
  int error;
2362
2362
  bool do_delete;
2363
2363
  /* True if at least one table we delete from is transactional */
2372
2372
  bool error_handled;
2373
2373
 
2374
2374
public:
2375
 
  multi_delete(TableList *dt, uint num_of_tables);
 
2375
  multi_delete(TableList *dt, uint32_t num_of_tables);
2376
2376
  ~multi_delete();
2377
2377
  int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
2378
2378
  bool send_data(List<Item> &items);
2379
2379
  bool initialize_tables (JOIN *join);
2380
 
  void send_error(uint errcode,const char *err);
 
2380
  void send_error(uint32_t errcode,const char *err);
2381
2381
  int  do_deletes();
2382
2382
  bool send_eof();
2383
2383
  virtual void abort();
2394
2394
  ha_rows updated, found;
2395
2395
  List <Item> *fields, *values;
2396
2396
  List <Item> **fields_for_table, **values_for_table;
2397
 
  uint table_count;
 
2397
  uint32_t table_count;
2398
2398
  /*
2399
2399
   List of tables referenced in the CHECK OPTION condition of
2400
2400
   the updated view excluding the updated table. 
2420
2420
  int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
2421
2421
  bool send_data(List<Item> &items);
2422
2422
  bool initialize_tables (JOIN *join);
2423
 
  void send_error(uint errcode,const char *err);
 
2423
  void send_error(uint32_t errcode,const char *err);
2424
2424
  int  do_updates();
2425
2425
  bool send_eof();
2426
2426
  virtual void abort();
2430
2430
public:
2431
2431
  LEX_STRING s;
2432
2432
  bool local;
2433
 
  uint offset;
 
2433
  uint32_t offset;
2434
2434
  enum_field_types type;
2435
 
  my_var (LEX_STRING& j, bool i, uint o, enum_field_types t)
 
2435
  my_var (LEX_STRING& j, bool i, uint32_t o, enum_field_types t)
2436
2436
    :s(j), local(i), offset(o), type(t)
2437
2437
  {}
2438
2438
  ~my_var() {}