~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_class.cc

  • Committer: Brian Aker
  • Date: 2008-10-20 03:40:03 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-20081020034003-t2dcnl0ayr2ymm8k
THD -> Session rename

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
char internal_table_name[2]= "*";
38
38
char empty_c_string[1]= {0};    /* used for not defined db */
39
39
 
40
 
const char * const THD::DEFAULT_WHERE= "field list";
 
40
const char * const Session::DEFAULT_WHERE= "field list";
41
41
 
42
42
 
43
43
/*****************************************************************************
86
86
  Construct an (almost) deep copy of this key. Only those
87
87
  elements that are known to never change are not copied.
88
88
  If out of memory, a partial copy is returned and an error is set
89
 
  in THD.
 
89
  in Session.
90
90
*/
91
91
 
92
92
Key::Key(const Key &rhs, MEM_ROOT *mem_root)
103
103
  Construct an (almost) deep copy of this foreign key. Only those
104
104
  elements that are known to never change are not copied.
105
105
  If out of memory, a partial copy is returned and an error is set
106
 
  in THD.
 
106
  in Session.
107
107
*/
108
108
 
109
109
Foreign_key::Foreign_key(const Foreign_key &rhs, MEM_ROOT *mem_root)
265
265
 
266
266
 
267
267
extern "C"
268
 
int thd_in_lock_tables(const THD *thd)
 
268
int thd_in_lock_tables(const Session *thd)
269
269
{
270
270
  return test(thd->in_lock_tables);
271
271
}
272
272
 
273
273
 
274
274
extern "C"
275
 
int thd_tablespace_op(const THD *thd)
 
275
int thd_tablespace_op(const Session *thd)
276
276
{
277
277
  return test(thd->tablespace_op);
278
278
}
279
279
 
280
280
 
281
281
/**
282
 
   Set the process info field of the THD structure.
 
282
   Set the process info field of the Session structure.
283
283
 
284
284
   This function is used by plug-ins. Internally, the
285
 
   THD::set_proc_info() function should be used.
 
285
   Session::set_proc_info() function should be used.
286
286
 
287
 
   @see THD::set_proc_info
 
287
   @see Session::set_proc_info
288
288
 */
289
289
extern "C" void
290
 
set_thd_proc_info(THD *thd, const char *info)
 
290
set_thd_proc_info(Session *thd, const char *info)
291
291
{
292
292
  thd->set_proc_info(info);
293
293
}
294
294
 
295
295
extern "C"
296
 
const char *get_thd_proc_info(THD *thd)
 
296
const char *get_thd_proc_info(Session *thd)
297
297
{
298
298
  return thd->get_proc_info();
299
299
}
300
300
 
301
301
extern "C"
302
 
void **thd_ha_data(const THD *thd, const struct handlerton *hton)
 
302
void **thd_ha_data(const Session *thd, const struct handlerton *hton)
303
303
{
304
304
  return (void **) &thd->ha_data[hton->slot].ha_ptr;
305
305
}
306
306
 
307
307
extern "C"
308
 
int64_t thd_test_options(const THD *thd, int64_t test_options)
 
308
int64_t thd_test_options(const Session *thd, int64_t test_options)
309
309
{
310
310
  return thd->options & test_options;
311
311
}
312
312
 
313
313
extern "C"
314
 
int thd_sql_command(const THD *thd)
 
314
int thd_sql_command(const Session *thd)
315
315
{
316
316
  return (int) thd->lex->sql_command;
317
317
}
318
318
 
319
319
extern "C"
320
 
int thd_tx_isolation(const THD *thd)
 
320
int thd_tx_isolation(const Session *thd)
321
321
{
322
322
  return (int) thd->variables.tx_isolation;
323
323
}
324
324
 
325
325
extern "C"
326
 
void thd_inc_row_count(THD *thd)
 
326
void thd_inc_row_count(Session *thd)
327
327
{
328
328
  thd->row_count++;
329
329
}
357
357
*/
358
358
 
359
359
void
360
 
Diagnostics_area::set_ok_status(THD *thd, ha_rows affected_rows_arg,
 
360
Diagnostics_area::set_ok_status(Session *thd, ha_rows affected_rows_arg,
361
361
                                uint64_t last_insert_id_arg,
362
362
                                const char *message_arg)
363
363
{
387
387
*/
388
388
 
389
389
void
390
 
Diagnostics_area::set_eof_status(THD *thd)
 
390
Diagnostics_area::set_eof_status(Session *thd)
391
391
{
392
392
  /** Only allowed to report eof if has not yet reported an error */
393
393
 
415
415
*/
416
416
 
417
417
void
418
 
Diagnostics_area::set_error_status(THD *thd __attribute__((unused)),
 
418
Diagnostics_area::set_error_status(Session *thd __attribute__((unused)),
419
419
                                   uint32_t sql_errno_arg,
420
420
                                   const char *message_arg)
421
421
{
455
455
}
456
456
 
457
457
 
458
 
THD::THD()
 
458
Session::Session()
459
459
   :Statement(&main_lex, &main_mem_root,
460
460
              /* statement id */ 0),
461
461
   Open_tables_state(refresh_version), rli_fake(0),
502
502
  limit_found_rows= 0;
503
503
  row_count_func= -1;
504
504
  statement_id_counter= 0UL;
505
 
  // Must be reset to handle error with THD's created for init of mysqld
 
505
  // Must be reset to handle error with Session's created for init of mysqld
506
506
  lex->current_select= 0;
507
507
  start_time=(time_t) 0;
508
508
  start_utime= 0L;
519
519
  memset(ha_data, 0, sizeof(ha_data));
520
520
  mysys_var=0;
521
521
  binlog_evt_union.do_union= false;
522
 
  dbug_sentry=THD_SENTRY_MAGIC;
 
522
  dbug_sentry=Session_SENTRY_MAGIC;
523
523
  net.vio=0;
524
524
  client_capabilities= 0;                       // minimalistic client
525
525
  system_thread= NON_SYSTEM_THREAD;
531
531
 
532
532
  /* Variables with default values */
533
533
  proc_info="login";
534
 
  where= THD::DEFAULT_WHERE;
 
534
  where= Session::DEFAULT_WHERE;
535
535
  server_id = ::server_id;
536
536
  slave_net = 0;
537
537
  command=COM_CONNECT;
567
567
}
568
568
 
569
569
 
570
 
void THD::push_internal_handler(Internal_error_handler *handler)
 
570
void Session::push_internal_handler(Internal_error_handler *handler)
571
571
{
572
572
  /*
573
573
    TODO: The current implementation is limited to 1 handler at a time only.
574
 
    THD and sp_rcontext need to be modified to use a common handler stack.
 
574
    Session and sp_rcontext need to be modified to use a common handler stack.
575
575
  */
576
576
  assert(m_internal_handler == NULL);
577
577
  m_internal_handler= handler;
578
578
}
579
579
 
580
580
 
581
 
bool THD::handle_error(uint32_t sql_errno, const char *message,
 
581
bool Session::handle_error(uint32_t sql_errno, const char *message,
582
582
                       DRIZZLE_ERROR::enum_warning_level level)
583
583
{
584
584
  if (m_internal_handler)
590
590
}
591
591
 
592
592
 
593
 
void THD::pop_internal_handler()
 
593
void Session::pop_internal_handler()
594
594
{
595
595
  assert(m_internal_handler != NULL);
596
596
  m_internal_handler= NULL;
597
597
}
598
598
 
599
599
extern "C"
600
 
void *thd_alloc(THD *thd, unsigned int size)
 
600
void *thd_alloc(Session *thd, unsigned int size)
601
601
{
602
602
  return thd->alloc(size);
603
603
}
604
604
 
605
605
extern "C"
606
 
void *thd_calloc(THD *thd, unsigned int size)
 
606
void *thd_calloc(Session *thd, unsigned int size)
607
607
{
608
608
  return thd->calloc(size);
609
609
}
610
610
 
611
611
extern "C"
612
 
char *thd_strdup(THD *thd, const char *str)
 
612
char *thd_strdup(Session *thd, const char *str)
613
613
{
614
614
  return thd->strdup(str);
615
615
}
616
616
 
617
617
extern "C"
618
 
char *thd_strmake(THD *thd, const char *str, unsigned int size)
 
618
char *thd_strmake(Session *thd, const char *str, unsigned int size)
619
619
{
620
620
  return thd->strmake(str, size);
621
621
}
622
622
 
623
623
extern "C"
624
 
LEX_STRING *thd_make_lex_string(THD *thd, LEX_STRING *lex_str,
 
624
LEX_STRING *thd_make_lex_string(Session *thd, LEX_STRING *lex_str,
625
625
                                const char *str, unsigned int size,
626
626
                                int allocate_lex_string)
627
627
{
630
630
}
631
631
 
632
632
extern "C"
633
 
void *thd_memdup(THD *thd, const void* str, unsigned int size)
 
633
void *thd_memdup(Session *thd, const void* str, unsigned int size)
634
634
{
635
635
  return thd->memdup(str, size);
636
636
}
637
637
 
638
638
extern "C"
639
 
void thd_get_xid(const THD *thd, DRIZZLE_XID *xid)
 
639
void thd_get_xid(const Session *thd, DRIZZLE_XID *xid)
640
640
{
641
641
  *xid = *(DRIZZLE_XID *) &thd->transaction.xid_state.xid;
642
642
}
645
645
  Init common variables that has to be reset on start and on change_user
646
646
*/
647
647
 
648
 
void THD::init(void)
 
648
void Session::init(void)
649
649
{
650
650
  pthread_mutex_lock(&LOCK_global_system_variables);
651
651
  plugin_thdvar_init(this);
652
 
  variables.time_format= date_time_format_copy((THD*) 0,
 
652
  variables.time_format= date_time_format_copy((Session*) 0,
653
653
                                               variables.time_format);
654
 
  variables.date_format= date_time_format_copy((THD*) 0,
 
654
  variables.date_format= date_time_format_copy((Session*) 0,
655
655
                                               variables.date_format);
656
 
  variables.datetime_format= date_time_format_copy((THD*) 0,
 
656
  variables.datetime_format= date_time_format_copy((Session*) 0,
657
657
                                                   variables.datetime_format);
658
658
  /*
659
659
    variables= global_system_variables above has reset
686
686
 
687
687
 
688
688
/*
689
 
  Init THD for query processing.
 
689
  Init Session for query processing.
690
690
  This has to be called once before we call mysql_parse.
691
691
  See also comments in sql_class.h.
692
692
*/
693
693
 
694
 
void THD::init_for_queries()
 
694
void Session::init_for_queries()
695
695
{
696
696
  set_time(); 
697
697
  ha_enable_transaction(this,true);
708
708
 
709
709
/* Do operations that may take a long time */
710
710
 
711
 
void THD::cleanup(void)
 
711
void Session::cleanup(void)
712
712
{
713
713
  assert(cleanup_done == 0);
714
714
 
743
743
  return;
744
744
}
745
745
 
746
 
THD::~THD()
 
746
Session::~Session()
747
747
{
748
 
  THD_CHECK_SENTRY(this);
749
 
  /* Ensure that no one is using THD */
 
748
  Session_CHECK_SENTRY(this);
 
749
  /* Ensure that no one is using Session */
750
750
  pthread_mutex_lock(&LOCK_delete);
751
751
  pthread_mutex_unlock(&LOCK_delete);
752
752
  add_to_status(&global_status_var, &status_var);
773
773
  free_root(&transaction.mem_root,MYF(0));
774
774
  mysys_var=0;                                  // Safety (shouldn't be needed)
775
775
  pthread_mutex_destroy(&LOCK_delete);
776
 
  dbug_sentry= THD_SENTRY_GONE;
 
776
  dbug_sentry= Session_SENTRY_GONE;
777
777
  if (rli_fake)
778
778
  {
779
779
    delete rli_fake;
836
836
}
837
837
 
838
838
 
839
 
void THD::awake(THD::killed_state state_to_set)
 
839
void Session::awake(Session::killed_state state_to_set)
840
840
{
841
 
  THD_CHECK_SENTRY(this);
 
841
  Session_CHECK_SENTRY(this);
842
842
  safe_mutex_assert_owner(&LOCK_delete); 
843
843
 
844
844
  killed= state_to_set;
845
 
  if (state_to_set != THD::KILL_QUERY)
 
845
  if (state_to_set != Session::KILL_QUERY)
846
846
  {
847
847
    thr_alarm_kill(thread_id);
848
848
    if (!slave_thread)
888
888
  sql_alloc() and the structure for the net buffer
889
889
*/
890
890
 
891
 
bool THD::store_globals()
 
891
bool Session::store_globals()
892
892
{
893
893
  /*
894
894
    Assert that thread_stack is initialized: it's necessary to be able
896
896
  */
897
897
  assert(thread_stack);
898
898
 
899
 
  if (pthread_setspecific(THR_THD,  this) ||
 
899
  if (pthread_setspecific(THR_Session,  this) ||
900
900
      pthread_setspecific(THR_MALLOC, &mem_root))
901
901
    return 1;
902
902
  mysys_var=my_thread_var;
903
903
  /*
904
904
    Let mysqld define the thread id (not mysys)
905
 
    This allows us to move THD to different threads if needed.
 
905
    This allows us to move Session to different threads if needed.
906
906
  */
907
907
  mysys_var->id= thread_id;
908
908
  real_id= pthread_self();                      // For debugging
909
909
 
910
910
  /*
911
 
    We have to call thr_lock_info_init() again here as THD may have been
 
911
    We have to call thr_lock_info_init() again here as Session may have been
912
912
    created in another thread
913
913
  */
914
914
  thr_lock_info_init(&lock_info);
920
920
  Cleanup after query.
921
921
 
922
922
  SYNOPSIS
923
 
    THD::cleanup_after_query()
 
923
    Session::cleanup_after_query()
924
924
 
925
925
  DESCRIPTION
926
926
    This function is used to reset thread data to its default state.
932
932
    slave.
933
933
*/
934
934
 
935
 
void THD::cleanup_after_query()
 
935
void Session::cleanup_after_query()
936
936
{
937
937
  /*
938
938
    Reset rand_used so that detection of calls to rand() will save random 
956
956
  /* Free Items that were created during this execution */
957
957
  free_items();
958
958
  /* Reset where. */
959
 
  where= THD::DEFAULT_WHERE;
 
959
  where= Session::DEFAULT_WHERE;
960
960
}
961
961
 
962
962
 
970
970
                              instead of using lex_str value
971
971
  @return  NULL on failure, or pointer to the LEX_STRING object
972
972
*/
973
 
LEX_STRING *THD::make_lex_string(LEX_STRING *lex_str,
 
973
LEX_STRING *Session::make_lex_string(LEX_STRING *lex_str,
974
974
                                 const char* str, uint32_t length,
975
975
                                 bool allocate_lex_string)
976
976
{
1004
1004
        In this case to->str will point to 0 and to->length will be 0.
1005
1005
*/
1006
1006
 
1007
 
bool THD::convert_string(LEX_STRING *to, const CHARSET_INFO * const to_cs,
 
1007
bool Session::convert_string(LEX_STRING *to, const CHARSET_INFO * const to_cs,
1008
1008
                         const char *from, uint32_t from_length,
1009
1009
                         const CHARSET_INFO * const from_cs)
1010
1010
{
1026
1026
  Convert string from source character set to target character set inplace.
1027
1027
 
1028
1028
  SYNOPSIS
1029
 
    THD::convert_string
 
1029
    Session::convert_string
1030
1030
 
1031
1031
  DESCRIPTION
1032
1032
    Convert string using convert_buffer - buffer for character set 
1037
1037
   !0   out of memory
1038
1038
*/
1039
1039
 
1040
 
bool THD::convert_string(String *s, const CHARSET_INFO * const from_cs,
 
1040
bool Session::convert_string(String *s, const CHARSET_INFO * const from_cs,
1041
1041
                         const CHARSET_INFO * const to_cs)
1042
1042
{
1043
1043
  uint32_t dummy_errors;
1058
1058
  Update some cache variables when character set changes
1059
1059
*/
1060
1060
 
1061
 
void THD::update_charset()
 
1061
void Session::update_charset()
1062
1062
{
1063
1063
  uint32_t not_used;
1064
1064
  charset_is_system_charset= !String::needs_conversion(0,charset(),
1088
1088
 
1089
1089
/* add table to list of changed in transaction tables */
1090
1090
 
1091
 
void THD::add_changed_table(Table *table)
 
1091
void Session::add_changed_table(Table *table)
1092
1092
{
1093
1093
  assert((options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) &&
1094
1094
              table->file->has_transactions());
1098
1098
}
1099
1099
 
1100
1100
 
1101
 
void THD::add_changed_table(const char *key, long key_length)
 
1101
void Session::add_changed_table(const char *key, long key_length)
1102
1102
{
1103
1103
  CHANGED_TableList **prev_changed = &transaction.changed_tables;
1104
1104
  CHANGED_TableList *curr = transaction.changed_tables;
1130
1130
}
1131
1131
 
1132
1132
 
1133
 
CHANGED_TableList* THD::changed_table_dup(const char *key, long key_length)
 
1133
CHANGED_TableList* Session::changed_table_dup(const char *key, long key_length)
1134
1134
{
1135
1135
  CHANGED_TableList* new_table = 
1136
1136
    (CHANGED_TableList*) trans_alloc(ALIGN_SIZE(sizeof(CHANGED_TableList))+
1151
1151
}
1152
1152
 
1153
1153
 
1154
 
int THD::send_explain_fields(select_result *result)
 
1154
int Session::send_explain_fields(select_result *result)
1155
1155
{
1156
1156
  List<Item> field_list;
1157
1157
  Item *item;
1214
1214
  thd->mem_root (this may no longer be a true statement)
1215
1215
*/
1216
1216
 
1217
 
void THD::nocheck_register_item_tree_change(Item **place, Item *old_value,
 
1217
void Session::nocheck_register_item_tree_change(Item **place, Item *old_value,
1218
1218
                                            MEM_ROOT *runtime_memroot)
1219
1219
{
1220
1220
  Item_change_record *change;
1239
1239
}
1240
1240
 
1241
1241
 
1242
 
void THD::rollback_item_tree_changes()
 
1242
void Session::rollback_item_tree_changes()
1243
1243
{
1244
1244
  I_List_iterator<Item_change_record> it(change_list);
1245
1245
  Item_change_record *change;
1471
1471
*/
1472
1472
 
1473
1473
 
1474
 
static File create_file(THD *thd, char *path, sql_exchange *exchange,
 
1474
static File create_file(Session *thd, char *path, sql_exchange *exchange,
1475
1475
                        IO_CACHE *cache)
1476
1476
{
1477
1477
  File file;
2048
2048
  Don't free mem_root, as mem_root is freed in the end of dispatch_command
2049
2049
  (once for any command).
2050
2050
*/
2051
 
void THD::end_statement()
 
2051
void Session::end_statement()
2052
2052
{
2053
2053
  /* Cleanup SQL processing state to reuse this statement in next query. */
2054
2054
  lex_end(lex);
2055
2055
}
2056
2056
 
2057
2057
 
2058
 
bool THD::copy_db_to(char **p_db, size_t *p_db_length)
 
2058
bool Session::copy_db_to(char **p_db, size_t *p_db_length)
2059
2059
{
2060
2060
  if (db == NULL)
2061
2061
  {
2130
2130
 
2131
2131
void thd_increment_bytes_sent(ulong length)
2132
2132
{
2133
 
  THD *thd=current_thd;
 
2133
  Session *thd=current_thd;
2134
2134
  if (likely(thd != 0))
2135
2135
  { /* current_thd==0 when close_connection() calls net_send_error() */
2136
2136
    thd->status_var.bytes_sent+= length;
2149
2149
  current_thd->status_var.net_big_packet_count+= length;
2150
2150
}
2151
2151
 
2152
 
void THD::send_kill_message() const
 
2152
void Session::send_kill_message() const
2153
2153
{
2154
2154
  int err= killed_errno();
2155
2155
  if (err)
2156
2156
    my_message(err, ER(err), MYF(0));
2157
2157
}
2158
2158
 
2159
 
void THD::set_status_var_init()
 
2159
void Session::set_status_var_init()
2160
2160
{
2161
2161
  memset(&status_var, 0, sizeof(status_var));
2162
2162
}
2198
2198
  access to mysql.proc table to find definitions of stored routines.
2199
2199
****************************************************************************/
2200
2200
 
2201
 
void THD::reset_n_backup_open_tables_state(Open_tables_state *backup)
 
2201
void Session::reset_n_backup_open_tables_state(Open_tables_state *backup)
2202
2202
{
2203
2203
  backup->set_open_tables_state(this);
2204
2204
  reset_open_tables_state();
2207
2207
}
2208
2208
 
2209
2209
 
2210
 
void THD::restore_backup_open_tables_state(Open_tables_state *backup)
 
2210
void Session::restore_backup_open_tables_state(Open_tables_state *backup)
2211
2211
{
2212
2212
  /*
2213
2213
    Before we will throw away current open tables state we want
2226
2226
  @retval 0 the user thread is active
2227
2227
  @retval 1 the user thread has been killed
2228
2228
*/
2229
 
extern "C" int thd_killed(const THD *thd)
 
2229
extern "C" int thd_killed(const Session *thd)
2230
2230
{
2231
2231
  return(thd->killed);
2232
2232
}
2236
2236
  @param thd user thread
2237
2237
  @return thread id
2238
2238
*/
2239
 
extern "C" unsigned long thd_get_thread_id(const THD *thd)
 
2239
extern "C" unsigned long thd_get_thread_id(const Session *thd)
2240
2240
{
2241
2241
  return((unsigned long)thd->thread_id);
2242
2242
}
2243
2243
 
2244
2244
 
2245
2245
#ifdef INNODB_COMPATIBILITY_HOOKS
2246
 
extern "C" const struct charset_info_st *thd_charset(THD *thd)
 
2246
extern "C" const struct charset_info_st *thd_charset(Session *thd)
2247
2247
{
2248
2248
  return(thd->charset());
2249
2249
}
2250
2250
 
2251
 
extern "C" char **thd_query(THD *thd)
 
2251
extern "C" char **thd_query(Session *thd)
2252
2252
{
2253
2253
  return(&thd->query);
2254
2254
}
2255
2255
 
2256
 
extern "C" int thd_slave_thread(const THD *thd)
 
2256
extern "C" int thd_slave_thread(const Session *thd)
2257
2257
{
2258
2258
  return(thd->slave_thread);
2259
2259
}
2260
2260
 
2261
 
extern "C" int thd_non_transactional_update(const THD *thd)
 
2261
extern "C" int thd_non_transactional_update(const Session *thd)
2262
2262
{
2263
2263
  return(thd->transaction.all.modified_non_trans_table);
2264
2264
}
2265
2265
 
2266
 
extern "C" int thd_binlog_format(const THD *thd)
 
2266
extern "C" int thd_binlog_format(const Session *thd)
2267
2267
{
2268
2268
  return (int) thd->variables.binlog_format;
2269
2269
}
2270
2270
 
2271
 
extern "C" void thd_mark_transaction_to_rollback(THD *thd, bool all)
 
2271
extern "C" void thd_mark_transaction_to_rollback(Session *thd, bool all)
2272
2272
{
2273
2273
  mark_transaction_to_rollback(thd, all);
2274
2274
}
2282
2282
  @param  all   true <=> rollback main transaction.
2283
2283
*/
2284
2284
 
2285
 
void mark_transaction_to_rollback(THD *thd, bool all)
 
2285
void mark_transaction_to_rollback(Session *thd, bool all)
2286
2286
{
2287
2287
  if (thd)
2288
2288
  {
2406
2406
 */
2407
2407
 
2408
2408
template <class RowsEventT> Rows_log_event* 
2409
 
THD::binlog_prepare_pending_rows_event(Table* table, uint32_t serv_id,
 
2409
Session::binlog_prepare_pending_rows_event(Table* table, uint32_t serv_id,
2410
2410
                                       size_t needed,
2411
2411
                                       bool is_transactional,
2412
2412
                                       RowsEventT *hint __attribute__((unused)))
2482
2482
  compiling option.
2483
2483
*/
2484
2484
template Rows_log_event*
2485
 
THD::binlog_prepare_pending_rows_event(Table*, uint32_t, size_t, bool,
 
2485
Session::binlog_prepare_pending_rows_event(Table*, uint32_t, size_t, bool,
2486
2486
                                       Write_rows_log_event*);
2487
2487
 
2488
2488
template Rows_log_event*
2489
 
THD::binlog_prepare_pending_rows_event(Table*, uint32_t, size_t, bool,
 
2489
Session::binlog_prepare_pending_rows_event(Table*, uint32_t, size_t, bool,
2490
2490
                                       Delete_rows_log_event *);
2491
2491
 
2492
2492
template Rows_log_event* 
2493
 
THD::binlog_prepare_pending_rows_event(Table*, uint32_t, size_t, bool,
 
2493
Session::binlog_prepare_pending_rows_event(Table*, uint32_t, size_t, bool,
2494
2494
                                       Update_rows_log_event *);
2495
2495
#endif
2496
2496
 
2608
2608
}
2609
2609
 
2610
2610
 
2611
 
int THD::binlog_write_row(Table* table, bool is_trans, 
 
2611
int Session::binlog_write_row(Table* table, bool is_trans, 
2612
2612
                          unsigned char const *record) 
2613
2613
2614
2614
  assert(current_stmt_binlog_row_based && mysql_bin_log.is_open());
2635
2635
  return ev->add_row_data(row_data, len);
2636
2636
}
2637
2637
 
2638
 
int THD::binlog_update_row(Table* table, bool is_trans,
 
2638
int Session::binlog_update_row(Table* table, bool is_trans,
2639
2639
                           const unsigned char *before_record,
2640
2640
                           const unsigned char *after_record)
2641
2641
2669
2669
    ev->add_row_data(after_row, after_size);
2670
2670
}
2671
2671
 
2672
 
int THD::binlog_delete_row(Table* table, bool is_trans, 
 
2672
int Session::binlog_delete_row(Table* table, bool is_trans, 
2673
2673
                           unsigned char const *record)
2674
2674
2675
2675
  assert(current_stmt_binlog_row_based && mysql_bin_log.is_open());
2697
2697
}
2698
2698
 
2699
2699
 
2700
 
int THD::binlog_flush_pending_rows_event(bool stmt_end)
 
2700
int Session::binlog_flush_pending_rows_event(bool stmt_end)
2701
2701
{
2702
2702
  /*
2703
2703
    We shall flush the pending event even if we are not in row-based
2751
2751
  RETURN VALUE
2752
2752
    Error code, or 0 if no error.
2753
2753
*/
2754
 
int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
 
2754
int Session::binlog_query(Session::enum_binlog_query_type qtype, char const *query_arg,
2755
2755
                      ulong query_len, bool is_trans, bool suppress_use,
2756
 
                      THD::killed_state killed_status_arg)
 
2756
                      Session::killed_state killed_status_arg)
2757
2757
{
2758
2758
  assert(query_arg && mysql_bin_log.is_open());
2759
2759
 
2782
2782
  }
2783
2783
 
2784
2784
  switch (qtype) {
2785
 
  case THD::ROW_QUERY_TYPE:
 
2785
  case Session::ROW_QUERY_TYPE:
2786
2786
    if (current_stmt_binlog_row_based)
2787
2787
      return(0);
2788
2788
    /* Otherwise, we fall through */
2789
 
  case THD::DRIZZLE_QUERY_TYPE:
 
2789
  case Session::DRIZZLE_QUERY_TYPE:
2790
2790
    /*
2791
2791
      Using this query type is a conveniece hack, since we have been
2792
2792
      moving back and forth between using RBR for replication of
2795
2795
      Make sure to change in check_table_binlog_row_based() according
2796
2796
      to how you treat this.
2797
2797
    */
2798
 
  case THD::STMT_QUERY_TYPE:
 
2798
  case Session::STMT_QUERY_TYPE:
2799
2799
    /*
2800
2800
      The DRIZZLE_LOG::write() function will set the STMT_END_F flag and
2801
2801
      flush the pending rows event if necessary.
2816
2816
    }
2817
2817
    break;
2818
2818
 
2819
 
  case THD::QUERY_TYPE_COUNT:
 
2819
  case Session::QUERY_TYPE_COUNT:
2820
2820
  default:
2821
2821
    assert(0 <= qtype && qtype < QUERY_TYPE_COUNT);
2822
2822
  }