~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/sql_class.h

Removed/replaced DBUG symbols and TRUE/FALSE

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
 
236
257
#include "sql_lex.h"                            /* Must be here */
237
258
 
238
259
class select_result;
259
280
  uint dynamic_variables_head;  /* largest valid variable offset */
260
281
  uint dynamic_variables_size;  /* how many bytes are in use */
261
282
  
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;
 
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;
267
288
  ha_rows select_limit;
268
289
  ha_rows max_join_size;
269
290
  ulong auto_increment_increment, auto_increment_offset;
323
344
  */
324
345
  my_thread_id pseudo_thread_id;
325
346
 
326
 
  bool low_priority_updates;
327
 
  bool new_mode;
 
347
  my_bool low_priority_updates;
 
348
  my_bool new_mode;
328
349
  /* 
329
350
    compatibility option:
330
351
      - index usage hints (USE INDEX without a FOR clause) behave as in 5.0 
331
352
  */
332
 
  bool old_mode;
333
 
  bool engine_condition_pushdown;
334
 
  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;
335
357
 
336
 
  bool old_alter_table;
 
358
  my_bool old_alter_table;
337
359
 
338
360
  plugin_ref table_plugin;
339
361
 
356
378
  DATE_TIME_FORMAT *date_format;
357
379
  DATE_TIME_FORMAT *datetime_format;
358
380
  DATE_TIME_FORMAT *time_format;
359
 
  bool sysdate_is_now;
 
381
  my_bool sysdate_is_now;
360
382
 
361
383
};
362
384
 
365
387
 
366
388
typedef struct system_status_var
367
389
{
368
 
  uint64_t bytes_received;
369
 
  uint64_t bytes_sent;
 
390
  ulonglong bytes_received;
 
391
  ulonglong bytes_sent;
370
392
  ulong com_other;
371
393
  ulong com_stat[(uint) SQLCOM_END];
372
394
  ulong created_tmp_disk_tables;
792
814
class Sub_statement_state
793
815
{
794
816
public:
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;
 
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;
798
820
  Discrete_interval auto_inc_interval_for_cur_row;
799
821
  Discrete_intervals_list auto_inc_intervals_forced;
800
 
  uint64_t limit_found_rows;
 
822
  ulonglong limit_found_rows;
801
823
  ha_rows    cuted_fields, sent_row_count, examined_row_count;
802
824
  ulong client_capabilities;
803
825
  uint in_sub_stmt;
810
832
/* Flags for the THD::system_thread variable */
811
833
enum enum_thread_type
812
834
{
813
 
  NON_SYSTEM_THREAD,
814
 
  SYSTEM_THREAD_SLAVE_IO,
815
 
  SYSTEM_THREAD_SLAVE_SQL
 
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
816
843
};
817
844
 
818
845
 
889
916
  bool can_overwrite_status;
890
917
 
891
918
  void set_ok_status(THD *thd, ha_rows affected_rows_arg,
892
 
                     uint64_t last_insert_id_arg,
 
919
                     ulonglong last_insert_id_arg,
893
920
                     const char *message);
894
921
  void set_eof_status(THD *thd);
895
922
  void set_error_status(THD *thd, uint sql_errno_arg, const char *message_arg);
920
947
  ha_rows affected_rows() const
921
948
  { assert(m_status == DA_OK); return m_affected_rows; }
922
949
 
923
 
  uint64_t last_insert_id() const
 
950
  ulonglong last_insert_id() const
924
951
  { assert(m_status == DA_OK); return m_last_insert_id; }
925
952
 
926
953
  uint total_warn_count() const
966
993
    thd->first_successful_insert_id_in_prev_stmt, which is used
967
994
    to implement LAST_INSERT_ID().
968
995
  */
969
 
  uint64_t   m_last_insert_id;
 
996
  ulonglong   m_last_insert_id;
970
997
  /** The total number of warnings. */
971
998
  uint       m_total_warn_count;
972
999
  enum_diagnostics_status m_status;
1113
1140
  /* remote (peer) port */
1114
1141
  uint16 peer_port;
1115
1142
  time_t     start_time, user_time;
1116
 
  uint64_t  connect_utime, thr_create_utime; // track down slow pthread_create
1117
 
  uint64_t  start_utime, utime_after_lock;
 
1143
  ulonglong  connect_utime, thr_create_utime; // track down slow pthread_create
 
1144
  ulonglong  start_utime, utime_after_lock;
1118
1145
  
1119
1146
  thr_lock_type update_lock_default;
1120
1147
 
1249
1276
    It can also be set by SET LAST_INSERT_ID=# or SELECT LAST_INSERT_ID(#).
1250
1277
    It is returned by LAST_INSERT_ID().
1251
1278
  */
1252
 
  uint64_t  first_successful_insert_id_in_prev_stmt;
 
1279
  ulonglong  first_successful_insert_id_in_prev_stmt;
1253
1280
  /*
1254
1281
    Variant of the above, used for storing in statement-based binlog. The
1255
1282
    difference is that the one above can change as the execution of a stored
1256
1283
    function progresses, while the one below is set once and then does not
1257
1284
    change (which is the value which statement-based binlog needs).
1258
1285
  */
1259
 
  uint64_t  first_successful_insert_id_in_prev_stmt_for_binlog;
 
1286
  ulonglong  first_successful_insert_id_in_prev_stmt_for_binlog;
1260
1287
  /*
1261
1288
    This is the first autogenerated insert id which was *successfully*
1262
1289
    inserted by the current statement. It is maintained only to set
1263
1290
    first_successful_insert_id_in_prev_stmt when statement ends.
1264
1291
  */
1265
 
  uint64_t  first_successful_insert_id_in_cur_stmt;
 
1292
  ulonglong  first_successful_insert_id_in_cur_stmt;
1266
1293
  /*
1267
1294
    We follow this logic:
1268
1295
    - when stmt starts, first_successful_insert_id_in_prev_stmt contains the
1342
1369
    mode, row-based binlogging is used for such cases where two
1343
1370
    auto_increment columns are inserted.
1344
1371
  */
1345
 
  inline void record_first_successful_insert_id_in_cur_stmt(uint64_t id_arg)
 
1372
  inline void record_first_successful_insert_id_in_cur_stmt(ulonglong id_arg)
1346
1373
  {
1347
1374
    if (first_successful_insert_id_in_cur_stmt == 0)
1348
1375
      first_successful_insert_id_in_cur_stmt= id_arg;
1349
1376
  }
1350
 
  inline uint64_t read_first_successful_insert_id_in_prev_stmt(void)
 
1377
  inline ulonglong read_first_successful_insert_id_in_prev_stmt(void)
1351
1378
  {
1352
1379
    if (!stmt_depends_on_first_successful_insert_id_in_prev_stmt)
1353
1380
    {
1363
1390
    (mysqlbinlog). We'll soon add a variant which can take many intervals in
1364
1391
    argument.
1365
1392
  */
1366
 
  inline void force_one_auto_inc_interval(uint64_t next_id)
 
1393
  inline void force_one_auto_inc_interval(ulonglong next_id)
1367
1394
  {
1368
1395
    auto_inc_intervals_forced.empty(); // in case of multiple SET INSERT_ID
1369
 
    auto_inc_intervals_forced.append(next_id, UINT64_MAX, 0);
 
1396
    auto_inc_intervals_forced.append(next_id, ULONGLONG_MAX, 0);
1370
1397
  }
1371
1398
 
1372
 
  uint64_t  limit_found_rows;
1373
 
  uint64_t  options;           /* Bitmap of states */
1374
 
  int64_t   row_count_func;    /* For the ROW_COUNT() function */
 
1399
  ulonglong  limit_found_rows;
 
1400
  ulonglong  options;           /* Bitmap of states */
 
1401
  longlong   row_count_func;    /* For the ROW_COUNT() function */
1375
1402
  ha_rows    cuted_fields;
1376
1403
 
1377
1404
  /*
1520
1547
  /* Used by the sys_var class to store temporary values */
1521
1548
  union
1522
1549
  {
1523
 
    bool   bool_value;
 
1550
    my_bool   my_bool_value;
1524
1551
    long      long_value;
1525
1552
    ulong     ulong_value;
1526
 
    uint64_t uint64_t_value;
 
1553
    ulonglong ulonglong_value;
1527
1554
  } sys_var_tmp;
1528
1555
  
1529
1556
  struct {
1561
1588
  */
1562
1589
  Lex_input_stream *m_lip;
1563
1590
 
 
1591
  /*
 
1592
    @todo The following is a work around for online backup and the DDL blocker.
 
1593
          It should be removed when the generalized solution is in place.
 
1594
          This is needed to ensure the restore (which uses DDL) is not blocked
 
1595
          when the DDL blocker is engaged.
 
1596
  */
 
1597
  my_bool DDL_exception; // Allow some DDL if there is an exception
 
1598
 
1564
1599
  THD();
1565
1600
  ~THD();
1566
1601
 
1670
1705
    start_utime= utime_after_lock= my_micro_time();
1671
1706
  }
1672
1707
  void set_time_after_lock()  { utime_after_lock= my_micro_time(); }
1673
 
  uint64_t current_utime()  { return my_micro_time(); }
1674
 
  inline uint64_t found_rows(void)
 
1708
  ulonglong current_utime()  { return my_micro_time(); }
 
1709
  inline ulonglong found_rows(void)
1675
1710
  {
1676
1711
    return limit_found_rows;
1677
1712
  }
1779
1814
    return (abort_on_warning);
1780
1815
  }
1781
1816
  void set_status_var_init();
 
1817
  bool is_context_analysis_only()
 
1818
    { return lex->view_prepare_mode; }
1782
1819
  void reset_n_backup_open_tables_state(Open_tables_state *backup);
1783
1820
  void restore_backup_open_tables_state(Open_tables_state *backup);
1784
1821
  void restore_sub_statement_state(Sub_statement_state *backup);
1827
1864
 
1828
1865
      Don't reset binlog format for NDB binlog injector thread.
1829
1866
    */
1830
 
    if ((temporary_tables == NULL) && (in_sub_stmt == 0))
 
1867
    if ((temporary_tables == NULL) && (in_sub_stmt == 0) &&
 
1868
        (system_thread != SYSTEM_THREAD_NDBCLUSTER_BINLOG))
1831
1869
    {
1832
1870
      current_stmt_binlog_row_based= 
1833
1871
        test(variables.binlog_format == BINLOG_FORMAT_ROW);
1952
1990
/** A short cut for thd->main_da.set_ok_status(). */
1953
1991
 
1954
1992
inline void
1955
 
my_ok(THD *thd, ha_rows affected_rows= 0, uint64_t id= 0,
 
1993
my_ok(THD *thd, ha_rows affected_rows= 0, ulonglong id= 0,
1956
1994
        const char *message= NULL)
1957
1995
{
1958
1996
  thd->main_da.set_ok_status(thd, affected_rows, id, message);
1968
2006
}
1969
2007
 
1970
2008
#define tmp_disable_binlog(A)       \
1971
 
  {uint64_t tmp_disable_binlog__save_options= (A)->options; \
 
2009
  {ulonglong tmp_disable_binlog__save_options= (A)->options; \
1972
2010
  (A)->options&= ~OPTION_BIN_LOG
1973
2011
 
1974
2012
#define reenable_binlog(A)   (A)->options= tmp_disable_binlog__save_options;}
2154
2192
  TABLE_LIST *table_list;
2155
2193
  TABLE *table;
2156
2194
  List<Item> *fields;
2157
 
  uint64_t autoinc_value_of_last_inserted_row; // autogenerated or not
 
2195
  ulonglong autoinc_value_of_last_inserted_row; // autogenerated or not
2158
2196
  COPY_INFO info;
2159
2197
  bool insert_into_view;
2160
2198
  select_insert(TABLE_LIST *table_list_par,
2297
2335
  bool flush();
2298
2336
  void cleanup();
2299
2337
  bool create_result_table(THD *thd, List<Item> *column_types,
2300
 
                           bool is_distinct, uint64_t options,
 
2338
                           bool is_distinct, ulonglong options,
2301
2339
                           const char *alias, bool bit_fields_as_long);
2302
2340
};
2303
2341
 
2426
2464
  bool unsigned_flag;
2427
2465
 
2428
2466
  double val_real(my_bool *null_value);
2429
 
  int64_t val_int(my_bool *null_value) const;
 
2467
  longlong val_int(my_bool *null_value) const;
2430
2468
  String *val_str(my_bool *null_value, String *str, uint decimals);
2431
2469
  my_decimal *val_decimal(my_bool *null_value, my_decimal *result);
2432
2470
  DTCollation collation;
2444
2482
{
2445
2483
  DYNAMIC_ARRAY file_ptrs;
2446
2484
  ulong max_elements;
2447
 
  uint64_t max_in_memory_size;
 
2485
  ulonglong max_in_memory_size;
2448
2486
  IO_CACHE file;
2449
2487
  TREE tree;
2450
2488
  uchar *record_pointers;
2454
2492
public:
2455
2493
  ulong elements;
2456
2494
  Unique(qsort_cmp2 comp_func, void *comp_func_fixed_arg,
2457
 
         uint size_arg, uint64_t max_in_memory_size_arg);
 
2495
         uint size_arg, ulonglong max_in_memory_size_arg);
2458
2496
  ~Unique();
2459
2497
  ulong elements_in_tree() { return tree.elements_in_tree; }
2460
2498
  inline bool unique_add(void *ptr)
2466
2504
 
2467
2505
  bool get(TABLE *table);
2468
2506
  static double get_use_cost(uint *buffer, uint nkeys, uint key_size, 
2469
 
                             uint64_t max_in_memory_size);
 
2507
                             ulonglong max_in_memory_size);
2470
2508
  inline static int get_cost_calc_buff_size(ulong nkeys, uint key_size, 
2471
 
                                            uint64_t max_in_memory_size)
 
2509
                                            ulonglong max_in_memory_size)
2472
2510
  {
2473
 
    register uint64_t max_elems_in_tree=
 
2511
    register ulonglong max_elems_in_tree=
2474
2512
      (1 + max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+key_size));
2475
2513
    return (int) (sizeof(uint)*(1 + nkeys/max_elems_in_tree));
2476
2514
  }