~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/log.cc

  • Committer: Monty Taylor
  • Date: 2008-07-09 16:42:25 UTC
  • mto: (77.6.1 glibclient-merge)
  • mto: This revision was merged to the branch mainline in revision 112.
  • Revision ID: monty@inaugust.com-20080709164225-2r6n4j98nhxh031l
Moved test to tests... 

Show diffs side-by-side

added added

removed removed

Lines of Context:
241
241
 
242
242
 
243
243
/* Check if a given table is opened log table */
244
 
int check_if_log_table(uint db_len, const char *db, uint table_name_len,
245
 
                       const char *table_name, uint check_if_opened)
 
244
int check_if_log_table(uint db_len __attribute__((__unused__)),
 
245
                       const char *db __attribute__((__unused__)),
 
246
                       uint table_name_len __attribute__((__unused__)),
 
247
                       const char *table_name __attribute__((__unused__)),
 
248
                       uint check_if_opened __attribute__((__unused__)))
246
249
{
247
250
  return 0;
248
251
}
284
287
*/
285
288
 
286
289
bool Log_to_file_event_handler::
287
 
  log_general(THD *thd, time_t event_time, const char *user_host,
 
290
  log_general(THD *thd __attribute__((__unused__)),
 
291
              time_t event_time, const char *user_host,
288
292
              uint user_host_len, int thread_id,
289
293
              const char *command_type, uint command_type_len,
290
294
              const char *sql_text, uint sql_text_len,
291
 
              CHARSET_INFO *client_cs)
 
295
              CHARSET_INFO *client_cs __attribute__((__unused__)))
292
296
{
293
297
  return mysql_log.write(event_time, user_host, user_host_len,
294
298
                         thread_id, command_type, command_type_len,
400
404
}
401
405
 
402
406
 
403
 
bool LOGGER::flush_logs(THD *thd)
 
407
bool LOGGER::flush_logs(THD *thd __attribute__((__unused__)))
404
408
{
405
409
  int rc= 0;
406
410
 
555
559
 
556
560
  /* prepare message */
557
561
  if (format)
558
 
    message_buff_len= my_vsnprintf(message_buff, sizeof(message_buff),
 
562
    message_buff_len= vsnprintf(message_buff, sizeof(message_buff),
559
563
                                   format, args);
560
564
  else
561
565
    message_buff[0]= '\0';
611
615
}
612
616
 
613
617
 
614
 
bool LOGGER::activate_log_handler(THD* thd, uint log_type)
 
618
bool LOGGER::activate_log_handler(THD* thd __attribute__((__unused__)),
 
619
                                  uint log_type)
615
620
{
616
621
  MYSQL_QUERY_LOG *file_log;
617
622
  bool res= FALSE;
645
650
}
646
651
 
647
652
 
648
 
void LOGGER::deactivate_log_handler(THD *thd, uint log_type)
 
653
void LOGGER::deactivate_log_handler(THD *thd __attribute__((__unused__)),
 
654
                                    uint log_type)
649
655
{
650
656
  my_bool *tmp_opt= 0;
651
657
  MYSQL_LOG *file_log;
776
782
  return 0;
777
783
}
778
784
 
779
 
static int binlog_close_connection(handlerton *hton, THD *thd)
 
785
static int binlog_close_connection(handlerton *hton __attribute__((__unused__)),
 
786
                                   THD *thd)
780
787
{
781
788
  binlog_trx_data *const trx_data=
782
789
    (binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
888
895
  DBUG_RETURN(error);
889
896
}
890
897
 
891
 
static int binlog_prepare(handlerton *hton, THD *thd, bool all)
 
898
static int binlog_prepare(handlerton *hton __attribute__((__unused__)),
 
899
                          THD *thd __attribute__((__unused__)),
 
900
                          bool all __attribute__((__unused__)))
892
901
{
893
902
  /*
894
903
    do nothing.
914
923
 
915
924
  @see handlerton::commit
916
925
*/
917
 
static int binlog_commit(handlerton *hton, THD *thd, bool all)
 
926
static int binlog_commit(handlerton *hton __attribute__((__unused__)),
 
927
                         THD *thd, bool all)
918
928
{
919
929
  DBUG_ENTER("binlog_commit");
920
930
  binlog_trx_data *const trx_data=
1019
1029
 
1020
1030
  @see handlerton::rollback
1021
1031
*/
1022
 
static int binlog_rollback(handlerton *hton, THD *thd, bool all)
 
1032
static int binlog_rollback(handlerton *hton __attribute__((__unused__)),
 
1033
                           THD *thd, bool all)
1023
1034
{
1024
1035
  DBUG_ENTER("binlog_rollback");
1025
1036
  int error=0;
1088
1099
  that case there is no need to have it in the binlog).
1089
1100
*/
1090
1101
 
1091
 
static int binlog_savepoint_set(handlerton *hton, THD *thd, void *sv)
 
1102
static int binlog_savepoint_set(handlerton *hton __attribute__((__unused__)),
 
1103
                                THD *thd, void *sv)
1092
1104
{
1093
1105
  DBUG_ENTER("binlog_savepoint_set");
1094
1106
 
1101
1113
  DBUG_RETURN(error);
1102
1114
}
1103
1115
 
1104
 
static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv)
 
1116
static int binlog_savepoint_rollback(handlerton *hton __attribute__((__unused__)),
 
1117
                                     THD *thd, void *sv)
1105
1118
{
1106
1119
  DBUG_ENTER("binlog_savepoint_rollback");
1107
1120
 
1303
1316
  if (log_type == LOG_NORMAL)
1304
1317
  {
1305
1318
    char *end;
1306
 
    int len=my_snprintf(buff, sizeof(buff), "%s, Version: %s (%s). "
1307
 
                        "started with:\nTCP Port: %d, Named Pipe: %s\n",
1308
 
                        my_progname, server_version, MYSQL_COMPILATION_COMMENT,
1309
 
                        mysqld_port, ""
1310
 
                       );
 
1319
    int len=snprintf(buff, sizeof(buff), "%s, Version: %s (%s). "
 
1320
                     "started with:\nTCP Port: %d, Named Pipe: %s\n",
 
1321
                     my_progname, server_version, MYSQL_COMPILATION_COMMENT,
 
1322
                     mysqld_port, ""
 
1323
                     );
1311
1324
    end= strnmov(buff + len, "Time                 Id Command    Argument\n",
1312
1325
                 sizeof(buff) - len);
1313
1326
    if (my_b_write(&log_file, (uchar*) buff, (uint) (end-buff)) ||
1491
1504
    TRUE - error occured
1492
1505
*/
1493
1506
 
1494
 
bool MYSQL_QUERY_LOG::write(time_t event_time, const char *user_host,
1495
 
                            uint user_host_len, int thread_id,
 
1507
bool MYSQL_QUERY_LOG::write(time_t event_time,
 
1508
                            const char *user_host __attribute__((__unused__)),
 
1509
                            uint user_host_len __attribute__((__unused__)),
 
1510
                            int thread_id,
1496
1511
                            const char *command_type, uint command_type_len,
1497
1512
                            const char *sql_text, uint sql_text_len)
1498
1513
{
1514
1529
 
1515
1530
        localtime_r(&event_time, &start);
1516
1531
 
1517
 
        time_buff_len= my_snprintf(local_time_buff, MAX_TIME_SIZE,
1518
 
                                   "%02d%02d%02d %2d:%02d:%02d",
1519
 
                                   start.tm_year % 100, start.tm_mon + 1,
1520
 
                                   start.tm_mday, start.tm_hour,
1521
 
                                   start.tm_min, start.tm_sec);
 
1532
        time_buff_len= snprintf(local_time_buff, MAX_TIME_SIZE,
 
1533
                                "%02d%02d%02d %2d:%02d:%02d",
 
1534
                                start.tm_year % 100, start.tm_mon + 1,
 
1535
                                start.tm_mday, start.tm_hour,
 
1536
                                start.tm_min, start.tm_sec);
1522
1537
 
1523
1538
        if (my_b_write(&log_file, (uchar*) local_time_buff, time_buff_len))
1524
1539
          goto err;
1528
1543
          goto err;
1529
1544
 
1530
1545
      /* command_type, thread_id */
1531
 
      length= my_snprintf(buff, 32, "%5ld ", (long) thread_id);
 
1546
      length= snprintf(buff, 32, "%5ld ", (long) thread_id);
1532
1547
 
1533
1548
    if (my_b_write(&log_file, (uchar*) buff, length))
1534
1549
      goto err;
1592
1607
*/
1593
1608
 
1594
1609
bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time,
1595
 
                            time_t query_start_arg, const char *user_host,
 
1610
                            time_t query_start_arg __attribute__((__unused__)),
 
1611
                            const char *user_host,
1596
1612
                            uint user_host_len, ulonglong query_utime,
1597
1613
                            ulonglong lock_utime, bool is_command,
1598
1614
                            const char *sql_text, uint sql_text_len)
1624
1640
        struct tm start;
1625
1641
        localtime_r(&current_time, &start);
1626
1642
 
1627
 
        buff_len= my_snprintf(buff, sizeof buff,
1628
 
                              "# Time: %02d%02d%02d %2d:%02d:%02d\n",
1629
 
                              start.tm_year % 100, start.tm_mon + 1,
1630
 
                              start.tm_mday, start.tm_hour,
1631
 
                              start.tm_min, start.tm_sec);
 
1643
        buff_len= snprintf(buff, sizeof buff,
 
1644
                           "# Time: %02d%02d%02d %2d:%02d:%02d\n",
 
1645
                           start.tm_year % 100, start.tm_mon + 1,
 
1646
                           start.tm_mday, start.tm_hour,
 
1647
                           start.tm_min, start.tm_sec);
1632
1648
 
1633
1649
        /* Note that my_b_write() assumes it knows the length for this */
1634
1650
        if (my_b_write(&log_file, (uchar*) buff, buff_len))
3849
3865
    if (log_file.type == WRITE_CACHE && log_type == LOG_BIN)
3850
3866
    {
3851
3867
      my_off_t offset= BIN_LOG_HEADER_SIZE + FLAGS_OFFSET;
3852
 
      my_off_t org_position= my_tell(log_file.file, MYF(0));
3853
3868
      uchar flags= 0;            // clearing LOG_EVENT_BINLOG_IN_USE_F
3854
3869
      pwrite(log_file.file, &flags, 1, offset);
3855
3870
    }
4023
4038
    signature to be compatible with other logging routines, which could
4024
4039
    return an error (e.g. logging to the log tables)
4025
4040
*/
4026
 
static void print_buffer_to_file(enum loglevel level, int error_code,
4027
 
                                 const char *buffer, size_t buffer_length)
 
4041
static void print_buffer_to_file(enum loglevel level,
 
4042
                                 int error_code __attribute__((__unused__)),
 
4043
                                 const char *buffer,
 
4044
                                 size_t buffer_length __attribute__((__unused__)))
4028
4045
{
4029
4046
  time_t skr;
4030
4047
  struct tm tm_tmp;
4063
4080
  int error_code= errno;
4064
4081
  DBUG_ENTER("vprint_msg_to_log");
4065
4082
 
4066
 
  length= my_vsnprintf(buff, sizeof(buff), format, args);
 
4083
  length= vsnprintf(buff, sizeof(buff), format, args);
4067
4084
 
4068
4085
  print_buffer_to_file(level, error_code, buff, length);
4069
4086
 
4359
4376
    to the position in memory where xid was logged to.
4360
4377
*/
4361
4378
 
4362
 
int TC_LOG_MMAP::log_xid(THD *thd, my_xid xid)
 
4379
int TC_LOG_MMAP::log_xid(THD *thd __attribute__((__unused__)), my_xid xid)
4363
4380
{
4364
4381
  int err;
4365
4382
  PAGE *p;
4471
4488
  cookie points directly to the memory where xid was logged.
4472
4489
*/
4473
4490
 
4474
 
void TC_LOG_MMAP::unlog(ulong cookie, my_xid xid)
 
4491
void TC_LOG_MMAP::unlog(ulong cookie, my_xid xid __attribute__((__unused__)))
4475
4492
{
4476
4493
  PAGE *p=pages+(cookie/tc_log_page_size);
4477
4494
  my_xid *x=(my_xid *)(data+cookie);
4730
4747
  DBUG_RETURN(!binlog_end_trans(thd, trx_data, &xle, TRUE));
4731
4748
}
4732
4749
 
4733
 
void TC_LOG_BINLOG::unlog(ulong cookie, my_xid xid)
 
4750
void TC_LOG_BINLOG::unlog(ulong cookie __attribute__((__unused__)),
 
4751
                          my_xid xid __attribute__((__unused__)))
4734
4752
{
4735
4753
  pthread_mutex_lock(&LOCK_prep_xids);
4736
4754
  DBUG_ASSERT(prepared_xids > 0);