From: <asf...@us...> - 2011-02-26 21:52:54
|
Revision: 52477 http://firebird.svn.sourceforge.net/firebird/?rev=52477&view=rev Author: asfernandes Date: 2011-02-26 21:52:47 +0000 (Sat, 26 Feb 2011) Log Message: ----------- Removed the legacy DSQL hash table module (HSHD). Modified Paths: -------------- firebird/trunk/builds/make.new/config/install-sh firebird/trunk/builds/win32/msvc10/engine.vcxproj firebird/trunk/builds/win32/msvc10/engine.vcxproj.filters firebird/trunk/builds/win32/msvc8/engine.vcproj firebird/trunk/builds/win32/msvc9/engine.vcproj firebird/trunk/src/dsql/dsql.cpp firebird/trunk/src/dsql/dsql.h firebird/trunk/src/dsql/make.cpp firebird/trunk/src/dsql/make_proto.h firebird/trunk/src/dsql/metd.epp firebird/trunk/src/dsql/parse.y firebird/trunk/src/dsql/pass1.cpp firebird/trunk/src/dsql/sym.h firebird/trunk/src/include/fb_blk.h Removed Paths: ------------- firebird/trunk/src/dsql/hsh.cpp firebird/trunk/src/dsql/hsh_proto.h firebird/trunk/src/dsql/parse_proto.h Property Changed: ---------------- firebird/trunk/builds/make.new/config/install-sh Property changes on: firebird/trunk/builds/make.new/config/install-sh ___________________________________________________________________ Added: svn:executable + * Modified: firebird/trunk/builds/win32/msvc10/engine.vcxproj =================================================================== --- firebird/trunk/builds/win32/msvc10/engine.vcxproj 2011-02-26 21:51:45 UTC (rev 52476) +++ firebird/trunk/builds/win32/msvc10/engine.vcxproj 2011-02-26 21:52:47 UTC (rev 52477) @@ -47,7 +47,6 @@ <ClCompile Include="..\..\..\src\dsql\errd.cpp" /> <ClCompile Include="..\..\..\src\dsql\ExprNodes.cpp" /> <ClCompile Include="..\..\..\src\dsql\gen.cpp" /> - <ClCompile Include="..\..\..\src\dsql\hsh.cpp" /> <ClCompile Include="..\..\..\src\dsql\make.cpp" /> <ClCompile Include="..\..\..\src\dsql\movd.cpp" /> <ClCompile Include="..\..\..\src\dsql\parse.cpp" /> @@ -177,7 +176,6 @@ <ClInclude Include="..\..\..\src\dsql\errd_proto.h" /> <ClInclude Include="..\..\..\src\dsql\ExprNodes.h" /> <ClInclude Include="..\..\..\src\dsql\gen_proto.h" /> - <ClInclude Include="..\..\..\src\dsql\hsh_proto.h" /> <ClInclude Include="..\..\..\src\dsql\make_proto.h" /> <ClInclude Include="..\..\..\src\dsql\metd_proto.h" /> <ClInclude Include="..\..\..\src\dsql\movd_proto.h" /> @@ -185,7 +183,6 @@ <ClInclude Include="..\..\..\src\dsql\Nodes.h" /> <ClInclude Include="..\..\..\src\dsql\PackageNodes.h" /> <ClInclude Include="..\..\..\src\dsql\Parser.h" /> - <ClInclude Include="..\..\..\src\dsql\parse_proto.h" /> <ClInclude Include="..\..\..\src\dsql\pass1_proto.h" /> <ClInclude Include="..\..\..\src\dsql\sqlda.h" /> <ClInclude Include="..\..\..\src\dsql\sqlda_pub.h" /> @@ -564,4 +561,4 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> -</Project> \ No newline at end of file +</Project> Modified: firebird/trunk/builds/win32/msvc10/engine.vcxproj.filters =================================================================== --- firebird/trunk/builds/win32/msvc10/engine.vcxproj.filters 2011-02-26 21:51:45 UTC (rev 52476) +++ firebird/trunk/builds/win32/msvc10/engine.vcxproj.filters 2011-02-26 21:52:47 UTC (rev 52477) @@ -144,9 +144,6 @@ <ClCompile Include="..\..\..\src\dsql\gen.cpp"> <Filter>DSQL</Filter> </ClCompile> - <ClCompile Include="..\..\..\src\dsql\hsh.cpp"> - <Filter>DSQL</Filter> - </ClCompile> <ClCompile Include="..\..\..\src\dsql\make.cpp"> <Filter>DSQL</Filter> </ClCompile> @@ -518,9 +515,6 @@ <ClInclude Include="..\..\..\src\dsql\gen_proto.h"> <Filter>Header files</Filter> </ClInclude> - <ClInclude Include="..\..\..\src\dsql\hsh_proto.h"> - <Filter>Header files</Filter> - </ClInclude> <ClInclude Include="..\..\..\src\dsql\make_proto.h"> <Filter>Header files</Filter> </ClInclude> @@ -539,9 +533,6 @@ <ClInclude Include="..\..\..\src\dsql\PackageNodes.h"> <Filter>Header files</Filter> </ClInclude> - <ClInclude Include="..\..\..\src\dsql\parse_proto.h"> - <Filter>Header files</Filter> - </ClInclude> <ClInclude Include="..\..\..\src\dsql\Parser.h"> <Filter>Header files</Filter> </ClInclude> @@ -1085,4 +1076,4 @@ <Filter>Resource files</Filter> </ResourceCompile> </ItemGroup> -</Project> \ No newline at end of file +</Project> Modified: firebird/trunk/builds/win32/msvc8/engine.vcproj =================================================================== --- firebird/trunk/builds/win32/msvc8/engine.vcproj 2011-02-26 21:51:45 UTC (rev 52476) +++ firebird/trunk/builds/win32/msvc8/engine.vcproj 2011-02-26 21:52:47 UTC (rev 52477) @@ -1184,10 +1184,6 @@ > </File> <File - RelativePath="..\..\..\src\dsql\hsh_proto.h" - > - </File> - <File RelativePath="..\..\..\src\jrd\ibase.h" > </File> @@ -1404,10 +1400,6 @@ > </File> <File - RelativePath="..\..\..\src\dsql\parse_proto.h" - > - </File> - <File RelativePath="..\..\..\src\dsql\Parser.h" > </File> @@ -1740,10 +1732,6 @@ > </File> <File - RelativePath="..\..\..\src\dsql\hsh.cpp" - > - </File> - <File RelativePath="..\..\..\src\dsql\make.cpp" > </File> Modified: firebird/trunk/builds/win32/msvc9/engine.vcproj =================================================================== --- firebird/trunk/builds/win32/msvc9/engine.vcproj 2011-02-26 21:51:45 UTC (rev 52476) +++ firebird/trunk/builds/win32/msvc9/engine.vcproj 2011-02-26 21:52:47 UTC (rev 52477) @@ -1184,10 +1184,6 @@ > </File> <File - RelativePath="..\..\..\src\dsql\hsh_proto.h" - > - </File> - <File RelativePath="..\..\..\src\jrd\ibase.h" > </File> @@ -1404,10 +1400,6 @@ > </File> <File - RelativePath="..\..\..\src\dsql\parse_proto.h" - > - </File> - <File RelativePath="..\..\..\src\dsql\Parser.h" > </File> @@ -1740,10 +1732,6 @@ > </File> <File - RelativePath="..\..\..\src\dsql\hsh.cpp" - > - </File> - <File RelativePath="..\..\..\src\dsql\make.cpp" > </File> Modified: firebird/trunk/src/dsql/dsql.cpp =================================================================== --- firebird/trunk/src/dsql/dsql.cpp 2011-02-26 21:51:45 UTC (rev 52476) +++ firebird/trunk/src/dsql/dsql.cpp 2011-02-26 21:52:47 UTC (rev 52477) @@ -49,10 +49,8 @@ #include "../dsql/dsql_proto.h" #include "../dsql/errd_proto.h" #include "../dsql/gen_proto.h" -#include "../dsql/hsh_proto.h" #include "../dsql/make_proto.h" #include "../dsql/movd_proto.h" -#include "../dsql/parse_proto.h" #include "../dsql/pass1_proto.h" #include "../jrd/blb_proto.h" #include "../jrd/cmp_proto.h" @@ -143,7 +141,6 @@ dsql_dbb::~dsql_dbb() { - HSHD_finish(this); } @@ -694,7 +691,7 @@ Jrd::ContextPoolHolder context(tdbb, &request->getPool()); const size_t MAX_CURSOR_LENGTH = 132 - 1; - Firebird::string cursor = input_cursor; + string cursor = input_cursor; if (cursor[0] == '\"') { @@ -702,7 +699,7 @@ // Note that "" will be replaced with ". // The code is very strange, because it doesn't check for "" really // and thus deletes one isolated " in the middle of the cursor. - for (Firebird::string::iterator i = cursor.begin(); i < cursor.end(); ++i) + for (string::iterator i = cursor.begin(); i < cursor.end(); ++i) { if (*i == '\"') cursor.erase(i); @@ -710,8 +707,8 @@ } else // not quoted name { - const Firebird::string::size_type i = cursor.find(' '); - if (i != Firebird::string::npos) + const string::size_type i = cursor.find(' '); + if (i != string::npos) cursor.resize(i); cursor.upper(); @@ -733,28 +730,31 @@ // If there already is a different cursor by the same name, bitch - const dsql_sym* symbol = HSHD_lookup(request->req_dbb, cursor.c_str(), length, SYM_cursor, 0); + dsql_req* const* symbol = request->req_dbb->dbb_cursors.get(cursor); if (symbol) { - if (request->req_cursor == symbol) + if (request == *symbol) return; ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-502) << Arg::Gds(isc_dsql_decl_err) << - Arg::Gds(isc_dsql_cursor_redefined) << Arg::Str(symbol->sym_string)); + Arg::Gds(isc_dsql_cursor_redefined) << cursor); } // If there already is a cursor and its name isn't the same, ditto. // We already know there is no cursor by this name in the hash table - if (!request->req_cursor) - request->req_cursor = MAKE_symbol(request->req_dbb, cursor.c_str(), length, SYM_cursor, request); + if (request->req_cursor.isEmpty()) + { + request->req_cursor = cursor; + request->req_dbb->dbb_cursors.put(cursor, request); + } else { - fb_assert(request->req_cursor != symbol); + fb_assert(request != (*symbol)); ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-502) << Arg::Gds(isc_dsql_decl_err) << - Arg::Gds(isc_dsql_cursor_redefined) << Arg::Str(request->req_cursor->sym_string)); + Arg::Gds(isc_dsql_cursor_redefined) << request->req_cursor); } } @@ -2287,10 +2287,10 @@ } request->req_traced = false; - if (request->req_cursor) + if (request->req_cursor.hasData()) { - HSHD_remove(request->req_cursor); - request->req_cursor = NULL; + request->req_dbb->dbb_cursors.remove(request->req_cursor); + request->req_cursor = ""; } // If a request has been compiled, release it now Modified: firebird/trunk/src/dsql/dsql.h =================================================================== --- firebird/trunk/src/dsql/dsql.h 2011-02-26 21:51:45 UTC (rev 52476) +++ firebird/trunk/src/dsql/dsql.h 2011-02-26 21:52:47 UTC (rev 52477) @@ -140,6 +140,9 @@ Firebird::MetaName, class dsql_intlsym*> > > dbb_collations; // known collations in database Firebird::GenericMap<Firebird::Pair<Firebird::NonPooled< SSHORT, dsql_intlsym*> > > dbb_charsets_by_id; // charsets sorted by charset_id + Firebird::GenericMap<Firebird::Pair<Firebird::Left< + Firebird::string, class dsql_req*> > > dbb_cursors; // known cursors in database + MemoryPool& dbb_pool; // The current pool for the dbb Database* dbb_database; Attachment* dbb_attachment; @@ -157,6 +160,7 @@ dbb_charsets(p), dbb_collations(p), dbb_charsets_by_id(p), + dbb_cursors(p), dbb_pool(p) {} @@ -541,6 +545,7 @@ statement(aStatement), cursors(req_pool), req_msg_buffers(req_pool), + req_cursor(req_pool), req_user_descs(req_pool) { } @@ -577,7 +582,7 @@ unsigned req_flags; // flags Firebird::Array<UCHAR*> req_msg_buffers; - dsql_sym* req_cursor; // Cursor symbol, if any + Firebird::string req_cursor; // Cursor name, if any blb* req_blb; // JRD blob Firebird::GenericMap<Firebird::NonPooled<const dsql_par*, dsc> > req_user_descs; // SQLDA data type Deleted: firebird/trunk/src/dsql/hsh.cpp =================================================================== --- firebird/trunk/src/dsql/hsh.cpp 2011-02-26 21:51:45 UTC (rev 52476) +++ firebird/trunk/src/dsql/hsh.cpp 2011-02-26 21:52:47 UTC (rev 52477) @@ -1,448 +0,0 @@ -/* - * PROGRAM: Dynamic SQL runtime support - * MODULE: hsh.cpp - * DESCRIPTION: Hash table and symbol manager - * - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html - * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code was created by Inprise Corporation - * and its predecessors. Portions created by Inprise Corporation are - * Copyright (C) Inprise Corporation. - * - * All Rights Reserved. - * Contributor(s): ______________________________________. - */ - -#include "firebird.h" -#include <string.h> -#include "../dsql/dsql.h" -#include "../jrd/ibase.h" -#include "../yvalve/gds_proto.h" -#include "../dsql/errd_proto.h" -#include "../dsql/hsh_proto.h" -#include "../dsql/parse_proto.h" -#include "../common/classes/init.h" - -using namespace Jrd; - -static USHORT hash(const SCHAR*, USHORT); -static bool remove_symbol(dsql_sym**, dsql_sym*); -static bool scompare(const TEXT*, USHORT, const TEXT*, const USHORT); - -namespace -{ - const int HASH_SIZE = 1021; - - class HashTable : public Firebird::Array<dsql_sym*> - { - public: - explicit HashTable(MemoryPool& pool) - : Firebird::Array<dsql_sym*>(pool) - { - grow(HASH_SIZE); - } - - static void init() - { - LEX_dsql_init(*getDefaultMemoryPool()); - } - }; - - Firebird::InitInstance<HashTable> hash_table; - Firebird::InitMutex<HashTable> hash_startup; - Firebird::GlobalPtr<Firebird::RWLock> hash_sync; -} - -#ifdef DEV_BUILD - -#include <stdio.h> - -/** - - HSHD_debug - - @brief Print out the hash table for debugging. - - - - **/ -void HSHD_debug() -{ - Firebird::ReadLockGuard guard(hash_sync); - - // dump each hash table entry - for (SSHORT h = 0; h < HASH_SIZE; h++) - { - for (dsql_sym* collision = hash_table()[h]; collision; collision = collision->sym_collision) - { - // check any homonyms first - fprintf(stderr, "Symbol type %d: %s %p\n", - collision->sym_type, collision->sym_string, collision->sym_dbb); - for (dsql_sym* homptr = collision->sym_homonym; homptr; homptr = homptr->sym_homonym) - { - fprintf(stderr, "Homonym Symbol type %d: %s %p\n", - homptr->sym_type, homptr->sym_string, homptr->sym_dbb); - } - } - } -} -#endif - - -/** - - HSHD_finish - - @brief Remove symbols used by a particular database. - Don't bother to release them since their pools - will be released. - - - @param database - - **/ -void HSHD_finish(const void* database) -{ - Firebird::WriteLockGuard guard(hash_sync); - - // check each hash table entry - for (SSHORT h = 0; h < HASH_SIZE; h++) - { - for (dsql_sym** collision = &hash_table()[h]; *collision;) - { - // check any homonyms first - dsql_sym* chain = *collision; - for (dsql_sym** homptr = &chain->sym_homonym; *homptr;) - { - dsql_sym* symbol = *homptr; - if (symbol->sym_dbb == database) - { - *homptr = symbol->sym_homonym; - symbol = symbol->sym_homonym; - } - else - { - homptr = &symbol->sym_homonym; - } - } - - // now, see if the root entry has to go - if (chain->sym_dbb == database) - { - if (chain->sym_homonym) - { - chain->sym_homonym->sym_collision = chain->sym_collision; - *collision = chain->sym_homonym; - } - else - { - *collision = chain->sym_collision; - } - chain = *collision; - } - else - { - collision = &chain->sym_collision; - } - } - } -} - - -/** - - HSHD_insert - - @brief Insert a symbol into the hash table. - - - @param symbol - - **/ -void HSHD_insert(dsql_sym* symbol) -{ - const USHORT h = hash(symbol->sym_string, symbol->sym_length); - const void* database = symbol->sym_dbb; - - //fb_assert(symbol->sym_type >= SYM_statement && symbol->sym_type <= SYM_eof); - fb_assert(symbol->sym_type >= SYM_cursor && symbol->sym_type <= SYM_eof); - - Firebird::WriteLockGuard guard(hash_sync); - - for (dsql_sym* old = hash_table()[h]; old; old = old->sym_collision) - { - if ((!database || (database == old->sym_dbb)) && - scompare(symbol->sym_string, symbol->sym_length, old->sym_string, old->sym_length)) - { - symbol->sym_homonym = old->sym_homonym; - old->sym_homonym = symbol; - return; - } - } - - symbol->sym_collision = hash_table()[h]; - hash_table()[h] = symbol; -} - - -/** - - HSHD_lookup - - @brief Perform a string lookup against hash table. - Make sure to only return a symbol of the desired type. - - - @param database - @param string - @param length - @param type - @param parser_version - - **/ -dsql_sym* HSHD_lookup(const void* database, - const TEXT* string, - SSHORT length, - SYM_TYPE type, - USHORT parser_version) -{ - hash_startup.init(); - - const USHORT h = hash(string, length); - - Firebird::ReadLockGuard guard(hash_sync); - - for (dsql_sym* symbol = hash_table()[h]; symbol; symbol = symbol->sym_collision) - { - if ((database == symbol->sym_dbb) && - scompare(string, length, symbol->sym_string, symbol->sym_length)) - { - // Search for a symbol of the proper type - while (symbol && symbol->sym_type != type) - { - symbol = symbol->sym_homonym; - } - - // If the symbol found was not part of the list of keywords for the - // client connecting, then assume nothing was found - - if (symbol) - { - if (parser_version < symbol->sym_version && type == SYM_keyword) - { - return NULL; - } - } - return symbol; - } - } - - return NULL; -} - - -/** - - HSHD_remove - - @brief Remove a symbol from the hash table. - - - @param symbol - - **/ -void HSHD_remove(dsql_sym* symbol) -{ - Firebird::WriteLockGuard guard(hash_sync); - - const USHORT h = hash(symbol->sym_string, symbol->sym_length); - - for (dsql_sym** collision = &hash_table()[h]; *collision; collision = &(*collision)->sym_collision) - { - if (remove_symbol(collision, symbol)) - { - return; - } - } - - ERRD_error("HSHD_remove failed"); -} - - -/** - - HSHD_set_flag - - @brief Set a flag in all similar objects in a chain. - This is used primarily to mark relations - as deleted. The object must have the same name and - type, but not the same database, and must belong to - some database. Later access to such an object by - another user or thread should result in that object's - being refreshed. Note that even if the name and ID - both match, it may still not represent an exact match. - This is because there's no way at present for DSQL to tell - if two databases as represented in DSQL are attachments to - the same physical database. - - - @param database - @param string - @param length - @param type - @param flag - - **/ -void HSHD_set_flag(const void* database, - const TEXT* string, - SSHORT length, - SYM_TYPE type, - SSHORT flag) -{ - // as of now, there's no work to do if there is no database or if - // the type is not a relation - - if (!database || type != SYM_relation) - return; - - const USHORT h = hash(string, length); - - Firebird::WriteLockGuard guard(hash_sync); - - for (dsql_sym* symbol = hash_table()[h]; symbol; symbol = symbol->sym_collision) - { - if (symbol->sym_dbb && (database != symbol->sym_dbb) && - scompare(string, length, symbol->sym_string, symbol->sym_length)) - { - // the symbol name matches and it's from a different database - - for (dsql_sym* homonym = symbol; homonym; homonym = homonym->sym_homonym) - { - if (homonym->sym_type == type) - { - // the homonym is of the correct type - - // the next check is for the same relation ID, - // which indicates that it MAY be the same relation - fb_assert(type == SYM_relation); - - dsql_rel* sym_rel = (dsql_rel*) homonym->sym_object; - sym_rel->rel_flags |= flag; - } - } - } - } -} - - -/** - - hash - - @brief Returns the hash function of a string. - - - @param - @param - - **/ -static USHORT hash(const SCHAR* string, USHORT length) -{ - ULONG value = 0; - - while (length--) - { - UCHAR c = *string++; - value = (value << 1) + c; - } - - return value % HASH_SIZE; -} - - -/** - - remove_symbol - - @brief Given the address of a collision, - remove a symbol from the collision - and homonym linked lists. - - - @param collision - @param symbol - - **/ -static bool remove_symbol(dsql_sym** collision, dsql_sym* symbol) -{ - if (symbol == *collision) - { - dsql_sym* homonym = symbol->sym_homonym; - if (homonym != NULL) - { - homonym->sym_collision = symbol->sym_collision; - *collision = homonym; - } - else - { - *collision = symbol->sym_collision; - } - - return true; - } - - for (dsql_sym** ptr = &(*collision)->sym_homonym; *ptr; ptr = &(*ptr)->sym_homonym) - { - if (symbol == *ptr) - { - *ptr = symbol->sym_homonym; - return true; - } - } - - return false; -} - - -/** - - scompare - - @brief Compare two symbolic strings - The character set for these strings is either ASCII or - Unicode in UTF format. - Symbols are case-significant - so no uppercase operation - is performed. - - - @param string1 - @param length1 - @param string2 - @param length2 - - **/ -static bool scompare(const TEXT* string1, - USHORT length1, - const TEXT* string2, - const USHORT length2) -{ - - if (length1 != length2) - return false; - - while (length1--) - { - if ((*string1++) != (*string2++)) - return false; - } - - return true; -} Deleted: firebird/trunk/src/dsql/hsh_proto.h =================================================================== --- firebird/trunk/src/dsql/hsh_proto.h 2011-02-26 21:51:45 UTC (rev 52476) +++ firebird/trunk/src/dsql/hsh_proto.h 2011-02-26 21:52:47 UTC (rev 52477) @@ -1,34 +0,0 @@ -/* - * PROGRAM: Dynamic SQL runtime support - * MODULE: hsh_proto.h - * DESCRIPTION: Prototype Header file for hsh.cpp - * - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html - * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code was created by Inprise Corporation - * and its predecessors. Portions created by Inprise Corporation are - * Copyright (C) Inprise Corporation. - * - * All Rights Reserved. - * Contributor(s): ______________________________________. - */ - -#ifndef DSQL_HSH_PROTO_H -#define DSQL_HSH_PROTO_H - -void HSHD_finish(const void*); -void HSHD_insert(Jrd::dsql_sym*); -Jrd::dsql_sym* HSHD_lookup(const void*, const TEXT*, SSHORT, Jrd::SYM_TYPE, USHORT); -void HSHD_remove(Jrd::dsql_sym*); -void HSHD_set_flag(const void *, const TEXT*, SSHORT, Jrd::SYM_TYPE, SSHORT); - -#endif //DSQL_HSH_PROTO_H - Modified: firebird/trunk/src/dsql/make.cpp =================================================================== --- firebird/trunk/src/dsql/make.cpp 2011-02-26 21:51:45 UTC (rev 52476) +++ firebird/trunk/src/dsql/make.cpp 2011-02-26 21:52:47 UTC (rev 52477) @@ -45,7 +45,6 @@ #include "../jrd/constants.h" #include "../jrd/align.h" #include "../dsql/errd_proto.h" -#include "../dsql/hsh_proto.h" #include "../dsql/make_proto.h" #include "../dsql/metd_proto.h" #include "../dsql/utld_proto.h" @@ -707,47 +706,6 @@ /** - MAKE_symbol - - @brief Make a symbol for an object and insert symbol into hash table. - - - @param database - @param name - @param length - @param type - @param object - - **/ -dsql_sym* MAKE_symbol(dsql_dbb* database, - const TEXT* name, USHORT length, SYM_TYPE type, dsql_req* object) -{ - DEV_BLKCHK(database, dsql_type_dbb); - DEV_BLKCHK(object, dsql_type_req); - fb_assert(name); - fb_assert(length > 0); - - thread_db* tdbb = JRD_get_thread_data(); - - dsql_sym* symbol = FB_NEW_RPT(*tdbb->getDefaultPool(), length) dsql_sym; - symbol->sym_type = type; - symbol->sym_object = object; - symbol->sym_dbb = database; - symbol->sym_length = length; - TEXT* p = symbol->sym_name; - symbol->sym_string = p; - - if (length) - memcpy(p, name, length); - - HSHD_insert(symbol); - - return symbol; -} - - -/** - MAKE_tagged_string @brief Generalized routine for making a string block. Modified: firebird/trunk/src/dsql/make_proto.h =================================================================== --- firebird/trunk/src/dsql/make_proto.h 2011-02-26 21:51:45 UTC (rev 52476) +++ firebird/trunk/src/dsql/make_proto.h 2011-02-26 21:52:47 UTC (rev 52477) @@ -63,7 +63,6 @@ Jrd::dsql_par* MAKE_parameter(Jrd::dsql_msg*, bool, bool, USHORT, const Jrd::dsql_nod*); void MAKE_parameter_names(Jrd::dsql_par*, const Jrd::dsql_nod*); Jrd::dsql_str* MAKE_string(const char*, int); -Jrd::dsql_sym* MAKE_symbol(Jrd::dsql_dbb*, const TEXT*, USHORT, Jrd::sym_type, Jrd::dsql_req*); Jrd::dsql_str* MAKE_tagged_string(const char* str, size_t length, const char* charset); #endif // DSQL_MAKE_PROTO_H Modified: firebird/trunk/src/dsql/metd.epp =================================================================== --- firebird/trunk/src/dsql/metd.epp 2011-02-26 21:51:45 UTC (rev 52476) +++ firebird/trunk/src/dsql/metd.epp 2011-02-26 21:52:47 UTC (rev 52477) @@ -42,7 +42,6 @@ #include "../jrd/tra.h" #include "../dsql/ddl_proto.h" #include "../dsql/metd_proto.h" -#include "../dsql/hsh_proto.h" #include "../dsql/make_proto.h" #include "../dsql/errd_proto.h" #include "../jrd/blb_proto.h" Modified: firebird/trunk/src/dsql/parse.y =================================================================== --- firebird/trunk/src/dsql/parse.y 2011-02-26 21:51:45 UTC (rev 52476) +++ firebird/trunk/src/dsql/parse.y 2011-02-26 21:52:47 UTC (rev 52477) @@ -89,7 +89,6 @@ #include "../jrd/flags.h" #include "../jrd/jrd.h" #include "../dsql/errd_proto.h" -#include "../dsql/hsh_proto.h" #include "../dsql/make_proto.h" #include "../yvalve/keywords.h" #include "../yvalve/gds_proto.h" @@ -6477,34 +6476,52 @@ */ -void LEX_dsql_init(MemoryPool& pool) +namespace { -/************************************** - * - * L E X _ d s q l _ i n i t - * - ************************************** - * - * Functional description - * Initialize LEX for processing. This is called only once - * per session. - * - **************************************/ - for (const TOK* token = KEYWORD_getTokens(); token->tok_string; ++token) + const int HASH_SIZE = 1021; + + struct KeywordVersion { - dsql_sym* symbol = FB_NEW_RPT(pool, 0) dsql_sym; - symbol->sym_string = token->tok_string; - symbol->sym_length = strlen(token->tok_string); - symbol->sym_type = SYM_keyword; - symbol->sym_keyword = token->tok_ident; - symbol->sym_version = token->tok_version; - dsql_str* str = FB_NEW_RPT(pool, symbol->sym_length) dsql_str; - str->str_length = symbol->sym_length; - strncpy(str->str_data, symbol->sym_string, symbol->sym_length); - //str->str_data[str->str_length] = 0; Is it necessary? - symbol->sym_object = (void *) str; - HSHD_insert(symbol); - } + KeywordVersion(int aKeyword, dsql_str* aStr, USHORT aVersion) + : keyword(aKeyword), + str(aStr), + version(aVersion) + { + } + + KeywordVersion() + : keyword(-1), + str(NULL), + version(0) + { + } + + int keyword; + dsql_str* str; + USHORT version; + }; + + class KeywordsMap : public GenericMap<Pair<Left<string, KeywordVersion> > > + { + public: + explicit KeywordsMap(MemoryPool& pool) + : GenericMap<Pair<Left<string, KeywordVersion> > >(pool) + { + for (const TOK* token = KEYWORD_getTokens(); token->tok_string; ++token) + { + size_t len = strlen(token->tok_string); + dsql_str* str = FB_NEW_RPT(pool, len) dsql_str; + str->str_length = len; + strncpy(str->str_data, token->tok_string, len); + //str->str_data[str->str_length] = 0; Is it necessary? + + put(string(token->tok_string, len), + KeywordVersion(token->tok_ident, str, token->tok_version)); + } + } + }; + + GlobalPtr<KeywordsMap> keywordsMap; } @@ -7587,7 +7604,6 @@ // end of number-recognition code - if (tok_class & CHR_LETTER) { char* p = string; @@ -7601,15 +7617,18 @@ check_bound(p, string); *p = 0; - dsql_sym* sym = - HSHD_lookup (NULL, string, (SSHORT)(p - string), SYM_keyword, parser_version); - if (sym && (sym->sym_keyword != COMMENT || lex.prev_keyword == -1)) + + Firebird::string str(string, p - string); + KeywordVersion keyVer; + + if (keywordsMap->get(str, keyVer) && parser_version >= keyVer.version && + (keyVer.keyword != COMMENT || lex.prev_keyword == -1)) { - yylval.legacyNode = (dsql_nod*) sym->sym_object; + yylval.legacyNode = (dsql_nod*) keyVer.str; lex.last_token_bk = lex.last_token; lex.line_start_bk = lex.line_start; lex.lines_bk = lex.lines; - return sym->sym_keyword; + return keyVer.keyword; } if (p > &string[MAX_SQL_IDENTIFIER_LEN]) @@ -7626,12 +7645,13 @@ if (lex.last_token + 1 < lex.end) { - dsql_sym* sym = - HSHD_lookup (NULL, lex.last_token, (SSHORT) 2, SYM_keyword, (USHORT) parser_version); - if (sym) + Firebird::string str(lex.last_token, 2); + KeywordVersion keyVer; + + if (keywordsMap->get(str, keyVer) && parser_version >= keyVer.version) { ++lex.ptr; - return sym->sym_keyword; + return keyVer.keyword; } } Deleted: firebird/trunk/src/dsql/parse_proto.h =================================================================== --- firebird/trunk/src/dsql/parse_proto.h 2011-02-26 21:51:45 UTC (rev 52476) +++ firebird/trunk/src/dsql/parse_proto.h 2011-02-26 21:52:47 UTC (rev 52477) @@ -1,30 +0,0 @@ -/* - * PROGRAM: Dynamic SQL runtime support - * MODULE: parse_proto.h - * DESCRIPTION: Prototype Header file for parse.cpp - * - * The contents of this file are subject to the Interbase Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy - * of the License at http://www.Inprise.com/IPL.html - * - * Software distributed under the License is distributed on an - * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express - * or implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code was created by Inprise Corporation - * and its predecessors. Portions created by Inprise Corporation are - * Copyright (C) Inprise Corporation. - * - * All Rights Reserved. - * Contributor(s): ______________________________________. - */ - -#ifndef DSQL_PARSE_PROTO_H -#define DSQL_PARSE_PROTO_H - -void LEX_dsql_init(MemoryPool&); - -#endif // DSQL_PARSE_PROTO_H - Modified: firebird/trunk/src/dsql/pass1.cpp =================================================================== --- firebird/trunk/src/dsql/pass1.cpp 2011-02-26 21:51:45 UTC (rev 52476) +++ firebird/trunk/src/dsql/pass1.cpp 2011-02-26 21:52:47 UTC (rev 52477) @@ -158,7 +158,6 @@ #include "../dsql/ddl_proto.h" #include "../dsql/errd_proto.h" #include "../dsql/gen_proto.h" -#include "../dsql/hsh_proto.h" #include "../dsql/make_proto.h" #include "../dsql/metd_proto.h" #include "../dsql/pass1_proto.h" @@ -2252,8 +2251,7 @@ const MetaName& cursorName = StmtNode::as<DeclareCursorNode>(cursor)->dsqlName; - const dsql_sym* symbol = HSHD_lookup(dsqlScratch->getAttachment(), cursorName.c_str(), - static_cast<SSHORT>(cursorName.length()), SYM_cursor, 0); + dsql_req* const* symbol = dsqlScratch->getAttachment()->dbb_cursors.get(cursorName.c_str()); if (!symbol) { @@ -2263,7 +2261,7 @@ Arg::Gds(isc_dsql_cursor_not_found) << cursorName); } - dsql_req* parent = (dsql_req*) symbol->sym_object; + dsql_req* parent = *symbol; // Verify that the cursor is appropriate and updatable @@ -6946,10 +6944,6 @@ trace_line("%sFIELD: %s\n", buffer, ((dsql_fld*) node)->fld_name.c_str()); return; - case dsql_type_sym: - trace_line("%sSYMBOL: %s\n", buffer, ((dsql_sym*) node)->sym_string); - return; - case dsql_type_nod: break; Modified: firebird/trunk/src/dsql/sym.h =================================================================== --- firebird/trunk/src/dsql/sym.h 2011-02-26 21:51:45 UTC (rev 52476) +++ firebird/trunk/src/dsql/sym.h 2011-02-26 21:52:47 UTC (rev 52477) @@ -32,10 +32,10 @@ enum sym_type { //SYM_statement, // used only in an assertion in HSHD_insert() - SYM_cursor = 1, - SYM_keyword, + //SYM_cursor = 1, + //SYM_keyword, //SYM_context, - SYM_relation, + SYM_relation = 1, //SYM_field, //SYM_stream, SYM_udf, @@ -47,25 +47,7 @@ typedef sym_type SYM_TYPE; -// symbol block -class dsql_sym : public pool_alloc_rpt<UCHAR, dsql_type_sym> -{ -public: - void *sym_dbb; // generic DB structure handle - const TEXT *sym_string; // address of asciz string - USHORT sym_length; // length of string (exc. term.) - SYM_TYPE sym_type; // symbol type - USHORT sym_keyword; // keyword number, if keyword - USHORT sym_version; // dialect version the symbol was introduced - void *sym_object; // general pointer to object - dsql_sym* sym_collision; // collision pointer - dsql_sym* sym_homonym; // homonym pointer - TEXT sym_name[2]; // space for name, if necessary -}; - - } // namespace #endif // DSQL_SYM_H - Modified: firebird/trunk/src/include/fb_blk.h =================================================================== --- firebird/trunk/src/include/fb_blk.h 2011-02-26 21:51:45 UTC (rev 52476) +++ firebird/trunk/src/include/fb_blk.h 2011-02-26 21:52:47 UTC (rev 52477) @@ -64,7 +64,6 @@ dsql_type_fil, dsql_type_nod, dsql_type_str, - dsql_type_sym, dsql_type_tra, dsql_type_udf, dsql_type_blb, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |