Problem with ReadOnly attribute

"Martin J. Evans" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Organization at home
Message-ID <[email protected]>
The DBI pod says for ReadOnly:

http://search.cpan.org/~timb/DBI-1.628/DBI.pm#ReadOnly

"
An application can set the ReadOnly attribute of a handle to a true 
value to indicate that it will not be attempting to make any changes 
using that handle or any children of it.

Note that the exact definition of 'read only' is rather fuzzy. For more 
details see the documentation for the driver you're using.
"

I have small issue with DBI's ReadOnly attribute. In ODBC it is mapped 
to SQLSetConnectAttr(SQL_ACCESS_MODE) and it just /suggests/ to the 
driver you'll be readonly and not making changes in case this allows the 
driver to optimise things.

However, a driver may not support SQL_ACCESS_MODE in which case it 
returns a SQL_SUCCESS_WITH_INFO and 01S02 - Option value changed, which 
is described as "the driver did not support the value specified in 
ValuePtr and substituted a similar value."

I don't see a way in DBI's pod to report this back i.e., there is no 
return value mentioned.

Should I just issue a warning if I get "option value changed - 01S02"?

The reason this has come up is that I have the following test:

# ReadOnly
{
     $dbh->{ReadOnly} = 1;
     is($dbh->{ReadOnly}, 1, 'ReadOnly set');
     $dbh->{ReadOnly} = 0;
     is($dbh->{ReadOnly}, 0, 'ReadOnly cleared');
}

and the SQLite ODBC driver is failing it because any setting of 
SQL_ACCESS_MODE returns SQL_SUCCESS_WITH_INFO, option value changed, 
01S02 and when you go to retrieve it back it is not what you set.

Martin
-- 
Martin J. Evans
Wetherby, UK
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.