📄 server-cfg
字号:
$limits{'func_extra_%'} = 0; $limits{'func_odbc_floor'} = 1; $limits{'column_alias'} = 1; $limits{'NEG'} = 1; $limits{'func_extra_in_num'} = 1; $limits{'unique_index'} = 1; # Unique index works or not $limits{'insert_select'} = 1; $limits{'working_blobs'} = 1; # If big varchar/blobs works $limits{'order_by_unused'} = 1; $limits{'working_all_fields'} = 1; $limits{'multi_distinct'} = 1; # allows select count(distinct a),count(distinct b).. return $self;}## Get the version number of the database#sub version{ my ($version,$dir); $version="Solid version ??"; foreach $dir ($ENV{'SOLIDDIR'},"/usr/local/solid", "/my/local/solid") { if ($dir && -e "$dir/bin/solcon") { $version=`$dir/bin/solcon -e"ver" $main::opt_user $main::opt_password | grep Server | sed q`; if ($? == 0) { chomp($version); $version .= "/ODBC" if ($self->{'data_source'} =~ /:ODBC:/); return $version; } } } $version .= "/ODBC" if ($self->{'data_source'} =~ /:ODBC:/); return $version;}sub connect{ my ($self)=@_; my ($dbh); $dbh=DBI->connect($self->{'data_source'}, $main::opt_user, $main::opt_password,{ PrintError => 0}) || die "Got error: '$DBI::errstr' when connecting to " . $self->{'data_source'} ." with user: '$main::opt_user' password: '$main::opt_password'\n"; return $dbh;}## Returns a list of statements to create a table# The field types are in ANSI SQL format.#sub create{ my($self,$table_name,$fields,$index) = @_; my($query,@queries,$nr); $query="create table $table_name ("; foreach $field (@$fields) { $field =~ s/mediumint/integer/i; $field =~ s/ double/ float/i; # Solid doesn't have blob, it has long varchar $field =~ s/ blob/ long varchar/;# $field =~ s/ decimal/ float/i;# $field =~ s/ big_decimal/ float/i;# $field =~ s/ date/ int/i; $query.= $field . ','; } substr($query,-1)=")"; # Remove last ','; push(@queries,$query); $nr=0; foreach $index (@$index) { if ($index =~ /^primary key/i || $index =~ /^unique/i) { # Add to create statement substr($queries[0],-1,0)="," . $index; } else { $index =~ /^(.*)\s+(\(.*\))$/; push(@queries,"create ${1}$nr on $table_name $2"); $nr++; } } return @queries;}# there is no sql statement in solid which can do the load from# an ascii file in the db ... but there is the speedloader program# an external program which can load the ascii file in the db ...# the server must be down before using speedloader !!!!# (in the standalone version)# it works also with a control file ... that one must be made ....sub insert_file { my ($self, $dbname, $file) = @_; my ($speedcmd); $speedcmd = '/usr/local/solid/bin/solload'; print "At this moment not supported - solid server must go down \n"; return 0;}# solid can't handle an alias in a having statement so# select test as foo from tmp group by foo having foor > 2# becomes# select test as foo from tmp group by foo having test > 2#sub query { my($self,$sql) = @_; my(@select,$tmp,$newhaving,$key,%change); if ($sql =~ /having\s+/i) { if ($sql =~ /select (.*) from/i) { (@select) = split(/,\s*/, $1); foreach $tmp (@select) { if ($tmp =~ /(.*)\s+as\s+(\w+)/) { $change{$2} = $1; } } } if ($sql =~ /having\s+(\w+)/i) { $newhaving = $1; foreach $key (sort {$a cmp $b} keys %change) { if ($newhaving eq $key) { $newhaving =~ s/$key/$change{$key}/g; } } } $sql =~ s/(having)\s+(\w+)/$1 $newhaving/i; } return $sql;}sub drop_index{ my ($self,$table,$index) = @_; return "DROP INDEX $index";}sub abort_if_fatal_error{ return 0;}sub small_rollback_segment{ return 0;}sub fix_for_insert{ my ($self,$cmd) = @_; return $cmd;}sub reconnect_on_errors{ return 0;}############################################################################## Definitions for Empress## at this moment DBI:Empress can only handle 200 prepare statements ...# so Empress can't be tested with the benchmark test :(#############################################################################package db_Empress;sub new{ my ($type,$host,$database)= @_; my $self= {}; my %limits; bless $self; $self->{'cmp_name'} = "empress"; $self->{'data_source'} = "DBI:EmpressNet:SERVER=$host;Database=/usr/local/empress/rdbms/bin/$database"; $self->{'limits'} = \%limits; $self->{'blob'} = "text"; $self->{'text'} = "text"; $self->{'double_quotes'} = 1; # Can handle: 'Walker''s' $self->{'drop_attr'} = ""; $self->{'transactions'} = 1; # Transactions enabled $limits{'max_conditions'} = 1258; $limits{'max_columns'} = 226; # server is disconnecting???? # above this value .... but can handle 2419 columns # maybe something for crash-me ... but how to check ??? $limits{'max_tables'} = 65000; # Should be big enough $limits{'max_text_size'} = 4095; # max returned .... $limits{'query_size'} = 65535; # Not a limit, big enough $limits{'max_index'} = 64; # Big enough $limits{'max_index_parts'} = 64; # Big enough $limits{'max_column_name'} = 31; $limits{'join_optimizer'} = 1; $limits{'load_data_infile'} = 0; $limits{'lock_tables'} = 1; $limits{'functions'} = 1; $limits{'group_functions'} = 1; $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; $limits{'multi_drop'} = 0; $limits{'subqueries'} = 1; $limits{'table_wildcard'} = 0; $limits{'having_with_alias'} = 0; # AS isn't supported in a select $limits{'having_with_group'} = 1; $limits{'like_with_column'} = 1; $limits{'order_by_position'} = 1; $limits{'group_by_position'} = 0; $limits{'alter_table'} = 1; $limits{'alter_add_multi_col'}= 0; $limits{'alter_table_dropcol'}= 0; $limits{'group_func_extra_std'}= 0; # Have group function std(). $limits{'func_odbc_mod'} = 0; $limits{'func_extra_%'} = 1; $limits{'func_odbc_floor'} = 1; $limits{'func_extra_if'} = 0; $limits{'column_alias'} = 0; $limits{'NEG'} = 1; $limits{'func_extra_in_num'} = 0; $limits{'unique_index'} = 1; # Unique index works or not $limits{'insert_select'} = 1; $limits{'working_blobs'} = 1; # If big varchar/blobs works $limits{'order_by_unused'} = 1; $limits{'working_all_fields'} = 1; $limits{'multi_distinct'} = 1; # allows select count(distinct a),count(distinct b).. return $self;}## Get the version number of the database#sub version{ my ($self,$dbh)=@_; my ($version); $version=""; if (-x "/usr/local/empress/rdbms/bin/empvers") { $version=`/usr/local/empress/rdbms/bin/empvers | grep Version`; } if ($version) { chomp($version); } else { $version="Empress version ???"; } $version .= "/ODBC" if ($self->{'data_source'} =~ /:ODBC:/); return $version;}sub connect{ my ($self)=@_; my ($dbh); $dbh=DBI->connect($self->{'data_source'}, $main::opt_user, $main::opt_password,{ PrintError => 0}) || die "Got error: '$DBI::errstr' when connecting to " . $self->{'data_source'} ." with user: '$main::opt_user' password: '$main::opt_password'\n"; return $dbh;}sub insert_file { my($self,$dbname, $file) = @_; my($command,$sth); $command = "insert into $dbname from '$file'"; print "$command\n" if ($opt_debug); $sth = $dbh->do($command) or die $DBI::errstr; return $sth;}## Returns a list of statements to create a table# The field types are in ANSI SQL format.#sub create{ my($self,$table_name,$fields,$index) = @_; my($query,@queries,$nr); $query="create table $table_name ("; foreach $field (@$fields) { $field =~ s/mediumint/int/i; $field =~ s/tinyint/int/i; $field =~ s/smallint/int/i; $field =~ s/longint/int/i; $field =~ s/integer/int/i; $field =~ s/ double/ longfloat/i; # Solid doesn't have blob, it has long varchar# $field =~ s/ blob/ text(65535,65535,65535,65535)/; $field =~ s/ blob/ text/; $field =~ s/ varchar\((\d+)\)/ char($1,3)/; $field =~ s/ char\((\d+)\)/ char($1,3)/;# $field =~ s/ decimal/ float/i;# $field =~ s/ big_decimal/ longfloat/i;# $field =~ s/ date/ int/i; $field =~ s/ float(.*)/ float/i; if ($field =~ / int\((\d+)\)/) { if ($1 > 4) { $field =~ s/ int\(\d+\)/ longinteger/i; } else { $field =~ s/ int\(\d+\)/ longinteger/i; } } else { $field =~ s/ int/ longinteger/i; } $query.= $field . ','; } substr($query,-1)=")"; # Remove last ','; push(@queries,$query); $nr=1; foreach $index (@$index) { # Primary key is unique index in Empress $index =~ s/primary key/unique index/i; if ($index =~ /^unique.*\(([^\(]*)\)$/i) { $nr++; push(@queries,"create unique index ${table_name}_$nr on $table_name ($1)"); } else { if (!($index =~ /^(.*index)\s+(\w*)\s+(\(.*\))$/i)) { die "Can't parse index information in '$index'\n"; } push(@queries,"create $1 ${table_name}_$2 on $table_name $3"); } } return @queries;}# empress can't handle an alias and but can handle the number of the# columname - so# select test as foo from tmp order by foo# becomes# select test from tmp order by 1#sub query { my($self,$sql) = @_; my(@select,$i,$tmp,$newselect,$neworder,@order,$key,%change); my($tmp1,$otmp,$tmp2); if ($sql =~ /\s+as\s+/i) { if ($sql =~ /select\s+(.*)\s+from/i) { $newselect = $1; (@select) = split(/,\s*/, $1); $i = 1; foreach $tmp (@select) { if ($tmp =~ /\s+as\s+(\w+)/) { $change{$1} = $i; } $i++; } } $newselect =~ s/\s+as\s+(\w+)//gi; $tmp2 = 0; if ($sql =~ /order\s+by\s+(.*)$/i) { (@order) = split(/,\s*/, $1); foreach $otmp (@order) { foreach $key (sort {$a cmp $b} keys %change) { if ($otmp eq $key) { $neworder .= "$tmp1"."$change{$key}"; $tmp1 = ", "; $tmp2 = 1; } elsif ($otmp =~ /(\w+)\s+(.+)$/) { if ($key eq $1) { $neworder .= "$tmp1"."$change{$key} $2"; $tmp2 = 1; } } } if ($tmp2 == 0) { $neworder .= "$tmp1"."$otmp"; } $tmp2 = 0; $tmp1 = ", "; } } $sql =~ s/(select)\s+(.*)\s+(from)/$1 $newselect $3/i; $sql =~ s/(order\s+by)\s+(.*)$/$1 $neworder/i; } return $sql;}sub fix_for_insert{ my ($self,$cmd) = @_; $cmd =~ s/\'\'/\' \'/g; return $cmd;}sub drop_index{ my ($self,$table,$index) = @_; return "DROP INDEX $index";}# This is a because of the 200 statement problem with DBI-Empresssub abort_if_fatal_error{ if ($DBI::errstr =~ /Overflow of table of prepared statements/i) { print "Overflow of prepared statements ... killing the process\n"; exit 1; } return 0;}sub small_rollback_segment{ return 0;}sub reconnect_on_errors{ return 0;}############################################################################## Definitions for Oracle#############################################################################package db_Oracle;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -