From fef9e7c57b003d934ec31acfefe451c5dd45e760 Mon Sep 17 00:00:00 2001 From: Pierre Chifflier Date: Tue, 6 Jan 2009 23:31:18 +0100 Subject: 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 --- output/dbi/ulogd_output_DBI.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'output') 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 +#include + #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 */ -- cgit v1.2.3