[interchange] Add new database configuration attribute PREQUERY.
Jon Jensen <[email protected]>
| Newsgroups | gmane.comp.web.interchange.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 0b995283bb267d757e9427979d7ce9d2b0e7d173 Author: Jon Jensen <[email protected]> Date: Mon Oct 3 19:32:09 2011 -0600 Add new database configuration attribute PREQUERY. This allows an arbitrary query to be defined, which is run every time the database connection is opened. Useful for setting database timezone, statement timeout, query optimizer hints, etc. This commit took its current form on 2007-07-23, but never got committed upstream till now. lib/Vend/Config.pm | 1 + lib/Vend/Table/DBI.pm | 11 +++++++++++ 2 files changed, 12 insertions(+), 0 deletions(-) --- diff --git a/lib/Vend/Config.pm b/lib/Vend/Config.pm index cfcc7c8..59eb770 100644 --- a/lib/Vend/Config.pm +++ b/lib/Vend/Config.pm @@ -4241,6 +4241,7 @@ my %Ary_ref = ( qw! BINARY BINARY PRECREATE PRECREATE POSTCREATE POSTCREATE + PREQUERY PREQUERY INDEX INDEX ALTERNATE_DSN ALTERNATE_DSN ALTERNATE_USER ALTERNATE_USER diff --git a/lib/Vend/Table/DBI.pm b/lib/Vend/Table/DBI.pm index 45081bc..343c365 100644 --- a/lib/Vend/Table/DBI.pm +++ b/lib/Vend/Table/DBI.pm @@ -654,6 +654,17 @@ sub open_table { $tablename = $config->{REAL_NAME} if $config->{REAL_NAME}; + if (ref $config->{PREQUERY} eq 'ARRAY') { + for (@{$config->{PREQUERY}}) { + $db->do($_) + or ::logError( + "DBI: Pre-use query '%s' failed: %s" , + $_, + $DBI::errstr, + ); + } + } + # Used so you can do query() and nothing else if($config->{HANDLE_ONLY}) { return bless [$config, $tablename, undef, undef, undef, $db], $class;