FirebirdSQL / NETProvider

Firebird ADO.NET Data Provider
https://www.firebirdsql.org/en/net-provider/
Other
152 stars 62 forks source link

FBTransactionOptions LockTables - Table name required in uppercase #1140

Closed ron90 closed 8 months ago

ron90 commented 8 months ago

Version

Firebird Driver Version: 9.1.1.0

Problem Description

In FBTransactionOptions when using LockTables.Add the table name is required to be in uppercase only. If given table name is not in upper case then error is raised. The functionality works but it is inconvenient and leads to error at runtime if by mistake the supplied table name is not in uppercase.

FbTransactionOptions tranOptions = new FbTransactionOptions();
// If table name is passed as T_LOCKREGINO then it will work
tranOptions.LockTables.Add("T_LockRegiNo", FbTransactionBehavior.LockWrite | FbTransactionBehavior.Protected);
FbTransaction tran = conn.BeginTransaction(tranOptions);
cmd.Transaction = tran;

Error

invalid parameter in transaction parameter block Table or view T_LockRegiNo not defined in system tables after table reservation isc_tpb_lock_write in TPB

Suggested Solution

A simple enhancement can be done by using ToUpper before using the table name

mrotteveel commented 8 months ago

This is not a solution. Unquoted identifiers are case-insensitive in SQL, but are stored in uppercase in the metadata, while quoted identifiers are case-sensitive and are stored as-is. In general, database APIs require you to work with the tablename as stored in the metadata, that means you need to use T_LOCKREGINO, or you need to switch to using quoted identifiers. Doing a ToUpper would break things for quoted identifiers.

ron90 commented 8 months ago

Ok understood. Thankyou @mrotteveel for your prompt reply and clear explanation.