From: | Gregory Seidman <gss+pg(at)cs(dot)brown(dot)edu> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: SQL server application porting headache |
Date: | 2002-06-24 17:49:12 |
Message-ID: | 20020624174911.GA15662@cs.brown.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Oskar Berggren sez:
[...]
} I'm getting ready to give up and recommend to my bosses that we hire
} a consultant to run the darn thing on Windows and SQL Server. Which
} I suppose means that Microsoft has succeeded with their little strange
} case-sensitivity trick. Anyway, I will talk to the head developer
} at the company that made the application tomorrow and we'll see what
} happens.
Hm. Perhaps you could mess with the ODBC driver (and install it under a
different name, I expect) so that it lowercases everything not in single
quotes, and strips double quotes. It's a hack, but it sounds like it would
work plausibly at a small performance cost. An appropriate function:
/* assumes inbuf is null-terminated and outbuf is allocated at least as
* large as inbuf; inbuf *must* be the entire query else quotes might get
* unbalanced; ignores all i18n considerations; outbuf will be filled with
* the stripped and sanitized null-terminated string, no larger than inbuf
*/
void
strip_and_sanitize(const char *inbuf, char *outbuf) {
/* these are boolean flags */
int escmode = 0;
int quotemode = 0;
char *iptr = inbuf;
char *optr = outbuf;
while (*iptr) {
char ochar = *iptr;
if (escmode) {
escmode = 0;
} else {
switch (ochar) {
case '\\':
escmode = 1;
break;
case '"';
if (!quotemode)
ochar = 0;
break;
case '\'':
quotemode ^= 1; /* toggle */
break;
default:
if (!quotemode)
ochar = tolower(ochar);
}
}
if (ochar)
*(optr++) = ochar;
++iptr;
}
*optr = 0;
}
} regards,
} Oskar
--Greg
From | Date | Subject | |
---|---|---|---|
Next Message | William N. Zanatta | 2002-06-24 17:57:13 | Help with Arrays and References |
Previous Message | Stephan Szabo | 2002-06-24 17:48:33 | Re: Need help on index!!! |