From: Marco H. <mh...@de...> - 2010-02-15 16:23:44
|
Hello all, due to I had some problem with transaction setting I ran through the code by debugger and found the following function which maybe did not work like it should. It is used to parse a set transaction command and check if some tables are required to be used in a special reservation mode. According to the sql syntax declaration Syntax SET TRANSACTION [NAME transaction] [READ WRITE | READ ONLY] [WAIT | NO WAIT] [[ISOLATION LEVEL] {SNAPSHOT [TABLE STABILITY] | READ COMMITTED [[NO] RECORD_VERSION]}] [RESERVING <reserving_clause> | USING dbhandle [, dbhandle ]]; <reserving_clause> = table [, table ] [FOR [SHARED | PROTECTED] {READ | WRITE}] [, <reserving_clause>] it is possible to define several tables in a comma separated list for a special reserving mode. The function below does not respect this possibility in my opinion. Only the comma for separation of different FOR clauses is respected. Furthermore there seems to be a problem in setting the lockMode for the table. Within the last if section for all tables found during the parsing, the lockMode of the last FOR clause is set. So the possibility of having different lockMode for each FOR clause is not respected. void IscConnection::parseReservingTable( char *& string, char *& tpbBuffer, short transFlags ) { char *saveLockMode[256]; int countTable = 0; char lockMode = 0; char *& ptOut = string; char *beg = tpbBuffer + 2; char *end; while ( true ) { saveLockMode[countTable++] = beg - 2; char &lengthTableName = *(beg - 1); end = beg; while ( !IS_END_TOKEN( *ptOut ) ) *end++ = *ptOut++; lengthTableName = end - beg; SKIP_WHITE ( ptOut ); // SYNTAX_ERROR ("relation name"); char &lockLevel = *end++; IS_MATCH_EXT( "FOR" ); lockLevel = (transFlags & TRA_con) ? isc_tpb_protected : isc_tpb_shared; lockMode = isc_tpb_lock_read; if ( IS_MATCH_EXT( "PROTECTED" ) ) lockLevel = isc_tpb_protected; else if ( IS_MATCH_EXT( "EXCLUSIVE" ) ) lockLevel = isc_tpb_exclusive; else if ( IS_MATCH_EXT( "SHARED" ) ) lockLevel = isc_tpb_shared; if ( IS_MATCH_EXT( "WRITE" ) ) { if ( transFlags & TRA_ro ) throw SQLEXCEPTION( SYNTAX_ERROR, "write lock requested for a read_only transaction" ); lockMode = isc_tpb_lock_write; } else IS_MATCH_EXT( "READ" ); if ( !( IS_MATCH_EXT( "," ) ) ) break; beg = end + 2; } tpbBuffer = end; if ( countTable ) { // // get the lock level and mode and apply them to all the // relations in the list // do *saveLockMode[--countTable] = lockMode; while ( countTable ); } } Can some authorized person check fix this, please? Thanks for help! Regards, Marco Held phone: +49 271 77202 27 e-mail: <mailto:mh...@de...> mh...@de... demig Prozessautomatisierung GmbH <http://www.demig.de/> http://www.demig.de <mailto:in...@de...> in...@de... Haardtstraße 40 D-57076 Siegen Tel. +49 271 77202 0 Fax +49 271 77202 92 Registergericht Siegen HRB 2819 Geschäftsführer Joachim Herbst, Winfried Held |
From: Nikolay S. <nik...@re...> - 2010-02-16 09:00:24
|
Hello, Marco! 1) Can you open this issue in a tracker? Test case would be welcome there. 2) Is it possible for you to prepare "unified context diff" (diff -u) format patch against current HEAD? I will review/apply it afterwards. Thanks! Nikolay Samofatov On 15.02.2010 11:22, Marco Held wrote: > > Hello all, > > due to I had some problem with transaction setting I ran through the > code by debugger and found the following function which maybe did not > work like it should. It is used to parse a "set transaction" command > and check if some tables are required to be used in a special > reservation mode. > > According to the sql syntax declaration > > /Syntax /SET TRANSACTION [NAME transaction] > > [READ WRITE | READ ONLY] > > [WAIT | NO WAIT] > > [[ISOLATION LEVEL] {SNAPSHOT [TABLE STABILITY] > > | READ COMMITTED [[NO] RECORD_VERSION]}] > > [RESERVING <reserving_clause> > > | USING dbhandle [, dbhandle ...]]; > > <reserving_clause> = table [, table ...] > > [FOR [SHARED | PROTECTED] {READ | WRITE}] [, <reserving_clause>] > > it is possible to define several tables in a comma separated list for > a special reserving mode. The function below does not respect this > possibility in my opinion. Only the comma for separation of different > "FOR" clauses is respected. > > Furthermore there seems to be a problem in setting the "lockMode" for > the table. Within the last "if" section for all tables found during > the parsing, the "lockMode" of the last "FOR" clause is set. So the > possibility of having different "lockMode" for each "FOR" clause is > not respected. > > void IscConnection::parseReservingTable( char *& string, char *& > tpbBuffer, short transFlags ) > > { > > char *saveLockMode[256]; > > int countTable = 0; > > char lockMode = 0; > > char *& ptOut = string; > > char *beg = tpbBuffer + 2; > > char *end; > > while ( true ) > > { > > saveLockMode[countTable++] = beg - 2; > > char &lengthTableName = *(beg - 1); > > end = beg; > > while ( !IS_END_TOKEN( *ptOut ) ) > > *end++ = *ptOut++; > > lengthTableName = end - beg; > > SKIP_WHITE ( ptOut ); > > // SYNTAX_ERROR ("relation name"); > > char &lockLevel = *end++; > > IS_MATCH_EXT( "FOR" ); > > lockLevel = (transFlags & TRA_con) ? isc_tpb_protected : > isc_tpb_shared; > > lockMode = isc_tpb_lock_read; > > if ( IS_MATCH_EXT( "PROTECTED" ) ) > > lockLevel = isc_tpb_protected; > > else if ( IS_MATCH_EXT( "EXCLUSIVE" ) ) > > lockLevel = isc_tpb_exclusive; > > else if ( IS_MATCH_EXT( "SHARED" ) ) > > lockLevel = isc_tpb_shared; > > if ( IS_MATCH_EXT( "WRITE" ) ) > > { > > if ( transFlags & TRA_ro ) > > throw SQLEXCEPTION( SYNTAX_ERROR, "write lock requested for a > read_only transaction" ); > > lockMode = isc_tpb_lock_write; > > } > > else > > IS_MATCH_EXT( "READ" ); > > if ( !( IS_MATCH_EXT( "," ) ) ) > > break; > > beg = end + 2; > > } > > tpbBuffer = end; > > if ( countTable ) > > { > > // > > // get the lock level and mode and apply them to all the > > // relations in the list > > // > > do > > *saveLockMode[--countTable] = lockMode; > > while ( countTable ); > > } > > } > > Can some authorized person check fix this, please? > > Thanks for help! > > Regards, > > Marco Held > > phone: +49 271 77202 27 > > e-mail: mh...@de... <mailto:mh...@de...> > > demig Prozessautomatisierung GmbH -- http://www.demig.de > <http://www.demig.de/> -- in...@de... <mailto:in...@de...> > > Haardtstraße 40 -- D-57076 Siegen -- Tel. +49 271 77202 0 -- Fax +49 > 271 77202 92 > > Registergericht Siegen HRB 2819 -- Geschäftsführer Joachim Herbst, > Winfried Held > |