use DBIx::Class::Carp;
use Scope::Guard ();
use Context::Preserve 'preserve_context';
-use Try::Tiny;
-use List::Util 'first';
+use DBIx::Class::_Util qw( modver_gt_or_eq modver_gt_or_eq_and_lt dbic_internal_try );
use namespace::clean;
__PACKAGE__->sql_limit_dialect ('RowNum');
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}
sub _dbh_last_insert_id {
my ($self, $dbh, $source, @columns) = @_;
my @ids = ();
+ my $ci = $source->columns_info(\@columns);
foreach my $col (@columns) {
- my $seq = ($source->column_info($col)->{sequence} ||= $self->get_autoinc_seq($source,$col));
+ my $seq = ( $ci->{$col}{sequence} ||= $self->get_autoinc_seq($source,$col));
my $id = $self->_sequence_fetch( 'CURRVAL', $seq );
push @ids, $id;
}
}
else {
$self->throw_exception( sprintf (
- "Unable to introspect trigger '%s' for column %s.%s (references multiple sequences). "
+ "Unable to introspect trigger '%s' for column '%s.%s' (references multiple sequences). "
. "You need to specify the correct 'sequence' explicitly in '%s's column_info.",
$triggers[0]{name},
$source_name,
}
else {
$self->throw_exception( sprintf (
- "Unable to reliably select a BEFORE INSERT trigger for column %s.%s (possibilities: %s). "
+ "Unable to reliably select a BEFORE INSERT trigger for column '%s.%s' (possibilities: %s). "
. "You need to specify the correct 'sequence' explicitly in '%s's column_info.",
$source_name,
$col,
}
$self->throw_exception( sprintf (
- "No suitable BEFORE INSERT triggers found for column %s.%s. "
+ "No suitable BEFORE INSERT triggers found for column '%s.%s'. "
. "You need to specify the correct 'sequence' explicitly in '%s's column_info.",
$source_name,
$col,
local $dbh->{RaiseError} = 1;
local $dbh->{PrintError} = 0;
- return try {
+ ( dbic_internal_try {
$dbh->do('select 1 from dual');
1;
- } catch {
- 0;
- };
+ })
+ ? 1
+ : 0
+ ;
}
sub _dbh_execute {
- #my ($self, $dbh, $sql, $bind, $ident) = @_;
- my ($self, $bind) = @_[0,3];
+ #my ($self, $dbh, $sql, $bind, $bind_attrs) = @_;
+ 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 {
+ local $self->{disable_sth_caching} = 1 if grep {
($_->[0]{_ora_lob_autosplit_part}||0)
>
(__cache_queries_with_max_lob_parts - 1)
return shift->$next(@_)
if $self->transaction_depth;
- # cheat the blockrunner - we do want to rerun things regardless of outer state
- local $self->{_in_do_block};
+ # Cheat the blockrunner we are just about to create:
+ # We *do* want to rerun things regardless of outer state
+ local $self->{_in_do_block}
+ if $self->{_in_do_block};
- return DBIx::Class::Storage::BlockRunner->new(
+ 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 {
- #my ($self, $sth, $tuple_status, @extra) = @_;
+ #my ($self, $source, $sth, $proto_bind, $cols, $data) = @_;
- # DBD::Oracle warns loudly on partial execute_for_fetch failures
- local $_[1]->{PrintWarn} = 0;
+ # Older DBD::Oracle warns loudly on partial execute_for_fetch failures
+ # before https://metacpan.org/source/PYTHIAN/DBD-Oracle-1.28/Changes#L7-9
+ local $_[2]->{PrintWarn} = 0
+ unless modver_gt_or_eq( 'DBD::Oracle', '1.28' );
shift->next::method(@_);
}
my $attrs = $self->next::method($ident, $bind);
- for my $i (0 .. $#$attrs) {
- if (keys %{$attrs->[$i]||{}} and my $col = $bind->[$i][0]{dbic_colname}) {
- $attrs->[$i]{ora_field} = $col;
- }
- }
+ # Push the column name into all bind attrs, make sure to *NOT* write into
+ # the existing $attrs->[$idx]{..} hashref, as it is cached by the call to
+ # next::method above.
+ # FIXME - this code will go away when the LobWriter refactor lands
+ $attrs->[$_]
+ and
+ keys %{ $attrs->[$_] }
+ and
+ $bind->[$_][0]{dbic_colname}
+ and
+ $attrs->[$_] = { %{$attrs->[$_]}, ora_field => $bind->[$_][0]{dbic_colname} }
+ for 0 .. $#$attrs;
$attrs;
}
if ($self->_is_lob_type($dt)) {
- # this is a hot-ish codepath, store an escape-flag in the DBD namespace, so that
- # things like Class::Unload work (unlikely but possible)
- unless ($DBD::Oracle::__DBIC_DBD_VERSION_CHECK_OK__) {
-
- # no earlier - no later
- if ($DBD::Oracle::VERSION eq '1.23') {
- $self->throw_exception(
- "BLOB/CLOB support in DBD::Oracle == 1.23 is broken, use an earlier or later ".
- "version (https://rt.cpan.org/Public/Bug/Display.html?id=46016)"
- );
- }
-
- $DBD::Oracle::__DBIC_DBD_VERSION_CHECK_OK__ = 1;
- }
+ # no earlier - no later
+ $self->throw_exception(
+ "BLOB/CLOB support in DBD::Oracle == 1.23 is broken, use an earlier or later "
+ . "version (https://rt.cpan.org/Public/Bug/Display.html?id=46016)"
+ ) if modver_gt_or_eq_and_lt( 'DBD::Oracle', '1.23', '1.24' );
return {
ora_type => $self->_is_text_lob_type($dt)
my ($final_sql, @final_binds);
if ($op eq 'update') {
- $self->throw_exception('Update with complex WHERE clauses currently not supported')
+ $self->throw_exception('Update with complex WHERE clauses involving BLOB columns currently not supported')
if $sql =~ /\bWHERE\b .+ \bWHERE\b/xs;
my $where_sql;
the L<DBIx::Class::Relationship> name is shortened and appended with half of an
MD5 hash.
-See L<DBIx::Class::Storage/"relname_to_table_alias">.
+See L<DBIx::Class::Storage::DBI/relname_to_table_alias>.
=cut
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);
}
# ORDER SIBLINGS BY
# firstname ASC
-=head1 AUTHOR
+=head1 FURTHER QUESTIONS?
-See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.
+Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
-=head1 LICENSE
+=head1 COPYRIGHT AND LICENSE
-You may distribute this code under the same terms as Perl itself.
+This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
+by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
+redistribute it and/or modify it under the same terms as the
+L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.
=cut