]> git.ipfire.org Git - thirdparty/ulogd2.git/commitdiff
DBI: lower column name before comparing to key
authorPierre Chifflier <chifflier@inl.fr>
Tue, 6 Jan 2009 22:31:18 +0000 (23:31 +0100)
committerEric Leblond <eric@inl.fr>
Tue, 6 Jan 2009 23:14:20 +0000 (00:14 +0100)
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>
output/dbi/ulogd_output_DBI.c

index 7c0f4fa16240e6a75b8e9ec8e75d8b01b5decf72..88730e605d779170b84a5d0d1bb87693c54c9542 100644 (file)
@@ -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 */