diff --git a/src/abstract/ecli_statement.e b/src/abstract/ecli_statement.e index e7f57fe..8bc14f5 100644 --- a/src/abstract/ecli_statement.e +++ b/src/abstract/ecli_statement.e @@ -549,14 +549,27 @@ feature -- Element change require valid_statement: is_valid sql_meaningful: not new_sql.is_empty + local + l_cache : ECLI_SQL_PARSER_CACHE + l_parser : ECLI_SQL_PARSER do reset_status sql := new_sql name_to_position.wipe_out - parser.parse (sql, Current) - create impl_sql.make_from_string (parser.parsed_sql) + Cache.search (sql) + if Cache.found then + l_cache := Cache.found_item + l_parser := l_cache.parser + name_to_position := l_cache.name_to_position + else + parser.parse (sql, Current) + create l_cache.make (parser, name_to_position) + Cache.force (l_cache, sql) + l_parser := parser + end + create impl_sql.make_from_string (l_parser.parsed_sql) set_parsed - parameters_count_impl := parser.parameters_count + parameters_count_impl := l_parser.parameters_count create {DS_LINKED_LIST[STRING]}impl_parameter_names.make impl_result_columns_count.put (-1) -- do not know is_executed := False @@ -1073,6 +1086,12 @@ feature {NONE} -- Implementation end end + Cache: DS_HASH_TABLE [ECLI_SQL_PARSER_CACHE, STRING] + -- SQL parser cache + once + create Result.make_default + end + parameters_count_impl : INTEGER create_parameters diff --git a/src/support/ecli_sql_parser_cache.e b/src/support/ecli_sql_parser_cache.e new file mode 100644 index 0000000..c02304c --- /dev/null +++ b/src/support/ecli_sql_parser_cache.e @@ -0,0 +1,46 @@ +note + + description: + + "Objects that cache SQL parsers." + + library: "ECLI : Eiffel Call Level Interface (ODBC) Library. Project SAFE." + Copyright: "Copyright (c) 2001-2012, Paul G. Crismer and others" + license: "Eiffel Forum License v2 (see forum.txt)" + date: "$Date$" + +class + ECLI_SQL_PARSER_CACHE + +create + + make + +feature {NONE} -- Initialization + + make (a_parser: ECLI_SQL_PARSER; a_name_to_position : DS_HASH_TABLE [DS_LIST[INTEGER], STRING]) + -- Create the cache. + require + a_parser_not_void: a_parser /= Void + a_name_to_position_not_void: a_name_to_position /= Void + do + parser := a_parser + name_to_position := a_name_to_position + ensure + parser_set: parser = a_parser + name_to_position_set: name_to_position = a_name_to_position + end + +feature -- Access + + parser: ECLI_SQL_PARSER + -- SQL parser + + name_to_position : DS_HASH_TABLE [DS_LIST[INTEGER], STRING] + -- Name to position table + +invariant + parser_not_void: parser /= Void + name_to_position_not_void: name_to_position /= Void + +end