Subject | Re: [IBO] Problem with field alias in 4.9.13 Beta 25 |
---|---|
Author | Thomas Steinmaurer |
Post date | 2011-05-09T13:15:18Z |
>> after upgrading to 4.9.13 Beta 25, it seems there is something messed upAn additional observation with TIB_MonitorDialog with the Rows option
>> when accessing a field in a result set by field alias name.
>>
>> With a TIB_Cursor. The following SQL statement:
>>
>> select
>> count(rdb$trigger_name) as anzahl
>> from
>> rdb$triggers
>> where
>> rdb$trigger_name=:trigger_name
>> and rdb$relation_name=:relation_name
>>
>>
>> Using the cursor like that:
>>
>>
>> c1.Close;
>> c1.ParamByName('trigger_name').AsString := ATriggerName;
>> c1.ParamByName('relation_name').AsString := ATableName;
>> c1.First;
>> Result := c1.FieldByName('anzahl').AsInteger> 0;<= exception here
>>
>>
>>
>> Worked fine with e.g. 4.9.8.
>
> The bad thing is, I can't reproduce with a simple application
> (TIB_Connection, TIB_Cursor).
>
> While I can't access the result field in my production application by
> name, I can by field index => .Fields[0].AsInteger. The interesting
> thing is, that .Fields[0].FieldName equals to 'RDB$RELATION_NAME' and
> NOT 'anzahl'.
>
> Weird.
enabled. See appendix below. A summary:
At the PREPARE STATEMENT, my query gets a STMT_HANDLE = 20. After that,
there is another, I guess IBO-generated SQL statement with STMT_HANDLE =
22. Executing/fetching of statement with handle 22 ends with ERRCODE
100. After that, a fetch for my statement (STMT_HANDLE = 20) has
RDB$RELATION_FIELDS.RDB$RELATION_NAME in the result fields included,
which looks like the one from the IBO-generated SQL statement with
STMT_HANDLE = 22.
Does this investigation helps somehow?
Thanks,
Thomas
Appendix:
/*---
START TRANSACTION
DB HANDLE COUNT 1
DB HANDLE 1 = 1
TPB VERSION 3
write
read_committed
rec_version
nowait
TR_HANDLE = 19
SECONDS = 0,015
----*/
/*---
EXECUTE IMMEDIATE
DB_HANDLE = 1
TR_HANDLE = 19
drop trigger TRI_KEYWORD_TABLE_TEST_L_D
PARAMS = [ ]
SECONDS = 0,031
----*/
/*---
START TRANSACTION
DB HANDLE COUNT 1
DB HANDLE 1 = 1
TPB VERSION 3
write
read_committed
rec_version
nowait
TR_HANDLE = 21
----*/
/*---
PREPARE STATEMENT
TR_HANDLE = 21
STMT_HANDLE = 20
select
count(rdb$trigger_name) anzahl
from
rdb$triggers
where
rdb$trigger_name=? /* trigger_name */
and rdb$relation_name=? /* relation_name */
PLAN (RDB$TRIGGERS INDEX (RDB$INDEX_8))
FIELDS = [ Version 1 SQLd 1 SQLn 30
[ANZAHL] = <NIL> ]
----*/
/*---
EXECUTE IMMEDIATE 2
DB_HANDLE = 1
TR_HANDLE = 3
SELECT D.RDB$CHARACTER_SET_NAME FROM RDB$DATABASE D
PARAMS = [ ]
FIELDS = [ Version 1 SQLd 1 SQLn 1
[CHARSET] = 'NONE
' (93 of 1022 bytes) ]
----*/
/*---
PREPARE STATEMENT
TR_HANDLE = 3
STMT_HANDLE = 22
SELECT R.RDB$RELATION_NAME
, R.RDB$FIELD_NAME
, F.RDB$CHARACTER_LENGTH
, C.RDB$CHARACTER_SET_NAME
FROM RDB$RELATION_FIELDS R
JOIN RDB$FIELDS F
ON F.RDB$FIELD_NAME = R.RDB$FIELD_SOURCE
JOIN RDB$CHARACTER_SETS C
ON C.RDB$CHARACTER_SET_ID = F.RDB$CHARACTER_SET_ID
AND C.RDB$CHARACTER_SET_NAME <>
( SELECT D.RDB$CHARACTER_SET_NAME
FROM RDB$DATABASE D )
WHERE R.RDB$RELATION_NAME NOT STARTING WITH 'RDB$'
AND R.RDB$RELATION_NAME NOT STARTING WITH 'MON$'
AND ( R.RDB$SYSTEM_FLAG <> 1 OR R.RDB$SYSTEM_FLAG IS NULL )
AND F.RDB$CHARACTER_SET_ID IS NOT NULL
ORDER BY R.RDB$RELATION_NAME ASC
, R.RDB$FIELD_POSITION ASC
PLAN (D NATURAL)
PLAN SORT (JOIN (F NATURAL, C INDEX (RDB$INDEX_25), R INDEX (RDB$INDEX_3)))
FIELDS = [ Version 1 SQLd 4 SQLn 30
RDB$RELATION_FIELDS.RDB$RELATION_NAME = <NIL>
RDB$RELATION_FIELDS.RDB$FIELD_NAME = <NIL>
RDB$FIELDS.RDB$CHARACTER_LENGTH = <NIL>
RDB$CHARACTER_SETS.RDB$CHARACTER_SET_NAME = <NIL> ]
SECONDS = 0,016
----*/
/*---
EXECUTE STATEMENT
TR_HANDLE = 3
STMT_HANDLE = 22
PARAMS = [ ]
----*/
/*---
FETCH
STMT_HANDLE = 22
FIELDS = [ Version 1 SQLd 4 SQLn 4
RDB$RELATION_FIELDS.RDB$RELATION_NAME = <NULL>
RDB$RELATION_FIELDS.RDB$FIELD_NAME = <NULL>
RDB$FIELDS.RDB$CHARACTER_LENGTH = <NULL>
RDB$CHARACTER_SETS.RDB$CHARACTER_SET_NAME = <NULL> ]
ERRCODE = 100
----*/
/*---
EXECUTE STATEMENT
TR_HANDLE = 21
STMT_HANDLE = 20
PARAMS = [ Version 1 SQLd 2 SQLn 2
[TRIGGER_NAME] = 'TRI_KEYWORD_TABLE_TEST2_L_D
' (93 bytes)
[RELATION_NAME] = 'KEYWORD_TABLE_TEST
' (93 bytes) ]
----*/
/*---
FETCH
STMT_HANDLE = 20
FIELDS = [ Version 1 SQLd 1 SQLn 1
RDB$RELATION_FIELDS.RDB$RELATION_NAME = '1
' (93
bytes) ]
----*/
/*---
EXECUTE IMMEDIATE
DB_HANDLE = 1
TR_HANDLE = 19
drop trigger TRI_KEYWORD_TABLE_TEST2_L_D
PARAMS = [ ]
SECONDS = 0,046
----*/
/*---
EXECUTE STATEMENT
TR_HANDLE = 21
STMT_HANDLE = 20
PARAMS = [ Version 1 SQLd 2 SQLn 2
[TRIGGER_NAME] = 'TRI_KEYWORD_TABLE_TEST3_L_D
' (93 bytes)
[RELATION_NAME] = 'KEYWORD_TABLE_TEST
' (93 bytes) ]
----*/
/*---
FETCH
STMT_HANDLE = 20
FIELDS = [ Version 1 SQLd 1 SQLn 1
RDB$RELATION_FIELDS.RDB$RELATION_NAME = '1
' (93
bytes) ]
----*/
/*---
EXECUTE IMMEDIATE
DB_HANDLE = 1
TR_HANDLE = 19
drop trigger TRI_KEYWORD_TABLE_TEST3_L_D
PARAMS = [ ]
SECONDS = 0,032
----*/
/*---
EXECUTE IMMEDIATE
DB_HANDLE = 1
TR_HANDLE = 19
delete from IBLM$COLUMNLOGDEF where (TABLE_NAME = 'KEYWORD_TABLE_TEST')
and ((OPERATION = 'DELETE') or (OPERATION = 'D'))
PARAMS = [ ]
SECONDS = 0,015
----*/
/*---
COMMIT
TR_HANDLE = 19
SECONDS = 0,188
----*/
/*---
COMMIT
TR_HANDLE = 3
----*/
> Thanks.
>