Issue Details (XML | Word | Printable)

Key: ODBC-79
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Alexander Potapchenko
Reporter: Marco Held
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
ODBC Driver

Problem with case sensitivity for table/relations name in SET TRANSACTION┬┤s RESERVING clause

Created: 18/Feb/10 11:08 AM   Updated: 06/Mar/16 05:35 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.0.4

File Attachments: 1. Text File bug-79.patch (2 kB)

Environment: ---


 Description  « Hide
If using a RESERVING clause in a SET TRANSACTION command, for now they must be in upper case characters. This must be not case sensitiv.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Nickolay Samofatov added a comment - 25/Apr/10 06:55 PM
You can see all the rules in Firebird's parse.y:
int Parser::yylexAux()

In short the logic is rather simple. The unquoted indentifiers are uppercased using UPPER(c):
#define UPPER(c) (((c) >= 'a' && (c) <= 'z') ? (c) - 'a' + 'A' : (c))

Quoted strings are parsed "as is", using double quote as the delimiter (and doubled double quote is interpreted as single double quote in the identifier).

In short, engine assumes that all DSQL strings are ASCII-based.

Marco Held added a comment - 12/Nov/10 10:42 AM
Is there any idea by the firebird crew, when to fix this issue?
Thx

Marco Held added a comment - 14/Nov/11 04:13 PM
Hi,

again, I want to ask, if it would be possible to fix this issue soon, please.
As I understand it is not a big thing to fix it.
Or can anyone send a hint in which file this msut be solved?

Thx,
Marco

Jojakim Stahl added a comment - 31/May/12 02:11 PM
Hello, I'm coworker of Marco Held. We had time /need to investigate and fix this problem:

--- e:\OdbcFb.org/IscDbc/IscConnection.cpp 2011-10-13 17:48:47.000000000 +0200
+++ ./IscDbc/IscConnection.cpp 2012-05-24 09:53:57.410707900 +0200
@@ -616,15 +616,63 @@
  char *& ptOut = string;
  char *beg = tpbBuffer + 2;
  char *end;
+ char quote;
+ char delimiter = *metaData->getIdentifierQuoteString();
+ delimiter = delimiter == ' ' || attachment->databaseDialect < 3 ? 0 : delimiter;
+ bool autoQuoted = delimiter && attachment->autoQuotedIdentifier;
 
  while ( true )
  {
  saveLockMode[countTable] = beg - 2;
  char &lengthTableName = *(beg - 1);
+
  end = beg;
 
- while ( !IS_END_TOKEN( *ptOut ) )
- *end++ = *ptOut++;
+ if ( IS_QUOTE( *ptOut ) )
+ {
+ quote = *ptOut++;
+ while ( *ptOut != '\0' && *ptOut != quote )
+ *end++ = *ptOut++;
+
+ if ( *ptOut == '\0' )
+ throw SQLEXCEPTION( SYNTAX_ERROR, "missing closing quote for identifier" );
+ else
+ ptOut++;
+ }
+ else
+ {
+ bool mixed = false;
+
+ if (autoQuoted)
+ {
+ const char* pt = ptOut;
+ bool hasUpper = false;
+ bool hasLower = false;
+
+ while ( IS_IDENT( *pt ) && !mixed )
+ {
+ hasUpper |= ISUPPER( *pt );
+ hasLower |= ISLOWER( *pt );
+ mixed = hasUpper && hasLower;
+ pt++;
+ }
+ }
+
+ if (mixed)
+ {
+ while ( IS_IDENT( *ptOut ) )
+ *end++ = *ptOut++;
+ }
+ else
+ {
+ while ( IS_IDENT( *ptOut ) )
+ {
+ // UPPER uses the argument two times - therefore the pointer inc is in a separate line
+ *end++ = UPPER( *ptOut );
+ ptOut++;
+ }
+ }
+ }
 
  lengthTableName = end - beg;
 

Jojakim Stahl added a comment - 03/Nov/14 01:14 PM
uploaded patch

Alexander Potapchenko added a comment - 05/Jan/15 09:26 PM
Fixed in CVS.