Hello Henning
I just needed something quick and dirty so I just added the following
function and used it instead of escape_common. This works fine with
Oracle.
int sql_escape(char *dst, char *src, int src_len)
{
int i, j;
if(dst==0 || src==0 || src_len<=0)
return 0;
j = 0;
for(i=0; i<src_len; i++)
{
switch(src[i])
{
case '\'':
dst[j++] = '\'';
dst[j++] = src[i];
break;
default:
dst[j++] = src[i];
}
}
return j;
}
It would be nice to add this as a configuration parameter in the future.
thanks
George
-----Original Message-----
From: Henning Westerholt [mailto:henning.westerholt@1und1.de]
Sent: Thursday, June 21, 2007 12:00 PM
To: users(a)openser.org
Cc: Papadopoulos Georgios
Subject: Re: [Users] unixodbc: use_escape_common
On Donnerstag, 7. Juni 2007, Papadopoulos Georgios wrote:
Hello all,
I am using
modparam("unixodbc", "use_escape_common", 1) and the result
is that if
I have a string like he'llo (single quote
between the e and l), it
becomes he\'llo which is not working in sql.
The result should be he''llo (two single quotes between e
and l). The
reason is that unixodbc uses the core function
escape_common(). I
think that unixodbc whould have two parameters like
modparam("unixodbc", "use_escape_character", "'")
modparam("unixodbc",
"escaped_characters",
"'\%^") use_escape_character would be null by
default and if it is not null it would be the character to use for
escaping.
escaped_characters would be a list of characters that should be
escaped by the character defined above.
I have patched unixodbc to use its own escape function
instead, but it
would be nice if this was a configurable option
that others
could use.
I could try to implement this if there is an
interest.
Please let me
know your thoughts.
Hello George,
sorry for the late reply. Yes, improvements of the unixodbc
escape functions would be nice. Do you add another function
for escaping to unixodbc, or do you use some provided
functions from the odbc driver?
In the past we had the problem that different odbc drivers
need different escape signs. So the mechanism you suggested
above (have options for the
escaping) would provide a solution for this problem.
Cheers,
Henning
Disclaimer
The information in this e-mail and any attachments is confidential. It is intended solely
for the attention and use of the named addressee(s). If you are not the intended
recipient, or person responsible for delivering this information to the intended
recipient, please notify the sender immediately. Unless you are the intended recipient or
his/her representative you are not authorized to, and must not, read, copy, distribute,
use or retain this message or any part of it. E-mail transmission cannot be guaranteed to
be secure or error-free as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses.