Skip to content

Commit

Permalink
Fix for ODBC-79. Problem with case sensitivity for table/relations na…
Browse files Browse the repository at this point in the history
…me in SET TRANSACTION?s RESERVING clause
  • Loading branch information
alexpotapchenko committed Jan 5, 2015
1 parent c0f4ed0 commit 1203914
Showing 1 changed file with 50 additions and 2 deletions.
52 changes: 50 additions & 2 deletions IscDbc/IscConnection.cpp
Expand Up @@ -616,15 +616,63 @@ void IscConnection::parseReservingTable( char *& string, char *& tpbBuffer, shor
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;

Expand Down

0 comments on commit 1203914

Please sign in to comment.