~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/sql_class.h

Merge from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
233
233
  LEX_COLUMN (const String& x,const  uint& y ): column (x),rights (y) {}
234
234
};
235
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
236
#include "sql_lex.h"                            /* Must be here */
258
237
 
259
238
class select_result;
280
259
  uint dynamic_variables_head;  /* largest valid variable offset */
281
260
  uint dynamic_variables_size;  /* how many bytes are in use */
282
261
  
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;
 
262
  uint64_t myisam_max_extra_sort_file_size;
 
263
  uint64_t myisam_max_sort_file_size;
 
264
  uint64_t max_heap_table_size;
 
265
  uint64_t tmp_table_size;
 
266
  uint64_t long_query_time;
288
267
  ha_rows select_limit;
289
268
  ha_rows max_join_size;
290
269
  ulong auto_increment_increment, auto_increment_offset;
350
329
    compatibility option:
351
330
      - index usage hints (USE INDEX without a FOR clause) behave as in 5.0 
352
331
  */
353
 
  my_bool old_mode;
354
 
  my_bool query_cache_wlock_invalidate;
 
332
  bool old_mode;
355
333
  my_bool engine_condition_pushdown;
356
334
  my_bool keep_files_on_create;
357
335
 
387
365
 
388
366
typedef struct system_status_var
389
367
{
390
 
  ulonglong bytes_received;
391
 
  ulonglong bytes_sent;
 
368
  uint64_t bytes_received;
 
369
  uint64_t bytes_sent;
392
370
  ulong com_other;
393
371
  ulong com_stat[(uint) SQLCOM_END];
394
372
  ulong created_tmp_disk_tables;
814
792
class Sub_statement_state
815
793
{
816
794
public:
817
 
  ulonglong options;
818
 
  ulonglong first_successful_insert_id_in_prev_stmt;
819
 
  ulonglong first_successful_insert_id_in_cur_stmt, insert_id_for_cur_row;
 
795
  uint64_t options;
 
796
  uint64_t first_successful_insert_id_in_prev_stmt;
 
797
  uint64_t first_successful_insert_id_in_cur_stmt, insert_id_for_cur_row;
820
798
  Discrete_interval auto_inc_interval_for_cur_row;
821
799
  Discrete_intervals_list auto_inc_intervals_forced;
822
 
  ulonglong limit_found_rows;
 
800
  uint64_t limit_found_rows;
823
801
  ha_rows    cuted_fields, sent_row_count, examined_row_count;
824
802
  ulong client_capabilities;
825
803
  uint in_sub_stmt;
832
810
/* Flags for the THD::system_thread variable */
833
811
enum enum_thread_type
834
812
{
835
 
  NON_SYSTEM_THREAD= 0,
836
 
  SYSTEM_THREAD_DELAYED_INSERT= 1,
837
 
  SYSTEM_THREAD_SLAVE_IO= 2,
838
 
  SYSTEM_THREAD_SLAVE_SQL= 4,
839
 
  SYSTEM_THREAD_NDBCLUSTER_BINLOG= 8,
840
 
  SYSTEM_THREAD_EVENT_SCHEDULER= 16,
841
 
  SYSTEM_THREAD_EVENT_WORKER= 32,
842
 
  SYSTEM_THREAD_BACKUP= 64
 
813
  NON_SYSTEM_THREAD,
 
814
  SYSTEM_THREAD_SLAVE_IO,
 
815
  SYSTEM_THREAD_SLAVE_SQL
843
816
};
844
817
 
845
818
 
916
889
  bool can_overwrite_status;
917
890
 
918
891
  void set_ok_status(THD *thd, ha_rows affected_rows_arg,
919
 
                     ulonglong last_insert_id_arg,
 
892
                     uint64_t last_insert_id_arg,
920
893
                     const char *message);
921
894
  void set_eof_status(THD *thd);
922
895
  void set_error_status(THD *thd, uint sql_errno_arg, const char *message_arg);
947
920
  ha_rows affected_rows() const
948
921
  { assert(m_status == DA_OK); return m_affected_rows; }
949
922
 
950
 
  ulonglong last_insert_id() const
 
923
  uint64_t last_insert_id() const
951
924
  { assert(m_status == DA_OK); return m_last_insert_id; }
952
925
 
953
926
  uint total_warn_count() const
993
966
    thd->first_successful_insert_id_in_prev_stmt, which is used
994
967
    to implement LAST_INSERT_ID().
995
968
  */
996
 
  ulonglong   m_last_insert_id;
 
969
  uint64_t   m_last_insert_id;
997
970
  /** The total number of warnings. */
998
971
  uint       m_total_warn_count;
999
972
  enum_diagnostics_status m_status;
1140
1113
  /* remote (peer) port */
1141
1114
  uint16 peer_port;
1142
1115
  time_t     start_time, user_time;
1143
 
  ulonglong  connect_utime, thr_create_utime; // track down slow pthread_create
1144
 
  ulonglong  start_utime, utime_after_lock;
 
1116
  uint64_t  connect_utime, thr_create_utime; // track down slow pthread_create
 
1117
  uint64_t  start_utime, utime_after_lock;
1145
1118
  
1146
1119
  thr_lock_type update_lock_default;
1147
1120
 
1276
1249
    It can also be set by SET LAST_INSERT_ID=# or SELECT LAST_INSERT_ID(#).
1277
1250
    It is returned by LAST_INSERT_ID().
1278
1251
  */
1279
 
  ulonglong  first_successful_insert_id_in_prev_stmt;
 
1252
  uint64_t  first_successful_insert_id_in_prev_stmt;
1280
1253
  /*
1281
1254
    Variant of the above, used for storing in statement-based binlog. The
1282
1255
    difference is that the one above can change as the execution of a stored
1283
1256
    function progresses, while the one below is set once and then does not
1284
1257
    change (which is the value which statement-based binlog needs).
1285
1258
  */
1286
 
  ulonglong  first_successful_insert_id_in_prev_stmt_for_binlog;
 
1259
  uint64_t  first_successful_insert_id_in_prev_stmt_for_binlog;
1287
1260
  /*
1288
1261
    This is the first autogenerated insert id which was *successfully*
1289
1262
    inserted by the current statement. It is maintained only to set
1290
1263
    first_successful_insert_id_in_prev_stmt when statement ends.
1291
1264
  */
1292
 
  ulonglong  first_successful_insert_id_in_cur_stmt;
 
1265
  uint64_t  first_successful_insert_id_in_cur_stmt;
1293
1266
  /*
1294
1267
    We follow this logic:
1295
1268
    - when stmt starts, first_successful_insert_id_in_prev_stmt contains the
1369
1342
    mode, row-based binlogging is used for such cases where two
1370
1343
    auto_increment columns are inserted.
1371
1344
  */
1372
 
  inline void record_first_successful_insert_id_in_cur_stmt(ulonglong id_arg)
 
1345
  inline void record_first_successful_insert_id_in_cur_stmt(uint64_t id_arg)
1373
1346
  {
1374
1347
    if (first_successful_insert_id_in_cur_stmt == 0)
1375
1348
      first_successful_insert_id_in_cur_stmt= id_arg;
1376
1349
  }
1377
 
  inline ulonglong read_first_successful_insert_id_in_prev_stmt(void)
 
1350
  inline uint64_t read_first_successful_insert_id_in_prev_stmt(void)
1378
1351
  {
1379
1352
    if (!stmt_depends_on_first_successful_insert_id_in_prev_stmt)
1380
1353
    {
1390
1363
    (mysqlbinlog). We'll soon add a variant which can take many intervals in
1391
1364
    argument.
1392
1365
  */
1393
 
  inline void force_one_auto_inc_interval(ulonglong next_id)
 
1366
  inline void force_one_auto_inc_interval(uint64_t next_id)
1394
1367
  {
1395
1368
    auto_inc_intervals_forced.empty(); // in case of multiple SET INSERT_ID
1396
 
    auto_inc_intervals_forced.append(next_id, ULONGLONG_MAX, 0);
 
1369
    auto_inc_intervals_forced.append(next_id, UINT64_MAX, 0);
1397
1370
  }
1398
1371
 
1399
 
  ulonglong  limit_found_rows;
1400
 
  ulonglong  options;           /* Bitmap of states */
1401
 
  longlong   row_count_func;    /* For the ROW_COUNT() function */
 
1372
  uint64_t  limit_found_rows;
 
1373
  uint64_t  options;           /* Bitmap of states */
 
1374
  int64_t   row_count_func;    /* For the ROW_COUNT() function */
1402
1375
  ha_rows    cuted_fields;
1403
1376
 
1404
1377
  /*
1550
1523
    my_bool   my_bool_value;
1551
1524
    long      long_value;
1552
1525
    ulong     ulong_value;
1553
 
    ulonglong ulonglong_value;
 
1526
    uint64_t uint64_t_value;
1554
1527
  } sys_var_tmp;
1555
1528
  
1556
1529
  struct {
1705
1678
    start_utime= utime_after_lock= my_micro_time();
1706
1679
  }
1707
1680
  void set_time_after_lock()  { utime_after_lock= my_micro_time(); }
1708
 
  ulonglong current_utime()  { return my_micro_time(); }
1709
 
  inline ulonglong found_rows(void)
 
1681
  uint64_t current_utime()  { return my_micro_time(); }
 
1682
  inline uint64_t found_rows(void)
1710
1683
  {
1711
1684
    return limit_found_rows;
1712
1685
  }
1864
1837
 
1865
1838
      Don't reset binlog format for NDB binlog injector thread.
1866
1839
    */
1867
 
    if ((temporary_tables == NULL) && (in_sub_stmt == 0) &&
1868
 
        (system_thread != SYSTEM_THREAD_NDBCLUSTER_BINLOG))
 
1840
    if ((temporary_tables == NULL) && (in_sub_stmt == 0))
1869
1841
    {
1870
1842
      current_stmt_binlog_row_based= 
1871
1843
        test(variables.binlog_format == BINLOG_FORMAT_ROW);
1990
1962
/** A short cut for thd->main_da.set_ok_status(). */
1991
1963
 
1992
1964
inline void
1993
 
my_ok(THD *thd, ha_rows affected_rows= 0, ulonglong id= 0,
 
1965
my_ok(THD *thd, ha_rows affected_rows= 0, uint64_t id= 0,
1994
1966
        const char *message= NULL)
1995
1967
{
1996
1968
  thd->main_da.set_ok_status(thd, affected_rows, id, message);
2006
1978
}
2007
1979
 
2008
1980
#define tmp_disable_binlog(A)       \
2009
 
  {ulonglong tmp_disable_binlog__save_options= (A)->options; \
 
1981
  {uint64_t tmp_disable_binlog__save_options= (A)->options; \
2010
1982
  (A)->options&= ~OPTION_BIN_LOG
2011
1983
 
2012
1984
#define reenable_binlog(A)   (A)->options= tmp_disable_binlog__save_options;}
2192
2164
  TABLE_LIST *table_list;
2193
2165
  TABLE *table;
2194
2166
  List<Item> *fields;
2195
 
  ulonglong autoinc_value_of_last_inserted_row; // autogenerated or not
 
2167
  uint64_t autoinc_value_of_last_inserted_row; // autogenerated or not
2196
2168
  COPY_INFO info;
2197
2169
  bool insert_into_view;
2198
2170
  select_insert(TABLE_LIST *table_list_par,
2335
2307
  bool flush();
2336
2308
  void cleanup();
2337
2309
  bool create_result_table(THD *thd, List<Item> *column_types,
2338
 
                           bool is_distinct, ulonglong options,
 
2310
                           bool is_distinct, uint64_t options,
2339
2311
                           const char *alias, bool bit_fields_as_long);
2340
2312
};
2341
2313
 
2464
2436
  bool unsigned_flag;
2465
2437
 
2466
2438
  double val_real(my_bool *null_value);
2467
 
  longlong val_int(my_bool *null_value) const;
 
2439
  int64_t val_int(my_bool *null_value) const;
2468
2440
  String *val_str(my_bool *null_value, String *str, uint decimals);
2469
2441
  my_decimal *val_decimal(my_bool *null_value, my_decimal *result);
2470
2442
  DTCollation collation;
2482
2454
{
2483
2455
  DYNAMIC_ARRAY file_ptrs;
2484
2456
  ulong max_elements;
2485
 
  ulonglong max_in_memory_size;
 
2457
  uint64_t max_in_memory_size;
2486
2458
  IO_CACHE file;
2487
2459
  TREE tree;
2488
2460
  uchar *record_pointers;
2492
2464
public:
2493
2465
  ulong elements;
2494
2466
  Unique(qsort_cmp2 comp_func, void *comp_func_fixed_arg,
2495
 
         uint size_arg, ulonglong max_in_memory_size_arg);
 
2467
         uint size_arg, uint64_t max_in_memory_size_arg);
2496
2468
  ~Unique();
2497
2469
  ulong elements_in_tree() { return tree.elements_in_tree; }
2498
2470
  inline bool unique_add(void *ptr)
2504
2476
 
2505
2477
  bool get(TABLE *table);
2506
2478
  static double get_use_cost(uint *buffer, uint nkeys, uint key_size, 
2507
 
                             ulonglong max_in_memory_size);
 
2479
                             uint64_t max_in_memory_size);
2508
2480
  inline static int get_cost_calc_buff_size(ulong nkeys, uint key_size, 
2509
 
                                            ulonglong max_in_memory_size)
 
2481
                                            uint64_t max_in_memory_size)
2510
2482
  {
2511
 
    register ulonglong max_elems_in_tree=
 
2483
    register uint64_t max_elems_in_tree=
2512
2484
      (1 + max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+key_size));
2513
2485
    return (int) (sizeof(uint)*(1 + nkeys/max_elems_in_tree));
2514
2486
  }