r23876 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23875‎ | r23876 | r23877 >
Date:20:23, 8 July 2007
Author:river
Status:old
Tags:
Comment:
- don't print binlog changes in non-debug mode
- show database name in error messages
- add ignore-database configuration parameter
- change -xarch=amd64 to -m64 for studio 12
Modified paths:
  • /trunk/tools/trainwreck/Makefile (modified) (history)
  • /trunk/tools/trainwreck/status.h (modified) (history)
  • /trunk/tools/trainwreck/trainwreck.c (modified) (history)

Diff [purge]

Index: trunk/tools/trainwreck/status.h
@@ -34,5 +34,4 @@
3535 #define ST_WAIT_FOR_ENTRY 4
3636 #define ST_INITIALISING 5
3737
38 -
3938 #endif /* !STATUS_H */
Index: trunk/tools/trainwreck/trainwreck.c
@@ -95,6 +95,7 @@
9696 static int max_buffer = 0;
9797
9898 regex_t *db_regex;
 99+regex_t *ignore_regex;
99100
100101 static int execute_query(MYSQL *, char const *);
101102
@@ -343,6 +344,15 @@
344345 (void) fprintf(stderr, "error in regular expression \"%s\": %s\n",
345346 value, errbuf);
346347 }
 348+ } else if (!strcmp(opt, "ignore-database")) {
 349+ int err;
 350+ ignore_regex = calloc(1, sizeof(*ignore_regex));
 351+ if ((err = regcomp(ignore_regex, value, REG_EXTENDED | REG_NOSUB)) != 0) {
 352+ char errbuf[1024];
 353+ (void) regerror(err, NULL, errbuf, sizeof(errbuf));
 354+ (void) fprintf(stderr, "error in regular expression \"%s\": %s\n",
 355+ value, errbuf);
 356+ }
347357 } else {
348358 (void) fprintf(stderr, "unknown option \"%s\" in configuration file \"%s\"\n",
349359 opt, cfgfile);
@@ -558,6 +568,7 @@
559569 pthread_mutex_unlock(&rst_mtx);
560570
561571 if ((db_regex == NULL || regexec(db_regex, ent->le_database, 0, NULL, 0) == 0) &&
 572+ (ignore_regex == NULL || regexec(ignore_regex, ent->le_database, 0, NULL, 0) != 0) &&
562573 (ent->le_type == ET_INTVAR || ent->le_type == ET_QUERY)) {
563574 writer_t *writer;
564575 writer = get_writer_for_dbname(ent->le_database);
@@ -872,7 +883,8 @@
873884
874885 self->wr_status = ST_WAIT_FOR_ENTRY;
875886 while ((e = lq_get(&self->wr_log_queue)) != NULL) {
876 - logmsg("%s,%lu [%d: %s]", e->le_file, (unsigned long) e->le_pos,
 887+ if (debug)
 888+ logmsg("%s,%lu [%d: %s]", e->le_file, (unsigned long) e->le_pos,
877889 self->wr_num, e->le_database);
878890
879891 self->wr_status = ST_EXECUTING;
@@ -889,8 +901,9 @@
890902 snprintf(query, sizeof(query), "SET INSERT_ID=%llu",
891903 (unsigned long long) e->le_insert_id);
892904 if (execute_query(self->wr_conn, query) != 0) {
893 - logmsg("%s,%lu: query failed (%u: %s): \"%s\"",
 905+ logmsg("%s,%lu: %s: query failed (%u: %s): \"%s\"",
894906 e->le_file, (unsigned long) e->le_pos,
 907+ e->le_database,
895908 mysql_errno(self->wr_conn), mysql_error(self->wr_conn),
896909 query);
897910 exit(1);
@@ -899,8 +912,9 @@
900913 char *query;
901914 query = e->le_info;
902915 if (execute_query(self->wr_conn, query) != 0) {
903 - logmsg("%s,%lu: query failed (%u: %s): \"%s\"",
 916+ logmsg("%s,%lu: %s: query failed (%u: %s): \"%s\"",
904917 e->le_file, (unsigned long) e->le_pos,
 918+ e->le_database,
905919 mysql_errno(self->wr_conn), mysql_error(self->wr_conn),
906920 query);
907921 exit(1);
Index: trunk/tools/trainwreck/Makefile
@@ -1,5 +1,5 @@
22 CC = cc
3 -CFLAGS = -g -mt -xarch=amd64 -xc99=none
 3+CFLAGS = -g -mt -m64 -xc99=none
44 LDFLAGS =
55 MYSQL_INCLUDES = -I/usr/local/mysql/include
66 MYSQL_LIBS = -L/usr/local/mysql/lib -R/usr/local/mysql/lib -lmysqlclient_r

Status & tagging log