summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi Inoue2006-04-04 20:26:45 +0000
committerHiroshi Inoue2006-04-04 20:26:45 +0000
commit2b19338dd886c6f5a36d247cfa32d2606e945e09 (patch)
treeb12d873aba5a542761b82c0fd6a7400614bf9277
parentfcfacd0ffd5f7e7fc439966efa81a3cafe6ed91d (diff)
Fix a SQLNumParams bug reported by lasse haataja.REL-07_03_ENHANCED
-rw-r--r--bind.c46
-rw-r--r--convert.c2
-rw-r--r--info.c2
-rw-r--r--version.h2
4 files changed, 34 insertions, 18 deletions
diff --git a/bind.c b/bind.c
index 2ae942c..aba623e 100644
--- a/bind.c
+++ b/bind.c
@@ -13,6 +13,8 @@
*-------
*/
+#include <stdlib.h>
+#include <string.h>
#include "bind.h"
#include "environ.h"
@@ -20,8 +22,7 @@
#include "descriptor.h"
#include "qresult.h"
#include "pgtypes.h"
-#include <stdlib.h>
-#include <string.h>
+#include "multibyte.h"
#include "pgapifunc.h"
@@ -419,7 +420,7 @@ PGAPI_NumParams(
{
StatementClass *stmt = (StatementClass *) hstmt;
CSTR func = "PGAPI_NumParams";
- char literal_quote = LITERAL_QUOTE, identifier_quote = IDENTIFIER_QUOTE, dollar_quote = '$';
+ char literal_quote = LITERAL_QUOTE, identifier_quote = IDENTIFIER_QUOTE, escape_in_literal = ESCAPE_IN_LITERAL, dollar_quote = '$';
mylog("%s: entering...\n", func);
@@ -449,21 +450,30 @@ inolog("num_params=%d,%d\n", stmt->num_params, stmt->proc_return);
{
const char *sptr, *tag = NULL;
int taglen;
- char bchar;
+ char tchar, bchar;
char in_literal = FALSE, in_identifier = FALSE,
- in_dollar_quote = FALSE, multi = FALSE, del_found = FALSE;
+ in_dollar_quote = FALSE, in_escape = FALSE,
+ multi = FALSE, del_found = FALSE;
+ encoded_str encstr;
stmt->proc_return = 0;
+ make_encoded_str(&encstr, SC_get_conn(stmt), stmt->statement);
for (sptr = stmt->statement, bchar = '\0'; *sptr; sptr++)
{
+ tchar = encoded_nextchar(&encstr);
+ if (ENCODE_STATUS(encstr) != 0) /* multibyte char */
+ {
+ bchar = tchar;
+ continue;
+ }
if (!multi && del_found)
{
- if (!isspace(*sptr))
+ if (!isspace(tchar))
multi = TRUE;
}
if (in_dollar_quote)
{
- if (*sptr == dollar_quote)
+ if (tchar == dollar_quote)
{
if (strncmp(sptr, tag, taglen) == 0)
{
@@ -476,25 +486,29 @@ inolog("num_params=%d,%d\n", stmt->num_params, stmt->proc_return);
}
else if (in_literal)
{
- if (*sptr == literal_quote)
+ if (in_escape)
+ in_escape = FALSE;
+ else if (tchar == escape_in_literal)
+ in_escape = TRUE;
+ else if (tchar == literal_quote)
in_literal = FALSE;
}
else if (in_identifier)
{
- if (*sptr == identifier_quote)
+ if (tchar == identifier_quote)
in_identifier = FALSE;
}
else
{
- if (*sptr == '?')
+ if (tchar == '?')
{
if (0 == *pcpar && bchar == '{')
stmt->proc_return = 1;
(*pcpar)++;
}
- else if (*sptr == ';')
+ else if (tchar == ';')
del_found = TRUE;
- else if (*sptr == dollar_quote)
+ else if (tchar == dollar_quote)
{
char *dollar_next;
@@ -507,12 +521,12 @@ inolog("num_params=%d,%d\n", stmt->num_params, stmt->proc_return);
sptr = dollar_next;
}
}
- else if (*sptr == literal_quote)
+ else if (tchar == literal_quote)
in_literal = TRUE;
- else if (*sptr == identifier_quote)
+ else if (tchar == identifier_quote)
in_identifier = TRUE;
- if (!isspace(*sptr))
- bchar = *sptr;
+ if (!isspace(tchar))
+ bchar = tchar;
}
}
stmt->num_params = *pcpar;
diff --git a/convert.c b/convert.c
index 80ab698..8cc01db 100644
--- a/convert.c
+++ b/convert.c
@@ -839,9 +839,11 @@ inolog("2stime fr=%d\n", std_time.fr);
needbuflen = len;
switch (fCType)
{
+#ifdef UNICODE_SUPPORT
case SQL_C_WCHAR:
needbuflen += WCLEN;
break;
+#endif /* UNICODE_SUPPORT */
case SQL_C_BINARY:
break;
default:
diff --git a/info.c b/info.c
index b46e7fb..6f6c2df 100644
--- a/info.c
+++ b/info.c
@@ -1729,7 +1729,7 @@ mylog("simple in=%s(%d)\n", src, srclen);
dest[outlen++] = *in;
continue;
}
- if ('\'' == *in ||
+ if (LITERAL_QUOTE == *in ||
escape_ch == *in)
dest[outlen++] = *in;
dest[outlen++] = *in;
diff --git a/version.h b/version.h
index 5de6d74..47fdc88 100644
--- a/version.h
+++ b/version.h
@@ -11,6 +11,6 @@
#define POSTGRESDRIVERVERSION "07.03.0262"
#define POSTGRES_RESOURCE_VERSION "07.03.0262\0"
-#define PG_DRVFILE_VERSION 7,3,2,62
+#define PG_DRVFILE_VERSION 7,3,2,62
#endif