Subject Re: [IBO] Read-Only Database with Firebird 2.1.1 and IBObjects 4.8.7
Author drseltsam2008
--- In IBObjects@yahoogroups.com, Thomas Steinmaurer <ts@...> wrote:
>
> > My Software has an option to archive older data to an read-only
> > marked database which may be stored to a CD or DVD. I created a
> > Viewer program using IBObjects that displays the data. That
worked
> > very well up to Firebird 2.0.3.
> >
> > Now I moved to Firebird 2.1.1. On opening a query with TIBOQuery
> > (IBObjects) I get following error message:
> >
> > attempted update on read-only database.
> >
> > I debugged the source code of IBObjects and found out that
following
> > statement is used before opening the Query:
> >
> > SELECT F.RDB$FIELD_NAME F_FieldName
> > , F.RDB$RELATION_NAME F_RelationName
> > , F.RDB$DEFAULT_SOURCE F_DefaultSource
> > , D.RDB$DEFAULT_SOURCE D_DefaultSource
> > , D.RDB$FIELD_TYPE D_FieldType
> > FROM RDB$RELATION_FIELDS F INNER JOIN RDB$FIELDS D
> > ON D.RDB$FIELD_NAME = F.RDB$FIELD_SOURCE
> > WHERE (( F.RDB$DEFAULT_SOURCE IS NOT NULL ) OR (
D.RDB$DEFAULT_SOURCE
> > IS NOT NULL ))
> > AND NOT F.RDB$RELATION_NAME STARTING WITH 'RDB$'
> > ORDER BY 1
> >
> > I tried some combinitians and found out that follwing statement
fails
> > with that error message:
> >
> > select *
> > from rdb$relation_fields
> > where rdb$default_source is not null
> >
> > The problem seems to be, that I created some columns with default
> > values. I did a workaround for my archive database an elliminate
> > every "default x" from the "create table" statements. Now
everything
> > works fine again.
> >
> > Maybe somebody else have the same problem and knows now what to
do,
> > or Jason reads this (Hi Jason... :-)) and he creates a workaround
in
> > the next version of IBObjects.
>
> The above shouldn't be the reason why it is failing on a read-only
database.
>
> Drop a TIB_MonitorDialog component onto your form, connect it with
your
> connection component and see what's going on. There must be some
kind of
> write operation involved.
>
> The above query works fine for me with TIB_Connection,
TIB_Transaction,
> TIBOQuery. Tried with FB 2.1.0, but not with 2.1.1 though.
>
> --
> Best Regards,
> Thomas Steinmaurer
> LogManager Series - Logging/Auditing Suites supporting
> InterBase, Firebird, Advantage Database, MS SQL Server and
> NexusDB V2
> Upscene Productions
> http://www.upscene.com
> My blog:
> http://blog.upscene.com/thomas/
>

Hi Thomas,

thank you for your answer. I placed the component on my test app und
queried

select * from rdb$relation_fields where rdb$default_source is not
null

this is the log-result:

/*---
[ 05.08.2008 19:24:19 ]
START TRANSACTION
DB HANDLE COUNT 1
TR_HANDLE = 4
----*/
/*---
[ 05.08.2008 19:24:19 ]
ALLOCATE STATEMENT
DB_HANDLE = 1
STMT_HANDLE = 5
----*/
/*---
[ 05.08.2008 19:24:19 ]
PREPARE STATEMENT
TR_HANDLE = 3
STMT_HANDLE = 5

SELECT RDB$PROCEDURE_NAME
FROM RDB$PROCEDURES
ORDER BY RDB$PROCEDURE_NAME ASC

PLAN (RDB$PROCEDURES ORDER RDB$INDEX_21)

FIELDS = [ Version 1 SQLd 1 SQLn 30
RDB$PROCEDURES.RDB$PROCEDURE_NAME = <NIL> ]
----*/
/*===
[ 05.08.2008 19:24:19 ]
//>>> STATEMENT PREPARED <<<//
TIB_Statement.API_Prepare()
TIB_SchemaCursor: "IBO_DefaultSession." stHandle=5
====*/
/*---
[ 05.08.2008 19:24:19 ]
STATEMENT INFO
STMT_HANDLE = 5
----*/
/*---
[ 05.08.2008 19:24:19 ]
EXECUTE STATEMENT
TR_HANDLE = 3
STMT_HANDLE = 5
PARAMS = [ ]
----*/
/*---
[ 05.08.2008 19:24:19 ]
OPEN CURSOR
STMT_HANDLE = 5
NAME = C2577934860719242

----*/
/*---
[ 05.08.2008 19:24:19 ]
CLOSE CURSOR
STMT_HANDLE = 5
----*/
/*---
[ 05.08.2008 19:24:19 ]
COMMIT
TR_HANDLE = 3
----*/
/*---
[ 05.08.2008 19:24:19 ]
START TRANSACTION
DB HANDLE COUNT 1
TR_HANDLE = 6
----*/
/*---
[ 05.08.2008 19:24:19 ]
PREPARE STATEMENT
TR_HANDLE = 6
STMT_HANDLE = 5

SELECT S.RDB$FIELD_NAME
, I.RDB$RELATION_NAME
FROM RDB$RELATION_CONSTRAINTS C
, RDB$INDICES I
, RDB$INDEX_SEGMENTS S
WHERE C.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY'
AND C.RDB$RELATION_NAME = I.RDB$RELATION_NAME
AND C.RDB$INDEX_NAME = I.RDB$INDEX_NAME
AND I.RDB$INDEX_NAME = S.RDB$INDEX_NAME
ORDER BY I.RDB$RELATION_NAME ASC
, S.RDB$FIELD_POSITION ASC

PLAN SORT (JOIN (I NATURAL, S INDEX (RDB$INDEX_6), C INDEX
(RDB$INDEX_43, RDB$INDEX_42)))

FIELDS = [ Version 1 SQLd 2 SQLn 30
RDB$INDEX_SEGMENTS.RDB$FIELD_NAME = <NIL>
RDB$INDICES.RDB$RELATION_NAME = <NIL> ]
----*/
/*===
[ 05.08.2008 19:24:19 ]
//>>> STATEMENT PREPARED <<<//
TIB_Statement.API_Prepare()
TIB_SchemaCursor: "IBO_DefaultSession." stHandle=5
====*/
/*---
[ 05.08.2008 19:24:19 ]
STATEMENT INFO
STMT_HANDLE = 5
----*/
/*---
[ 05.08.2008 19:24:19 ]
EXECUTE STATEMENT
TR_HANDLE = 6
STMT_HANDLE = 5
PARAMS = [ ]

SECONDS = 0,016
----*/
/*---
[ 05.08.2008 19:24:19 ]
OPEN CURSOR
STMT_HANDLE = 5
NAME = C2577942463919243

----*/
/*---
[ 05.08.2008 19:24:19 ]
CLOSE CURSOR
STMT_HANDLE = 5
----*/
/*---
[ 05.08.2008 19:24:19 ]
COMMIT
TR_HANDLE = 6
----*/
/*---
[ 05.08.2008 19:24:19 ]
START TRANSACTION
DB HANDLE COUNT 1
TR_HANDLE = 7
----*/
/*---
[ 05.08.2008 19:24:19 ]
PREPARE STATEMENT
TR_HANDLE = 7
STMT_HANDLE = 5

SELECT S.RDB$FIELD_NAME
FROM RDB$RELATION_CONSTRAINTS C
, RDB$INDICES I
, RDB$INDEX_SEGMENTS S
WHERE C.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY'
AND C.RDB$RELATION_NAME = I.RDB$RELATION_NAME
AND C.RDB$INDEX_NAME = I.RDB$INDEX_NAME
AND I.RDB$INDEX_NAME = S.RDB$INDEX_NAME
AND I.RDB$RELATION_NAME = ? /* RDB$RELATION_NAME */
ORDER BY S.RDB$FIELD_POSITION ASC

PLAN SORT (JOIN (I INDEX (RDB$INDEX_31), S INDEX (RDB$INDEX_6), C
INDEX (RDB$INDEX_43, RDB$INDEX_42)))

FIELDS = [ Version 1 SQLd 1 SQLn 30
RDB$INDEX_SEGMENTS.RDB$FIELD_NAME = <NIL> ]
----*/
/*===
[ 05.08.2008 19:24:19 ]
//>>> STATEMENT PREPARED <<<//
TIB_Statement.API_Prepare()
TIB_Dataset: "IB_Connection1." stHandle=5
====*/
/*---
[ 05.08.2008 19:24:19 ]
DESCRIBE INPUT
STMT_HANDLE = 5
PARAMS = [ Version 1 SQLd 1 SQLn 1
< SQLType: 453 SQLLen: 31 > = <NIL> ]
----*/
/*---
[ 05.08.2008 19:24:19 ]
STATEMENT INFO
STMT_HANDLE = 5
----*/
/*---
[ 05.08.2008 19:24:19 ]
COMMIT
TR_HANDLE = 7
----*/
/*---
[ 05.08.2008 19:24:19 ]
START TRANSACTION
DB HANDLE COUNT 1
TR_HANDLE = 8
----*/
/*---
[ 05.08.2008 19:24:19 ]
EXECUTE STATEMENT
TR_HANDLE = 8
STMT_HANDLE = 5
PARAMS = [ Version 1 SQLd 1 SQLn 1
[RDB$RELATION_NAME] = 'RDB$RELATION_FIELDS ' ]
----*/
/*---
[ 05.08.2008 19:24:19 ]
OPEN CURSOR
STMT_HANDLE = 5
NAME = C2581426470119244

----*/
/*---
[ 05.08.2008 19:24:19 ]
CLOSE CURSOR
STMT_HANDLE = 5
----*/
/*---
[ 05.08.2008 19:24:19 ]
COMMIT
TR_HANDLE = 8
----*/
/*---
[ 05.08.2008 19:24:19 ]
PREPARE STATEMENT
TR_HANDLE = 4
STMT_HANDLE = 2


SELECT RDB$RELATION_FIELDS.*
, RDB$RELATION_FIELDS.RDB$DB_KEY
from rdb$relation_fields
where rdb$default_source is not null

PLAN (RDB$RELATION_FIELDS NATURAL)

FIELDS = [ Version 1 SQLd 20 SQLn 30
RDB$RELATION_FIELDS.RDB$FIELD_NAME = <NIL>
RDB$RELATION_FIELDS.RDB$RELATION_NAME = <NIL>
RDB$RELATION_FIELDS.RDB$FIELD_SOURCE = <NIL>
RDB$RELATION_FIELDS.RDB$QUERY_NAME = <NIL>
RDB$RELATION_FIELDS.RDB$BASE_FIELD = <NIL>
RDB$RELATION_FIELDS.RDB$EDIT_STRING = <NIL>
RDB$RELATION_FIELDS.RDB$FIELD_POSITION = <NIL>
RDB$RELATION_FIELDS.RDB$QUERY_HEADER = <NIL>
RDB$RELATION_FIELDS.RDB$UPDATE_FLAG = <NIL>
RDB$RELATION_FIELDS.RDB$FIELD_ID = <NIL>
RDB$RELATION_FIELDS.RDB$VIEW_CONTEXT = <NIL>
RDB$RELATION_FIELDS.RDB$DESCRIPTION = <NIL>
RDB$RELATION_FIELDS.RDB$DEFAULT_VALUE = <NIL>
RDB$RELATION_FIELDS.RDB$SYSTEM_FLAG = <NIL>
RDB$RELATION_FIELDS.RDB$SECURITY_CLASS = <NIL>
RDB$RELATION_FIELDS.RDB$COMPLEX_NAME = <NIL>
RDB$RELATION_FIELDS.RDB$NULL_FLAG = <NIL>
RDB$RELATION_FIELDS.RDB$DEFAULT_SOURCE = <NIL>
RDB$RELATION_FIELDS.RDB$COLLATION_ID = <NIL>
RDB$RELATION_FIELDS.DB_KEY = <NIL> ]
----*/
/*===
[ 05.08.2008 19:24:19 ]
//>>> STATEMENT PREPARED <<<//
TIB_Statement.API_Prepare()
TIB_Query: "Form1.IB_Query1" stHandle=2
====*/
/*---
[ 05.08.2008 19:24:19 ]
STATEMENT INFO
STMT_HANDLE = 2
----*/
/*---
[ 05.08.2008 19:24:19 ]
EXECUTE STATEMENT
TR_HANDLE = 4
STMT_HANDLE = 2
PARAMS = [ ]
----*/
/*---
[ 05.08.2008 19:24:19 ]
OPEN CURSOR
STMT_HANDLE = 2
NAME = C2566158474819247

----*/
/*---
[ 05.08.2008 19:24:19 ]
INTERPRET BUFFER =

ERRCODE = 38
----*/
/*---
[ 05.08.2008 19:24:19 ]
INTERPRET BUFFER = attempted update on read-only database

ERRCODE = -1
----*/
/*===
[ 05.08.2008 19:24:19 ]
//>>> ERROR <<<//
ISC ERROR CODE:335544765

ISC ERROR MESSAGE:
attempted update on read-only database

STATEMENT:
TIB_Query: "<TApplication>.Form1.IB_Query1." stHandle=2 (ERROR)

//>>> SQL MESSAGE <<<//
SQL ERROR CODE:-817

SQL ERROR MESSAGE:
The insert, update, delete, ddl or authorization statement cannot
be executed because the transaction is inquiry only
====*/
/*---
[ 05.08.2008 19:24:24 ]
CLOSE CURSOR
STMT_HANDLE = 2
----*/

--- END OF THE LOG ---

I don't see any update statements. Does the log help in any kind?

Thank you very much.