Simon Oliver wrote:

>Tim Bunce wrote:
>
>>FYI, here's what I'm playing with at the moment:
>>
>>    sub quote_identifier {
>>        my $dbh = shift;
>>        my @id  = grep { defined } @_;  # ignore null elements (ie catalog, schema)
>>        s/"/""/g    foreach @id;        # escape embedded quotes
>>        $_=qq{"$_"} foreach @id;        # quote the element
>>        return join '.', @id;           # ... and join the dots
>>    }
>>
>>Any drivers that need different behaviour will need to define their
>>own method to override this default.
>>
>
>Makes sense.  DBD coders should be *encouraged* to override this method if the
>undelying DBMS is capable of changes to the quoting behaviour.  This would
>include DBD::ODBC, DBD::ADO, DBD::Sybase, DBD::ASAny to name a few that I know
>this applies to.  
>
>As an example, if quoted identifiers is turned off as a database option then
>then the DBD's overriding method should realise this and return a non-quoted
>identifier.
>
>And any method that returns an identifier should pass it through
>$dbh->quote_identifier as matter of course.  Currently I think this only
>applied to $dbh->tables, but I forsee the list growing with the inclusion of
>AnyDBD interface, new metadata methods and SQL rewriting stuff.
>
>Happy New Year
>
>--
>  Simon Oliver
>

Hmmmm, basically, I see what's going on.  Informix only supports 
delimited identifiers if the environment variable DELIMIDENT is set when 
the connection is initiated, which will make this very difficult to 
handle.  In the absence of DELIMIDENT, Informix allows both single 
quotes and double quotes to identify strings (an issue predating the SQL 
standards on the subject).  So, although the method outlined by Tim is 
correct, it won't work usefully unless DELIMIDENT is set, and DELIMIDENT 
needs to be set prior to making the connection so it can't be handled 
when the quote_identifier method is called.  So, it would be useful if 
there was a connection time attribute that could be set indicating that 
delimited identifiers will be used -- if that's available, DBD::Informix 
can set DELIMIDENT before creating the connection and then all will be 
fine.  Without that, Informix won't be able to do much -- you'll simply 
get (at best) syntax errors and (at worst) misunderstood SQL.

-- 
Jonathan Leffler ([EMAIL PROTECTED], [EMAIL PROTECTED])
Guardian of DBD::Informix 1.00.PC1 -- see http://www.cpan.org/
#include <disclaimer.h>



Reply via email to