~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/sql_class.h

Removed/replaced DBUG symbols and standardized TRUE/FALSE

Show diffs side-by-side

added added

removed removed

Lines of Context:
262
262
#define THD_SENTRY_MAGIC 0xfeedd1ff
263
263
#define THD_SENTRY_GONE  0xdeadbeef
264
264
 
265
 
#define THD_CHECK_SENTRY(thd) DBUG_ASSERT(thd->dbug_sentry == THD_SENTRY_MAGIC)
 
265
#define THD_CHECK_SENTRY(thd) assert(thd->dbug_sentry == THD_SENTRY_MAGIC)
266
266
 
267
267
struct system_variables
268
268
{
468
468
 
469
469
#ifdef MYSQL_SERVER
470
470
 
471
 
 
472
 
/* The following macro is to make init of Query_arena simpler */
473
 
#ifndef DBUG_OFF
474
471
#define INIT_ARENA_DBUG_INFO is_backup_arena= 0
475
 
#else
476
 
#define INIT_ARENA_DBUG_INFO
477
 
#endif
478
472
 
479
473
class Query_arena
480
474
{
485
479
  */
486
480
  Item *free_list;
487
481
  MEM_ROOT *mem_root;                   // Pointer to current memroot
488
 
#ifndef DBUG_OFF
489
482
  bool is_backup_arena; /* True if this arena is used for backup. */
490
 
#endif
 
483
 
491
484
  /*
492
485
    The states relfects three diffrent life cycles for three
493
486
    different types of statements:
940
933
  enum_diagnostics_status status() const { return m_status; }
941
934
 
942
935
  const char *message() const
943
 
  { DBUG_ASSERT(m_status == DA_ERROR || m_status == DA_OK); return m_message; }
 
936
  { assert(m_status == DA_ERROR || m_status == DA_OK); return m_message; }
944
937
 
945
938
  uint sql_errno() const
946
 
  { DBUG_ASSERT(m_status == DA_ERROR); return m_sql_errno; }
 
939
  { assert(m_status == DA_ERROR); return m_sql_errno; }
947
940
 
948
941
  uint server_status() const
949
942
  {
950
 
    DBUG_ASSERT(m_status == DA_OK || m_status == DA_EOF);
 
943
    assert(m_status == DA_OK || m_status == DA_EOF);
951
944
    return m_server_status;
952
945
  }
953
946
 
954
947
  ha_rows affected_rows() const
955
 
  { DBUG_ASSERT(m_status == DA_OK); return m_affected_rows; }
 
948
  { assert(m_status == DA_OK); return m_affected_rows; }
956
949
 
957
950
  ulonglong last_insert_id() const
958
 
  { DBUG_ASSERT(m_status == DA_OK); return m_last_insert_id; }
 
951
  { assert(m_status == DA_OK); return m_last_insert_id; }
959
952
 
960
953
  uint total_warn_count() const
961
954
  {
962
 
    DBUG_ASSERT(m_status == DA_OK || m_status == DA_EOF);
 
955
    assert(m_status == DA_OK || m_status == DA_EOF);
963
956
    return m_total_warn_count;
964
957
  }
965
958
 
1110
1103
    Set it using the  thd_proc_info(THD *thread, const char *message)
1111
1104
    macro/function.
1112
1105
  */
1113
 
#ifndef DBUG_OFF
1114
 
  #define THD_SET_PROC_INFO(thd, info) \
1115
 
    (thd)->set_proc_info(__FILE__, __LINE__, (info))
1116
 
 
1117
 
  void set_proc_info(const char* file, int line, const char* info);
1118
 
#else
1119
 
  #define THD_SET_PROC_INFO(thd, info) \
 
1106
#define THD_SET_PROC_INFO(thd, info) \
1120
1107
    (thd)->proc_info= (info)
1121
 
#endif
1122
1108
 
1123
1109
  inline const char* get_proc_info() { return proc_info;}
1124
1110
 
1142
1128
    points to a lock object if the lock is present. See item_func.cc and
1143
1129
    chapter 'Miscellaneous functions', for functions GET_LOCK, RELEASE_LOCK. 
1144
1130
  */
1145
 
#ifndef DBUG_OFF
1146
1131
  uint dbug_sentry; // watch out for memory corruption
1147
 
#endif
1148
1132
  struct st_my_thread_var *mysys_var;
1149
1133
  /*
1150
1134
    Type of current query: COM_STMT_PREPARE, COM_QUERY, etc. Set from
1503
1487
  bool       last_cuted_field;
1504
1488
  bool       no_errors, password;
1505
1489
  /**
1506
 
    Set to TRUE if execution of the current compound statement
 
1490
    Set to true if execution of the current compound statement
1507
1491
    can not continue. In particular, disables activation of
1508
1492
    CONTINUE or EXIT handlers of stored routines.
1509
1493
    Reset in the end of processing of the current user request, in
1517
1501
  */
1518
1502
  bool       transaction_rollback_request;
1519
1503
  /**
1520
 
    TRUE if we are in a sub-statement and the current error can
 
1504
    true if we are in a sub-statement and the current error can
1521
1505
    not be safely recovered until we left the sub-statement mode.
1522
1506
    In particular, disables activation of CONTINUE and EXIT
1523
1507
    handlers inside sub-statements. E.g. if it is a deadlock
1525
1509
    raised (traditionally, MySQL first has to close all the reads
1526
1510
    via @see handler::ha_index_or_rnd_end() and only then perform
1527
1511
    the rollback).
1528
 
    Reset to FALSE when we leave the sub-statement mode.
 
1512
    Reset to false when we leave the sub-statement mode.
1529
1513
  */
1530
1514
  bool       is_fatal_sub_stmt_error;
1531
1515
  bool       query_start_used, rand_used, time_zone_used;
1551
1535
  bool       no_warnings_for_error; /* no warnings on call to my_error() */
1552
1536
  /* set during loop of derived table processing */
1553
1537
  bool       derived_tables_processing;
1554
 
  bool    tablespace_op;        /* This is TRUE in DISCARD/IMPORT TABLESPACE */
 
1538
  bool    tablespace_op;        /* This is true in DISCARD/IMPORT TABLESPACE */
1555
1539
 
1556
1540
  /*
1557
1541
    If we do a purge of binary logs, log index info of the threads
1577
1561
    */
1578
1562
    bool do_union;
1579
1563
    /*
1580
 
      If TRUE, at least one mysql_bin_log::write(Log_event) call has been
 
1564
      If true, at least one mysql_bin_log::write(Log_event) call has been
1581
1565
      made after last mysql_bin_log.start_union_events() call.
1582
1566
    */
1583
1567
    bool unioned_events;
1584
1568
    /*
1585
 
      If TRUE, at least one mysql_bin_log::write(Log_event e), where 
1586
 
      e.cache_stmt == TRUE call has been made after last 
 
1569
      If true, at least one mysql_bin_log::write(Log_event e), where 
 
1570
      e.cache_stmt == true call has been made after last 
1587
1571
      mysql_bin_log.start_union_events() call.
1588
1572
    */
1589
1573
    bool unioned_events_trans;
1762
1746
  */
1763
1747
  inline void clear_error()
1764
1748
  {
1765
 
    DBUG_ENTER("clear_error");
1766
1749
    if (main_da.is_error())
1767
1750
      main_da.reset_diagnostics_area();
1768
1751
    is_slave_error= 0;
1769
 
    DBUG_VOID_RETURN;
 
1752
    return;
1770
1753
  }
1771
1754
  inline bool vio_ok() const { return net.vio != 0; }
1772
 
  /** Return FALSE if connection to client is broken. */
 
1755
  /** Return false if connection to client is broken. */
1773
1756
  bool vio_is_connected();
1774
1757
  /**
1775
1758
    Mark the current error as fatal. Warning: this does not
1778
1761
  */
1779
1762
  inline void fatal_error()
1780
1763
  {
1781
 
    DBUG_ASSERT(main_da.is_error());
 
1764
    assert(main_da.is_error());
1782
1765
    is_fatal_error= 1;
1783
 
    DBUG_PRINT("error",("Fatal error set"));
1784
1766
  }
1785
1767
  /**
1786
 
    TRUE if there is an error in the error stack.
 
1768
    true if there is an error in the error stack.
1787
1769
 
1788
1770
    Please use this method instead of direct access to
1789
1771
    net.report_error.
1790
1772
 
1791
 
    If TRUE, the current (sub)-statement should be aborted.
 
1773
    If true, the current (sub)-statement should be aborted.
1792
1774
    The main difference between this member and is_fatal_error
1793
1775
    is that a fatal error can not be handled by a stored
1794
1776
    procedure continue handler, whereas a normal error can.
1826
1808
    if (err)
1827
1809
      my_message(err, ER(err), MYF(0));
1828
1810
  }
1829
 
  /* return TRUE if we will abort query if we make a warning now */
 
1811
  /* return true if we will abort query if we make a warning now */
1830
1812
  inline bool really_abort_on_warning()
1831
1813
  {
1832
1814
    return (abort_on_warning);
1853
1835
    */
1854
1836
    if ((variables.binlog_format == BINLOG_FORMAT_MIXED) &&
1855
1837
        (in_sub_stmt == 0))
1856
 
      current_stmt_binlog_row_based= TRUE;
 
1838
      current_stmt_binlog_row_based= true;
1857
1839
  }
1858
1840
  inline void set_current_stmt_binlog_row_based()
1859
1841
  {
1860
 
    current_stmt_binlog_row_based= TRUE;
 
1842
    current_stmt_binlog_row_based= true;
1861
1843
  }
1862
1844
  inline void clear_current_stmt_binlog_row_based()
1863
1845
  {
1864
 
    current_stmt_binlog_row_based= FALSE;
 
1846
    current_stmt_binlog_row_based= false;
1865
1847
  }
1866
1848
  inline void reset_current_stmt_binlog_row_based()
1867
1849
  {
1898
1880
 
1899
1881
    Initialize the current database from a NULL-terminated string with
1900
1882
    length. If we run out of memory, we free the current database and
1901
 
    return TRUE.  This way the user will notice the error as there will be
 
1883
    return true.  This way the user will notice the error as there will be
1902
1884
    no current database selected (in addition to the error message set by
1903
1885
    malloc).
1904
1886
 
1908
1890
    will be made private and more convenient interface will be provided.
1909
1891
 
1910
1892
    @return Operation status
1911
 
      @retval FALSE Success
1912
 
      @retval TRUE  Out-of-memory error
 
1893
      @retval false Success
 
1894
      @retval true  Out-of-memory error
1913
1895
  */
1914
1896
  bool set_db(const char *new_db, size_t new_db_len)
1915
1897
  {
1954
1936
    if (db == NULL)
1955
1937
    {
1956
1938
      my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
1957
 
      return TRUE;
 
1939
      return true;
1958
1940
    }
1959
1941
    *p_db= strmake(db, db_length);
1960
1942
    *p_db_length= db_length;
1961
 
    return FALSE;
 
1943
    return false;
1962
1944
  }
1963
1945
  thd_scheduler scheduler;
1964
1946
 
2089
2071
    Check if this query returns a result set and therefore is allowed in
2090
2072
    cursors and set an error message if it is not the case.
2091
2073
 
2092
 
    @retval FALSE     success
2093
 
    @retval TRUE      error, an error message is set
 
2074
    @retval false     success
 
2075
    @retval true      error, an error message is set
2094
2076
  */
2095
2077
  virtual bool check_simple_select() const;
2096
2078
  virtual void abort() {}
2117
2099
  uint field_count(List<Item> &fields __attribute__((__unused__))) const
2118
2100
  { return 0; }
2119
2101
  bool send_fields(List<Item> &fields __attribute__((__unused__)),
2120
 
                   uint flag __attribute__((__unused__))) { return FALSE; }
 
2102
                   uint flag __attribute__((__unused__))) { return false; }
2121
2103
};
2122
2104
 
2123
2105
 
2129
2111
  */
2130
2112
  bool is_result_set_started;
2131
2113
public:
2132
 
  select_send() :is_result_set_started(FALSE) {}
 
2114
  select_send() :is_result_set_started(false) {}
2133
2115
  bool send_fields(List<Item> &list, uint flags);
2134
2116
  bool send_data(List<Item> &items);
2135
2117
  bool send_eof();
2136
 
  virtual bool check_simple_select() const { return FALSE; }
 
2118
  virtual bool check_simple_select() const { return false; }
2137
2119
  void abort();
2138
2120
  virtual void cleanup();
2139
2121
};
2313
2295
  bool precomputed_group_by;
2314
2296
  bool force_copy_fields;
2315
2297
  /*
2316
 
    If TRUE, create_tmp_field called from create_tmp_table will convert
 
2298
    If true, create_tmp_field called from create_tmp_table will convert
2317
2299
    all BIT fields to 64-bit longs. This is a workaround the limitation
2318
2300
    that MEMORY tables cannot index BIT columns.
2319
2301
  */
2515
2497
  ulong elements_in_tree() { return tree.elements_in_tree; }
2516
2498
  inline bool unique_add(void *ptr)
2517
2499
  {
2518
 
    DBUG_ENTER("unique_add");
2519
 
    DBUG_PRINT("info", ("tree %u - %lu", tree.elements_in_tree, max_elements));
2520
2500
    if (tree.elements_in_tree > max_elements && flush())
2521
 
      DBUG_RETURN(1);
2522
 
    DBUG_RETURN(!tree_insert(&tree, ptr, 0, tree.custom_arg));
 
2501
      return(1);
 
2502
    return(!tree_insert(&tree, ptr, 0, tree.custom_arg));
2523
2503
  }
2524
2504
 
2525
2505
  bool get(TABLE *table);