Index: trunk/tools/trainwreck/status.h |
— | — | @@ -34,5 +34,4 @@ |
35 | 35 | #define ST_WAIT_FOR_ENTRY 4 |
36 | 36 | #define ST_INITIALISING 5 |
37 | 37 | |
38 | | - |
39 | 38 | #endif /* !STATUS_H */ |
Index: trunk/tools/trainwreck/trainwreck.c |
— | — | @@ -95,6 +95,7 @@ |
96 | 96 | static int max_buffer = 0; |
97 | 97 | |
98 | 98 | regex_t *db_regex; |
| 99 | +regex_t *ignore_regex; |
99 | 100 | |
100 | 101 | static int execute_query(MYSQL *, char const *); |
101 | 102 | |
— | — | @@ -343,6 +344,15 @@ |
344 | 345 | (void) fprintf(stderr, "error in regular expression \"%s\": %s\n", |
345 | 346 | value, errbuf); |
346 | 347 | } |
| 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 | + } |
347 | 357 | } else { |
348 | 358 | (void) fprintf(stderr, "unknown option \"%s\" in configuration file \"%s\"\n", |
349 | 359 | opt, cfgfile); |
— | — | @@ -558,6 +568,7 @@ |
559 | 569 | pthread_mutex_unlock(&rst_mtx); |
560 | 570 | |
561 | 571 | 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) && |
562 | 573 | (ent->le_type == ET_INTVAR || ent->le_type == ET_QUERY)) { |
563 | 574 | writer_t *writer; |
564 | 575 | writer = get_writer_for_dbname(ent->le_database); |
— | — | @@ -872,7 +883,8 @@ |
873 | 884 | |
874 | 885 | self->wr_status = ST_WAIT_FOR_ENTRY; |
875 | 886 | 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, |
877 | 889 | self->wr_num, e->le_database); |
878 | 890 | |
879 | 891 | self->wr_status = ST_EXECUTING; |
— | — | @@ -889,8 +901,9 @@ |
890 | 902 | snprintf(query, sizeof(query), "SET INSERT_ID=%llu", |
891 | 903 | (unsigned long long) e->le_insert_id); |
892 | 904 | 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\"", |
894 | 906 | e->le_file, (unsigned long) e->le_pos, |
| 907 | + e->le_database, |
895 | 908 | mysql_errno(self->wr_conn), mysql_error(self->wr_conn), |
896 | 909 | query); |
897 | 910 | exit(1); |
— | — | @@ -899,8 +912,9 @@ |
900 | 913 | char *query; |
901 | 914 | query = e->le_info; |
902 | 915 | 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\"", |
904 | 917 | e->le_file, (unsigned long) e->le_pos, |
| 918 | + e->le_database, |
905 | 919 | mysql_errno(self->wr_conn), mysql_error(self->wr_conn), |
906 | 920 | query); |
907 | 921 | exit(1); |
Index: trunk/tools/trainwreck/Makefile |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | CC = cc |
3 | | -CFLAGS = -g -mt -xarch=amd64 -xc99=none |
| 3 | +CFLAGS = -g -mt -m64 -xc99=none |
4 | 4 | LDFLAGS = |
5 | 5 | MYSQL_INCLUDES = -I/usr/local/mysql/include |
6 | 6 | MYSQL_LIBS = -L/usr/local/mysql/lib -R/usr/local/mysql/lib -lmysqlclient_r |