#At lp:maria/5.2 2761 knielsen@knielsen-hq.org 2010-03-31 [merge] Merge OQGraph into MariaDB 5.2. (and in the process, fix compile-bintar to link C++ with g++ rather than gcc). added: mysql-test/suite/oqgraph/ mysql-test/suite/oqgraph/include/ mysql-test/suite/oqgraph/include/have_oqgraph_engine.inc mysql-test/suite/oqgraph/r/ mysql-test/suite/oqgraph/r/basic.result mysql-test/suite/oqgraph/t/ mysql-test/suite/oqgraph/t/basic-master.opt mysql-test/suite/oqgraph/t/basic.test mysql-test/suite/pbxt/r/pbxt_xa.result mysql-test/suite/pbxt/t/pbxt_xa.test mysql-test/suite/pbxt/t/suite.opt storage/oqgraph/ storage/oqgraph/CMakeFiles.txt storage/oqgraph/Makefile.am storage/oqgraph/README storage/oqgraph/graphcore-graph.h storage/oqgraph/graphcore-types.h storage/oqgraph/graphcore.cc storage/oqgraph/graphcore.h storage/oqgraph/graphstore.c storage/oqgraph/graphstore.h storage/oqgraph/ha_oqgraph.cc storage/oqgraph/ha_oqgraph.h storage/oqgraph/oqgraph_config.h.in storage/oqgraph/oqgraph_probes.d storage/oqgraph/plug.in modified: BUILD/SETUP.sh BUILD/compile-bintar extra/comp_err.c extra/libevent/kqueue.c mysql-test/Makefile.am mysql-test/extra/rpl_tests/rpl_tmp_table_and_DDL.test mysql-test/include/default_mysqld.cnf mysql-test/lib/My/SafeProcess/safe_process.cc mysql-test/lib/mtr_cases.pm mysql-test/lib/v1/mysql-test-run.pl mysql-test/mysql-test-run.pl mysql-test/suite/parts/t/rpl_partition.test mysql-test/suite/rpl/r/rpl_do_grant.result mysql-test/suite/rpl/t/rpl_do_grant.test mysql-test/suite/rpl/t/rpl_name_const.test mysql-test/suite/rpl/t/rpl_row_basic_11bugs.test mysql-test/suite/rpl/t/rpl_row_trig003.test mysql-test/t/bug47671-master.opt mysql-test/t/ctype_latin1_de-master.opt mysql-test/t/ctype_ucs2_def-master.opt mysys/mf_keycache.c mysys/my_gethostbyname.c sql/handler.cc sql/item.cc sql/item.h sql/item_cmpfunc.cc sql/item_create.cc sql/item_create.h sql/item_sum.cc sql/item_sum.h sql/log.cc sql/mysqld.cc sql/net_serv.cc sql/set_var.cc sql/sql_class.h sql/sql_table.cc sql/sql_view.cc sql/sql_yacc.yy storage/example/ha_example.h storage/maria/ma_loghandler.c storage/maria/ma_search.c storage/maria/maria_def.h storage/myisam/ft_stopwords.c storage/myisammrg/ha_myisammrg.cc storage/myisammrg/myrg_open.c storage/xtradb/include/page0page.h storage/xtradb/include/page0page.ic storage/xtradb/include/ut0lst.h strings/ctype-ucs2.c strings/ctype-utf8.c support-files/compiler_warnings.supp unittest/mysys/waiting_threads-t.c === modified file 'BUILD/SETUP.sh' --- a/BUILD/SETUP.sh 2010-01-07 12:02:18 +0000 +++ b/BUILD/SETUP.sh 2010-03-30 16:16:57 +0000 @@ -204,7 +204,7 @@ if test -z "$CC" ; then fi if test -z "$CXX" ; then - CXX=gcc + CXX=g++ fi # If ccache (a compiler cache which reduces build time) === modified file 'BUILD/compile-bintar' --- a/BUILD/compile-bintar 2010-01-07 12:02:18 +0000 +++ b/BUILD/compile-bintar 2010-03-31 08:17:03 +0000 @@ -32,8 +32,7 @@ # .so files at runtime (either system stuff like NSS, or server # plugins). # -# We link libgcc statically (and avoid linking libstdc++ at all by -# CXX=gcc), to avoid reduce nasty library version dependencies. +# We link libgcc statically to avoid reduce nasty library version dependencies. test -f Makefile && make distclean @@ -52,13 +51,12 @@ get_cpuopt get_make_parallel_flag # Use gcc rather than g++ to avoid linking libstdc++.so (which we don't need). -COMP="gcc -static-libgcc" FLAGS="-O2 -fno-omit-frame-pointer -g -pipe -Wall $CPUOPT" # Don't press on in case of error. set -e -CC="$COMP" CXX="$COMP" CFLAGS="$FLAGS" CXXFLAGS="$FLAGS" \ +CC="gcc -static-libgcc" CXX="g++ -static-libgcc" CFLAGS="$FLAGS" CXXFLAGS="$FLAGS" \ ./configure \ --prefix=/usr/local/mysql \ --exec-prefix=/usr/local/mysql \ === modified file 'extra/comp_err.c' --- a/extra/comp_err.c 2009-11-20 10:11:31 +0000 +++ b/extra/comp_err.c 2010-03-30 12:36:49 +0000 @@ -660,7 +660,7 @@ static ha_checksum checksum_format_speci case 'u': case 'x': case 's': - chksum= my_checksum(chksum, start, (uint) (p + 1 - start)); + chksum= my_checksum(chksum, (uchar*) start, (uint) (p + 1 - start)); start= 0; /* Not in format specifier anymore */ break; === modified file 'extra/libevent/kqueue.c' --- a/extra/libevent/kqueue.c 2009-03-12 22:27:35 +0000 +++ b/extra/libevent/kqueue.c 2010-03-30 12:36:49 +0000 @@ -144,7 +144,7 @@ kq_init(struct event_base *base) */ if (kevent(kq, kqueueop->changes, 1, kqueueop->events, NEVENT, NULL) != 1 || - kqueueop->events[0].ident != -1 || + ((int) kqueueop->events[0].ident) != -1 || kqueueop->events[0].flags != EV_ERROR) { event_warn("%s: detected broken kqueue; not using.", __func__); free(kqueueop->changes); === modified file 'mysql-test/Makefile.am' --- a/mysql-test/Makefile.am 2010-03-18 12:08:39 +0000 +++ b/mysql-test/Makefile.am 2010-03-31 08:17:03 +0000 @@ -104,6 +104,7 @@ TEST_DIRS = t r include std_data std_dat suite/pbxt/t suite/pbxt/r \ suite/innodb suite/innodb/t suite/innodb/r suite/innodb/include \ suite/vcol suite/vcol/t suite/vcol/r suite/vcol/inc + suite/oqgraph suite/oqgraph/t suite/oqgraph/r suite/oqgraph/include # Used by dist-hook and install-data-local to copy all # test files into either dist or install directory === modified file 'mysql-test/extra/rpl_tests/rpl_tmp_table_and_DDL.test' --- a/mysql-test/extra/rpl_tests/rpl_tmp_table_and_DDL.test 2010-01-22 09:38:21 +0000 +++ b/mysql-test/extra/rpl_tests/rpl_tmp_table_and_DDL.test 2010-03-28 18:10:00 +0000 @@ -157,3 +157,4 @@ INSERT INTO t1 VALUES (1); DROP TEMPORARY TABLE t1; +--sync_slave_with_master === modified file 'mysql-test/include/default_mysqld.cnf' --- a/mysql-test/include/default_mysqld.cnf 2008-04-08 14:51:26 +0000 +++ b/mysql-test/include/default_mysqld.cnf 2010-03-28 18:10:00 +0000 @@ -2,7 +2,7 @@ [mysqld] open-files-limit= 1024 local-infile -default-character-set= latin1 +character-set-server= latin1 # Increase default connect_timeout to avoid intermittent # disconnects when test servers are put under load see BUG#28359 === modified file 'mysql-test/lib/My/SafeProcess/safe_process.cc' --- a/mysql-test/lib/My/SafeProcess/safe_process.cc 2009-07-08 12:31:22 +0000 +++ b/mysql-test/lib/My/SafeProcess/safe_process.cc 2010-03-28 18:10:00 +0000 @@ -159,7 +159,7 @@ int main(int argc, char* const argv[] ) signal(SIGCHLD, handle_signal); signal(SIGABRT, handle_abort); - sprintf(safe_process_name, "safe_process[%d]", own_pid); + sprintf(safe_process_name, "safe_process[%d]", (int) own_pid); message("Started"); === modified file 'mysql-test/lib/mtr_cases.pm' --- a/mysql-test/lib/mtr_cases.pm 2010-01-15 15:27:55 +0000 +++ b/mysql-test/lib/mtr_cases.pm 2010-03-30 16:16:57 +0000 @@ -681,6 +681,8 @@ sub optimize_cases { if ( $default_engine =~ /^ndb/i ); $tinfo->{'innodb_test'}= 1 if ( $default_engine =~ /^innodb/i ); + $tinfo->{'pbxt_test'}= 1 + if ( $default_engine =~ /^pbxt/i ); } } @@ -778,6 +780,8 @@ sub collect_one_test_case { my $disabled= shift; my $suite_opts= shift; + my $local_default_storage_engine= $default_storage_engine; + #print "collect_one_test_case\n"; #print " suitedir: $suitedir\n"; #print " testdir: $testdir\n"; @@ -932,15 +936,26 @@ sub collect_one_test_case { tags_from_test_file($tinfo,"$testdir/${tname}.test"); - if ( defined $default_storage_engine ) + # Get default storage engine from suite.opt file + + if (defined $suite_opts && + "@$suite_opts" =~ "default-storage-engine=\s*([^\s]*)") + { + $local_default_storage_engine= $1; + } + + if ( defined $local_default_storage_engine ) { # Different default engine is used # tag test to require that engine $tinfo->{'ndb_test'}= 1 - if ( $default_storage_engine =~ /^ndb/i ); + if ( $local_default_storage_engine =~ /^ndb/i ); $tinfo->{'innodb_test'}= 1 - if ( $default_storage_engine =~ /^innodb/i ); + if ( $local_default_storage_engine =~ /^innodb/i ); + + $tinfo->{'pbxt_test'}= 1 + if ( $local_default_storage_engine =~ /^pbxt/i ); } @@ -1103,6 +1118,28 @@ sub collect_one_test_case { $tinfo->{template_path}= $config; } + if ( $tinfo->{'pbxt_test'} ) + { + # This is a test that needs pbxt + if ( $::mysqld_variables{'pbxt'} eq "OFF" || + ! exists $::mysqld_variables{'pbxt'} ) + { + # Engine is not supported, skip it + $tinfo->{'skip'}= 1; + return $tinfo; + } + } + else + { + # Only disable engine if it's on by default (to avoid warnings about + # not existing loose options + if ( $::mysqld_variables{'pbxt'} eq "ON") + { + push(@{$tinfo->{'master_opt'}}, "--loose-skip-pbxt"); + push(@{$tinfo->{'slave_opt'}}, "--loose-skip-pbxt"); + } + } + if ( $tinfo->{'example_plugin_test'} ) { if ( !$ENV{'EXAMPLE_PLUGIN'} ) @@ -1113,6 +1150,16 @@ sub collect_one_test_case { } } + if ( $tinfo->{'oqgraph_test'} ) + { + if ( !$ENV{'OQGRAPH_PLUGIN'} ) + { + $tinfo->{'skip'}= 1; + $tinfo->{'comment'}= "Test requires the OQGraph storage engine"; + return $tinfo; + } + } + # Set extra config file to use if (defined $defaults_extra_file) { @@ -1156,6 +1203,7 @@ my @tags= ["include/have_log_bin.inc", "need_binlog", 1], ["include/have_innodb.inc", "innodb_test", 1], + ["include/have_pbxt.inc", "pbxt_test", 1], ["include/big_test.inc", "big_test", 1], ["include/have_debug.inc", "need_debug", 1], ["include/have_ndb.inc", "ndb_test", 1], @@ -1167,6 +1215,7 @@ my @tags= ["include/not_embedded.inc", "not_embedded", 1], ["include/not_valgrind.inc", "not_valgrind", 1], ["include/have_example_plugin.inc", "example_plugin_test", 1], + ["include/have_oqgraph_engine.inc", "oqgraph_test", 1], ["include/have_ssl.inc", "need_ssl", 1], ); === modified file 'mysql-test/lib/v1/mysql-test-run.pl' --- a/mysql-test/lib/v1/mysql-test-run.pl 2010-03-04 08:03:07 +0000 +++ b/mysql-test/lib/v1/mysql-test-run.pl 2010-03-28 18:10:00 +0000 @@ -3965,7 +3965,7 @@ sub mysqld_arguments ($$$$) { } } - mtr_add_arg($args, "%s--default-character-set=latin1", $prefix); + mtr_add_arg($args, "%s--character-set-server-set=latin1", $prefix); mtr_add_arg($args, "%s--language=%s", $prefix, $path_language); mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix); === modified file 'mysql-test/mysql-test-run.pl' --- a/mysql-test/mysql-test-run.pl 2010-02-19 08:10:05 +0000 +++ b/mysql-test/mysql-test-run.pl 2010-03-31 08:17:03 +0000 @@ -126,7 +126,7 @@ my $path_config_file; # The ge # executables will be used by the test suite. our $opt_vs_config = $ENV{'MTR_VS_CONFIG'}; -my $DEFAULT_SUITES= "main,binlog,federated,rpl,maria,parts,vcol"; +my $DEFAULT_SUITES= "main,binlog,federated,rpl,maria,parts,vcol,oqgraph"; my $opt_suites; our $opt_verbose= 0; # Verbose output, enable with --verbose @@ -1909,6 +1909,33 @@ sub detect_plugins { $ENV{'HA_EXAMPLE_SO'}="'".$plugin_filename."'"; $ENV{'EXAMPLE_PLUGIN_LOAD'}="--plugin_load=EXAMPLE=".$plugin_filename; } + + # -------------------------------------------------------------------------- + # Add the path where mysqld will find graph_engine.so + # -------------------------------------------------------------------------- + if ($mysql_version_id >= 50100 && !(IS_WINDOWS && $opt_embedded_server)) { + my $plugin_filename; + if (IS_WINDOWS) + { + $plugin_filename = "oqgraph_engine.dll"; + } + else + { + $plugin_filename = "oqgraph_engine.so"; + } + my $lib_oqgraph_plugin= + mtr_file_exists(vs_config_dirs('storage/oqgraph',$plugin_filename), + "$basedir/storage/oqgraph/.libs/".$plugin_filename, + "$basedir/lib/mariadb/plugin/".$plugin_filename, + "$basedir/lib/mysql/plugin/".$plugin_filename); + $ENV{'OQGRAPH_PLUGIN'}= + ($lib_oqgraph_plugin ? basename($lib_oqgraph_plugin) : ""); + $ENV{'OQGRAPH_PLUGIN_OPT'}= "--plugin-dir=". + ($lib_oqgraph_plugin ? dirname($lib_oqgraph_plugin) : ""); + + $ENV{'GRAPH_ENGINE_SO'}="'".$plugin_filename."'"; + $ENV{'OQGRAPH_PLUGIN_LOAD'}="--plugin_load=;OQGRAPH=".$plugin_filename.";"; + } } # === added directory 'mysql-test/suite/oqgraph' === added directory 'mysql-test/suite/oqgraph/include' === added file 'mysql-test/suite/oqgraph/include/have_oqgraph_engine.inc' --- a/mysql-test/suite/oqgraph/include/have_oqgraph_engine.inc 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/oqgraph/include/have_oqgraph_engine.inc 2010-01-04 08:27:50 +0000 @@ -0,0 +1,4 @@ +disable_query_log; +--require r/true.require +select (PLUGIN_LIBRARY LIKE 'oqgraph_engine%') as `TRUE` from information_schema.plugins where PLUGIN_NAME='OQGRAPH'; +enable_query_log; === added directory 'mysql-test/suite/oqgraph/r' === added file 'mysql-test/suite/oqgraph/r/basic.result' --- a/mysql-test/suite/oqgraph/r/basic.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/oqgraph/r/basic.result 2010-01-04 08:27:50 +0000 @@ -0,0 +1,63 @@ +drop table if exists graph; +Warnings: +Note 1051 Unknown table 'graph' +CREATE TABLE graph ( +latch SMALLINT UNSIGNED NULL, +origid BIGINT UNSIGNED NULL, +destid BIGINT UNSIGNED NULL, +weight DOUBLE NULL, +seq BIGINT UNSIGNED NULL, +linkid BIGINT UNSIGNED NULL, +KEY (latch, origid, destid) USING HASH, +KEY (latch, destid, origid) USING HASH +) ENGINE=OQGRAPH; +delete from graph; +insert into graph(origid, destid) values (1,2), (2,1); +insert into graph(origid, destid) values (1,3), (3,1); +insert into graph(origid, destid) values (3,4), (4,3); +insert into graph(origid, destid) values (3,5), (5,3); +insert into graph(origid, destid) values (5,6), (6,5); +select * from graph where latch = 2 and origid = 1 and weight = 1; +latch origid destid weight seq linkid +2 1 NULL 1 3 3 +2 1 NULL 1 2 2 +select * from graph where latch = 2 and origid = 1 and weight = 2; +latch origid destid weight seq linkid +2 1 NULL 2 5 5 +2 1 NULL 2 4 4 +select * from graph +where latch = 2 and origid = 1 and (weight = 1 or weight = 2); +latch origid destid weight seq linkid +2 1 NULL 2 5 5 +2 1 NULL 2 4 4 +2 1 NULL 1 3 3 +2 1 NULL 1 2 2 +select * from graph where latch=1 and origid=1 and destid=6; +latch origid destid weight seq linkid +1 1 6 NULL 0 1 +1 1 6 1 1 3 +1 1 6 1 2 5 +1 1 6 1 3 6 +select * from graph where latch=1 and origid=1 and destid=4; +latch origid destid weight seq linkid +1 1 4 NULL 0 1 +1 1 4 1 1 3 +1 1 4 1 2 4 +select * from graph where latch=1 and origid=4 and destid=1; +latch origid destid weight seq linkid +1 4 1 NULL 0 4 +1 4 1 1 1 3 +1 4 1 1 2 1 +insert into graph (origid,destid) values (4,6); +delete from graph where origid=5; +delete from graph where origid=3 and destid=5; +select * from graph where latch=1 and origid=1 and destid=6; +latch origid destid weight seq linkid +1 1 6 NULL 0 1 +1 1 6 1 1 3 +1 1 6 1 2 4 +1 1 6 1 3 6 +select * from graph where latch=1 and origid=6 and destid=1; +latch origid destid weight seq linkid +truncate table graph; +drop table graph; === added directory 'mysql-test/suite/oqgraph/t' === added file 'mysql-test/suite/oqgraph/t/basic-master.opt' --- a/mysql-test/suite/oqgraph/t/basic-master.opt 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/oqgraph/t/basic-master.opt 2010-01-04 08:27:50 +0000 @@ -0,0 +1,2 @@ +$OQGRAPH_PLUGIN_OPT +$OQGRAPH_PLUGIN_LOAD === added file 'mysql-test/suite/oqgraph/t/basic.test' --- a/mysql-test/suite/oqgraph/t/basic.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/oqgraph/t/basic.test 2010-01-04 08:27:50 +0000 @@ -0,0 +1,45 @@ +-- source suite/oqgraph/include/have_oqgraph_engine.inc + +drop table if exists graph; + +CREATE TABLE graph ( + latch SMALLINT UNSIGNED NULL, + origid BIGINT UNSIGNED NULL, + destid BIGINT UNSIGNED NULL, + weight DOUBLE NULL, + seq BIGINT UNSIGNED NULL, + linkid BIGINT UNSIGNED NULL, + KEY (latch, origid, destid) USING HASH, + KEY (latch, destid, origid) USING HASH + ) ENGINE=OQGRAPH; + +delete from graph; + +insert into graph(origid, destid) values (1,2), (2,1); +insert into graph(origid, destid) values (1,3), (3,1); +insert into graph(origid, destid) values (3,4), (4,3); +insert into graph(origid, destid) values (3,5), (5,3); +insert into graph(origid, destid) values (5,6), (6,5); + +select * from graph where latch = 2 and origid = 1 and weight = 1; + +select * from graph where latch = 2 and origid = 1 and weight = 2; + +select * from graph +where latch = 2 and origid = 1 and (weight = 1 or weight = 2); + +select * from graph where latch=1 and origid=1 and destid=6; +select * from graph where latch=1 and origid=1 and destid=4; +select * from graph where latch=1 and origid=4 and destid=1; + +insert into graph (origid,destid) values (4,6); + +delete from graph where origid=5; +delete from graph where origid=3 and destid=5; + +select * from graph where latch=1 and origid=1 and destid=6; +select * from graph where latch=1 and origid=6 and destid=1; + +truncate table graph; + +drop table graph; === modified file 'mysql-test/suite/parts/t/rpl_partition.test' --- a/mysql-test/suite/parts/t/rpl_partition.test 2009-02-01 12:00:48 +0000 +++ b/mysql-test/suite/parts/t/rpl_partition.test 2010-03-29 19:07:45 +0000 @@ -1,6 +1,7 @@ --source include/have_partition.inc --source include/have_innodb.inc --source include/master-slave.inc +--source include/big_test.inc --vertical_results === added file 'mysql-test/suite/pbxt/r/pbxt_xa.result' --- a/mysql-test/suite/pbxt/r/pbxt_xa.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/pbxt/r/pbxt_xa.result 2010-03-24 22:12:39 +0000 @@ -0,0 +1,18 @@ +drop table if exists t1, t2; +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb; +CREATE TABLE t2 (b INT PRIMARY KEY) ENGINE=pbxt; +BEGIN; +SELECT @@log_bin; +@@log_bin +0 +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +COMMIT; +select * from t1; +a +1 +select * from t2; +b +2 +drop table t1, t2; +drop database pbxt; === added file 'mysql-test/suite/pbxt/t/pbxt_xa.test' --- a/mysql-test/suite/pbxt/t/pbxt_xa.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/pbxt/t/pbxt_xa.test 2010-03-24 22:12:39 +0000 @@ -0,0 +1,23 @@ +-- source include/have_innodb.inc + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings + +# +# bug lp:544173, xa crash with two 2pc-capable storage engines without binlog +# + +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb; +CREATE TABLE t2 (b INT PRIMARY KEY) ENGINE=pbxt; +BEGIN; +# verify that binlog is off +SELECT @@log_bin; +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +COMMIT; +select * from t1; +select * from t2; +drop table t1, t2; +drop database pbxt; + === added file 'mysql-test/suite/pbxt/t/suite.opt' --- a/mysql-test/suite/pbxt/t/suite.opt 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/pbxt/t/suite.opt 2010-03-30 12:36:49 +0000 @@ -0,0 +1 @@ +--default-storage-engine=pbxt === modified file 'mysql-test/suite/rpl/r/rpl_do_grant.result' --- a/mysql-test/suite/rpl/r/rpl_do_grant.result 2010-03-16 12:38:35 +0000 +++ b/mysql-test/suite/rpl/r/rpl_do_grant.result 2010-03-31 08:17:03 +0000 @@ -165,10 +165,9 @@ USE test; DROP FUNCTION bug42217_db.upgrade_del_func; DROP FUNCTION bug42217_db.upgrade_alter_func; DROP DATABASE bug42217_db; -DROP USER 'create_rout_db'@'localhost'; -call mtr.add_suppression("Slave: Operation DROP USER failed for 'create_rout_db'@'localhost' Error_code: 1396"); -USE mtr; call mtr.add_suppression("Slave: Operation DROP USER failed for 'create_rout_db'@'localhost' Error_code: 1396"); +stop slave; +DROP USER 'create_rout_db'@'localhost'; ######## BUG#49119 ####### ### i) test case from the 'how to repeat section' stop slave; === modified file 'mysql-test/suite/rpl/t/rpl_do_grant.test' --- a/mysql-test/suite/rpl/t/rpl_do_grant.test 2010-03-16 12:38:35 +0000 +++ b/mysql-test/suite/rpl/t/rpl_do_grant.test 2010-03-31 08:17:03 +0000 @@ -209,12 +209,18 @@ USE test; DROP FUNCTION bug42217_db.upgrade_del_func; DROP FUNCTION bug42217_db.upgrade_alter_func; DROP DATABASE bug42217_db; -DROP USER 'create_rout_db'@'localhost'; call mtr.add_suppression("Slave: Operation DROP USER failed for 'create_rout_db'@'localhost' Error_code: 1396"); + +sync_slave_with_master; + +# Drop the user that was already dropped on the slave connection slave; -USE mtr; -call mtr.add_suppression("Slave: Operation DROP USER failed for 'create_rout_db'@'localhost' Error_code: 1396"); +--disable_warnings +stop slave; +connection master; +DROP USER 'create_rout_db'@'localhost'; +--enable_warnings # BUG#49119: Master crashes when executing 'REVOKE ... ON # {PROCEDURE|FUNCTION} FROM ...' === modified file 'mysql-test/suite/rpl/t/rpl_name_const.test' --- a/mysql-test/suite/rpl/t/rpl_name_const.test 2009-04-08 23:42:51 +0000 +++ b/mysql-test/suite/rpl/t/rpl_name_const.test 2010-03-28 18:10:00 +0000 @@ -45,3 +45,4 @@ select * from t1 order by id; connection master; drop table t1; drop procedure test_procedure; +--sync_slave_with_master === modified file 'mysql-test/suite/rpl/t/rpl_row_basic_11bugs.test' --- a/mysql-test/suite/rpl/t/rpl_row_basic_11bugs.test 2007-12-12 10:14:59 +0000 +++ b/mysql-test/suite/rpl/t/rpl_row_basic_11bugs.test 2010-03-28 18:10:00 +0000 @@ -53,6 +53,7 @@ UPDATE t1 SET a=99 WHERE a = 0; SHOW BINLOG EVENTS; DROP TABLE t1; +--sync_slave_with_master # BUG#17620: Replicate (Row Based) Fails when Query Cache enabled on # slave === modified file 'mysql-test/suite/rpl/t/rpl_row_trig003.test' --- a/mysql-test/suite/rpl/t/rpl_row_trig003.test 2007-12-06 15:27:10 +0000 +++ b/mysql-test/suite/rpl/t/rpl_row_trig003.test 2010-03-29 19:07:45 +0000 @@ -149,6 +149,8 @@ DROP TABLE IF EXISTS test.t2; DROP TABLE IF EXISTS test.t3; --enable_warnings +sync_slave_with_master; + diff_files $MYSQLTEST_VARDIR/tmp/trg003_master.sql $MYSQLTEST_VARDIR/tmp/trg003_slave.sql; # End of 5.0 test case === modified file 'mysql-test/t/bug47671-master.opt' --- a/mysql-test/t/bug47671-master.opt 2009-11-25 06:55:49 +0000 +++ b/mysql-test/t/bug47671-master.opt 2010-03-28 18:10:00 +0000 @@ -1 +1 @@ ---default-character-set=utf8 --skip-character-set-client-handshake +--character-set-server=utf8 --skip-character-set-client-handshake === modified file 'mysql-test/t/ctype_latin1_de-master.opt' --- a/mysql-test/t/ctype_latin1_de-master.opt 2003-05-21 23:57:27 +0000 +++ b/mysql-test/t/ctype_latin1_de-master.opt 2010-03-28 18:10:00 +0000 @@ -1 +1 @@ ---default-character-set=latin1 --default-collation=latin1_german2_ci +--character-set-server=latin1 --default-collation=latin1_german2_ci === modified file 'mysql-test/t/ctype_ucs2_def-master.opt' --- a/mysql-test/t/ctype_ucs2_def-master.opt 2007-02-19 11:04:38 +0000 +++ b/mysql-test/t/ctype_ucs2_def-master.opt 2010-03-28 18:10:00 +0000 @@ -1 +1 @@ ---default-collation=ucs2_unicode_ci --default-character-set=ucs2,latin1 +--default-collation=ucs2_unicode_ci --character-set-server=ucs2,latin1 === modified file 'mysys/mf_keycache.c' --- a/mysys/mf_keycache.c 2009-12-03 11:19:05 +0000 +++ b/mysys/mf_keycache.c 2010-03-30 12:36:49 +0000 @@ -3924,6 +3924,12 @@ restart: uint next_status; uint hash_requests; + LINT_INIT(next_hash_link); + LINT_INIT(next_diskpos); + LINT_INIT(next_file); + LINT_INIT(next_status); + LINT_INIT(hash_requests); + total_found++; found++; KEYCACHE_DBUG_ASSERT(found <= keycache->blocks_used); === modified file 'mysys/my_gethostbyname.c' --- a/mysys/my_gethostbyname.c 2006-12-31 00:32:21 +0000 +++ b/mysys/my_gethostbyname.c 2010-03-30 12:36:49 +0000 @@ -91,9 +91,12 @@ extern pthread_mutex_t LOCK_gethostbynam is finished with the structure. */ -struct hostent *my_gethostbyname_r(const char *name, - struct hostent *result, char *buffer, - int buflen, int *h_errnop) +struct hostent * +my_gethostbyname_r(const char *name, + struct hostent *result __attribute__((unused)), + char *buffer __attribute__((unused)), + int buflen__attribute__((unused)), + int *h_errnop) { struct hostent *hp; pthread_mutex_lock(&LOCK_gethostbyname_r); === modified file 'sql/handler.cc' --- a/sql/handler.cc 2010-03-25 13:33:39 +0000 +++ b/sql/handler.cc 2010-03-31 08:17:03 +0000 @@ -4252,7 +4252,7 @@ int handler::read_multi_range_first(KEY_ */ int handler::read_multi_range_next(KEY_MULTI_RANGE **found_range_p) { - int result; + int result= 0; DBUG_ENTER("handler::read_multi_range_next"); /* We should not be called after the last call returned EOF. */ === modified file 'sql/item.cc' --- a/sql/item.cc 2010-03-15 11:51:23 +0000 +++ b/sql/item.cc 2010-03-31 08:17:03 +0000 @@ -7040,7 +7040,7 @@ bool Item_cache_int::cache_value() } -void Item_cache_int::store(Item *item, longlong val_arg) +void Item_cache_int::store_longlong(Item *item, longlong val_arg) { /* An explicit values is given, save it. */ value_cached= TRUE; === modified file 'sql/item.h' --- a/sql/item.h 2010-03-15 11:51:23 +0000 +++ b/sql/item.h 2010-03-31 08:17:03 +0000 @@ -1132,7 +1132,8 @@ class Field_enumerator { public: virtual void visit_field(Field *field)= 0; - virtual ~Field_enumerator() {}; /* purecov: inspected */ + virtual ~Field_enumerator() {}; /* purecov: inspected */ + Field_enumerator() {} /* Remove gcc warning */ }; @@ -3148,7 +3149,7 @@ public: Item_cache_int(enum_field_types field_type_arg): Item_cache(field_type_arg), value(0) {} - void store(Item *item, longlong val_arg); + void store_longlong(Item *item, longlong val_arg); double val_real(); longlong val_int(); String* val_str(String *str); === modified file 'sql/item_cmpfunc.cc' --- a/sql/item_cmpfunc.cc 2010-03-04 08:03:07 +0000 +++ b/sql/item_cmpfunc.cc 2010-03-28 18:10:00 +0000 @@ -879,7 +879,7 @@ get_time_value(THD *thd, Item ***item_ar Item_cache_int *cache= new Item_cache_int(); /* Mark the cache as non-const to prevent re-caching. */ cache->set_used_tables(1); - cache->store(item, value); + cache->store_longlong(item, value); *cache_arg= cache; *item_arg= cache_arg; } @@ -917,13 +917,13 @@ int Arg_comparator::set_cmp_func(Item_re cache->set_used_tables(1); if (!(*a)->is_datetime()) { - cache->store((*a), const_value); + cache->store_longlong((*a), const_value); a_cache= cache; a= (Item **)&a_cache; } else { - cache->store((*b), const_value); + cache->store_longlong((*b), const_value); b_cache= cache; b= (Item **)&b_cache; } @@ -1145,7 +1145,7 @@ get_datetime_value(THD *thd, Item ***ite Item_cache_int *cache= new Item_cache_int(MYSQL_TYPE_DATETIME); /* Mark the cache as non-const to prevent re-caching. */ cache->set_used_tables(1); - cache->store(item, value); + cache->store_longlong(item, value); *cache_arg= cache; *item_arg= cache_arg; } === modified file 'sql/item_create.cc' --- a/sql/item_create.cc 2010-03-04 08:03:07 +0000 +++ b/sql/item_create.cc 2010-03-29 19:07:45 +0000 @@ -76,7 +76,7 @@ public: @param thd The current thread @return An item representing the function call */ - virtual Item *create(THD *thd) = 0; + virtual Item *create_builder(THD *thd) = 0; protected: /** Constructor. */ @@ -101,7 +101,7 @@ public: @param arg1 The first argument of the function @return An item representing the function call */ - virtual Item *create(THD *thd, Item *arg1) = 0; + virtual Item *create_1_arg(THD *thd, Item *arg1) = 0; protected: /** Constructor. */ @@ -127,7 +127,7 @@ public: @param arg2 The second argument of the function @return An item representing the function call */ - virtual Item *create(THD *thd, Item *arg1, Item *arg2) = 0; + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2) = 0; protected: /** Constructor. */ @@ -154,7 +154,7 @@ public: @param arg3 The third argument of the function @return An item representing the function call */ - virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3) = 0; + virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) = 0; protected: /** Constructor. */ @@ -171,8 +171,8 @@ protected: class Create_sp_func : public Create_qfunc { public: - virtual Item *create(THD *thd, LEX_STRING db, LEX_STRING name, - bool use_explicit_name, List<Item> *item_list); + virtual Item *create_with_db(THD *thd, LEX_STRING db, LEX_STRING name, + bool use_explicit_name, List<Item> *item_list); static Create_sp_func s_singleton; @@ -217,7 +217,7 @@ protected: class Create_func_abs : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_abs s_singleton; @@ -230,7 +230,7 @@ protected: class Create_func_acos : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_acos s_singleton; @@ -243,7 +243,7 @@ protected: class Create_func_addtime : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_addtime s_singleton; @@ -256,7 +256,7 @@ protected: class Create_func_aes_encrypt : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_aes_encrypt s_singleton; @@ -269,7 +269,7 @@ protected: class Create_func_aes_decrypt : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_aes_decrypt s_singleton; @@ -283,7 +283,7 @@ protected: class Create_func_area : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_area s_singleton; @@ -298,7 +298,7 @@ protected: class Create_func_as_wkb : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_as_wkb s_singleton; @@ -313,7 +313,7 @@ protected: class Create_func_as_wkt : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_as_wkt s_singleton; @@ -327,7 +327,7 @@ protected: class Create_func_asin : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_asin s_singleton; @@ -353,7 +353,7 @@ protected: class Create_func_benchmark : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_benchmark s_singleton; @@ -366,7 +366,7 @@ protected: class Create_func_bin : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_bin s_singleton; @@ -379,7 +379,7 @@ protected: class Create_func_bit_count : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_bit_count s_singleton; @@ -392,7 +392,7 @@ protected: class Create_func_bit_length : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_bit_length s_singleton; @@ -405,7 +405,7 @@ protected: class Create_func_ceiling : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_ceiling s_singleton; @@ -419,7 +419,7 @@ protected: class Create_func_centroid : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_centroid s_singleton; @@ -433,7 +433,7 @@ protected: class Create_func_char_length : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_char_length s_singleton; @@ -446,7 +446,7 @@ protected: class Create_func_coercibility : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_coercibility s_singleton; @@ -459,7 +459,7 @@ protected: class Create_func_compress : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_compress s_singleton; @@ -498,7 +498,7 @@ protected: class Create_func_connection_id : public Create_func_arg0 { public: - virtual Item *create(THD *thd); + virtual Item *create_builder(THD *thd); static Create_func_connection_id s_singleton; @@ -512,7 +512,7 @@ protected: class Create_func_contains : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_contains s_singleton; @@ -526,7 +526,7 @@ protected: class Create_func_conv : public Create_func_arg3 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3); + virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3); static Create_func_conv s_singleton; @@ -539,7 +539,7 @@ protected: class Create_func_convert_tz : public Create_func_arg3 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3); + virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3); static Create_func_convert_tz s_singleton; @@ -552,7 +552,7 @@ protected: class Create_func_cos : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_cos s_singleton; @@ -565,7 +565,7 @@ protected: class Create_func_cot : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_cot s_singleton; @@ -578,7 +578,7 @@ protected: class Create_func_crc32 : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_crc32 s_singleton; @@ -592,7 +592,7 @@ protected: class Create_func_crosses : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_crosses s_singleton; @@ -606,7 +606,7 @@ protected: class Create_func_date_format : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_date_format s_singleton; @@ -619,7 +619,7 @@ protected: class Create_func_datediff : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_datediff s_singleton; @@ -632,7 +632,7 @@ protected: class Create_func_dayname : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_dayname s_singleton; @@ -645,7 +645,7 @@ protected: class Create_func_dayofmonth : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_dayofmonth s_singleton; @@ -658,7 +658,7 @@ protected: class Create_func_dayofweek : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_dayofweek s_singleton; @@ -671,7 +671,7 @@ protected: class Create_func_dayofyear : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_dayofyear s_singleton; @@ -684,7 +684,7 @@ protected: class Create_func_decode : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_decode s_singleton; @@ -697,7 +697,7 @@ protected: class Create_func_degrees : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_degrees s_singleton; @@ -737,7 +737,7 @@ protected: class Create_func_dimension : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_dimension s_singleton; @@ -752,7 +752,7 @@ protected: class Create_func_disjoint : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_disjoint s_singleton; @@ -779,7 +779,7 @@ protected: class Create_func_encode : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_encode s_singleton; @@ -806,7 +806,7 @@ protected: class Create_func_endpoint : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_endpoint s_singleton; @@ -821,7 +821,7 @@ protected: class Create_func_envelope : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_envelope s_singleton; @@ -836,7 +836,7 @@ protected: class Create_func_equals : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_equals s_singleton; @@ -850,7 +850,7 @@ protected: class Create_func_exp : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_exp s_singleton; @@ -877,7 +877,7 @@ protected: class Create_func_exteriorring : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_exteriorring s_singleton; @@ -904,7 +904,7 @@ protected: class Create_func_find_in_set : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_find_in_set s_singleton; @@ -917,7 +917,7 @@ protected: class Create_func_floor : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_floor s_singleton; @@ -930,7 +930,7 @@ protected: class Create_func_format : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_format s_singleton; @@ -943,7 +943,7 @@ protected: class Create_func_found_rows : public Create_func_arg0 { public: - virtual Item *create(THD *thd); + virtual Item *create_builder(THD *thd); static Create_func_found_rows s_singleton; @@ -956,7 +956,7 @@ protected: class Create_func_from_days : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_from_days s_singleton; @@ -1013,7 +1013,7 @@ protected: class Create_func_geometry_type : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_geometry_type s_singleton; @@ -1028,7 +1028,7 @@ protected: class Create_func_geometryn : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_geometryn s_singleton; @@ -1042,7 +1042,7 @@ protected: class Create_func_get_lock : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_get_lock s_singleton; @@ -1056,7 +1056,7 @@ protected: class Create_func_glength : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_glength s_singleton; @@ -1083,7 +1083,7 @@ protected: class Create_func_hex : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_hex s_singleton; @@ -1096,7 +1096,7 @@ protected: class Create_func_ifnull : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_ifnull s_singleton; @@ -1109,7 +1109,7 @@ protected: class Create_func_inet_ntoa : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_inet_ntoa s_singleton; @@ -1122,7 +1122,7 @@ protected: class Create_func_inet_aton : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_inet_aton s_singleton; @@ -1135,7 +1135,7 @@ protected: class Create_func_instr : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_instr s_singleton; @@ -1149,7 +1149,7 @@ protected: class Create_func_interiorringn : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_interiorringn s_singleton; @@ -1164,7 +1164,7 @@ protected: class Create_func_intersects : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_intersects s_singleton; @@ -1178,7 +1178,7 @@ protected: class Create_func_is_free_lock : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_is_free_lock s_singleton; @@ -1191,7 +1191,7 @@ protected: class Create_func_is_used_lock : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_is_used_lock s_singleton; @@ -1205,7 +1205,7 @@ protected: class Create_func_isclosed : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_isclosed s_singleton; @@ -1220,7 +1220,7 @@ protected: class Create_func_isempty : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_isempty s_singleton; @@ -1234,7 +1234,7 @@ protected: class Create_func_isnull : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_isnull s_singleton; @@ -1248,7 +1248,7 @@ protected: class Create_func_issimple : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_issimple s_singleton; @@ -1262,7 +1262,7 @@ protected: class Create_func_last_day : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_last_day s_singleton; @@ -1288,7 +1288,7 @@ protected: class Create_func_lcase : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_lcase s_singleton; @@ -1314,7 +1314,7 @@ protected: class Create_func_length : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_length s_singleton; @@ -1327,7 +1327,7 @@ protected: class Create_func_ln : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_ln s_singleton; @@ -1340,7 +1340,7 @@ protected: class Create_func_load_file : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_load_file s_singleton; @@ -1379,7 +1379,7 @@ protected: class Create_func_log10 : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_log10 s_singleton; @@ -1392,7 +1392,7 @@ protected: class Create_func_log2 : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_log2 s_singleton; @@ -1405,7 +1405,7 @@ protected: class Create_func_lpad : public Create_func_arg3 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3); + virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3); static Create_func_lpad s_singleton; @@ -1418,7 +1418,7 @@ protected: class Create_func_ltrim : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_ltrim s_singleton; @@ -1431,7 +1431,7 @@ protected: class Create_func_makedate : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_makedate s_singleton; @@ -1444,7 +1444,7 @@ protected: class Create_func_maketime : public Create_func_arg3 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3); + virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3); static Create_func_maketime s_singleton; @@ -1483,7 +1483,7 @@ protected: class Create_func_md5 : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_md5 s_singleton; @@ -1496,7 +1496,7 @@ protected: class Create_func_monthname : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_monthname s_singleton; @@ -1509,7 +1509,7 @@ protected: class Create_func_name_const : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_name_const s_singleton; @@ -1522,7 +1522,7 @@ protected: class Create_func_nullif : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_nullif s_singleton; @@ -1536,7 +1536,7 @@ protected: class Create_func_numgeometries : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_numgeometries s_singleton; @@ -1551,7 +1551,7 @@ protected: class Create_func_numinteriorring : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_numinteriorring s_singleton; @@ -1566,7 +1566,7 @@ protected: class Create_func_numpoints : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_numpoints s_singleton; @@ -1580,7 +1580,7 @@ protected: class Create_func_oct : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_oct s_singleton; @@ -1593,7 +1593,7 @@ protected: class Create_func_ord : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_ord s_singleton; @@ -1607,7 +1607,7 @@ protected: class Create_func_overlaps : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_overlaps s_singleton; @@ -1621,7 +1621,7 @@ protected: class Create_func_period_add : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_period_add s_singleton; @@ -1634,7 +1634,7 @@ protected: class Create_func_period_diff : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_period_diff s_singleton; @@ -1647,7 +1647,7 @@ protected: class Create_func_pi : public Create_func_arg0 { public: - virtual Item *create(THD *thd); + virtual Item *create_builder(THD *thd); static Create_func_pi s_singleton; @@ -1661,7 +1661,7 @@ protected: class Create_func_pointn : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_pointn s_singleton; @@ -1675,7 +1675,7 @@ protected: class Create_func_pow : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_pow s_singleton; @@ -1688,7 +1688,7 @@ protected: class Create_func_quote : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_quote s_singleton; @@ -1701,7 +1701,7 @@ protected: class Create_func_radians : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_radians s_singleton; @@ -1727,7 +1727,7 @@ protected: class Create_func_release_lock : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_release_lock s_singleton; @@ -1740,7 +1740,7 @@ protected: class Create_func_reverse : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_reverse s_singleton; @@ -1766,7 +1766,7 @@ protected: class Create_func_row_count : public Create_func_arg0 { public: - virtual Item *create(THD *thd); + virtual Item *create_builder(THD *thd); static Create_func_row_count s_singleton; @@ -1779,7 +1779,7 @@ protected: class Create_func_rpad : public Create_func_arg3 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3); + virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3); static Create_func_rpad s_singleton; @@ -1792,7 +1792,7 @@ protected: class Create_func_rtrim : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_rtrim s_singleton; @@ -1805,7 +1805,7 @@ protected: class Create_func_sec_to_time : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_sec_to_time s_singleton; @@ -1818,7 +1818,7 @@ protected: class Create_func_sha : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_sha s_singleton; @@ -1831,7 +1831,7 @@ protected: class Create_func_sign : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_sign s_singleton; @@ -1844,7 +1844,7 @@ protected: class Create_func_sin : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_sin s_singleton; @@ -1857,7 +1857,7 @@ protected: class Create_func_sleep : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_sleep s_singleton; @@ -1870,7 +1870,7 @@ protected: class Create_func_soundex : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_soundex s_singleton; @@ -1883,7 +1883,7 @@ protected: class Create_func_space : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_space s_singleton; @@ -1896,7 +1896,7 @@ protected: class Create_func_sqrt : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_sqrt s_singleton; @@ -1910,7 +1910,7 @@ protected: class Create_func_srid : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_srid s_singleton; @@ -1925,7 +1925,7 @@ protected: class Create_func_startpoint : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_startpoint s_singleton; @@ -1939,7 +1939,7 @@ protected: class Create_func_str_to_date : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_str_to_date s_singleton; @@ -1952,7 +1952,7 @@ protected: class Create_func_strcmp : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_strcmp s_singleton; @@ -1965,7 +1965,7 @@ protected: class Create_func_substr_index : public Create_func_arg3 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3); + virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3); static Create_func_substr_index s_singleton; @@ -1978,7 +1978,7 @@ protected: class Create_func_subtime : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_subtime s_singleton; @@ -1991,7 +1991,7 @@ protected: class Create_func_tan : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_tan s_singleton; @@ -2004,7 +2004,7 @@ protected: class Create_func_time_format : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_time_format s_singleton; @@ -2017,7 +2017,7 @@ protected: class Create_func_time_to_sec : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_time_to_sec s_singleton; @@ -2030,7 +2030,7 @@ protected: class Create_func_timediff : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_timediff s_singleton; @@ -2043,7 +2043,7 @@ protected: class Create_func_to_days : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_to_days s_singleton; @@ -2057,7 +2057,7 @@ protected: class Create_func_touches : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_touches s_singleton; @@ -2071,7 +2071,7 @@ protected: class Create_func_ucase : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_ucase s_singleton; @@ -2084,7 +2084,7 @@ protected: class Create_func_uncompress : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_uncompress s_singleton; @@ -2097,7 +2097,7 @@ protected: class Create_func_uncompressed_length : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_uncompressed_length s_singleton; @@ -2110,7 +2110,7 @@ protected: class Create_func_unhex : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_unhex s_singleton; @@ -2136,7 +2136,7 @@ protected: class Create_func_uuid : public Create_func_arg0 { public: - virtual Item *create(THD *thd); + virtual Item *create_builder(THD *thd); static Create_func_uuid s_singleton; @@ -2149,7 +2149,7 @@ protected: class Create_func_uuid_short : public Create_func_arg0 { public: - virtual Item *create(THD *thd); + virtual Item *create_builder(THD *thd); static Create_func_uuid_short s_singleton; @@ -2162,7 +2162,7 @@ protected: class Create_func_version : public Create_func_arg0 { public: - virtual Item *create(THD *thd); + virtual Item *create_builder(THD *thd); static Create_func_version s_singleton; @@ -2175,7 +2175,7 @@ protected: class Create_func_weekday : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_weekday s_singleton; @@ -2188,7 +2188,7 @@ protected: class Create_func_weekofyear : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_weekofyear s_singleton; @@ -2202,7 +2202,7 @@ protected: class Create_func_within : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_within s_singleton; @@ -2217,7 +2217,7 @@ protected: class Create_func_x : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_x s_singleton; @@ -2231,7 +2231,7 @@ protected: class Create_func_xml_extractvalue : public Create_func_arg2 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2); + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); static Create_func_xml_extractvalue s_singleton; @@ -2244,7 +2244,7 @@ protected: class Create_func_xml_update : public Create_func_arg3 { public: - virtual Item *create(THD *thd, Item *arg1, Item *arg2, Item *arg3); + virtual Item *create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3); static Create_func_xml_update s_singleton; @@ -2258,7 +2258,7 @@ protected: class Create_func_y : public Create_func_arg1 { public: - virtual Item *create(THD *thd, Item *arg1); + virtual Item *create_1_arg(THD *thd, Item *arg1); static Create_func_y s_singleton; @@ -2353,7 +2353,7 @@ Create_qfunc::create(THD *thd, LEX_STRIN if (thd->lex->copy_db_to(&db.str, &db.length)) return NULL; - return create(thd, db, name, false, item_list); + return create_with_db(thd, db, name, false, item_list); } @@ -2470,8 +2470,8 @@ Create_udf_func::create(THD *thd, udf_fu Create_sp_func Create_sp_func::s_singleton; Item* -Create_sp_func::create(THD *thd, LEX_STRING db, LEX_STRING name, - bool use_explicit_name, List<Item> *item_list) +Create_sp_func::create_with_db(THD *thd, LEX_STRING db, LEX_STRING name, + bool use_explicit_name, List<Item> *item_list) { int arg_count= 0; Item *func= NULL; @@ -2538,7 +2538,7 @@ Create_func_arg0::create(THD *thd, LEX_S return NULL; } - return create(thd); + return create_builder(thd); } @@ -2564,7 +2564,7 @@ Create_func_arg1::create(THD *thd, LEX_S return NULL; } - return create(thd, param_1); + return create_1_arg(thd, param_1); } @@ -2592,7 +2592,7 @@ Create_func_arg2::create(THD *thd, LEX_S return NULL; } - return create(thd, param_1, param_2); + return create_2_arg(thd, param_1, param_2); } @@ -2622,14 +2622,14 @@ Create_func_arg3::create(THD *thd, LEX_S return NULL; } - return create(thd, param_1, param_2, param_3); + return create_3_arg(thd, param_1, param_2, param_3); } Create_func_abs Create_func_abs::s_singleton; Item* -Create_func_abs::create(THD *thd, Item *arg1) +Create_func_abs::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_abs(arg1); } @@ -2638,7 +2638,7 @@ Create_func_abs::create(THD *thd, Item * Create_func_acos Create_func_acos::s_singleton; Item* -Create_func_acos::create(THD *thd, Item *arg1) +Create_func_acos::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_acos(arg1); } @@ -2647,7 +2647,7 @@ Create_func_acos::create(THD *thd, Item Create_func_addtime Create_func_addtime::s_singleton; Item* -Create_func_addtime::create(THD *thd, Item *arg1, Item *arg2) +Create_func_addtime::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_add_time(arg1, arg2, 0, 0); } @@ -2656,7 +2656,7 @@ Create_func_addtime::create(THD *thd, It Create_func_aes_encrypt Create_func_aes_encrypt::s_singleton; Item* -Create_func_aes_encrypt::create(THD *thd, Item *arg1, Item *arg2) +Create_func_aes_encrypt::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_aes_encrypt(arg1, arg2); } @@ -2665,7 +2665,7 @@ Create_func_aes_encrypt::create(THD *thd Create_func_aes_decrypt Create_func_aes_decrypt::s_singleton; Item* -Create_func_aes_decrypt::create(THD *thd, Item *arg1, Item *arg2) +Create_func_aes_decrypt::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_aes_decrypt(arg1, arg2); } @@ -2675,7 +2675,7 @@ Create_func_aes_decrypt::create(THD *thd Create_func_area Create_func_area::s_singleton; Item* -Create_func_area::create(THD *thd, Item *arg1) +Create_func_area::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_area(arg1); } @@ -2686,7 +2686,7 @@ Create_func_area::create(THD *thd, Item Create_func_as_wkb Create_func_as_wkb::s_singleton; Item* -Create_func_as_wkb::create(THD *thd, Item *arg1) +Create_func_as_wkb::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_as_wkb(arg1); } @@ -2697,7 +2697,7 @@ Create_func_as_wkb::create(THD *thd, Ite Create_func_as_wkt Create_func_as_wkt::s_singleton; Item* -Create_func_as_wkt::create(THD *thd, Item *arg1) +Create_func_as_wkt::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_as_wkt(arg1); } @@ -2707,7 +2707,7 @@ Create_func_as_wkt::create(THD *thd, Ite Create_func_asin Create_func_asin::s_singleton; Item* -Create_func_asin::create(THD *thd, Item *arg1) +Create_func_asin::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_asin(arg1); } @@ -2753,7 +2753,7 @@ Create_func_atan::create_native(THD *thd Create_func_benchmark Create_func_benchmark::s_singleton; Item* -Create_func_benchmark::create(THD *thd, Item *arg1, Item *arg2) +Create_func_benchmark::create_2_arg(THD *thd, Item *arg1, Item *arg2) { thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); return new (thd->mem_root) Item_func_benchmark(arg1, arg2); @@ -2763,7 +2763,7 @@ Create_func_benchmark::create(THD *thd, Create_func_bin Create_func_bin::s_singleton; Item* -Create_func_bin::create(THD *thd, Item *arg1) +Create_func_bin::create_1_arg(THD *thd, Item *arg1) { Item *i10= new (thd->mem_root) Item_int((int32) 10,2); Item *i2= new (thd->mem_root) Item_int((int32) 2,1); @@ -2774,7 +2774,7 @@ Create_func_bin::create(THD *thd, Item * Create_func_bit_count Create_func_bit_count::s_singleton; Item* -Create_func_bit_count::create(THD *thd, Item *arg1) +Create_func_bit_count::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_bit_count(arg1); } @@ -2783,7 +2783,7 @@ Create_func_bit_count::create(THD *thd, Create_func_bit_length Create_func_bit_length::s_singleton; Item* -Create_func_bit_length::create(THD *thd, Item *arg1) +Create_func_bit_length::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_bit_length(arg1); } @@ -2792,7 +2792,7 @@ Create_func_bit_length::create(THD *thd, Create_func_ceiling Create_func_ceiling::s_singleton; Item* -Create_func_ceiling::create(THD *thd, Item *arg1) +Create_func_ceiling::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_ceiling(arg1); } @@ -2802,7 +2802,7 @@ Create_func_ceiling::create(THD *thd, It Create_func_centroid Create_func_centroid::s_singleton; Item* -Create_func_centroid::create(THD *thd, Item *arg1) +Create_func_centroid::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_centroid(arg1); } @@ -2812,7 +2812,7 @@ Create_func_centroid::create(THD *thd, I Create_func_char_length Create_func_char_length::s_singleton; Item* -Create_func_char_length::create(THD *thd, Item *arg1) +Create_func_char_length::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_char_length(arg1); } @@ -2821,7 +2821,7 @@ Create_func_char_length::create(THD *thd Create_func_coercibility Create_func_coercibility::s_singleton; Item* -Create_func_coercibility::create(THD *thd, Item *arg1) +Create_func_coercibility::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_coercibility(arg1); } @@ -2873,7 +2873,7 @@ Create_func_concat_ws::create_native(THD Create_func_compress Create_func_compress::s_singleton; Item* -Create_func_compress::create(THD *thd, Item *arg1) +Create_func_compress::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_compress(arg1); } @@ -2882,7 +2882,7 @@ Create_func_compress::create(THD *thd, I Create_func_connection_id Create_func_connection_id::s_singleton; Item* -Create_func_connection_id::create(THD *thd) +Create_func_connection_id::create_builder(THD *thd) { thd->lex->safe_to_cache_query= 0; return new (thd->mem_root) Item_func_connection_id(); @@ -2893,7 +2893,7 @@ Create_func_connection_id::create(THD *t Create_func_contains Create_func_contains::s_singleton; Item* -Create_func_contains::create(THD *thd, Item *arg1, Item *arg2) +Create_func_contains::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2, Item_func::SP_CONTAINS_FUNC); @@ -2904,7 +2904,7 @@ Create_func_contains::create(THD *thd, I Create_func_conv Create_func_conv::s_singleton; Item* -Create_func_conv::create(THD *thd, Item *arg1, Item *arg2, Item *arg3) +Create_func_conv::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) { return new (thd->mem_root) Item_func_conv(arg1, arg2, arg3); } @@ -2913,7 +2913,7 @@ Create_func_conv::create(THD *thd, Item Create_func_convert_tz Create_func_convert_tz::s_singleton; Item* -Create_func_convert_tz::create(THD *thd, Item *arg1, Item *arg2, Item *arg3) +Create_func_convert_tz::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) { return new (thd->mem_root) Item_func_convert_tz(arg1, arg2, arg3); } @@ -2922,7 +2922,7 @@ Create_func_convert_tz::create(THD *thd, Create_func_cos Create_func_cos::s_singleton; Item* -Create_func_cos::create(THD *thd, Item *arg1) +Create_func_cos::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_cos(arg1); } @@ -2931,7 +2931,7 @@ Create_func_cos::create(THD *thd, Item * Create_func_cot Create_func_cot::s_singleton; Item* -Create_func_cot::create(THD *thd, Item *arg1) +Create_func_cot::create_1_arg(THD *thd, Item *arg1) { Item *i1= new (thd->mem_root) Item_int((char*) "1", 1, 1); Item *i2= new (thd->mem_root) Item_func_tan(arg1); @@ -2942,7 +2942,7 @@ Create_func_cot::create(THD *thd, Item * Create_func_crc32 Create_func_crc32::s_singleton; Item* -Create_func_crc32::create(THD *thd, Item *arg1) +Create_func_crc32::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_crc32(arg1); } @@ -2952,7 +2952,7 @@ Create_func_crc32::create(THD *thd, Item Create_func_crosses Create_func_crosses::s_singleton; Item* -Create_func_crosses::create(THD *thd, Item *arg1, Item *arg2) +Create_func_crosses::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2, Item_func::SP_CROSSES_FUNC); @@ -2963,7 +2963,7 @@ Create_func_crosses::create(THD *thd, It Create_func_date_format Create_func_date_format::s_singleton; Item* -Create_func_date_format::create(THD *thd, Item *arg1, Item *arg2) +Create_func_date_format::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_date_format(arg1, arg2, 0); } @@ -2972,7 +2972,7 @@ Create_func_date_format::create(THD *thd Create_func_datediff Create_func_datediff::s_singleton; Item* -Create_func_datediff::create(THD *thd, Item *arg1, Item *arg2) +Create_func_datediff::create_2_arg(THD *thd, Item *arg1, Item *arg2) { Item *i1= new (thd->mem_root) Item_func_to_days(arg1); Item *i2= new (thd->mem_root) Item_func_to_days(arg2); @@ -2984,7 +2984,7 @@ Create_func_datediff::create(THD *thd, I Create_func_dayname Create_func_dayname::s_singleton; Item* -Create_func_dayname::create(THD *thd, Item *arg1) +Create_func_dayname::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_dayname(arg1); } @@ -2993,7 +2993,7 @@ Create_func_dayname::create(THD *thd, It Create_func_dayofmonth Create_func_dayofmonth::s_singleton; Item* -Create_func_dayofmonth::create(THD *thd, Item *arg1) +Create_func_dayofmonth::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_dayofmonth(arg1); } @@ -3002,7 +3002,7 @@ Create_func_dayofmonth::create(THD *thd, Create_func_dayofweek Create_func_dayofweek::s_singleton; Item* -Create_func_dayofweek::create(THD *thd, Item *arg1) +Create_func_dayofweek::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_weekday(arg1, 1); } @@ -3011,7 +3011,7 @@ Create_func_dayofweek::create(THD *thd, Create_func_dayofyear Create_func_dayofyear::s_singleton; Item* -Create_func_dayofyear::create(THD *thd, Item *arg1) +Create_func_dayofyear::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_dayofyear(arg1); } @@ -3020,7 +3020,7 @@ Create_func_dayofyear::create(THD *thd, Create_func_decode Create_func_decode::s_singleton; Item* -Create_func_decode::create(THD *thd, Item *arg1, Item *arg2) +Create_func_decode::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_decode(arg1, arg2); } @@ -3029,7 +3029,7 @@ Create_func_decode::create(THD *thd, Ite Create_func_degrees Create_func_degrees::s_singleton; Item* -Create_func_degrees::create(THD *thd, Item *arg1) +Create_func_degrees::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_units((char*) "degrees", arg1, 180/M_PI, 0.0); @@ -3114,7 +3114,7 @@ Create_func_des_encrypt::create_native(T Create_func_dimension Create_func_dimension::s_singleton; Item* -Create_func_dimension::create(THD *thd, Item *arg1) +Create_func_dimension::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_dimension(arg1); } @@ -3125,7 +3125,7 @@ Create_func_dimension::create(THD *thd, Create_func_disjoint Create_func_disjoint::s_singleton; Item* -Create_func_disjoint::create(THD *thd, Item *arg1, Item *arg2) +Create_func_disjoint::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2, Item_func::SP_DISJOINT_FUNC); @@ -3157,7 +3157,7 @@ Create_func_elt::create_native(THD *thd, Create_func_encode Create_func_encode::s_singleton; Item* -Create_func_encode::create(THD *thd, Item *arg1, Item *arg2) +Create_func_encode::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_encode(arg1, arg2); } @@ -3205,7 +3205,7 @@ Create_func_encrypt::create_native(THD * Create_func_endpoint Create_func_endpoint::s_singleton; Item* -Create_func_endpoint::create(THD *thd, Item *arg1) +Create_func_endpoint::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_spatial_decomp(arg1, Item_func::SP_ENDPOINT); @@ -3217,7 +3217,7 @@ Create_func_endpoint::create(THD *thd, I Create_func_envelope Create_func_envelope::s_singleton; Item* -Create_func_envelope::create(THD *thd, Item *arg1) +Create_func_envelope::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_envelope(arg1); } @@ -3228,7 +3228,7 @@ Create_func_envelope::create(THD *thd, I Create_func_equals Create_func_equals::s_singleton; Item* -Create_func_equals::create(THD *thd, Item *arg1, Item *arg2) +Create_func_equals::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2, Item_func::SP_EQUALS_FUNC); @@ -3239,7 +3239,7 @@ Create_func_equals::create(THD *thd, Ite Create_func_exp Create_func_exp::s_singleton; Item* -Create_func_exp::create(THD *thd, Item *arg1) +Create_func_exp::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_exp(arg1); } @@ -3302,7 +3302,7 @@ Create_func_export_set::create_native(TH Create_func_exteriorring Create_func_exteriorring::s_singleton; Item* -Create_func_exteriorring::create(THD *thd, Item *arg1) +Create_func_exteriorring::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_spatial_decomp(arg1, Item_func::SP_EXTERIORRING); @@ -3334,7 +3334,7 @@ Create_func_field::create_native(THD *th Create_func_find_in_set Create_func_find_in_set::s_singleton; Item* -Create_func_find_in_set::create(THD *thd, Item *arg1, Item *arg2) +Create_func_find_in_set::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_find_in_set(arg1, arg2); } @@ -3343,7 +3343,7 @@ Create_func_find_in_set::create(THD *thd Create_func_floor Create_func_floor::s_singleton; Item* -Create_func_floor::create(THD *thd, Item *arg1) +Create_func_floor::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_floor(arg1); } @@ -3352,7 +3352,7 @@ Create_func_floor::create(THD *thd, Item Create_func_format Create_func_format::s_singleton; Item* -Create_func_format::create(THD *thd, Item *arg1, Item *arg2) +Create_func_format::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_format(arg1, arg2); } @@ -3361,7 +3361,7 @@ Create_func_format::create(THD *thd, Ite Create_func_found_rows Create_func_found_rows::s_singleton; Item* -Create_func_found_rows::create(THD *thd) +Create_func_found_rows::create_builder(THD *thd) { thd->lex->set_stmt_unsafe(); thd->lex->safe_to_cache_query= 0; @@ -3372,7 +3372,7 @@ Create_func_found_rows::create(THD *thd) Create_func_from_days Create_func_from_days::s_singleton; Item* -Create_func_from_days::create(THD *thd, Item *arg1) +Create_func_from_days::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_from_days(arg1); } @@ -3500,7 +3500,7 @@ Create_func_geometry_from_wkb::create_na Create_func_geometry_type Create_func_geometry_type::s_singleton; Item* -Create_func_geometry_type::create(THD *thd, Item *arg1) +Create_func_geometry_type::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_geometry_type(arg1); } @@ -3511,7 +3511,7 @@ Create_func_geometry_type::create(THD *t Create_func_geometryn Create_func_geometryn::s_singleton; Item* -Create_func_geometryn::create(THD *thd, Item *arg1, Item *arg2) +Create_func_geometryn::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_spatial_decomp_n(arg1, arg2, Item_func::SP_GEOMETRYN); @@ -3522,7 +3522,7 @@ Create_func_geometryn::create(THD *thd, Create_func_get_lock Create_func_get_lock::s_singleton; Item* -Create_func_get_lock::create(THD *thd, Item *arg1, Item *arg2) +Create_func_get_lock::create_2_arg(THD *thd, Item *arg1, Item *arg2) { thd->lex->set_stmt_unsafe(); thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); @@ -3534,7 +3534,7 @@ Create_func_get_lock::create(THD *thd, I Create_func_glength Create_func_glength::s_singleton; Item* -Create_func_glength::create(THD *thd, Item *arg1) +Create_func_glength::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_glength(arg1); } @@ -3565,7 +3565,7 @@ Create_func_greatest::create_native(THD Create_func_hex Create_func_hex::s_singleton; Item* -Create_func_hex::create(THD *thd, Item *arg1) +Create_func_hex::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_hex(arg1); } @@ -3574,7 +3574,7 @@ Create_func_hex::create(THD *thd, Item * Create_func_ifnull Create_func_ifnull::s_singleton; Item* -Create_func_ifnull::create(THD *thd, Item *arg1, Item *arg2) +Create_func_ifnull::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_ifnull(arg1, arg2); } @@ -3583,7 +3583,7 @@ Create_func_ifnull::create(THD *thd, Ite Create_func_inet_ntoa Create_func_inet_ntoa::s_singleton; Item* -Create_func_inet_ntoa::create(THD *thd, Item *arg1) +Create_func_inet_ntoa::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_inet_ntoa(arg1); } @@ -3592,7 +3592,7 @@ Create_func_inet_ntoa::create(THD *thd, Create_func_inet_aton Create_func_inet_aton::s_singleton; Item* -Create_func_inet_aton::create(THD *thd, Item *arg1) +Create_func_inet_aton::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_inet_aton(arg1); } @@ -3601,7 +3601,7 @@ Create_func_inet_aton::create(THD *thd, Create_func_instr Create_func_instr::s_singleton; Item* -Create_func_instr::create(THD *thd, Item *arg1, Item *arg2) +Create_func_instr::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_locate(arg1, arg2); } @@ -3611,7 +3611,7 @@ Create_func_instr::create(THD *thd, Item Create_func_interiorringn Create_func_interiorringn::s_singleton; Item* -Create_func_interiorringn::create(THD *thd, Item *arg1, Item *arg2) +Create_func_interiorringn::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_spatial_decomp_n(arg1, arg2, Item_func::SP_INTERIORRINGN); @@ -3623,7 +3623,7 @@ Create_func_interiorringn::create(THD *t Create_func_intersects Create_func_intersects::s_singleton; Item* -Create_func_intersects::create(THD *thd, Item *arg1, Item *arg2) +Create_func_intersects::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2, Item_func::SP_INTERSECTS_FUNC); @@ -3634,7 +3634,7 @@ Create_func_intersects::create(THD *thd, Create_func_is_free_lock Create_func_is_free_lock::s_singleton; Item* -Create_func_is_free_lock::create(THD *thd, Item *arg1) +Create_func_is_free_lock::create_1_arg(THD *thd, Item *arg1) { thd->lex->set_stmt_unsafe(); thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); @@ -3645,7 +3645,7 @@ Create_func_is_free_lock::create(THD *th Create_func_is_used_lock Create_func_is_used_lock::s_singleton; Item* -Create_func_is_used_lock::create(THD *thd, Item *arg1) +Create_func_is_used_lock::create_1_arg(THD *thd, Item *arg1) { thd->lex->set_stmt_unsafe(); thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); @@ -3657,7 +3657,7 @@ Create_func_is_used_lock::create(THD *th Create_func_isclosed Create_func_isclosed::s_singleton; Item* -Create_func_isclosed::create(THD *thd, Item *arg1) +Create_func_isclosed::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_isclosed(arg1); } @@ -3668,7 +3668,7 @@ Create_func_isclosed::create(THD *thd, I Create_func_isempty Create_func_isempty::s_singleton; Item* -Create_func_isempty::create(THD *thd, Item *arg1) +Create_func_isempty::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_isempty(arg1); } @@ -3678,7 +3678,7 @@ Create_func_isempty::create(THD *thd, It Create_func_isnull Create_func_isnull::s_singleton; Item* -Create_func_isnull::create(THD *thd, Item *arg1) +Create_func_isnull::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_isnull(arg1); } @@ -3688,7 +3688,7 @@ Create_func_isnull::create(THD *thd, Ite Create_func_issimple Create_func_issimple::s_singleton; Item* -Create_func_issimple::create(THD *thd, Item *arg1) +Create_func_issimple::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_issimple(arg1); } @@ -3698,7 +3698,7 @@ Create_func_issimple::create(THD *thd, I Create_func_last_day Create_func_last_day::s_singleton; Item* -Create_func_last_day::create(THD *thd, Item *arg1) +Create_func_last_day::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_last_day(arg1); } @@ -3744,7 +3744,7 @@ Create_func_last_insert_id::create_nativ Create_func_lcase Create_func_lcase::s_singleton; Item* -Create_func_lcase::create(THD *thd, Item *arg1) +Create_func_lcase::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_lcase(arg1); } @@ -3774,7 +3774,7 @@ Create_func_least::create_native(THD *th Create_func_length Create_func_length::s_singleton; Item* -Create_func_length::create(THD *thd, Item *arg1) +Create_func_length::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_length(arg1); } @@ -3783,7 +3783,7 @@ Create_func_length::create(THD *thd, Ite Create_func_ln Create_func_ln::s_singleton; Item* -Create_func_ln::create(THD *thd, Item *arg1) +Create_func_ln::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_ln(arg1); } @@ -3792,7 +3792,7 @@ Create_func_ln::create(THD *thd, Item *a Create_func_load_file Create_func_load_file::s_singleton; Item* -Create_func_load_file::create(THD *thd, Item *arg1) +Create_func_load_file::create_1_arg(THD *thd, Item *arg1) { thd->lex->set_stmt_unsafe(); thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); @@ -3881,7 +3881,7 @@ Create_func_log::create_native(THD *thd, Create_func_log10 Create_func_log10::s_singleton; Item* -Create_func_log10::create(THD *thd, Item *arg1) +Create_func_log10::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_log10(arg1); } @@ -3890,7 +3890,7 @@ Create_func_log10::create(THD *thd, Item Create_func_log2 Create_func_log2::s_singleton; Item* -Create_func_log2::create(THD *thd, Item *arg1) +Create_func_log2::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_log2(arg1); } @@ -3899,7 +3899,7 @@ Create_func_log2::create(THD *thd, Item Create_func_lpad Create_func_lpad::s_singleton; Item* -Create_func_lpad::create(THD *thd, Item *arg1, Item *arg2, Item *arg3) +Create_func_lpad::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) { return new (thd->mem_root) Item_func_lpad(arg1, arg2, arg3); } @@ -3908,7 +3908,7 @@ Create_func_lpad::create(THD *thd, Item Create_func_ltrim Create_func_ltrim::s_singleton; Item* -Create_func_ltrim::create(THD *thd, Item *arg1) +Create_func_ltrim::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_ltrim(arg1); } @@ -3917,7 +3917,7 @@ Create_func_ltrim::create(THD *thd, Item Create_func_makedate Create_func_makedate::s_singleton; Item* -Create_func_makedate::create(THD *thd, Item *arg1, Item *arg2) +Create_func_makedate::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_makedate(arg1, arg2); } @@ -3926,7 +3926,7 @@ Create_func_makedate::create(THD *thd, I Create_func_maketime Create_func_maketime::s_singleton; Item* -Create_func_maketime::create(THD *thd, Item *arg1, Item *arg2, Item *arg3) +Create_func_maketime::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) { return new (thd->mem_root) Item_func_maketime(arg1, arg2, arg3); } @@ -4001,7 +4001,7 @@ Create_func_master_pos_wait::create_nati Create_func_md5 Create_func_md5::s_singleton; Item* -Create_func_md5::create(THD *thd, Item *arg1) +Create_func_md5::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_md5(arg1); } @@ -4010,7 +4010,7 @@ Create_func_md5::create(THD *thd, Item * Create_func_monthname Create_func_monthname::s_singleton; Item* -Create_func_monthname::create(THD *thd, Item *arg1) +Create_func_monthname::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_monthname(arg1); } @@ -4019,7 +4019,7 @@ Create_func_monthname::create(THD *thd, Create_func_name_const Create_func_name_const::s_singleton; Item* -Create_func_name_const::create(THD *thd, Item *arg1, Item *arg2) +Create_func_name_const::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_name_const(arg1, arg2); } @@ -4028,7 +4028,7 @@ Create_func_name_const::create(THD *thd, Create_func_nullif Create_func_nullif::s_singleton; Item* -Create_func_nullif::create(THD *thd, Item *arg1, Item *arg2) +Create_func_nullif::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_nullif(arg1, arg2); } @@ -4038,7 +4038,7 @@ Create_func_nullif::create(THD *thd, Ite Create_func_numgeometries Create_func_numgeometries::s_singleton; Item* -Create_func_numgeometries::create(THD *thd, Item *arg1) +Create_func_numgeometries::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_numgeometries(arg1); } @@ -4049,7 +4049,7 @@ Create_func_numgeometries::create(THD *t Create_func_numinteriorring Create_func_numinteriorring::s_singleton; Item* -Create_func_numinteriorring::create(THD *thd, Item *arg1) +Create_func_numinteriorring::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_numinteriorring(arg1); } @@ -4060,7 +4060,7 @@ Create_func_numinteriorring::create(THD Create_func_numpoints Create_func_numpoints::s_singleton; Item* -Create_func_numpoints::create(THD *thd, Item *arg1) +Create_func_numpoints::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_numpoints(arg1); } @@ -4070,7 +4070,7 @@ Create_func_numpoints::create(THD *thd, Create_func_oct Create_func_oct::s_singleton; Item* -Create_func_oct::create(THD *thd, Item *arg1) +Create_func_oct::create_1_arg(THD *thd, Item *arg1) { Item *i10= new (thd->mem_root) Item_int((int32) 10,2); Item *i8= new (thd->mem_root) Item_int((int32) 8,1); @@ -4081,7 +4081,7 @@ Create_func_oct::create(THD *thd, Item * Create_func_ord Create_func_ord::s_singleton; Item* -Create_func_ord::create(THD *thd, Item *arg1) +Create_func_ord::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_ord(arg1); } @@ -4091,7 +4091,7 @@ Create_func_ord::create(THD *thd, Item * Create_func_overlaps Create_func_overlaps::s_singleton; Item* -Create_func_overlaps::create(THD *thd, Item *arg1, Item *arg2) +Create_func_overlaps::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2, Item_func::SP_OVERLAPS_FUNC); @@ -4102,7 +4102,7 @@ Create_func_overlaps::create(THD *thd, I Create_func_period_add Create_func_period_add::s_singleton; Item* -Create_func_period_add::create(THD *thd, Item *arg1, Item *arg2) +Create_func_period_add::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_period_add(arg1, arg2); } @@ -4111,7 +4111,7 @@ Create_func_period_add::create(THD *thd, Create_func_period_diff Create_func_period_diff::s_singleton; Item* -Create_func_period_diff::create(THD *thd, Item *arg1, Item *arg2) +Create_func_period_diff::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_period_diff(arg1, arg2); } @@ -4120,7 +4120,7 @@ Create_func_period_diff::create(THD *thd Create_func_pi Create_func_pi::s_singleton; Item* -Create_func_pi::create(THD *thd) +Create_func_pi::create_builder(THD *thd) { return new (thd->mem_root) Item_static_float_func("pi()", M_PI, 6, 8); } @@ -4130,7 +4130,7 @@ Create_func_pi::create(THD *thd) Create_func_pointn Create_func_pointn::s_singleton; Item* -Create_func_pointn::create(THD *thd, Item *arg1, Item *arg2) +Create_func_pointn::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_spatial_decomp_n(arg1, arg2, Item_func::SP_POINTN); @@ -4141,7 +4141,7 @@ Create_func_pointn::create(THD *thd, Ite Create_func_pow Create_func_pow::s_singleton; Item* -Create_func_pow::create(THD *thd, Item *arg1, Item *arg2) +Create_func_pow::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_pow(arg1, arg2); } @@ -4150,7 +4150,7 @@ Create_func_pow::create(THD *thd, Item * Create_func_quote Create_func_quote::s_singleton; Item* -Create_func_quote::create(THD *thd, Item *arg1) +Create_func_quote::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_quote(arg1); } @@ -4159,7 +4159,7 @@ Create_func_quote::create(THD *thd, Item Create_func_radians Create_func_radians::s_singleton; Item* -Create_func_radians::create(THD *thd, Item *arg1) +Create_func_radians::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_units((char*) "radians", arg1, M_PI/180, 0.0); @@ -4216,7 +4216,7 @@ Create_func_rand::create_native(THD *thd Create_func_release_lock Create_func_release_lock::s_singleton; Item* -Create_func_release_lock::create(THD *thd, Item *arg1) +Create_func_release_lock::create_1_arg(THD *thd, Item *arg1) { thd->lex->set_stmt_unsafe(); thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); @@ -4227,7 +4227,7 @@ Create_func_release_lock::create(THD *th Create_func_reverse Create_func_reverse::s_singleton; Item* -Create_func_reverse::create(THD *thd, Item *arg1) +Create_func_reverse::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_reverse(arg1); } @@ -4274,7 +4274,7 @@ Create_func_round::create_native(THD *th Create_func_row_count Create_func_row_count::s_singleton; Item* -Create_func_row_count::create(THD *thd) +Create_func_row_count::create_builder(THD *thd) { thd->lex->set_stmt_unsafe(); thd->lex->safe_to_cache_query= 0; @@ -4285,7 +4285,7 @@ Create_func_row_count::create(THD *thd) Create_func_rpad Create_func_rpad::s_singleton; Item* -Create_func_rpad::create(THD *thd, Item *arg1, Item *arg2, Item *arg3) +Create_func_rpad::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) { return new (thd->mem_root) Item_func_rpad(arg1, arg2, arg3); } @@ -4294,7 +4294,7 @@ Create_func_rpad::create(THD *thd, Item Create_func_rtrim Create_func_rtrim::s_singleton; Item* -Create_func_rtrim::create(THD *thd, Item *arg1) +Create_func_rtrim::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_rtrim(arg1); } @@ -4303,7 +4303,7 @@ Create_func_rtrim::create(THD *thd, Item Create_func_sec_to_time Create_func_sec_to_time::s_singleton; Item* -Create_func_sec_to_time::create(THD *thd, Item *arg1) +Create_func_sec_to_time::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_sec_to_time(arg1); } @@ -4312,7 +4312,7 @@ Create_func_sec_to_time::create(THD *thd Create_func_sha Create_func_sha::s_singleton; Item* -Create_func_sha::create(THD *thd, Item *arg1) +Create_func_sha::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_sha(arg1); } @@ -4321,7 +4321,7 @@ Create_func_sha::create(THD *thd, Item * Create_func_sign Create_func_sign::s_singleton; Item* -Create_func_sign::create(THD *thd, Item *arg1) +Create_func_sign::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_sign(arg1); } @@ -4330,7 +4330,7 @@ Create_func_sign::create(THD *thd, Item Create_func_sin Create_func_sin::s_singleton; Item* -Create_func_sin::create(THD *thd, Item *arg1) +Create_func_sin::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_sin(arg1); } @@ -4339,7 +4339,7 @@ Create_func_sin::create(THD *thd, Item * Create_func_sleep Create_func_sleep::s_singleton; Item* -Create_func_sleep::create(THD *thd, Item *arg1) +Create_func_sleep::create_1_arg(THD *thd, Item *arg1) { thd->lex->set_stmt_unsafe(); thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); @@ -4350,7 +4350,7 @@ Create_func_sleep::create(THD *thd, Item Create_func_soundex Create_func_soundex::s_singleton; Item* -Create_func_soundex::create(THD *thd, Item *arg1) +Create_func_soundex::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_soundex(arg1); } @@ -4359,7 +4359,7 @@ Create_func_soundex::create(THD *thd, It Create_func_space Create_func_space::s_singleton; Item* -Create_func_space::create(THD *thd, Item *arg1) +Create_func_space::create_1_arg(THD *thd, Item *arg1) { /** TODO: Fix Bug#23637 @@ -4387,7 +4387,7 @@ Create_func_space::create(THD *thd, Item Create_func_sqrt Create_func_sqrt::s_singleton; Item* -Create_func_sqrt::create(THD *thd, Item *arg1) +Create_func_sqrt::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_sqrt(arg1); } @@ -4397,7 +4397,7 @@ Create_func_sqrt::create(THD *thd, Item Create_func_srid Create_func_srid::s_singleton; Item* -Create_func_srid::create(THD *thd, Item *arg1) +Create_func_srid::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_srid(arg1); } @@ -4408,7 +4408,7 @@ Create_func_srid::create(THD *thd, Item Create_func_startpoint Create_func_startpoint::s_singleton; Item* -Create_func_startpoint::create(THD *thd, Item *arg1) +Create_func_startpoint::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_spatial_decomp(arg1, Item_func::SP_STARTPOINT); @@ -4419,7 +4419,7 @@ Create_func_startpoint::create(THD *thd, Create_func_str_to_date Create_func_str_to_date::s_singleton; Item* -Create_func_str_to_date::create(THD *thd, Item *arg1, Item *arg2) +Create_func_str_to_date::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_str_to_date(arg1, arg2); } @@ -4428,7 +4428,7 @@ Create_func_str_to_date::create(THD *thd Create_func_strcmp Create_func_strcmp::s_singleton; Item* -Create_func_strcmp::create(THD *thd, Item *arg1, Item *arg2) +Create_func_strcmp::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_strcmp(arg1, arg2); } @@ -4437,7 +4437,7 @@ Create_func_strcmp::create(THD *thd, Ite Create_func_substr_index Create_func_substr_index::s_singleton; Item* -Create_func_substr_index::create(THD *thd, Item *arg1, Item *arg2, Item *arg3) +Create_func_substr_index::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) { return new (thd->mem_root) Item_func_substr_index(arg1, arg2, arg3); } @@ -4446,7 +4446,7 @@ Create_func_substr_index::create(THD *th Create_func_subtime Create_func_subtime::s_singleton; Item* -Create_func_subtime::create(THD *thd, Item *arg1, Item *arg2) +Create_func_subtime::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_add_time(arg1, arg2, 0, 1); } @@ -4455,7 +4455,7 @@ Create_func_subtime::create(THD *thd, It Create_func_tan Create_func_tan::s_singleton; Item* -Create_func_tan::create(THD *thd, Item *arg1) +Create_func_tan::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_tan(arg1); } @@ -4464,7 +4464,7 @@ Create_func_tan::create(THD *thd, Item * Create_func_time_format Create_func_time_format::s_singleton; Item* -Create_func_time_format::create(THD *thd, Item *arg1, Item *arg2) +Create_func_time_format::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_date_format(arg1, arg2, 1); } @@ -4473,7 +4473,7 @@ Create_func_time_format::create(THD *thd Create_func_time_to_sec Create_func_time_to_sec::s_singleton; Item* -Create_func_time_to_sec::create(THD *thd, Item *arg1) +Create_func_time_to_sec::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_time_to_sec(arg1); } @@ -4482,7 +4482,7 @@ Create_func_time_to_sec::create(THD *thd Create_func_timediff Create_func_timediff::s_singleton; Item* -Create_func_timediff::create(THD *thd, Item *arg1, Item *arg2) +Create_func_timediff::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_timediff(arg1, arg2); } @@ -4491,7 +4491,7 @@ Create_func_timediff::create(THD *thd, I Create_func_to_days Create_func_to_days::s_singleton; Item* -Create_func_to_days::create(THD *thd, Item *arg1) +Create_func_to_days::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_to_days(arg1); } @@ -4501,7 +4501,7 @@ Create_func_to_days::create(THD *thd, It Create_func_touches Create_func_touches::s_singleton; Item* -Create_func_touches::create(THD *thd, Item *arg1, Item *arg2) +Create_func_touches::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2, Item_func::SP_TOUCHES_FUNC); @@ -4512,7 +4512,7 @@ Create_func_touches::create(THD *thd, It Create_func_ucase Create_func_ucase::s_singleton; Item* -Create_func_ucase::create(THD *thd, Item *arg1) +Create_func_ucase::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_ucase(arg1); } @@ -4521,7 +4521,7 @@ Create_func_ucase::create(THD *thd, Item Create_func_uncompress Create_func_uncompress::s_singleton; Item* -Create_func_uncompress::create(THD *thd, Item *arg1) +Create_func_uncompress::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_uncompress(arg1); } @@ -4530,7 +4530,7 @@ Create_func_uncompress::create(THD *thd, Create_func_uncompressed_length Create_func_uncompressed_length::s_singleton; Item* -Create_func_uncompressed_length::create(THD *thd, Item *arg1) +Create_func_uncompressed_length::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_uncompressed_length(arg1); } @@ -4539,7 +4539,7 @@ Create_func_uncompressed_length::create( Create_func_unhex Create_func_unhex::s_singleton; Item* -Create_func_unhex::create(THD *thd, Item *arg1) +Create_func_unhex::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_unhex(arg1); } @@ -4584,7 +4584,7 @@ Create_func_unix_timestamp::create_nativ Create_func_uuid Create_func_uuid::s_singleton; Item* -Create_func_uuid::create(THD *thd) +Create_func_uuid::create_builder(THD *thd) { thd->lex->set_stmt_unsafe(); thd->lex->safe_to_cache_query= 0; @@ -4595,7 +4595,7 @@ Create_func_uuid::create(THD *thd) Create_func_uuid_short Create_func_uuid_short::s_singleton; Item* -Create_func_uuid_short::create(THD *thd) +Create_func_uuid_short::create_builder(THD *thd) { thd->lex->set_stmt_unsafe(); thd->lex->safe_to_cache_query= 0; @@ -4606,7 +4606,7 @@ Create_func_uuid_short::create(THD *thd) Create_func_version Create_func_version::s_singleton; Item* -Create_func_version::create(THD *thd) +Create_func_version::create_builder(THD *thd) { thd->lex->set_stmt_unsafe(); return new (thd->mem_root) Item_static_string_func("version()", @@ -4620,7 +4620,7 @@ Create_func_version::create(THD *thd) Create_func_weekday Create_func_weekday::s_singleton; Item* -Create_func_weekday::create(THD *thd, Item *arg1) +Create_func_weekday::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_weekday(arg1, 0); } @@ -4629,7 +4629,7 @@ Create_func_weekday::create(THD *thd, It Create_func_weekofyear Create_func_weekofyear::s_singleton; Item* -Create_func_weekofyear::create(THD *thd, Item *arg1) +Create_func_weekofyear::create_1_arg(THD *thd, Item *arg1) { Item *i1= new (thd->mem_root) Item_int((char*) "0", 3, 1); return new (thd->mem_root) Item_func_week(arg1, i1); @@ -4640,7 +4640,7 @@ Create_func_weekofyear::create(THD *thd, Create_func_within Create_func_within::s_singleton; Item* -Create_func_within::create(THD *thd, Item *arg1, Item *arg2) +Create_func_within::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2, Item_func::SP_WITHIN_FUNC); @@ -4652,7 +4652,7 @@ Create_func_within::create(THD *thd, Ite Create_func_x Create_func_x::s_singleton; Item* -Create_func_x::create(THD *thd, Item *arg1) +Create_func_x::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_x(arg1); } @@ -4662,7 +4662,7 @@ Create_func_x::create(THD *thd, Item *ar Create_func_xml_extractvalue Create_func_xml_extractvalue::s_singleton; Item* -Create_func_xml_extractvalue::create(THD *thd, Item *arg1, Item *arg2) +Create_func_xml_extractvalue::create_2_arg(THD *thd, Item *arg1, Item *arg2) { return new (thd->mem_root) Item_func_xml_extractvalue(arg1, arg2); } @@ -4671,7 +4671,7 @@ Create_func_xml_extractvalue::create(THD Create_func_xml_update Create_func_xml_update::s_singleton; Item* -Create_func_xml_update::create(THD *thd, Item *arg1, Item *arg2, Item *arg3) +Create_func_xml_update::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) { return new (thd->mem_root) Item_func_xml_update(arg1, arg2, arg3); } @@ -4681,7 +4681,7 @@ Create_func_xml_update::create(THD *thd, Create_func_y Create_func_y::s_singleton; Item* -Create_func_y::create(THD *thd, Item *arg1) +Create_func_y::create_1_arg(THD *thd, Item *arg1) { return new (thd->mem_root) Item_func_y(arg1); } === modified file 'sql/item_create.h' --- a/sql/item_create.h 2007-08-15 13:43:08 +0000 +++ b/sql/item_create.h 2010-03-28 18:10:00 +0000 @@ -91,8 +91,9 @@ public: @param item_list The list of arguments to the function, can be NULL @return An item representing the parsed function call */ - virtual Item* create(THD *thd, LEX_STRING db, LEX_STRING name, - bool use_explicit_name, List<Item> *item_list) = 0; + virtual Item *create_with_db(THD *thd, LEX_STRING db, LEX_STRING name, + bool use_explicit_name, + List<Item> *item_list) = 0; protected: /** Constructor. */ === modified file 'sql/item_sum.cc' --- a/sql/item_sum.cc 2010-01-15 15:27:55 +0000 +++ b/sql/item_sum.cc 2010-03-28 18:10:00 +0000 @@ -642,7 +642,7 @@ Item_sum_hybrid::fix_fields(THD *thd, It default: DBUG_ASSERT(0); }; - setup(args[0], NULL); + setup_item(args[0], NULL); /* MIN/MAX can return NULL for empty set indepedent of the used column */ maybe_null= 1; unsigned_flag=item->unsigned_flag; @@ -676,7 +676,7 @@ Item_sum_hybrid::fix_fields(THD *thd, It of the original MIN/MAX object and it is saved in this object's cache. */ -void Item_sum_hybrid::setup(Item *item, Item *value_arg) +void Item_sum_hybrid::setup_item(Item *item, Item *value_arg) { value= Item_cache::get_cache(item); value->setup(item); @@ -1646,7 +1646,7 @@ void Item_sum_hybrid::no_rows_in_result( Item *Item_sum_min::copy_or_same(THD* thd) { Item_sum_min *item= new (thd->mem_root) Item_sum_min(thd, this); - item->setup(args[0], value); + item->setup_item(args[0], value); return item; } @@ -1669,7 +1669,7 @@ bool Item_sum_min::add() Item *Item_sum_max::copy_or_same(THD* thd) { Item_sum_max *item= new (thd->mem_root) Item_sum_max(thd, this); - item->setup(args[0], value); + item->setup_item(args[0], value); return item; } === modified file 'sql/item_sum.h' --- a/sql/item_sum.h 2010-02-01 06:14:12 +0000 +++ b/sql/item_sum.h 2010-03-31 08:17:03 +0000 @@ -870,7 +870,7 @@ protected: was_values(item->was_values) { } bool fix_fields(THD *, Item **); - void setup(Item *item, Item *value_arg); + void setup_item(Item *item, Item *value_arg); void clear(); double val_real(); longlong val_int(); === modified file 'sql/log.cc' --- a/sql/log.cc 2010-03-15 11:51:23 +0000 +++ b/sql/log.cc 2010-03-31 08:17:03 +0000 @@ -5424,7 +5424,7 @@ int TC_LOG_MMAP::open(const char *opt_na pg->state=POOL; pthread_mutex_init(&pg->lock, MY_MUTEX_INIT_FAST); pthread_cond_init (&pg->cond, 0); - pg->start=(my_xid *)(data + i*tc_log_page_size); + pg->ptr= pg->start=(my_xid *)(data + i*tc_log_page_size); pg->size=pg->free=tc_log_page_size/sizeof(my_xid); pg->end=pg->start + pg->size; } @@ -5659,7 +5659,15 @@ int TC_LOG_MMAP::sync() /* marking 'syncing' slot free */ pthread_mutex_lock(&LOCK_sync); syncing=0; - pthread_cond_signal(&active->cond); // wake up a new syncer + /* + we check the "active" pointer without LOCK_active. Still, it's safe - + "active" can change from NULL to not NULL any time, but it + will take LOCK_sync before waiting on active->cond. That is, it can never + miss a signal. + And "active" can change to NULL only after LOCK_sync, so this is safe too. + */ + if (active) + pthread_cond_signal(&active->cond); // wake up a new syncer pthread_mutex_unlock(&LOCK_sync); return err; } === modified file 'sql/mysqld.cc' --- a/sql/mysqld.cc 2010-03-29 15:13:53 +0000 +++ b/sql/mysqld.cc 2010-03-31 08:17:03 +0000 @@ -8371,6 +8371,8 @@ mysqld_get_one_option(int optid, case (int) OPT_INIT_RPL_ROLE: { int role; + LINT_INIT(role); + if (!find_opt_type(argument, &rpl_role_typelib, opt->name, &role)) { rpl_status = (role == 1) ? RPL_AUTH_MASTER : RPL_IDLE_SLAVE; @@ -8427,6 +8429,8 @@ mysqld_get_one_option(int optid, case OPT_BINLOG_FORMAT: { int id; + LINT_INIT(id); + if (!find_opt_type(argument, &binlog_format_typelib, opt->name, &id)) { global_system_variables.binlog_format= opt_binlog_format_id= id - 1; @@ -8677,6 +8681,8 @@ mysqld_get_one_option(int optid, else { int type; + LINT_INIT(type); + if (!find_opt_type(argument, &delay_key_write_typelib, opt->name, &type)) delay_key_write_options= (uint) type-1; } @@ -8688,6 +8694,8 @@ mysqld_get_one_option(int optid, case OPT_TX_ISOLATION: { int type; + LINT_INIT(type); + if (!find_opt_type(argument, &tx_isolation_typelib, opt->name, &type)) global_system_variables.tx_isolation= (type-1); break; @@ -8775,6 +8783,7 @@ mysqld_get_one_option(int optid, ulong method_conv; int method; LINT_INIT(method_conv); + LINT_INIT(method); myisam_stats_method_str= argument; if (!find_opt_type(argument, &myisam_stats_method_typelib, @@ -8837,6 +8846,7 @@ mysqld_get_one_option(int optid, case OPT_THREAD_HANDLING: { int id; + LINT_INIT(id); if (!find_opt_type(argument, &thread_handling_typelib, opt->name, &id)) global_system_variables.thread_handling= id - 1; opt_thread_handling= thread_handling_typelib.type_names[global_system_variables.thread_handling]; === modified file 'sql/net_serv.cc' --- a/sql/net_serv.cc 2010-02-23 12:04:58 +0000 +++ b/sql/net_serv.cc 2010-03-29 19:07:45 +0000 @@ -279,7 +279,7 @@ static int net_data_is_ready(my_socket s @param clear_buffer if <> 0, then clear all data from comm buff */ -void net_clear(NET *net, my_bool clear_buffer) +void net_clear(NET *net, my_bool clear_buffer __attribute__((unused))) { #if !defined(EMBEDDED_LIBRARY) && defined(DBUG_OFF) size_t count; === modified file 'sql/set_var.cc' --- a/sql/set_var.cc 2010-03-15 11:51:23 +0000 +++ b/sql/set_var.cc 2010-03-31 08:17:03 +0000 @@ -1266,16 +1266,16 @@ uchar *sys_var_set::value_ptr(THD *thd, void sys_var_set_slave_mode::set_default(THD *thd, enum_var_type type) { - slave_exec_mode_options= 0; - bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT); + slave_exec_mode_options= (ULL(1) << SLAVE_EXEC_MODE_STRICT); } bool sys_var_set_slave_mode::check(THD *thd, set_var *var) { bool rc= sys_var_set::check(thd, var); if (!rc && - bit_is_set(var->save_result.ulong_value, SLAVE_EXEC_MODE_STRICT) == 1 && - bit_is_set(var->save_result.ulong_value, SLAVE_EXEC_MODE_IDEMPOTENT) == 1) + test_all_bits(var->save_result.ulong_value, + ((ULL(1) << SLAVE_EXEC_MODE_STRICT) | + (ULL(1) << SLAVE_EXEC_MODE_IDEMPOTENT)))) { rc= true; my_error(ER_SLAVE_AMBIGOUS_EXEC_MODE, MYF(0), ""); @@ -1297,15 +1297,16 @@ void fix_slave_exec_mode(enum_var_type t DBUG_ENTER("fix_slave_exec_mode"); compile_time_assert(sizeof(slave_exec_mode_options) * CHAR_BIT > SLAVE_EXEC_MODE_LAST_BIT - 1); - if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT) == 1 && - bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 1) + if (test_all_bits(slave_exec_mode_options, + ((ULL(1) << SLAVE_EXEC_MODE_STRICT) | + (ULL(1) << SLAVE_EXEC_MODE_IDEMPOTENT)))) { sql_print_error("Ambiguous slave modes combination." " STRICT will be used"); - bit_do_clear(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT); + slave_exec_mode_options&= ~(ULL(1) << SLAVE_EXEC_MODE_IDEMPOTENT); } - if (bit_is_set(slave_exec_mode_options, SLAVE_EXEC_MODE_IDEMPOTENT) == 0) - bit_do_set(slave_exec_mode_options, SLAVE_EXEC_MODE_STRICT); + if (!(slave_exec_mode_options & (ULL(1) << SLAVE_EXEC_MODE_IDEMPOTENT))) + slave_exec_mode_options|= (ULL(1)<< SLAVE_EXEC_MODE_STRICT); DBUG_VOID_RETURN; } === modified file 'sql/sql_class.h' --- a/sql/sql_class.h 2010-03-29 15:13:53 +0000 +++ b/sql/sql_class.h 2010-03-31 08:17:03 +0000 @@ -63,6 +63,7 @@ public: bool report_error(THD *thd); bool is_invalidated() const { return m_invalidated; } void reset_reprepare_observer() { m_invalidated= FALSE; } + Reprepare_observer() {} /* Remove gcc warning */ private: bool m_invalidated; }; @@ -1117,6 +1118,7 @@ public: /* Ignore error */ return TRUE; } + Dummy_error_handler() {} /* Remove gcc warning */ }; === modified file 'sql/sql_table.cc' --- a/sql/sql_table.cc 2010-03-15 11:51:23 +0000 +++ b/sql/sql_table.cc 2010-03-31 08:17:03 +0000 @@ -5704,6 +5704,10 @@ compare_tables(TABLE *table, */ Alter_info tmp_alter_info(*alter_info, thd->mem_root); uint db_options= 0; /* not used */ + + /* Set default value for return value (to ensure it's always set) */ + *need_copy_table= ALTER_TABLE_DATA_CHANGED; + /* Create the prepared information. */ if (mysql_prepare_create_table(thd, create_info, &tmp_alter_info, @@ -5762,7 +5766,6 @@ compare_tables(TABLE *table, (table->s->frm_version < FRM_VER_TRUE_VARCHAR && varchar)) { DBUG_PRINT("info", ("Basic checks -> ALTER_TABLE_DATA_CHANGED")); - *need_copy_table= ALTER_TABLE_DATA_CHANGED; DBUG_RETURN(0); } @@ -5792,7 +5795,6 @@ compare_tables(TABLE *table, { DBUG_PRINT("info", ("NULL behaviour difference in field '%s' -> " "ALTER_TABLE_DATA_CHANGED", new_field->field_name)); - *need_copy_table= ALTER_TABLE_DATA_CHANGED; DBUG_RETURN(0); } @@ -5828,7 +5830,6 @@ compare_tables(TABLE *table, { DBUG_PRINT("info", ("!field_is_equal('%s') -> ALTER_TABLE_DATA_CHANGED", new_field->field_name)); - *need_copy_table= ALTER_TABLE_DATA_CHANGED; DBUG_RETURN(0); } // Clear indexed marker @@ -5963,7 +5964,6 @@ compare_tables(TABLE *table, { DBUG_PRINT("info", ("check_if_incompatible_data() -> " "ALTER_TABLE_DATA_CHANGED")); - *need_copy_table= ALTER_TABLE_DATA_CHANGED; DBUG_RETURN(0); } === modified file 'sql/sql_view.cc' --- a/sql/sql_view.cc 2010-03-04 08:03:07 +0000 +++ b/sql/sql_view.cc 2010-03-30 12:36:49 +0000 @@ -1034,10 +1034,12 @@ bool mysql_make_view(THD *thd, File_pars bool parse_status; bool result, view_is_mergeable; TABLE_LIST *UNINIT_VAR(view_main_select_tables); - DBUG_ENTER("mysql_make_view"); DBUG_PRINT("info", ("table: 0x%lx (%s)", (ulong) table, table->table_name)); + LINT_INIT(parse_status); + LINT_INIT(view_select); + if (table->view) { /* === modified file 'sql/sql_yacc.yy' --- a/sql/sql_yacc.yy 2010-03-29 15:13:53 +0000 +++ b/sql/sql_yacc.yy 2010-03-31 08:17:03 +0000 @@ -8190,7 +8190,7 @@ function_call_generic: builder= find_qualified_function_builder(thd); DBUG_ASSERT(builder); - item= builder->create(thd, $1, $3, true, $5); + item= builder->create_with_db(thd, $1, $3, true, $5); if (! ($$= item)) { === modified file 'storage/example/ha_example.h' --- a/storage/example/ha_example.h 2007-08-13 13:11:25 +0000 +++ b/storage/example/ha_example.h 2010-03-28 18:10:00 +0000 @@ -155,7 +155,8 @@ public: /** @brief This method will never be called if you do not implement indexes. */ - virtual double read_time(ha_rows rows) { return (double) rows / 20.0+1; } + virtual double read_time(uint index, uint ranges, ha_rows rows) + { return (double) rows / 20.0+1; } /* Everything below are methods that we implement in ha_example.cc. === modified file 'storage/maria/ma_loghandler.c' --- a/storage/maria/ma_loghandler.c 2010-03-30 12:35:15 +0000 +++ b/storage/maria/ma_loghandler.c 2010-03-31 08:17:03 +0000 @@ -1274,6 +1274,8 @@ static my_bool translog_set_lsn_for_file for (file= from_file; file <= to_file; file++) { LOGHANDLER_FILE_INFO info; + LINT_INIT(info.max_lsn); + File fd= open_logfile_by_number_no_cache(file); LINT_INIT_STRUCT(info); if ((fd < 0) || @@ -3967,7 +3969,8 @@ my_bool translog_init_with_table(const c if (!old_log_was_recovered && old_flags == flags) { LOGHANDLER_FILE_INFO info; - LINT_INIT_STRUCT(info); + LINT_INIT(info.maria_version); + /* Accessing &log_descriptor.open_files without mutex is safe because it is initialization === modified file 'storage/maria/ma_search.c' --- a/storage/maria/ma_search.c 2010-03-15 11:51:23 +0000 +++ b/storage/maria/ma_search.c 2010-03-31 08:17:03 +0000 @@ -76,8 +76,8 @@ int _ma_search(register MARIA_HA *info, bmove512(info->keyread_buff, page_buff, info->s->block_size); /* Save position for a possible read next / previous */ - info->int_keypos= info->keyread_buff + (ulonglong) info->int_keypos; - info->int_maxpos= info->keyread_buff + (ulonglong) info->int_maxpos; + info->int_keypos= info->keyread_buff + info->keypos_offset; + info->int_maxpos= info->keyread_buff + info->maxpos_offset; info->int_keytree_version= key->keyinfo->version; info->last_search_keypage= info->last_keypage; info->page_changed= 0; @@ -214,8 +214,8 @@ static int _ma_search_no_save(register M info->cur_row.trid= _ma_trid_from_key(&info->last_key); /* Store offset to key */ - info->int_keypos= (uchar*) (keypos - page.buff); - info->int_maxpos= (uchar*) (maxpos - page.buff); + info->keypos_offset= (uint) (keypos - page.buff); + info->maxpos_offset= (uint) (maxpos - page.buff); info->int_nod_flag= nod_flag; info->last_keypage= pos; *res_page_link= page_link; === modified file 'storage/maria/maria_def.h' --- a/storage/maria/maria_def.h 2010-03-09 19:22:24 +0000 +++ b/storage/maria/maria_def.h 2010-03-28 18:10:00 +0000 @@ -506,8 +506,10 @@ struct st_maria_handler uchar *first_mbr_key; /* Searhed spatial key */ uchar *rec_buff; /* Temp buffer for recordpack */ uchar *blob_buff; /* Temp buffer for blobs */ - uchar *int_keypos, /* Save position for next/previous */ - *int_maxpos; /* -""- */ + uchar *int_keypos; /* Save position for next/previous */ + uchar *int_maxpos; /* -""- */ + uint keypos_offset; /* Tmp storage for offset int_keypos */ + uint maxpos_offset; /* Tmp storage for offset int_maxpos */ uchar *update_field_data; /* Used by update in rows-in-block */ uint int_nod_flag; /* -""- */ uint32 int_keytree_version; /* -""- */ === modified file 'storage/myisam/ft_stopwords.c' --- a/storage/myisam/ft_stopwords.c 2010-03-10 10:32:14 +0000 +++ b/storage/myisam/ft_stopwords.c 2010-03-28 18:10:00 +0000 @@ -44,9 +44,10 @@ static void FT_STOPWORD_free(FT_STOPWORD static int ft_add_stopword(const char *w) { FT_STOPWORD sw; - return !w || - (((sw.len= (uint) strlen(sw.pos=(const uchar *)w)) >= ft_min_word_len) && - (tree_insert(stopwords3, &sw, 0, stopwords3->custom_arg)==NULL)); + return (!w || + (((sw.len= (uint) strlen((char*) (sw.pos=(const uchar *)w))) >= + ft_min_word_len) && + (tree_insert(stopwords3, &sw, 0, stopwords3->custom_arg)==NULL))); } int ft_init_stopwords() === modified file 'storage/myisammrg/ha_myisammrg.cc' --- a/storage/myisammrg/ha_myisammrg.cc 2010-03-04 08:03:07 +0000 +++ b/storage/myisammrg/ha_myisammrg.cc 2010-03-30 12:36:49 +0000 @@ -382,7 +382,7 @@ static MI_INFO *myisammrg_attach_childre my_errno= HA_ERR_WRONG_MRG_TABLE_DEF; } DBUG_PRINT("myrg", ("MyISAM handle: 0x%lx my_errno: %d", - my_errno ? NULL : (long) myisam, my_errno)); + my_errno ? 0L : (long) myisam, my_errno)); err: DBUG_RETURN(my_errno ? NULL : myisam); === modified file 'storage/myisammrg/myrg_open.c' --- a/storage/myisammrg/myrg_open.c 2009-09-23 13:21:29 +0000 +++ b/storage/myisammrg/myrg_open.c 2010-03-30 12:36:49 +0000 @@ -239,6 +239,7 @@ MYRG_INFO *myrg_parent_open(const char * rc= 1; errpos= 0; bzero((char*) &file_cache, sizeof(file_cache)); + LINT_INIT(m_info); /* Open MERGE meta file. */ if ((fd= my_open(fn_format(parent_name_buff, parent_name, "", MYRG_NAME_EXT, === added directory 'storage/oqgraph' === added file 'storage/oqgraph/CMakeFiles.txt' --- a/storage/oqgraph/CMakeFiles.txt 1970-01-01 00:00:00 +0000 +++ b/storage/oqgraph/CMakeFiles.txt 2010-01-04 08:27:50 +0000 @@ -0,0 +1,22 @@ +# Copyright (C) 2006 MySQL AB +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql + ${CMAKE_SOURCE_DIR}/regex + ${CMAKE_SOURCE_DIR}/extra/yassl/include) +ADD_LIBRARY(oqgraph ha_oqgraph.cc) === added file 'storage/oqgraph/Makefile.am' --- a/storage/oqgraph/Makefile.am 1970-01-01 00:00:00 +0000 +++ b/storage/oqgraph/Makefile.am 2010-03-30 18:12:00 +0000 @@ -0,0 +1,96 @@ +# Copyright (C) 2007-2009 Arjen G Lentz & Antony T Curtis for Open Query +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +# ====================================================================== +# Open Query Graph Computation Engine, based on a concept by Arjen Lentz +# Mk.II implementation by Antony Curtis & Arjen Lentz +# For more information, documentation, support, enhancement engineering, +# and non-GPL licensing, see http://openquery.com/graph +# or contact graph@openquery.com +# For packaged binaries, see http://ourdelta.org +# ====================================================================== + +mysqlplugindir= $(pkglibdir)/plugin + +BOOST_CXXFLAGS = -frtti -fexceptions -fimplicit-templates +#BOOST_CXXFLAGS+= -g +#original flags before 2009-11-10 +#BOOST_CXXFLAGS+= -O3 -fomit-frame-pointer -fstrict-aliasing +#BOOST_CXXFLAGS+= -momit-leaf-frame-pointer -falign-loops +#modified flags: +# - remove omit-frame-pointer, x86 specific (fails on PPC) + hinders debugging +# Option details from gcc man: +# Don't keep the frame pointer in a register for functions that don't need one. +# This avoids the instructions to save, set up and restore frame pointers; +# it also makes an extra register available in many functions. +# It also makes debugging impossible on some machines. +# (automatically gets enabled anyway by -O* on some architectures) +BOOST_CXXFLAGS+= -O3 -fstrict-aliasing +BOOST_CXXFLAGS+= -falign-loops +BOOST_CXXFLAGS+= -fvisibility-inlines-hidden +BOOST_CXXFLAGS+= -funroll-loops -fno-trapping-math + +EXTRA_DIST = ha_oqgraph.h ha_oqgraph.cc graphcore.cc \ + graphcore-graph.h graphcore-types.h graphcore.h \ + CMakeFiles.txt plug.in oqgraph_probes.d + +# DTRACE = @DTRACE@ +# DTRACEFLAGS = @DTRACEFLAGS@ +# DTRACEFILES = .libs/liboqgraph_engine_la-ha_oqgraph.o + +ORIG_CXXFLAGS = @CXXFLAGS@ +CXXFLAGS= +noinst_HEADERS = ha_oqgraph.h \ + graphcore-graph.h graphcore-types.h graphcore.h +# oqgraph_probes.h + +noinst_LTLIBRARIES = libgraphcore.la +libgraphcore_la_SOURCES = graphcore.cc +libgraphcore_la_CXXFLAGS = $(ORIG_CXXFLAGS) $(BOOST_CXXFLAGS) + +if BUILD_OQGRAPH_FOR_MYSQL + +if BUILD_OQGRAPH_STANDALONE +INCLUDES = -DDBUG_ON -DSAFE_MUTEX -DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS -DSAFEMALLOC -DPEDANTIC_SAFEMALLOC -DSAFE_MUTEX -DHAVE_OQGRAPH $(MYSQL_INC) +else +INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/regex -I$(top_srcdir)/sql -I$(srcdir) -DHAVE_OQGRAPH +endif !BUILD_OQGRAPH_STANDALONE + +EXTRA_LTLIBRARIES = oqgraph_engine.la +mysqlplugin_LTLIBRARIES = @plugin_oqgraph_shared_target@ +oqgraph_engine_la_SOURCES = ha_oqgraph.cc +oqgraph_engine_la_LIBADD = libgraphcore.la + +# if HAVE_DTRACE +# oqgraph_engine_la_LIBADD += oqgraph_probes.o +# endif + +oqgraph_engine_la_LDFLAGS = -module -rpath $(mysqlplugindir) +oqgraph_engine_la_CFLAGS = $(ORIG_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN +oqgraph_engine_la_CXXFLAGS = $(ORIG_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN + +# oqgraph_probes.h: oqgraph_probes.d +# $(DTRACE) $(DTRACEFLAGS) -h -s oqgraph_probes.d +# mv oqgraph_probes.h oqgraph_probes.h.bak +# sed "s/#include <unistd.h>//g" oqgraph_probes.h.bak > oqgraph_probes.h +# rm oqgraph_probes.h.bak + +# oqgraph_probes.o: +# $(DTRACE) $(DTRACEFLAGS) -G -s oqgraph_probes.d $(DTRACEFILES) + +endif BUILD_OQGRAPH_FOR_MYSQL + +# End === added file 'storage/oqgraph/README' --- a/storage/oqgraph/README 1970-01-01 00:00:00 +0000 +++ b/storage/oqgraph/README 2010-03-30 07:33:38 +0000 @@ -0,0 +1,16 @@ +OQGraph storage engine +Copyright (C) 2007-2009 Arjen G Lentz & Antony T Curtis for Open Query + +The Open Query GRAPH engine (OQGRAPH) is a computation engine allowing +hierarchies and more complex graph structures to be handled in a +relational fashion. In a nutshell, tree structures and +friend-of-a-friend style searches can now be done using standard SQL +syntax, and results joined onto other tables. + +See http://openquery.com/graph for more information. + + +INSTALLATION + +OQGraph requires at least version 1.40.0 of the Boost library. To +obtain a copy of the Boost library, see http://www.boost.org/ === added file 'storage/oqgraph/graphcore-graph.h' --- a/storage/oqgraph/graphcore-graph.h 1970-01-01 00:00:00 +0000 +++ b/storage/oqgraph/graphcore-graph.h 2010-01-04 08:27:50 +0000 @@ -0,0 +1,48 @@ +/* Copyright (C) 2007-2009 Arjen G Lentz & Antony T Curtis for Open Query + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* ====================================================================== + Open Query Graph Computation Engine, based on a concept by Arjen Lentz + Mk.II implementation by Antony Curtis & Arjen Lentz + For more information, documentation, support, enhancement engineering, + and non-GPL licensing, see http://openquery.com/graph + or contact graph@openquery.com + For packaged binaries, see http://ourdelta.org + ====================================================================== +*/ + +#ifndef oq_graphcore_graph_h_ +#define oq_graphcore_graph_h_ + +typedef adjacency_list +< + vecS, + vecS, + bidirectionalS, + VertexInfo, + EdgeInfo +> Graph; + +#define GRAPH_WEIGHTMAP(G) get(&EdgeInfo::weight, G) +typedef property_map<Graph, EdgeWeight EdgeInfo::*>::type weightmap_type; + +#define GRAPH_INDEXMAP(G) get(vertex_index, G) +typedef property_map<Graph, vertex_index_t>::type indexmap_type; + +#define GRAPH_IDMAP(G) get(&VertexInfo::id, G) +typedef property_map<Graph, VertexID VertexInfo::*>::type idmap_type; + +#endif === added file 'storage/oqgraph/graphcore-types.h' --- a/storage/oqgraph/graphcore-types.h 1970-01-01 00:00:00 +0000 +++ b/storage/oqgraph/graphcore-types.h 2010-01-04 08:27:50 +0000 @@ -0,0 +1,36 @@ +/* Copyright (C) 2007-2009 Arjen G Lentz & Antony T Curtis for Open Query + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* ====================================================================== + Open Query Graph Computation Engine, based on a concept by Arjen Lentz + Mk.II implementation by Antony Curtis & Arjen Lentz + For more information, documentation, support, enhancement engineering, + and non-GPL licensing, see http://openquery.com/graph + or contact graph@openquery.com + For packaged binaries, see http://ourdelta.org + ====================================================================== +*/ + +#ifndef oq_graphcore_types_h_ +#define oq_graphcore_types_h_ +namespace open_query +{ + + typedef unsigned long long VertexID; + typedef double EdgeWeight; + +} +#endif === added file 'storage/oqgraph/graphcore.cc' --- a/storage/oqgraph/graphcore.cc 1970-01-01 00:00:00 +0000 +++ b/storage/oqgraph/graphcore.cc 2010-03-31 07:54:07 +0000 @@ -0,0 +1,1101 @@ +/* Copyright (C) 2007-2009 Arjen G Lentz & Antony T Curtis for Open Query + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* ====================================================================== + Open Query Graph Computation Engine, based on a concept by Arjen Lentz + Mk.II implementation by Antony Curtis & Arjen Lentz + For more information, documentation, support, enhancement engineering, + and non-GPL licensing, see http://openquery.com/graph + or contact graph@openquery.com + For packaged binaries, see http://ourdelta.org + ====================================================================== +*/ + +#include <strings.h> + +#define BOOST_ALL_NO_LIB 1 + +#include <boost/config.hpp> + +#include <set> +#include <stack> + +#include <boost/property_map/property_map.hpp> + +#include <boost/graph/graph_concepts.hpp> +#include <boost/graph/graph_archetypes.hpp> +#include <boost/graph/adjacency_list.hpp> +#include <boost/graph/breadth_first_search.hpp> +#include <boost/graph/dijkstra_shortest_paths.hpp> +#include <boost/graph/iteration_macros.hpp> +#include <boost/graph/reverse_graph.hpp> +#include <boost/graph/graph_utility.hpp> + +#include "graphcore.h" + +using namespace open_query; +using namespace boost; + +static const row empty_row = { 0 }; + +namespace open_query +{ + enum vertex_id_t { vertex_id }; + + struct VertexInfo { + inline VertexInfo() { } + + inline VertexInfo(VertexID _id) + : id(_id) { } + + VertexID id; + }; + + struct EdgeInfo { + EdgeWeight weight; + }; +} + +namespace boost +{ + BOOST_INSTALL_PROPERTY(vertex, id); + + namespace graph + { + template<> + struct internal_vertex_name<VertexInfo> + { + typedef multi_index::member<VertexInfo, VertexID, &VertexInfo::id> type; + }; + + template<> + struct internal_vertex_constructor<VertexInfo> + { + typedef vertex_from_name<VertexInfo> type; + }; + } +} + +namespace open_query +{ + + #include "graphcore-graph.h" + + typedef graph_traits<Graph>::vertex_descriptor Vertex; + typedef graph_traits<Graph>::edge_descriptor Edge; + + typedef std::list<std::pair<Vertex,optional<EdgeWeight> > > shortest_path_list; + typedef shortest_path_list::iterator shortest_path_iterator; + + template<typename ID, typename IDMap> + class id_equals_t + { + public: + id_equals_t(ID id, IDMap map) + : m_id(id), m_map(map) + { } + template<typename V> + bool operator()(V u) const + { + return m_map[u] == m_id; + } + private: + ID m_id; + IDMap m_map; + }; + + template<typename ID, typename IDMap> + inline id_equals_t<ID,IDMap> + id_equals(ID id, IDMap idmap) + { + return id_equals_t<ID,IDMap>(id, idmap); + } + + template<typename T, typename Graph> + class target_equals_t + { + public: + target_equals_t(T target, Graph &g) + : m_target(target), m_g(g) + { } + template<typename V> + bool operator()(V u) const + { + return target(u, m_g) == m_target; + } + private: + T m_target; + Graph &m_g; + }; + + template<typename T, typename Graph> + inline target_equals_t<T,Graph> + target_equals(T target, Graph &g) + { + return target_equals_t<T,Graph>(target, g); + } + + template<typename T, typename Graph> + class source_equals_t + { + public: + source_equals_t(T source, Graph &g) + : m_source(source), m_g(g) + { } + template<typename V> + bool operator()(V u) const + { + return source(u, m_g) == m_source; + } + private: + T m_source; + Graph &m_g; + }; + + template<typename T, typename Graph> + inline source_equals_t<T,Graph> + source_equals(T source, Graph &g) + { + return source_equals_t<T,Graph>(source, g); + } + + struct reference + { + int m_flags; + int m_sequence; + Vertex m_vertex; + Edge m_edge; + EdgeWeight m_weight; + + enum + { + HAVE_SEQUENCE = 1, + HAVE_WEIGHT = 2, + HAVE_EDGE = 4, + }; + + inline reference() + : m_flags(0), m_sequence(0), + m_vertex(graph_traits<Graph>::null_vertex()), + m_edge(), m_weight(0) + { } + + inline reference(int s, Edge e) + : m_flags(HAVE_SEQUENCE | HAVE_EDGE), m_sequence(s), + m_vertex(graph_traits<Graph>::null_vertex()), + m_edge(e), m_weight(0) + { } + + inline reference(int s, Vertex v, const optional<Edge> &e, + const optional<EdgeWeight> &w) + : m_flags(HAVE_SEQUENCE | (w ? HAVE_WEIGHT : 0) | (e ? HAVE_EDGE : 0)), + m_sequence(s), m_vertex(v) + { + if (w) m_weight= *w; + if (e) m_edge= *e; + } + + inline reference(int s, Vertex v, Edge e, EdgeWeight w) + : m_flags(HAVE_SEQUENCE | HAVE_WEIGHT | HAVE_EDGE), + m_sequence(s), m_vertex(v), m_edge(e), m_weight(w) + { } + + inline reference(int s, Vertex v, EdgeWeight w) + : m_flags(HAVE_SEQUENCE | HAVE_WEIGHT), + m_sequence(s), m_vertex(v), m_edge(), m_weight(w) + { } + + inline reference(int s, Vertex v) + : m_flags(HAVE_SEQUENCE), m_sequence(s), m_vertex(v), m_edge(), + m_weight(0) + { } + + optional<int> sequence() const + { + if (m_flags & HAVE_SEQUENCE) + { + return m_sequence; + } + return optional<int>(); + } + + optional<Vertex> vertex() const + { + if (m_vertex != graph_traits<Graph>::null_vertex()) + return m_vertex; + return optional<Vertex>(); + } + + optional<Edge> edge() const + { + if (m_flags & HAVE_EDGE) + return m_edge; + return optional<Edge>(); + }; + + optional<EdgeWeight> weight() const + { + if (m_flags & HAVE_WEIGHT) + return m_weight; + return optional<EdgeWeight>(); + } + }; +} + +namespace open_query { + class GRAPHCORE_INTERNAL oqgraph_share + { + public: + Graph g; + + weightmap_type weightmap; + idmap_type idmap; + indexmap_type indexmap; + + optional<Vertex> find_vertex(VertexID id) const; + optional<Edge> find_edge(Vertex, Vertex) const; + + inline oqgraph_share() throw() + : g(), + weightmap(GRAPH_WEIGHTMAP(g)), + idmap(GRAPH_IDMAP(g)), + indexmap(GRAPH_INDEXMAP(g)) + { } + inline ~oqgraph_share() + { } + }; + + class GRAPHCORE_INTERNAL oqgraph_cursor + { + public: + oqgraph_share *const share; + + inline oqgraph_cursor(oqgraph_share *arg) + : share(arg) + { } + virtual ~oqgraph_cursor() + { } + + virtual int fetch_row(const row &, row&) = 0; + virtual int fetch_row(const row &, row&, const reference&) = 0; + virtual void current(reference& ref) const = 0; + }; +} + +namespace open_query { + class GRAPHCORE_INTERNAL stack_cursor : public oqgraph_cursor + { + private: + optional<EdgeWeight> no_weight; + public: + int sequence; + std::stack<reference> results; + reference last; + + inline stack_cursor(oqgraph_share *arg) + : oqgraph_cursor(arg), no_weight(), sequence(0), results(), last() + { } + + int fetch_row(const row &, row&); + int fetch_row(const row &, row&, const reference&); + + void current(reference& ref) const + { + ref= last; + } + }; + + class GRAPHCORE_INTERNAL vertices_cursor : public oqgraph_cursor + { + typedef graph_traits<Graph>::vertex_iterator vertex_iterator; + + size_t position; + reference last; + public: + inline vertices_cursor(oqgraph_share *arg) + : oqgraph_cursor(arg), position(0) + { } + + int fetch_row(const row &, row&); + int fetch_row(const row &, row&, const reference&); + + void current(reference& ref) const + { + ref= last; + } + + }; + + class GRAPHCORE_INTERNAL edges_cursor : public oqgraph_cursor + { + typedef graph_traits<Graph>::edge_iterator edge_iterator; + typedef edge_iterator::difference_type edge_difference; + + edge_difference position; + reference last; + public: + inline edges_cursor(oqgraph_share *arg) + : oqgraph_cursor(arg), position(0), last() + { } + + int fetch_row(const row &, row&); + int fetch_row(const row &, row&, const reference&); + + void current(reference& ref) const + { + ref= last; + } + }; + + struct GRAPHCORE_INTERNAL oqgraph_visit_dist + : public base_visitor<oqgraph_visit_dist> + { + typedef on_finish_vertex event_filter; + + oqgraph_visit_dist(std::vector<Vertex>::iterator p, + std::vector<EdgeWeight>::iterator d, + stack_cursor *cursor) + : seq(0), m_cursor(*cursor), m_p(p), m_d(d) + { assert(cursor); } + + template<class T, class Graph> + void operator()(T u, Graph &g) + { + m_cursor.results.push(reference(++seq, u, m_d[GRAPH_INDEXMAP(g)[u]])); + } + private: + int seq; + stack_cursor &m_cursor; + std::vector<Vertex>::iterator m_p; + std::vector<EdgeWeight>::iterator m_d; + }; + + template<bool record_weight, typename goal_filter> + struct GRAPHCORE_INTERNAL oqgraph_goal + : public base_visitor<oqgraph_goal<record_weight,goal_filter> > + { + typedef goal_filter event_filter; + + oqgraph_goal(Vertex goal, std::vector<Vertex>::iterator p, + stack_cursor *cursor) + : m_goal(goal), m_cursor(*cursor), m_p(p) + { assert(cursor); } + + template<class T, class Graph> + void operator()(T u, Graph &g) + { + if (u == m_goal) + { + int seq= 0; + indexmap_type indexmap= GRAPH_INDEXMAP(g); + + for (Vertex q, v= u;; v = q, seq++) + if ((q= m_p[ indexmap[v] ]) == v) + break; + + for (Vertex v= u;; u= v) + { + optional<Edge> edge; + optional<EdgeWeight> weight; + v= m_p[ indexmap[u] ]; + if (record_weight && u != v) + { + typename graph_traits<Graph>::out_edge_iterator ei, ei_end; + for (tie(ei, ei_end)= out_edges(v, g); ei != ei_end; ++ei) + { + if (target(*ei, g) == u) + { + edge= *ei; + weight= GRAPH_WEIGHTMAP(g)[*ei]; + break; + } + } + } + else if (u != v) + weight= 1; + m_cursor.results.push(reference(seq--, u, edge, weight)); + if (u == v) + break; + } + throw this; + } + } + + private: + Vertex m_goal; + stack_cursor &m_cursor; + std::vector<Vertex>::iterator m_p; + }; +} + +namespace open_query +{ + inline oqgraph::oqgraph(oqgraph_share *arg) throw() + : share(arg), cursor(0) + { } + + inline oqgraph::~oqgraph() throw() + { + delete cursor; + } + + unsigned oqgraph::edges_count() const throw() + { + return num_edges(share->g); + } + + unsigned oqgraph::vertices_count() const throw() + { + return num_vertices(share->g); + } + + oqgraph* oqgraph::create(oqgraph_share *share) throw() + { + assert(share != NULL); + return new (std::nothrow) oqgraph(share); + } + + oqgraph_share* oqgraph::create() throw() + { + return new (std::nothrow) oqgraph_share(); + } + + optional<Edge> + oqgraph_share::find_edge(Vertex orig, Vertex dest) const + { + if (in_degree(dest, g) >= out_degree(orig, g)) + { + graph_traits<Graph>::out_edge_iterator ei, ei_end; + tie(ei, ei_end)= out_edges(orig, g); + if ((ei= find_if(ei, ei_end, target_equals(dest, g))) != ei_end) + return *ei; + } + else + { + graph_traits<Graph>::in_edge_iterator ei, ei_end; + tie(ei, ei_end)= in_edges(dest, g); + if ((ei= find_if(ei, ei_end, source_equals(orig, g))) != ei_end) + return *ei; + } + return optional<Edge>(); + } + + optional<Vertex> + oqgraph_share::find_vertex(VertexID id) const + { + return boost::graph::find_vertex(id, g); + } + + int oqgraph::delete_all() throw() + { + share->g.clear(); + return 0; + } + + int oqgraph::insert_edge( + VertexID orig_id, VertexID dest_id, EdgeWeight weight, bool replace) throw() + { + optional<Vertex> orig, dest; + optional<Edge> edge; + bool inserted= 0; + + if (weight < 0) + return INVALID_WEIGHT; + if (!(orig= share->find_vertex(orig_id))) + { + try + { + orig= add_vertex(VertexInfo(orig_id), share->g); + if (orig == graph_traits<Graph>::null_vertex()) + return CANNOT_ADD_VERTEX; + } + catch (...) + { + return CANNOT_ADD_VERTEX; + } + } + if (!(dest= share->find_vertex(dest_id))) + { + try + { + dest= add_vertex(VertexInfo(dest_id), share->g); + if (dest == graph_traits<Graph>::null_vertex()) + return CANNOT_ADD_VERTEX; + } + catch (...) + { + return CANNOT_ADD_VERTEX; + } + } + if (!(edge= share->find_edge(*orig, *dest))) + { + try + { + tie(edge, inserted)= add_edge(*orig, *dest, share->g); + if (!inserted) + return CANNOT_ADD_EDGE; + } + catch (...) + { + return CANNOT_ADD_EDGE; + } + } + else + { + if (!replace) + return DUPLICATE_EDGE; + } + share->weightmap[*edge]= weight; + return OK; + } + + int oqgraph::delete_edge(current_row_st) throw() + { + reference ref; + if (cursor) + return EDGE_NOT_FOUND; + cursor->current(ref); + optional<Edge> edge; + if (!(edge= ref.edge())) + return EDGE_NOT_FOUND; + Vertex orig= source(*edge, share->g); + Vertex dest= target(*edge, share->g); + remove_edge(*edge, share->g); + if (!degree(orig, share->g)) + remove_vertex(orig, share->g); + if (!degree(dest, share->g)) + remove_vertex(dest, share->g); + return OK; + } + + int oqgraph::modify_edge(current_row_st, + VertexID *orig_id, VertexID *dest_id, EdgeWeight *weight, + bool replace) throw() + { + if (!cursor) + return EDGE_NOT_FOUND; + reference ref; + cursor->current(ref); + optional<Edge> edge; + if (!(edge= ref.edge())) + return EDGE_NOT_FOUND; + if (weight && *weight < 0) + return INVALID_WEIGHT; + + optional<Vertex> orig= source(*edge, share->g), + dest= target(*edge, share->g); + + bool orig_neq= orig_id ? share->idmap[*orig] != *orig_id : 0; + bool dest_neq= dest_id ? share->idmap[*dest] != *dest_id : 0; + if (orig_neq || dest_neq) + { + optional<Edge> new_edge; + if (orig_neq && !(orig= share->find_vertex(*orig_id))) + { + try + { + orig= add_vertex(VertexInfo(*orig_id), share->g); + if (orig == graph_traits<Graph>::null_vertex()) + return CANNOT_ADD_VERTEX; + } + catch (...) + { + return CANNOT_ADD_VERTEX; + } + } + if (dest_neq && !(dest= share->find_vertex(*dest_id))) + { + try + { + dest= add_vertex(VertexInfo(*dest_id), share->g); + if (dest == graph_traits<Graph>::null_vertex()) + return CANNOT_ADD_VERTEX; + } + catch (...) + { + return CANNOT_ADD_VERTEX; + } + } + if (!(new_edge= share->find_edge(*orig, *dest))) + { + try + { + bool inserted; + tie(new_edge, inserted)= add_edge(*orig, *dest, share->g); + if (!inserted) + return CANNOT_ADD_EDGE; + } + catch (...) + { + return CANNOT_ADD_EDGE; + } + } + else + { + if (!replace) + return DUPLICATE_EDGE; + } + share->weightmap[*new_edge]= share->weightmap[*edge]; + remove_edge(*edge, share->g); + edge= new_edge; + } + if (weight) + share->weightmap[*edge]= *weight; + return OK; + } + + int oqgraph::modify_edge( + VertexID orig_id, VertexID dest_id, EdgeWeight weight) throw() + { + optional<Vertex> orig, dest; + optional<Edge> edge; + + if (weight < 0) + return INVALID_WEIGHT; + if (!(orig= share->find_vertex(orig_id))) + return EDGE_NOT_FOUND; + if (!(dest= share->find_vertex(dest_id))) + return EDGE_NOT_FOUND; + if (!(edge= share->find_edge(*orig, *dest))) + return EDGE_NOT_FOUND; + share->weightmap[*edge]= weight; + return OK; + } + + + int oqgraph::delete_edge(VertexID orig_id, VertexID dest_id) throw() + { + optional<Vertex> orig, dest; + optional<Edge> edge; + + if (!(orig= share->find_vertex(orig_id))) + return EDGE_NOT_FOUND; + if (!(dest= share->find_vertex(dest_id))) + return EDGE_NOT_FOUND; + if (!(edge= share->find_edge(*orig, *dest))) + return EDGE_NOT_FOUND; + remove_edge(*edge, share->g); + if (!degree(*orig, share->g)) + remove_vertex(*orig, share->g); + if (!degree(*dest, share->g)) + remove_vertex(*dest, share->g); + return OK; + } + + + int oqgraph::search(int *latch, VertexID *orig_id, VertexID *dest_id) throw() + { + optional<Vertex> orig, dest; + int op= 0, seq= 0; + enum { + NO_SEARCH = 0, + DIJKSTRAS = 1, + BREADTH_FIRST = 2, + + ALGORITHM = 0x0ffff, + HAVE_ORIG = 0x10000, + HAVE_DEST = 0x20000, + }; + + delete cursor; cursor= 0; + row_info= empty_row; + if ((row_info.latch_indicator= latch)) + op= ALGORITHM & (row_info.latch= *latch); + if ((row_info.orig_indicator= orig_id) && (op|= HAVE_ORIG)) + orig= share->find_vertex((row_info.orig= *orig_id)); + if ((row_info.dest_indicator= dest_id) && (op|= HAVE_DEST)) + dest= share->find_vertex((row_info.dest= *dest_id)); + //try + //{ + switch (op) + { + case NO_SEARCH | HAVE_ORIG | HAVE_DEST: + case NO_SEARCH | HAVE_ORIG: + if ((cursor= new (std::nothrow) stack_cursor(share)) && orig) + { + graph_traits<Graph>::out_edge_iterator ei, ei_end; + for (tie(ei, ei_end)= out_edges(*orig, share->g); ei != ei_end; ++ei) + { + Vertex v= target(*ei, share->g); + static_cast<stack_cursor*>(cursor)-> + results.push(reference(++seq, v, *ei, share->weightmap[*ei])); + } + } + /* fall through */ + case NO_SEARCH | HAVE_DEST: + if ((op & HAVE_DEST) && + (cursor || (cursor= new (std::nothrow) stack_cursor(share))) && + dest) + { + graph_traits<Graph>::in_edge_iterator ei, ei_end; + for (tie(ei, ei_end)= in_edges(*dest, share->g); ei != ei_end; ++ei) + { + Vertex v= source(*ei, share->g); + static_cast<stack_cursor*>(cursor)-> + results.push(reference(++seq, v, *ei, share->weightmap[*ei])); + } + } + break; + + case NO_SEARCH: + cursor= new (std::nothrow) vertices_cursor(share); + break; + + case DIJKSTRAS | HAVE_ORIG | HAVE_DEST: + if ((cursor= new (std::nothrow) stack_cursor(share)) && orig && dest) + { + std::vector<Vertex> p(num_vertices(share->g)); + std::vector<EdgeWeight> d(num_vertices(share->g)); + oqgraph_goal<true, on_finish_vertex> + vis(*dest, p.begin(), static_cast<stack_cursor*>(cursor)); + p[share->indexmap[*orig]]= *orig; + try + { + dijkstra_shortest_paths(share->g, *orig, + weight_map( + share->weightmap + ). + distance_map( + make_iterator_property_map(d.begin(), share->indexmap) + ). + predecessor_map( + make_iterator_property_map(p.begin(), share->indexmap) + ). + visitor( + make_dijkstra_visitor(vis) + ) + ); + } + catch (...) + { /* printf("found\n"); */ } + } + break; + + case BREADTH_FIRST | HAVE_ORIG | HAVE_DEST: + if ((cursor= new (std::nothrow) stack_cursor(share)) && orig && dest) + { + std::vector<Vertex> p(num_vertices(share->g)); + oqgraph_goal<false, on_discover_vertex> + vis(*dest, p.begin(), static_cast<stack_cursor*>(cursor)); + p[share->indexmap[*orig]]= *orig; + try + { + breadth_first_search(share->g, *orig, + visitor(make_bfs_visitor( + std::make_pair( + record_predecessors( + make_iterator_property_map(p.begin(), share->indexmap), + on_tree_edge() + ), + vis) + ) + ) + ); + } + catch (...) + { /* printf("found\n"); */ } + } + break; + + case DIJKSTRAS | HAVE_ORIG: + case BREADTH_FIRST | HAVE_ORIG: + if ((cursor= new (std::nothrow) stack_cursor(share)) && (orig || dest)) + { + std::vector<Vertex> p(num_vertices(share->g)); + std::vector<EdgeWeight> d(num_vertices(share->g)); + oqgraph_visit_dist vis(p.begin(), d.begin(), + static_cast<stack_cursor*>(cursor)); + p[share->indexmap[*orig]]= *orig; + switch (ALGORITHM & op) + { + case DIJKSTRAS: + dijkstra_shortest_paths(share->g, *orig, + weight_map( + share->weightmap + ). + distance_map( + make_iterator_property_map(d.begin(), share->indexmap) + ). + predecessor_map( + make_iterator_property_map(p.begin(), share->indexmap) + ). + visitor( + make_dijkstra_visitor(vis) + ) + ); + break; + case BREADTH_FIRST: + breadth_first_search(share->g, *orig, + visitor(make_bfs_visitor( + std::make_pair( + record_predecessors( + make_iterator_property_map(p.begin(), + share->indexmap), + on_tree_edge() + ), + std::make_pair( + record_distances( + make_iterator_property_map(d.begin(), + share->indexmap), + on_tree_edge() + ), + vis + )) + )) + ); + break; + default: + abort(); + } + } + break; + + case BREADTH_FIRST | HAVE_DEST: + case DIJKSTRAS | HAVE_DEST: + if ((cursor= new (std::nothrow) stack_cursor(share)) && (orig || dest)) + { + std::vector<Vertex> p(num_vertices(share->g)); + std::vector<EdgeWeight> d(num_vertices(share->g)); + oqgraph_visit_dist vis(p.begin(), d.begin(), + static_cast<stack_cursor*>(cursor)); + reverse_graph<Graph> r(share->g); + p[share->indexmap[*dest]]= *dest; + switch (ALGORITHM & op) + { + case DIJKSTRAS: + dijkstra_shortest_paths(r, *dest, + weight_map( + share->weightmap + ). + distance_map( + make_iterator_property_map(d.begin(), share->indexmap) + ). + predecessor_map( + make_iterator_property_map(p.begin(), share->indexmap) + ). + visitor( + make_dijkstra_visitor(vis) + ) + ); + break; + case BREADTH_FIRST: + breadth_first_search(r, *dest, + visitor(make_bfs_visitor( + std::make_pair( + record_predecessors( + make_iterator_property_map(p.begin(), + share->indexmap), + on_tree_edge() + ), + std::make_pair( + record_distances( + make_iterator_property_map(d.begin(), + share->indexmap), + on_tree_edge() + ), + vis + )) + )) + ); + break; + default: + abort(); + } + } + break; + + default: + break; + } + return 0; + //} + //catch (...) + //{ + // return MISC_FAIL; + //} + } + + int oqgraph::fetch_row(row& result) throw() + { + if (!cursor) + return NO_MORE_DATA; + return cursor->fetch_row(row_info, result); + } + + int oqgraph::fetch_row(row& result, const void* ref_ptr) throw() + { + const reference &ref= *(const reference*) ref_ptr; + if (!cursor) + return NO_MORE_DATA; + return cursor->fetch_row(row_info, result, ref); + } + + void oqgraph::row_ref(void *ref_ptr) throw() + { + reference &ref= *(reference*) ref_ptr; + if (cursor) + cursor->current(ref); + else + ref= reference(); + } + + int oqgraph::random(bool scan) throw() + { + if (scan || !cursor) + { + delete cursor; cursor= 0; + if (!(cursor= new (std::nothrow) edges_cursor(share))) + return MISC_FAIL; + } + row_info= empty_row; + return OK; + } + + void oqgraph::free(oqgraph *graph) throw() + { + delete graph; + } + + void oqgraph::free(oqgraph_share *graph) throw() + { + delete graph; + } + + const size_t oqgraph::sizeof_ref= sizeof(reference); +} + +int stack_cursor::fetch_row(const row &row_info, row &result) +{ + if (!results.empty()) + { + if (int res= fetch_row(row_info, result, results.top())) + return res; + results.pop(); + return oqgraph::OK; + } + else + { + last= reference(); + return oqgraph::NO_MORE_DATA; + } +} + +int stack_cursor::fetch_row(const row &row_info, row &result, + const reference &ref) +{ + last= ref; + if (optional<Vertex> v= last.vertex()) + { + optional<int> seq; + optional<EdgeWeight> w; + optional<Vertex> v; + result= row_info; + if ((result.seq_indicator= seq= last.sequence())) + result.seq= *seq; + if ((result.link_indicator= v= last.vertex())) + result.link= share->idmap[*v]; + if ((result.weight_indicator= w= last.weight())) + result.weight= *w; + return oqgraph::OK; + } + else + return oqgraph::NO_MORE_DATA; +} + + +int vertices_cursor::fetch_row(const row &row_info, row &result) +{ + vertex_iterator it, end; + reference ref; + size_t count= position; + for (tie(it, end)= vertices(share->g); count && it != end; ++it, --count) + ; + if (it != end) + ref= reference(position+1, *it); + if (int res= fetch_row(row_info, result, ref)) + return res; + position++; + return oqgraph::OK; +} + +int vertices_cursor::fetch_row(const row &row_info, row &result, + const reference &ref) +{ + last= ref; + optional<Vertex> v= last.vertex(); + result= row_info; + if (v) + { + result.link_indicator= 1; + result.link= share->idmap[*v]; +#ifdef DISPLAY_VERTEX_INFO + result.seq_indicator= 1; + if ((result.seq= degree(*v, share->g))) + { + EdgeWeight weight= 0; + graph_traits<Graph>::in_edge_iterator iei, iei_end; + for (tie(iei, iei_end)= in_edges(*v, share->g); iei != iei_end; ++iei) + weight+= share->weightmap[*iei]; + graph_traits<Graph>::out_edge_iterator oei, oei_end; + for (tie(oei, oei_end)= out_edges(*v, share->g); oei != oei_end; ++oei) + weight+= share->weightmap[*oei]; + result.weight_indicator= 1; + result.weight= weight / result.seq; + } +#endif + return oqgraph::OK; + } + else + return oqgraph::NO_MORE_DATA; +} + +int edges_cursor::fetch_row(const row &row_info, row &result) +{ + edge_iterator it, end; + reference ref; + size_t count= position; + for (tie(it, end)= edges(share->g); count && it != end; ++it, --count) + ; + if (it != end) + ref= reference(position+1, *it); + if (int res= fetch_row(row_info, result, ref)) + return res; + ++position; + return oqgraph::OK; +} + +int edges_cursor::fetch_row(const row &row_info, row &result, + const reference &ref) +{ + optional<Edge> edge; + if ((edge= (last= ref).edge())) + { + result= row_info; + result.orig_indicator= result.dest_indicator= result.weight_indicator= 1; + result.orig= share->idmap[ source( *edge, share->g ) ]; + result.dest= share->idmap[ target( *edge, share->g ) ]; + result.weight= share->weightmap[ *edge ]; + return oqgraph::OK; + } + return oqgraph::NO_MORE_DATA; +} + +namespace boost { + GRAPHCORE_INTERNAL void throw_exception(std::exception const&) + { + abort(); + } +} === added file 'storage/oqgraph/graphcore.h' --- a/storage/oqgraph/graphcore.h 1970-01-01 00:00:00 +0000 +++ b/storage/oqgraph/graphcore.h 2010-01-04 08:27:50 +0000 @@ -0,0 +1,116 @@ +/* Copyright (C) 2007-2009 Arjen G Lentz & Antony T Curtis for Open Query + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* ====================================================================== + Open Query Graph Computation Engine, based on a concept by Arjen Lentz + Mk.II implementation by Antony Curtis & Arjen Lentz + For more information, documentation, support, enhancement engineering, + and non-GPL licensing, see http://openquery.com/graph + or contact graph@openquery.com + For packaged binaries, see http://ourdelta.org + ====================================================================== +*/ + +#ifndef oq_graphcore_h_ +#define oq_graphcore_h_ + +/* #define GRAPHCORE_INTERNAL __attribute__((visibility("hidden"))) */ +#define GRAPHCORE_INTERNAL + +#include "graphcore-types.h" + +namespace open_query +{ + class oqgraph_share; + class oqgraph_cursor; + + struct row + { + bool latch_indicator; + bool orig_indicator; + bool dest_indicator; + bool weight_indicator; + bool seq_indicator; + bool link_indicator; + + int latch; + VertexID orig; + VertexID dest; + EdgeWeight weight; + unsigned seq; + VertexID link; + }; + + class oqgraph + { + oqgraph_share *const share; + oqgraph_cursor *cursor; + row row_info; + + inline oqgraph(oqgraph_share*) throw(); + inline ~oqgraph() throw(); + public: + + enum error_code + { + OK= 0, + NO_MORE_DATA, + EDGE_NOT_FOUND, + INVALID_WEIGHT, + DUPLICATE_EDGE, + CANNOT_ADD_VERTEX, + CANNOT_ADD_EDGE, + MISC_FAIL + }; + + struct current_row_st {}; + static inline current_row_st current_row() + { return current_row_st(); } + + unsigned vertices_count() const throw(); + unsigned edges_count() const throw(); + + int delete_all(void) throw(); + + int insert_edge(VertexID, VertexID, EdgeWeight, bool=0) throw(); + int modify_edge(VertexID, VertexID, EdgeWeight) throw(); + int delete_edge(VertexID, VertexID) throw(); + + int modify_edge(current_row_st, + VertexID*, VertexID*, EdgeWeight*, bool=0) throw(); + int delete_edge(current_row_st) throw(); + + int replace_edge(VertexID orig, VertexID dest, EdgeWeight weight) throw() + { return insert_edge(orig, dest, weight, true); } + + int search(int*, VertexID*, VertexID*) throw(); + int random(bool) throw(); + + int fetch_row(row&) throw(); + int fetch_row(row&, const void*) throw(); + void row_ref(void*) throw(); + + static oqgraph* create(oqgraph_share*) throw(); + static oqgraph_share *create() throw(); + + static void free(oqgraph*) throw(); + static void free(oqgraph_share*) throw(); + + static const size_t sizeof_ref; + }; + +} +#endif === added file 'storage/oqgraph/graphstore.c' --- a/storage/oqgraph/graphstore.c 1970-01-01 00:00:00 +0000 +++ b/storage/oqgraph/graphstore.c 2010-01-04 08:27:50 +0000 @@ -0,0 +1,356 @@ +/* + * Graph Engine - Copyright (C) 2007 by Arjen Lentz (arjen@openquery.com.au) + * graphstore.c internal storage system + */ +#include <stdlib.h> +#include <string.h> +#include <my_global.h> +#include <my_sys.h> +#include "graphstore.h" + + +/* + create a new vertex, and add it to the list (or start a list) + NOTE! gspp is ptr to base ptr + + returns 1 for ok, 0 for error +*/ +static int _add_vertex (GRAPHSTORE **gspp, GRAPH_VERTEXID id) +{ + GRAPHSTORE *newgsp; + GRAPHSTORE *gscurp; + + if (gspp == NULL) + return 0; + + /* not allowing 0 */ + if (!id) + return 0; + + if (*gspp != NULL) { + for (gscurp = *gspp; gscurp != NULL; gscurp = gscurp->next) { + if (gscurp->vertex->id == id) + return 1; /* we can ignore, id already exists */ + } + } + + /* allocate and initialise */ + if ((newgsp = my_malloc(sizeof (GRAPHSTORE),MYF(MY_ZEROFILL))) == NULL) + return 0; + + if ((newgsp->vertex = my_malloc(sizeof (GRAPH_VERTEX),MYF(MY_ZEROFILL))) == NULL) { + my_free(newgsp,MYF(0)); + return 0; + } + + newgsp->vertex->id = id; + /* add new vertex to end of list */ + if (*gspp != NULL) { + for (gscurp = *gspp; gscurp->next != NULL; gscurp = gscurp->next); + gscurp->next = newgsp; + } + else /* new list */ + *gspp = newgsp; + + /* ok */ + return 1; +} + + +/* + find a vertex by id + + returns ptr or NULL +*/ +static GRAPH_VERTEX *_find_vertex (GRAPHSTORE *gsp, GRAPH_VERTEXID id) +{ + /* just loop through the list to find id */ + while (gsp != NULL && gsp->vertex->id != id) + gsp = gsp->next; + + /* return ptr to vertex, or NULL */ + return (gsp != NULL ? gsp->vertex : NULL); +} + + +/* + add edge + both vertices must already exist; graphstore_insert() does this + + return 1 for ok, 0 for error (already exists, alloc error, etc) +*/ +static int _add_edge (GRAPHSTORE *gsp, GRAPH_VERTEXID origid, GRAPH_VERTEXID destid, GRAPH_WEIGHT weight) +{ + GRAPH_VERTEX *origvp, *destvp; + GRAPH_EDGE *ep, *newep; + + /* find both vertices */ + if ((origvp = _find_vertex(gsp,origid)) == NULL || + (destvp = _find_vertex(gsp,destid)) == NULL) + return 0; + + /* check if edge already exists */ + for (ep = origvp->forward_edge; ep != NULL; ep = ep->next_edge) { + if (ep->vertex->id == destid) + return 0; + } + + /* allocate and initialise new edge */ + if ((newep = my_malloc(sizeof (GRAPH_EDGE),MYF(MY_ZEROFILL))) == NULL) + return 0; + + newep->vertex = destvp; + newep->weight = weight; + + /* insert new edge at start of chain, that's easiest */ + ep = origvp->forward_edge; + origvp->forward_edge = newep; + newep->next_edge = ep; + + /* ok */ + return 1; +} + + +/* + create a new row, and add it to the graph set (or start set) + NOTE! gsetpp is ptr to base ptr + + returns 1 for ok, 0 for error +*/ +static int _add_graph_set (GRAPH_SET **gsetpp, GRAPH_TUPLE *gtp) +{ + GRAPH_SET *newgsetp; + GRAPH_SET *gsetcurp; + + if (gsetpp == NULL || gtp == NULL) + return 0; + + /* allocate and initialise */ + if ((newgsetp = my_malloc(sizeof (GRAPH_SET),MYF(MY_ZEROFILL))) == NULL) + return 0; + + /* put in the data */ + memcpy(&newgsetp->tuple,gtp,sizeof (GRAPH_TUPLE)); + + /* add new row to end of set */ + if (*gsetpp != NULL) { + for (gsetcurp = *gsetpp; gsetcurp->next != NULL; gsetcurp = gsetcurp->next); + gsetcurp->next = newgsetp; + } + else { /* new set */ + *gsetpp = newgsetp; + } + + /* ok */ + return 1; +} + + +/* + free a graph set (release memory) + + returns 1 for ok, 0 for error +*/ +int free_graph_set (GRAPH_SET *gsetp) +{ + GRAPH_SET *nextgsetp; + + if (gsetp == NULL) + return 0; + + while (gsetp != NULL) { + nextgsetp = gsetp->next; + /* free() is a void function, nothing to check */ + my_free(gsetp,MYF(0)); + gsetp = nextgsetp; + } + + /* ok */ + return 1; +} + + +/* + insert new data into graphstore + this can be either a vertex or an edge, depending on the params + NOTE! gspp is ptr to base ptr + + returns 1 for ok, 0 for error +*/ +int graphstore_insert (GRAPHSTORE **gspp, GRAPH_TUPLE *gtp) +{ + if (gspp == NULL) + return 0; + + /* if nada or no orig vertex, we can't do anything */ + if (gtp == NULL || !gtp->origid) + return 0; + +#if 0 +printf("inserting: origid=%lu destid=%lu weight=%lu\n",gtp->origid,gtp->destid,gtp->weight); +#endif + + if (!gtp->destid) /* no edge param so just adding vertex */ + return _add_vertex(gspp,gtp->origid); + + /* + add an edge + first add both vertices just in case they didn't yet exist... + not checking result there: if there's a prob, _add_edge() will catch. + */ + _add_vertex(gspp,gtp->origid); + _add_vertex(gspp,gtp->destid); + return _add_edge(*gspp,gtp->origid,gtp->destid,gtp->weight); +} + + +/* + this is an internal function used by graphstore_query() + + find any path from originating vertex to destid + if found, add to the result set on the way back + NOTE: recursive function! + + returns 1 for hit, 0 for nothing, -1 for error +*/ +int _find_any_path(GRAPH_SET **gsetpp, GRAPH_VERTEXID origid, GRAPH_VERTEXID destid, GRAPH_VERTEX *gvp, GRAPH_SEQ depth) +{ + GRAPH_EDGE *gep; + GRAPH_TUPLE tup; + int res; + + if (gvp->id == destid) { + /* found target! */ + bzero(&tup,sizeof (GRAPH_TUPLE)); + tup.origid = origid; + tup.destid = destid; + tup.seq = depth; + tup.linkid = gvp->id; + return (_add_graph_set(gsetpp,&tup) ? 1 : -1); + } + + /* walk through all edges for this vertex */ + for (gep = gvp->forward_edge; gep; gep = gep->next_edge) { + /* recurse */ + res = _find_any_path(gsetpp,origid,destid,gep->vertex,depth+1); + if (res < 0) + return res; + if (res > 0) { + /* found somewhere below this one, insert ourselves and return */ + bzero(&tup,sizeof (GRAPH_TUPLE)); + tup.origid = origid; + tup.destid = destid; + tup.weight = gep->weight; + tup.seq = depth; + tup.linkid = gvp->id; + return (_add_graph_set(gsetpp,&tup) ? 1 : -1); + } + } + + /* nothing found but no error */ + return 0; +} + + +/* + query graphstore + latch specifies what operation to perform + + we need to feed the conditions in... (through engine condition pushdown) + for now we just presume one condition per field so we just feed in a tuple + this also means we can just find constants, not ranges + + return ptr to GRAPH_SET + caller must free with free_graph_set() +*/ +GRAPH_SET *graphstore_query (GRAPHSTORE *gsp, GRAPH_TUPLE *gtp) +{ + GRAPH_SET *gsetp = NULL; + GRAPH_SET *gsetcurp; + GRAPH_SET *newgsetp; + + if (gsp == NULL || gtp == NULL) + return (NULL); + + switch (gtp->latch) { + case 0: /* return all vertices/edges */ + { + GRAPHSTORE *gscurp; + GRAPH_EDGE *gep; + GRAPH_TUPLE tup; + + /* walk through all vertices */ + for (gscurp = gsp; gscurp != NULL; gscurp = gscurp->next) { + /* check for condition */ + if (gtp->origid && gscurp->vertex->id != gtp->origid) + continue; + + bzero(&tup,sizeof (GRAPH_TUPLE)); + tup.origid = gscurp->vertex->id; + + /* no edges? */ + if (gscurp->vertex->forward_edge == NULL) { + /* just add vertex to set */ + if (!_add_graph_set(&gsetp,&tup)) { + if (gsetp != NULL) /* clean up */ + my_free(gsetp,MYF(0)); + return (NULL); + } + } + else { + /* walk through all edges */ + for (gep = gscurp->vertex->forward_edge; gep; gep = gep->next_edge) { + tup.destid = gep->vertex->id; + tup.weight = gep->weight; + + /* just add vertex to set */ + if (!_add_graph_set(&gsetp,&tup)) { + if (gsetp != NULL) /* clean up */ + my_free(gsetp,MYF(0)); + return (NULL); + } + } + } + } + } + break; + + case 1: /* find a path between origid and destid */ + /* yes it'll just go with the first path it finds! */ + { + GRAPHSTORE *gscurp; + GRAPH_VERTEX *origvp; + GRAPH_TUPLE tup; + + if (!gtp->origid || !gtp->destid) + return NULL; + + /* find both vertices */ + if ((origvp = _find_vertex(gsp,gtp->origid)) == NULL || + _find_vertex(gsp,gtp->destid) == NULL) + return NULL; + + if (_find_any_path(&gsetp,gtp->origid,gtp->destid,origvp,0) < 0) { /* error? */ + if (gsetp != NULL) /* clean up */ + my_free(gsetp,MYF(0)); + return NULL; + } + } + break; + + default: + /* this ends up being an empty set */ + break; + } + + /* Fix up latch column with the proper value - to be relationally correct */ + for (gsetcurp = gsetp; gsetcurp != NULL; gsetcurp = gsetcurp->next) + gsetcurp->tuple.latch = gtp->latch; + + return gsetp; +} + + + +/* end of graphstore.c */ \ No newline at end of file === added file 'storage/oqgraph/graphstore.h' --- a/storage/oqgraph/graphstore.h 1970-01-01 00:00:00 +0000 +++ b/storage/oqgraph/graphstore.h 2010-01-04 08:27:50 +0000 @@ -0,0 +1,90 @@ +/* + * Graph Engine - Copyright (C) 2007 by Arjen Lentz (arjen@openquery.com.au) + * graphstore.h internal storage system + */ +//typedef unsigned short uint16; +//typedef unsigned long long uint64; + + +/* + This is essentially what a GRAPH engine table looks like on the MySQL end: + CREATE TABLE foo ( + latch SMALLINT UNSIGNED NULL, + origid BIGINT UNSIGNED NULL, + destid BIGINT UNSIGNED NULL, + weight BIGINT UNSIGNED NULL, + seq BIGINT UNSIGNED NULL, + linkid BIGINT UNSIGNED NULL + ) ENGINE=OQGRAPH +*/ + + +/* + We represent the above in C in the following way: +*/ +typedef uint16 GRAPH_LATCH; +typedef uint64 GRAPH_VERTEXID; +typedef uint64 GRAPH_WEIGHT; +typedef uint64 GRAPH_SEQ; + +typedef struct graph_tuple { + GRAPH_LATCH latch; /* function */ + GRAPH_VERTEXID origid; /* vertex (should be != 0) */ + GRAPH_VERTEXID destid; /* edge */ + GRAPH_WEIGHT weight; /* weight */ + GRAPH_SEQ seq; /* seq# within (origid) */ + GRAPH_VERTEXID linkid; /* current step between origid/destid */ +} GRAPH_TUPLE; + +typedef struct graph_set { + GRAPH_TUPLE tuple; + struct graph_set *next; +} GRAPH_SET; + + +/* + Internally, sets look nothing like the above + + - We have vertices, connected by edges. + - Each vertex' edges are maintained in a linked list. + - Edges can be weighted. + + There are some issues with this structure, it'd be a pest to do a delete + So for now, let's just not support deletes! +*/ +/* the below is half-gross and will likely change */ +typedef struct graph_edge { + struct graph_vertex { + GRAPH_VERTEXID id; + struct graph_edge *forward_edge; + } *vertex; + GRAPH_WEIGHT weight; + struct graph_edge *next_edge; +} GRAPH_EDGE; + +typedef struct graph_vertex GRAPH_VERTEX; + + +/* + A rough internal storage system for a set +*/ +/* this below is fully gross and will definitely change */ +typedef struct graphstore { + GRAPH_VERTEX *vertex; /* changed to ptr when integrating into MySQL */ + struct graphstore *next; +} GRAPHSTORE; + +#ifdef __cplusplus +extern "C" { +#endif + +/* public function declarations */ +int graphstore_insert (GRAPHSTORE **gspp, GRAPH_TUPLE *gtp); +GRAPH_SET *graphstore_query (GRAPHSTORE *gsp, GRAPH_TUPLE *gtp); +int free_graph_set (GRAPH_SET *gsetp); + +#ifdef __cplusplus +} +#endif + +/* end of graphstore.h */ \ No newline at end of file === added file 'storage/oqgraph/ha_oqgraph.cc' --- a/storage/oqgraph/ha_oqgraph.cc 1970-01-01 00:00:00 +0000 +++ b/storage/oqgraph/ha_oqgraph.cc 2010-01-04 13:32:42 +0000 @@ -0,0 +1,1040 @@ +/* Copyright (C) 2007-2009 Arjen G Lentz & Antony T Curtis for Open Query + Portions of this file copyright (C) 2000-2006 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* ====================================================================== + Open Query Graph Computation Engine, based on a concept by Arjen Lentz + Mk.II implementation by Antony Curtis & Arjen Lentz + For more information, documentation, support, enhancement engineering, + and non-GPL licensing, see http://openquery.com/graph + or contact graph@openquery.com + For packaged binaries, see http://ourdelta.org + ====================================================================== +*/ + +#ifdef USE_PRAGMA_IMPLEMENTATION +#pragma implementation // gcc: Class implementation +#endif + +#define MYSQL_SERVER // to have THD +#include "mysql_priv.h" +#if MYSQL_VERSION_ID >= 50100 +#include <mysql/plugin.h> +#endif + +#ifdef HAVE_OQGRAPH + +#include "ha_oqgraph.h" +#include "graphcore.h" + +#define OQGRAPH_STATS_UPDATE_THRESHOLD 10 + +using namespace open_query; + + +struct oqgraph_info_st +{ + THR_LOCK lock; + oqgraph_share *graph; + uint use_count; + uint key_stat_version; + uint records; + bool dropped; + char name[FN_REFLEN+1]; +}; + +static const char oqgraph_description[]= + "Open Query Graph Computation Engine, stored in memory " + "(http://openquery.com/graph)"; + +#if MYSQL_VERSION_ID < 50100 +static bool oqgraph_init(); + +handlerton oqgraph_hton= { + "OQGRAPH", + SHOW_OPTION_YES, + oqgraph_description, + DB_TYPE_OQGRAPH, + oqgraph_init, + 0, /* slot */ + 0, /* savepoint size. */ + NULL, /* close_connection */ + NULL, /* savepoint */ + NULL, /* rollback to savepoint */ + NULL, /* release savepoint */ + NULL, /* commit */ + NULL, /* rollback */ + NULL, /* prepare */ + NULL, /* recover */ + NULL, /* commit_by_xid */ + NULL, /* rollback_by_xid */ + NULL, /* create_cursor_read_view */ + NULL, /* set_cursor_read_view */ + NULL, /* close_cursor_read_view */ + HTON_NO_FLAGS +}; + +#define STATISTIC_INCREMENT(X) \ +statistic_increment(table->in_use->status_var.X, &LOCK_status) +#define MOVE(X) move_field(X) +#define RECORDS records +#else +#define STATISTIC_INCREMENT(X) ha_statistic_increment(&SSV::X) +#define MOVE(X) move_field_offset(X) +#define RECORDS stats.records +#endif + +static HASH oqgraph_open_tables; +static pthread_mutex_t LOCK_oqgraph; +static bool oqgraph_init_done= 0; + +#if MYSQL_VERSION_ID >= 50130 +#define HASH_KEY_LENGTH size_t +#else +#define HASH_KEY_LENGTH uint +#endif + +static uchar* get_key(const uchar *ptr, HASH_KEY_LENGTH *length, + my_bool) +{ + const OQGRAPH_INFO *share= (const OQGRAPH_INFO*) ptr; + *length= strlen(share->name); + return (uchar*) share->name; +} + +#if MYSQL_VERSION_ID >= 50100 +static handler* oqgraph_create_handler(handlerton *hton, TABLE_SHARE *table, + MEM_ROOT *mem_root) +{ + return new (mem_root) ha_oqgraph(hton, table); +} + +static int oqgraph_init(handlerton *hton) +{ +#else +static bool oqgraph_init() +{ + if (have_oqgraph == SHOW_OPTION_DISABLED) + return 1; +#endif + if (pthread_mutex_init(&LOCK_oqgraph, MY_MUTEX_INIT_FAST)) + goto error; + if (hash_init(&oqgraph_open_tables, &my_charset_bin, 32, 0, 0, + get_key, 0, 0)) + { + pthread_mutex_destroy(&LOCK_oqgraph); + goto error; + } +#if MYSQL_VERSION_ID >= 50100 + hton->state= SHOW_OPTION_YES; + hton->db_type= DB_TYPE_AUTOASSIGN; + hton->create= oqgraph_create_handler; + hton->flags= HTON_NO_FLAGS; +#endif + oqgraph_init_done= TRUE; + return 0; +error: +#if MYSQL_VERSION_ID < 50100 + have_oqgraph= SHOW_OPTION_DISABLED; +#endif + return 1; +} + +#if MYSQL_VERSION_ID >= 50100 +static int oqgraph_fini(void *) +{ + hash_free(&oqgraph_open_tables); + pthread_mutex_destroy(&LOCK_oqgraph); + oqgraph_init_done= FALSE; + return 0; +} +#endif + +static OQGRAPH_INFO *get_share(const char *name, TABLE *table=0) +{ + OQGRAPH_INFO *share; + uint length= strlen(name); + + safe_mutex_assert_owner(&LOCK_oqgraph); + if (!(share= (OQGRAPH_INFO*) hash_search(&oqgraph_open_tables, + (byte*) name, length))) + { + if (!table || + !(share= new OQGRAPH_INFO)) + return 0; + share->use_count= share->key_stat_version= share->records= 0; + share->dropped= 0; + strmov(share->name, name); + if (!(share->graph= oqgraph::create())) + { + delete share; + return 0; + } + if (my_hash_insert(&oqgraph_open_tables, (byte*) share)) + { + oqgraph::free(share->graph); + delete share; + return 0; + } + thr_lock_init(&share->lock); + } + share->use_count++; + return share; +} + +static int free_share(OQGRAPH_INFO *share, bool drop=0) +{ + safe_mutex_assert_owner(&LOCK_oqgraph); + if (!share) + return 0; + if (drop) + { + share->dropped= true; + hash_delete(&oqgraph_open_tables, (byte*) share); + } + if (!--share->use_count) + { + if (share->dropped) + { + thr_lock_delete(&share->lock); + oqgraph::free(share->graph); + delete share; + } + } + return 0; +} + +static int error_code(int res) +{ + switch (res) + { + case oqgraph::OK: + return 0; + case oqgraph::NO_MORE_DATA: + return HA_ERR_END_OF_FILE; + case oqgraph::EDGE_NOT_FOUND: + return HA_ERR_KEY_NOT_FOUND; + case oqgraph::INVALID_WEIGHT: + return HA_ERR_AUTOINC_ERANGE; + case oqgraph::DUPLICATE_EDGE: + return HA_ERR_FOUND_DUPP_KEY; + case oqgraph::CANNOT_ADD_VERTEX: + case oqgraph::CANNOT_ADD_EDGE: + return HA_ERR_RECORD_FILE_FULL; + case oqgraph::MISC_FAIL: + default: + return HA_ERR_CRASHED_ON_USAGE; + } +} + +/** + * Check if table complies with our designated structure + * + * ColName Type Attributes + * ======= ======== ============= + * latch SMALLINT UNSIGNED NULL + * origid BIGINT UNSIGNED NULL + * destid BIGINT UNSIGNED NULL + * weight DOUBLE NULL + * seq BIGINT UNSIGNED NULL + * linkid BIGINT UNSIGNED NULL + * ================================= + * + CREATE TABLE foo ( + latch SMALLINT UNSIGNED NULL, + origid BIGINT UNSIGNED NULL, + destid BIGINT UNSIGNED NULL, + weight DOUBLE NULL, + seq BIGINT UNSIGNED NULL, + linkid BIGINT UNSIGNED NULL, + KEY (latch, origid, destid) USING HASH, + KEY (latch, destid, origid) USING HASH + ) ENGINE=OQGRAPH + + */ +static int oqgraph_check_table_structure (TABLE *table_arg) +{ + int i; + struct { const char *colname; int coltype; } skel[] = { + { "latch" , MYSQL_TYPE_SHORT }, + { "origid", MYSQL_TYPE_LONGLONG }, + { "destid", MYSQL_TYPE_LONGLONG }, + { "weight", MYSQL_TYPE_DOUBLE }, + { "seq" , MYSQL_TYPE_LONGLONG }, + { "linkid", MYSQL_TYPE_LONGLONG }, + { NULL , 0} + }; + + DBUG_ENTER("ha_oqgraph::table_structure_ok"); + + Field **field= table_arg->field; + for (i= 0; *field && skel[i].colname; i++, field++) { + /* Check Column Type */ + if ((*field)->type() != skel[i].coltype) + DBUG_RETURN(-1); + if (skel[i].coltype != MYSQL_TYPE_DOUBLE) { + /* Check Is UNSIGNED */ + if (!((*field)->flags & UNSIGNED_FLAG )) + DBUG_RETURN(-1); + } + /* Check THAT NOT NULL isn't set */ + if ((*field)->flags & NOT_NULL_FLAG) + DBUG_RETURN(-1); + /* Check the column name */ + if (strcmp(skel[i].colname,(*field)->field_name)) + DBUG_RETURN(-1); + } + + if (skel[i].colname || *field || !table_arg->key_info || !table_arg->s->keys) + DBUG_RETURN(-1); + + KEY *key= table_arg->key_info; + for (uint i= 0; i < table_arg->s->keys; ++i, ++key) + { + Field **field= table_arg->field; + /* check that the first key part is the latch and it is a hash key */ + if (!(field[0] == key->key_part[0].field && + HA_KEY_ALG_HASH == key->algorithm)) + DBUG_RETURN(-1); + if (key->key_parts == 3) + { + /* KEY (latch, origid, destid) USING HASH */ + /* KEY (latch, destid, origid) USING HASH */ + if (!(field[1] == key->key_part[1].field && + field[2] == key->key_part[2].field) && + !(field[1] == key->key_part[2].field && + field[2] == key->key_part[1].field)) + DBUG_RETURN(-1); + } + else + DBUG_RETURN(-1); + } + + DBUG_RETURN(0); +} + +/***************************************************************************** +** OQGRAPH tables +*****************************************************************************/ + +#if MYSQL_VERSION_ID >= 50100 +ha_oqgraph::ha_oqgraph(handlerton *hton, TABLE_SHARE *table_arg) + : handler(hton, table_arg), +#else +ha_oqgraph::ha_oqgraph(TABLE *table_arg) + : handler(&oqgraph_hton, table_arg), +#endif + share(0), graph(0), records_changed(0), key_stat_version(0) +{ } + + +static const char *ha_oqgraph_exts[] = +{ + NullS +}; + +const char **ha_oqgraph::bas_ext() const +{ + return ha_oqgraph_exts; +} + +#if MYSQL_VERSION_ID >= 50100 +ulonglong ha_oqgraph::table_flags() const +#else +ulong ha_oqgraph::table_flags() const +#endif +{ + return (HA_NO_BLOBS | HA_NULL_IN_KEY | + HA_REC_NOT_IN_SEQ | HA_CAN_INSERT_DELAYED); +} + +ulong ha_oqgraph::index_flags(uint inx, uint part, bool all_parts) const +{ + return HA_ONLY_WHOLE_INDEX | HA_KEY_SCAN_NOT_ROR; +} + +int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) +{ + pthread_mutex_lock(&LOCK_oqgraph); + if ((share = get_share(name, table))) + { + ref_length= oqgraph::sizeof_ref; + } + + if (share) + { + /* Initialize variables for the opened table */ + thr_lock_data_init(&share->lock, &lock, NULL); + + graph= oqgraph::create(share->graph); + + /* + We cannot run update_key_stats() here because we do not have a + lock on the table. The 'records' count might just be changed + temporarily at this moment and we might get wrong statistics (Bug + #10178). Instead we request for update. This will be done in + ha_oqgraph::info(), which is always called before key statistics are + used. + */ + key_stat_version= share->key_stat_version-1; + } + pthread_mutex_unlock(&LOCK_oqgraph); + + return (share ? 0 : 1); +} + +int ha_oqgraph::close(void) +{ + pthread_mutex_lock(&LOCK_oqgraph); + oqgraph::free(graph); graph= 0; + int res= free_share(share); + pthread_mutex_unlock(&LOCK_oqgraph); + return error_code(res); +} + +void ha_oqgraph::update_key_stats() +{ + for (uint i= 0; i < table->s->keys; i++) + { + KEY *key=table->key_info+i; + if (!key->rec_per_key) + continue; + if (key->algorithm != HA_KEY_ALG_BTREE) + { + if (key->flags & HA_NOSAME) + key->rec_per_key[key->key_parts-1]= 1; + else + { + unsigned vertices= graph->vertices_count(); + unsigned edges= graph->edges_count(); + uint no_records= vertices ? 2 * (edges + vertices) / vertices : 2; + if (no_records < 2) + no_records= 2; + key->rec_per_key[key->key_parts-1]= no_records; + } + } + } + records_changed= 0; + /* At the end of update_key_stats() we can proudly claim they are OK. */ + key_stat_version= share->key_stat_version; +} + + +int ha_oqgraph::write_row(byte * buf) +{ + int res= oqgraph::MISC_FAIL; + Field ** const field= table->field; + STATISTIC_INCREMENT(ha_write_count); + +#if MYSQL_VERSION_ID >= 50100 + my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); +#endif + my_ptrdiff_t ptrdiff= buf - table->record[0]; + + if (ptrdiff) + { + field[1]->MOVE(ptrdiff); + field[2]->MOVE(ptrdiff); + field[3]->MOVE(ptrdiff); + } + + if (!field[1]->is_null() && !field[2]->is_null()) + { + VertexID orig_id= (VertexID) field[1]->val_int(); + VertexID dest_id= (VertexID) field[2]->val_int(); + EdgeWeight weight= 1; + + if (!field[3]->is_null()) + weight= (EdgeWeight) field[3]->val_real(); + + if (!(res= graph->insert_edge(orig_id, dest_id, weight, replace_dups))) + { + ++records_changed; + share->records++; + } + if (res == oqgraph::DUPLICATE_EDGE && ignore_dups && !insert_dups) + res= oqgraph::OK; + } + + if (ptrdiff) + { + field[1]->MOVE(-ptrdiff); + field[2]->MOVE(-ptrdiff); + field[3]->MOVE(-ptrdiff); + } +#if MYSQL_VERSION_ID >= 50100 + dbug_tmp_restore_column_map(table->read_set, old_map); +#endif + + if (!res && records_changed*OQGRAPH_STATS_UPDATE_THRESHOLD > share->records) + { + /* + We can perform this safely since only one writer at the time is + allowed on the table. + */ + share->key_stat_version++; + } + + return error_code(res); +} + +int ha_oqgraph::update_row(const byte * old, byte * buf) +{ + int res= oqgraph::MISC_FAIL; + VertexID orig_id, dest_id; + EdgeWeight weight= 1; + Field **field= table->field; + STATISTIC_INCREMENT(ha_update_count); + +#if MYSQL_VERSION_ID >= 50100 + my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); +#endif + my_ptrdiff_t ptrdiff= buf - table->record[0]; + + if (ptrdiff) + { + field[0]->MOVE(ptrdiff); + field[1]->MOVE(ptrdiff); + field[2]->MOVE(ptrdiff); + field[3]->MOVE(ptrdiff); + } + + if (inited == INDEX || inited == RND) + { + VertexID *origp= 0, *destp= 0; + EdgeWeight *weightp= 0; + if (!field[1]->is_null()) + *(origp= &orig_id)= (VertexID) field[1]->val_int(); + if (!field[2]->is_null()) + *(destp= &dest_id)= (VertexID) field[2]->val_int(); + if (!field[3]->is_null()) + *(weightp= &weight)= (EdgeWeight) field[3]->val_real(); + + my_ptrdiff_t ptrdiff2= old - buf; + + field[0]->MOVE(ptrdiff2); + field[1]->MOVE(ptrdiff2); + field[2]->MOVE(ptrdiff2); + field[3]->MOVE(ptrdiff2); + + if (field[0]->is_null()) + { + if (!origp == field[1]->is_null() && + *origp == (VertexID) field[1]->val_int()) + origp= 0; + if (!destp == field[2]->is_null() && + *destp == (VertexID) field[2]->val_int()) + origp= 0; + if (!weightp == field[3]->is_null() && + *weightp == (VertexID) field[3]->val_real()) + weightp= 0; + + if (!(res= graph->modify_edge(oqgraph::current_row(), + origp, destp, weightp, replace_dups))) + ++records_changed; + else if (ignore_dups && res == oqgraph::DUPLICATE_EDGE) + res= oqgraph::OK; + } + + field[0]->MOVE(-ptrdiff2); + field[1]->MOVE(-ptrdiff2); + field[2]->MOVE(-ptrdiff2); + field[3]->MOVE(-ptrdiff2); + } + + if (ptrdiff) + { + field[0]->MOVE(-ptrdiff); + field[1]->MOVE(-ptrdiff); + field[2]->MOVE(-ptrdiff); + field[3]->MOVE(-ptrdiff); + } +#if MYSQL_VERSION_ID >= 50100 + dbug_tmp_restore_column_map(table->read_set, old_map); +#endif + + if (!res && records_changed*OQGRAPH_STATS_UPDATE_THRESHOLD > share->records) + { + /* + We can perform this safely since only one writer at the time is + allowed on the table. + */ + share->key_stat_version++; + } + return error_code(res); +} + +int ha_oqgraph::delete_row(const byte * buf) +{ + int res= oqgraph::EDGE_NOT_FOUND; + Field **field= table->field; + STATISTIC_INCREMENT(ha_delete_count); + + if (inited == INDEX || inited == RND) + { + if ((res= graph->delete_edge(oqgraph::current_row())) == oqgraph::OK) + { + ++records_changed; + share->records--; + } + } + if (res != oqgraph::OK) + { +#if MYSQL_VERSION_ID >= 50100 + my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); +#endif + my_ptrdiff_t ptrdiff= buf - table->record[0]; + + if (ptrdiff) + { + field[0]->MOVE(ptrdiff); + field[1]->MOVE(ptrdiff); + field[2]->MOVE(ptrdiff); + } + + if (field[0]->is_null() && !field[1]->is_null() && !field[2]->is_null()) + { + VertexID orig_id= (VertexID) field[1]->val_int(); + VertexID dest_id= (VertexID) field[2]->val_int(); + + if ((res= graph->delete_edge(orig_id, dest_id)) == oqgraph::OK) + { + ++records_changed; + share->records--; + } + } + + if (ptrdiff) + { + field[0]->MOVE(-ptrdiff); + field[1]->MOVE(-ptrdiff); + field[2]->MOVE(-ptrdiff); + } +#if MYSQL_VERSION_ID >= 50100 + dbug_tmp_restore_column_map(table->read_set, old_map); +#endif + } + + if (!res && table->s->tmp_table == NO_TMP_TABLE && + records_changed*OQGRAPH_STATS_UPDATE_THRESHOLD > share->records) + { + /* + We can perform this safely since only one writer at the time is + allowed on the table. + */ + share->key_stat_version++; + } + return error_code(res); +} + +int ha_oqgraph::index_read(byte * buf, const byte * key, uint key_len, + enum ha_rkey_function find_flag) +{ + DBUG_ASSERT(inited==INDEX); + return index_read_idx(buf, active_index, key, key_len, find_flag); +} + +int ha_oqgraph::index_next_same(byte *buf, const byte *key, uint key_len) +{ + int res; + open_query::row row; + DBUG_ASSERT(inited==INDEX); + STATISTIC_INCREMENT(ha_read_key_count); + if (!(res= graph->fetch_row(row))) + res= fill_record(buf, row); + table->status= res ? STATUS_NOT_FOUND : 0; + return error_code(res); +} + +int ha_oqgraph::index_read_idx(byte * buf, uint index, const byte * key, + uint key_len, enum ha_rkey_function find_flag) +{ + Field **field= table->field; + KEY *key_info= table->key_info + index; + int res; + VertexID orig_id, dest_id; + int latch; + VertexID *orig_idp=0, *dest_idp=0; + int *latchp=0; + open_query::row row; + STATISTIC_INCREMENT(ha_read_key_count); + + bmove_align(buf, table->s->default_values, table->s->reclength); + key_restore(buf, (byte*) key, key_info, key_len); + +#if MYSQL_VERSION_ID >= 50100 + my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); +#endif + my_ptrdiff_t ptrdiff= buf - table->record[0]; + + if (ptrdiff) + { + field[0]->MOVE(ptrdiff); + field[1]->MOVE(ptrdiff); + field[2]->MOVE(ptrdiff); + } + + if (!field[0]->is_null()) + { + latch= (int) field[0]->val_int(); + latchp= &latch; + } + + if (!field[1]->is_null()) + { + orig_id= (VertexID) field[1]->val_int(); + orig_idp= &orig_id; + } + + if (!field[2]->is_null()) + { + dest_id= (VertexID) field[2]->val_int(); + dest_idp= &dest_id; + } + + if (ptrdiff) + { + field[0]->MOVE(-ptrdiff); + field[1]->MOVE(-ptrdiff); + field[2]->MOVE(-ptrdiff); + } +#if MYSQL_VERSION_ID >= 50100 + dbug_tmp_restore_column_map(table->read_set, old_map); +#endif + + res= graph->search(latchp, orig_idp, dest_idp); + + if (!res && !(res= graph->fetch_row(row))) + res= fill_record(buf, row); + table->status = res ? STATUS_NOT_FOUND : 0; + return error_code(res); +} + +int ha_oqgraph::fill_record(byte *record, const open_query::row &row) +{ + Field **field= table->field; + + bmove_align(record, table->s->default_values, table->s->reclength); + +#if MYSQL_VERSION_ID >= 50100 + my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set); +#endif + my_ptrdiff_t ptrdiff= record - table->record[0]; + + if (ptrdiff) + { + field[0]->MOVE(ptrdiff); + field[1]->MOVE(ptrdiff); + field[2]->MOVE(ptrdiff); + field[3]->MOVE(ptrdiff); + field[4]->MOVE(ptrdiff); + field[5]->MOVE(ptrdiff); + } + + // just each field specifically, no sense iterating + if (row.latch_indicator) + { + field[0]->set_notnull(); + field[0]->store((longlong) row.latch); + } + + if (row.orig_indicator) + { + field[1]->set_notnull(); + field[1]->store((longlong) row.orig); + } + + if (row.dest_indicator) + { + field[2]->set_notnull(); + field[2]->store((longlong) row.dest); + } + + if (row.weight_indicator) + { + field[3]->set_notnull(); + field[3]->store((double) row.weight); + } + + if (row.seq_indicator) + { + field[4]->set_notnull(); + field[4]->store((longlong) row.seq); + } + + if (row.link_indicator) + { + field[5]->set_notnull(); + field[5]->store((longlong) row.link); + } + + if (ptrdiff) + { + field[0]->MOVE(-ptrdiff); + field[1]->MOVE(-ptrdiff); + field[2]->MOVE(-ptrdiff); + field[3]->MOVE(-ptrdiff); + field[4]->MOVE(-ptrdiff); + field[5]->MOVE(-ptrdiff); + } +#if MYSQL_VERSION_ID >= 50100 + dbug_tmp_restore_column_map(table->write_set, old_map); +#endif + + return 0; +} + +int ha_oqgraph::rnd_init(bool scan) +{ + return error_code(graph->random(scan)); +} + +int ha_oqgraph::rnd_next(byte *buf) +{ + int res; + open_query::row row; + STATISTIC_INCREMENT(ha_read_rnd_next_count); + if (!(res= graph->fetch_row(row))) + res= fill_record(buf, row); + table->status= res ? STATUS_NOT_FOUND: 0; + return error_code(res); +} + +int ha_oqgraph::rnd_pos(byte * buf, byte *pos) +{ + int res; + open_query::row row; + STATISTIC_INCREMENT(ha_read_rnd_count); + if (!(res= graph->fetch_row(row, pos))) + res= fill_record(buf, row); + table->status=res ? STATUS_NOT_FOUND: 0; + return error_code(res); +} + +void ha_oqgraph::position(const byte *record) +{ + graph->row_ref((void*) ref); // Ref is aligned +} + +int ha_oqgraph::cmp_ref(const byte *ref1, const byte *ref2) +{ + return memcmp(ref1, ref2, oqgraph::sizeof_ref); +} + +int ha_oqgraph::info(uint flag) +{ + RECORDS= graph->vertices_count() + graph->edges_count(); +#if 0 + records= hp_info.records; + deleted= hp_info.deleted; + errkey= hp_info.errkey; + mean_rec_length= hp_info.reclength; + data_file_length= hp_info.data_length; + index_file_length= hp_info.index_length; + max_data_file_length= hp_info.max_records* hp_info.reclength; + delete_length= hp_info.deleted * hp_info.reclength; +#endif + /* + If info() is called for the first time after open(), we will still + have to update the key statistics. Hoping that a table lock is now + in place. + */ + if (key_stat_version != share->key_stat_version) + update_key_stats(); + return 0; +} + +int ha_oqgraph::extra(enum ha_extra_function operation) +{ + switch (operation) + { + case HA_EXTRA_IGNORE_DUP_KEY: + ignore_dups= true; + break; + case HA_EXTRA_NO_IGNORE_DUP_KEY: + ignore_dups= false; + insert_dups= false; + break; + case HA_EXTRA_WRITE_CAN_REPLACE: + replace_dups= true; + break; + case HA_EXTRA_WRITE_CANNOT_REPLACE: + replace_dups= false; + break; + case HA_EXTRA_INSERT_WITH_UPDATE: + insert_dups= true; + break; + default: + break; + } + return 0; +} + +int ha_oqgraph::delete_all_rows() +{ + int res; + if (!(res= graph->delete_all())) + { + share->records= 0; + } + + if (!res && table->s->tmp_table == NO_TMP_TABLE) + { + /* + We can perform this safely since only one writer at the time is + allowed on the table. + */ + share->key_stat_version++; + } + return error_code(res); +} + +int ha_oqgraph::external_lock(THD *thd, int lock_type) +{ + return 0; // No external locking +} + + +THR_LOCK_DATA **ha_oqgraph::store_lock(THD *thd, + THR_LOCK_DATA **to, + enum thr_lock_type lock_type) +{ + if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) + lock.type=lock_type; + *to++= &lock; + return to; +} + +/* + We have to ignore ENOENT entries as the HEAP table is created on open and + not when doing a CREATE on the table. +*/ + +int ha_oqgraph::delete_table(const char *name) +{ + int res= 0; + OQGRAPH_INFO *share; + pthread_mutex_lock(&LOCK_oqgraph); + if ((share= get_share(name))) + { + res= free_share(share, true); + } + pthread_mutex_unlock(&LOCK_oqgraph); + return error_code(res); +} + +int ha_oqgraph::rename_table(const char * from, const char * to) +{ + pthread_mutex_lock(&LOCK_oqgraph); + if (OQGRAPH_INFO *share= get_share(from)) + { + strmov(share->name, to); + hash_update(&oqgraph_open_tables, (byte*) share, + (byte*) from, strlen(from)); + } + pthread_mutex_unlock(&LOCK_oqgraph); + return 0; +} + + +ha_rows ha_oqgraph::records_in_range(uint inx, key_range *min_key, + key_range *max_key) +{ + KEY *key=table->key_info+inx; + //if (key->algorithm == HA_KEY_ALG_BTREE) + // return btree_records_in_range(file, inx, min_key, max_key); + + if (!min_key || !max_key || + min_key->length != max_key->length || + min_key->length < key->key_length - key->key_part[2].store_length || + min_key->flag != HA_READ_KEY_EXACT || + max_key->flag != HA_READ_AFTER_KEY) + { + if (min_key->length == key->key_part[0].store_length) + { + // If latch is not null and equals 0, return # nodes + DBUG_ASSERT(key->key_part[0].store_length == 3); + if (key->key_part[0].null_bit && !min_key->key[0] && + !min_key->key[1] && !min_key->key[2]) + return graph->vertices_count(); + } + return HA_POS_ERROR; // Can only use exact keys + } + + if (RECORDS <= 1) + return RECORDS; + + /* Assert that info() did run. We need current statistics here. */ + DBUG_ASSERT(key_stat_version == share->key_stat_version); + ha_rows result= key->rec_per_key[key->key_parts-1]; + + return result; +} + + +int ha_oqgraph::create(const char *name, TABLE *table_arg, + HA_CREATE_INFO *create_info) +{ + int res = -1; + OQGRAPH_INFO *share; + + pthread_mutex_lock(&LOCK_oqgraph); + if ((share= get_share(name))) + { + free_share(share); + } + else + { + if (!oqgraph_check_table_structure(table_arg)) + res= 0;; + } + pthread_mutex_unlock(&LOCK_oqgraph); + + if (this->share) + info(HA_STATUS_NO_LOCK | HA_STATUS_CONST | HA_STATUS_VARIABLE); + return error_code(res); +} + + +void ha_oqgraph::update_create_info(HA_CREATE_INFO *create_info) +{ + table->file->info(HA_STATUS_AUTO); + //if (!(create_info->used_fields & HA_CREATE_USED_AUTO)) + // create_info->auto_increment_value= auto_increment_value; +} + +#if MYSQL_VERSION_ID >= 50100 +struct st_mysql_storage_engine oqgraph_storage_engine= +{ MYSQL_HANDLERTON_INTERFACE_VERSION }; + +mysql_declare_plugin(oqgraph) +{ + MYSQL_STORAGE_ENGINE_PLUGIN, + &oqgraph_storage_engine, + "OQGRAPH", + "Arjen Lentz & Antony T Curtis, Open Query", + oqgraph_description, + PLUGIN_LICENSE_GPL, + (int (*)(void*)) oqgraph_init, /* Plugin Init */ + oqgraph_fini, /* Plugin Deinit */ + 0x0200, /* Version: 2.0 */ + NULL, /* status variables */ + NULL, /* system variables */ + NULL /* config options */ +} +mysql_declare_plugin_end; +#endif + +#endif === added file 'storage/oqgraph/ha_oqgraph.h' --- a/storage/oqgraph/ha_oqgraph.h 1970-01-01 00:00:00 +0000 +++ b/storage/oqgraph/ha_oqgraph.h 2010-01-04 08:27:50 +0000 @@ -0,0 +1,114 @@ +/* Copyright (C) 2007-2009 Arjen G Lentz & Antony T Curtis for Open Query + Portions of this file copyright (C) 2000-2006 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* ====================================================================== + Open Query Graph Computation Engine, based on a concept by Arjen Lentz + Mk.II implementation by Antony Curtis & Arjen Lentz + For more information, documentation, support, enhancement engineering, + and non-GPL licensing, see http://openquery.com/graph + or contact graph@openquery.com + For packaged binaries, see http://ourdelta.org + ====================================================================== +*/ + +#ifdef USE_PRAGMA_INTERFACE +#pragma interface /* gcc class implementation */ +#endif + + +typedef struct oqgraph_info_st OQGRAPH_INFO; + +#if MYSQL_VERSION_ID >= 50120 +typedef uchar byte; +#endif + +namespace open_query +{ + struct row; + class oqgraph; +} + +/* class for the the Open Query Graph handler */ + +class ha_oqgraph: public handler +{ + OQGRAPH_INFO *share; + open_query::oqgraph *graph; + THR_LOCK_DATA lock; + /* number of records changed since last statistics update */ + uint records_changed; + uint key_stat_version; + bool replace_dups, ignore_dups, insert_dups; + + int fill_record(byte*, const open_query::row&); + +public: +#if MYSQL_VERSION_ID >= 50100 + ha_oqgraph(handlerton *hton, TABLE_SHARE *table); + ulonglong table_flags() const; +#else + ha_oqgraph(TABLE *table); + ulong table_flags() const; +#endif + ~ha_oqgraph() {} + const char *table_type() const + { + return "OQGRAPH"; + } + const char *index_type(uint inx) + { + return "HASH"; + } + /* Rows also use a fixed-size format */ + enum row_type get_row_type() const { return ROW_TYPE_FIXED; } + const char **bas_ext() const; + ulong index_flags(uint inx, uint part, bool all_parts) const; + uint max_supported_keys() const { return MAX_KEY; } + uint max_supported_key_part_length() const { return MAX_KEY_LENGTH; } + double scan_time() { return (double) 1000000000; } + double read_time(uint index, uint ranges, ha_rows rows) + { return 1; } + + int open(const char *name, int mode, uint test_if_locked); + int close(void); + int write_row(byte * buf); + int update_row(const byte * old_data, byte * new_data); + int delete_row(const byte * buf); + int index_read(byte * buf, const byte * key, + uint key_len, enum ha_rkey_function find_flag); + int index_read_idx(byte * buf, uint idx, const byte * key, + uint key_len, enum ha_rkey_function find_flag); + int index_next_same(byte * buf, const byte * key, uint key_len); + int rnd_init(bool scan); + int rnd_next(byte *buf); + int rnd_pos(byte * buf, byte *pos); + void position(const byte *record); + int info(uint); + int extra(enum ha_extra_function operation); + int external_lock(THD *thd, int lock_type); + int delete_all_rows(void); + ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key); + int delete_table(const char *from); + int rename_table(const char * from, const char * to); + int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); + void update_create_info(HA_CREATE_INFO *create_info); + + THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, + enum thr_lock_type lock_type); + int cmp_ref(const byte *ref1, const byte *ref2); +private: + void update_key_stats(); +}; === added file 'storage/oqgraph/oqgraph_config.h.in' --- a/storage/oqgraph/oqgraph_config.h.in 1970-01-01 00:00:00 +0000 +++ b/storage/oqgraph/oqgraph_config.h.in 2010-01-04 08:27:50 +0000 @@ -0,0 +1,73 @@ +/* src/oqgraph_config.h.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#undef HAVE_DLFCN_H + +/* Enables DTRACE Support */ +#undef HAVE_DTRACE + +/* Define to 1 if you have the <inttypes.h> header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the <limits.h> header file. */ +#undef HAVE_LIMITS_H + +/* Define to 1 if you have the <memory.h> header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the <stdint.h> header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the <stdlib.h> header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the <strings.h> header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the <string.h> header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the <syslimits.h> header file. */ +#undef HAVE_SYSLIMITS_H + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the <sys/types.h> header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + +/* Source directory for MySQL */ +#undef MYSQL_SRC + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `unsigned int' if <sys/types.h> does not define. */ +#undef size_t === added file 'storage/oqgraph/oqgraph_probes.d' --- a/storage/oqgraph/oqgraph_probes.d 1970-01-01 00:00:00 +0000 +++ b/storage/oqgraph/oqgraph_probes.d 2010-01-04 08:27:50 +0000 @@ -0,0 +1,19 @@ +/* Copyright (C) 2004-2005 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +provider oqgraph { + probe open(); + probe close(); +}; === added file 'storage/oqgraph/plug.in' --- a/storage/oqgraph/plug.in 1970-01-01 00:00:00 +0000 +++ b/storage/oqgraph/plug.in 2010-03-30 07:33:38 +0000 @@ -0,0 +1,24 @@ +MYSQL_STORAGE_ENGINE(oqgraph,,[Graph Storage Engine], + [Open Query Graph Computation Engine], []) +MYSQL_PLUGIN_DYNAMIC(oqgraph, [oqgraph_engine.la]) +MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS(oqgraph, [ha_oqgraph.cc]) +AM_CONDITIONAL([BUILD_OQGRAPH_FOR_MYSQL], true) +AM_CONDITIONAL([BUILD_OQGRAPH_STANDALONE], false) +AM_CONDITIONAL([HAVE_DTRACE], false) + +AC_LANG_PUSH([C++]) + +AC_MSG_CHECKING([for Boost usable by OQGraph engine]) +AC_PREPROC_IFELSE( + [ +#include <boost/version.hpp> +#if BOOST_VERSION >= 104000 +#else +#error oops +#endif + ], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + with_plugin_oqgraph=no]) + +AC_LANG_POP() === modified file 'storage/xtradb/include/page0page.h' --- a/storage/xtradb/include/page0page.h 2010-01-06 12:00:14 +0000 +++ b/storage/xtradb/include/page0page.h 2010-03-28 18:10:00 +0000 @@ -517,7 +517,7 @@ UNIV_INLINE rec_t* page_rec_get_next( /*==============*/ - rec_t* rec); /*!< in: pointer to record */ + const rec_t* rec); /*!< in: pointer to record */ /************************************************************//** Gets the pointer to the next record on the page. @return pointer to next record */ === modified file 'storage/xtradb/include/page0page.ic' --- a/storage/xtradb/include/page0page.ic 2010-01-06 12:00:14 +0000 +++ b/storage/xtradb/include/page0page.ic 2010-03-28 18:10:00 +0000 @@ -731,7 +731,7 @@ UNIV_INLINE rec_t* page_rec_get_next( /*==============*/ - rec_t* rec) /*!< in: pointer to record */ + const rec_t* rec) /*!< in: pointer to record */ { return((rec_t*) page_rec_get_next_low(rec, page_rec_is_comp(rec))); } === modified file 'storage/xtradb/include/ut0lst.h' --- a/storage/xtradb/include/ut0lst.h 2009-09-07 10:22:53 +0000 +++ b/storage/xtradb/include/ut0lst.h 2010-03-30 12:36:49 +0000 @@ -158,7 +158,7 @@ Inserts a NODE2 after NODE1 in a list. /** Invalidate the pointers in a list node. @param NAME list name @param N pointer to the node that was removed */ -# define UT_LIST_REMOVE_CLEAR(NAME, N) while (0) +# define UT_LIST_REMOVE_CLEAR(NAME, N) {} while (0) #endif /*******************************************************************//** === modified file 'strings/ctype-ucs2.c' --- a/strings/ctype-ucs2.c 2010-03-15 11:51:23 +0000 +++ b/strings/ctype-ucs2.c 2010-03-31 08:17:03 +0000 @@ -203,7 +203,7 @@ static int my_strnncoll_ucs2(CHARSET_INF my_bool t_is_prefix) { int s_res,t_res; - my_wc_t UNINIT_VAR(s_wc),t_wc; + my_wc_t UNINIT_VAR(s_wc), UNINIT_VAR(t_wc); const uchar *se=s+slen; const uchar *te=t+tlen; MY_UNICASE_INFO *const *uni_plane= cs->caseinfo; @@ -317,7 +317,7 @@ static int my_strncasecmp_ucs2(CHARSET_I const char *s, const char *t, size_t len) { int s_res,t_res; - my_wc_t UNINIT_VAR(s_wc),t_wc; + my_wc_t UNINIT_VAR(s_wc), UNINIT_VAR(t_wc); const char *se=s+len; const char *te=t+len; MY_UNICASE_INFO *const *uni_plane= cs->caseinfo; @@ -1384,7 +1384,7 @@ int my_strnncoll_ucs2_bin(CHARSET_INFO * my_bool t_is_prefix) { int s_res,t_res; - my_wc_t UNINIT_VAR(s_wc),t_wc; + my_wc_t UNINIT_VAR(s_wc), UNINIT_VAR(t_wc); const uchar *se=s+slen; const uchar *te=t+tlen; === modified file 'strings/ctype-utf8.c' --- a/strings/ctype-utf8.c 2010-01-06 19:20:16 +0000 +++ b/strings/ctype-utf8.c 2010-03-31 08:17:03 +0000 @@ -2308,7 +2308,7 @@ static int my_strnncoll_utf8(CHARSET_INF my_bool t_is_prefix) { int s_res,t_res; - my_wc_t UNINIT_VAR(s_wc), t_wc; + my_wc_t UNINIT_VAR(s_wc), UNINIT_VAR(t_wc); const uchar *se=s+slen; const uchar *te=t+tlen; MY_UNICASE_INFO *const *uni_plane= cs->caseinfo; @@ -2378,7 +2378,7 @@ static int my_strnncollsp_utf8(CHARSET_I my_bool diff_if_only_endspace_difference) { int s_res, t_res, res; - my_wc_t UNINIT_VAR(s_wc),t_wc; + my_wc_t UNINIT_VAR(s_wc), UNINIT_VAR(t_wc); const uchar *se= s+slen, *te= t+tlen; MY_UNICASE_INFO *const *uni_plane= cs->caseinfo; === modified file 'support-files/compiler_warnings.supp' --- a/support-files/compiler_warnings.supp 2010-03-10 10:32:14 +0000 +++ b/support-files/compiler_warnings.supp 2010-03-30 12:36:49 +0000 @@ -39,6 +39,7 @@ sync/sync0rw\.c: unused parameter sync/sync0sync\.c: unused parameter sync/sync0sync\.c: unused variable ut/ut0ut\.c: ignoring return value of +srv/srv0srv\.c: value computed is not used # # bdb is not critical to keep up to date @@ -66,6 +67,16 @@ db_vrfy.c : .*comparison is always false /usr/share/aclocal/audiofile.m4 : .* # +# Ignore strict-aliasing warnings (for now) +# +.*: break strict-aliasing rules + +# +# Ignore not important declaration warnings +# +.*: only defines private constructors and has no friends + +# # Ignore all conversion warnings on windows 64 # (Is safe as we are not yet supporting strings >= 2G) # @@ -100,6 +111,11 @@ db_vrfy.c : .*comparison is always false storage/maria/ma_pagecache.c: .*'info_check_pin' defined but not used # +# Pbxt +# +xaction_xt\.cc: may be used uninitialized in this function + +# # I think these are due to mix of C and C++. # storage/pbxt/ : typedef.*was ignored in this declaration @@ -112,6 +128,7 @@ include/runtime.hpp: .*pure_error.* .*/extra/yassl/taocrypt/src/blowfish\.cpp: array subscript is above array bounds .*/extra/yassl/taocrypt/src/file\.cpp: ignoring return value .*/extra/yassl/taocrypt/src/integer\.cpp: control reaches end of non-void function +mySTL/algorithm\.hpp: is used uninitialized in this function # # Groff warnings on OpenSUSE. @@ -123,18 +140,18 @@ include/runtime.hpp: .*pure_error.* # listener.cc : .*conversion from 'SOCKET' to 'int'.* net_serv.cc : .*conversion from 'SOCKET' to 'int'.* -set_var.cc: right-hand operand of comma has no effect : 1000-1400 - # allow a little moving space for the warning below -mi_packrec.c : .*result of 32-bit shift implicitly converted to 64 bits.* : 560-600 -ma_packrec.c : .*result of 32-bit shift implicitly converted to 64 bits.* : 550-650 +mi_packrec\.c : .*result of 32-bit shift implicitly converted to 64 bits.* : 560-600 +ma_packrec\.c : .*result of 32-bit shift implicitly converted to 64 bits.* : 550-650 # # Wrong compiler warnings # .* : .*no matching operator delete found; memory will not be freed if initialization throws an exception.* -ctype-simple.c : .*unary minus operator applied to unsigned type, result still unsigned.* +ctype-simple\.c : .*unary minus operator applied to unsigned type, result still unsigned.* # Wrong warning due to GCC bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29478 -regexec\.c : .*passing argument 3 of.*matcher.* discards qualifiers from pointer target type.* +regexec\.c : passing argument 3 of.*matcher.* discards qualifiers from pointer target type +libmysql\.c: passing argument 2 of .*memcpy.* discards qualifiers from pointer target type : 3000-4000 +storage/xtradb/dict/dict0dict\.c: passing argument 1 of .*strcpy.* discards qualifiers from pointer target type : 2500-3500 === modified file 'unittest/mysys/waiting_threads-t.c' --- a/unittest/mysys/waiting_threads-t.c 2010-01-28 14:49:14 +0000 +++ b/unittest/mysys/waiting_threads-t.c 2010-03-30 12:36:49 +0000 @@ -258,7 +258,7 @@ void do_tests() #define test_kill_strategy(X) \ diag("kill strategy: " #X); \ DBUG_EXECUTE("reset_file", \ - { rewind(DBUG_FILE); (void) ftruncate(fileno(DBUG_FILE), 0); }); \ + { rewind(DBUG_FILE); my_chsize(fileno(DBUG_FILE), 0, 0, MYF(MY_WME)); }); \ DBUG_PRINT("info", ("kill strategy: " #X)); \ kill_strategy=X; \ do_one_test();