Changeset: 508619cb3fb4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=508619cb3fb4
Modified Files:
        clients/odbc/driver/ODBCUtil.c
Branch: default
Log Message:

Implemented {escape 'X'} escape sequence.


diffs (57 lines):

diff --git a/clients/odbc/driver/ODBCUtil.c b/clients/odbc/driver/ODBCUtil.c
--- a/clients/odbc/driver/ODBCUtil.c
+++ b/clients/odbc/driver/ODBCUtil.c
@@ -542,6 +542,53 @@ ODBCTranslateSQL(ODBCDbc *dbc, const SQL
                        free(nquery);
                        nquery = q;
                        q += n;
+               } else if (strncasecmp(p, "escape ", 7) == 0) {
+                       /* note that in ODBC the syntax is
+                        * {escape '\'}
+                        * whereas MonetDB expects
+                        * ESCAPE '\\'
+                        */
+                       char esc;
+                       p += 7;
+                       while (*p == ' ')
+                               p++;
+                       if (*p++ != '\'')
+                               continue;
+                       if (*p == '\'' && p[1] == '\'' && p[2] == '\'') {
+                               esc = '\'';
+                               p += 3;
+                       } else if (*p != '\'' && p[1] == '\'') {
+                               esc = *p;
+                               if (esc & 0200)
+                                       continue;
+                               p += 2;
+                       } else
+                               continue;
+                       while (*p == ' ')
+                               p++;
+                       if (*p++ != '}')
+                               continue;
+                       n = (int) (q - nquery);
+                       pr = (int) (p - q);
+                       q = malloc(length - pr + 13 + 1);
+                       if (q == NULL) {
+                               free(nquery);
+                               return NULL;
+                       }
+                       switch (esc) {
+                       case '\'':
+                               length = (size_t) sprintf(q, "%.*s ESCAPE '''' 
%s", n, nquery, p);
+                               break;
+                       case '\\':
+                               length = (size_t) sprintf(q, "%.*s ESCAPE 
'\\\\' %s", n, nquery, p);
+                               break;
+                       default:
+                               length = (size_t) sprintf(q, "%.*s ESCAPE '%c' 
%s", n, nquery, esc, p);
+                               break;
+                       }
+                       free(nquery);
+                       nquery = q;
+                       q += n;
                } else if (strncasecmp(p, "call ", 5) == 0) {
                        const char *proc, *procend;
 
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to