DBD-PrimeBase

 view release on metacpan or  search on metacpan

benchmarks/server-cfg  view on Meta::CPAN


#
# Returns a list of statements to create a table
# The field types are in ANSI SQL format.
#
# If one uses $main::opt_fast then one is allowed to use
# non standard types to get better speed.
#

sub create
{
  my($self,$table_name,$fields,$index,$options) = @_;
  my($query,@queries);

  $query="create table $table_name (";
  foreach $field (@$fields)
  {
    $field =~ s/ decimal/ double(10,2)/i;
    $field =~ s/ big_decimal/ double(10,2)/i;
    $field =~ s/ date/ int/i;		# Because of tcp ?
    $query.= $field . ',';
  }
  foreach $index (@$index)
  {
    $query.= $index . ',';
  }
  substr($query,-1)=")";		# Remove last ',';
  $query.=" $options" if (defined($options));
  push(@queries,$query);
  return @queries;
}

sub insert_file {
  my($self,$dbname, $file) = @_;
  print "insert of an ascii file isn't supported by Mimer\n";
  return 0;
}

#
# Do any conversions to the ANSI SQL query so that the database can handle it
#

sub query {
  my($self,$sql) = @_;
  return $sql;
}

sub drop_index {
  my ($self,$table,$index) = @_;
  return "DROP INDEX $index";
}

#
# Abort if the server has crashed
# return: 0 if ok
#	  1 question should be retried
#

sub abort_if_fatal_error
{
  return 1 if ($DBI::errstr =~ /Table locked by another cursor/);
  return 0;
}

sub small_rollback_segment
{
  return 0;
}

sub reconnect_on_errors
{
  return 0;
}

#############################################################################
#	     Configuration for InterBase
#############################################################################

package db_interbase;

sub new
{
  my ($type,$host,$database)= @_;
  my $self= {};
  my %limits;
  bless $self;

  $self->{'cmp_name'}		= "interbase";
  $self->{'data_source'}	= "DBI:InterBase:database=$database";
  $self->{'limits'}		= \%limits;
  $self->{'smds'}		= \%smds;
  $self->{'blob'}		= "blob";
  $self->{'text'}		= "";
  $self->{'double_quotes'}	= 1; # Can handle:  'Walker''s'
  $self->{'drop_attr'}		= "";
  $self->{'char_null'}          = "";
  $self->{'numeric_null'}       = "";

  $limits{'max_conditions'}	= 9999; # (Actually not a limit)
  $limits{'max_columns'}	= 252;	# Max number of columns in table
  $limits{'max_tables'}		= 65000;	# Should be big enough
  $limits{'max_text_size'}	= 15000; # Max size with default buffers.
  $limits{'query_size'}		= 1000000; # Max size with default buffers.
  $limits{'max_index'}		= 31; # Max number of keys
  $limits{'max_index_parts'}	= 8; # Max segments/key
  $limits{'max_column_name'}	= 128; # max table and column name

  $limits{'join_optimizer'}	= 1; # Can optimize FROM tables
  $limits{'load_data_infile'}	= 0; # Has load data infile
  $limits{'lock_tables'}	= 0; # Has lock tables
  $limits{'functions'}		= 1; # Has simple functions (+/-)
  $limits{'group_functions'}	= 1; # Have group functions
  $limits{'group_func_sql_min_str'} = 1; # Can execute MIN() and MAX() on strings
  $limits{'group_distinct_functions'}= 1; # Have count(distinct)
  $limits{'select_without_from'}= 0; # Cannot do 'select 1';
  $limits{'multi_drop'}		= 0; # Drop table cannot take many tables
  $limits{'subqueries'}		= 1; # Supports sub-queries.
  $limits{'left_outer_join'}	= 1; # Supports left outer joins
  $limits{'table_wildcard'}	= 1; # Has SELECT table_name.*
  $limits{'having_with_alias'}  = 0; # Can use aliases in HAVING
  $limits{'having_with_group'}	= 1; # Can use group functions in HAVING

benchmarks/server-cfg  view on Meta::CPAN


  $query="create table $table_name (";
  foreach $field (@$fields)
  {
    $field =~ s/ big_decimal/ float/i;
    $field =~ s/ double/ float/i;
    $field =~ s/ tinyint/ smallint/i;
    $field =~ s/ mediumint/ int/i;
    $field =~ s/ integer/ int/i;
    $field =~ s/ float\(\d,\d\)/ float/i;
    $field =~ s/ date/ int/i;		# Because of tcp ?
    $field =~ s/ smallint\(\d\)/ smallint/i;
    $field =~ s/ int\(\d\)/ int/i;
    $query.= $field . ',';
  }
  foreach $ind (@$index)
  {
    my @index;
    if ( $ind =~ /\bKEY\b/i ){
      push(@keys,"ALTER TABLE $table_name ADD $ind");
    }else{
      my @fields = split(' ',$index);
      my $query="CREATE INDEX $fields[1] ON $table_name $fields[2]";
      push(@index,$query);
    }
  }
  substr($query,-1)=")";		# Remove last ',';
  $query.=" $options" if (defined($options));
  push(@queries,$query);
  return @queries;
}

sub insert_file {
  my($self,$dbname, $file) = @_;
  print "insert of an ascii file isn't supported by InterBase\n";
  return 0;
}

#
# Do any conversions to the ANSI SQL query so that the database can handle it
#

sub query {
  my($self,$sql) = @_;
  return $sql;
}

sub drop_index {
  my ($self,$table,$index) = @_;
  return "DROP INDEX $index";
}

#
# Abort if the server has crashed
# return: 0 if ok
#	  1 question should be retried
#

sub abort_if_fatal_error
{
  return 1 if ($DBI::errstr =~ /Table locked by another cursor/);
  return 0;
}

sub small_rollback_segment
{
  return 1;
}

sub reconnect_on_errors
{
  return 1;
}

#############################################################################
#	     Configuration for FrontBase 
#############################################################################

package db_FrontBase;

sub new
{
  my ($type,$host,$database)= @_;
  my $self= {};
  my %limits;
  bless $self;

  $self->{'cmp_name'}		= "FrontBase";
  $self->{'data_source'}	= "DBI:FB:dbname=$database;host=$host";
  $self->{'limits'}		= \%limits;
  $self->{'smds'}		= \%smds;
  $self->{'blob'}		= "varchar(8000000)";
  $self->{'text'}		= "varchar(8000000)";
  $self->{'double_quotes'}	= 1; # Can handle:  'Walker''s'
  $self->{'drop_attr'}		= ' restrict';
  $self->{'error_on_execute_means_zero_rows'}=1;

  $limits{'max_conditions'}	= 5427; # (Actually not a limit)
  # The following should be 8192, but is smaller because Frontbase crashes..
  $limits{'max_columns'}	= 150;	# Max number of columns in table
  $limits{'max_tables'}		= 5000;	# 10000 crashed FrontBase
  $limits{'max_text_size'}	= 65000; # Max size with default buffers.
  $limits{'query_size'}		= 8000000; # Max size with default buffers.
  $limits{'max_index'}		= 38; # Max number of keys
  $limits{'max_index_parts'}	= 20; # Max segments/key
  $limits{'max_column_name'}	= 128; # max table and column name

  $limits{'join_optimizer'}	= 1; # Can optimize FROM tables
  $limits{'load_data_infile'}	= 1; # Has load data infile
  $limits{'lock_tables'}	= 0; # Has lock tables
  $limits{'functions'}		= 1; # Has simple functions (+/-)
  $limits{'group_functions'}	= 1; # Have group functions
  $limits{'group_distinct_functions'}= 0; # Have count(distinct)
  $limits{'select_without_from'}= 0;
  $limits{'multi_drop'}		= 0; # Drop table cannot take many tables
  $limits{'subqueries'}		= 1; # Supports sub-queries.
  $limits{'left_outer_join'}	= 1; # Supports left outer joins
  $limits{'table_wildcard'}	= 1; # Has SELECT table_name.*
  $limits{'having_with_alias'}  = 0; # Can use aliases in HAVING
  $limits{'having_with_group'}	= 0; # Can use group functions in HAVING
  $limits{'like_with_column'}	= 1; # Can use column1 LIKE column2



( run in 1.524 second using v1.01-cache-2.11-cpan-39bf76dae61 )