Detecting a parameter is DB_KEY

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Detecting a parameter is DB_KEY

Mark Rotteveel-2
How can I find out if a parameter is a DB_KEY?

When describing "select column1 from testrowid where rdb$db_key = ?",
how can I derive from the parameter information that this is actually a
db_key?

For selected fields like in "select rdb$db_key, column1 from testrowid"
it is easy: just check if isc_info_sql_field is "DB_KEY", but this
doesn't work for parameters, because those don't include name information.

Mark

PS I sent this to the support list earlier, but got no response there.

--
Mark Rotteveel

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Detecting a parameter is DB_KEY

Adriano dos Santos Fernandes-3
On 25/05/2017 05:13, Mark Rotteveel wrote:

> How can I find out if a parameter is a DB_KEY?
>
> When describing "select column1 from testrowid where rdb$db_key = ?",
> how can I derive from the parameter information that this is actually a
> db_key?
>
> For selected fields like in "select rdb$db_key, column1 from testrowid"
> it is easy: just check if isc_info_sql_field is "DB_KEY", but this
> doesn't work for parameters, because those don't include name information.
>
Why would you need it?


Adriano


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Detecting a parameter is DB_KEY

Mark Rotteveel-2
On 25-5-2017 12:38, Adriano dos Santos Fernandes wrote:

> On 25/05/2017 05:13, Mark Rotteveel wrote:
>> How can I find out if a parameter is a DB_KEY?
>>
>> When describing "select column1 from testrowid where rdb$db_key = ?",
>> how can I derive from the parameter information that this is actually a
>> db_key?
>>
>> For selected fields like in "select rdb$db_key, column1 from testrowid"
>> it is easy: just check if isc_info_sql_field is "DB_KEY", but this
>> doesn't work for parameters, because those don't include name information.
>>
> Why would you need it?

I'm implementing JDBC ROWID support in Jaybird, and that means that I'd
prefer to be able to consistently identify both columns and parameters
addressing RDB$DB_KEY as being a ROWID. Unfortunately right now, it
looks like I can only do that for columns.

Mark
--
Mark Rotteveel

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Detecting a parameter is DB_KEY

Ann Harrison-3

> On May 25, 2017, at 8:13 AM, Mark Rotteveel <[hidden email]> wrote:
>
>>> How can I find out if a parameter is a DB_KEY?
>
> I'm implementing JDBC ROWID support in Jaybird

Does it matter that the ID is not consistent except within a transaction?

Cheers,

Ann

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Detecting a parameter is DB_KEY

Mark Rotteveel-2
On 2017-05-30 14:42, Ann Harrison wrote:
>> On May 25, 2017, at 8:13 AM, Mark Rotteveel <[hidden email]>
>> wrote:
>>
>>>> How can I find out if a parameter is a DB_KEY?
>>
>> I'm implementing JDBC ROWID support in Jaybird
>
> Does it matter that the ID is not consistent except within a
> transaction?

No, as JDBC is totally OK with that, it defines the following rowid
'lifetimes':

- ROWID_UNSUPPORTED
- ROWID_VALID_FOREVER
- ROWID_VALID_OTHER
- ROWID_VALID_SESSION
- ROWID_VALID_TRANSACTION

With the following consideration for validity:
ROWID_UNSUPPORTED < ROWID_VALID_OTHER < ROWID_VALID_TRANSACTION <
ROWID_VALID_SESSION < ROWID_VALID_FOREVER

See
https://docs.oracle.com/javase/8/docs/api/java/sql/RowIdLifetime.html 
and
https://docs.oracle.com/javase/8/docs/api/java/sql/DatabaseMetaData.html#getRowIdLifetime--

BTW: isc_dpb_dbkey_scope=1 should extend it to session/connection scope
(although my implementation will now always report
ROWID_VALID_TRANSACTION).

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Detecting a parameter is DB_KEY

Ann Harrison-3
> On May 30, 2017, at 5:06 PM, Mark Rotteveel <[hidden email]> wrote:

>
> BTW: isc_dpb_dbkey_scope=1 should extend it to session/connection scope

At some cost in garbage collection.... and an extra transaction start.

Cheers,

Ann

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Loading...