savepoints for Informix
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Informix.pm
1 package DBIx::Class::Storage::DBI::Informix;
2 use strict;
3 use warnings;
4
5 use base qw/DBIx::Class::Storage::DBI/;
6
7 use mro 'c3';
8
9 __PACKAGE__->mk_group_accessors('simple' => '__last_insert_id');
10
11 sub _execute {
12   my $self = shift;
13   my ($op) = @_;
14   my ($rv, $sth, @rest) = $self->next::method(@_);
15   if ($op eq 'insert') {
16     $self->__last_insert_id($sth->{ix_sqlerrd}[1]);
17   }
18   return (wantarray ? ($rv, $sth, @rest) : $rv);
19 }
20
21 sub last_insert_id {
22   shift->__last_insert_id;
23 }
24
25 sub _sql_maker_opts {
26   my ( $self, $opts ) = @_;
27
28   if ( $opts ) {
29     $self->{_sql_maker_opts} = { %$opts };
30   }
31
32   return { limit_dialect => 'SkipFirst', %{$self->{_sql_maker_opts}||{}} };
33 }
34
35 sub _svp_begin {
36     my ($self, $name) = @_;
37
38     $self->_get_dbh->do("SAVEPOINT $name");
39 }
40
41 # can't release savepoints
42 sub _svp_release { 1 }
43
44 sub _svp_rollback {
45     my ($self, $name) = @_;
46
47     $self->_get_dbh->do("ROLLBACK TO SAVEPOINT $name")
48 }
49
50
51 1;
52
53 __END__
54
55 =head1 NAME
56
57 DBIx::Class::Storage::DBI::Informix - Base Storage Class for INFORMIX Support
58
59 =head1 SYNOPSIS
60
61 =head1 DESCRIPTION
62
63 This class implements storage-specific support for Informix
64
65 =head1 AUTHORS
66
67 See L<DBIx::Class/CONTRIBUTORS>
68
69 =head1 LICENSE
70
71 You may distribute this code under the same terms as Perl itself.
72
73 =cut