DBD-Fulcrum

 view release on metacpan or  search on metacpan

dbdimp.c  view on Meta::CPAN

    HV *bn = imp_sth->bind_names;
    retsv = newSViv( imp_sth->ful_last_row_id );
  } else if (kl == 4 && strEQ(key, "NAME")) {
    AV *av = newAV();
    retsv = newRV((SV*)av);
    while(--i >= 0)
      av_store(av, i, newSVpv((char*)imp_sth->fbh[i].cbuf,0));
    
  } else if (kl == 10 && strEQ(key, "CursorName")) {
    /* Thanks to Peter Wyngaard for this ... */
    char cursor_name[SQL_MAX_CURSOR_NAME_LEN + 1];
    if (SQLGetCursorName (imp_sth->phstmt,
			  cursor_name,
			  SQL_MAX_CURSOR_NAME_LEN,
			  NULL)
	== SQL_SUCCESS)
      retsv = newSVpv (cursor_name, 0);
    else
      retsv = Nullsv;
  }
  else {
    return Nullsv;
  }

  if (cacheit) { /* cache for next time (via DBI quick_FETCH)	*/
    SV **svp = hv_fetch((HV*)SvRV(sth), key, kl, 1);
    sv_free(*svp);

test.pl  view on Meta::CPAN

#   while (<INHDL>) { print TESTHDL $_;   }
#   close INHDL;
#   close TESTHDL;
#};
#print "ok\n";


print "Doing a query (expecting 'Data truncated' error)... ";
#$::ful_dbh->{LongTruncOk} = 0;

#my $cursor = $::ful_dbh->prepare ('select ft_text,ft_sfname,filesize,title from test where title contains \'pippo\'', {fulcrum_MaximumHitsInInternalColumns => 100});
my $cursor = $::ful_dbh->prepare ('select ft_text,ft_sfname,filesize,title from test where title contains \'pippo\'');
if ($cursor) {
   print "(execute) ... ";
   $cursor->execute;
   print "ok, now fetching (fetchrow): ";
   my $text;
   my @row;
   my $eot;
   my $data_truncated = 0;
   while (@row  = $cursor->fetchrow) {
      $data_truncated++ if ($cursor->state =~ /01004/);
   }
   print "checking data truncated condition... ";
   if ($data_truncated == 0) {
      print "FAILED: did not detect 01004 [Data truncated] condition!\n";
      exit 1;
   }
   print "ok\n";
}
else {
   print "FAILED: Prepare failed ($DBI::errstr)\n";
   exit 1;
}

print "Doing another query (this time you'll see the data)... ";
$DBD::Fulcrum::ful_maxhitsinternalcolumns = 64;
$cursor = $::ful_dbh->prepare ('select ft_text,ft_sfname,filesize,title from test where title contains \'pippo\'');
if ($cursor) {
   print "(execute) ... ";
   $cursor->execute;
   print "ok, now fetching (fetchrow):\n***\n";
   my $text;
   my @row;
   my $eot;
   my $data_truncated = 0;
   while (@row  = $cursor->fetchrow) {
      $data_truncated++ if ($DBI::state =~ /truncated/);
      $cursor->blob_read (1, 0, 8192, \$text);
      #or (print "+++ RB NOT OK:$DBI::errstr\n");
      $text = $` if ($text =~ /\x00/);
      print "(FILE: $row[1] TITLE: '$row[3]') "; #$text removed to clean up output
   }
   if ($data_truncated > 0) {
      print "FAILED: Data truncated when it shouldn't be!\n";
      exit 1;
   }
   print "\n***\n\tok\n";
}
else {
   print "FAILED: Prepare failed ($DBI::errstr)\n";
   exit 1;
}

$cursor->finish;
$ful_dbh->disconnect;

print "Exiting\nIf you are here, then most likely all tests were successful.\n";
exit 0;
# end.



( run in 0.319 second using v1.01-cache-2.11-cpan-4d50c553e7e )