DBD-Teradata
view release on metacpan or search on metacpan
lib/DBD/Teradata.pm view on Meta::CPAN
$maxparmlen = MAX_PARM_TUPLES;
}
else {
foreach (0..$numParam-1) {
$maxparmlen = scalar(@{$$params[$_]})
if (ref $$params[$_] eq 'ARRAY') &&
(scalar(@{$$params[$_]}) > $maxparmlen);
}
}
my $fldcnt = $numParam;
my ($tuples, $datainfo, $indicdata) = (0, '', '');
my $pos = 0;
if (($params && scalar @$params) || $attrs->{_fetch_sub}) {
($tuples, $datainfo, $indicdata) =
$usephs ? _process_ph_params($sth, $fldcnt, $params, $attrs) :
_process_using_params($sth, $fldcnt, $rawmode, $modepcl, $params, $attrs);
return undef
unless $tuples;
}
$iobj->io_tddo('BT'),
$iobj->[11] = 1
if ($partition == 1) && (!$dbh->{AutoCommit}) &&
($dbh->{tdat_mode} ne 'ANSI') && ($iobj->[11] == 0);
$iobj->[11] = 1
if ($partition == 1) && ($dbh->{tdat_mode} eq 'ANSI');
return $tuples
if $attrs->{_fetch_sub};
my $rowcnt = $iobj->io_execute($sth, $datainfo, $indicdata,
($use_cursor ? $cursth->{_p}[6] : undef));
$sthp->[13] = $rowcnt;
return $sth->DBI::set_err($iobj->io_get_error())
unless defined($rowcnt);
$sth->{Active} = ($sth->{NUM_OF_FIELDS} != 0);
undef $sthp->[6]
if ($sth->{Statement}=~/^DELETE\s+.+\s+WHERE\s+CURRENT\s+OF\s+\w+$/i);
$sthp->[26] = 1
unless $sthp->[22] && (! $sth->{tdat_keepresp});
return ($rowcnt == 0) ? -1 : $rowcnt
lib/DBD/Teradata.pm view on Meta::CPAN
(($ptypes->[$_] == 12) ||
($ptypes->[$_] == -3));
substr($datainfo, $j, 4) = pack('SS', $tdtype, $plens->[$_]);
$maxszs->[$_] = $prec;
$j += 4;
}
return ($datainfo, $packstr);
}
sub _process_ph_params {
my ($sth, $fldcnt, $params, $attrs) = @_;
my $indicdata;
my $pos = 0;
my $maxsz = 100;
my ($i, $p);
my $sthp = $sth->{_p};
my $iobj = $sthp->[11];
my $ptypes = $sthp->[2];
my $plens = $sthp->[9];
my $fetch_sub = $attrs->{_fetch_sub};
my @maxszs = ((0) x $fldcnt);
my ($datainfo, $packstr) = _gen_datainfo($fldcnt, $ptypes, $plens, \@maxszs);
lib/DBD/Teradata.pm view on Meta::CPAN
($ttype == -3)) ? 2 + length($p) :
($ttype == 3) ? $td_decszs[(($plens->[$_]>>8) & 31)] :
$plens->[$_];
$maxszs[$_] = length($p) + 2,
substr($datainfo, 4 + ($_ << 2), 2, pack('S', $maxszs[$_]))
if (($ttype == 12) || ($ttype == -3)) &&
($maxszs[$_] < length($p) + 2);
}
map { $maxsz += $_; } @maxszs;
$maxsz += scalar @indicvec;
$indicdata = "\0" x $maxsz;
substr($indicdata, 0, scalar(@indicvec), pack('C*', @indicvec));
substr($indicdata, scalar(@indicvec), $pos, pack($packstr, @tmpary));
$pos += scalar(@indicvec);
return (++$tuples, $datainfo, substr($indicdata, 0, $pos))
;
}
substr($iobj->[16], $attrs->{_datainfop}, length($datainfo), $datainfo);
return ($tuples, undef, undef);
}
sub _process_using_params {
my ($sth, $fldcnt, $rawmode, $modepcl, $params, $attrs) = @_;
my $indicdata;
my $pos = 0;
my $maxsz = (($fldcnt & 7) ? ($fldcnt>>3) + 1 : $fldcnt>>3);
my ($i, $k, $p);
my $sthp = $sth->{_p};
my $iobj = $sthp->[11];
my $ptypes = $sthp->[2];
my $plens = $sthp->[9];
my $packstr = $sthp->[18];
my $fetch_sub = $attrs->{_fetch_sub};
my $tuples = 0;
lib/DBD/Teradata.pm view on Meta::CPAN
$pos +=
(($ttype == 12) ||
($ttype == -3)) ? 2 + length($p) :
($ttype == 3) ? $td_decszs[(($plens->[$_]>>8) & 31)] :
$plens->[$_];
$ttype = $ptypes->[$i];
$p = $params->[$i];
$p = $$p
if defined($p) && (ref $p);
}
$indicdata = "\0" x $maxsz;
substr($indicdata, 0, scalar(@indicvec), pack('C*', @indicvec));
substr($indicdata, scalar(@indicvec), $pos, pack($packstr, @tmpary));
$pos += scalar(@indicvec);
}
else {
$p = $params->[0];
$p = (ref $p eq 'ARRAY') ? $p->[0] : $$p
if defined($p) && (ref $p);
$pos = length($p) - 3;
$indicdata = substr($p, 2, $pos);
}
return (++$tuples, undef, substr($indicdata, 0, $pos))
;
}
return ($tuples, undef, undef);
}
sub Realize {
return defined($_[0]->{_p}[11]->io_Realize($_[0])) ?
1 : $_[0]->DBI::set_err($_[0]->{_p}[11]->io_get_error());
}
*tdat_Realize = \&Realize;
sub tdat_Rewind {
lib/DBD/Teradata.pm view on Meta::CPAN
$colcnt = unpack('S', substr($pcl, $curpos));
$stmtinfo->{SummaryStarts}[$nextsum] = $nextcol;
$stmtinfo->{SummaryEnds}[$nextsum] = $nextcol + $colcnt - 1;
$nextsum++;
$curpos += 2;
$sumcnt--;
}
return $nextcol;
}
sub io_execute {
my ($obj, $sth, $datainfo, $indicdata, $rowid) = @_;
$obj->[18] = 0;
$obj->[24] = '00000';
$obj->[17] = '';
my $stmtinfo = $sth->{tdat_stmt_info};
my $stmtno = $sth->{tdat_stmtno};
my $nowait = $sth->{tdat_nowait};
my $stmt = $sth->{Statement} || '';
my $keepresp = ($sth->{tdat_keepresp} || ($stmt=~/\s+FOR\s+CURSOR\s*$/i));
my $rawmode = $sth->{tdat_raw_in};
my $reqmsg = '';
lib/DBD/Teradata.pm view on Meta::CPAN
my $modepcl = ($rawmode && defined($rawmodes{$rawmode})) ?
$rawmodes{$rawmode} : 68;
my $partition = $obj->[19];
my $reqfac = $obj->[38];
$stmt=~s/\s+WHERE\s+CURRENT\s+OF\s+([^\s;]+)\s*;?\s*$/ WHERE CURRENT/i;
my $forCursor = ($stmt=~/\s+WHERE\s+CURRENT$/i) && $rowid;
if (($partition == 1) ||
(($partition == 6) && ($stmt ne ';'))) {
$reqlen = 4 + length($stmt) + 6 +
((defined($datainfo) && length($datainfo)) ? 4 + length($datainfo) : 0) +
((defined($indicdata) && length($indicdata)) ? 4 + length($indicdata) : 0) +
($forCursor ? 4 + length($rowid) : 0) +
($sth->{tdat_mload} ? 14 : 0);
if ($reqlen > 65535) {
$reqlen += 4 + 4 + (length($datainfo) ? 4 : 0) +
(length($indicdata) ? 4 : 0) + (($forCursor && $rowid) ? 4 : 0);
$obj->[26] = 1;
}
else {
$obj->[26] = undef;
}
}
if ($sth->{Statement}=~/^\s*(CREATE|REPLACE)\s+PROCEDURE\s+/i) {
my $pos = 0;
my $segment = 1;
my $len = length($sth->{Statement});
lib/DBD/Teradata.pm view on Meta::CPAN
$sth->{_p}[12] = $treqno;
last unless $len;
return undef unless defined($obj->io_Realize($sth));
}
return ($nowait ? -1 : $obj->io_Realize($sth));
}
return $obj->io_set_error('Maximum request size exceeded.')
if ($obj->[40] < 5000000) && ($reqlen > 65535);
if ($partition == 1) {
$reqmsg = $reqfac->sqlRequest($obj, $sth, $forCursor, $rowid, $modepcl, $keepresp,
$obj->[3], $stmt, $datainfo, $indicdata);
}
delete $obj->[1]{$_}
foreach (keys %{$obj->[1]});
my $treqno = $obj->[2];
if (($partition == 5) || ($partition == 4)) {
$obj->io_quicksend($obj->[32], undef, $obj->[16])
or return undef;
}
else {
$obj->io_tdsend($reqmsg) or return undef;
( run in 0.488 second using v1.01-cache-2.11-cpan-454fe037f31 )