Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with case sensitivity for table/relations name in SET TRANSACTION´s RESERVING clause [ODBC79] #78

Closed
firebird-automations opened this issue Feb 18, 2010 · 10 comments

Comments

@firebird-automations
Copy link

Submitted by: Marco Held (demig-mh)

Attachments:
bug-79.patch

Votes: 1

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.

Commits: 1e85566 1203914

@firebird-automations
Copy link
Author

Commented by: @samofatov

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.

@firebird-automations
Copy link
Author

Commented by: Marco Held (demig-mh)

Is there any idea by the firebird crew, when to fix this issue?
Thx

@firebird-automations
Copy link
Author

Commented by: Marco Held (demig-mh)

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

@firebird-automations
Copy link
Author

Commented by: Jojakim Stahl (jstahl)

Hello, I'm coworker of Marco Held. We had time /need to investigate and fix this problem:

--- e:\http://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;

@firebird-automations
Copy link
Author

Commented by: Jojakim Stahl (jstahl)

uploaded patch

@firebird-automations
Copy link
Author

Modified by: Jojakim Stahl (jstahl)

Attachment: bug-79.patch [ 12612 ]

@firebird-automations
Copy link
Author

Modified by: @alexpotapchenko

assignee: Alexander Potapchenko [ lightfore ]

@firebird-automations
Copy link
Author

Commented by: @alexpotapchenko

Fixed in CVS.

@firebird-automations
Copy link
Author

Modified by: @alexpotapchenko

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.0.4 [ 10662 ]

@firebird-automations
Copy link
Author

Modified by: @alexpotapchenko

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants