~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/log_event.h

  • Committer: Brian Aker
  • Date: 2008-10-20 04:28:21 UTC
  • mto: (492.3.21 drizzle-clean-code)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: brian@tangent.org-20081020042821-rqqdrccuu8195k3y
Second pass of thd cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
429
429
/**
430
430
  @def OPTIONS_WRITTEN_TO_BIN_LOG
431
431
 
432
 
  OPTIONS_WRITTEN_TO_BIN_LOG are the bits of thd->options which must
 
432
  OPTIONS_WRITTEN_TO_BIN_LOG are the bits of session->options which must
433
433
  be written to the binlog. OPTIONS_WRITTEN_TO_BIN_LOG could be
434
434
  written into the Format_description_log_event, so that if later we
435
435
  don't want to replicate a variable we did replicate, or the
436
436
  contrary, it's doable. But it should not be too hard to decide once
437
437
  for all of what we replicate and what we don't, among the fixed 32
438
 
  bits of thd->options.
 
438
  bits of session->options.
439
439
 
440
440
  I (Guilhem) have read through every option's usage, and it looks
441
441
  like OPTION_AUTO_IS_NULL and OPTION_NO_FOREIGN_KEYS are the only
785
785
  */
786
786
  ulong slave_exec_mode;
787
787
 
788
 
  Session* thd;
 
788
  Session* session;
789
789
 
790
790
  Log_event();
791
 
  Log_event(Session* thd_arg, uint16_t flags_arg, bool cache_stmt);
 
791
  Log_event(Session* session_arg, uint16_t flags_arg, bool cache_stmt);
792
792
  /*
793
793
    read_log_event() functions read an event from a binlog or relay
794
794
    log; used by SHOW BINLOG EVENTS, the binlog_dump thread on the
823
823
 
824
824
  virtual const char* get_db()
825
825
  {
826
 
    return thd ? thd->db : 0;
 
826
    return session ? session->db : 0;
827
827
  }
828
828
 
829
829
  static void *operator new(size_t size)
854
854
  { return 0; }
855
855
  inline time_t get_time()
856
856
  {
857
 
    Session *tmp_thd;
 
857
    Session *tmp_session;
858
858
    if (when)
859
859
      return when;
860
 
    if (thd)
861
 
      return thd->start_time;
862
 
    if ((tmp_thd= current_thd))
863
 
      return tmp_thd->start_time;
 
860
    if (session)
 
861
      return session->start_time;
 
862
    if ((tmp_session= current_session))
 
863
      return tmp_session->start_time;
864
864
    return my_time(0);
865
865
  }
866
866
  virtual Log_event_type get_type_code() = 0;
1179
1179
    <td>flags2</td>
1180
1180
    <td>Q_FLAGS2_CODE == 0</td>
1181
1181
    <td>4 byte bitfield</td>
1182
 
    <td>The flags in @c thd->options, binary AND-ed with @c
1183
 
    OPTIONS_WRITTEN_TO_BIN_LOG.  The @c thd->options bitfield contains
 
1182
    <td>The flags in @c session->options, binary AND-ed with @c
 
1183
    OPTIONS_WRITTEN_TO_BIN_LOG.  The @c session->options bitfield contains
1184
1184
    options for "SELECT".  @c OPTIONS_WRITTEN identifies those options
1185
1185
    that need to be written to the binlog (not all do).  Specifically,
1186
1186
    @c OPTIONS_WRITTEN_TO_BIN_LOG equals (@c OPTION_AUTO_IS_NULL | @c
1337
1337
    <td>2 byte integer</td>
1338
1338
 
1339
1339
    <td>The value of the collation_database system variable (in the
1340
 
    source code stored in @c thd->variables.collation_database), which
 
1340
    source code stored in @c session->variables.collation_database), which
1341
1341
    holds the code for a (character set, collation) pair as described
1342
1342
    above (see Q_CHARSET_CODE).
1343
1343
 
1430
1430
 
1431
1431
  /*
1432
1432
    'flags2' is a second set of flags (on top of those in Log_event), for
1433
 
    session variables. These are thd->options which is & against a mask
 
1433
    session variables. These are session->options which is & against a mask
1434
1434
    (OPTIONS_WRITTEN_TO_BIN_LOG).
1435
1435
    flags2_inited helps make a difference between flags2==0 (3.23 or 4.x
1436
1436
    master, we don't know flags2, so use the slave server's global options) and
1452
1452
  uint32_t charset_database_number;
1453
1453
 
1454
1454
 
1455
 
  Query_log_event(Session* thd_arg, const char* query_arg, ulong query_length,
 
1455
  Query_log_event(Session* session_arg, const char* query_arg, ulong query_length,
1456
1456
                  bool using_trans, bool suppress_use,
1457
1457
                  Session::killed_state killed_err_arg= Session::KILLED_NO_VALUE);
1458
1458
  const char* get_db() { return db; }
1551
1551
  std::string master_log;
1552
1552
  uint16_t master_port;
1553
1553
 
1554
 
  Slave_log_event(Session* thd_arg, Relay_log_info* rli);
 
1554
  Slave_log_event(Session* session_arg, Relay_log_info* rli);
1555
1555
  void pack_info(Protocol* protocol);
1556
1556
 
1557
1557
  Slave_log_event(const char* buf, uint32_t event_len);
1815
1815
  String field_lens_buf;
1816
1816
  String fields_buf;
1817
1817
 
1818
 
  Load_log_event(Session* thd, sql_exchange* ex, const char* db_arg,
 
1818
  Load_log_event(Session* session, sql_exchange* ex, const char* db_arg,
1819
1819
                 const char* table_name_arg,
1820
1820
                 List<Item>& fields_arg, enum enum_duplicates handle_dup, bool ignore,
1821
1821
                 bool using_trans);
1851
1851
public:        /* !!! Public in this patch to allow old usage */
1852
1852
  virtual int do_apply_event(Relay_log_info const* rli)
1853
1853
  {
1854
 
    return do_apply_event(thd->slave_net,rli,0);
 
1854
    return do_apply_event(session->slave_net,rli,0);
1855
1855
  }
1856
1856
 
1857
1857
  int do_apply_event(NET *net, Relay_log_info const *rli,
2050
2050
  uint64_t val;
2051
2051
  unsigned char type;
2052
2052
 
2053
 
  Intvar_log_event(Session* thd_arg,unsigned char type_arg, uint64_t val_arg)
2054
 
    :Log_event(thd_arg,0,0),val(val_arg),type(type_arg)
 
2053
  Intvar_log_event(Session* session_arg,unsigned char type_arg, uint64_t val_arg)
 
2054
    :Log_event(session_arg,0,0),val(val_arg),type(type_arg)
2055
2055
  {}
2056
2056
  void pack_info(Protocol* protocol);
2057
2057
 
2115
2115
  uint64_t seed1;
2116
2116
  uint64_t seed2;
2117
2117
 
2118
 
  Rand_log_event(Session* thd_arg, uint64_t seed1_arg, uint64_t seed2_arg)
2119
 
    :Log_event(thd_arg,0,0),seed1(seed1_arg),seed2(seed2_arg)
 
2118
  Rand_log_event(Session* session_arg, uint64_t seed1_arg, uint64_t seed2_arg)
 
2119
    :Log_event(session_arg,0,0),seed1(seed1_arg),seed2(seed2_arg)
2120
2120
  {}
2121
2121
  void pack_info(Protocol* protocol);
2122
2122
 
2147
2147
 public:
2148
2148
   my_xid xid;
2149
2149
 
2150
 
  Xid_log_event(Session* thd_arg, my_xid x): Log_event(thd_arg,0,0), xid(x) {}
 
2150
  Xid_log_event(Session* session_arg, my_xid x): Log_event(session_arg,0,0), xid(x) {}
2151
2151
  void pack_info(Protocol* protocol);
2152
2152
 
2153
2153
  Xid_log_event(const char* buf,
2182
2182
  Item_result type;
2183
2183
  uint32_t charset_number;
2184
2184
  bool is_null;
2185
 
  User_var_log_event(Session* thd_arg __attribute__((unused)),
 
2185
  User_var_log_event(Session* session_arg __attribute__((unused)),
2186
2186
                     char *name_arg, uint32_t name_len_arg,
2187
2187
                     char *val_arg, ulong val_len_arg, Item_result type_arg,
2188
2188
                     uint32_t charset_number_arg)
2348
2348
  uint32_t file_id;
2349
2349
  bool inited_from_old;
2350
2350
 
2351
 
  Create_file_log_event(Session* thd, sql_exchange* ex, const char* db_arg,
 
2351
  Create_file_log_event(Session* session, sql_exchange* ex, const char* db_arg,
2352
2352
                        const char* table_name_arg,
2353
2353
                        List<Item>& fields_arg,
2354
2354
                        enum enum_duplicates handle_dup, bool ignore,
2412
2412
  */
2413
2413
  const char* db;
2414
2414
 
2415
 
  Append_block_log_event(Session* thd, const char* db_arg, unsigned char* block_arg,
 
2415
  Append_block_log_event(Session* session, const char* db_arg, unsigned char* block_arg,
2416
2416
                         uint32_t block_len_arg, bool using_trans);
2417
2417
  void pack_info(Protocol* protocol);
2418
2418
  virtual int get_create_or_append() const;
2444
2444
  uint32_t file_id;
2445
2445
  const char* db; /* see comment in Append_block_log_event */
2446
2446
 
2447
 
  Delete_file_log_event(Session* thd, const char* db_arg, bool using_trans);
 
2447
  Delete_file_log_event(Session* session, const char* db_arg, bool using_trans);
2448
2448
  void pack_info(Protocol* protocol);
2449
2449
 
2450
2450
  Delete_file_log_event(const char* buf, uint32_t event_len,
2473
2473
  uint32_t file_id;
2474
2474
  const char* db; /* see comment in Append_block_log_event */
2475
2475
 
2476
 
  Execute_load_log_event(Session* thd, const char* db_arg, bool using_trans);
 
2476
  Execute_load_log_event(Session* session, const char* db_arg, bool using_trans);
2477
2477
  void pack_info(Protocol* protocol);
2478
2478
 
2479
2479
  Execute_load_log_event(const char* buf, uint32_t event_len,
2503
2503
class Begin_load_query_log_event: public Append_block_log_event
2504
2504
{
2505
2505
public:
2506
 
  Begin_load_query_log_event(Session* thd_arg, const char *db_arg,
 
2506
  Begin_load_query_log_event(Session* session_arg, const char *db_arg,
2507
2507
                             unsigned char* block_arg, uint32_t block_len_arg,
2508
2508
                             bool using_trans);
2509
 
  Begin_load_query_log_event(Session* thd);
 
2509
  Begin_load_query_log_event(Session* session);
2510
2510
  int get_create_or_append() const;
2511
2511
  Begin_load_query_log_event(const char* buf, uint32_t event_len,
2512
2512
                             const Format_description_log_event
2548
2548
  */
2549
2549
  enum_load_dup_handling dup_handling;
2550
2550
 
2551
 
  Execute_load_query_log_event(Session* thd, const char* query_arg,
 
2551
  Execute_load_query_log_event(Session* session, const char* query_arg,
2552
2552
                               ulong query_length, uint32_t fn_pos_start_arg,
2553
2553
                               uint32_t fn_pos_end_arg,
2554
2554
                               enum_load_dup_handling dup_handling_arg,
2865
2865
  void clear_flags(flag_set flag) { m_flags &= ~flag; }
2866
2866
  flag_set get_flags(flag_set flag) const { return m_flags & flag; }
2867
2867
 
2868
 
  Table_map_log_event(Session *thd, Table *tbl, ulong tid, 
 
2868
  Table_map_log_event(Session *session, Table *tbl, ulong tid, 
2869
2869
                      bool is_transactional, uint16_t flags);
2870
2870
  Table_map_log_event(const char *buf, uint32_t event_len, 
2871
2871
                      const Format_description_log_event *description_event);
2954
2954
    /* Last event of a statement */
2955
2955
    STMT_END_F = (1U << 0),
2956
2956
 
2957
 
    /* Value of the OPTION_NO_FOREIGN_KEY_CHECKS flag in thd->options */
 
2957
    /* Value of the OPTION_NO_FOREIGN_KEY_CHECKS flag in session->options */
2958
2958
    NO_FOREIGN_KEY_CHECKS_F = (1U << 1),
2959
2959
 
2960
 
    /* Value of the OPTION_RELAXED_UNIQUE_CHECKS flag in thd->options */
 
2960
    /* Value of the OPTION_RELAXED_UNIQUE_CHECKS flag in session->options */
2961
2961
    RELAXED_UNIQUE_CHECKS_F = (1U << 2),
2962
2962
 
2963
2963
    /** 
3154
3154
                       bool is_transactional);
3155
3155
  Write_rows_log_event(const char *buf, uint32_t event_len, 
3156
3156
                       const Format_description_log_event *description_event);
3157
 
  static bool binlog_row_logging_function(Session *thd, Table *table,
 
3157
  static bool binlog_row_logging_function(Session *session, Table *table,
3158
3158
                                          bool is_transactional,
3159
3159
                                          const unsigned char *before_record
3160
3160
                                          __attribute__((unused)),
3161
3161
                                          const unsigned char *after_record)
3162
3162
  {
3163
 
    return thd->binlog_write_row(table, is_transactional, after_record);
 
3163
    return session->binlog_write_row(table, is_transactional, after_record);
3164
3164
  }
3165
3165
 
3166
3166
private:
3203
3203
  Update_rows_log_event(const char *buf, uint32_t event_len, 
3204
3204
                        const Format_description_log_event *description_event);
3205
3205
 
3206
 
  static bool binlog_row_logging_function(Session *thd, Table *table,
 
3206
  static bool binlog_row_logging_function(Session *session, Table *table,
3207
3207
                                          bool is_transactional,
3208
3208
                                          const unsigned char *before_record,
3209
3209
                                          const unsigned char *after_record)
3210
3210
  {
3211
 
    return thd->binlog_update_row(table, is_transactional,
 
3211
    return session->binlog_update_row(table, is_transactional,
3212
3212
                                  before_record, after_record);
3213
3213
  }
3214
3214
 
3258
3258
                        bool is_transactional);
3259
3259
  Delete_rows_log_event(const char *buf, uint32_t event_len, 
3260
3260
                        const Format_description_log_event *description_event);
3261
 
  static bool binlog_row_logging_function(Session *thd, Table *table,
 
3261
  static bool binlog_row_logging_function(Session *session, Table *table,
3262
3262
                                          bool is_transactional,
3263
3263
                                          const unsigned char *before_record,
3264
3264
                                          const unsigned char *after_record
3265
3265
                                          __attribute__((unused)))
3266
3266
  {
3267
 
    return thd->binlog_delete_row(table, is_transactional, before_record);
 
3267
    return session->binlog_delete_row(table, is_transactional, before_record);
3268
3268
  }
3269
3269
  
3270
3270
protected:
3314
3314
*/
3315
3315
class Incident_log_event : public Log_event {
3316
3316
public:
3317
 
  Incident_log_event(Session *thd_arg, Incident incident)
3318
 
    : Log_event(thd_arg, 0, false), m_incident(incident)
 
3317
  Incident_log_event(Session *session_arg, Incident incident)
 
3318
    : Log_event(session_arg, 0, false), m_incident(incident)
3319
3319
  {
3320
3320
    m_message.str= NULL;                    /* Just as a precaution */
3321
3321
    m_message.length= 0;
3322
3322
    return;
3323
3323
  }
3324
3324
 
3325
 
  Incident_log_event(Session *thd_arg, Incident incident, LEX_STRING const msg)
3326
 
    : Log_event(thd_arg, 0, false), m_incident(incident)
 
3325
  Incident_log_event(Session *session_arg, Incident incident, LEX_STRING const msg)
 
3326
    : Log_event(session_arg, 0, false), m_incident(incident)
3327
3327
  {
3328
3328
    m_message= msg;
3329
3329
    return;