File Coverage

blib/lib/DBD/cubrid.pm
Criterion Covered Total %
statement 68 242 28.1
branch 13 142 9.1
condition 1 75 1.3
subroutine 11 20 55.0
pod 0 1 0.0
total 93 480 19.3


line stmt bran cond sub pod time code
1             # cubrid.pm
2             #
3             # Copyright (C) 2008 Search Solution Corporation. All rights reserved by Search Solution.
4             #
5             # Redistribution and use in source and binary forms, with or without modification,
6             # are permitted provided that the following conditions are met:
7             #
8             # - Redistributions of source code must retain the above copyright notice,
9             # this list of conditions and the following disclaimer.
10             #
11             # - Redistributions in binary form must reproduce the above copyright notice,
12             # this list of conditions and the following disclaimer in the documentation
13             # and/or other materials provided with the distribution.
14             #
15             # - Neither the name of the nor the names of its contributors
16             # may be used to endorse or promote products derived from this software without
17             # specific prior written permission.
18             #
19             # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20             # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21             # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22             # IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23             # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24             # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
25             # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26             # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27             # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
28             # OF SUCH DAMAGE.
29             #
30              
31 26     26   125474 use 5.008;
  26         93  
  26         1158  
32 26     26   139 use warnings;
  26         52  
  26         915  
33 26     26   127 use strict;
  26         53  
  26         978  
34              
35             { package DBD::cubrid;
36              
37 26     26   133 use DBI ();
  26         46  
  26         449  
38 26     26   123 use DynaLoader ();
  26         61  
  26         651  
39 26     26   124 use vars qw(@ISA $VERSION $err $errstr $sqlstate $drh $dbh);
  26         40  
  26         9714  
40             @ISA = qw(DynaLoader);
41              
42             require_version DBI 1.61;
43              
44             $VERSION = '9.3.0.0001';
45              
46             bootstrap DBD::cubrid $VERSION;
47              
48             $drh = undef; # holds driver handle once initialized
49             $err = 0; # holds error code for DBI::err
50             $errstr = ''; # holds error string for DBI::errstr
51             $sqlstate = ''; # holds five character SQLSTATE code
52              
53             sub driver {
54 26 50   26 0 7101 return $drh if $drh;
55              
56 26         71 my($class, $attr) = @_;
57              
58 26         69 $class .= "::dr";
59              
60 26         296 $drh = DBI::_new_drh ($class, {
61             'Name' => 'cubrid',
62             'Version' => $VERSION,
63             'Err' => \$DBD::cubrid::err,
64             'Errstr' => \$DBD::cubrid::errstr,
65             'Attribution' => 'DBD::cubrid by Zhang Hui'
66             });
67              
68 26         1657 DBD::cubrid::st->install_method ('cubrid_lob_get');
69 26         1510 DBD::cubrid::st->install_method ('cubrid_lob_export');
70 26         830 DBD::cubrid::st->install_method ('cubrid_lob_import');
71 26         815 DBD::cubrid::st->install_method ('cubrid_lob_close');
72              
73 26         836 $drh
74             }
75             }
76              
77             { package DBD::cubrid::dr; # ====== DRIVER ======
78 26     26   160 use strict;
  26         220  
  26         41618  
79            
80             sub connect {
81              
82 26     26   1570 my ($drh, $dsn, $user, $passwd, $attrhash) = @_;
83 26         60 my %connect_attr;
84              
85 26 50       163 if ($dsn =~ /=/) {
86 26         67 my ($n,$v);
87 26         87 $dsn =~ s/^\s+//;
88 26         85 $dsn =~ s/\s+$//;
89 26         57 $dsn =~ s/^DBI:cubrid://;
90 26         62 $dsn =~ s/^dbi:cubrid://;
91 79         949 my @dsn = map {
92 26         281 ($n,$v) = split /\s*=\s*/, $_, -1;
93 79 50 33     548 Carp::carp("DSN component '$_' is not in 'name=value' format")
94             unless defined $v && defined $n;
95 79         289 (uc($n), $v)
96             } split /\s*;\s*/, $dsn;
97 26         126 my %dsn = @dsn;
98 26         135 foreach (%dsn) {
99 158         396 $connect_attr{$_} = $dsn{$_};
100             }
101             }
102             else {
103 0         0 Carp::carp("DSN $dsn is not in 'name=value' format");
104             }
105              
106 26 50       104 $user = 'public' if not defined $user;
107              
108 26         48 my ($host, $port, $dbname);
109              
110 26 50       99 if ($connect_attr{HOST}) {
111 26         62 $host = $connect_attr{HOST};
112             } else {
113 0         0 $host = 'localhost';
114             }
115              
116 26 50       78 if ($connect_attr{PORT}) {
117 26         62 $port = $connect_attr{PORT};
118             } else {
119 0         0 $port = 33000;
120             }
121              
122 26 50       79 if ($connect_attr{DATABASE}) {
123 26         56 $dbname = $connect_attr{DATABASE};
124             } else {
125 0         0 $dbname = '';
126             }
127              
128 26         127 my $connect_dsn = "cci:cubrid:$host:$port:$dbname" . ':::';
129 26         59 my $is_connect_attr = 0;
130              
131 26 50       141 if ($connect_attr{ALTHOSTS}) {
132 0         0 $connect_dsn .= "?alhosts=$connect_attr{ALTHOSTS}";
133 0         0 $is_connect_attr = 1;
134             }
135              
136 26 50       103 if ($connect_attr{RCTIME}) {
137 0 0       0 if ($is_connect_attr) {
138 0         0 $connect_dsn .= "&rctime=$connect_attr{RCTIME}";
139             } else {
140 0         0 $connect_dsn .= "?rctime=$connect_attr{RCTIME}";
141 0         0 $is_connect_attr = 1;
142             }
143             }
144              
145 26 50       103 if ($connect_attr{LOGIN_TIMEOUT}) {
146 0 0       0 if ($is_connect_attr) {
147 0         0 $connect_dsn .= "&login_timeout=$connect_attr{LOGIN_TIMEOUT}";
148             } else {
149 0         0 $connect_dsn .= "?login_timeout=$connect_attr{LOGIN_TIMEOUT}";
150 0         0 $is_connect_attr = 1;
151             }
152             }
153              
154 26 50       122 if ($connect_attr{QUERY_TIMEOUT}) {
155 0 0       0 if ($is_connect_attr) {
156 0         0 $connect_dsn .= "&query_timeout=$connect_attr{QUERY_TIMEOUT}";
157             } else {
158 0         0 $connect_dsn .= "?query_timeout=$connect_attr{QUERY_TIMEOUT}";
159 0         0 $is_connect_attr = 1;
160             }
161             }
162              
163 26 50       103 if ($connect_attr{DISCONNECT_ON_QUERY_TIMEOUT}) {
164 0 0       0 if ($is_connect_attr) {
165 0         0 $connect_dsn .= "&disconnect_on_query_timeout=$connect_attr{DISCONNECT_ON_QUERY_TIMEOUT}";
166             } else {
167 0         0 $connect_dsn .= "?disconnect_on_query_timeout=$connect_attr{DISCONNECT_ON_QUERY_TIMEOUT}";
168 0         0 $is_connect_attr = 1;
169             }
170             }
171              
172 26         217 my ($dbh) = DBI::_new_dbh ($drh, {
173             'Name' => $dbname,
174             'User' => $user,
175             });
176              
177 26 50       201282 DBD::cubrid::db::_login($dbh, $connect_dsn, $user, $passwd, $attrhash) or return undef;
178              
179 0           $dbh
180             }
181              
182             } # end the package of DBD::cubrid::dr
183              
184              
185             { package DBD::cubrid::db; # ====== DATABASE ======
186 26     26   165 use strict;
  26         62  
  26         928  
187 26     26   135 use DBI qw(:sql_types);
  26         58  
  26         118744  
188              
189             sub prepare {
190              
191 0     0     my ($dbh, $statement, @attribs) = @_;
192              
193 0 0         return undef if ! defined $statement;
194              
195 0           my $sth = DBI::_new_sth ($dbh, {
196             'Statement' => $statement,
197             });
198              
199 0 0         DBD::cubrid::st::_prepare($sth, $statement, @attribs) or return undef;
200              
201 0           $sth
202             }
203              
204             sub ping {
205 0     0     my $dbh = shift;
206 0 0   0     local $SIG{__WARN__} = sub { } if $dbh->FETCH('PrintError');
  0            
207 0           my $ret = DBD::cubrid::db::_ping($dbh);
208 0 0         return $ret ? 1 : 0;
209             }
210              
211             sub get_info {
212 0     0     my ($dbh, $info_type) = @_;
213 0           require DBD::cubrid::GetInfo;
214 0           my $v = $DBD::cubrid::GetInfo::info{int($info_type)};
215 0 0         $v = $v->($dbh) if ref $v eq 'CODE';
216 0           return $v;
217             }
218              
219             sub table_info {
220 0     0     my ($dbh, $catalog, $schema, $table, $type, $attr) = @_;
221              
222 0           my @names = qw(TABLE_CAT TABLE_SCHEM TABLE_NAME TABLE_TYPE REMARKS);
223 0           my @rows;
224              
225 0 0         my $sponge = DBI->connect("DBI:Sponge:", '','')
226             or return $dbh->DBI::set_err($DBI::err, "DBI::Sponge: $DBI::errstr");
227              
228 0 0 0       if ((defined $catalog && $catalog eq "%") &&
    0 0        
    0 0        
      0        
      0        
      0        
      0        
      0        
      0        
      0        
      0        
      0        
      0        
      0        
      0        
      0        
      0        
229             (!defined($schema) || $schema eq "") &&
230             (!defined($table) || $table eq ""))
231             {
232 0           @rows = (); # Empty, because CUBRID doesn't support catalogs (yet)
233             }
234             elsif ((defined $schema && $schema eq "%") &&
235             (!defined($catalog) || $catalog eq "") &&
236             (!defined($table) || $table eq ""))
237             {
238 0           @rows = (); # Empty, because CUBRID doesn't support schemas (yet)
239             }
240             elsif ((defined $type && $type eq "%") &&
241             (!defined($catalog) || $catalog eq "") &&
242             (!defined($schema) || $schema eq "") &&
243             (!defined($table) || $table eq ""))
244             {
245 0           @rows = (
246             [ undef, undef, undef, "TABLE", undef ],
247             [ undef, undef, undef, "VIEW", undef ],
248             );
249             }
250             else
251             {
252 0 0         $table = '%' unless defined $table;
253            
254 0           my ($want_tables, $want_views);
255 0 0 0       if (defined $type && $type ne "") {
256 0 0 0       if (($type =~ m/^table$/i) || ($type =~ m/^view$/i) || ($type =~ /^'table','view'$/i)) {
      0        
257 0           $want_tables = ($type =~ m/table/i);
258 0           $want_views = ($type =~ m/view/i);
259             }
260             else {
261 0           Carp::carp ("\$type must be TABLE, VIEW or 'TABELE','VIEW'");
262             }
263             }
264             else {
265 0           $want_tables = $want_views = 1;
266             }
267              
268 0           my $sql = "SELECT class_name, class_type FROM db_class where class_name like " . $dbh->quote($table);
269 0 0         my $sth = $dbh->prepare ($sql) or return undef;
270 0 0         $sth->execute or return DBI::set_err($dbh, $sth->err(), $sth->errstr());
271              
272 0           while (my $ref = $sth->fetchrow_arrayref()) {
273 0 0 0       my $type = (defined $ref->[1] &&
274             $ref->[1] =~ /VCLASS/i) ? 'VIEW' : 'TABLE';
275 0 0 0       next if $type eq 'TABLE' && not $want_tables;
276 0 0 0       next if $type eq 'VIEW' && not $want_views;
277 0           push @rows, [ undef, undef, $ref->[0], $type, undef ];
278             }
279             }
280              
281 0 0         my $sth = $sponge->prepare("table_info",
282             {
283             rows => \@rows,
284             NUM_OF_FIELDS => scalar @names,
285             NAME => \@names,
286             }
287             ) or return $dbh->DBI::set_err($sponge->err(), $sponge->errstr());
288              
289 0           return $sth;
290             }
291              
292             sub column_info {
293 0     0     my $dbh = shift;
294 0           my ($catalog, $schema, $table, $column) = @_;
295              
296             # ODBC allows a NULL to mean all columns, so we'll accept undef
297 0 0         $column = '%' unless defined $column;
298              
299 0           my $table_id = $dbh->quote_identifier($table);
300              
301 0           my @names = qw(
302             TABLE_CAT TABLE_SCHEM TABLE_NAME COLUMN_NAME DATA_TYPE TYPE_NAME COLUMN_SIZE
303             BUFFER_LENGTH DECIMAL_DIGITS NUM_PREC_RADIX NULLABLE REMARKS COLUMN_DEF
304             SQL_DATA_TYPE SQL_DATETIME_SUB CHAR_OCTET_LENGTH ORDINAL_POSITION IS_NULLABLE
305             CHAR_SET_CAT CHAR_SET_SCHEM CHAR_SET_NAME COLLATION_CAT COLLATION_SCHEM
306             COLLATION_NAME UDT_CAT UDT_SCHEM UDT_NAME DOMAIN_CAT DOMAIN_SCHEM DOMAIN_NAME
307             SCOPE_CAT SCOPE_SCHEM SCOPE_NAME MAX_CARDINALITY DTD_IDENTIFIER IS_SELF_REF
308             );
309              
310 0           my @col_info;
311              
312 0           local $dbh->{FetchHashKeyName} = 'NAME_lc';
313 0           my $desc_sth = $dbh->prepare("SHOW COLUMNS FROM $table_id LIKE " . $dbh->quote($column));
314 0           my $desc = $dbh->selectall_arrayref($desc_sth, { Columns=>{} });
315              
316 0           my $ordinal_pos = 0;
317 0           for my $row (@$desc) {
318              
319 0           my $type = $row->{type};
320 0 0         if (!defined($type)) {
321 0           $type = "NULL";
322             }
323              
324 0 0         my $info = {
    0          
325             TABLE_CAT => $catalog,
326             TABLE_SCHEM => $schema,
327             TABLE_NAME => $table,
328             COLUMN_NAME => $row->{field},
329             NULLABLE => ($row->{null} eq 'YES') ? 1 : 0,
330             IS_NULLABLE => ($row->{null} eq 'YES') ? "YES" : "NO",
331             TYPE_NAME => uc($type),
332             COLUMN_DEF => $row->{default},
333             ORDINAL_POSITION => ++$ordinal_pos,
334             };
335              
336 0 0         if ($type =~ /CHAR/) {
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
337 0           $info->{DATA_TYPE} = SQL_VARCHAR;
338 0 0         $info->{DATA_TYPE} = SQL_CHAR if $type =~ /^CHAR/;
339              
340 0 0         if ($type =~ /\(/) {
341 0           my @tmp = split /\(/, $type;
342 0           my @tmp1 = split /\)/, $tmp[1];
343 0           $info->{COLUMN_SIZE} = $tmp1[0];
344             }
345             else {
346 0           $info->{COLUMN_SIZE} = 1073741823;
347             }
348             }
349             elsif ($type =~ /STRING/) {
350 0           $info->{DATA_TYPE} = SQL_VARCHAR;
351              
352 0 0         if ($type =~ /\(/) {
353 0           my @tmp = split /\(/, $type;
354 0           my @tmp1 = split /\)/, $tmp[1];
355 0           $info->{COLUMN_SIZE} = $tmp1[0];
356             }
357             else {
358 0           $info->{COLUMN_SIZE} = 1073741823;
359             }
360             }
361             elsif ($type =~ /INT/) {
362 0           $info->{NUM_PREC_RADIX} = 10;
363 0 0         if ($type =~ /BIGINT/) {
    0          
364 0           $info->{DATA_TYPE} = SQL_BIGINT;
365 0           $info->{COLUMN_SIZE} = 19;
366             }
367             elsif ($type =~ /SMALLINT/) {
368 0           $info->{DATA_TYPE} = SQL_SMALLINT;
369 0           $info->{COLUMN_SIZE} = 5;
370             }
371             else {
372 0           $info->{DATA_TYPE} = SQL_INTEGER;
373 0           $info->{COLUMN_SIZE} = 10;
374             }
375             }
376             elsif ($type =~ /SHORT/) {
377 0           $info->{DATA_TYPE} = SQL_SMALLINT;
378 0           $info->{COLUMN_SIZE} = 5;
379 0           $info->{NUM_PREC_RADIX} = 10;
380             }
381             elsif ($type =~ /NUMERIC/) {
382 0           $info->{DATA_TYPE} = SQL_NUMERIC;
383 0           $info->{COLUMN_SIZE} = 38;
384 0 0         if ($type =~ /\(/) {
385 0           my @tmp = split /\(/, $type;
386 0           my @tmp1 = split /\)/, $tmp[1];
387 0           my @tmp2 = split /,/, $tmp1[0];
388 0           $info->{DECIMAL_DIGITS} = $tmp2[1];
389 0           $info->{NUM_PREC_RADIX} = $tmp2[0];
390             }
391             else {
392 0           $info->{DECIMAL_DIGITS} = 15;
393 0           $info->{NUM_PREC_RADIX} = 10;
394             }
395             }
396             elsif ($type =~ /MONETARY/) {
397 0           $info->{DATA_TYPE} = SQL_FLOAT;
398 0           $info->{COLUMN_SIZE} = 14;
399 0           $info->{DECIMAL_DIGITS} = 2;
400             }
401             elsif ($type =~ /BLOB/) {
402 0           $info->{DATA_TYPE} = SQL_BLOB;
403 0           $info->{COLUMN_SIZE} = 0;
404             }
405             elsif ($type =~ /CLOB/) {
406 0           $info->{DATA_TYPE} = SQL_CLOB;
407 0           $info->{COLUMN_SIZE} = 0;
408             }
409             elsif ($type =~ /FLOAT/) {
410 0           $info->{DATA_TYPE} = SQL_FLOAT;
411 0           $info->{COLUMN_SIZE} = 14;
412 0           $info->{NUM_PREC_RADIX} = 10;
413             }
414             elsif ($type=~ /DOUBLE/) {
415 0           $info->{DATA_TYPE} = SQL_DOUBLE;
416 0           $info->{COLUMN_SIZE} = 28;
417 0           $info->{NUM_PREC_RADIX} = 10;
418             }
419             elsif ($type =~ /TIME/) {
420 0 0         if ($type =~ /TIMESTAMP|DATETIME/) {
421 0           $info->{DATA_TYPE} = SQL_TYPE_TIMESTAMP;
422 0 0         $info->{COLUMN_SIZE} = 19 if $type =~ /^TIMESTAMP/;
423 0 0         $info->{COLUMN_SIZE} = 23 if $type =~ /^DATETIME/;
424             }
425             else {
426 0           $info->{DATA_TYPE} = SQL_TYPE_TIME;
427 0           $info->{COLUMN_SIZE} = 8;
428             }
429             }
430             elsif ($type =~ /DATE/) {
431 0 0         if ($type =~ /DATETIME/) {
432 0           $info->{DATA_TYPE} = SQL_TYPE_TIMESTAMP;
433 0           $info->{COLUMN_SIZE} = 23;
434             }
435             else {
436 0           $info->{DATA_TYPE} = SQL_TYPE_DATE;
437 0           $info->{COLUMN_SIZE} = 10;
438             }
439             }
440             elsif ($type =~ /BIT/) {
441 0 0         if ($type =~ /VARYING/) {
442 0           $info->{DATA_TYPE} = SQL_VARBINARY;
443             }
444             else {
445 0           $info->{DATA_TYPE} = SQL_BINARY;
446             }
447              
448 0 0         if ($type =~ /\(/) {
449 0           my @tmp = split /\(/, $type;
450 0           my @tmp1 = split /\)/, $tmp[1];
451 0           $info->{COLUMN_SIZE} = $tmp1[0];
452             }
453             else {
454 0           $info->{COLUMN_SIZE} = 1073741823;
455             }
456             }
457             elsif ($type =~ /^NULL$/) {
458 0           $info->{DATA_TYPE} = SQL_UNKNOWN_TYPE;
459             }
460             else {
461 0           $info->{DATA_TYPE} = SQL_VARCHAR;
462             }
463              
464 0   0       $info->{SQL_DATA_TYPE} ||= $info->{DATA_TYPE};
465              
466 0           push @col_info, [
467             $info->{TABLE_CAT},
468             $info->{TABLE_SCHEM},
469             $info->{TABLE_NAME},
470             $info->{COLUMN_NAME},
471             $info->{DATA_TYPE},
472             $info->{TYPE_NAME},
473             $info->{COLUMN_SIZE},
474             $info->{BUFFER_LENGTH},
475             $info->{DECIMAL_DIGITS},
476             $info->{NUM_PREC_RADIX},
477             $info->{NULLABLE},
478             $info->{REMARKS},
479             $info->{COLUMN_DEF},
480             $info->{SQL_DATA_TYPE},
481             $info->{SQL_DATETIME_SUB},
482             $info->{CHAR_OCTET_LENGTH},
483             $info->{ORDINAL_POSITION},
484             $info->{IS_NULLABLE},
485             $info->{CHAR_SET_CAT},
486             $info->{CHAR_SET_SCHEM},
487             $info->{CHAR_SET_NAME},
488             $info->{COLLATION_CAT},
489             $info->{COLLATION_SCHEM},
490             $info->{COLLATION_NAME},
491             $info->{UDT_CAT},
492             $info->{UDT_SCHEM},
493             $info->{UDT_NAME},
494             $info->{DOMAIN_CAT},
495             $info->{DOMAIN_SCHEM},
496             $info->{DOMAIN_NAME},
497             $info->{SCOPE_CAT},
498             $info->{SCOPE_SCHEM},
499             $info->{SCOPE_NAME},
500             $info->{MAX_CARDINALITY},
501             $info->{DTD_IDENTIFIER},
502             $info->{IS_SELF_REF}
503             ];
504             }
505              
506 0 0         my $sponge = DBI->connect("DBI:Sponge:", '','')
507             or return $dbh->DBI::set_err($DBI::err, "DBI::Sponge: $DBI::errstr");
508            
509 0 0         my $sth = $sponge->prepare("column_info $table_id", {
510             rows => \@col_info,
511             NUM_OF_FIELDS => scalar @names,
512             NAME => \@names,
513             }) or return $dbh->DBI::set_err($sponge->err(), $sponge->errstr());
514              
515 0           return $sth;
516             }
517              
518             sub primary_key_info {
519 0     0     my ($dbh, $catalog, $schema, $table) = @_;
520              
521 0           my @names = qw(
522             TABLE_CAT TABLE_SCHEM TABLE_NAME COLUMN_NAME KEY_SEQ PK_NAME
523             );
524              
525 0           my @col_info;
526              
527 0           my $desc = DBD::cubrid::db::_primary_key_info ($dbh, $table);
528 0           for my $row (@$desc) {
529 0           push @col_info, [
530             $catalog,
531             $schema,
532             $row->[0],
533             $row->[1],
534             $row->[2],
535             $row->[3],
536             ];
537             }
538              
539 0 0         my $sponge = DBI->connect ("DBI:Sponge:", '','')
540             or return $dbh->DBI::set_err ($DBI::err, "DBI::Sponge: $DBI::errstr");
541 0 0         my $sth= $sponge->prepare ("primary_key_info $table", {
542             rows => \@col_info,
543             NUM_OF_FIELDS => scalar @names,
544             NAME => \@names,
545             }) or return $dbh->DBI::set_err($sponge->err(), $sponge->errstr());
546              
547 0           return $sth;
548             }
549              
550             sub foreign_key_info {
551 0     0     my ($dbh,
552             $pk_catalog, $pk_schema, $pk_table,
553             $fk_catalog, $fk_schema, $fk_table,
554             ) = @_;
555              
556 0           my @names = qw(
557             PKTABLE_CAT PKTABLE_SCHEM PKTABLE_NAME PKCOLUMN_NAME
558             FKTABLE_CAT FKTABLE_SCHEM FKTABLE_NAME FKCOLUMN_NAME
559             KEY_SEQ UPDATE_RULE DELETE_RULE FK_NAME PK_NAME DEFERRABILITY
560             );
561              
562 0           my @col_info;
563              
564 0           my $desc = DBD::cubrid::db::_foreign_key_info ($dbh, $pk_table, $fk_table);
565 0           for my $row (@$desc) {
566 0           push @col_info, [
567             $pk_catalog,
568             $pk_schema,
569             $row->[0],
570             $row->[1],
571             $fk_catalog,
572             $fk_schema,
573             $row->[2],
574             $row->[3],
575             $row->[4],
576             $row->[5],
577             $row->[6],
578             $row->[7],
579             $row->[8],
580             undef
581             ];
582             }
583              
584 0 0         my $sponge = DBI->connect ("DBI:Sponge:", '','')
585             or return $dbh->DBI::set_err ($DBI::err, "DBI::Sponge: $DBI::errstr");
586 0 0         my $sth= $sponge->prepare ("foreign_key_info", {
587             rows => \@col_info,
588             NUM_OF_FIELDS => scalar @names,
589             NAME => \@names,
590             }) or return $dbh->DBI::set_err($sponge->err(), $sponge->errstr());
591              
592 0           return $sth;
593             }
594              
595             sub type_info_all {
596 0     0     my ($dbh) = @_;
597              
598 0           my $type_info_all = [
599             {
600             TYPE_NAME => 0,
601             DATA_TYPE => 1,
602             COLUMN_SIZE => 2,
603             LITERAL_PREFIX => 3,
604             LITERAL_SUFFIX => 4,
605             CREATE_PARAMS => 5,
606             NULLABLE => 6,
607             CASE_SENSITIVE => 7,
608             SEARCHABLE => 8,
609             UNSIGNED_ATTRIBUTE => 9,
610             FIXED_PREC_SCALE => 10,
611             AUTO_UNIQUE_VALUE => 11,
612             LOCAL_TYPE_NAME => 12,
613             MINIMUM_SCALE => 13,
614             MAXIMUM_SCALE => 14,
615             SQL_DATA_TYPE => 15,
616             SQL_DATETIME_SUB => 16,
617             NUM_PREC_RADIX => 17,
618             INTERVAL_PRECISION => 18,
619             },
620             ["CHAR", SQL_CHAR, 1073741823, q{'}, q{'}, "length",
621             1, 0, 3, -1, 0, 0, "CHAR", -1, -1, SQL_CHAR, -1, -1, -1],
622             ["VARCHAR", SQL_VARCHAR, 1073741823, q{'}, q{'}, "length",
623             1, 0, 3, -1, 0, 0, "CHAR VARYING", -1, -1, SQL_VARCHAR, -1, -1, -1],
624             ["BIT", SQL_BINARY, 1073741823 / 8, q{X'}, q{'}, "length",
625             1, 0, 3, -1, 0, 0, "BIT", -1, -1, SQL_BINARY, -1, -1, -1],
626             ["BIT VARYING", SQL_VARBINARY, 1073741823 / 8, q{X'}, q{'}, "length",
627             1, 0, 3, -1, 0, 0, "BIT VARYING", -1, -1, SQL_VARBINARY, -1, -1, -1],
628             ["NUMERIC", SQL_NUMERIC, 38, undef, undef, "precision, scale",
629             1, 0, 2, 0, 0, 0, "NUMERIC", 0, 38, SQL_NUMERIC, -1, 10, -1],
630             ["DECIMAL", SQL_DECIMAL, 38, undef, undef, "precision, scale",
631             1, 0, 2, 0, 0, 0, "DECIMAL", 0, 38, SQL_DECIMAL, -1, 10, -1],
632             ["INTEGER", SQL_INTEGER, 10, undef, undef, undef,
633             1, 0, 2, 0, 0, 0, "INTEGER", -1, -1, SQL_INTEGER, -1, 10, -1],
634             ["SMALLINT", SQL_SMALLINT, 5, undef, undef, undef,
635             1, 0, 2, 0, 0, 0, "SMALLINT", -1, -1, SQL_SMALLINT, -1, 10, -1],
636             ["REAL", SQL_REAL, 14, undef, undef, "precision",
637             1, 0, 2, 0, 0, 0, "REAL", -1, -1, SQL_REAL, -1, 10, -1],
638             ["FLOAT", SQL_FLOAT, 14, undef, undef, "precision",
639             1, 0, 2, 0, 0, 0, "FLOAT", -1, -1, SQL_FLOAT, -1, 10, -1],
640             ["DOUBLE", SQL_DOUBLE, 28, undef, undef, "precision",
641             1, 0, 2, 0, 0, 0, "DOUBLE", -1, -1, SQL_DOUBLE, -1, 10, -1],
642             ["DATE", SQL_TYPE_DATE, 10, q{DATE '}, q{'}, undef,
643             1, 0, 2, 0, 0, 0, "DATE", -1, -1, SQL_DATETIME, 1, -1, -1],
644             ["TIME", SQL_TYPE_TIME, 8, q{TIME '}, q{'}, undef,
645             1, 0, 2, 0, 0, 0, "TIME", -1, -1, SQL_DATETIME, 2, -1, -1],
646             ["TIMESTAMP", SQL_TYPE_TIMESTAMP, 19, q{TIMESTAMP '}, q{'}, undef,
647             1, 0, 2, 0, 0, 0, "TIMESTAMP", -1, -1, SQL_DATETIME, 3, -1, -1],
648             ["BIGINT", SQL_BIGINT, 19, undef, undef, undef,
649             1, 0, 2, 0, 0, 0, "BIGINT", -1, -1, SQL_INTEGER, -1, 10, -1],
650             ["DATETIME", SQL_TYPE_TIMESTAMP, 23, q{DATETIME '}, q{'}, undef,
651             1, 0, 2, 0, 0, 0, "DATETIME", -1, -1, SQL_DATETIME, 3, -1, -1],
652             ["ENUM", SQL_VARCHAR, 0, undef, undef, undef,
653             1, 0, 3, 0, 0, 0, "ENUM", -1, -1, SQL_VARCHAR, -1, -1, -1],
654             ["BLOB", SQL_BLOB, 0, undef, undef, undef,
655             1, 0, 3, 0, 0, 0, "BLOB", -1, -1, SQL_BLOB, -1, -1, -1],
656             ["CLOB", SQL_CLOB, 0, undef, undef, undef,
657             1, 0, 3, 0, 0, 0, "CLOB", -1, -1, SQL_CLOB, -1, -1, -1],
658             ];
659              
660 0           return $type_info_all;
661             }
662              
663             } # end of package DBD::cubrid::db
664              
665              
666             { package DBD::cubrid::st; # ====== STATEMENT ======
667              
668              
669             }
670              
671             1;
672              
673             __END__