« blib/lib/SQL/Translator/Parser/DBI/SQLServer.pm
↑ Summary
blib/lib/SQL/Translator/Parser/DBI/Sybase.pm »
| 1 | package SQL::Translator::Producer::Oracle; | ||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||
| 5 | SQL::Translator::Producer::Oracle - Oracle SQL producer | ||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||
| 9 | use SQL::Translator; | ||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||
| 11 | my $t = SQL::Translator->new( parser => '...', producer => 'Oracle' ); | ||||||||||||||||||||||||||||||||||||||||
| 12 | print $translator->translate( $file ); | ||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||
| 14 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||
| 16 | Creates an SQL DDL suitable for Oracle. | ||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||
| 18 | =head1 producer_args | ||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||
| 20 | =over | ||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||
| 22 | =item delay_constraints | ||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||
| 24 | This option remove the primary key and other key constraints from the | ||||||||||||||||||||||||||||||||||||||||
| 25 | CREATE TABLE statement and adds ALTER TABLEs at the end with it. | ||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||
| 27 | =item quote_field_names | ||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||
| 29 | Controls whether quotes are being used around column names in generated DDL. | ||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||
| 31 | =item quote_table_names | ||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||
| 33 | Controls whether quotes are being used around table, sequence and trigger names in | ||||||||||||||||||||||||||||||||||||||||
| 34 | generated DDL. | ||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||
| 36 | =back | ||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||
| 38 | =head1 NOTES | ||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||
| 40 | =head2 Autoincremental primary keys | ||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||
| 42 | This producer uses sequences and triggers to autoincrement primary key | ||||||||||||||||||||||||||||||||||||||||
| 43 | columns, if necessary. SQLPlus and DBI expect a slightly different syntax | ||||||||||||||||||||||||||||||||||||||||
| 44 | of CREATE TRIGGER statement. You might have noticed that this | ||||||||||||||||||||||||||||||||||||||||
| 45 | producer returns a scalar containing all statements concatenated by | ||||||||||||||||||||||||||||||||||||||||
| 46 | newlines or an array of single statements depending on the context | ||||||||||||||||||||||||||||||||||||||||
| 47 | (scalar, array) it has been called in. | ||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||
| 49 | SQLPlus expects following trigger syntax: | ||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||
| 51 | CREATE OR REPLACE TRIGGER ai_person_id | ||||||||||||||||||||||||||||||||||||||||
| 52 | BEFORE INSERT ON person | ||||||||||||||||||||||||||||||||||||||||
| 53 | FOR EACH ROW WHEN ( | ||||||||||||||||||||||||||||||||||||||||
| 54 | new.id IS NULL OR new.id = 0 | ||||||||||||||||||||||||||||||||||||||||
| 55 | ) | ||||||||||||||||||||||||||||||||||||||||
| 56 | BEGIN | ||||||||||||||||||||||||||||||||||||||||
| 57 | SELECT sq_person_id.nextval | ||||||||||||||||||||||||||||||||||||||||
| 58 | INTO :new.id | ||||||||||||||||||||||||||||||||||||||||
| 59 | FROM dual; | ||||||||||||||||||||||||||||||||||||||||
| 60 | END; | ||||||||||||||||||||||||||||||||||||||||
| 61 | / | ||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||
| 63 | Whereas if you want to create the same trigger using L<DBI/do>, you need | ||||||||||||||||||||||||||||||||||||||||
| 64 | to omit the last slash: | ||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||
| 66 | my $dbh = DBI->connect('dbi:Oracle:mysid', 'scott', 'tiger'); | ||||||||||||||||||||||||||||||||||||||||
| 67 | $dbh->do(" | ||||||||||||||||||||||||||||||||||||||||
| 68 | CREATE OR REPLACE TRIGGER ai_person_id | ||||||||||||||||||||||||||||||||||||||||
| 69 | BEFORE INSERT ON person | ||||||||||||||||||||||||||||||||||||||||
| 70 | FOR EACH ROW WHEN ( | ||||||||||||||||||||||||||||||||||||||||
| 71 | new.id IS NULL OR new.id = 0 | ||||||||||||||||||||||||||||||||||||||||
| 72 | ) | ||||||||||||||||||||||||||||||||||||||||
| 73 | BEGIN | ||||||||||||||||||||||||||||||||||||||||
| 74 | SELECT sq_person_id.nextval | ||||||||||||||||||||||||||||||||||||||||
| 75 | INTO :new.id | ||||||||||||||||||||||||||||||||||||||||
| 76 | FROM dual; | ||||||||||||||||||||||||||||||||||||||||
| 77 | END; | ||||||||||||||||||||||||||||||||||||||||
| 78 | "); | ||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||
| 80 | If you call this producer in array context, we expect you want to process | ||||||||||||||||||||||||||||||||||||||||
| 81 | the returned array of statements using L<DBI> like | ||||||||||||||||||||||||||||||||||||||||
| 82 | L<DBIx::Class::Schema/deploy> does. | ||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||
| 84 | To get this working we removed the slash in those statements in version | ||||||||||||||||||||||||||||||||||||||||
| 85 | 0.09002 of L<SQL::Translator> when called in array context. In scalar | ||||||||||||||||||||||||||||||||||||||||
| 86 | context the slash will be still there to ensure compatibility with SQLPlus. | ||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||
| 88 | =cut | ||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||
| 90 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 91 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 92 | 10 | our ( $DEBUG, $WARN ); | |||||||||||||||||||||||||||||||||||||||
| 93 | 10 | our $VERSION = '1.6_3'; | |||||||||||||||||||||||||||||||||||||||
| 94 | 10 | ▶ | $DEBUG = 0 unless defined $DEBUG; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||
| 96 | 10 | ▶ | use base 'SQL::Translator::Producer'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 97 | 10 | ▶ | use SQL::Translator::Schema::Constants; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 98 | 10 | ▶ | use SQL::Translator::Utils qw(header_comment); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||
| 100 | 10 | my %translate = ( | |||||||||||||||||||||||||||||||||||||||
| 101 | # | ||||||||||||||||||||||||||||||||||||||||
| 102 | # MySQL types | ||||||||||||||||||||||||||||||||||||||||
| 103 | # | ||||||||||||||||||||||||||||||||||||||||
| 104 | bigint => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 105 | double => 'float', | ||||||||||||||||||||||||||||||||||||||||
| 106 | decimal => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 107 | float => 'float', | ||||||||||||||||||||||||||||||||||||||||
| 108 | int => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 109 | integer => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 110 | mediumint => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 111 | smallint => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 112 | tinyint => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 113 | char => 'char', | ||||||||||||||||||||||||||||||||||||||||
| 114 | varchar => 'varchar2', | ||||||||||||||||||||||||||||||||||||||||
| 115 | tinyblob => 'blob', | ||||||||||||||||||||||||||||||||||||||||
| 116 | blob => 'blob', | ||||||||||||||||||||||||||||||||||||||||
| 117 | mediumblob => 'blob', | ||||||||||||||||||||||||||||||||||||||||
| 118 | longblob => 'blob', | ||||||||||||||||||||||||||||||||||||||||
| 119 | tinytext => 'varchar2', | ||||||||||||||||||||||||||||||||||||||||
| 120 | text => 'clob', | ||||||||||||||||||||||||||||||||||||||||
| 121 | longtext => 'clob', | ||||||||||||||||||||||||||||||||||||||||
| 122 | mediumtext => 'clob', | ||||||||||||||||||||||||||||||||||||||||
| 123 | enum => 'varchar2', | ||||||||||||||||||||||||||||||||||||||||
| 124 | set => 'varchar2', | ||||||||||||||||||||||||||||||||||||||||
| 125 | date => 'date', | ||||||||||||||||||||||||||||||||||||||||
| 126 | datetime => 'date', | ||||||||||||||||||||||||||||||||||||||||
| 127 | time => 'date', | ||||||||||||||||||||||||||||||||||||||||
| 128 | timestamp => 'date', | ||||||||||||||||||||||||||||||||||||||||
| 129 | year => 'date', | ||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||
| 131 | # | ||||||||||||||||||||||||||||||||||||||||
| 132 | # PostgreSQL types | ||||||||||||||||||||||||||||||||||||||||
| 133 | # | ||||||||||||||||||||||||||||||||||||||||
| 134 | numeric => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 135 | 'double precision' => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 136 | serial => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 137 | bigserial => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 138 | money => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 139 | character => 'char', | ||||||||||||||||||||||||||||||||||||||||
| 140 | 'character varying' => 'varchar2', | ||||||||||||||||||||||||||||||||||||||||
| 141 | bytea => 'BLOB', | ||||||||||||||||||||||||||||||||||||||||
| 142 | interval => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 143 | boolean => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 144 | point => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 145 | line => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 146 | lseg => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 147 | box => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 148 | path => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 149 | polygon => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 150 | circle => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 151 | cidr => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 152 | inet => 'varchar2', | ||||||||||||||||||||||||||||||||||||||||
| 153 | macaddr => 'varchar2', | ||||||||||||||||||||||||||||||||||||||||
| 154 | bit => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 155 | 'bit varying' => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||
| 157 | # | ||||||||||||||||||||||||||||||||||||||||
| 158 | # Oracle types | ||||||||||||||||||||||||||||||||||||||||
| 159 | # | ||||||||||||||||||||||||||||||||||||||||
| 160 | number => 'number', | ||||||||||||||||||||||||||||||||||||||||
| 161 | varchar2 => 'varchar2', | ||||||||||||||||||||||||||||||||||||||||
| 162 | long => 'clob', | ||||||||||||||||||||||||||||||||||||||||
| 163 | ); | ||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||
| 165 | # | ||||||||||||||||||||||||||||||||||||||||
| 166 | # Oracle 8/9 max size of data types from: | ||||||||||||||||||||||||||||||||||||||||
| 167 | # http://www.ss64.com/orasyntax/datatypes.html | ||||||||||||||||||||||||||||||||||||||||
| 168 | # | ||||||||||||||||||||||||||||||||||||||||
| 169 | 10 | my %max_size = ( | |||||||||||||||||||||||||||||||||||||||
| 170 | char => 2000, | ||||||||||||||||||||||||||||||||||||||||
| 171 | float => 126, | ||||||||||||||||||||||||||||||||||||||||
| 172 | nchar => 2000, | ||||||||||||||||||||||||||||||||||||||||
| 173 | nvarchar2 => 4000, | ||||||||||||||||||||||||||||||||||||||||
| 174 | number => [ 38, 127 ], | ||||||||||||||||||||||||||||||||||||||||
| 175 | raw => 2000, | ||||||||||||||||||||||||||||||||||||||||
| 176 | varchar => 4000, # only synonym for varchar2 | ||||||||||||||||||||||||||||||||||||||||
| 177 | varchar2 => 4000, | ||||||||||||||||||||||||||||||||||||||||
| 178 | ); | ||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||
| 180 | 10 | my $max_id_length = 30; | |||||||||||||||||||||||||||||||||||||||
| 181 | 10 | my %used_identifiers = (); | |||||||||||||||||||||||||||||||||||||||
| 182 | 10 | my %global_names; | |||||||||||||||||||||||||||||||||||||||
| 183 | my %truncated; | ||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||
| 185 | # Quote used to escape table, field, sequence and trigger names | ||||||||||||||||||||||||||||||||||||||||
| 186 | 10 | my $quote_char = '"'; | |||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||
| 188 | sub produce { | ||||||||||||||||||||||||||||||||||||||||
| 189 | 10 | ▶ | my $translator = shift; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
produce: called CC=13 SCAR=25.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 190 | 10 | $DEBUG = $translator->debug; | |||||||||||||||||||||||||||||||||||||||
| 191 | 10 | ▶ | $WARN = $translator->show_warnings || 0; | ||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$translator->show_warnings || 0
MC/DC0%0/1
$translator->show_warnings || 0
$translator->show_warnings
Truth table50%1/2
A
A= $translator->show_warnings
| |||||||||||||||||||||||||||||||||||||||||
| 192 | 10 | my $no_comments = $translator->no_comments; | |||||||||||||||||||||||||||||||||||||||
| 193 | 10 | my $add_drop_table = $translator->add_drop_table; | |||||||||||||||||||||||||||||||||||||||
| 194 | 10 | my $schema = $translator->schema; | |||||||||||||||||||||||||||||||||||||||
| 195 | 10 | ▶ | my $oracle_version = $translator->producer_args->{oracle_version} || 0; | ||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$translator->producer_args->{'oracle_version'} || 0
MC/DC0%0/1
$translator->producer_args->{'oracle_version'} || 0
$translator->producer_args->{'oracle_version'}
Truth table50%1/2
A
A= $translator->producer_args->{'oracle_version'}
| |||||||||||||||||||||||||||||||||||||||||
| 196 | 10 | my $delay_constraints = $translator->producer_args->{delay_constraints}; | |||||||||||||||||||||||||||||||||||||||
| 197 | 10 | my ($output, $create, @table_defs, @fk_defs, @trigger_defs, @index_defs, @constraint_defs); | |||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||
| 199 | 10 | ▶ | $create .= header_comment unless ($no_comments); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 200 | 10 | ▶ | my $qt = 1 if $translator->quote_table_names; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 201 | 10 | ▶ | my $qf = 1 if $translator->quote_field_names; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||
| 203 | 10 | ▶ | if ( $translator->parser_type =~ /mysql/i ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | ▶ | $create .= | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 205 | "-- We assume that default NLS_DATE_FORMAT has been changed\n". | ||||||||||||||||||||||||||||||||||||||||
| 206 | "-- but we set it here anyway to be self-consistent.\n" | ||||||||||||||||||||||||||||||||||||||||
| 207 | unless $no_comments; | ||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||
| 209 | 1 | $create .= | |||||||||||||||||||||||||||||||||||||||
| 210 | "ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS';\n\n"; | ||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||
| 213 | 10 | for my $table ( $schema->get_tables ) { | |||||||||||||||||||||||||||||||||||||||
| 214 | 20 | my ( $table_def, $fk_def, $trigger_def, $index_def, $constraint_def ) = create_table( | |||||||||||||||||||||||||||||||||||||||
| 215 | $table, | ||||||||||||||||||||||||||||||||||||||||
| 216 | { | ||||||||||||||||||||||||||||||||||||||||
| 217 | add_drop_table => $add_drop_table, | ||||||||||||||||||||||||||||||||||||||||
| 218 | show_warnings => $WARN, | ||||||||||||||||||||||||||||||||||||||||
| 219 | no_comments => $no_comments, | ||||||||||||||||||||||||||||||||||||||||
| 220 | delay_constraints => $delay_constraints, | ||||||||||||||||||||||||||||||||||||||||
| 221 | quote_table_names => $qt, | ||||||||||||||||||||||||||||||||||||||||
| 222 | quote_field_names => $qf, | ||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||
| 224 | ); | ||||||||||||||||||||||||||||||||||||||||
| 225 | 20 | push @table_defs, @$table_def; | |||||||||||||||||||||||||||||||||||||||
| 226 | 20 | push @fk_defs, @$fk_def; | |||||||||||||||||||||||||||||||||||||||
| 227 | 20 | push @trigger_defs, @$trigger_def; | |||||||||||||||||||||||||||||||||||||||
| 228 | 20 | push @index_defs, @$index_def; | |||||||||||||||||||||||||||||||||||||||
| 229 | 20 | push @constraint_defs, @$constraint_def; | |||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||
| 232 | 10 | my (@view_defs); | |||||||||||||||||||||||||||||||||||||||
| 233 | 10 | foreach my $view ( $schema->get_views ) { | |||||||||||||||||||||||||||||||||||||||
| 234 | 5 | my ( $view_def ) = create_view( | |||||||||||||||||||||||||||||||||||||||
| 235 | $view, | ||||||||||||||||||||||||||||||||||||||||
| 236 | { | ||||||||||||||||||||||||||||||||||||||||
| 237 | add_drop_view => $add_drop_table, | ||||||||||||||||||||||||||||||||||||||||
| 238 | quote_table_names => $qt, | ||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||
| 240 | ); | ||||||||||||||||||||||||||||||||||||||||
| 241 | 5 | push @view_defs, @$view_def; | |||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||
| 244 | 10 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | ▶ | return defined $create ? $create : (), @table_defs, @view_defs, @fk_defs, @trigger_defs, @index_defs, @constraint_defs; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||
| 247 | else { | ||||||||||||||||||||||||||||||||||||||||
| 248 | 8 | $create .= join (";\n\n", @table_defs, @view_defs, @fk_defs, @index_defs, @constraint_defs); | |||||||||||||||||||||||||||||||||||||||
| 249 | 8 | $create .= ";\n\n"; | |||||||||||||||||||||||||||||||||||||||
| 250 | # If wantarray is not set we have to add "/" in this statement | ||||||||||||||||||||||||||||||||||||||||
| 251 | # DBI->do() needs them omitted | ||||||||||||||||||||||||||||||||||||||||
| 252 | # triggers may NOT end with a semicolon but a "/" instead | ||||||||||||||||||||||||||||||||||||||||
| 253 | $create .= "$_/\n\n" | ||||||||||||||||||||||||||||||||||||||||
| 254 | 8 | for @trigger_defs; | |||||||||||||||||||||||||||||||||||||||
| 255 | 8 | return $create; | |||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||
| 259 | sub create_table { | ||||||||||||||||||||||||||||||||||||||||
| 260 | 21 | ▶ | my ($table, $options) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_table: called CC=70 SCAR=58.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 261 | 21 | my $qt = $options->{quote_table_names}; | |||||||||||||||||||||||||||||||||||||||
| 262 | 21 | my $qf = $options->{quote_field_names}; | |||||||||||||||||||||||||||||||||||||||
| 263 | 21 | my $table_name = $table->name; | |||||||||||||||||||||||||||||||||||||||
| 264 | 21 | my $table_name_q = quote($table_name,$qt); | |||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||
| 266 | 21 | my $item = ''; | |||||||||||||||||||||||||||||||||||||||
| 267 | 21 | my $drop; | |||||||||||||||||||||||||||||||||||||||
| 268 | 21 | my (@create, @field_defs, @constraint_defs, @fk_defs, @trigger_defs); | |||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||
| 270 | 21 | ▶ | push @create, "--\n-- Table: $table_name\n--" unless $options->{no_comments}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 271 | 21 | ▶ | push @create, qq[DROP TABLE $table_name_q CASCADE CONSTRAINTS] if $options->{add_drop_table}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||
| 273 | 21 | my ( %field_name_scope, @field_comments ); | |||||||||||||||||||||||||||||||||||||||
| 274 | 21 | for my $field ( $table->get_fields ) { | |||||||||||||||||||||||||||||||||||||||
| 275 | 84 | my ($field_create, $field_defs, $trigger_defs, $field_comments) = | |||||||||||||||||||||||||||||||||||||||
| 276 | create_field($field, $options, \%field_name_scope); | ||||||||||||||||||||||||||||||||||||||||
| 277 | 84 | ▶ | push @create, @$field_create if ref $field_create; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 278 | 84 | ▶ | push @field_defs, @$field_defs if ref $field_defs; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 279 | 84 | ▶ | push @trigger_defs, @$trigger_defs if ref $trigger_defs; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 280 | 84 | ▶ | push @field_comments, @$field_comments if ref $field_comments; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||
| 283 | # | ||||||||||||||||||||||||||||||||||||||||
| 284 | # Table options | ||||||||||||||||||||||||||||||||||||||||
| 285 | # | ||||||||||||||||||||||||||||||||||||||||
| 286 | 21 | my @table_options; | |||||||||||||||||||||||||||||||||||||||
| 287 | 21 | for my $opt ( $table->options ) { | |||||||||||||||||||||||||||||||||||||||
| 288 | 7 | ▶ | if ( ref $opt eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 289 | 5 | my ( $key, $value ) = each %$opt; | |||||||||||||||||||||||||||||||||||||||
| 290 | 5 | ▶ | if ( ref $value eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 291 | push @table_options, "$key\n(\n". join ("\n", | ||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | map { " $_->[0]\t$_->[1]" } | |||||||||||||||||||||||||||||||||||||||
| 293 | 0 | map { [ each %$_ ] } | |||||||||||||||||||||||||||||||||||||||
| 294 | @$value | ||||||||||||||||||||||||||||||||||||||||
| 295 | )."\n)"; | ||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||
| 297 | elsif ( !defined $value ) { | ||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | push @table_options, $key; | |||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||
| 300 | else { | ||||||||||||||||||||||||||||||||||||||||
| 301 | 5 | push @table_options, "$key $value"; | |||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||
| 306 | # | ||||||||||||||||||||||||||||||||||||||||
| 307 | # Table constraints | ||||||||||||||||||||||||||||||||||||||||
| 308 | # | ||||||||||||||||||||||||||||||||||||||||
| 309 | 21 | for my $c ( $table->get_constraints ) { | |||||||||||||||||||||||||||||||||||||||
| 310 | 35 | ▶ | my $name = $c->name || ''; | ||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$c->name || ''
MC/DC100%1/1
$c->name || ''
$c->name
Truth table100%2/2
A
A= $c->name
| |||||||||||||||||||||||||||||||||||||||||
| 311 | 35 | my @fields = map { quote($_,$qf) } $c->fields; | |||||||||||||||||||||||||||||||||||||||
| 312 | 35 | my @rfields = map { quote($_,$qf) } $c->reference_fields; | |||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||
| 314 | 35 | ▶ | next if !@fields && $c->type ne CHECK_C; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not @fields and $c->type ne "CHECK"
MC/DC0%0/2
not @fields and $c->type ne "CHECK"
not @fields
$c->type ne "CHECK"
Truth table33%1/3
not(A) and B
A= not @fieldsB= $c->type ne "CHECK"
| |||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||
| 316 | 35 | ▶ | if ( $c->type eq PRIMARY_KEY ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||
| 317 | # create a name if delay_constraints | ||||||||||||||||||||||||||||||||||||||||
| 318 | $name ||= mk_name( $table_name, 'pk' ) | ||||||||||||||||||||||||||||||||||||||||
| 319 | 18 | ▶ | if $options->{delay_constraints}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$name ||= mk_name($table_name, "pk")
MC/DC0%0/2
$name ||= mk_name($table_name, "pk")
$name
mk_name($table_name, "pk")
Truth table33%1/3
A ||= B
A= $nameB= mk_name($table_name, "pk")
| |||||||||||||||||||||||||||||||||||||||||
| 320 | 18 | $name = quote($name,$qf); | |||||||||||||||||||||||||||||||||||||||
| 321 | 18 | ▶ | push @constraint_defs, ($name ? "CONSTRAINT $name " : '') . | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 322 | 'PRIMARY KEY (' . join( ', ', @fields ) . ')'; | ||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||
| 324 | elsif ( $c->type eq UNIQUE ) { | ||||||||||||||||||||||||||||||||||||||||
| 325 | # Don't create UNIQUE constraints identical to the primary key | ||||||||||||||||||||||||||||||||||||||||
| 326 | 10 | ▶ | if ( my $pk = $table->primary_key ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 327 | 10 | my $u_fields = join(":", @fields); | |||||||||||||||||||||||||||||||||||||||
| 328 | 10 | my $pk_fields = join(":", $pk->fields); | |||||||||||||||||||||||||||||||||||||||
| 329 | 10 | ▶ | next if $u_fields eq $pk_fields; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||
| 332 | 10 | ▶ | if ($name) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 333 | # Force prepend of table_name as ORACLE doesn't allow duplicate | ||||||||||||||||||||||||||||||||||||||||
| 334 | # CONSTRAINT names even for different tables (ORA-02264) | ||||||||||||||||||||||||||||||||||||||||
| 335 | 10 | ▶ | $name = mk_name( "${table_name}_$name", 'u' ) unless $name =~ /^$table_name/; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||
| 337 | else { | ||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $name = mk_name( $table_name, 'u' ); | |||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||
| 341 | 10 | $name = quote($name, $qf); | |||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||
| 343 | 10 | for my $f ( $c->fields ) { | |||||||||||||||||||||||||||||||||||||||
| 344 | 10 | ▶ | my $field_def = $table->get_field( $f ) or next; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 345 | 10 | ▶ | my $dtype = $translate{ ref $field_def->data_type eq "ARRAY" ? $field_def->data_type->[0] : $field_def->data_type} or next; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 346 | 10 | ▶ | if ( $WARN && $dtype =~ /clob/i ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$SQL::Translator::Producer::Oracle::WARN and $dtype =~ /clob/i
MC/DC0%0/2
$SQL::Translator::Producer::Oracle::WARN and $dtype =~ /clob/i
$SQL::Translator::Producer::Oracle::WARN
$dtype =~ /clob/i
Truth table33%1/3
A and B
A= $SQL::Translator::Producer::Oracle::WARNB= $dtype =~ /clob/i
| |||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | warn "Oracle will not allow UNIQUE constraints on " . | |||||||||||||||||||||||||||||||||||||||
| 348 | "CLOB field '" . $field_def->table->name . '.' . | ||||||||||||||||||||||||||||||||||||||||
| 349 | $field_def->name . ".'\n" | ||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||
| 353 | 10 | push @constraint_defs, "CONSTRAINT $name UNIQUE " . | |||||||||||||||||||||||||||||||||||||||
| 354 | '(' . join( ', ', @fields ) . ')'; | ||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||
| 356 | elsif ( $c->type eq CHECK_C ) { | ||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | $name ||= mk_name( $name || $table_name, 'ck' ); | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$name ||= mk_name($name || $table_name, "ck")
$name || $table_name
MC/DC0%0/2
$name ||= mk_name($name || $table_name, "ck")
$name
mk_name($name || $table_name, "ck")
MC/DC0%0/2
$name || $table_name
$name
$table_name
Truth table0%0/3
A ||= B
A= $nameB= mk_name($name || $table_name, "ck")
Truth table0%0/3
A || B
A= $nameB= $table_name
| |||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | $name = quote($name, $qf); | |||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | my $expression = $c->expression || ''; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$c->expression || ''
MC/DC0%0/1
$c->expression || ''
$c->expression
Truth table0%0/2
A
A= $c->expression
| |||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | push @constraint_defs, "CONSTRAINT $name CHECK ($expression)"; | |||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||
| 362 | elsif ( $c->type eq FOREIGN_KEY ) { | ||||||||||||||||||||||||||||||||||||||||
| 363 | 7 | $name = mk_name( join('_', $table_name, $c->fields). '_fk' ); | |||||||||||||||||||||||||||||||||||||||
| 364 | 7 | $name = quote($name, $qf); | |||||||||||||||||||||||||||||||||||||||
| 365 | 7 | ▶ | my $on_delete = uc ($c->on_delete || ''); | ||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$c->on_delete || ''
MC/DC0%0/1
$c->on_delete || ''
$c->on_delete
Truth table50%1/2
A
A= $c->on_delete
| |||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||
| 367 | 7 | my $def = "CONSTRAINT $name FOREIGN KEY "; | |||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||
| 369 | 7 | ▶ | if ( @fields ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 370 | 7 | $def .= '(' . join( ', ', @fields ) . ')'; | |||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||
| 373 | 7 | my $ref_table = quote($c->reference_table,$qt); | |||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||
| 375 | 7 | $def .= " REFERENCES $ref_table"; | |||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||
| 377 | 7 | ▶ | if ( @rfields ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 378 | 7 | $def .= ' (' . join( ', ', @rfields ) . ')'; | |||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||
| 381 | 7 | ▶ | if ( $c->match_type ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | $def .= ' MATCH ' . | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 383 | ( $c->match_type =~ /full/i ) ? 'FULL' : 'PARTIAL'; | ||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||
| 386 | 7 | ▶ | if ( $on_delete && $on_delete ne "RESTRICT") { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$on_delete and $on_delete ne "RESTRICT"
MC/DC0%0/2
$on_delete and $on_delete ne "RESTRICT"
$on_delete
$on_delete ne "RESTRICT"
Truth table33%1/3
A and B
A= $on_deleteB= $on_delete ne "RESTRICT"
| |||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $def .= ' ON DELETE '.$c->on_delete; | |||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||
| 390 | # disabled by plu 2007-12-29 - doesn't exist for oracle | ||||||||||||||||||||||||||||||||||||||||
| 391 | #if ( $c->on_update ) { | ||||||||||||||||||||||||||||||||||||||||
| 392 | # $def .= ' ON UPDATE '. $c->on_update; | ||||||||||||||||||||||||||||||||||||||||
| 393 | #} | ||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||
| 395 | 7 | push @fk_defs, sprintf("ALTER TABLE %s ADD %s", $table_name_q, $def); | |||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||
| 399 | # | ||||||||||||||||||||||||||||||||||||||||
| 400 | # Index Declarations | ||||||||||||||||||||||||||||||||||||||||
| 401 | # | ||||||||||||||||||||||||||||||||||||||||
| 402 | 21 | my @index_defs = (); | |||||||||||||||||||||||||||||||||||||||
| 403 | 21 | for my $index ( $table->get_indices ) { | |||||||||||||||||||||||||||||||||||||||
| 404 | 11 | ▶ | my $index_name = $index->name || ''; | ||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$index->name || ''
MC/DC0%0/1
$index->name || ''
$index->name
Truth table50%1/2
A
A= $index->name
| |||||||||||||||||||||||||||||||||||||||||
| 405 | 11 | ▶ | my $index_type = $index->type || NORMAL; | ||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$index->type || 'NORMAL'
MC/DC0%0/1
$index->type || 'NORMAL'
$index->type
Truth table50%1/2
A
A= $index->type
| |||||||||||||||||||||||||||||||||||||||||
| 406 | 11 | my @fields = map { quote($_, $qf) } $index->fields; | |||||||||||||||||||||||||||||||||||||||
| 407 | 11 | ▶ | next unless @fields; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||
| 409 | 11 | my @index_options; | |||||||||||||||||||||||||||||||||||||||
| 410 | 11 | for my $opt ( $index->options ) { | |||||||||||||||||||||||||||||||||||||||
| 411 | 3 | ▶ | if ( ref $opt eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 412 | 3 | my ( $key, $value ) = each %$opt; | |||||||||||||||||||||||||||||||||||||||
| 413 | 3 | ▶ | if ( ref $value eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 414 | push @table_options, "$key\n(\n". join ("\n", | ||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | map { " $_->[0]\t$_->[1]" } | |||||||||||||||||||||||||||||||||||||||
| 416 | 0 | map { [ each %$_ ] } | |||||||||||||||||||||||||||||||||||||||
| 417 | @$value | ||||||||||||||||||||||||||||||||||||||||
| 418 | )."\n)"; | ||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||
| 420 | elsif ( !defined $value ) { | ||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | push @index_options, $key; | |||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||
| 423 | else { | ||||||||||||||||||||||||||||||||||||||||
| 424 | 3 | push @index_options, "$key $value"; | |||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||
| 428 | 11 | ▶ | my $index_options = @index_options | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 429 | ? "\n".join("\n", @index_options) : ''; | ||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||
| 431 | 11 | ▶ | if ( $index_type eq PRIMARY_KEY ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | $index_name = $index_name ? mk_name( $index_name ) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 433 | : mk_name( $table_name, 'pk' ); | ||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | $index_name = quote($index_name, $qf); | |||||||||||||||||||||||||||||||||||||||
| 435 | 0 | push @field_defs, 'CONSTRAINT '.$index_name.' PRIMARY KEY '. | |||||||||||||||||||||||||||||||||||||||
| 436 | '(' . join( ', ', @fields ) . ')'; | ||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||
| 438 | elsif ( $index_type eq NORMAL ) { | ||||||||||||||||||||||||||||||||||||||||
| 439 | 10 | ▶ | $index_name = $index_name ? mk_name( $index_name ) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$index_name || 'i'
MC/DC0%0/1
$index_name || 'i'
$index_name
Truth table0%0/2
A
A= $index_name
| |||||||||||||||||||||||||||||||||||||||||
| 440 | : mk_name( $table_name, $index_name || 'i' ); | ||||||||||||||||||||||||||||||||||||||||
| 441 | 10 | $index_name = quote($index_name, $qf); | |||||||||||||||||||||||||||||||||||||||
| 442 | 10 | push @index_defs, | |||||||||||||||||||||||||||||||||||||||
| 443 | "CREATE INDEX $index_name on $table_name_q (". | ||||||||||||||||||||||||||||||||||||||||
| 444 | join( ', ', @fields ). | ||||||||||||||||||||||||||||||||||||||||
| 445 | ")$index_options"; | ||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||
| 447 | elsif ( $index_type eq UNIQUE ) { | ||||||||||||||||||||||||||||||||||||||||
| 448 | 1 | ▶ | $index_name = $index_name ? mk_name( $index_name ) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$index_name || 'i'
MC/DC0%0/1
$index_name || 'i'
$index_name
Truth table0%0/2
A
A= $index_name
| |||||||||||||||||||||||||||||||||||||||||
| 449 | : mk_name( $table_name, $index_name || 'i' ); | ||||||||||||||||||||||||||||||||||||||||
| 450 | 1 | $index_name = quote($index_name, $qf); | |||||||||||||||||||||||||||||||||||||||
| 451 | 1 | push @index_defs, | |||||||||||||||||||||||||||||||||||||||
| 452 | "CREATE UNIQUE INDEX $index_name on $table_name_q (". | ||||||||||||||||||||||||||||||||||||||||
| 453 | join( ', ', @fields ). | ||||||||||||||||||||||||||||||||||||||||
| 454 | ")$index_options"; | ||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||
| 456 | else { | ||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | warn "Unknown index type ($index_type) on table $table_name.\n" | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 458 | if $WARN; | ||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||
| 462 | 21 | ▶ | if ( my @table_comments = $table->comments ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | for my $comment ( @table_comments ) { | |||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | next unless $comment; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | $comment = __PACKAGE__->_quote_string($comment); | |||||||||||||||||||||||||||||||||||||||
| 466 | push @field_comments, "COMMENT ON TABLE $table_name_q is\n $comment" | ||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | unless $options->{no_comments}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||
| 471 | 21 | ▶ | my $table_options = @table_options | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 472 | ? "\n".join("\n", @table_options) : ''; | ||||||||||||||||||||||||||||||||||||||||
| 473 | push @create, "CREATE TABLE $table_name_q (\n" . | ||||||||||||||||||||||||||||||||||||||||
| 474 | 110 | ▶ | join( ",\n", map { " $_" } @field_defs, | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 475 | 21 | ($options->{delay_constraints} ? () : @constraint_defs) ) . | |||||||||||||||||||||||||||||||||||||||
| 476 | "\n)$table_options"; | ||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||
| 478 | 21 | @constraint_defs = map { "ALTER TABLE $table_name_q ADD $_" } | |||||||||||||||||||||||||||||||||||||||
| 479 | @constraint_defs; | ||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||
| 481 | 21 | ▶ | if ( $WARN ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ▶ | if ( %truncated ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | warn "Truncated " . keys( %truncated ) . " names:\n"; | |||||||||||||||||||||||||||||||||||||||
| 484 | 0 | warn "\t" . join( "\n\t", sort keys %truncated ) . "\n"; | |||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||
| 488 | 21 | ▶ | return \@create, \@fk_defs, \@trigger_defs, \@index_defs, ($options->{delay_constraints} ? \@constraint_defs : []); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||
| 491 | sub alter_field { | ||||||||||||||||||||||||||||||||||||||||
| 492 | 2 | ▶ | my ($from_field, $to_field, $options) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
alter_field: called CC=5 SCAR=16.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||
| 494 | 2 | my $qt = $options->{quote_table_names}; | |||||||||||||||||||||||||||||||||||||||
| 495 | 2 | my ($field_create, $field_defs, $trigger_defs, $field_comments) = | |||||||||||||||||||||||||||||||||||||||
| 496 | create_field($to_field, $options, {}); | ||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||
| 498 | # Fix ORA-01442 | ||||||||||||||||||||||||||||||||||||||||
| 499 | 2 | ▶ | if ($to_field->is_nullable && !$from_field->is_nullable) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$to_field->is_nullable and not $from_field->is_nullable
MC/DC0%0/2
$to_field->is_nullable and not $from_field->is_nullable
$to_field->is_nullable
not $from_field->is_nullable
Truth table33%1/3
A and not(B)
A= $to_field->is_nullableB= not $from_field->is_nullable
| |||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | die 'Cannot remove NOT NULL from table field'; | |||||||||||||||||||||||||||||||||||||||
| 501 | ▶ | } elsif (!$from_field->is_nullable && !$to_field->is_nullable) { | |||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$from_field->is_nullable || $to_field->is_nullable
MC/DC50%1/2
$from_field->is_nullable || $to_field->is_nullable
$from_field->is_nullable
$to_field->is_nullable
Truth table66%2/3
A || B
A= $from_field->is_nullableB= $to_field->is_nullable
| |||||||||||||||||||||||||||||||||||||||||
| 502 | 1 | @$field_defs = map { s/ NOT NULL//; $_} @$field_defs; | |||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||
| 505 | 2 | my $table_name = quote($to_field->table->name,$qt); | |||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||
| 507 | 2 | return 'ALTER TABLE '.$table_name.' MODIFY ( '.join('', @$field_defs).' )'; | |||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||
| 510 | sub add_field { | ||||||||||||||||||||||||||||||||||||||||
| 511 | 1 | ▶ | my ($new_field, $options) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_field: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||
| 513 | 1 | my $qt = $options->{quote_table_names}; | |||||||||||||||||||||||||||||||||||||||
| 514 | 1 | my ($field_create, $field_defs, $trigger_defs, $field_comments) = | |||||||||||||||||||||||||||||||||||||||
| 515 | create_field($new_field, $options, {}); | ||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||
| 517 | 1 | my $table_name = quote($new_field->table->name,$qt); | |||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||
| 519 | 1 | my $out = sprintf('ALTER TABLE %s ADD ( %s )', | |||||||||||||||||||||||||||||||||||||||
| 520 | $table_name, | ||||||||||||||||||||||||||||||||||||||||
| 521 | join('', @$field_defs)); | ||||||||||||||||||||||||||||||||||||||||
| 522 | 1 | return $out; | |||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||
| 525 | sub create_field { | ||||||||||||||||||||||||||||||||||||||||
| 526 | 87 | ▶ | my ($field, $options, $field_name_scope) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_field: called CC=44 SCAR=41.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 527 | 87 | my $qf = $options->{quote_field_names}; | |||||||||||||||||||||||||||||||||||||||
| 528 | 87 | my $qt = $options->{quote_table_names}; | |||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||
| 530 | 87 | my (@create, @field_defs, @trigger_defs, @field_comments); | |||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||
| 532 | 87 | my $table_name = $field->table->name; | |||||||||||||||||||||||||||||||||||||||
| 533 | 87 | my $table_name_q = quote($table_name, $qt); | |||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||
| 535 | # | ||||||||||||||||||||||||||||||||||||||||
| 536 | # Field name | ||||||||||||||||||||||||||||||||||||||||
| 537 | # | ||||||||||||||||||||||||||||||||||||||||
| 538 | 87 | my $field_name = mk_name( | |||||||||||||||||||||||||||||||||||||||
| 539 | $field->name, '', $field_name_scope, 1 | ||||||||||||||||||||||||||||||||||||||||
| 540 | ); | ||||||||||||||||||||||||||||||||||||||||
| 541 | 87 | my $field_name_q = quote($field_name, $qf); | |||||||||||||||||||||||||||||||||||||||
| 542 | 87 | my $field_def = quote($field_name, $qf); | |||||||||||||||||||||||||||||||||||||||
| 543 | 87 | $field->name( $field_name ); | |||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||
| 545 | # | ||||||||||||||||||||||||||||||||||||||||
| 546 | # Datatype | ||||||||||||||||||||||||||||||||||||||||
| 547 | # | ||||||||||||||||||||||||||||||||||||||||
| 548 | 87 | my $check; | |||||||||||||||||||||||||||||||||||||||
| 549 | 87 | my $data_type = lc $field->data_type; | |||||||||||||||||||||||||||||||||||||||
| 550 | 87 | my @size = $field->size; | |||||||||||||||||||||||||||||||||||||||
| 551 | 87 | my %extra = $field->extra; | |||||||||||||||||||||||||||||||||||||||
| 552 | 87 | ▶ | my $list = $extra{'list'} || []; | ||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$extra{'list'} || []
MC/DC100%1/1
$extra{'list'} || []
$extra{'list'}
Truth table100%2/2
A
A= $extra{'list'}
| |||||||||||||||||||||||||||||||||||||||||
| 553 | 87 | my $commalist = join( ', ', map { __PACKAGE__->_quote_string($_) } @$list ); | |||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||
| 555 | 87 | ▶ | if ( $data_type eq 'enum' ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 556 | 1 | $check = "CHECK ($field_name_q IN ($commalist))"; | |||||||||||||||||||||||||||||||||||||||
| 557 | 1 | $data_type = 'varchar2'; | |||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||
| 559 | elsif ( $data_type eq 'set' ) { | ||||||||||||||||||||||||||||||||||||||||
| 560 | # XXX add a CHECK constraint maybe | ||||||||||||||||||||||||||||||||||||||||
| 561 | # (trickier and slower, than enum :) | ||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | $data_type = 'varchar2'; | |||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||
| 564 | else { | ||||||||||||||||||||||||||||||||||||||||
| 565 | 86 | ▶ | if (defined $translate{ $data_type }) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 566 | 82 | ▶ | if (ref $translate{ $data_type } eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ($data_type,$size[0]) = @{$translate{ $data_type }}; | |||||||||||||||||||||||||||||||||||||||
| 568 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 569 | 82 | $data_type = $translate{ $data_type }; | |||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||
| 572 | 86 | ▶ | $data_type ||= 'varchar2'; | ||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$data_type ||= "varchar2"
MC/DC0%0/1
$data_type ||= "varchar2"
$data_type
Truth table50%1/2
A
A= $data_type
| |||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||
| 575 | # ensure size is not bigger than max size oracle allows for data type | ||||||||||||||||||||||||||||||||||||||||
| 576 | 87 | ▶ | if ( defined $max_size{$data_type} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 577 | 73 | ▶ | for ( my $i = 0 ; $i < scalar @size ; $i++ ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 578 | my $max = | ||||||||||||||||||||||||||||||||||||||||
| 579 | ref( $max_size{$data_type} ) eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||
| 580 | ? $max_size{$data_type}->[$i] | ||||||||||||||||||||||||||||||||||||||||
| 581 | 81 | ▶ | : $max_size{$data_type}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 582 | 81 | ▶ | $size[$i] = $max if $size[$i] > $max; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||
| 586 | # | ||||||||||||||||||||||||||||||||||||||||
| 587 | # Fixes ORA-02329: column of datatype LOB cannot be | ||||||||||||||||||||||||||||||||||||||||
| 588 | # unique or a primary key | ||||||||||||||||||||||||||||||||||||||||
| 589 | # | ||||||||||||||||||||||||||||||||||||||||
| 590 | 87 | ▶ | if ( $data_type eq 'clob' && $field->is_primary_key ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$data_type eq "clob" and $field->is_primary_key
MC/DC100%2/2
$data_type eq "clob" and $field->is_primary_key
$data_type eq "clob"
$field->is_primary_key
Truth table100%3/3
A and B
A= $data_type eq "clob"B= $field->is_primary_key
| |||||||||||||||||||||||||||||||||||||||||
| 591 | 1 | $data_type = 'varchar2'; | |||||||||||||||||||||||||||||||||||||||
| 592 | 1 | $size[0] = 4000; | |||||||||||||||||||||||||||||||||||||||
| 593 | 1 | ▶ | warn "CLOB cannot be a primary key, changing to VARCHAR2\n" | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 594 | if $WARN; | ||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||
| 597 | 87 | ▶ | if ( $data_type eq 'clob' && $field->is_unique ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$data_type eq "clob" and $field->is_unique
MC/DC0%0/2
$data_type eq "clob" and $field->is_unique
$data_type eq "clob"
$field->is_unique
Truth table66%2/3
A and B
A= $data_type eq "clob"B= $field->is_unique
| |||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | $data_type = 'varchar2'; | |||||||||||||||||||||||||||||||||||||||
| 599 | 0 | $size[0] = 4000; | |||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | warn "CLOB cannot be a unique key, changing to VARCHAR2\n" | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 601 | if $WARN; | ||||||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||
| 604 | # | ||||||||||||||||||||||||||||||||||||||||
| 605 | # Fixes ORA-00907: missing right parenthesis | ||||||||||||||||||||||||||||||||||||||||
| 606 | # | ||||||||||||||||||||||||||||||||||||||||
| 607 | 87 | ▶ | if ( $data_type =~ /(date|clob)/i ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 608 | 13 | undef @size; | |||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||
| 611 | # | ||||||||||||||||||||||||||||||||||||||||
| 612 | # Fixes ORA-00906: missing right parenthesis | ||||||||||||||||||||||||||||||||||||||||
| 613 | # if size is 0 or undefined | ||||||||||||||||||||||||||||||||||||||||
| 614 | # | ||||||||||||||||||||||||||||||||||||||||
| 615 | 87 | for (qw/varchar2/) { | |||||||||||||||||||||||||||||||||||||||
| 616 | 87 | ▶ | if ( $data_type =~ /^($_)$/i ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 617 | 38 | ▶ | $size[0] ||= $max_size{$_}; | ||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$size[0] ||= $max_size{$_}
MC/DC0%0/2
$size[0] ||= $max_size{$_}
$size[0]
$max_size{$_}
Truth table66%2/3
A ||= B
A= $size[0]B= $max_size{$_}
| |||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||
| 621 | 87 | $field_def .= " $data_type"; | |||||||||||||||||||||||||||||||||||||||
| 622 | 87 | ▶ | if ( defined $size[0] && $size[0] > 0 ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $size[0] and $size[0] > 0
MC/DC100%2/2
defined $size[0] and $size[0] > 0
defined $size[0]
$size[0] > 0
Truth table100%3/3
A and B
A= defined $size[0]B= $size[0] > 0
| |||||||||||||||||||||||||||||||||||||||||
| 623 | 71 | $field_def .= '(' . join( ',', @size ) . ')'; | |||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||
| 626 | # | ||||||||||||||||||||||||||||||||||||||||
| 627 | # Default value | ||||||||||||||||||||||||||||||||||||||||
| 628 | # | ||||||||||||||||||||||||||||||||||||||||
| 629 | 87 | my $default = $field->default_value; | |||||||||||||||||||||||||||||||||||||||
| 630 | 87 | ▶ | if ( defined $default ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 631 | # | ||||||||||||||||||||||||||||||||||||||||
| 632 | # Wherein we try to catch a string being used as | ||||||||||||||||||||||||||||||||||||||||
| 633 | # a default value for a numerical field. If "true/false," | ||||||||||||||||||||||||||||||||||||||||
| 634 | # then sub "1/0," otherwise just test the truthity of the | ||||||||||||||||||||||||||||||||||||||||
| 635 | # argument and use that (naive?). | ||||||||||||||||||||||||||||||||||||||||
| 636 | # | ||||||||||||||||||||||||||||||||||||||||
| 637 | 35 | ▶ | if (ref $default and defined $$default) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition33%1/3
ref $default and defined $$default
MC/DC0%0/2
ref $default and defined $$default
ref $default
defined $$default
Truth table33%1/3
A and B
A= ref $defaultB= defined $$default
| |||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | $default = $$default; | |||||||||||||||||||||||||||||||||||||||
| 639 | } elsif (ref $default) { | ||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | $default = 'NULL'; | |||||||||||||||||||||||||||||||||||||||
| 641 | ▶ | } elsif ( | |||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
$data_type =~ /^number$/i and not $default =~ /^-?\d+$/ and not $default =~ /null/i
$data_type =~ /^number$/i and not $default =~ /^-?\d+$/
MC/DC66%2/3
$data_type =~ /^number$/i and not $default =~ /^-?\d+$/ and not $default =~ /null/i
$data_type =~ /^number$/i
not $default =~ /^-?\d+$/
not $default =~ /null/i
Truth table75%3/4
A and not(B) and not(C)
A= $data_type =~ /^number$/iB= not $default =~ /^-?\d+$/C= not $default =~ /null/i
| |||||||||||||||||||||||||||||||||||||||||
| 642 | $data_type =~ /^number$/i && | ||||||||||||||||||||||||||||||||||||||||
| 643 | $default !~ /^-?\d+$/ && | ||||||||||||||||||||||||||||||||||||||||
| 644 | $default !~ m/null/i | ||||||||||||||||||||||||||||||||||||||||
| 645 | ) { | ||||||||||||||||||||||||||||||||||||||||
| 646 | 1 | ▶ | if ( $default =~ /^true$/i ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | $default = "'1'"; | |||||||||||||||||||||||||||||||||||||||
| 648 | } elsif ( $default =~ /^false$/i ) { | ||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | $default = "'0'"; | |||||||||||||||||||||||||||||||||||||||
| 650 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 651 | 1 | ▶ | $default = $default ? "'1'" : "'0'"; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||||||||
| 653 | ▶ | } elsif ( | |||||||||||||||||||||||||||||||||||||||
|
Condition16%1/6
$data_type =~ /date/ and $default eq "current_timestamp" || $default eq "now()"
$default eq "current_timestamp" or $default eq "now()"
MC/DC0%0/3
$data_type =~ /date/ and $default eq "current_timestamp" || $default eq "now()"
$data_type =~ /date/
$default eq "current_timestamp"
$default eq "now()"
Truth table25%1/4
A and B or C
A= $data_type =~ /date/B= $default eq "current_timestamp"C= $default eq "now()"
| |||||||||||||||||||||||||||||||||||||||||
| 654 | $data_type =~ /date/ && ( | ||||||||||||||||||||||||||||||||||||||||
| 655 | $default eq 'current_timestamp' | ||||||||||||||||||||||||||||||||||||||||
| 656 | || | ||||||||||||||||||||||||||||||||||||||||
| 657 | $default eq 'now()' | ||||||||||||||||||||||||||||||||||||||||
| 658 | ) | ||||||||||||||||||||||||||||||||||||||||
| 659 | ) { | ||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | $default = 'SYSDATE'; | |||||||||||||||||||||||||||||||||||||||
| 661 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 662 | 34 | ▶ | $default = $default =~ m/null/i ? 'NULL' : __PACKAGE__->_quote_string($default); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||
| 665 | 35 | $field_def .= " DEFAULT $default", | |||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||
| 668 | # | ||||||||||||||||||||||||||||||||||||||||
| 669 | # Not null constraint | ||||||||||||||||||||||||||||||||||||||||
| 670 | # | ||||||||||||||||||||||||||||||||||||||||
| 671 | 87 | ▶ | unless ( $field->is_nullable ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 672 | 35 | $field_def .= ' NOT NULL'; | |||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||
| 675 | 87 | ▶ | $field_def .= " $check" if $check; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||
| 677 | # | ||||||||||||||||||||||||||||||||||||||||
| 678 | # Auto_increment | ||||||||||||||||||||||||||||||||||||||||
| 679 | # | ||||||||||||||||||||||||||||||||||||||||
| 680 | 87 | ▶ | if ( $field->is_auto_increment ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 681 | 15 | my $base_name = $table_name . "_". $field_name; | |||||||||||||||||||||||||||||||||||||||
| 682 | 15 | my $seq_name = quote(mk_name( $base_name, 'sq' ),$qt); | |||||||||||||||||||||||||||||||||||||||
| 683 | 15 | my $trigger_name = quote(mk_name( $base_name, 'ai' ),$qt); | |||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||
| 685 | 15 | ▶ | push @create, qq[DROP SEQUENCE $seq_name] if $options->{add_drop_table}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 686 | 15 | push @create, "CREATE SEQUENCE $seq_name"; | |||||||||||||||||||||||||||||||||||||||
| 687 | 15 | my $trigger = | |||||||||||||||||||||||||||||||||||||||
| 688 | "CREATE OR REPLACE TRIGGER $trigger_name\n" . | ||||||||||||||||||||||||||||||||||||||||
| 689 | "BEFORE INSERT ON $table_name_q\n" . | ||||||||||||||||||||||||||||||||||||||||
| 690 | "FOR EACH ROW WHEN (\n" . | ||||||||||||||||||||||||||||||||||||||||
| 691 | " new.$field_name_q IS NULL". | ||||||||||||||||||||||||||||||||||||||||
| 692 | " OR new.$field_name_q = 0\n". | ||||||||||||||||||||||||||||||||||||||||
| 693 | ")\n". | ||||||||||||||||||||||||||||||||||||||||
| 694 | "BEGIN\n" . | ||||||||||||||||||||||||||||||||||||||||
| 695 | " SELECT $seq_name.nextval\n" . | ||||||||||||||||||||||||||||||||||||||||
| 696 | " INTO :new." . $field_name_q."\n" . | ||||||||||||||||||||||||||||||||||||||||
| 697 | " FROM dual;\n" . | ||||||||||||||||||||||||||||||||||||||||
| 698 | "END;\n"; | ||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||
| 700 | 15 | push @trigger_defs, $trigger; | |||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||
| 703 | 87 | ▶ | if ( lc $field->data_type eq 'timestamp' ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 704 | 6 | my $base_name = $table_name . "_". $field_name; | |||||||||||||||||||||||||||||||||||||||
| 705 | 6 | my $trig_name = quote(mk_name( $base_name, 'ts' ), $qt); | |||||||||||||||||||||||||||||||||||||||
| 706 | 6 | my $trigger = | |||||||||||||||||||||||||||||||||||||||
| 707 | "CREATE OR REPLACE TRIGGER $trig_name\n". | ||||||||||||||||||||||||||||||||||||||||
| 708 | "BEFORE INSERT OR UPDATE ON $table_name_q\n". | ||||||||||||||||||||||||||||||||||||||||
| 709 | "FOR EACH ROW WHEN (new.$field_name_q IS NULL)\n". | ||||||||||||||||||||||||||||||||||||||||
| 710 | "BEGIN\n". | ||||||||||||||||||||||||||||||||||||||||
| 711 | " SELECT sysdate INTO :new.$field_name_q FROM dual;\n". | ||||||||||||||||||||||||||||||||||||||||
| 712 | "END;\n"; | ||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||
| 714 | 6 | push @trigger_defs, $trigger; | |||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||
| 717 | 87 | push @field_defs, $field_def; | |||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||
| 719 | 87 | ▶ | if ( my $comment = $field->comments ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 720 | 5 | $comment =~ __PACKAGE__->_quote_string($comment); | |||||||||||||||||||||||||||||||||||||||
| 721 | push @field_comments, | ||||||||||||||||||||||||||||||||||||||||
| 722 | "COMMENT ON COLUMN $table_name_q.$field_name_q is\n $comment;" | ||||||||||||||||||||||||||||||||||||||||
| 723 | 5 | ▶ | unless $options->{no_comments}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||
| 726 | 87 | return \@create, \@field_defs, \@trigger_defs, \@field_comments; | |||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||
| 731 | sub create_view { | ||||||||||||||||||||||||||||||||||||||||
| 732 | 6 | ▶ | my ($view, $options) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_view: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 733 | 6 | my $qt = $options->{quote_table_names}; | |||||||||||||||||||||||||||||||||||||||
| 734 | 6 | my $view_name = quote($view->name,$qt); | |||||||||||||||||||||||||||||||||||||||
| 735 | 6 | my $extra = $view->extra; | |||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||
| 737 | 6 | my $view_type = 'VIEW'; | |||||||||||||||||||||||||||||||||||||||
| 738 | 6 | my $view_options = ''; | |||||||||||||||||||||||||||||||||||||||
| 739 | 6 | ▶ | if ( my $materialized = $extra->{materialized} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 740 | 1 | $view_type = 'MATERIALIZED VIEW'; | |||||||||||||||||||||||||||||||||||||||
| 741 | 1 | $view_options .= ' '.$materialized; | |||||||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||
| 744 | 6 | my @create; | |||||||||||||||||||||||||||||||||||||||
| 745 | push @create, qq[DROP $view_type $view_name] | ||||||||||||||||||||||||||||||||||||||||
| 746 | 6 | ▶ | if $options->{add_drop_view}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||
| 748 | 6 | push @create, sprintf("CREATE %s %s%s AS\n%s", | |||||||||||||||||||||||||||||||||||||||
| 749 | $view_type, | ||||||||||||||||||||||||||||||||||||||||
| 750 | $view_name, | ||||||||||||||||||||||||||||||||||||||||
| 751 | $view_options, | ||||||||||||||||||||||||||||||||||||||||
| 752 | $view->sql); | ||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||
| 754 | 6 | return \@create; | |||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||
| 757 | sub mk_name { | ||||||||||||||||||||||||||||||||||||||||
| 758 | 153 | ▶ | my $basename = shift || ''; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_name: called CC=17 SCAR=30.0
Pod
undocumented
Condition50%1/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||
| 759 | 153 | ▶ | my $type = shift || ''; | ||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || ''
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||
| 760 | 153 | ▶ | $type = '' if $type =~ /^\d/; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 761 | 153 | ▶ | my $scope = shift || ''; | ||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || ''
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||
| 762 | 153 | ▶ | my $critical = shift || ''; | ||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || ''
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||
| 763 | 153 | my $basename_orig = $basename; | |||||||||||||||||||||||||||||||||||||||
| 764 | 153 | ▶ | my $max_name = $type | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 765 | ? $max_id_length - (length($type) + 1) | ||||||||||||||||||||||||||||||||||||||||
| 766 | : $max_id_length; | ||||||||||||||||||||||||||||||||||||||||
| 767 | 153 | ▶ | $basename = substr( $basename, 0, $max_name ) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 768 | if length( $basename ) > $max_name; | ||||||||||||||||||||||||||||||||||||||||
| 769 | 153 | ▶ | my $name = $type ? "${type}_$basename" : $basename; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||
| 771 | 153 | ▶ | if ( $basename ne $basename_orig and $critical ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$basename ne $basename_orig and $critical
MC/DC0%0/2
$basename ne $basename_orig and $critical
$basename ne $basename_orig
$critical
Truth table66%2/3
A and B
A= $basename ne $basename_origB= $critical
| |||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | ▶ | my $show_type = $type ? "+'$type'" : ""; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | ▶ | warn "Truncating '$basename_orig'$show_type to $max_id_length ", | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 774 | "character limit to make '$name'\n" if $WARN; | ||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | $truncated{ $basename_orig } = $name; | |||||||||||||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||
| 778 | 153 | ▶ | $scope ||= \%global_names; | ||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$scope ||= \%global_names
MC/DC100%1/1
$scope ||= \%global_names
$scope
Truth table100%2/2
A
A= $scope
| |||||||||||||||||||||||||||||||||||||||||
| 779 | 153 | ▶ | if ( my $prev = $scope->{ $name } ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 780 | 20 | my $name_orig = $name; | |||||||||||||||||||||||||||||||||||||||
| 781 | 20 | ▶ | substr($name, $max_id_length - 2) = "" | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 782 | if length( $name ) >= $max_id_length - 1; | ||||||||||||||||||||||||||||||||||||||||
| 783 | 20 | $name .= sprintf( "%02d", $prev++ ); | |||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||
| 785 | 20 | ▶ | warn "The name '$name_orig' has been changed to ", | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 786 | "'$name' to make it unique.\n" if $WARN; | ||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||
| 788 | 20 | $scope->{ $name_orig }++; | |||||||||||||||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||
| 791 | 153 | $scope->{ $name }++; | |||||||||||||||||||||||||||||||||||||||
| 792 | 153 | return $name; | |||||||||||||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||
| 795 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||
| 797 | sub quote { | ||||||||||||||||||||||||||||||||||||||||
| 798 | 436 | ▶ | my ($name, $q) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
quote: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 799 | 436 | ▶ | return $name unless $q && $name; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$q and $name
MC/DC100%2/2
$q and $name
$q
$name
Truth table100%3/3
A and B
A= $qB= $name
| |||||||||||||||||||||||||||||||||||||||||
| 800 | 253 | $name =~ s/\Q$quote_char/$quote_char$quote_char/g; | |||||||||||||||||||||||||||||||||||||||
| 801 | 253 | return "$quote_char$name$quote_char"; | |||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||
| 805 | # ------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||
| 806 | # All bad art is the result of good intentions. | ||||||||||||||||||||||||||||||||||||||||
| 807 | # Oscar Wilde | ||||||||||||||||||||||||||||||||||||||||
| 808 | # ------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||
| 810 | =pod | ||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||
| 812 | =head1 CREDITS | ||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||
| 814 | Mad props to Tim Bunce for much of the logic stolen from his "mysql2ora" | ||||||||||||||||||||||||||||||||||||||||
| 815 | script. | ||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||
| 817 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||
| 819 | Ken Youens-Clark E<lt>kclark@cpan.orgE<gt>, | ||||||||||||||||||||||||||||||||||||||||
| 820 | Alexander Hartmaier E<lt>abraxxa@cpan.orgE<gt>, | ||||||||||||||||||||||||||||||||||||||||
| 821 | Fabien Wernli E<lt>faxmodem@cpan.orgE<gt>. | ||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||
| 823 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||
| 825 | SQL::Translator, DDL::Oracle, mysql2ora. | ||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||
| 827 | =cut | ||||||||||||||||||||||||||||||||||||||||