diff options
author | Pierre Chifflier <chifflier@inl.fr> | 2009-01-06 23:31:18 +0100 |
---|---|---|
committer | Eric Leblond <eric@inl.fr> | 2009-01-07 00:14:20 +0100 |
commit | fef9e7c57b003d934ec31acfefe451c5dd45e760 (patch) | |
tree | 22ce5a98f62cea2ade16d120ba0c3f35c2598d4f /output/dbi | |
parent | acc52090393384c8e8d1994b32363895d5afb371 (diff) |
DBI: lower column name before comparing to key
Some databases (e.g Oracle) return column name in uppercase, while
key name is in lowercase. This patch allows to match keys correctly.
Signed-off-by: Pierre Chifflier <chifflier@inl.fr>
Diffstat (limited to 'output/dbi')
-rw-r--r-- | output/dbi/ulogd_output_DBI.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/output/dbi/ulogd_output_DBI.c b/output/dbi/ulogd_output_DBI.c index 7c0f4fa..88730e6 100644 --- a/output/dbi/ulogd_output_DBI.c +++ b/output/dbi/ulogd_output_DBI.c @@ -21,6 +21,8 @@ #include <dbi.h> +#include <ctype.h> + #ifdef DEBUG_DBI #define DEBUGP(x, args...) fprintf(stderr, x, ## args) #else @@ -86,6 +88,16 @@ static struct config_keyset dbi_kset = { #define schema_ce(x) (x->ces[DB_CE_NUM+5]) #define dbtype_ce(x) (x->ces[DB_CE_NUM+6]) + +/* lower-cases s in place */ +static void str_tolower(char *s) +{ + while(*s) { + *s = tolower(*s); + s++; + } +} + /* find out which columns the table has */ static int get_columns_dbi(struct ulogd_pluginstance *upi) { @@ -139,6 +151,8 @@ static int get_columns_dbi(struct ulogd_pluginstance *upi) while ((underscore = strchr(buf, '_'))) *underscore = '.'; + str_tolower(buf); + DEBUGP("field '%s' found: ", buf); /* add it to list of input keys */ |