X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FOracle%2FGeneric.pm;h=a69309bfaa07ef653588ee7924f5cb15f5f374de;hb=954077f7dc9c6203ba9e8022587c8f9934ec4b9a;hp=568b56172da9c9f91da4ba46d97b52a900f4e397;hpb=9930caaf7e7c250d914cb1440d9a0f1dd2a1dedc;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm index 568b561..a69309b 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm @@ -103,9 +103,6 @@ sub deployment_statements { my ($schema, $type, $version, $dir, $sqltargs, @rest) = @_; $sqltargs ||= {}; - my $quote_char = $self->schema->storage->sql_maker->quote_char; - $sqltargs->{quote_table_names} = $quote_char ? 1 : 0; - $sqltargs->{quote_field_names} = $quote_char ? 1 : 0; if ( ! exists $sqltargs->{producer_args}{oracle_version} @@ -133,7 +130,7 @@ sub _dbh_get_autoinc_seq { my ($self, $dbh, $source, $col) = @_; my $sql_maker = $self->sql_maker; - my ($ql, $qr) = map { $_ ? (quotemeta $_) : '' } $sql_maker->_quote_chars; + my $quoting = !!($sql_maker->_quote_chars)[0]; my $source_name; if ( ref $source->name eq 'SCALAR' ) { @@ -145,7 +142,7 @@ sub _dbh_get_autoinc_seq { } else { $source_name = $source->name; - $source_name = uc($source_name) unless $ql; + $source_name = uc($source_name) unless $quoting; } # trigger_body is a LONG @@ -154,8 +151,10 @@ sub _dbh_get_autoinc_seq { # disable default bindtype local $sql_maker->{bindtype} = 'normal'; + my $ident_re = $quoting ? qr/ @{[$sql_maker->quoted_ident_re]} | \w+ /x : qr/ \w+ /x; + # look up the correct sequence automatically - my ( $schema, $table ) = $source_name =~ /( (?:${ql})? \w+ (?:${qr})? ) \. ( (?:${ql})? \w+ (?:${qr})? )/x; + my ( $schema, $table ) = map { $sql_maker->_unquote($_) } $source_name =~ /( $ident_re ) \. ( $ident_re )/x; # if no explicit schema was requested - use the default schema (which in the case of Oracle is the db user) $schema ||= \'= USER'; @@ -175,10 +174,11 @@ sub _dbh_get_autoinc_seq { # to find all the triggers that mention the column in question a simple # regex grep since the trigger_body above is a LONG and hence not searchable # via -like + my $qcol = $sql_maker->_quote($col); my @triggers = ( map { my %inf; @inf{qw/body schema name/} = @$_; \%inf } ( grep - { $_->[0] =~ /\:new\.${ql}${col}${qr} | \:new\.$col/xi } + { $_->[0] =~ /\:new\.(?: \Q$qcol\E | \Q$col\E )/xi } @{ $dbh->selectall_arrayref( $sql, {}, @bind ) } ) ); @@ -216,7 +216,7 @@ sub _dbh_get_autoinc_seq { elsif (@triggers > 1) { my @candidates = grep - { $_->{body} =~ / into \s+ \:new\.$col /xi } + { $_->{body} =~ / into \s+ \:new\.\Q$col\E /xi } @triggers ; @@ -285,7 +285,7 @@ sub _ping { sub _dbh_execute { #my ($self, $dbh, $sql, $bind, $bind_attrs) = @_; - my ($self, $bind) = @_[0,3]; + my ($self, $sql, $bind) = @_[0,2,3]; # Turn off sth caching for multi-part LOBs. See _prep_for_execute below local $self->{disable_sth_caching} = 1 if first { @@ -300,26 +300,31 @@ sub _dbh_execute { return shift->$next(@_) if $self->transaction_depth; - # cheat the blockrunner - we do want to rerun things regardless of outer state + # cheat the blockrunner we are just about to create + # we do want to rerun things regardless of outer state local $self->{_in_do_block}; return DBIx::Class::Storage::BlockRunner->new( storage => $self, - run_code => $next, - run_args => \@_, wrap_txn => 0, retry_handler => sub { # ORA-01003: no statement parsed (someone changed the table somehow, # invalidating your cursor.) - return 0 if ($_[0]->retried_count or $_[0]->last_exception !~ /ORA-01003/); - - # re-prepare towards new table data - if (my $dbh = $_[0]->storage->_dbh) { - delete $dbh->{CachedKids}{$_[0]->run_args->[2]}; + if ( + $_[0]->failed_attempt_count == 1 + and + $_[0]->last_exception =~ /ORA-01003/ + and + my $dbh = $_[0]->storage->_dbh + ) { + delete $dbh->{CachedKids}{$sql}; + return 1; + } + else { + return 0; } - return 1; }, - )->run; + )->run( $next, @_ ); } sub _dbh_execute_for_fetch { @@ -644,7 +649,7 @@ sub relname_to_table_alias { my $alias = $self->next::method(@_); # we need to shorten here in addition to the shortening in SQLA itself, - # since the final relnames are a crucial for the join optimizer + # since the final relnames are crucial for the join optimizer return $self->sql_maker->_shorten_identifier($alias); }