[PATCH 6/6] DBI: lower column name before comparing to key

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
 output/dbi/ulogd_output_DBI.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/output/dbi/ulogd_output_DBI.c b/output/dbi/ulogd_output_DBI.c
index 7c0f4fa..3f086fc 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,17 @@ 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 +152,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 */
-- 
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux