diff options
author | Luis Fernando Muñoz Mejías <Luis.Fernando.Munoz.Mejias@cern.ch> | 2009-04-15 16:53:18 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2009-04-16 15:26:09 +0200 |
commit | f89b761c84270cde71e0a6275ea80bb20f60d2df (patch) | |
tree | 5148a0d6930532712661e96c7634ed2aeb06dea9 /plugins/omoracle | |
parent | 24fcd96203c9b8b84a8414cea19dcb3ba989c9ba (diff) | |
download | rsyslog-f89b761c84270cde71e0a6275ea80bb20f60d2df.tar.gz rsyslog-f89b761c84270cde71e0a6275ea80bb20f60d2df.tar.xz rsyslog-f89b761c84270cde71e0a6275ea80bb20f60d2df.zip |
Make the counting of bind parameters aware of literals.
Literal strings passed in the statement may contain ':', let's not
count them.
Diffstat (limited to 'plugins/omoracle')
-rw-r--r-- | plugins/omoracle/omoracle.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/plugins/omoracle/omoracle.c b/plugins/omoracle/omoracle.c index 12efd61c..b598192f 100644 --- a/plugins/omoracle/omoracle.c +++ b/plugins/omoracle/omoracle.c @@ -180,14 +180,21 @@ static int oci_errors(void* handle, ub4 htype, sword status) } /** Returns the number of bind parameters for the statement given as - * an argument. */ + * an argument. It counts the number of appearances of ':', as in + * + * insert into foo(bar, baz) values(:bar, :baz) + * + * while taking in account that string literals must not be parsed. */ static int count_bind_parameters(char* p) { int n = 0; + int enable = 1; for (; *p; p++) - if (*p == BIND_MARK) + if (enable && *p == BIND_MARK ) n++; + else if (*p == '\'') + enable ^= 1; dbgprintf ("omoracle statement has %d parameters\n", n); return n; } @@ -429,7 +436,6 @@ CODESTARTdoAction } for (i = 0; i < pData->batch.arguments && params[i]; i++) { - dbgprintf ("omoracle argument on batch[%d][%d]: %s\n", i, n, params[i]); pData->batch.parameters[i][n] = strdup(params[i]); CHKmalloc(pData->batch.parameters[i][n]); } |