line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Parse::Dia::SQL::Output::Postgres; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: Postgres.pm,v 1.2 2009/03/02 13:41:39 aff Exp $ |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=pod |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Parse::Dia::SQL::Output::Postgres - Create SQL for Postgres. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SEE ALSO |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Parse::Dia::SQL::Output |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
8
|
|
|
8
|
|
12878
|
use warnings; |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
231
|
|
18
|
8
|
|
|
8
|
|
41
|
use strict; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
142
|
|
19
|
|
|
|
|
|
|
|
20
|
8
|
|
|
8
|
|
36
|
use Data::Dumper; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
337
|
|
21
|
8
|
|
|
8
|
|
46
|
use File::Spec::Functions qw(catfile); |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
453
|
|
22
|
|
|
|
|
|
|
|
23
|
8
|
|
|
8
|
|
57
|
use lib q{lib}; |
|
8
|
|
|
|
|
67
|
|
|
8
|
|
|
|
|
53
|
|
24
|
8
|
|
|
8
|
|
771
|
use base q{Parse::Dia::SQL::Output}; # extends |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
867
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
require Parse::Dia::SQL::Logger; |
27
|
|
|
|
|
|
|
require Parse::Dia::SQL::Const; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 new |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
The constructor. Arguments: |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
36
|
|
|
|
|
|
|
my ( $class, %param ) = @_; |
37
|
|
|
|
|
|
|
my $self = {}; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Set defaults for postgres |
40
|
|
|
|
|
|
|
$param{db} = q{postgres}; |
41
|
|
|
|
|
|
|
$param{object_name_max_length} = $param{object_name_max_length} || 63; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$self = $class->SUPER::new(%param); |
44
|
|
|
|
|
|
|
bless( $self, $class ); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
return $self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 _get_drop_index_sql |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Create drop index sql for given index. Discard tablename. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
(same as sas) |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _get_drop_index_sql { |
58
|
|
|
|
|
|
|
my ( $self, $tablename, $indexname ) = @_; |
59
|
|
|
|
|
|
|
return qq{drop index $indexname cascade} |
60
|
|
|
|
|
|
|
. $self->{end_of_statement} |
61
|
|
|
|
|
|
|
. $self->{newline}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |