summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorRomain Bignon <romain@inl.fr>2009-04-17 14:56:19 +0200
committerEric Leblond <eric@inl.fr>2009-04-18 13:25:51 +0200
commitc1c034c930beda542b201d01cf7b9d74baf8af1f (patch)
tree5c77b3adbf2aac6bfdcb7c4d8deaaed200564e13 /util
parent49122eee73d381cb24539e0b81092bf8a4b1870d (diff)
DB plugins: fixed bug with INSERT* procedures
When procedure begins with INSERT* (without space), it considers it as an INSERT statement. Signed-off-by: Romain Bignon <romain@inl.fr>
Diffstat (limited to 'util')
-rw-r--r--util/db.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/util/db.c b/util/db.c
index c2b674e..184ad86 100644
--- a/util/db.c
+++ b/util/db.c
@@ -91,19 +91,22 @@ static int sql_createstmt(struct ulogd_pluginstance *upi)
return -ENOMEM;
}
- if (strncasecmp(procedure, "INSERT INTO", strlen("INSERT INTO")) == 0)
- sprintf(mi->stmt, "%s (", procedure);
+ if (strncasecmp(procedure,"INSERT", strlen("INSERT")) == 0 &&
+ (procedure[strlen("INSERT")] == '\0' ||
+ procedure[strlen("INSERT")] == ' ')) {
+ char buf[ULOGD_MAX_KEYLEN];
+ char *underscore;
- if (strcasecmp(procedure,"INSERT") == 0) {
- if (mi->schema)
- sprintf(mi->stmt, "insert into %s.%s (", mi->schema, table);
+ if(procedure[6] == '\0') {
+ /* procedure == "INSERT" */
+ if (mi->schema)
+ sprintf(mi->stmt, "insert into %s.%s (", mi->schema, table);
+ else
+ sprintf(mi->stmt, "insert into %s (", table);
+ }
else
- sprintf(mi->stmt, "insert into %s (", table);
- }
+ sprintf(mi->stmt, "%s (", procedure);
- if (strncasecmp(procedure,"INSERT", strlen("INSERT")) == 0) {
- char buf[ULOGD_MAX_KEYLEN];
- char *underscore;
mi->stmt_val = mi->stmt + strlen(mi->stmt);
for (i = 0; i < upi->input.num_keys; i++) {