Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions src/abstract/ecli_statement.e
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
46 changes: 46 additions & 0 deletions src/support/ecli_sql_parser_cache.e
Original file line number Diff line number Diff line change
@@ -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