~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/drizzled.cc

  • Committer: Monty Taylor
  • Date: 2008-10-20 08:48:34 UTC
  • mfrom: (520.1.22 drizzle)
  • Revision ID: monty@inaugust.com-20081020084834-xpb3w01vkcp55o02
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
extern "C" {                                    // Because of SCO 3.2V4.2
70
70
#include <errno.h>
71
71
#include <sys/stat.h>
72
 
#ifndef __GNU_LIBRARY__
73
 
#define __GNU_LIBRARY__                         // Skip warnings in getopt.h
74
 
#endif
75
72
#include <mysys/my_getopt.h>
76
73
#ifdef HAVE_SYSENT_H
77
74
#include <sysent.h>
198
195
 
199
196
const char *first_keyword= "first", *binary_keyword= "BINARY";
200
197
const char *my_localhost= "localhost";
201
 
#if SIZEOF_OFF_T > 4 && defined(BIG_TABLES)
202
198
#define GET_HA_ROWS GET_ULL
203
 
#else
204
 
#define GET_HA_ROWS GET_ULONG
205
 
#endif
206
199
 
207
200
/*
208
201
  Used with --help for detailed option
241
234
static char *default_collation_name;
242
235
static char *default_storage_engine_str;
243
236
static char compiled_default_collation_name[]= DRIZZLE_DEFAULT_COLLATION_NAME;
244
 
static I_List<THD> thread_cache;
 
237
static I_List<Session> thread_cache;
245
238
 
246
239
static pthread_cond_t COND_thread_cache, COND_flush_thread_cache;
247
240
 
303
296
uint32_t lower_case_table_names= 1;
304
297
uint32_t tc_heuristic_recover= 0;
305
298
uint32_t volatile thread_count, thread_running;
306
 
uint64_t thd_startup_options;
 
299
uint64_t session_startup_options;
307
300
ulong back_log, connect_timeout, server_id;
308
301
ulong table_cache_size, table_def_size;
309
302
ulong what_to_log;
411
404
 
412
405
FILE *stderror_file=0;
413
406
 
414
 
I_List<THD> threads;
 
407
I_List<Session> threads;
415
408
I_List<NAMED_LIST> key_caches;
416
409
Rpl_filter* rpl_filter;
417
410
Rpl_filter* binlog_filter;
435
428
/* Thread specific variables */
436
429
 
437
430
pthread_key(MEM_ROOT**,THR_MALLOC);
438
 
pthread_key(THD*, THR_THD);
 
431
pthread_key(Session*, THR_Session);
439
432
pthread_mutex_t LOCK_mysql_create_db, LOCK_open, LOCK_thread_count,
440
433
                LOCK_status, LOCK_global_read_lock,
441
434
                LOCK_error_log, LOCK_uuid_generator,
473
466
static char **defaults_argv;
474
467
static char *opt_bin_logname;
475
468
 
476
 
struct rand_struct sql_rand; ///< used by sql_class.cc:THD::THD()
 
469
struct rand_struct sql_rand; ///< used by sql_class.cc:Session::Session()
477
470
 
478
471
struct passwd *user_info;
479
472
static pthread_t select_thread;
583
576
    statements and inform their clients that the server is about to die.
584
577
  */
585
578
 
586
 
  THD *tmp;
 
579
  Session *tmp;
587
580
  (void) pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
588
581
 
589
 
  I_List_iterator<THD> it(threads);
 
582
  I_List_iterator<Session> it(threads);
590
583
  while ((tmp=it++))
591
584
  {
592
585
    /* We skip slave threads & scheduler on this first loop through. */
593
586
    if (tmp->slave_thread)
594
587
      continue;
595
588
 
596
 
    tmp->killed= THD::KILL_CONNECTION;
 
589
    tmp->killed= Session::KILL_CONNECTION;
597
590
    thread_scheduler.post_kill_notification(tmp);
598
591
    if (tmp->mysys_var)
599
592
    {
1213
1206
/**
1214
1207
  Close a connection.
1215
1208
 
1216
 
  @param thd            Thread handle
 
1209
  @param session                Thread handle
1217
1210
  @param errcode        Error code to print to console
1218
1211
  @param lock           1 if we have have to lock LOCK_thread_count
1219
1212
 
1220
1213
  @note
1221
1214
    For the connection that is doing shutdown, this is called twice
1222
1215
*/
1223
 
void close_connection(THD *thd, uint32_t errcode, bool lock)
 
1216
void close_connection(Session *session, uint32_t errcode, bool lock)
1224
1217
{
1225
1218
  st_vio *vio;
1226
1219
  if (lock)
1227
1220
    (void) pthread_mutex_lock(&LOCK_thread_count);
1228
 
  thd->killed= THD::KILL_CONNECTION;
1229
 
  if ((vio= thd->net.vio) != 0)
 
1221
  session->killed= Session::KILL_CONNECTION;
 
1222
  if ((vio= session->net.vio) != 0)
1230
1223
  {
1231
1224
    if (errcode)
1232
 
      net_send_error(thd, errcode, ER(errcode)); /* purecov: inspected */
1233
 
    net_close(&(thd->net));             /* vio is freed in delete thd */
 
1225
      net_send_error(session, errcode, ER(errcode)); /* purecov: inspected */
 
1226
    net_close(&(session->net));         /* vio is freed in delete session */
1234
1227
  }
1235
1228
  if (lock)
1236
1229
    (void) pthread_mutex_unlock(&LOCK_thread_count);
1242
1235
/* ARGSUSED */
1243
1236
extern "C" RETSIGTYPE end_thread_signal(int sig __attribute__((unused)))
1244
1237
{
1245
 
  THD *thd=current_thd;
1246
 
  if (thd)
 
1238
  Session *session=current_session;
 
1239
  if (session)
1247
1240
  {
1248
1241
    statistic_increment(killed_threads, &LOCK_status);
1249
 
    thread_scheduler.end_thread(thd,0);         /* purecov: inspected */
 
1242
    thread_scheduler.end_thread(session,0);             /* purecov: inspected */
1250
1243
  }
1251
1244
  return;;                              /* purecov: deadcode */
1252
1245
}
1253
1246
 
1254
1247
 
1255
1248
/*
1256
 
  Unlink thd from global list of available connections and free thd
 
1249
  Unlink session from global list of available connections and free session
1257
1250
 
1258
1251
  SYNOPSIS
1259
 
    unlink_thd()
1260
 
    thd          Thread handler
 
1252
    unlink_session()
 
1253
    session              Thread handler
1261
1254
 
1262
1255
  NOTES
1263
1256
    LOCK_thread_count is locked and left locked
1264
1257
*/
1265
1258
 
1266
 
void unlink_thd(THD *thd)
 
1259
void unlink_session(Session *session)
1267
1260
{
1268
 
  thd->cleanup();
 
1261
  session->cleanup();
1269
1262
 
1270
1263
  pthread_mutex_lock(&LOCK_connection_count);
1271
1264
  --connection_count;
1273
1266
 
1274
1267
  (void) pthread_mutex_lock(&LOCK_thread_count);
1275
1268
  thread_count--;
1276
 
  delete thd;
 
1269
  delete session;
1277
1270
  return;;
1278
1271
}
1279
1272
 
1309
1302
      pthread_cond_signal(&COND_flush_thread_cache);
1310
1303
    if (wake_thread)
1311
1304
    {
1312
 
      THD *thd;
 
1305
      Session *session;
1313
1306
      wake_thread--;
1314
 
      thd= thread_cache.get();
1315
 
      thd->thread_stack= (char*) &thd;          // For store_globals
1316
 
      (void) thd->store_globals();
 
1307
      session= thread_cache.get();
 
1308
      session->thread_stack= (char*) &session;          // For store_globals
 
1309
      (void) session->store_globals();
1317
1310
      /*
1318
 
        THD::mysys_var::abort is associated with physical thread rather
1319
 
        than with THD object. So we need to reset this flag before using
1320
 
        this thread for handling of new THD object/connection.
 
1311
        Session::mysys_var::abort is associated with physical thread rather
 
1312
        than with Session object. So we need to reset this flag before using
 
1313
        this thread for handling of new Session object/connection.
1321
1314
      */
1322
 
      thd->mysys_var->abort= 0;
1323
 
      thd->thr_create_utime= my_micro_time();
1324
 
      threads.append(thd);
 
1315
      session->mysys_var->abort= 0;
 
1316
      session->thr_create_utime= my_micro_time();
 
1317
      threads.append(session);
1325
1318
      return(1);
1326
1319
    }
1327
1320
  }
1334
1327
 
1335
1328
  SYNOPSIS
1336
1329
    one_thread_per_connection_end()
1337
 
    thd           Thread handler
 
1330
    session               Thread handler
1338
1331
    put_in_cache  Store thread in cache, if there is room in it
1339
1332
                  Normally this is true in all cases except when we got
1340
1333
                  out of resources initializing the current thread
1348
1341
    0    Signal to handle_one_connection to reuse connection
1349
1342
*/
1350
1343
 
1351
 
bool one_thread_per_connection_end(THD *thd, bool put_in_cache)
 
1344
bool one_thread_per_connection_end(Session *session, bool put_in_cache)
1352
1345
{
1353
 
  unlink_thd(thd);
 
1346
  unlink_session(session);
1354
1347
  if (put_in_cache)
1355
1348
    put_in_cache= cache_thread();
1356
1349
  pthread_mutex_unlock(&LOCK_thread_count);
1389
1382
*/
1390
1383
extern "C" RETSIGTYPE abort_thread(int sig __attribute__((unused)))
1391
1384
{
1392
 
  THD *thd=current_thd;
1393
 
  if (thd)
1394
 
    thd->killed= THD::KILL_CONNECTION;
 
1385
  Session *session=current_session;
 
1386
  if (session)
 
1387
    session->killed= Session::KILL_CONNECTION;
1395
1388
  return;;
1396
1389
}
1397
1390
#endif
1457
1450
                     (global_system_variables.read_buff_size +
1458
1451
                      global_system_variables.sortbuff_size) *
1459
1452
                     thread_scheduler.max_threads +
1460
 
                     max_connections * sizeof(THD)) / 1024);
 
1453
                     max_connections * sizeof(Session)) / 1024);
1461
1454
 
1462
1455
#ifdef HAVE_STACKTRACE
1463
 
  THD *thd= current_thd;
 
1456
  Session *session= current_session;
1464
1457
 
1465
1458
  if (!(test_flags & TEST_NO_STACKTRACE))
1466
1459
  {
1467
 
    fprintf(stderr,"thd: 0x%lx\n",(long) thd);
 
1460
    fprintf(stderr,"session: 0x%lx\n",(long) session);
1468
1461
    fprintf(stderr,_("Attempting backtrace. You can use the following "
1469
1462
                     "information to find out\n"
1470
1463
                     "where mysqld died. If you see no messages after this, "
1471
1464
                     "something went\n"
1472
1465
                     "terribly wrong...\n"));
1473
 
    print_stacktrace(thd ? (unsigned char*) thd->thread_stack : (unsigned char*) 0,
 
1466
    print_stacktrace(session ? (unsigned char*) session->thread_stack : (unsigned char*) 0,
1474
1467
                     my_thread_stack_size);
1475
1468
  }
1476
 
  if (thd)
 
1469
  if (session)
1477
1470
  {
1478
1471
    const char *kreason= "UNKNOWN";
1479
 
    switch (thd->killed) {
1480
 
    case THD::NOT_KILLED:
 
1472
    switch (session->killed) {
 
1473
    case Session::NOT_KILLED:
1481
1474
      kreason= "NOT_KILLED";
1482
1475
      break;
1483
 
    case THD::KILL_BAD_DATA:
 
1476
    case Session::KILL_BAD_DATA:
1484
1477
      kreason= "KILL_BAD_DATA";
1485
1478
      break;
1486
 
    case THD::KILL_CONNECTION:
 
1479
    case Session::KILL_CONNECTION:
1487
1480
      kreason= "KILL_CONNECTION";
1488
1481
      break;
1489
 
    case THD::KILL_QUERY:
 
1482
    case Session::KILL_QUERY:
1490
1483
      kreason= "KILL_QUERY";
1491
1484
      break;
1492
 
    case THD::KILLED_NO_VALUE:
 
1485
    case Session::KILLED_NO_VALUE:
1493
1486
      kreason= "KILLED_NO_VALUE";
1494
1487
      break;
1495
1488
    }
1496
1489
    fprintf(stderr, _("Trying to get some variables.\n"
1497
1490
                      "Some pointers may be invalid and cause the "
1498
1491
                      "dump to abort...\n"));
1499
 
    safe_print_str("thd->query", thd->query, 1024);
1500
 
    fprintf(stderr, "thd->thread_id=%"PRIu32"\n", (uint32_t) thd->thread_id);
1501
 
    fprintf(stderr, "thd->killed=%s\n", kreason);
 
1492
    safe_print_str("session->query", session->query, 1024);
 
1493
    fprintf(stderr, "session->thread_id=%"PRIu32"\n", (uint32_t) session->thread_id);
 
1494
    fprintf(stderr, "session->killed=%s\n", kreason);
1502
1495
  }
1503
1496
  fflush(stderr);
1504
1497
#endif /* HAVE_STACKTRACE */
1778
1771
      if (!abort_loop)
1779
1772
      {
1780
1773
        bool not_used;
1781
 
        reload_cache((THD*) 0,
 
1774
        reload_cache((Session*) 0,
1782
1775
                     (REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST |
1783
1776
                      REFRESH_GRANT |
1784
1777
                      REFRESH_THREADS | REFRESH_HOSTS),
1815
1808
 
1816
1809
void my_message_sql(uint32_t error, const char *str, myf MyFlags)
1817
1810
{
1818
 
  THD *thd;
 
1811
  Session *session;
1819
1812
  /*
1820
1813
    Put here following assertion when situation with EE_* error codes
1821
1814
    will be fixed
1822
1815
  */
1823
 
  if ((thd= current_thd))
 
1816
  if ((session= current_session))
1824
1817
  {
1825
1818
    if (MyFlags & ME_FATALERROR)
1826
 
      thd->is_fatal_error= 1;
 
1819
      session->is_fatal_error= 1;
1827
1820
 
1828
1821
    /*
1829
 
      TODO: There are two exceptions mechanism (THD and sp_rcontext),
 
1822
      TODO: There are two exceptions mechanism (Session and sp_rcontext),
1830
1823
      this could be improved by having a common stack of handlers.
1831
1824
    */
1832
 
    if (thd->handle_error(error, str,
 
1825
    if (session->handle_error(error, str,
1833
1826
                          DRIZZLE_ERROR::WARN_LEVEL_ERROR))
1834
1827
      return;;
1835
1828
 
1836
 
    thd->is_slave_error=  1; // needed to catch query errors during replication
 
1829
    session->is_slave_error=  1; // needed to catch query errors during replication
1837
1830
 
1838
1831
    /*
1839
 
      thd->lex->current_select == 0 if lex structure is not inited
 
1832
      session->lex->current_select == 0 if lex structure is not inited
1840
1833
      (not query command (COM_QUERY))
1841
1834
    */
1842
 
    if (! (thd->lex->current_select &&
1843
 
        thd->lex->current_select->no_error && !thd->is_fatal_error))
 
1835
    if (! (session->lex->current_select &&
 
1836
        session->lex->current_select->no_error && !session->is_fatal_error))
1844
1837
    {
1845
 
      if (! thd->main_da.is_error())            // Return only first message
 
1838
      if (! session->main_da.is_error())            // Return only first message
1846
1839
      {
1847
1840
        if (error == 0)
1848
1841
          error= ER_UNKNOWN_ERROR;
1849
1842
        if (str == NULL)
1850
1843
          str= ER(error);
1851
 
        thd->main_da.set_error_status(thd, error, str);
 
1844
        session->main_da.set_error_status(session, error, str);
1852
1845
      }
1853
1846
    }
1854
1847
 
1855
 
    if (!thd->no_warnings_for_error && !thd->is_fatal_error)
 
1848
    if (!session->no_warnings_for_error && !session->is_fatal_error)
1856
1849
    {
1857
1850
      /*
1858
1851
        Suppress infinite recursion if there a memory allocation error
1859
1852
        inside push_warning.
1860
1853
      */
1861
 
      thd->no_warnings_for_error= true;
1862
 
      push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR, error, str);
1863
 
      thd->no_warnings_for_error= false;
 
1854
      session->no_warnings_for_error= true;
 
1855
      push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR, error, str);
 
1856
      session->no_warnings_for_error= false;
1864
1857
    }
1865
1858
  }
1866
 
  if (!thd || MyFlags & ME_NOREFRESH)
 
1859
  if (!session || MyFlags & ME_NOREFRESH)
1867
1860
    sql_print_error("%s: %s",my_progname,str); /* purecov: inspected */
1868
1861
  return;;
1869
1862
}
2263
2256
    (void)pthread_attr_setschedparam(&connection_attrib, &tmp_sched_param);
2264
2257
  }
2265
2258
 
2266
 
  if (pthread_key_create(&THR_THD,NULL) ||
 
2259
  if (pthread_key_create(&THR_Session,NULL) ||
2267
2260
      pthread_key_create(&THR_MALLOC,NULL))
2268
2261
  {
2269
2262
    sql_print_error(_("Can't create thread-keys"));
2649
2642
  error_handler_hook= my_message_sql;
2650
2643
  start_signal_handler();                               // Creates pidfile
2651
2644
 
2652
 
  if (mysql_rm_tmp_tables() || my_tz_init((THD *)0, default_tz_name))
 
2645
  if (mysql_rm_tmp_tables() || my_tz_init((Session *)0, default_tz_name))
2653
2646
  {
2654
2647
    abort_loop=1;
2655
2648
    select_thread_in_use=0;
2708
2701
 
2709
2702
    This function will create new thread to handle the incoming
2710
2703
    connection.  If there are idle cached threads one will be used.
2711
 
    'thd' will be pushed into 'threads'.
 
2704
    'session' will be pushed into 'threads'.
2712
2705
 
2713
2706
    In single-threaded mode (\#define ONE_THREAD) connection will be
2714
2707
    handled inside this function.
2715
2708
 
2716
 
  @param[in,out] thd    Thread handle of future thread.
 
2709
  @param[in,out] session    Thread handle of future thread.
2717
2710
*/
2718
2711
 
2719
 
static void create_new_thread(THD *thd)
 
2712
static void create_new_thread(Session *session)
2720
2713
{
2721
2714
 
2722
2715
  /*
2730
2723
  {
2731
2724
    pthread_mutex_unlock(&LOCK_connection_count);
2732
2725
 
2733
 
    close_connection(thd, ER_CON_COUNT_ERROR, 1);
2734
 
    delete thd;
 
2726
    close_connection(session, ER_CON_COUNT_ERROR, 1);
 
2727
    delete session;
2735
2728
    return;;
2736
2729
  }
2737
2730
 
2747
2740
  pthread_mutex_lock(&LOCK_thread_count);
2748
2741
 
2749
2742
  /*
2750
 
    The initialization of thread_id is done in create_embedded_thd() for
 
2743
    The initialization of thread_id is done in create_embedded_session() for
2751
2744
    the embedded library.
2752
2745
    TODO: refactor this to avoid code duplication there
2753
2746
  */
2754
 
  thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
 
2747
  session->thread_id= session->variables.pseudo_thread_id= thread_id++;
2755
2748
 
2756
2749
  thread_count++;
2757
2750
 
2758
 
  thread_scheduler.add_connection(thd);
 
2751
  thread_scheduler.add_connection(session);
2759
2752
 
2760
2753
  return;;
2761
2754
}
2784
2777
  int x;
2785
2778
  int sock,new_sock;
2786
2779
  uint32_t error_count=0;
2787
 
  THD *thd;
 
2780
  Session *session;
2788
2781
  struct sockaddr_storage cAddr;
2789
2782
 
2790
2783
  MAYBE_BROKEN_SYSCALL;
2873
2866
    ** Don't allow too many connections
2874
2867
    */
2875
2868
 
2876
 
    if (!(thd= new THD))
 
2869
    if (!(session= new Session))
2877
2870
    {
2878
2871
      (void) shutdown(new_sock, SHUT_RDWR);
2879
2872
      close(new_sock);
2880
2873
      continue;
2881
2874
    }
2882
 
    if (net_init_sock(&thd->net, new_sock, sock == 0))
 
2875
    if (net_init_sock(&session->net, new_sock, sock == 0))
2883
2876
    {
2884
 
      delete thd;
 
2877
      delete session;
2885
2878
      continue;
2886
2879
    }
2887
2880
 
2888
 
    create_new_thread(thd);
 
2881
    create_new_thread(session);
2889
2882
  }
2890
2883
}
2891
2884
 
3922
3915
  {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
3923
3916
};
3924
3917
 
3925
 
static int show_net_compression(THD *thd __attribute__((unused)),
 
3918
static int show_net_compression(Session *session __attribute__((unused)),
3926
3919
                                SHOW_VAR *var,
3927
3920
                                char *buff __attribute__((unused)))
3928
3921
{
3929
3922
  var->type= SHOW_MY_BOOL;
3930
 
  var->value= (char *)&thd->net.compress;
 
3923
  var->value= (char *)&session->net.compress;
3931
3924
  return 0;
3932
3925
}
3933
3926
 
3934
3927
static st_show_var_func_container
3935
3928
show_net_compression_cont= { &show_net_compression };
3936
3929
 
3937
 
static int show_starttime(THD *thd, SHOW_VAR *var, char *buff)
 
3930
static int show_starttime(Session *session, SHOW_VAR *var, char *buff)
3938
3931
{
3939
3932
  var->type= SHOW_LONG;
3940
3933
  var->value= buff;
3941
 
  *((long *)buff)= (long) (thd->query_start() - server_start_time);
 
3934
  *((long *)buff)= (long) (session->query_start() - server_start_time);
3942
3935
  return 0;
3943
3936
}
3944
3937
 
3945
3938
static st_show_var_func_container
3946
3939
show_starttime_cont= { &show_starttime };
3947
3940
 
3948
 
static int show_flushstatustime(THD *thd, SHOW_VAR *var, char *buff)
 
3941
static int show_flushstatustime(Session *session, SHOW_VAR *var, char *buff)
3949
3942
{
3950
3943
  var->type= SHOW_LONG;
3951
3944
  var->value= buff;
3952
 
  *((long *)buff)= (long) (thd->query_start() - flush_status_time);
 
3945
  *((long *)buff)= (long) (session->query_start() - flush_status_time);
3953
3946
  return 0;
3954
3947
}
3955
3948
 
3956
3949
static st_show_var_func_container
3957
3950
show_flushstatustime_cont= { &show_flushstatustime };
3958
3951
 
3959
 
static int show_slave_running(THD *thd __attribute__((unused)),
 
3952
static int show_slave_running(Session *session __attribute__((unused)),
3960
3953
                              SHOW_VAR *var, char *buff)
3961
3954
{
3962
3955
  var->type= SHOW_MY_BOOL;
3971
3964
static st_show_var_func_container
3972
3965
show_slave_running_cont= { &show_slave_running };
3973
3966
 
3974
 
static int show_slave_retried_trans(THD *thd __attribute__((unused)),
 
3967
static int show_slave_retried_trans(Session *session __attribute__((unused)),
3975
3968
                                    SHOW_VAR *var, char *buff)
3976
3969
{
3977
3970
  /*
3996
3989
static st_show_var_func_container
3997
3990
show_slave_retried_trans_cont= { &show_slave_retried_trans };
3998
3991
 
3999
 
static int show_slave_received_heartbeats(THD *thd __attribute__((unused)),
 
3992
static int show_slave_received_heartbeats(Session *session __attribute__((unused)),
4000
3993
                                          SHOW_VAR *var, char *buff)
4001
3994
{
4002
3995
  pthread_mutex_lock(&LOCK_active_mi);
4017
4010
static st_show_var_func_container
4018
4011
show_slave_received_heartbeats_cont= { &show_slave_received_heartbeats };
4019
4012
 
4020
 
static int show_heartbeat_period(THD *thd __attribute__((unused)),
 
4013
static int show_heartbeat_period(Session *session __attribute__((unused)),
4021
4014
                                 SHOW_VAR *var, char *buff)
4022
4015
{
4023
4016
  pthread_mutex_lock(&LOCK_active_mi);
4036
4029
static st_show_var_func_container
4037
4030
show_heartbeat_period_cont= { &show_heartbeat_period};
4038
4031
 
4039
 
static int show_open_tables(THD *thd __attribute__((unused)),
 
4032
static int show_open_tables(Session *session __attribute__((unused)),
4040
4033
                            SHOW_VAR *var, char *buff)
4041
4034
{
4042
4035
  var->type= SHOW_LONG;
4045
4038
  return 0;
4046
4039
}
4047
4040
 
4048
 
static int show_table_definitions(THD *thd __attribute__((unused)),
 
4041
static int show_table_definitions(Session *session __attribute__((unused)),
4049
4042
                                  SHOW_VAR *var, char *buff)
4050
4043
{
4051
4044
  var->type= SHOW_LONG;
4254
4247
  log_error_file_ptr= log_error_file;
4255
4248
  language_ptr= language;
4256
4249
  mysql_data_home= mysql_real_data_home;
4257
 
  thd_startup_options= (OPTION_AUTO_IS_NULL | OPTION_BIN_LOG |
 
4250
  session_startup_options= (OPTION_AUTO_IS_NULL | OPTION_BIN_LOG |
4258
4251
                        OPTION_QUOTE_SHOW_CREATE | OPTION_SQL_NOTES);
4259
4252
  protocol_version= PROTOCOL_VERSION;
4260
4253
  what_to_log= ~ (1L << (uint) COM_TIME);
4704
4697
    test_flags&= ~TEST_CORE_ON_SIGNAL;
4705
4698
  }
4706
4699
  /* Set global MyISAM variables from delay_key_write_options */
4707
 
  fix_delay_key_write((THD*) 0, OPT_GLOBAL);
 
4700
  fix_delay_key_write((Session*) 0, OPT_GLOBAL);
4708
4701
  /* Set global slave_exec_mode from its option */
4709
4702
  fix_slave_exec_mode(OPT_GLOBAL);
4710
4703
 
4971
4964
}
4972
4965
 
4973
4966
/** Clear most status variables. */
4974
 
void refresh_status(THD *thd)
 
4967
void refresh_status(Session *session)
4975
4968
{
4976
4969
  pthread_mutex_lock(&LOCK_status);
4977
4970
 
4978
4971
  /* Add thread's status variabes to global status */
4979
 
  add_to_status(&global_status_var, &thd->status_var);
 
4972
  add_to_status(&global_status_var, &session->status_var);
4980
4973
 
4981
4974
  /* Reset thread's status variables */
4982
 
  memset(&thd->status_var, 0, sizeof(thd->status_var));
 
4975
  memset(&session->status_var, 0, sizeof(session->status_var));
4983
4976
 
4984
4977
  /* Reset some global variables */
4985
4978
  reset_status_vars();
5007
5000
 
5008
5001
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
5009
5002
/* Used templates */
5010
 
template class I_List<THD>;
5011
 
template class I_List_iterator<THD>;
 
5003
template class I_List<Session>;
 
5004
template class I_List_iterator<Session>;
5012
5005
template class I_List<i_string>;
5013
5006
template class I_List<i_string_pair>;
5014
5007
template class I_List<NAMED_LIST>;