line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Class::Storage::DBI::IdentityInsert; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
35
|
use strict; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
119
|
|
4
|
5
|
|
|
5
|
|
22
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
106
|
|
5
|
5
|
|
|
5
|
|
21
|
use base 'DBIx::Class::Storage::DBI'; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
424
|
|
6
|
5
|
|
|
5
|
|
32
|
use mro 'c3'; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
24
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
DBIx::Class::Storage::DBI::IdentityInsert - Storage Component for Sybase ASE and |
11
|
|
|
|
|
|
|
MSSQL for Identity Inserts / Updates |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This is a storage component for Sybase ASE |
16
|
|
|
|
|
|
|
(L) and Microsoft SQL Server |
17
|
|
|
|
|
|
|
(L) to support identity inserts, that is |
18
|
|
|
|
|
|
|
inserts of explicit values into C columns. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This is done by wrapping C operations in a pair of table identity |
21
|
|
|
|
|
|
|
toggles like: |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
SET IDENTITY_INSERT $table ON |
24
|
|
|
|
|
|
|
$sql |
25
|
|
|
|
|
|
|
SET IDENTITY_INSERT $table OFF |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# SET IDENTITY_X only works as part of a statement scope. We can not |
30
|
|
|
|
|
|
|
# $dbh->do the $sql and the wrapping set()s individually. Hence the |
31
|
|
|
|
|
|
|
# sql mangling. The newlines are important. |
32
|
|
|
|
|
|
|
sub _prep_for_execute { |
33
|
0
|
|
|
0
|
|
|
my $self = shift; |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
|
return $self->next::method(@_) unless $self->_autoinc_supplied_for_op; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my ($op, $ident) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $table = $self->sql_maker->_quote($ident->name); |
40
|
0
|
|
|
|
|
|
$op = uc $op; |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
0
|
|
|
|
DBIx::Class::Exception->throw( |
43
|
0
|
|
|
|
|
|
"Unexpected _autoinc_supplied_for_op flag in callstack - please file a bug including the stacktrace ( @{[ DBIx::Class::_ENV_::HELP_URL() ]} ):\n\n STACKTRACE STARTS", |
44
|
|
|
|
|
|
|
'stacktrace' |
45
|
|
|
|
|
|
|
) if $op ne 'INSERT' and $op ne 'UPDATE'; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my ($sql, $bind) = $self->next::method(@_); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return (<
|
50
|
|
|
|
|
|
|
SET IDENTITY_$op $table ON |
51
|
|
|
|
|
|
|
$sql |
52
|
|
|
|
|
|
|
SET IDENTITY_$op $table OFF |
53
|
|
|
|
|
|
|
EOS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 FURTHER QUESTIONS? |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Check the list of L. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This module is free software L |
64
|
|
|
|
|
|
|
by the L. You can |
65
|
|
|
|
|
|
|
redistribute it and/or modify it under the same terms as the |
66
|
|
|
|
|
|
|
L. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |