diff --git a/.bzrignore b/.bzrignore index 02a97d7d1af..cfe38741074 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1107,3 +1107,6 @@ vio/test-sslclient vio/test-sslserver vio/viotest-ssl VC++Files/client/mysql_amd64.dsp +client/mysqltestmanager-pwgen +client/mysqltestmanagerc +tools/mysqltestmanager diff --git a/BUILD/compile-pentium-cybozu b/BUILD/compile-pentium-cybozu new file mode 100755 index 00000000000..841635985a1 --- /dev/null +++ b/BUILD/compile-pentium-cybozu @@ -0,0 +1,9 @@ +#! /bin/sh + +path=`dirname $0` +. "$path/SETUP.sh" + +extra_flags="$pentium_cflags $fast_cflags -g" +extra_configs="$pentium_configs --with-charset=utf8 --with-collation=utf8_general_cs" + +. "$path/FINISH.sh" diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 1897af73735..dc419e29ef4 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -9,6 +9,7 @@ Sinisa@sinisa.nasamreza.org WAX@sergbook.mysql.com acurtis@ltantony.rdg.cyberkinetica.homeunix.net acurtis@pcgem.rdg.cyberkinetica.com +acurtis@xiphis.org administrador@light.hegel.local ahlentz@co3064164-a.rochd1.qld.optusnet.com.au akishkin@work.mysql.com @@ -56,8 +57,10 @@ georg@beethoven.local georg@beethoven.site georg@lmy002.wdf.sap.corp gerberb@ou800.zenez.com +gluh@eagle.intranet.mysql.r18.ru gluh@gluh.(none) gluh@gluh.mysql.r18.ru +gluh@mysql.com gordon@zero.local.lan greg@gcw.ath.cx greg@mysql.com diff --git a/BitKeeper/triggers/post-commit b/BitKeeper/triggers/post-commit index 4fbc0b2a9b8..e3f86fa995a 100755 --- a/BitKeeper/triggers/post-commit +++ b/BitKeeper/triggers/post-commit @@ -27,6 +27,7 @@ then fi CHANGESET=`bk -R prs -r+ -h -d':P:::I:' ChangeSet` +CSETKEY=`bk -R prs -r+ -h -d':KEY:' ChangeSet` BUG=`bk -R prs -r+ -h -d':C:' ChangeSet | sed -ne 's/^.*[Bb][Uu][Gg] *# *\([0-9][0-9]*\).*$/\1/p'` WL=`bk -R prs -r+ -h -d':C:' ChangeSet | sed -ne 's/^.*[Ww][Ll] *# *\([0-9][0-9]*\).*$/ WL#\1/p'` @@ -52,6 +53,7 @@ List-ID: From: $FROM To: $TO Subject: bk commit - $VERSION tree ($CHANGESET)${BS}${WL} +X-CSetKey: <$CSETKEY> $BH EOF bk changes -v -r+ @@ -68,6 +70,7 @@ List-ID: From: $FROM To: $INTERNALS Subject: bk commit into $VERSION tree ($CHANGESET)$BS +X-CSetKey: <$CSETKEY> $BH Below is the list of changes that have just been committed into a local $VERSION repository of $USER. When $USER does a push these changes will diff --git a/Build-tools/Bootstrap b/Build-tools/Bootstrap deleted file mode 100755 index 32d371cc2c6..00000000000 --- a/Build-tools/Bootstrap +++ /dev/null @@ -1,475 +0,0 @@ -#!/usr/bin/perl -w -# -# Bootstrap -# -# Script to export a given BK source tree into a separate directory -# and create the source distribution to be used for all binary builds -# -# Use the "--help" option for more info! -# -# written by Lenz Grimmer -# - -use Cwd; -use Getopt::Long; -Getopt::Long::Configure ("bundling"); - -# Include helper functions -$LOGGER= "$ENV{HOME}/bin/logger.pm"; -if (-f $LOGGER) -{ - do "$LOGGER"; -} -else -{ - die "ERROR: $LOGGER cannot be found!\n"; -} - -# Some predefined settings -$build_command= "BUILD/compile-dist"; -$PWD= cwd(); -$opt_docdir= $PWD . "/mysqldoc"; -$opt_archive_log= undef; -$opt_build_command= undef; -$opt_changelog= undef; -$opt_delete= undef; -$opt_directory= $PWD; -$opt_dry_run= undef; -$opt_export_only= undef; -$opt_help= $opt_verbose= 0; -$opt_log= undef; -$opt_mail= "build\@mysql.com"; -$opt_pull= undef; -$opt_revision= undef; -$opt_suffix= ""; -$opt_test= undef; -$opt_skip_check= undef; -$opt_skip_manual= undef; -$opt_win_dist= undef; -$opt_quiet= undef; -$version= "unknown"; -$major=$minor=$release=0; - -GetOptions( - "archive-log|a", - "build-command|b=s", - "changelog|c:s", - "directory|d=s", - "delete", - "docdir=s", - "dry-run", - "export-only|e", - "help|h", - "log|l:s", - "mail|m=s", - "pull|p", - "revision|r=s", - "skip-check|s", - "skip-manual", - "suffix=s", - "test|t", - "verbose|v", - "win-dist|w", - "quiet|q", -) || print_help(""); - -# -# Override predefined build command -# -if (defined $opt_build_command) -{ - $build_command= $opt_build_command; -} - -print_help("") if ($opt_help); -defined($REPO=$ARGV[0]) || print_help("Please enter the BK repository to be used!"); - -# -# Override predefined Log file name -# -if (defined $opt_log) -{ - if ($opt_log ne "") - { - if ($opt_log =~ /^\/.*/) - { - $LOGFILE= $opt_log; - } - else - { - $LOGFILE= $PWD . "/" . $opt_log; - } - } -} - -$LOGFILE= $PWD . "/Bootstrap-" . $REPO . ".log" unless ($LOGFILE); - -&logger("Starting build"); -&abort("The directory \"$REPO\" could not be found!") if (!-d $REPO); -&logger("Using $REPO as the BK parent repository"); -system ("bk help > /dev/null") == 0 or &abort("Cannot execute BitKeeper binary!"); -system ("bk root $REPO > /dev/null 2>&1") == 0 or &abort("$REPO does not seem to be a valid BK repository!"); - -if (($opt_directory ne $PWD) && (!-d $opt_directory && !$opt_dry_run)) -{ - &abort("Could not find target directory \"$opt_directory\"!"); -} - -&logger("Logging to $LOGFILE") if (defined $opt_log); - -# -# Pull recent changes first -# -if ($opt_pull) -{ - &bk_pull("$REPO"); - &bk_pull("$opt_docdir") unless ($opt_skip_manual); -} - -# -# Use a temporary name until we know the version number -# -$target_dir= $opt_directory . "/mysql-" . $$ . "-" . time() . ".tmp"; -&logger("Using temporary directory $target_dir"); -&abort("Target directory $target_dir already exists!") if (-d $target_dir && !$opt_dry_run); - -# -# Export the BK tree -# -$command= "bk export "; -$command.= "-r " . $opt_revision . " " if $opt_revision; -$command.= "-v " if ($opt_verbose || defined $opt_log); -$command.= $REPO . " " . $target_dir; -&logger("Exporting $REPO"); -&run_command($command, "Could not create $target_dir!"); - -# -# Make sure we can write all files -# -$command= "find $target_dir -type f -print0 | xargs --null chmod u+w"; -&run_command($command, "Failed to fix file permissions!"); - -# -# Try to obtain version number from newly extracted configure.in -# -$CONF="$target_dir/configure.in"; -&abort("Could not find \"$CONF\" to determine version!") if (!-f $CONF && !$opt_dry_run); - -# -# The following can only be done, if the tree has actually been -# exported - it cannot be performed in a dry run. -# -if (!$opt_dry_run) -{ - open (CONF, $CONF) or &abort("Unable to open \"$CONF\": $!"); - @conf= ; - close CONF; - - foreach (@conf) - { - m/^AM_INIT_AUTOMAKE\(mysql, ([1-9]\.[0-9]{1,2}\.[0-9]{1,2}.*)\)/; - $version= $1; - ($major, $minor, $release) = split(/\./,$version); - } - &logger("Found version string: $version"); - - # - # Add suffix to version string and write out the modified file - # - if ($opt_suffix) - { - $opt_suffix= "-" . &ymd() if ($opt_suffix eq "YMD"); - - &logger("Replacing $version with $version$opt_suffix"); - foreach (@conf) - { - s/^AM_INIT_AUTOMAKE.*/AM_INIT_AUTOMAKE\(mysql, $version$opt_suffix\)/; - } - open(CONF,">$CONF") or &abort("Unable to open \"$CONF\": $!"); - print CONF @conf; - close(CONF); - } -} - -# -# Rename directory according to the version number found in configure.in -# of the extracted tree (plus suffix, if requested) -# -$temp_name= $target_dir; -$target_dir= $opt_directory . "/mysql-" . $version . $opt_suffix . "-build"; -if (-d $target_dir) -{ - &logger("Target directory $target_dir already exists!"); - if ($opt_delete) - { - &logger("Deleting $target_dir..."); - $command= "rm "; - $command.= "-v " if ($opt_verbose || defined $opt_log); - $command.= "$target_dir"; - &run_command($command, "Could not delete $target_dir!"); - } - else - { - # Get the time stamp of "configure.in" - @stat= stat("$target_dir/configure.in"); - my $mtime= $stat[9]; - my ($sec,$min,$hour,$mday,$mon,$year) = localtime($mtime); - my $mtime= sprintf("%04d-%02d-%02d-%02d:%02d", $year+1900, $mon+1, $mday, $hour, $min); - - &logger("Renaming $target_dir to $target_dir-$mtime"); - $command= "mv "; - $command.= "-v " if ($opt_verbose || defined $opt_log); - $command.= "$target_dir $target_dir-$mtime"; - &run_command($command, "Could not rename $target_dir!"); - } -} - -&logger("Renaming temporary directory to $target_dir"); -$command= "mv "; -$command.= "-v " if ($opt_verbose || defined $opt_log); -$command.= "$temp_name $target_dir"; -&run_command($command, "Could not rename $temp_name!"); - -# -# Add a ChangeLog (make dist will pick it up automatically) -# -if (defined $opt_changelog) -{ - # - # Use some magic to obtain the correct ChangeSet number that identifies - # the last tagged ChangeSet (this relies heavily on our current tagging - # practice!) - # - $opt_changelog=~ s/^=//; # Sometimes, a leading '=' was not stripped. - my $log_base= $opt_changelog; - my $changelogfile; - if ($target_dir =~ m:^/:) # we need an absolute path, as we change directory - { - $changelogfile= $target_dir. "/ChangeLog"; - } - else - { - $changelogfile= cwd() . "/" . $target_dir . "/ChangeLog"; - } - - if ($opt_changelog eq "last") - { - if (!$opt_revision) - { - $log_base= `bk changes -t -d':REV:::TAG:' -n $REPO | grep mysql-$major.$minor | head -1 | cut -f1 -d ":"`; - } - else - { - $log_base= `bk changes -r..$opt_revision -t -d':REV:' -n $REPO | head -2 | tail -1`; - } - chomp($log_base); - } - - $msg= "Adding $changelogfile"; - $msg.= " (down to revision $log_base)" if $log_base ne ""; - &logger($msg); - # Due to a BK error, "bk changes" must be run in $REPO ! - $command= "cd $REPO ; "; - $command.= "bk changes -v"; - $command.= " -r" if ($log_base ne "" || $opt_revision); - $command.= $log_base if $log_base ne ""; - $command.= ".." if ($log_base ne "" && !$opt_revision); - $command.= ".." . $opt_revision if $opt_revision; - $command.= " > $changelogfile"; - &logger($command); - # We cannot use run_command here because of output redirection - unless ($opt_dry_run) - { - system($command) == 0 or &abort("Could not create $changelogfile!"); - } -} - -# -# Add the latest manual and tool from the mysqldoc tree -# -unless ($opt_skip_manual) -{ - &logger("Updating manual files"); - foreach $file qw/internals manual reservedwords errmsg-table cl-errmsg-table/ - { - system ("bk cat $opt_docdir/Docs/$file.texi > $target_dir/Docs/$file.texi") == 0 - or &abort("Could not update $file.texi in $target_dir/Docs/!"); - } - &run_command("cp $opt_docdir/Docs/Support/texi2html $target_dir/Docs/Support", - "Could not copy $opt_docdir/Docs/Support/texi2html!"); - - &run_command("rm -f $target_dir/Docs/Images/Makefile*", - "Could not remove Makefiles in $target_dir/Docs/Images/!"); - &run_command("cp $opt_docdir/Docs/Images/*.* $target_dir/Docs/Images", - "Could not copy image files in $target_dir/Docs/Images/!"); -} - -# -# Abort here, if we just wanted to export the tree -# -if ($opt_export_only) -{ - &logger("SUCCESS: Export finished successfully."); - exit 0; -} - -# -# Enter the target directory first -# -&logger("Entering $target_dir"); -if (!$opt_dry_run) -{ - chdir($target_dir) or &abort("Cannot chdir to $target_dir: $!"); -} - -# -# Now build the source distribution -# -&logger("Compiling..."); -$command= $build_command; -&run_command($command, "Compilation failed!"); - -# -# Testing the built binary by running "make test" (optional) -# -if ($opt_test) -{ - &logger ("Running test suite"); - $command= "make test"; - &run_command($command, "\"make test\" failed!"); -} - -# -# Pack it all up -# -&logger("Creating source distribution"); -$command= "make dist"; -&run_command($command, "make dist failed!"); - -# -# Package the Windows source -# -if ($opt_win_dist) -{ - &logger ("Creating Windows source package"); - $command= "./scripts/make_win_src_distribution --tar --zip"; - &run_command($command, "make_win_src_distribution failed!"); -} - -# -# Run "make distcheck" to verify the source archive -# -if (!$opt_skip_check) -{ - &logger ("Checking source distribution"); - $command= "make distcheck"; - &run_command($command, "make distcheck failed!"); -} - -# -# All done when we came down here -# -&logger("SUCCESS: Build finished successfully.") if (!$opt_dry_run); - -# -# Move the log file into the Log dir of the target dir -# -if ($opt_archive_log) -{ - my $logdir= $target_dir . "/Logs"; - &logger("Moving $LOGFILE to $logdir"); - mkdir "$logdir" if (! -d $logdir); - $command= "mv "; - $command.= "-v " if ($opt_verbose || defined $opt_log); - $command.= "$LOGFILE $logdir"; - &run_command($command, "Could not move $LOGFILE to $logdir!"); -} - -exit 0; - -# -# Run a BK pull on the given BK tree -# -sub bk_pull -{ - my $bk_tree= $_[0]; - &logger("Updating BK tree $bk_tree to latest ChangeSet first"); - chdir ($bk_tree) or &abort("Could not chdir to $bk_tree!"); - &run_command("bk pull", "Could not update $bk_tree!"); - chdir ($PWD) or &abort("Could not chdir to $PWD!"); -} - -# -# Print the help text message (with an optional message on top) -# -sub print_help -{ - my $message= $_[0]; - if ($message ne "") - { - print "\n"; - print "ERROR: $message\n"; - } - print < - -Creates a MySQL source distribution to be used for the release builds. - -It checks out (exports) a clear-text version of the given local BitKeeper -repository, creates and adds a Changelog file (if requested), adds the -latest manual files from the mysqldoc BK tree and builds a source -distribution (*.tar.gz) file. Optionally, the test suite and the -distribution check can be run before the source archive is being created. - -Options: - --a, --archive-log Move the log file into the Logs directory of - the exported tree after a successful build --b, --build-command= Use to compile the sources before packing - the distribution. - (default is "$build_command") --c, --changelog[=] Add a ChangeLog [down to revision ] - This will automatically be included in the source - distribution. To get a ChangeLog down to the last - tagged Changeset, simply use "last" as the revision - number. ---delete Delete an already existing distribution directory - in the target directory instead of renaming it. --d, --directory= Specify the target directory - (default is "$opt_directory") ---docdir= Use the MySQL documentation BK tree located - in - (default is "$opt_docdir") ---dry-run Dry run without executing --e, --export-only Just export (and add the ChangeLog, if requested), - do not build or test the source distribution --h, --help Print this help message --l, --log[=] Write a log file [to ] - (default is "./Bootstrap-.log") --m, --mail=
Mail a failure report to the given address (and - include a log file snippet, if logging is enabled) - Note that the \@-Sign needs to be quoted! - Example: --mail=user\\\@domain.com - Default: build\@mysql.com --q, --quiet Be quiet --p, --pull Update the source BK trees before building --r, --revision= Export the tree as of revision - (default is up to the latest revision) --s, --skip-check Skip checking the distribution with "make distcheck" ---skip-manual Skip updating the manual from the mysqldoc tree ---suffix= Append to the version number in - configure.in. Using the special suffix "YMD" will - add the current date as the suffix - (e.g. "-20020518"). --t, --test Run the test suite after build --v, --verbose Be verbose --w, --win-dist Also make Windows source distribution - -Example: - - Bootstrap -c last -v -l -- mysql-4.0 - -EOF - exit 1; -} diff --git a/Build-tools/Do-all-build-steps b/Build-tools/Do-all-build-steps deleted file mode 100755 index 8ff8851aecd..00000000000 --- a/Build-tools/Do-all-build-steps +++ /dev/null @@ -1,108 +0,0 @@ -#!/bin/sh - -WD=`pwd` -# Don't write a wrong path for BD !!!!! -if [ -w /my/tmp ] -then - BD=/my/tmp/BUILD -elif [ -n "$TMPDIR" ] -then - BD=$TMPDIR/BUILD -else - BD=/tmp/BUILD -fi -TMP_SCRIPT=$WD/Logs/00-temp-for-do-all-build-steps.$$ - -# We build on work -to_host=`hostname` -cc=gcc -ccc=gcc -EXTRA_CONFIG="--without-perl" -#AM_MAKEFLAGS="-j 2" -echo "Building on $to_host" - -rm -rf $BD/* -rm -f $WD/binary/* -mkdir -p $WD/binary -mkdir -p $WD/Logs -mkdir -p $BD/Logs - -cat > $TMP_SCRIPT < $log 2>&1 -else - time sh $TMP_SCRIPT > $log 2>&1 -fi - -# Create a commercial MySQL distribution (mysqlcom-VER.tar.gz) from -# the newly made source distribution - -cd "$BD" -DIST=`ls -t mysql-*.tar.gz | head -1` -$BD/Build-tools/mysql-copyright --target=. $DIST - -# move the binaries to the 'binary' directory -mv $BD/mysql*tar.gz $WD/binary -mv $BD/NEW-RPMS/* $WD/binary diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile deleted file mode 100755 index 97ca0df87c0..00000000000 --- a/Build-tools/Do-compile +++ /dev/null @@ -1,941 +0,0 @@ -#!/usr/bin/perl -w - -use File::Basename; -use Getopt::Long; -use Sys::Hostname; - -@config_options= (); -@make_options= (); - -$opt_comment=$opt_distribution=$opt_user=$opt_config_env=$opt_config_extra_env=""; -$opt_dbd_options=$opt_perl_options=$opt_config_options=$opt_make_options=$opt_suffix=""; -$opt_tmp=$opt_version_suffix=""; -$opt_bundled_zlib=$opt_help=$opt_delete=$opt_debug=$opt_stage=$opt_no_test=$opt_no_perl=$opt_one_error=$opt_with_low_memory=$opt_fast_benchmark=$opt_static_client=$opt_static_server=$opt_static_perl=$opt_sur=$opt_with_small_disk=$opt_local_perl=$opt_tcpip=$opt_build_thread=$opt_use_old_distribution=$opt_enable_shared=$opt_no_crash_me=$opt_no_strip=$opt_with_archive=$opt_with_cluster=$opt_with_csv=$opt_with_example=$opt_with_debug=$opt_no_benchmark=$opt_no_mysqltest=$opt_without_embedded=$opt_readline=$opt_with_blackhole=0; -$opt_skip_embedded_test=$opt_skip_ps_test=$opt_innodb=$opt_bdb=$opt_raid=$opt_libwrap=$opt_clearlogs=$opt_with_federated=$opt_with_big_tables=0; -$global_step=""; - -GetOptions( - "bdb", - "build-thread=i", - "bundled-zlib", - "comment=s", - "config-env=s" => \@config_env, - "config-extra-env=s" => \@config_extra_env, - "config-options=s" => \@config_options, - "dbd-options=s", - "debug", - "delete", - "distribution=s", - "enable-shared", - "fast-benchmark", - "help|Information", - "innodb", - "libwrap", - "local-perl", - "make-options=s" => \@make_options, - "no-crash-me", - "no-perl", - "no-strip", - "no-test", - "no-mysqltest", - "no-benchmark", - "one-error", - "perl-files=s", - "perl-options=s", - "raid", - "readline", - "skip-embedded-test", - "skip-ps-test", - "stage=i", - "static-client", - "static-perl", - "static-server", - "suffix=s", - "sur", - "tcpip", - "tmp=s", - "use-old-distribution", - "user=s", - "version-suffix=s", - "with-archive", - "with-big-tables", - "with-blackhole", - "with-cluster", - "with-csv", - "with-debug", - "with-example", - "with-federated", - "with-low-memory", - "with-other-libc=s", - "with-small-disk", - "without-embedded", - "clearlogs", -) || usage(); - -usage() if ($opt_help); -usage() if (!$opt_distribution); - -if (@make_options > 0) -{ - chomp(@make_options); - $opt_make_options= join(" ", @make_options); -} - -if (@config_options > 0) -{ - chomp(@config_options); - $opt_config_options= join(" ", @config_options); -} - -if (@config_env > 0) -{ - chomp(@config_env); - $opt_config_env= join(" ", @config_env); -} - -if (@config_extra_env > 0) -{ - chomp(@config_extra_env); - $opt_config_extra_env= join(" ", @config_extra_env); -} - -$host= hostname(); -chomp($uname=`uname`); -$full_host_name=$host; -$connect_option= ($opt_tcpip ? "--host=$host" : ""); -$host =~ /^([^.-]*)/; -$host=$1 . $opt_suffix; -$email="$opt_user\@mysql.com"; -chomp($pwd = `pwd`); -$VER= basename($opt_distribution); -$VER=~ /mysql.*-([1-9]\.[0-9]{1,2}\.[0-9]{1,2}.*)\.tar*/; $version=$1; -$release=""; # Shut up perl -($major, $minor, $release) = split(/\./,$version); -$log="$pwd/Logs/$host-$major.$minor$opt_version_suffix.log"; -$opt_distribution =~ /(mysql[^\/]*)\.tar/; -$ver=$1; -$gcc_version=which("gcc"); -$opt_comment= "Official MySQL$opt_version_suffix binary" unless $opt_comment; -if (defined($gcc_version) && ! $opt_config_env) -{ - $tmp=`$gcc_version -v 2>&1`; - if ($tmp =~ /version 2\.7\./) - { - $opt_config_env= 'CC=gcc CFLAGS="-O2 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O2 -fno-omit-frame-pointer"'; - } - elsif ($tmp =~ /version 3\.0\./) - { - $opt_config_env= 'CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti"'; - } - else - { - $opt_config_env= 'CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti"'; - } -} - -$opt_config_env.=" $opt_config_extra_env"; - -$new_opt_tmp=0; -if ($opt_tmp) -{ - unless (-d $opt_tmp) - { - safe_system("mkdir $opt_tmp"); - $new_opt_tmp=1; - } - $ENV{'TMPDIR'}=$opt_tmp; -} -else -{ - $opt_tmp="/tmp"; -} -$bench_tmpdir="$opt_tmp/my_build-$host"; -$ENV{'PATH'}= "$pwd/$host/bin:" . $ENV{'PATH'}; -$make=which("gmake","make"); # Can't use -j here! -$tar=which("gtar","tar"); -$sendmail=find("/usr/lib/sendmail","/usr/sbin/sendmail"); -$sur= $opt_sur ? "/my/local/bin/sur" : ""; -delete $ENV{'MYSQL_PWD'}; # Reset possibly password -delete $ENV{'MY_BASEDIR_VERSION'}; -$ENV{'MYSQL_TCP_PORT'}= $mysql_tcp_port= 3334 + $opt_build_thread*2; -$ENV{'MYSQL_UNIX_PORT'}=$mysql_unix_port="$opt_tmp/mysql$opt_suffix.build"; -$ENV{"PERL5LIB"}="$pwd/$host/perl5:$pwd/$host/perl5/site_perl"; -$slave_port=$mysql_tcp_port+16; -$ndbcluster_port= 9350 + $opt_build_thread*4; -$manager_port=$mysql_tcp_port+1; -$mysqladmin_args="--no-defaults -u root --connect_timeout=5 --shutdown_timeout=20"; - -if ($opt_stage == 0 || $opt_clearlogs) -{ - system("mkdir Logs") if (! -d "Logs"); - system("mv $log ${log}-old") if (-f $log); - unlink($log); -} - -open(LOG,">>$log") || abort("Can't open log file, error $?"); -select LOG; -$|=1; -select STDOUT; -$|=1; - -info("Compiling MySQL$opt_version_suffix at $host$opt_suffix, stage: $opt_stage\n"); -info("LD_LIBRARY_PATH is $ENV{LD_LIBRARY_PATH}"); -info("PATH is $ENV{PATH}"); - -$global_step= "Check MD5, shutdown"; -log_timestamp("START"); - -$md5_result= safe_system("perl $ENV{HOME}/my_md5sum -c ${opt_distribution}.md5"); - -if ($md5_result != 0) -{ - abort("MD5 check failed for $opt_distribution!"); -} -else -{ - info("SUCCESS: MD5 checks for $opt_distribution"); -} - -if (-x "$host/bin/mysqladmin") -{ - log_system("$host/bin/mysqladmin $mysqladmin_args -S $mysql_unix_port -s shutdown"); - log_system("$host/bin/mysqladmin $mysqladmin_args -P $mysql_tcp_port -h $host -s shutdown"); - log_system("$host/bin/mysqladmin $mysqladmin_args -P $slave_port -h $host -s shutdown"); - log_system("$host/bin/mysqladmin $mysqladmin_args -P 9306 -h $host -s shutdown"); - log_system("$host/bin/mysqladmin $mysqladmin_args -P 9307 -h $host -s shutdown"); -} -kill_all("mysqlmanager"); -# -# Kill all old processes that are in the build directories -# This is to find any old mysqld servers left from previous builds -kill_all("$pwd/host/mysql"); -kill_all("$pwd/host/test"); - -$global_step= "directory cleanup"; -if ($opt_stage == 0) -{ - log_timestamp("START"); - print "$host: Removing old distribution\n" if ($opt_debug); - if (!$opt_use_old_distribution) - { - system("mkdir $host") if (! -d $host); - system("touch $host/mysql-fix-for-glob"); - rm_all(<$host/mysql*>); - system("mkdir $host/bin") if (! -d "$host/bin"); - } - rm_all("$host/test"); - system("mkdir $host/test") if (! -d "$host/test"); -} - -safe_cd($host); -if ($opt_stage == 0 && ! $opt_use_old_distribution) -{ - safe_system("gunzip < $opt_distribution | $tar xf -"); - - # Fix file times; This is needed because the time for files may be - # in the future. The following is done this way to ensure that - # we don't get any errors from xargs touch - system("touch timestamp"); - sleep(2); - system("touch timestamp2"); - system("find . -newer timestamp -print | xargs touch"); - unlink("timestamp"); - unlink("timestamp2"); - sleep(2); - # Ensure that files we don't want to rebuild are newer than other files - safe_cd($ver); - foreach $name ("configure", - "Docs/include.texi", - "Docs/*.html", "Docs/manual.txt", "Docs/mysql.info", - "sql/sql_yacc.h", "sql/sql_yacc.cc") - { - system("touch $name"); - } - # Fix some file modes in BDB tables that makes life harder. - system("chmod -R u+rw ."); -} - -safe_cd("$pwd/$host/$ver"); - -# -# Configure the sources -# -$global_step= "configure"; -if ($opt_stage <= 1) -{ - # Fix files if this is in another timezone than the build host - log_timestamp("START"); - unlink("config.cache"); - unlink("bdb/build_unix/config.cache"); - unlink("innobase/config.cache"); - log_system("$make clean") if ($opt_use_old_distribution); - $opt_config_options.= " --disable-shared" if (!$opt_enable_shared); # Default for binary versions - $opt_config_options.= " --with-berkeley-db" if ($opt_bdb); - $opt_config_options.= " --with-zlib-dir=bundled" if ($opt_bundled_zlib); - $opt_config_options.= " --with-client-ldflags=-all-static" if ($opt_static_client); - $opt_config_options.= " --with-debug" if ($opt_with_debug); - $opt_config_options.= " --without-ndb-debug" if ($opt_with_debug && $opt_with_cluster); - $opt_config_options.= " --with-libwrap" if ($opt_libwrap); - $opt_config_options.= " --with-low-memory" if ($opt_with_low_memory); - $opt_config_options.= " --with-big-tables" if ($opt_with_big_tables); - $opt_config_options.= " --with-mysqld-ldflags=-all-static" if ($opt_static_server); - $opt_config_options.= " --with-raid" if ($opt_raid); - if ($opt_readline) - { - $opt_config_options.= " --with-readline"; - } - else - { - $opt_config_options.= " --with-libedit"; - } - $opt_config_options.= " --with-embedded-server" unless ($opt_without_embedded); - $opt_skip_embedded_test= 1 if ($opt_without_embedded); - $opt_config_options.= " --with-archive-storage-engine" if ($opt_with_archive); - $opt_config_options.= " --with-blackhole-storage-engine" if ($opt_with_blackhole); - $opt_config_options.= " --with-ndbcluster" if ($opt_with_cluster); - $opt_config_options.= " --with-csv-storage-engine" if ($opt_with_csv); - $opt_config_options.= " --with-example-storage-engine" if ($opt_with_example); - $opt_config_options.= " --with-federated-storage-engine" if ($opt_with_federated); - - # Only enable InnoDB when requested (required to be able to - # build the "Classic" packages that do not include InnoDB) - if ($opt_innodb) - { - $opt_config_options.= " --with-innodb"; - } - else - { - $opt_config_options.= " --without-innodb"; - } - - if ($opt_with_other_libc) - { - $opt_with_other_libc= " --with-other-libc=$opt_with_other_libc"; - $opt_config_options.= $opt_with_other_libc; - } - - $prefix="/usr/local/mysql"; - check_system("$opt_config_env ./configure --prefix=$prefix --localstatedir=$prefix/data --libexecdir=$prefix/bin --with-comment=\"$opt_comment\" --with-extra-charsets=complex --with-server-suffix=\"$opt_version_suffix\" --enable-thread-safe-client --enable-local-infile $opt_config_options","Thank you for choosing MySQL"); - if (-d "$pwd/$host/include-mysql") - { - safe_system("cp -r $pwd/$host/include-mysql/* $pwd/$host/$ver/include"); - } - log_timestamp("DONE "); -} - -# -# Compile the binaries -# -$global_step= "compile + link"; -if ($opt_stage <= 2) -{ - my ($command); - log_timestamp("START"); - unlink($opt_distribution) if ($opt_delete && !$opt_use_old_distribution); - $command=$make; - $command.= " $opt_make_options" if (defined($opt_make_options) && $opt_make_options ne ""); - safe_system($command); - print LOG "Do-compile: Build successful\n"; - log_timestamp("DONE "); -} - -# -# Create the binary distribution -# -$global_step= "pack binary distribution"; -if ($opt_stage <= 3) -{ - log_timestamp("START"); - my $flags= ""; - log_system("rm -fr mysql-{3,4,5}* $pwd/$host/mysql*.t*gz"); - # No need to add the debug symbols, if the binaries are not stripped (saves space) - unless ($opt_with_debug || $opt_no_strip) - { - log_system("nm -n sql/mysqld | gzip -9 -v 2>&1 > sql/mysqld.sym.gz | cat"); - } - - $flags.= " --no-strip" if ($opt_no_strip || $opt_with_debug); - $flags.= " --with-ndbcluster" if ($opt_with_cluster); - check_system("scripts/make_binary_distribution --tmp=$opt_tmp --suffix=$opt_suffix $flags",".tar.gz created"); - safe_system("mv mysql*.t*gz $pwd/$host"); - if (-f "client/.libs/mysqladmin") - { - safe_system("cp client/.libs/mysqladmin $pwd/$host/bin"); - } - else - { - safe_system("cp client/mysqladmin $pwd/$host/bin"); - } - safe_system("$make clean") if ($opt_with_small_disk); - log_timestamp("DONE "); -} - -$tar_file=<$pwd/$host/mysql*.t*gz>; -abort ("Could not find tarball!") unless ($tar_file); - -# Generate the MD5 for the binary distribution -$tar_file=~ /(mysql[^\/]*)\.(tar\.gz|tgz)/; -$tar_file_lite= "$1.$2"; -system("cd $pwd/$host; perl $ENV{HOME}/my_md5sum $tar_file_lite > ${tar_file_lite}.md5"); - -# -# Unpack the binary distribution -# -$global_step= "extract binary distribution"; -if ($opt_stage <= 4 && !$opt_no_test) -{ - log_timestamp("START"); - rm_all(<$pwd/$host/test/*>); - safe_cd("$pwd/$host/test"); - safe_system("gunzip < $tar_file | $tar xf -"); - log_timestamp("DONE "); -} - -$tar_file =~ /(mysql[^\/]*)\.(tar\.gz|tgz)/; -$ver=$1; -$test_dir="$pwd/$host/test/$ver"; -$ENV{"LD_LIBRARY_PATH"}= ("$test_dir/lib" . - (defined($ENV{"LD_LIBRARY_PATH"}) ? - ":" . $ENV{"LD_LIBRARY_PATH"} : "")); -# -# Run the test suite -# -$global_step= "tests in default mode"; -if ($opt_stage <= 5 && !$opt_no_test && !$opt_no_mysqltest) -{ - log_timestamp("START"); - my $flags= ""; - $flags.= " --with-ndbcluster" if ($opt_with_cluster); - $flags.= " --force" if (!$opt_one_error); - info("Running test suite"); - system("mkdir $bench_tmpdir") if (! -d $bench_tmpdir); - safe_cd("${test_dir}/mysql-test"); - check_system("./mysql-test-run $flags --tmpdir=$bench_tmpdir --master_port=$mysql_tcp_port --slave_port=$slave_port --ndbcluster_port=$ndbcluster_port --manager-port=$manager_port --no-manager --sleep=10", "were successful"); - log_timestamp("DONE "); - - $global_step= "tests using prepared statements"; - unless ($opt_skip_ps_test) - { - log_timestamp("START"); - info("Running test suite using prepared statements"); - check_system("./mysql-test-run $flags --ps-protocol --tmpdir=$bench_tmpdir --master_port=$mysql_tcp_port --slave_port=$slave_port --ndbcluster_port=$ndbcluster_port --manager-port=$manager_port --no-manager --sleep=10", "were successful"); - log_timestamp("DONE "); - } - - $global_step= "tests using embedded server"; - unless ($opt_skip_embedded_test) - { - log_timestamp("START"); - info("Running embedded server test suite"); - # Embedded server and NDB don't jive - $flags=~ s/ --with-ndbcluster//; - check_system("./mysql-test-run $flags --embedded-server --tmpdir=$bench_tmpdir --master_port=$mysql_tcp_port --slave_port=$slave_port --manager-port=$manager_port --no-manager --sleep=10", "were successful"); - log_timestamp("DONE "); - } - # 'mysql-test-run' writes its own final message for log evaluation. -} - -# -# Start the server if we are going to run any of the benchmarks -# -if (!$opt_no_test && !$opt_no_benchmark) -{ - my $extra; - safe_cd($test_dir); - log_system("./bin/mysqladmin $mysqladmin_args -S $mysql_unix_port -s shutdown") || info("There was no mysqld running\n"); - sleep(2); - log_system("rm -f ./data/mysql/*"); - check_system("scripts/mysql_install_db --no-defaults --skip-locking","https://order"); - $extra=""; - if ($opt_bdb) - { - $extra.=" --bdb_cache_size=16M --bdb_max_lock=240000" - } - if ($opt_innodb) - { - $extra.=" --innodb_data_file_path=ibdata1:100M:autoextend"; - } - safe_system("./bin/mysqld --no-defaults --basedir . --datadir ./data --skip-locking $extra >> $log 2>&1 &"); - sleep(2); -} - -# -# Compile and install the required Perl modules -# -$global_step= "installing Perl modules"; -if ($opt_stage <= 7 && $opt_perl_files && !$opt_no_perl && !$opt_no_test && - !$opt_no_benchmark) -{ - log_timestamp("START"); - safe_cd($test_dir); - rm_all("perl"); - safe_system("mkdir perl"); - $ENV{'IN_MYSQL_DISTRIBUTION'}=1; - $ENV{'MYSQL_BUILD'}=$test_dir; - - foreach $module (split(/,/,$opt_perl_files)) - { - my $options; - safe_cd("$test_dir/perl"); - if ($opt_debug) - { - safe_system("gunzip < $pwd/$module | tar xvf -"); - } - else - { - safe_system("gunzip < $pwd/$module | tar xf -"); - } - $module =~ m|([^/]+)\.tar\.gz|; - $module = $1; - safe_cd($module); - $options=""; - $options= "--mysql-install --noprompt --mysql-incdir=$test_dir/include --mysql-libdir=$test_dir/lib -nomsql-install -nomsql1-install --mysql-test-db=test $opt_dbd_options" if ($module =~ /Msql-Mysql/); - $options.= " PREFIX=$pwd/$host INSTALLPRIVLIB=$pwd/$host/perl5 INSTALLSCRIPT=$pwd/$host/bin INSTALLSITELIB=$pwd/$host/perl5/site_perl INSTALLBIN=$pwd/$host/bin INSTALLMAN1DIR=$pwd/$host/man INSTALLMAN3DIR=$pwd/$host/man/man3" if ($opt_local_perl); - $options.= " $opt_perl_options" if (defined($opt_perl_options)); - safe_system($opt_static_perl ? "perl Makefile.PL -static $options" : "perl Makefile.PL $options"); - safe_system("$make ; $sur $make install"); - } - log_timestamp("DONE "); -} - -# -# Run crash-me test -# -$global_step= "crash-me checks"; -if ($opt_stage <= 8 && !$opt_no_test && !$opt_no_crash_me) -{ - log_timestamp("START"); - safe_cd("$test_dir/sql-bench"); - log_system("rm -f limits/mysql.cfg"); - safe_system("perl ./crash-me --force --batch-mode $connect_option"); - log_timestamp("DONE "); -} - -# -# Run sql-bench Benchmarks -# -$global_step= "benchmarks"; -if ($opt_stage <= 9 && !$opt_no_test && !$opt_no_benchmark) -{ - log_timestamp("START"); - safe_cd("$test_dir/sql-bench"); - log_system("rm -f output/*"); - $tmp= $opt_fast_benchmark ? "--fast --user root --small-test" : ""; - check_system("perl ./run-all-tests --log --die-on-errors $connect_option $tmp","RUN-mysql"); - # Run additional fast test with dynamic-row tables - check_system("perl ./run-all-tests --log --suffix=\"_dynamic_rows\" --die-on-errors $connect_option --fast --user=root --small-test --create-options=\"row_format=dynamic\"","RUN-mysql"); - if ($opt_innodb) - { - check_system("perl ./run-all-tests --log --suffix=\"_innodb\" --die-on-errors $connect_option $tmp --create-options=\"type=innodb\"","RUN-mysql"); - } - if ($opt_bdb) - { - check_system("perl ./run-all-tests --log --suffix=\"_bdb\" --die-on-errors $connect_option $tmp --create-options=\"type=bdb\"","RUN-mysql"); - } - log_timestamp("DONE "); -} - -rm_all($bench_tmpdir); -rm_all("$opt_tmp") if ($new_opt_tmp); - -log_system("$pwd/$host/bin/mysqladmin $mysqladmin_args -S $mysql_unix_port shutdown"); -print LOG "ok\n"; -close LOG; -print "$host: ok\n"; - -exit 0; - - -sub usage -{ -print < -When running several Do-compile runs in parallel, each build -should have its own thread ID, so running the test suites -does not cause conflicts with duplicate TCP port numbers. - ---comment= -Replace the default compilation comment that is embedded into -the mysqld binary. - ---config-env= -To set up the environment, like 'CC=cc CXX=gcc CXXFLAGS=-O3' - ---config-extra-env -Additional flags for environment (not CC or CXX). Should be used when one -wants Do-compile to propose proper CC and CXX flags. - ---config-options= -To add some extra options to configure (e.g. '--with-perl=yes') - ---dbd-options -Options for Makefile.PL when configuring msql-mysql-modules. - ---debug -Print all shell commands on stdout. - ---delete -Delete the distribution file. - ---distribution= -Name of the MySQL source distribution file. - ---enable-shared -Compile with shared libraries - ---fast-benchmark -Run fast benchmark only to speed up testing - ---help or --Information -Show this help - ---innodb -Compile with support for Innodb tables - ---libwrap -Compile with TCP wrapper support - ---local-perl -Install Perl modules locally - ---make-options= -Options to make after configure. (Like 'CXXLD=gcc') - ---no-crash-me -Do not run the "crash-me" test - ---no-strip -Do not strip the binaries included in the binary distribution - ---no-test -Do not run any tests. - ---no-benchmark -Do not run the benchmark test (written in perl) - ---no-mysqltest -Do not run the mysql-test-run test (Same as 'make test') - ---one-error -Terminate the mysql-test-run test after the first difference (default: use '--force') - ---no-perl -Do not compile or install Perl modules, use the system installed ones - ---perl-files= -Compile and install the given perl modules. - ---perl-options= -Build Perl modules with the additional options - ---raid -Compile with RAID support - ---readline -Compile against readline library instead of libedit - ---skip-embedded-test -Skip running the test suite against the embedded server - ---skip-ps-test -Skip running the additional test run that uses the prepared statement protocol - ---stage=[1-6] -Start script from some specific point. - ---static-client -Build statically linked client binaries - ---static-perl -Build statically linked Perl modules - ---static-server -Build statically linked server binary - ---tcpip -Connect to the server to be tested via TCP/IP instead of socket - ---tmp= -Use a different temporary directory than /tmp - ---use-old-distribution -Do not clean up the build environment and extract a fresh source -distribution, use an existing one instead. - ---user= -Mail 'user_name'\@mysql.com if something went wrong. -If user is empty then no mail is sent. - ---version-suffix=suffix -Set name suffix (e.g. 'com' or '-max') for a distribution - ---with-archive -Enable the Archive storage engine - ---with-cluster -Compile and test with NDB Cluster enabled - ---with-csv -Enable the CSV storage engine - ---with-example -Enable the Example storage engine - ---with-federated -Enable the Federated storage engine - ---with-debug -Build binaries with debug information (implies "--no-strip") - ---with-low-memory -Use less memory when compiling. - ---with-other-libc= -Link against libc and other standard libraries installed in the specified -non-standard location overriding default. - ---with-small-disk -Clean up the build environment before testing the binary distribution -(to save disk space) - ---without-embedded -Don't compile the embedded server. -EOF -exit 1; -} - -sub abort -{ - my($message)=@_; - my($mail_header_file); - print LOG "\n$message\n"; - print "$host: $message\n" if ($opt_debug); - log_timestamp("ABORT"); - close LOG; - - if ($opt_user) - { - # Take the last 40 lines of the build log - open(LOG, "$log") or die $!; - my @log= ; - close LOG; - splice @log => 0, -40; - my $mail_file="$opt_tmp/do-command.$$"; - open(TMP,">$mail_file") or die $!; - print TMP "From: mysqldev\@$full_host_name\n"; - print TMP "To: $email\n"; - print TMP "Subject: $host($uname): $ver$opt_version_suffix compilation failed\n\n"; - print TMP @log; - close TMP; - system("$sendmail -t -f $email < $mail_file"); - unlink($mail_file); - } - exit 1; -} - -sub info -{ - my($message)=@_; - print LOG "$message\n"; - print "$host: $message\n"; -} - -sub log_system -{ - my($com)=@_; - print "$host: $com\n" if ($opt_debug); - if (defined($log)) - { - print LOG "$com\n"; - system("$com >> $log 2>&1") && - print LOG ("Info: couldn't execute command, error: " . ($? / 256) ."\n"); - } - else - { - system($com) && print "$host: Couldn't execute command, error: " . ($? / 256) ."\n"; - } -} - - -sub safe_system -{ - my($com,$res)=@_; - print LOG "$com\n"; - print "$host: $com\n" if ($opt_debug); - my $result= system("$com >> $log 2>&1"); - abort("error: Couldn't execute command, error: " . ($? / 256)) unless $result == 0; - - return $result; -} - -sub check_system -{ - my($com,$res)=@_; - my ($error,$found); - print LOG "$com\n"; - print "$host: $com\n" if ($opt_debug); - open (COM, "$com 2>&1 < /dev/null|") || abort("Got error " . ($?/256) ." opening pipe"); - $found=0; - while () - { - print LOG $_; - if (index($_,$res) >= 0) - { - $found=1; - last; - } - } - close COM; - abort("Couldn't find '$res' in the command result") if (!$found); - print "$host: Command ok\n" if ($opt_debug); -} - -sub safe_cd -{ - my($dir)=@_; - print LOG "cd $dir\n"; - print "$host: cd $dir\n" if ($opt_debug); - chdir($dir) || abort("Can't cd to $dir"); -} - -sub which -{ - my(@progs)=@_; - foreach $prog (@progs) - { - chomp($found=`which $prog | head -n 1`); - if ($? == 0 && $found ne "" && index($found," ") == -1) - { - $found =~ s|/+|/|g; # Make nicer output - return $found; - } - } - return undef(); -} - -sub find -{ - my (@progs)=@_; - foreach $prog (@progs) - { - return $prog if (-x $prog); - } - return undef(); -} - -# -# Remove recursively all from a directory -# This is needed because problems with NFS and open files -# - -sub rm_all -{ - my(@rm_files)=@_; - my($dir,$current_dir,@files,@dirs,$removed); - $current_dir = `pwd`; chomp($current_dir); - - foreach $dir (@rm_files) - { - if (-d $dir) - { - chdir($dir) || abort("Can't cd to $dir"); - print "$host: Removing from $dir\n" if ($opt_debug); - while (<* .*>) - { - next if ($_ eq "." x (length($_))); - if (-d $_) - { -# die "Can't remove directory that starts with ." if ($_ =~ /^\./ && $_ ne ".libs"); # Safety - push (@dirs,$_); - } - else - { - push (@files,$_); - } - } - if ($#files >= 0) - { - $removed= unlink @files; - print "rm_all : removed $removed files in $current_dir/$dir\n" if ($opt_debug); - abort("Can't remove all $#files+1 from $current_dir/$dir, just $removed") if $removed != $#files+1; - } - foreach $dir (@dirs) - { - rm_all($dir); - } - chdir($current_dir) || abort("Can't cd to $current_dir"); - log_system("rmdir $dir"); - } - else - { - system("rm -f $dir") && abort("Can't remove file $dir"); - } - } -} - -sub kill_all -{ - my ($pattern) = @_; - my ($USER,$BSD,$LINUX, $pscmd, $user, $os, $pid); - $user=$ENV{'USER'}; - $os=defined($ENV{'OS'}) ? $ENV{'OS'} : "unknown"; - $BSD = -f '/vmunix' || $os eq "SunOS4" || $^O eq 'darwin'; - $LINUX = $^O eq 'linux'; - $pscmd = $BSD ? "/bin/ps -auxww" : $LINUX ? "/bin/ps axuw" : "/bin/ps -ef"; - - if (!open(PS, "$pscmd|")) - { - print "Warning: Can't run $pscmd: $!\n"; - log_timestamp("ABORT"); - exit; - } - - # Catch any errors with eval. A bad pattern, for instance. - process: - while ($cand = ) - { - chop($cand); - ($pid_user, $pid) = split(' ', $cand); - next if $pid eq $$; - next process if (! ($cand =~ $pattern) || $pid_user ne $user); - print LOG "Killing $_\n"; - &killpid($pid); - } -} - -sub killpid -{ - local($pid) = @_; - kill 15, $pid; - for (1..5) - { - sleep 2; - return if kill(0, $pid) == 0; - } - kill 9, $pid; - for (1..5) { - sleep 2; - return if kill(0, $pid) == 0; - } - print LOG "$pid will not die!\n"; -} - -# -# return the current date as a string (YYYY-MM-DD HH:MM:SS) -# -sub log_timestamp -{ - my ($message) = @_; - my @ta=localtime(time()); - print LOG sprintf("%4d-%02d-%02d %02d:%02d:%02d %s %s\n", - $ta[5]+1900, $ta[4]+1, $ta[3], $ta[2], $ta[1], $ta[0], - $message, $global_step); - -} diff --git a/Build-tools/Do-create-perl-rpms b/Build-tools/Do-create-perl-rpms deleted file mode 100755 index 2aa71740b58..00000000000 --- a/Build-tools/Do-create-perl-rpms +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - - -PM_FILES='Data-Dumper Data-ShowTable DBI Msql-Mysql-modules' -FILE_EXT='tar.gz' -ARCH=`uname -m | perl -p -e 's/^i[0-9]86$/i386/'` - -# directories -[ -d /usr/src/redhat ] && RPM_SRC=/usr/src/redhat -[ -d /usr/src/packages ] && RPM_SRC=/usr/src/packages -SRC_DIR=/home/matt/work/pm_rpm/tarballs # pristine tarballs -DEST_DIR=${RPM_SRC}/SOURCES # RPM SOURCES (building area) -RPM_DEPOSIT=/var/tmp/ftp/RPMS # RPM production deposit -SRPM_DEPOSIT=/var/tmp/ftp/SRPMS # SRPM production deposit - -# keyword replacement for SPEC templates -REPLACE_KEY='REPLACE_VERSION' - -# paths to beloved programs -NEWEST=/home/matt/work/build_pm_rpms/newest -REPLACE=/usr/local/bin/replace - - -#++ -# Copy the source tarballs up to staging area for RPM building. -#-- -cd $SRC_DIR -for i in $PM_FILES -do - echo Copying $i... - cp ${SRC_DIR}/`$NEWEST -s $SRC_DIR -b $i -t $FILE_EXT` $DEST_DIR -done - - -#++ -# Do keyword replacements on the SPEC templates, and build RPMS -#-- -cd ${RPM_SRC}/SPECS -for i in $PM_FILES -do - cat ${i}.spec.template | $REPLACE $REPLACE_KEY `$NEWEST -s $DEST_DIR -b $i -t $FILE_EXT -v` > ${i}.spec - rpm -ba ${i}.spec - rm ${i}.spec -done - - -#++ -# Copy new RPMS and SRPMS to production deposit -#-- -cd $RPM_SRC - -# kludge code -PM_FILES=`echo $PM_FILES | $REPLACE Msql-Mysql-modules DBD-Mysql` -tmpv=`$NEWEST -s $DEST_DIR -b Msql-Mysql-modules -t $FILE_EXT -v` -mv SOURCES/Msql-Mysql-modules-${tmpv}.${FILE_EXT} SOURCES/DBD-Mysql-${tmpv}.${FILE_EXT} - - -for i in $PM_FILES -do - cp RPMS/${ARCH}/${i}-`$NEWEST -s $DEST_DIR -b $i -t $FILE_EXT -v`-1.${ARCH}.rpm $RPM_DEPOSIT - cp SRPMS/${i}-`$NEWEST -s $DEST_DIR -b $i -t $FILE_EXT -v`-1.src.rpm $SRPM_DEPOSIT - rm SOURCES/`$NEWEST -s $DEST_DIR -b $i -t $FILE_EXT` -done - diff --git a/Build-tools/Do-hpux-depot b/Build-tools/Do-hpux-depot deleted file mode 100755 index f7e8e2c020d..00000000000 --- a/Build-tools/Do-hpux-depot +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/perl - -# -# By Matt Wagner 2005 -# -# This script generates HP Depot packages for MySQL Server. -# It basically repackages a binary tarball as a depot. -# -# Usage: ./Do-hpux-depot -# - -$fullname = shift @ARGV; -$fullname or die "No package name was specified"; --d $fullname or die "That directory is not present!"; - -$fullname =~ s,/+$,,; # Remove ending slash if any - -chomp($pwd= `pwd`); - -%title= ( - "mysql-standard" => "MySQL Community Edition - Standard (GPL)", - "mysql-debug" => "MySQL Community Edition - Debug (GPL)", - "mysql-max" => "MySQL Community Edition - Experimental (GPL)", - "mysql-pro" => "MySQL Pro (Commercial)", - "mysql-classic" => "MySQL Classic (Commercial)", - "mysql-cluster" => "MySQL Cluster (Commercial)", -); - -%architecture= ( - "hpux11.23" => "HP-UX_B.11.23", - "hpux11.11" => "HP-UX_B.11.11", - "hpux11.00" => "HP-UX_B.11.00", -); - -%os_release= ( - "hpux11.23" => "?.11.2?", - "hpux11.11" => "?.11.1?", - "hpux11.00" => "?.11.0?", -); - -%machine_type= ( - "ia64" => "ia64*", - "hppa2.0w" => "9000/*", -); - -$fullname =~ m/^(mysql-\w+)-([\d\.]+)-hp-(hpux11\.\d\d)-(hppa2\.0w|(ia64))-?(64bit)?$/; - -# print "title: $1\n"; -# print "version: $2\n"; -# print "os: $3\n"; -# print "cpu: $4\n"; -# print "64: $6\n"; - -$cpu64= ($6 ne "") ? "_64" : ""; - -open (PSF,">${fullname}.psf") or die "Unable to write PSF file ($!)\n"; - -print PSF < $fullname.depot.gz\" -x target_type=tape -s ${pwd}/${fullname}.psf"); - diff --git a/Build-tools/Do-linux-build b/Build-tools/Do-linux-build deleted file mode 100755 index 44a9ad05fa2..00000000000 --- a/Build-tools/Do-linux-build +++ /dev/null @@ -1,28 +0,0 @@ -#! /bin/sh - -set -e -x - -# Only use the "--with-other-libc" parameter, if another libc actually -# exists, since this will also force static linking, which does not work -# together with OpenSSL -OTHER_LIBC_DIR=/usr/local/mysql-glibc -OTHER_LIBC="" -if [ -d OTHER_LIBC_DIR ] ; then - OTHER_LIBC="--with-other-libc=$OTHER_LIBC_DIR" -fi - -BUILD/compile-pentium-max $OTHER_LIBC \ - --with-comment="Official MySQL Binary" \ - --prefix=/usr/local/mysql --with-extra-charset=complex \ - --enable-thread-safe-client --enable-local-infile \ - --with-server-suffix=-max -nm -n sql/mysqld | gzip -9 -v 2>&1 > sql/mysqld.sym.gz -scripts/make_binary_distribution -make dist -Build-tools/Do-rpm --local -BUILD/compile-pentium --with-other-libc=$OTHER_LIBC_DIR \ - --with-comment="Official MySQL Binary" \ - --prefix=/usr/local/mysql --with-extra-charset=complex \ - --enable-thread-safe-client --enable-local-infile -nm -n sql/mysqld | gzip -9 -v 2>&1 > sql/mysqld.sym.gz -scripts/make_binary_distribution diff --git a/Build-tools/Do-local-patch-file b/Build-tools/Do-local-patch-file deleted file mode 100755 index 708d06966d3..00000000000 --- a/Build-tools/Do-local-patch-file +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# make a patch file of a mysql distribution -# takes as argument the previous version - -case $# in -0) echo Usage: $0 previous_version; exit 1;; -esac - -PVER=$1; -VER=`grep SERVER_VERSION include/mysql_version.h | cut -d'"' -f2` -NEW="mysql-$VER.tar.gz" -OLD="mysql-$PVER.tar.gz" -RESULT="mysql-$PVER-$VER.patch.gz" -PATCH_DIR=/my/data/tcxwww/html/Downloads/Patches -RESULT_DIR=/my/data/tcxwww/html/Downloads/MySQL-3.22 - -if test ! -f $NEW -then - echo "$NEW doesn't exist"; - exit 1; -fi - -if test ! -f $RESULT_DIR/$OLD -then - echo "$RESULT_DIR/$OLD doesn't exist"; - exit 1; -fi - -mkdir patch -cd patch -gtar xfz ../$NEW -gtar xfz $RESULT_DIR/$OLD -cd mysql-$PVER -diff --context --new-file --recursive . ../mysql-$VER | gzip -9 > ../../$RESULT -cd ../.. -/bin/rm -rf patch - diff --git a/Build-tools/Do-patch-file b/Build-tools/Do-patch-file deleted file mode 100755 index 7e6d4c493d8..00000000000 --- a/Build-tools/Do-patch-file +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# make a patch file of a mysql distribution -# takes as argument the previous version - -case $# in -0) echo Usage: $0 previous_version; exit 1;; -esac - -PVER=$1; -VER=`grep SERVER_VERSION /my/tmp/BUILD/include/mysql_version.h | cut -d'"' -f2` -NEWDIR="binary" -NEW="mysql-$VER.tar.gz" -OLD="mysql-$PVER.tar.gz" -RESULT="mysql-$PVER-$VER.patch.gz" -PATCH_DIR=/my/web/Downloads-live/Patches -RESULT_DIR=/my/web/Downloads-live/MySQL-4.0 -RESULT_DIR_MAX=/my/web/Downloads-live/MySQL-Max-4.0 - -if test ! -f $NEWDIR/$NEW -then - echo "$NEWDIR/$NEW doesn't exist"; - exit 1; -fi - -if test ! -f $RESULT_DIR/$OLD -then - echo "$RESULT_DIR/$OLD doesn't exist"; - exit 1; -fi - -mkdir patch -cd patch -gtar xfz ../$NEWDIR/$NEW -gtar xfz $RESULT_DIR/$OLD -cd mysql-$PVER -diff --unified --new-file --recursive . ../mysql-$VER | gzip -9 > ../../$RESULT -cd ../.. -/bin/rm -rf patch -chmod a+r,o-w $RESULT binary/* -mv $RESULT $PATCH_DIR -cp binary/mysqlcom-* binary/mysql*win* /net/web/home/production/data/nweb/customer/Downloads -rm binary/mysqlcom-* -mv binary/*Max* binary/*-max* $RESULT_DIR_MAX -cp binary/* $RESULT_DIR diff --git a/Build-tools/Do-pkg b/Build-tools/Do-pkg deleted file mode 100755 index 9e3fde76f4f..00000000000 --- a/Build-tools/Do-pkg +++ /dev/null @@ -1,334 +0,0 @@ -#!/usr/bin/perl -w -# -# Do-pkg - convert a binary distribution into a Mac OS X PKG and put it -# inside a Disk Image (.dmg). Additionally, add a separate package, -# including the required Startup Item to automatically start MySQL on -# bootup. -# -# The script currently assumes the following environment (which should exist -# like that, if the Do-compile script was used to build the binary -# distribution) -# -# - there must be a binary distribution (*.tar.gz) in the directory -# `hostname` of the current directory -# - the extracted and compiled source tree should be located in the -# `hostname` directory, too -# -# Use the "--help" option for more info! -# -# written by Lenz Grimmer -# - -use Cwd; -use File::Basename; -use File::Copy; -use Getopt::Long; -Getopt::Long::Configure ("bundling"); -use Sys::Hostname; - -$opt_dry_run= undef; -$opt_help= undef; -$opt_log= undef; -$opt_mail= ""; -$opt_skip_dmg= undef; -$opt_skip_prefpane= undef; -$opt_skip_si= undef; -$opt_suffix= undef; -$opt_verbose= undef; -$opt_version= undef; - -GetOptions( - "dry-run", - "help|h", - "log|l:s", - "mail|m=s", - "skip-prefpane|p", - "skip-dmg|skip-disk-image|s", - "skip-si|skip-startup-item", - "suffix=s", - "verbose|v", - "version=s", -) || &print_help; - -# Include helper functions -$PWD= cwd(); -$LOGGER= "$PWD/logger.pm"; -if (-f "$LOGGER") -{ - do "$LOGGER"; -} -else -{ - die "ERROR: $LOGGER cannot be found!\n"; -} - -$PM= "/Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker"; -# Try another location on 10.3.3 -unless (-e "$PM") -{ - $PM= "/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker"; -} - -$TMP= $ENV{TMPDIR}; -$TMP eq "" ? $TMP= $TMP . "/PKGBUILD.$$": $TMP= "/tmp/PKGBUILD.$$"; -$PKGROOT= "$TMP/PMROOT"; -$PKGDEST= "$TMP/PKG"; -$RESOURCE_DIR= "$TMP/Resources"; -$SUFFIX= $opt_suffix; -$VERSION= $opt_version; -($MAJOR, $MINOR, $RELEASE)= split(/\./, $VERSION); -$NAME= "mysql$SUFFIX-$VERSION"; -$HOST= hostname(); -$ID= getpwuid($>); -$HOST=~ /^([^.-]*)/; -$HOST= $1; -$LOGFILE= "$PWD/Logs/$HOST-$MAJOR.$MINOR$SUFFIX.log"; -$BUILDDIR= "$PWD/$HOST"; -$PREFPANE= "$PWD/mysql-administrator/source/mac/PreferencePane/build/MySQL.prefPane"; -$SRCBASEDIR= <$BUILDDIR/mysql*-$VERSION>; -$SUPFILEDIR= <$SRCBASEDIR/support-files/MacOSX>; -$TAR= <$BUILDDIR/$NAME-apple-darwin*-powerpc*.tar.gz>; -$TAR =~ /.*\/$NAME(.*)\.tar\.gz$/; -$ARCH= $1; -$NAME= $NAME . $ARCH; -$INFO= <$SUPFILEDIR/Info.plist>; -$DESC= <$SUPFILEDIR/Description.plist>; -$SI_INFO= <$SUPFILEDIR/StartupItem.Info.plist>; -$SI_DESC= <$SUPFILEDIR/StartupItem.Description.plist>; -$SI_PARAMS= <$SUPFILEDIR/StartupParameters.plist>; -$SI_POST= <$SUPFILEDIR/StartupItem.postinstall>; -$SI_NAME= "MySQLStartupItem"; -$SI_DIR_NAME= "MySQLCOM"; -$SI_SCRIPT= <$SUPFILEDIR/MySQLCOM>; -@RESOURCES= qw/ ReadMe.txt postinstall preinstall /; -@LICENSES= ("$SRCBASEDIR/COPYING","$SRCBASEDIR/MySQLEULA.txt"); - -&print_help("") if ($opt_help || !$opt_suffix || !$opt_version); - -# -# Override predefined Log file name -# -if (defined $opt_log) -{ - if ($opt_log ne "") - { - if ($opt_log =~ /^\/.*/) - { - $LOGFILE= $opt_log; - } - else - { - $LOGFILE= $PWD . "/" . $opt_log; - } - } -} - -# Creating the UFS disk image requires root privileges -die("You must be root to run this script!") if ($ID ne "root" && !$opt_dry_run); - -@files= ($TAR, $INFO, $DESC); -@files= (@files, $SI_INFO, $SI_DESC, $SI_POST, $SI_SCRIPT) unless $opt_skip_si; -foreach $file (@files) -{ - &abort("Unable to find $file!") unless (-f "$file"); -} - -# Remove old temporary build directories first -&logger("Cleaning up temporary build directories"); -&run_command("rm -rf $TMP", "Could not clean up $TMP!"); -&logger("Creating temp directories"); -foreach $dir ($TMP, $PKGROOT, $PKGDEST, $RESOURCE_DIR) -{ - if (!-d $dir) - { - &logger("Creating directory $dir!"); - unless($opt_dry_run) - { - mkdir($dir) or &abort("Could not make directory $dir!"); - } - } -} - -foreach $resfile (@RESOURCES) -{ - &logger("Copying $SUPFILEDIR/$resfile to $RESOURCE_DIR"); - unless($opt_dry_run) - { - copy("$SUPFILEDIR/$resfile", "$RESOURCE_DIR") or - &abort("Error while copying $SUPFILEDIR/$resfile to $RESOURCE_DIR"); - } -} - -# Search for license file -foreach $license (@LICENSES) -{ - if (-f "$license") - { - &logger("Copy $license to $RESOURCE_DIR/License.txt"); - unless($opt_dry_run) - { - copy("$license", "$RESOURCE_DIR/License.txt") or - &abort("Error while copying $license to $RESOURCE_DIR"); - } - } -} - -&abort("Could not find a license file!") -unless (-f "$RESOURCE_DIR/License.txt"); - -# Extract the binary tarball and create the "mysql" symlink -&logger("Extracting $TAR to $PKGROOT"); -&run_command("gnutar zxf $TAR -C $PKGROOT", "Unable to extract $TAR!"); -&run_command("cd $PKGROOT ; ln -s mysql* ./mysql", "Unable to create symlink!"); -&run_command("chown -R root:wheel $PKGROOT/*", "Cannot chown $PKGROOT!"); - -# Now build the PGK using PackageMaker -# The "|| true" is a nasty hack to work around a problem with Package Maker -# returning a non-zero value, even though the package was created correctly -&logger("Running PackageMaker"); -$command= "$PM -build -p $PKGDEST/$NAME.pkg -f $PKGROOT -r $RESOURCE_DIR -i $INFO -d $DESC || true"; -&run_command($command, "Error while building package $NAME.pkg!"); - -# -# Build the Startup Item PKG -# -unless ($opt_skip_si) -{ - &logger("Cleaning up $PKGROOT"); - &run_command("rm -rf $PKGROOT/*", "Unable to clean up $PKGROOT!"); - &logger("Cleaning up $RESOURCE_DIR"); - &run_command("rm -rf $RESOURCE_DIR/*", "Unable to clean up $RESOURCE_DIR!"); - - my $SI_DIR= $PKGROOT . "/" . $SI_DIR_NAME; - &logger("Installing MySQL StartupItem files into $SI_DIR"); - unless($opt_dry_run) - { - mkdir("$SI_DIR") - or &abort("Error creating $SI_DIR"); - copy("$SI_SCRIPT", "$SI_DIR/") - or &abort("Error copying $SI_SCRIPT!"); - chmod(0755, "$SI_DIR/" . basename("$SI_SCRIPT")); - copy("$SI_PARAMS", "$SI_DIR/") - or &abort("Error copying $SI_PARAMS!"); - chmod(0644, "$SI_DIR/" . basename("$SI_PARAMS")); - &run_command("chown -R root:wheel $PKGROOT/*", "Cannot chown $PKGROOT!"); - copy("$SI_POST", "$RESOURCE_DIR/postinstall") - or &abort("Error copying $SI_POST!"); - chmod(0644, "$RESOURCE_DIR/postinstall"); - } - - &logger("Building $SI_NAME.pkg using PackageMaker"); - $command= "$PM -build -p $PKGDEST/$SI_NAME.pkg -f $PKGROOT -r $RESOURCE_DIR -i $SI_INFO -d $SI_DESC || true"; - &run_command($command, "Error while building package $SI_NAME.pkg!"); -} - -# -# Include the MySQL Preference Pane -# -unless ($opt_skip_prefpane) -{ - &abort("Could not find PrefPane helper application. Did you compile and install it?") - unless (-f "$PREFPANE/Contents/Resources/mahelper"); - &logger("Including $PREFPANE in $PKGDEST"); - &run_command("mkdir $PKGDEST/MySQL.prefPane", "Could not create $PKGDEST/MySQL.prefPane!"); - &run_command("ditto $PREFPANE $PKGDEST/MySQL.prefPane", "Could not copy $PREFPANE into $PKGDEST!"); - &run_command("chown -R root:wheel $PKGDEST/MySQL.prefPane", "Cannot chown $PKGDEST/MySQL.prefPane!"); -} - -if ($opt_skip_dmg) -{ - &logger("SUCCESS: Package $PKGDEST/$NAME.pkg created"); - exit 0; -} - -# Determine the size of the Disk image to be created and add a 5% safety -# margin for filesystem overhead -&logger("Determining required disk image size for $PKGDEST"); -unless($opt_dry_run) -{ - chomp($_= `du -sk $PKGDEST`); - @size= split(); - $size= int($size[0]+($size[0]*0.05)); - &logger("Disk image size: $size KB"); -} - -unless($opt_dry_run) -{ - &abort("Zero bytes? Something is wrong here!") if ($size == 0); -} - -# Now create and mount the disk image -$TMPNAME= $NAME . ".tmp"; -&logger("Creating temporary Disk image $TMPNAME.dmg"); -$command= "hdiutil create $TMPNAME -size ${size}k -ov -fs UFS -volname $NAME"; -&run_command($command, "Unable to create disk image $TMPNAME.dmg!"); -&logger("Attaching Disk image $TMPNAME.dmg"); -&run_command("hdid $TMPNAME.dmg", "Unable to attach $TMPNAME.dmg!"); - -# Install the PKG into the .dmg -chomp($mountpoint=`mount | grep "\/Volumes\/$NAME" | cut -f3 -d" "`) if (!$opt_dry_run); -&logger("Copying $PKGDEST/$NAME.pkg to Disk image /Volumes/$NAME"); -&run_command("ditto $PKGDEST /Volumes/$NAME", "Could not copy $PKGDEST to /Volumes/$NAME!"); -&run_command("ditto $SUPFILEDIR/ReadMe.txt /Volumes/$NAME", "Could not copy $SPFILEDIR/ReadMe.txt to /Volumes/$NAME!"); -&run_command("chown root:wheel /Volumes/$NAME/ReadMe.txt", "Could not fix ownerships of /Volumes/$NAME/ReadMe.txt!"); -chomp($mountpoint=`mount | grep "\/Volumes\/$NAME" | cut -f1 -d" "`) if (!$opt_dry_run); -&abort("/Volumes/$NAME not attached!") if (!$mountpoint && !$opt_dry_run); -&logger("Unmounting $mountpoint"); -&run_command("hdiutil detach $mountpoint", "Unable to detach $mountpoint"); -&run_command("rm -f $NAME.dmg", "Unable to remove $NAME.dmg!") if (-f "$NAME.dmg"); -&logger("Compressing disk image"); -$command= "hdiutil convert $TMPNAME.dmg -format UDZO -imagekey zlib-level=9 -o $NAME.dmg"; -&run_command($command, "Unable to compress disk image!"); - -# Final cleanups -&logger("Removing $TMPNAME.dmg"); -&run_command("rm -f $TMPNAME.dmg", "Unable to remove $TMPNAME.dmg!"); -&logger("Removing $TMP"); -&run_command("rm -rf $TMP", "Unable to remove $TMP!"); - -&logger("SUCCESS: $NAME.dmg created.") if (!$opt_dry_run); -exit 0; - -sub print_help -{ - my $message= $_[0]; - if ($message ne "") - { - print "\n"; - print "ERROR: $message\n"; - } - print < --suffix= --version= - -Creates a Mac OS X installation package (PKG) and stores it inside -a Disk Image (.dmg) file. You need to create a binary distribution -tarball with scripts/make_binary_distribution first! - -NOTE: You need to run this script with root privileges (required - to create the disk image) - -Options: - - --dry-run Dry run without executing --h, --help Print this help --l, --log[=] Write a log file [to ] - (default is "$LOGFILE") --m, --mail=
Mail a failure report to the given - address (and include a log file snippet, - if logging is enabled) - Note that the \@-Sign needs to be quoted! - Example: --mail=user\\\@domain.com --p, --skip-prefpane Skip including the PreferencePane --s, --skip-disk-image, --skip-dmg Just build the PKGs, don't put it into a - disk image afterwards - --skip-startup-item, --skip-si Skip the creation of the StartupItem PKG - --suffix= The package suffix - (e.g. "-standard" or "-pro) - --version= The MySQL version number - (e.g. 4.0.11-gamma) --v, --verbose Verbose execution - -EOF - exit 1; -} diff --git a/Build-tools/Do-rpm b/Build-tools/Do-rpm deleted file mode 100755 index 23602debfb1..00000000000 --- a/Build-tools/Do-rpm +++ /dev/null @@ -1,332 +0,0 @@ -#!/usr/bin/perl -w -# -# Do-rpm - compile RPM packages out of a source tarball and move the -# resulting RPM packages into the current directory. -# -# The script currently assumes the following environment: -# -# - there must be a source distribution (mysql-.tar.gz) -# in the current directory -# - You must provide the name of an RPM spec file (mysql-.spec) -# as the argument -# -# Use the "--help" option for more info! -# -# written by Lenz Grimmer -# - -use Cwd; -use File::Basename; -use File::Copy; -use Getopt::Long; -Getopt::Long::Configure ("bundling"); -use Sys::Hostname; - -$opt_cc= undef; -$opt_cflags= undef; -$opt_clean= undef; -$opt_cxx= undef; -$opt_cxxflags= undef; -$opt_dry_run= undef; -$opt_help= undef; -$opt_log= undef; -$opt_mail= ""; -$opt_verbose= undef; -$opt_susebuild= undef; -$opt_susebuildroot= undef; -$opt_suserpms= undef; - -# Set a dummy version until we know the correct one -$VERSION= "x.y.z"; -$MAJOR= $MINOR= $RELEASE= 0; -$SUFFIX= ""; - -GetOptions( - "cc=s", - "cflags=s", - "clean|c", - "cxx=s", - "cxxflags=s", - "dry-run|t", - "help|h", - "log|l:s", - "mail|m=s", - "susebuild|s", - "susebuildroot|r=s", - "suserpms=s", - "verbose|v", -) || &print_help; - -&print_help("") if ($opt_help); - -defined($SPECFILE=$ARGV[0]) || print_help("Please provide the spec file name!"); - -&print_help("Please define the location of the RPM repository!") if $opt_susebuild && !($opt_suserpms || $ENV{BUILD_RPMS}); - -unless ($opt_susebuildroot) -{ - if ($ENV{BUILD_ROOT}) - { - $opt_susebuildroot= $ENV{BUILD_ROOT}; - } - else - { - $opt_susebuildroot="/var/tmp/build-root"; - } -} - -# Include helper functions -$PWD= cwd(); -$LOGGER= "$PWD/logger.pm"; -if (-f "$LOGGER") -{ - do "$LOGGER"; -} -else -{ - die "ERROR: $LOGGER cannot be found!\n"; -} - -$subject= "RPM build for $SPECFILE failed" if $opt_mail; - -# Open the spec file and extract the version number -open(SPEC, $SPECFILE) or die "Unable to open \"$ARGV[0]\": $!"; -@spec= ; -close SPEC; - -foreach (@spec) -{ - if (m/^%define\s*mysql_version\s*(.*)/) - { - $VERSION= $1; - $VERSION_SRPM=$VERSION; - ($MAJOR, $MINOR, $RELEASE)= split(/\./,$VERSION); - $VERSION_SRPM= $MAJOR . '.' . $MINOR . '.' . $RELEASE; - $VERSION_SRPM =~ s/\-\w+$//; - ($RELEASE, $SUFFIX)= split(/\-/,$RELEASE); - $SUFFIX= "-" . $SUFFIX if ($SUFFIX); - } -} - -$HOST= hostname(); -$HOST=~ /^([^.-]*)/; -$HOST= $1; -$LOGFILE= "$PWD/Logs/Do-rpm-$HOST-$MAJOR.$MINOR.log"; -&logger("Logging to $LOGFILE"); - -# -# Override predefined Log file name -# -if (defined $opt_log) -{ - if ($opt_log ne "") - { - if ($opt_log =~ /^\/.*/) - { - $LOGFILE= $opt_log; - } - else - { - $LOGFILE= $PWD . "/" . $opt_log; - } - } -} - -&logger("Using spec file for version: $VERSION"); - -if ($opt_susebuild) -{ - &susebuild; -} -else -{ - &rpmbuild; -} - -&logger("SUCCESS: RPM files successfully created.") unless ($opt_dry_run); -exit 0; - -# -# Build using SUSE's "build" script -# -sub susebuild -{ - $BUILD= "/usr/bin/build"; - ( -x $BUILD) ? &logger("$BUILD found, proceeding.") : &abort("$BUILD could not be found!"); - $command= "sudo $BUILD --clean"; - $command.= " --root=$opt_susebuildroot"; - $command.= " --rpms=$opt_suserpms" if $opt_suserpms; - $command.= " $SPECFILE"; - &logger("Building RPMs using SUSE build."); - &run_command($command, "Error while running the SUSE RPM build!"); - - # - # Move the resulting RPMs into the pwd - we can use broad globs here - # as the build root has been cleaned up before so there should not be - # any residuals from previous build runs - # - $command= "cp"; - $command.= " -v " if ($opt_verbose); - $command.= " $opt_susebuildroot/usr/src/packages/SRPMS/MySQL*.src.rpm $PWD"; - &logger("Copying source RPM to current dir."); - &run_command($command, "Error moving source RPM!"); - - $command= "cp"; - $command.= " -v " if ($opt_verbose); - $command.= " $opt_susebuildroot/usr/src/packages/RPMS/*/MySQL*.rpm $PWD"; - &logger("Copying binary RPMs to current dir."); - &run_command($command, "Error moving binary RPMs!"); -} - -# -# Build using "plain" RPM -# -sub rpmbuild -{ - - # - # Newer RPM versions ship with a separate tool "rpmbuild" to build RPMs - # - if (-x "/usr/bin/rpmbuild") - { - $RPM= "/usr/bin/rpmbuild"; - $RMSOURCE= "--rmsource --rmspec"; - } - else - { - $RPM= "/bin/rpm"; - $RMSOURCE= "--rmspec"; - } - - if ($RPM) - { - &logger("Found rpm binary: $RPM"); - } - else - { - &abort("Unable to find RPM binary!"); - } - - # - # determine some RPM settings for this host - # - chomp($RPMARCH= `$RPM --eval "%{_arch}" 2> /dev/null`); - chomp($RPMDIR= `$RPM --eval "%{_rpmdir}" 2> /dev/null`); - chomp($SOURCEDIR= `$RPM --eval "%{_sourcedir}" 2> /dev/null`); - chomp($SPECDIR= `$RPM --eval "%{_specdir}" 2> /dev/null`); - chomp($SRCRPMDIR= `$RPM --eval "%{_srcrpmdir}" 2> /dev/null`); - - $SOURCEFILE= glob "mysql*-$VERSION.tar.gz"; - - &logger("Starting RPM build of MySQL-$VERSION on $HOST"); - - foreach $file ($SOURCEFILE, $SPECFILE) - { - &abort("Unable to find $file!") unless (-f "$file"); - } - - # - # Install source and spec file - # - &logger("Copying SOURCE and SPEC file to build directories."); - unless ($opt_dry_run) - { - copy($SOURCEFILE, $SOURCEDIR) - or &abort("Unable to copy $SOURCEFILE to $SOURCEDIR!"); - copy($SPECFILE, $SPECDIR) - or &abort("Unable to copy $SPECFILE to $SPECDIR!"); - } - - # - # Set environment variables - these are being used in the - # official MySQL RPM spec file - # - &logger("Setting special build environment variables") - if ($opt_cc) or ($opt_cflags) or ($opt_cxxflags) or ($opt_cxx); - $ENV{MYSQL_BUILD_CC}=$opt_cc if ($opt_cc); - $ENV{MYSQL_BUILD_CFLAGS}=$opt_cflags if ($opt_cflags); - $ENV{MYSQL_BUILD_CXXFLAGS}=$opt_cxxflags if ($opt_cxxflags); - $ENV{MYSQL_BUILD_CXX}=$opt_cxx if ($opt_cxx); - - # - # Build the RPMs - # - $command= "$RPM"; - $command.= " -v" if ($opt_verbose); - $command.= " -ba"; - $command.= " --clean $RMSOURCE" if $opt_clean; - $command.= " $SPECDIR/"; - $command.= basename($SPECFILE); - &logger("Building RPM."); - &run_command($command, "Error while building the RPMs!"); - - # - # Move the resulting RPMs into the pwd - # - $command= "mv"; - $command.= " -v " if ($opt_verbose); - $command.= " $SRCRPMDIR/MySQL*$VERSION_SRPM*.src.rpm $PWD"; - &logger("Moving source RPM to current dir."); - &run_command($command, "Error moving source RPM!"); - - $command= "mv"; - $command.= " -v " if ($opt_verbose); - $command.= " $RPMDIR/$RPMARCH/MySQL*$VERSION_SRPM*.$RPMARCH.rpm $PWD"; - &logger("Moving binary RPMs to current dir."); - &run_command($command, "Error moving binary RPMs!"); -} - -sub print_help -{ - my $message= $_[0]; - if ($message ne "") - { - print "\n"; - print "ERROR: $message\n\n"; - } - print < - -Creates a binary RPM package out of a MySQL source distribution and moves -the resulting RPMs into the current directory. is the MySQL RPM -spec file to use (e.g. mysql-4.0.17.spec). - -This script expects to find the required MySQL source distribution -(mysql-.tar.gz) in the current directory. - -Options: - - --cc= Use to compile C code - --ccflags= Use special C compiler flags - --cxx= Use to compile C++ code - --cxxflags= Use special C++ compiler flags --c, --clean Clean up after the build --t, --dry-run Dry run without executing --h, --help Print this help --l, --log[=] Write a log file [to ] --m, --mail=
Mail a failure report to the given address - (and include a log file snippet, if logging - is enabled) - Note that the \@-Sign needs to be quoted! - Example: --mail=user\\\@domain.com --s, --susebuild Use the SUSE "build" script instead of RPM - directly (requires sudo privileges to run the - /usr/bin/build command) --r, --susebuildroot= Use as the build root directory for the - SUSE "build" (default is /var/tmp/build-root - or defined by the BUILD_ROOT environment - variable) ---suserpms= Path to the SUSE RPM repository to build up - the build root (mandatory option when using - --susebuild and the BUILD_RPMS environment - variable is not set.) --v, --verbose Verbose execution - -Example: - - Do-rpm -cv mysql-4.0.17.spec - -EOF - exit 1; -} diff --git a/Build-tools/Do-solaris-pkg b/Build-tools/Do-solaris-pkg deleted file mode 100644 index 22d68793808..00000000000 --- a/Build-tools/Do-solaris-pkg +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/perl -# -# Script to create Solaris packages -# -$INTERACTIVE= 0; -chomp ($hostname= `hostname`); -$find = "/usr/bin/find"; -$pkgproto = "/usr/bin/pkgproto"; -$pkgmk = "/usr/bin/pkgmk -o"; -$pkgtrans = "/usr/bin/pkgtrans"; -$temp = "/tmp/prototype$$"; -$prototype = "prototype"; -$pkginfo = "pkginfo"; -($gid ,$pkg ,$uid ,$userInfo ,$email ,$quota ,$group ,$passwd -,$category ,$userHome ,$vendor ,$loginShell ,$pstamp ,$basedir)=(); - -$tarball= $fullname= shift @ARGV; -$fullname=~ s/.*(mysql.*)\.tar\.gz/$1/; -$workdir= $$; -chomp ($parent_workdir= `pwd`); - -$hostname= ($fullname=~ m/^.+-64bit$/) ? $hostname . "-64bit" : $hostname; -$pkgdir= "$ENV{'HOME'}/$hostname"; - -mkdir $workdir or die "Can't make workdir: $!\n"; -chdir $workdir or die "Can't change to workdir: $!\n"; -system ("tar xzvf $tarball") == 0 or die "Can't untar: $!\n"; - -system ("$find . -print | $pkgproto > $temp"); -open (PREPROTO,"<$temp") or die "Unable to read prototype information ($!)\n"; -open (PROTO,">$prototype") or die "Unable to write file prototype ($!)\n"; -print PROTO "i pkginfo=./$pkginfo\n"; -while () { - # Read the prototype information from /tmp/prototype$$ - chomp; - $thisline = $_; - if ($thisline =~ " prototype " - or $thisline =~ " pkginfo ") { - # We don't need that line - } elsif ($thisline =~ "^[fd] ") { - # Change the ownership for files and directories - ($dir, $none, $file, $mode, $user, $group) = split / /,$thisline; - print PROTO "$dir $none $file $mode bin bin\n"; - } else { - # Symlinks and other stuff should be printed as well ofcourse - print PROTO "$thisline\n"; - } -} -close PROTO; -close PREPROTO; - -# Clean up -unlink $temp or warn "Unable to remove tempfile ($!)\n"; - -# Now we can start building the package -# -# First get some info -$fullname =~ s,/+$,,; # Remove ending slash if any - -$fullname =~ /^((mysql)(?:-\w+){1,3})-([\d\.]+\w?)-.+$/ - or die "This name is not what I expected - \"$fullname\""; - -$default{"name"}= $2; -$default{"version"}= $3; -$default{"pkg"}= $1; -$default{"arch"} = `uname -m`; -chomp $default{"arch"}; -$default{"category"}= "application"; -$default{"vendor"}= "MySQL AB"; -$default{"email"}= "build\@mysql.com"; -$default{"pstamp"}= "MySQL AB Build Engineers"; -$os = `uname -r`; -$os =~ '\.'; -$os = "sol$'"; -chomp $os; -$default{"basedir"}= "/usr/local"; -$default{"packagename"}= "${fullname}.pkg"; - -# Check for correctness of guessed values by userinput - -%questions = ( - pkg => "Please give the name for this package", - name => "Now enter the real name for this package", - arch => "What architecture did you build the package on?", - version => "Enter the version number of the package", - category => "What category does this package belong to?", - vendor => "Who is the vendor of this package?", - email => "Enter the email adress for contact", - pstamp => "Enter your own name", - basedir => "What is the basedir this package will install into?", - packagename => "How should I call the packagefile?", -); - -@vars = qw(pkg name arch version category vendor email pstamp basedir - packagename); -foreach $varname (@vars) { - getvar_noq($varname); -} - -if ($INTERACTIVE) { - while (!&chkvar()) { - print "\n"; - foreach $varname (@vars) { - getvar($varname); - } - @vars = qw(pkg name arch version category vendor email pstamp basedir - packagename); - } -} -$classes = "none"; - -# Create the pkginfo file - -print "\nNow creating $pkginfo file\n"; -open (PKGINFO,">$pkginfo") || die "Unable to open $pkginfo for writing ($!)\n"; -print PKGINFO "PKG=\"$pkg\"\n"; -print PKGINFO "NAME=\"$name\"\n"; -print PKGINFO "ARCH=\"$arch\"\n"; -print PKGINFO "VERSION=\"$version\"\n"; -print PKGINFO "CATEGORY=\"$category\"\n"; -print PKGINFO "VENDOR=\"$vendor\"\n"; -print PKGINFO "EMAIL=\"$email\"\n"; -print PKGINFO "PSTAMP=\"$pstamp\"\n"; -print PKGINFO "BASEDIR=\"$basedir\"\n"; -print PKGINFO "CLASSES=\"$classes\"\n"; -close PKGINFO; -print "Done.\n"; - -# Build and zip the package - -print "Building package\n"; -system ("$pkgmk -r `pwd`"); -system ("(cd /var/spool/pkg; $pkgtrans -s -o `pwd` /tmp/$packagename $pkg)"); -system ("gzip /tmp/$packagename"); - -# Clean-up the spool area -system ("(cd /var/spool/pkg; rm -rf $pkg)"); -# Clean-up the ~/packaging/ area -unlink $pkginfo; -unlink $prototype; -chdir $parent_workdir or die "Can't change to parent workdir '$parent_workdir': $!\n"; -system ("rm -rf $workdir") == 0 or die "Can't remove the working dir: $!\n"; -system ("mv /tmp/${packagename}.gz $pkgdir") == 0 or die "Can't move the finished package out of /tmp: $!\n"; -print "Done. (~/$hostname/$packagename.gz)\n"; -# The subroutines -sub chkvar { - print "\n"; - - print "PKG=$pkg\n"; - print "NAME=$name\n"; - print "ARCH=$arch\n"; - print "VERSION=$version\n"; - print "CATEGORY=$category\n"; - print "VENDOR=$vendor\n"; - print "EMAIL=$email\n"; - print "PSTAMP=$pstamp\n"; - print "BASEDIR=$basedir\n"; - print "PACKAGENAME=$packagename\n"; - - - print "\nIs this information correct? [Y/n]: "; - my $answer= ; - chomp $answer; - $answer= 'Y' if ($answer eq ""); - $answer= uc $answer; - my $res= ($answer eq 'Y')? 1 : 0; - return($res); -} - -sub getvar_noq { - my $questionname = "@_"; - $$questionname = $default{$questionname}; -} - -sub getvar { - my $questionname = "@_"; - my $ucquestionname= uc $questionname; - print "$ucquestionname: $questions{$questionname} [$default{\"$questionname\"}]: "; - my $answer = ; - chomp $answer; - $$questionname = $answer; - $$questionname = $default{$questionname} if ($$questionname eq ""); -} diff --git a/Build-tools/Do-win-build b/Build-tools/Do-win-build deleted file mode 100755 index a78b091a737..00000000000 --- a/Build-tools/Do-win-build +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/perl -w - -use Getopt::Long; - -$opt_help=0; -$opt_tarball=$opt_builddir=$opt_suffix=""; - -GetOptions( - "help", - "tarball=s", - "builddir=s", - "suffix=s" -) || print_help(); - -print_help() if ($opt_help); - -chomp($MSDEV=`which msdev`); - -if (!$opt_builddir) { - $opt_builddir = "/cygdrive/c/mysql-win-build"; -} - -$opt_tarball =~ /(mysql[^\/]*)-win-src\.tar/; -$mysqlver=$1; -$basedir = "$opt_builddir/$mysqlver"; -$scriptdir = `pwd`; - -# Make sure build dir exists -mkdir($opt_builddir); -# Clean out any previous build -system("rm -rf $basedir"); - -# Unpack in the script directory -system("tar -zxvf $opt_tarball"); -# Move to the build directory -system("mv $mysqlver $opt_builddir"); - -if (!chdir($basedir)) -{ - print "Do-win-build error: Could not change to $basedir"; - exit 1; -} - -# Check whether this is a classic edition build -if ($opt_suffix =~ /-classic/) -{ - # Blank out ha_innodb.cpp - chmod 0644, 'sql/ha_innodb.cpp'; - open(OUT, '>', 'sql/ha_innodb.cpp'); - close(OUT); - - # Remove HAVE_INNOBASE_DB from the requisite project files - for $dspfile ('libmysqld/libmysqld.dsp', 'mysqldemb/mysqldemb.dsp', 'mysqlserver/mysqlserver.dsp', 'sql/mysqld.dsp', 'sql/mysqldmax.dsp') - { - open(IN, '<', $dspfile); - open(OUT, '>', "$dspfile.tmp"); - while (readline IN) - { - s/\D \"HAVE_INNOBASE_DB\" //g; - print OUT $_; - } - close(IN); - close(OUT); - unlink $dspfile; - rename "$dspfile.tmp", $dspfile; - } -} - -# Perform compilation -system("\"$MSDEV\" mysql.dsw /MAKE \"ALL\" /OUT $mysqlver-build.log"); - -# Package binary -system("./scripts/make_win_binary_distribution --suffix=$opt_suffix"); - -# Copy log back to script directory -system("cp $mysqlver$suffix-build.log $scriptdir"); - -# Move binary package to script directory -system("mv *.zip $scriptdir"); - -# -# Print a help text message -# -sub print_help -{ - print < -Set the Cygwin path to build under; the tarball will actually -be moved to /mysql-/tarball and extracted under -/mysql-/build. -Default: /cygdrive/c/mysql-win-build - ---suffix= -If specified, the resulting binary will have the specified suffix -in its name. If the suffix is "-classic", the project files will -be stripped of all occurrences of HAVE_INNOBASE_DB and -ha_innodb.cpp will be blanked out, to create classic edition -server binaries. - ---tarball= -Windows source tarball to use for this build. Must be of the form -mysql[com]-x.x.x-win-src.tar.gz (REQUIRED) - -EOF - exit 1; -} diff --git a/Build-tools/cvs-sanity-check b/Build-tools/cvs-sanity-check deleted file mode 100755 index b3d57e98033..00000000000 --- a/Build-tools/cvs-sanity-check +++ /dev/null @@ -1,15 +0,0 @@ -#! /bin/sh - -CVSROOT=my@work.mysql.com:/home/cvs -CVS_RSH=ssh -TMPDIR=/tmp -cd $TMPDIR -[ -d mysql ] && rm -rf mysql -CVSROOT=$CVSROOT CVS_RSH=$CVS_RSH cvs -z 9 co mysql && cd mysql && \ - chmod u+w -R * && BUILD/compile-pentium -if test $? = 0 -then -cd $TMPDIR && rm -rf mysql -fi - - diff --git a/Build-tools/logger.pm b/Build-tools/logger.pm deleted file mode 100644 index d3fb4c9db2f..00000000000 --- a/Build-tools/logger.pm +++ /dev/null @@ -1,112 +0,0 @@ -# Helper functions - -# -# Create a log entry -# -sub logger -{ - my $message= $_[0]; - my $cmnd= $_[1]; - - print $message . "\n" if !$opt_quiet && !$opt_verbose && !$cmnd; - print timestamp() . " " . $message . "\n" if $opt_verbose; - if (defined $opt_log && !$opt_dry_run) - { - open LOG, ">>$LOGFILE" or die "Can't open logfile $LOGFILE!"; - print LOG timestamp() . " " . $message . "\n"; - close LOG; - } -} - -# -# run_command(,) -# Execute the given command or die with the respective error message -# Just print out the command when doing a dry run -# -sub run_command -{ - my $command= $_[0]; - my $errormsg= $_[1]; - if ($opt_dry_run) - { - print "$command\n"; - } - else - { - &logger($command, 1); - - $command.= ';' unless ($command =~ m/^.*;$/); - - $command =~ s/;/ >> $LOGFILE 2>&1;/g if defined $opt_log; - $command =~ s/;/ > \/dev\/null;/g if (!$opt_verbose && !$opt_log); - system($command) == 0 or &abort("$errormsg\n"); - } -} - -# -# abort() -# Exit with giving out the given error message or by sending -# it via email to the given mail address (including a log file snippet, -# if available) -# -sub abort -{ - my $message= $_[0]; - my $messagefile; - my $subject= "Bootstrap of $REPO failed" if $opt_mail; - $message= "ERROR: " . $message; - &logger($message); - - if ($opt_mail && !$opt_dry_run) - { - $messagefile= "/tmp/message.$$"; - open(TMP,">$messagefile"); - print TMP "$message\n\n"; - close TMP; - if (defined $opt_log) - { - system("tail -n 40 $LOGFILE >> $messagefile"); - } - system("mail -s \"$subject\" $opt_mail < $messagefile"); - unlink($messagefile); - } - - exit 1; -} - -# Create a time stamp for logging purposes -sub timestamp -{ - return &ymd() . " " . &hms(); -} - -# -# return the current time as a string (HH:MM:SS) -# -sub hms -{ - my @ta= localtime(time()); - my $h= $ta[2]; - $h= "0" . "$h" if ($h <= 9); - my $m= $ta[1]; - $m= "0" . "$m" if ($m <= 9); - my $s= $ta[0]; - $s="0" . "$s" if ($s <= 9); - - return "$h:$m:$s"; -} - -# -# return the current date as a string (YYYYMMDD) -# -sub ymd -{ - my @ta=localtime(time()); - my $d=$ta[3]; - $d="0" . "$d" if ($d <= 9); - my $m=$ta[4]+1; - $m="0" . "$m" if ($m <= 9); - my $y=1900+$ta[5]; - - return "$y$m$d"; -} diff --git a/Build-tools/my_md5sum b/Build-tools/my_md5sum deleted file mode 100755 index f4ac2f7d674..00000000000 --- a/Build-tools/my_md5sum +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/perl -# -# my_md5sum -# -# Script to clone the 'md5sum' command found on modern systems, since that -# command is not always found on all systems. -# -# Use the "--help" option for more info! -# -# Written by Matt Wagner -# -use strict; - -# -# Use local perl libraries first. 'unshift' adds to the front of @INC -# The local perl library dir hidden is $HOME/.perllibs on each build host -# -BEGIN -{ - my $homedir= $ENV{HOME}; - unshift (@INC, "$homedir/.perllibs"); -} - -use Digest::MD5; -use Getopt::Long; - -my $VER= "1.3"; -my $EXIT= 0; - -# -# Strip the leading path info off the program name ($0). We want 'my_md5sum' -# not './my_md5sum'. -# -$0=~ s/^.*\/(.+)$/$1/; - -my ($opt_check, $opt_help)= undef; - -GetOptions( - "check|c" => \$opt_check, - "help|h" => \$opt_help, - ) || usage(); - -# -# Put all the [file1 file2 file3 ...]'s into an array -# -my @files = @ARGV; - -# -# Give the "--help" text if: -# - "--help|-h" was specified -# - The number of files given as arguments is nil -# - The "--check|-c" option is used with more than one [file] argument -# -usage() if $opt_help || $#files == -1 || ($opt_check && $#files > 0); - -# If "--check|-c", then go into checking -if ($opt_check) -{ - open (CHECKFILE, $files[0]) or die "$files[0]: $!"; - - while () - { - # - # Goto the next line in the file if it does not match a typical - # digest line like: - # - # f1007efa2c72daa693981ec764cdeaca Bootstrap - # - next if $_!~ m/^([a-z0-9]{32})\s+(.+)$/; - - # Collect the trappings from the above regex - my $checksum= $1; - my $checkfile= $2; - - # Generate a fresh MD5 for the file in question - my $digest= &mkmd5($checkfile); - - # Check the fresh MD5 against what is recorded in the file - # Print an error message if they don't match, else print OK - print "$checkfile: FAILED\n" if $digest ne $checksum; - print "$checkfile: OK\n" if $digest eq $checksum; - - # Set the exit() status to non-zero if FAILED - $EXIT= 1 if $digest ne $checksum; - } -} -# Else generate the MD5 digest to STDOUT -else -{ - foreach my $file (@files) - { - my $digest= &mkmd5($file); - - print "$digest $file\n"; - } -} - -exit($EXIT); - - -# -# This routine generates the MD5 digest of a file -# -sub mkmd5 -{ - my $file= shift; - - open (FILE, $file) or die "$file: $!"; - binmode(FILE); - - my $digest= Digest::MD5->new->addfile(*FILE)->hexdigest; - - close FILE; - - return $digest; -} - -# -# Print the help text -# -sub usage -{ - print < - -Usage: -$0 [-c [file]] | [file1...] -Generates or checks MD5 message digests. - -Options: --c, --check Check message digests (default is generate) --h, --help Display this text and exit - -The input for -c should be the list of message digests and file names that is -printed on STDOUT by this program when it generates digests. - -EOF - - exit(0); -} diff --git a/Build-tools/mysql-copyright b/Build-tools/mysql-copyright deleted file mode 100755 index 81d6d761498..00000000000 --- a/Build-tools/mysql-copyright +++ /dev/null @@ -1,372 +0,0 @@ -#!/usr/bin/perl -wi - -# Untar a MySQL distribution, change the copyright texts, -# pack it up again to a given directory - -$VER="1.5"; - -use Cwd; -use File::Basename; -use File::Copy; -use Getopt::Long; - -$opt_help = 0; -$opt_version = 0; -$opt_verbose = 0; -$opt_target = "mysql-copyright-target-"; -$opt_target .= `date +%d%m%y-%H%M%S`; -chop $opt_target; - -GetOptions("help","version","target=s", "verbose") || error(); - -# fix the directory prefix for target dir - -$WD= cwd(); -my $win_flag = 0; -$opt_target= $WD . '/' . $opt_target; - -&main(); - -#### -#### main -#### - -sub main -{ - my $REG_BASENAME = '[a-z0-9A-Z\-\_\+]+'; - my $REG_VERSION = '[0-9\.\-]+[a-z]?[0-9\.\-]+?(.alpha|.beta|.gamma|pre\d|[0-9\.\-a-z])?'; - my $target; - - if ($opt_version) - { - print "$0 version $VER by Jani Tolonen\n"; - exit(0); - } - usage() if ($opt_help); - print error() if ($#ARGV == -1); - - `mkdir -p $opt_target`; - $pec= $? >> 8; - die "Couldn't make the target directory!\n" if ($pec); - - for ($i=0; $ARGV[$i]; $i++) - { - my $distfile= $ARGV[$i]; - $win_flag = ($distfile =~ /win-src/) ? 1 : 0; - my $dir; - - $dir= "mysql-copyright-"; - $dir.= `date +%d%m%y-%H%M%S`; - chop $dir; - - if (!(mkdir "$dir", 0700)) - { - die "Couldn't make directory $dir!"; - } - if (!(chdir "$dir")) - { - abort($dir, "Couldn't cd to $dir!"); - } - # if the distfile is mysql-3.22.22-alpha.tar.gz, then - # distname is 'mysql-3.22.22-alpha' and suffix '.tar.gz' - if ($distfile =~ - m/^($REG_BASENAME)([\-\_])($REG_VERSION){1}([\.\-\+]\w+\-\w+)?[\.\-\+](.*)?$/xo) - { - $distname= $1.$2.$3; - $suffix= $5; - $fileext = $6; - $newdistname= $1."com".$2.$3; - $newdistname .= $suffix if $win_flag; - } - # find out the extract path (should be same as distname!) - chomp($destdir= `tar ztf ../$distfile | head -1`); - # remove slash from the end - $destdir= substr($destdir, 0, -1); - - if ("$destdir" ne "$distname") - { - print "Destination directory (the directory that will be extracted\n"; - print "from the original distribution file) differs from the\n"; - print "distribution name! Are you sure you want to continue? (Y/N) [N]:"; - $ans= my_read(1); - abort($dir, "Aborted!") if ("$ans" ne "Y" && "$ans" ne "y"); - } - - # everything should be ok, continue with extracting.. - `tar xfz ../$distfile`; - $pec= $? >> 8; - abort($dir, "Extracting from tar failed!\n") if ($pec); - - # remove the 'PUBLIC' file from distribution and copy MySQLEULA.txt - # on the toplevel of the directory instead. file 'PUBLIC' shouldn't - # exist in the new mysql distributions, but let's be sure.. - unlink("$destdir/PUBLIC", "$destdir/README"); - unlink("$destdir/COPYING", "$destdir/EXCEPTIONS-CLIENT"); - copy("$WD/Docs/MySQLEULA.txt", "$destdir"); - - # remove subdirectories 'bdb', 'cmd-line-utils/readline' - my @extra_fat= ('bdb', 'cmd-line-utils/readline'); - - foreach my $fat (@extra_fat) - { - &trim_the_fat($fat); - } - - # fix file copyrights - &fix_usage_copyright(); - &add_copyright(); - - # fix LICENSE tag in include/mysql_version.h - &fix_mysql_version(); - - # apply "autotools" - must be last to ensure proper timestamps - &run_autotools(); - - # rename the directory with new distribution name - chdir("$WD/$dir"); - print "renaming $destdir $newdistname\n" if $opt_verbose; - rename($destdir, $newdistname); - - # tar the new distribution - `tar cz -f $WD/$newdistname.tar.gz $newdistname`; - $pec= $? >> 8; - abort($dir, "Making new tar archive failed!\n") if ($pec); - - # remove temporary directory - chdir($WD) or print "$! Unable to move up one dir\n"; - my $cwd = getcwd(); - print "current dir is $cwd\n" if $opt_verbose ; - if (-e $dir) { - print "Trying to delete $dir\n" if $opt_verbose; - if ( system("rm -rf $dir")){ - print "$! Unable to delete $dir!\n"; - } - } - } - exit(0); -} - -#### -#### This function will s/GPL/Commercial/ in include/mysql_version.h for the -#### LICENSE tag. -#### -sub fix_mysql_version -{ - my $cwd= getcwd(); - chdir("$destdir"); - my $header_file= (-f 'include/mysql_version.h.in')? 'include/mysql_version.h.in' : 'include/mysql_version.h'; - - open(MYSQL_VERSION,"<$header_file") or die "Unable to open $header_file for read: $!\n"; - undef $/; - my $mysql_version= ; - close(MYSQL_VERSION); - - $mysql_version=~ s/\#define LICENSE[\s\t]+GPL/#define LICENSE Commercial/; - - open(MYSQL_VERSION,">$header_file") or die "Unable to open $header_file for write: $!\n"; - print MYSQL_VERSION $mysql_version; - close(MYSQL_VERSION); - chdir("$cwd"); -} - -#### -#### This function will remove unwanted parts of a src tree for the mysqlcom -#### distributions. -#### - -sub trim_the_fat -{ - my $the_fat= shift; - my $cwd= getcwd(); - - chdir("$destdir"); - if ( -d "${the_fat}" ) - { - system("rm -rf ${the_fat}"); - if (!$win_flag) - { - open(CONFIG_IN,"; - close(CONFIG_IN); - - # - # If $the_fat Makefile line closes the parenthesis, then - # replace that line with just the closing parenthesis. - # - if ($config_in=~ m|${the_fat}/Makefile\)\n?|) - { - $config_in=~ s|${the_fat}/Makefile(\)\n?)|$1|; - } - # - # Else just delete the line - # - else - { - $config_in=~ s|${the_fat}/Makefile dnl\n?||; - } - - open(CONFIG_IN,">configure.in") or die "Unable to open configure.in for write: $!\n"; - print CONFIG_IN $config_in; - close(CONFIG_IN); - } - } - chdir("$cwd"); -} - - -#### -#### This function will run the autotools on the reduced source tree. -#### - -sub run_autotools -{ - my $cwd= getcwd(); - - if (!$win_flag) - { - chdir("$destdir"); - unlink ("configure") or die "Can't delete $destdir/configure: $!\n"; - - # File "configure.in" has already been modified by "trim_the_fat()" - - # It must be ensured that the timestamps of the relevant files are really - # ascending, for otherwise the Makefile may cause a re-run of these - # autotools. Experience shows that deletion is the only safe way. - unlink ("config.h.in") or die "Can't delete $destdir/config.h.in: $!\n"; - unlink ("aclocal.m4") or die "Can't delete $destdir/aclocal.m4: $!\n"; - - # These sleep commands also ensure the ascending order. - `aclocal && sleep 2 && autoheader && sleep 2 && automake && sleep 2 && autoconf`; - die "'./configure' was not produced!" unless (-f "configure"); - - if (-d "autom4te.cache") { - print "Trying to delete autom4te.cache dir\n" if $opt_verbose; - system("rm -rf autom4te.cache") or print "Unable to delete autom4te.cache dir: $!\n"; - } - - chdir("$cwd"); - } -} - - -#### -#### mysqld and MySQL client programs have a usage printed with --help. -#### This usage includes a copyright, which needs to be modified -#### -sub fix_usage_copyright -{ - my $findlist = `find . -type f -name \"*.c*\"`; - my @files = split("\n", $findlist); - my $cwd = getcwd(); - - foreach my $file (@files) - { - next if ! -f $file; - print "processing file $file in cwd $cwd\n" if $opt_verbose; - `replace "This is free software," "This is commercial software," "and you are welcome to modify and redistribute it under the GPL license" "please see the file MySQLEULA.txt for details" -- "$file"` ; - } -} - -#### -#### change the copyright text in the beginning of the files -#### - -sub add_copyright -{ - my $findlist = `find . -type f -name "*"`; - my @files = split("\n", $findlist); - my $cwd = getcwd(); - - foreach my $file (@files) - { - next if ! -f $file; - next if -B $file; - print "processing file $file in cwd $cwd\n" if $opt_verbose; - `$WD/Build-tools/mysql-copyright-2 "$file"`; - } -} - -#### -#### read stdin -#### - -sub my_read -{ - ($length)= @_; # Max allowed length for the string. - - $input= getc(STDIN); - if($input eq "\n") - { - return "\n"; - } - for($new_input= getc(STDIN); $new_input ne "\n" ;) - { - if(length($input) < $length) - { - $input.= $new_input; - } - $new_input= getc(STDIN); - } - return $input; -} - -#### -#### abort -#### - -sub abort -{ - my ($dir, $errstr)= @_; - # remove newly made directory and it's contents - print "$errstr\n"; - chdir ".."; - print "Removing directory $dir...\n"; - `rm -rf $dir`; - exit(0); -} - -#### -#### usage -#### - -sub usage -{ - print < -mysqlcom-3.23.18-beta.tar.gz. DATE is of form DDMMYY-HHMMSS. The -target directory can be changed with option ---target=... mysql-copyright consists of two perl programs, this one -and another, mysql-copyright-2. Make sure the second part of the -script is available to the main script. - -Usage: -$0 [options] file1 [file2 file3...] - -Options: ---help Show this help and exit. ---target Target directory for new distribution files. - '.' can be used for the current directory. - (Default: $opt_target) -EOF - exit(0); -} - -#### -#### error -#### - -sub error -{ - if ($#ARGV == -1) - { - print "Too few arguments to $0!\n"; - } - exit(1); -} diff --git a/Build-tools/mysql-copyright-2 b/Build-tools/mysql-copyright-2 deleted file mode 100755 index 972d5483d54..00000000000 --- a/Build-tools/mysql-copyright-2 +++ /dev/null @@ -1,175 +0,0 @@ -#!/usr/bin/perl -i - -# Add the header to all given files -# This program asumes that after the copyright there is a empty line -# - -$opt_v= 0; -require "getopts.pl"; -Getopts("v") || die "Aborted"; - -@copyright= -( - "Copyright (C) 2000 MySQL AB & MySQL Finland AB", - "", - "This software is distributed with NO WARRANTY OF ANY KIND. No author or", - "distributor accepts any responsibility for the consequences of using it, or", - "for whether it serves any particular purpose or works at all, unless he or", - "she says so in writing. Refer to the MySQLEULA.txt file for details.", - "", - "Every copy of this file must include a copy of the License, normally in a", - "plain ASCII text file named MySQLEULA.txt. The License grants you the right to", - "copy, modify and redistribute this file, but only under certain conditions", - "described in the License. Among other things, the License requires that", - "the copyright notice and this notice be preserved on all copies" -); - -while (<>) -{ - if (!$first++) - { - add_copyright($_); - } - if ($in_copyright) - { - $in_copyright=check_in_copyright($_); - } - print $_ if (!$in_copyright); - if (eof) - { - $first=0; $in_copyright=1; - } -} - -exit 0; - -sub add_copyright -{ - my ($line)=@_; - my ($row); - - $in_copyright= $line =~ /copyright/i; - $found_end_copyright=$skip_this_line=0; - - if (!($line =~ /Monty/ || $line =~ /MySQL AB/)) - { - $in_copyright=0; - print STDERR "File with unknown copyright ", $ARGV,"\n" if ($opt_v); - return; - } - else - { - print STDERR "To be Changed: ", $ARGV, "\n" if ($opt_v); - } - if ($ARGV =~ /Makefile/ || - $ARGV =~ /makefile/) - { # Makefile - $start_copyright="# "; - $line_copyright= "# "; - $end_copyright= ""; - } - elsif ($line =~ "^#!") - { # Shell script - $start_copyright="# "; - $line_copyright= "# "; - $end_copyright= ""; - $skip_this_line=1; - print $line; - while ($line=<>) # Copy all until new line or copyright - { - if ($line =~ /copyright/i) - { - last; - } - print $line; - last if ($line =~ /^(\s|\n)*$/); - } - $in_copyright=1; - } - elsif ($ARGV =~ /\.c$/ || - $ARGV =~ /\.cc$/ || - $ARGV =~ /\.h$/ || - $ARGV =~ /\.cpp$/ || - $ARGV =~ /\.txt$/ || - $ARGV =~ /\.yy$/) - { - $start_copyright="/* "; - $line_copyright= " "; - $end_copyright= "*/"; - } - elsif ($ARGV =~ /-x86\.s$/) - { - $start_copyright="# "; - $line_copyright= "# "; - $end_copyright= ""; - } - elsif ($ARGV =~ /\.s$/) - { - $start_copyright="! "; - $line_copyright= "! "; - $end_copyright= ""; - } - elsif ($ARGV =~ /\.sql$/) - { - $start_copyright="-- "; - $line_copyright= "-- "; - $end_copyright= ""; - } - elsif ($ARGV =~ /\.asm$/) - { - $start_copyright="; "; - $line_copyright= "; "; - $end_copyright= ""; - } - else # Unknown file - { - $in_copyright=0; - print STDERR "Unknown file type ", $ARGV,"\n" if ($opt_v); - return; - } - $data=\@copyright; - - for ($row=0 ; $row <= $#$data ; $row++) - { - print $row == 0 ? $start_copyright : $line_copyright; - print $data->[$row]; - print $row != $#$data ? "\n" : $end_copyright . "\n"; - } - print "\n"; - $end_copyright =~ /\s*([^\s]+)\s*(([^\s].*)|)$/; # Remove pre and post spaces -} - -# -# Return 1 if in copyright -# - -sub check_in_copyright -{ - my ($line)=@_; - $line =~ /^(.*[^\s])(\s|\n|\r)*$/; # Remove end space and newline - $line=$1; - if (!$line) - { - $found_end_copyright=1 if (!length($end_copyright)); - return 1; # Skip empty lines - } - return 0 if ($found_end_copyright); - if ($end_copyright) - { - if (index($line,$end_copyright) != -1) - { - $found_end_copyright=1; - } - return 1; - } - if ($line =~ /copyright/i || index($line . " ",$line_copyright) == 0) - { - return 1; - } - if ($skip_this_line) - { - $skip_this_line=0; - return 1; - } - return 0; # Can't trust the empty copyright line yet -} diff --git a/Build-tools/newest b/Build-tools/newest deleted file mode 100644 index 367c9bd1f1b..00000000000 --- a/Build-tools/newest +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/perl - -package NEWEST; - -use Getopt::Long; -use File::Basename; - -my $src_dir; -my $basename; -my $type = "tar.gz"; -my $versions; -my $help; -my %KEEPER; - - -GetOptions( - "src_dir=s" => \$src_dir, - "basename=s" => \$basename, - "type=s" => \$type, - "versions!" => \$versions, - "help!" => \$help - ); - -if (!defined $src_dir || !defined $basename) { - $help = 1; -} - -if ($help) { - &help(); - exit; -} - - -&extract_version(\$src_dir, \$basename, \$type, \%KEEPER); -&print_max(\%KEEPER, \$type, \$versions, &find_max(\%KEEPER)); - - - -sub extract_version { - my $src_dir = shift; - my $basename = shift; - my $type = shift; - my $KEEPER = shift; - - while (glob("$${src_dir}/$${basename}*")) { - my $base = basename("$_",".$${type}"); - my @ver = split /-/, $base; - my @nums = split /\./, $ver[$#ver]; - - my $new; - for (my $i=0; $i<$#nums+1; $i++) { - $new =~ s/^([0-9]*)([a-zA-Z]*)$/$1/; - $new .= 10000+$nums[$i]; - $new .= $2; - } - $KEEPER->{"$new"} = [$base,$ver[$#ver]]; - } - - return; -} - - - -sub find_max { - my $KEEPER = shift; - - return reverse sort (keys %$KEEPER); -} - - - -sub print_max { - my $KEEPER = shift; - my $type = shift; - my $versions = shift; - my $max_key = shift; - - if ($${versions}) { - print "$KEEPER->{$max_key}->[1]\n"; - } - else { - print "$KEEPER->{$max_key}->[0]" . ".$${type}\n"; - } - - return; -} - - - -sub help { - - print qq("newest" finds the tarball in a given directory with the newest version number -and returns it's filename. "newest" is meant to be embedded in UNIX shell -scripts. - -Usage: - -newest -(src_dir | s) /path/to/dir/with/tarballs - -(basename | b) BaseName (ex. BaseName-2.10.tar.gz) - -(type | t) Type of file (default: tar.gz) - -(versions | v) Print only version information - -(help | h) Prints usage help - -Ex: \$ /opt/bin/newest -s /opt/incoming/pm_modules -b Data-Dumper - Data-Dumper-2.101.tar.gz - -Both arguments, '-s' and '-b' are required; '-t' and '-v' are optional. - -); - - return; -} - - - - diff --git a/COPYING b/COPYING new file mode 100644 index 00000000000..2cf699059db --- /dev/null +++ b/COPYING @@ -0,0 +1,352 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +Preamble +======== + +The licenses for most software are designed to take away your freedom +to share and change it. By contrast, the GNU General Public License is +intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not price. +Our General Public Licenses are designed to make sure that you have +the freedom to distribute copies of free software (and charge for this +service if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone +to deny you these rights or to ask you to surrender the rights. These +restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis +or for a fee, you must give the recipients all the rights that you +have. You must make sure that they, too, receive or can get the source +code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + +Finally, any free program is threatened constantly by software patents. +We wish to avoid the danger that redistributors of a free program will +individually obtain patent licenses, in effect making the program +proprietary. To prevent this, we have made it clear that any patent +must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + 0. This License applies to any program or other work which contains a + notice placed by the copyright holder saying it may be distributed + under the terms of this General Public License. The "Program", + below, refers to any such program or work, and a "work based on + the Program" means either the Program or any derivative work under + copyright law: that is to say, a work containing the Program or a + portion of it, either verbatim or with modifications and/or + translated into another language. (Hereinafter, translation is + included without limitation in the term "modification".) Each + licensee is addressed as "you". + + Activities other than copying, distribution and modification are + not covered by this License; they are outside its scope. The act + of running the Program is not restricted, and the output from the + Program is covered only if its contents constitute a work based on + the Program (independent of having been made by running the + Program). Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's + source code as you receive it, in any medium, provided that you + conspicuously and appropriately publish on each copy an appropriate + copyright notice and disclaimer of warranty; keep intact all the + notices that refer to this License and to the absence of any + warranty; and give any other recipients of the Program a copy of + this License along with the Program. + + You may charge a fee for the physical act of transferring a copy, + and you may at your option offer warranty protection in exchange + for a fee. + + 2. You may modify your copy or copies of the Program or any portion + of it, thus forming a work based on the Program, and copy and + distribute such modifications or work under the terms of Section 1 + above, provided that you also meet all of these conditions: + + a. You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b. You must cause any work that you distribute or publish, that + in whole or in part contains or is derived from the Program + or any part thereof, to be licensed as a whole at no charge + to all third parties under the terms of this License. + + c. If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display + an announcement including an appropriate copyright notice and + a notice that there is no warranty (or else, saying that you + provide a warranty) and that users may redistribute the + program under these conditions, and telling the user how to + view a copy of this License. (Exception: if the Program + itself is interactive but does not normally print such an + announcement, your work based on the Program is not required + to print an announcement.) + + These requirements apply to the modified work as a whole. If + identifiable sections of that work are not derived from the + Program, and can be reasonably considered independent and separate + works in themselves, then this License, and its terms, do not + apply to those sections when you distribute them as separate + works. But when you distribute the same sections as part of a + whole which is a work based on the Program, the distribution of + the whole must be on the terms of this License, whose permissions + for other licensees extend to the entire whole, and thus to each + and every part regardless of who wrote it. + + Thus, it is not the intent of this section to claim rights or + contest your rights to work written entirely by you; rather, the + intent is to exercise the right to control the distribution of + derivative or collective works based on the Program. + + In addition, mere aggregation of another work not based on the + Program with the Program (or with a work based on the Program) on + a volume of a storage or distribution medium does not bring the + other work under the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, + under Section 2) in object code or executable form under the terms + of Sections 1 and 2 above provided that you also do one of the + following: + + a. Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of + Sections 1 and 2 above on a medium customarily used for + software interchange; or, + + b. Accompany it with a written offer, valid for at least three + years, to give any third-party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a + medium customarily used for software interchange; or, + + c. Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with + such an offer, in accord with Subsection b above.) + + The source code for a work means the preferred form of the work for + making modifications to it. For an executable work, complete + source code means all the source code for all modules it contains, + plus any associated interface definition files, plus the scripts + used to control compilation and installation of the executable. + However, as a special exception, the source code distributed need + not include anything that is normally distributed (in either + source or binary form) with the major components (compiler, + kernel, and so on) of the operating system on which the executable + runs, unless that component itself accompanies the executable. + + If distribution of executable or object code is made by offering + access to copy from a designated place, then offering equivalent + access to copy the source code from the same place counts as + distribution of the source code, even though third parties are not + compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program + except as expressly provided under this License. Any attempt + otherwise to copy, modify, sublicense or distribute the Program is + void, and will automatically terminate your rights under this + License. However, parties who have received copies, or rights, + from you under this License will not have their licenses + terminated so long as such parties remain in full compliance. + + 5. You are not required to accept this License, since you have not + signed it. However, nothing else grants you permission to modify + or distribute the Program or its derivative works. These actions + are prohibited by law if you do not accept this License. + Therefore, by modifying or distributing the Program (or any work + based on the Program), you indicate your acceptance of this + License to do so, and all its terms and conditions for copying, + distributing or modifying the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the + Program), the recipient automatically receives a license from the + original licensor to copy, distribute or modify the Program + subject to these terms and conditions. You may not impose any + further restrictions on the recipients' exercise of the rights + granted herein. You are not responsible for enforcing compliance + by third parties to this License. + + 7. If, as a consequence of a court judgment or allegation of patent + infringement or for any other reason (not limited to patent + issues), conditions are imposed on you (whether by court order, + agreement or otherwise) that contradict the conditions of this + License, they do not excuse you from the conditions of this + License. If you cannot distribute so as to satisfy simultaneously + your obligations under this License and any other pertinent + obligations, then as a consequence you may not distribute the + Program at all. For example, if a patent license would not permit + royalty-free redistribution of the Program by all those who + receive copies directly or indirectly through you, then the only + way you could satisfy both it and this License would be to refrain + entirely from distribution of the Program. + + If any portion of this section is held invalid or unenforceable + under any particular circumstance, the balance of the section is + intended to apply and the section as a whole is intended to apply + in other circumstances. + + It is not the purpose of this section to induce you to infringe any + patents or other property right claims or to contest validity of + any such claims; this section has the sole purpose of protecting + the integrity of the free software distribution system, which is + implemented by public license practices. Many people have made + generous contributions to the wide range of software distributed + through that system in reliance on consistent application of that + system; it is up to the author/donor to decide if he or she is + willing to distribute software through any other system and a + licensee cannot impose that choice. + + This section is intended to make thoroughly clear what is believed + to be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in + certain countries either by patents or by copyrighted interfaces, + the original copyright holder who places the Program under this + License may add an explicit geographical distribution limitation + excluding those countries, so that distribution is permitted only + in or among countries not thus excluded. In such case, this + License incorporates the limitation as if written in the body of + this License. + + 9. The Free Software Foundation may publish revised and/or new + versions of the General Public License from time to time. Such + new versions will be similar in spirit to the present version, but + may differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the + Program specifies a version number of this License which applies + to it and "any later version", you have the option of following + the terms and conditions either of that version or of any later + version published by the Free Software Foundation. If the Program + does not specify a version number of this License, you may choose + any version ever published by the Free Software Foundation. + + 10. If you wish to incorporate parts of the Program into other free + programs whose distribution conditions are different, write to the + author to ask for permission. For software which is copyrighted + by the Free Software Foundation, write to the Free Software + Foundation; we sometimes make exceptions for this. Our decision + will be guided by the two goals of preserving the free status of + all derivatives of our free software and of promoting the sharing + and reuse of software generally. + + NO WARRANTY + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO + WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE + LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT + HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT + WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT + NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE + QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE + PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY + SERVICING, REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN + WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY + MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE + LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, + INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR + INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF + DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU + OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY + OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS +How to Apply These Terms to Your New Programs +============================================= + +If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + +To do so, attach the following notices to the program. It is safest to +attach them to the start of each source file to most effectively convey +the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES. + Copyright (C) YYYY NAME OF AUTHOR + + 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; either 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. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the +appropriate parts of the General Public License. Of course, the +commands you use may be called something other than `show w' and `show +c'; they could even be mouse-clicks or menu items--whatever suits your +program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + SIGNATURE OF TY COON, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, +you may consider it more useful to permit linking proprietary +applications with the library. If this is what you want to do, use the +GNU Library General Public License instead of this License. + diff --git a/Docs/Images/Attic/html-fs.gif b/Docs/Images/Attic/html-fs.gif deleted file mode 100644 index 73f9ab5bec6..00000000000 Binary files a/Docs/Images/Attic/html-fs.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-01.gif b/Docs/Images/Attic/mysql-01.gif deleted file mode 100644 index 773453f8dd7..00000000000 Binary files a/Docs/Images/Attic/mysql-01.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-02.gif b/Docs/Images/Attic/mysql-02.gif deleted file mode 100644 index 12d984b55e0..00000000000 Binary files a/Docs/Images/Attic/mysql-02.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-03.gif b/Docs/Images/Attic/mysql-03.gif deleted file mode 100644 index abb16f2aa59..00000000000 Binary files a/Docs/Images/Attic/mysql-03.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-04.gif b/Docs/Images/Attic/mysql-04.gif deleted file mode 100644 index e207e1790f7..00000000000 Binary files a/Docs/Images/Attic/mysql-04.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-05.gif b/Docs/Images/Attic/mysql-05.gif deleted file mode 100644 index f78b8a17b93..00000000000 Binary files a/Docs/Images/Attic/mysql-05.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-06.gif b/Docs/Images/Attic/mysql-06.gif deleted file mode 100644 index c660e1d1f4f..00000000000 Binary files a/Docs/Images/Attic/mysql-06.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-07.gif b/Docs/Images/Attic/mysql-07.gif deleted file mode 100644 index be309d0de1c..00000000000 Binary files a/Docs/Images/Attic/mysql-07.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-08.gif b/Docs/Images/Attic/mysql-08.gif deleted file mode 100644 index 3d5b2135655..00000000000 Binary files a/Docs/Images/Attic/mysql-08.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-09.gif b/Docs/Images/Attic/mysql-09.gif deleted file mode 100644 index 75d08592795..00000000000 Binary files a/Docs/Images/Attic/mysql-09.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-10.gif b/Docs/Images/Attic/mysql-10.gif deleted file mode 100644 index 8d0a8551e9e..00000000000 Binary files a/Docs/Images/Attic/mysql-10.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-11.gif b/Docs/Images/Attic/mysql-11.gif deleted file mode 100644 index e5f3770a7bd..00000000000 Binary files a/Docs/Images/Attic/mysql-11.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-12.gif b/Docs/Images/Attic/mysql-12.gif deleted file mode 100644 index b045aaf3549..00000000000 Binary files a/Docs/Images/Attic/mysql-12.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-13.gif b/Docs/Images/Attic/mysql-13.gif deleted file mode 100644 index 0d5aaf88f6f..00000000000 Binary files a/Docs/Images/Attic/mysql-13.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-14.gif b/Docs/Images/Attic/mysql-14.gif deleted file mode 100644 index 9bce287b4b3..00000000000 Binary files a/Docs/Images/Attic/mysql-14.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-15.gif b/Docs/Images/Attic/mysql-15.gif deleted file mode 100644 index d70ffec83dd..00000000000 Binary files a/Docs/Images/Attic/mysql-15.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-16.gif b/Docs/Images/Attic/mysql-16.gif deleted file mode 100644 index 9b30833dc1d..00000000000 Binary files a/Docs/Images/Attic/mysql-16.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-17.gif b/Docs/Images/Attic/mysql-17.gif deleted file mode 100644 index 5b228496b66..00000000000 Binary files a/Docs/Images/Attic/mysql-17.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-18.gif b/Docs/Images/Attic/mysql-18.gif deleted file mode 100644 index 71211350aa2..00000000000 Binary files a/Docs/Images/Attic/mysql-18.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-19.gif b/Docs/Images/Attic/mysql-19.gif deleted file mode 100644 index 38e6691d9c6..00000000000 Binary files a/Docs/Images/Attic/mysql-19.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql-compatible.jpg b/Docs/Images/Attic/mysql-compatible.jpg deleted file mode 100644 index cce9cf84b91..00000000000 Binary files a/Docs/Images/Attic/mysql-compatible.jpg and /dev/null differ diff --git a/Docs/Images/Attic/mysql5.gif b/Docs/Images/Attic/mysql5.gif deleted file mode 100644 index f78b8a17b93..00000000000 Binary files a/Docs/Images/Attic/mysql5.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql_anim-01.gif b/Docs/Images/Attic/mysql_anim-01.gif deleted file mode 100644 index f537d60da41..00000000000 Binary files a/Docs/Images/Attic/mysql_anim-01.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql_anim-02.gif b/Docs/Images/Attic/mysql_anim-02.gif deleted file mode 100644 index cfd3e1cfc3e..00000000000 Binary files a/Docs/Images/Attic/mysql_anim-02.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql_anim-03.gif b/Docs/Images/Attic/mysql_anim-03.gif deleted file mode 100644 index 6ac6b3ebcc1..00000000000 Binary files a/Docs/Images/Attic/mysql_anim-03.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql_anim-04.gif b/Docs/Images/Attic/mysql_anim-04.gif deleted file mode 100644 index d3150860ecf..00000000000 Binary files a/Docs/Images/Attic/mysql_anim-04.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql_anim-05.gif b/Docs/Images/Attic/mysql_anim-05.gif deleted file mode 100644 index 46f288ef71d..00000000000 Binary files a/Docs/Images/Attic/mysql_anim-05.gif and /dev/null differ diff --git a/Docs/Images/Attic/mysql_anim-06.gif b/Docs/Images/Attic/mysql_anim-06.gif deleted file mode 100644 index 3dc283dbfb6..00000000000 Binary files a/Docs/Images/Attic/mysql_anim-06.gif and /dev/null differ diff --git a/Docs/Images/Attic/powered-by-MySQL-transparent.gif b/Docs/Images/Attic/powered-by-MySQL-transparent.gif deleted file mode 100644 index be309d0de1c..00000000000 Binary files a/Docs/Images/Attic/powered-by-MySQL-transparent.gif and /dev/null differ diff --git a/Docs/Images/Makefile.am b/Docs/Images/Makefile.am deleted file mode 100644 index 8ba1ff7382c..00000000000 --- a/Docs/Images/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Library General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library 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 -# Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public -# License along with this library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA - -## Process this file with automake to create Makefile.in - -# This is a dummy file to satisfy the hierarchy of Makefiles. -# When a release is built, the true Makefile will be copied -# together with the "real" files in this directory. - -EXTRA_DIST = - -# Nothing to create in this dummy directory. -all: - : - -# Don't update the files from bitkeeper -%::SCCS/s.% diff --git a/Docs/Images/empty.png b/Docs/Images/empty.png deleted file mode 100644 index 71ac39b37f0..00000000000 Binary files a/Docs/Images/empty.png and /dev/null differ diff --git a/Docs/Images/flag-background.pnm b/Docs/Images/flag-background.pnm deleted file mode 100755 index 2bd7b604298..00000000000 Binary files a/Docs/Images/flag-background.pnm and /dev/null differ diff --git a/Docs/Images/mysql-logo.gif b/Docs/Images/mysql-logo.gif deleted file mode 100644 index f8110ddcb93..00000000000 Binary files a/Docs/Images/mysql-logo.gif and /dev/null differ diff --git a/Docs/Makefile.am b/Docs/Makefile.am index 681046543bd..92f3c56a504 100644 --- a/Docs/Makefile.am +++ b/Docs/Makefile.am @@ -9,184 +9,17 @@ # If you know how to fix any of this more elegantly please mail # docs@mysql.com -TEXI2HTML_FLAGS = -iso -number -acc -DVIPS = dvips -MAKEINFO = @MAKEINFO@ -TEXINFO_TEX = Support/texinfo.tex +noinst_SCRIPTS = Support/generate-text-files.pl -noinst_SCRIPTS = Support/texi2html Support/generate-text-files.pl \ - Support/generate-mirror-listing.pl -info_TEXINFOS = manual.texi +EXTRA_DIST = $(noinst_SCRIPTS) mysql.info INSTALL-BINARY -targets = manual.txt mysql.info manual.html - -BUILT_SOURCES = $(targets) manual_toc.html include.texi -EXTRA_DIST = $(noinst_SCRIPTS) $(BUILT_SOURCES) mysqld_error.txt \ - INSTALL-BINARY reservedwords.texi internals.texi - -SUBDIRS = Images - -all: $(targets) txt_files +all: txt_files txt_files: ../INSTALL-SOURCE ../COPYING ../INSTALL-WIN-SOURCE ../EXCEPTIONS-CLIENT \ INSTALL-BINARY ../support-files/MacOSX/ReadMe.txt -CLEAN_FILES: $(BUILD_SOURCES) - touch $(BUILD_SOURCES) - -# The PostScript and PDF version are so big that they are not included in the -# standard distribution. It is available for download from the home page. -paper: manual_a4.ps manual_letter.ps $(PDFMANUAL) - -######################################################################### - -# The Makefile contains the previous version so we can not use that -include.texi: ../configure.in - echo "@c This file is autogenerated by the Makefile" > $@ - echo -n "@set mysqlversion " >> $@ - grep "AM_INIT_AUTOMAKE(mysql, " ../configure.in | \ - sed -e 's;AM_INIT_AUTOMAKE(mysql, ;;' -e 's;);;' >> $@ - echo -n "@set defaultport " >> $@ - grep "MYSQL_TCP_PORT_DEFAULT=" ../configure.in | \ - sed -e 's;MYSQL_TCP_PORT_DEFAULT=;;' >> $@ - - -# -# English Manual -# - -# GNU Info -mysql.info: manual.texi include.texi - cd $(srcdir) && $(MAKEINFO) --no-split -I $(srcdir) $< - -# Plain Text -manual.txt: manual.texi include.texi - cd $(srcdir) && \ - $(MAKEINFO) -I $(srcdir) --no-headers --no-split --output $@ $< - -# HTML, all in one file -manual.html: manual.texi include.texi $(srcdir)/Support/texi2html - cd $(srcdir) && @PERL@ $(srcdir)/Support/texi2html $(TEXI2HTML_FLAGS) $< -manual_toc.html: manual.html - -# PDF, Portable Document Format -manual.pdf: manual.texi - sed -e 's|@image{[^}]*} *||g' <$< >manual-tmp.texi - pdftex --interaction=nonstopmode manual-tmp.texi - texindex manual-tmp.?? - pdftex --interaction=nonstopmode manual-tmp.texi - texindex manual-tmp.?? - pdftex --interaction=nonstopmode manual-tmp.texi - mv manual-tmp.pdf $@ - rm -f manual-tmp.* - touch $@ - -# XML, DocBook 4.0 -mysql.xml: manual.texi include.texi - $(MAKEINFO) --force --no-ifinfo --docbook $< - mv $@ mysql-tmp.xml - Support/docbook-fixup.pl $@ - rm -f mysql-tmp.xml - -# Postscript, A4 Paper -manual_a4.ps: manual.texi include.texi - TEXINPUTS=$(srcdir):$$TEXINPUTS \ - MAKEINFO='$(MAKEINFO) -I $(srcdir)' \ - $(TEXI2DVI) --batch --texinfo --quiet '@afourpaper' $< - $(DVIPS) -t a4 manual.dvi -o $@ - touch $@ - -# Postscript, US Letter Paper -manual_letter.ps: manual.texi include.texi - TEXINPUTS=$(srcdir):$$TEXINPUTS \ - MAKEINFO='$(MAKEINFO) -I $(srcdir)' \ - $(TEXI2DVI) --batch $< - $(DVIPS) -t letter manual.dvi -o $@ - touch $@ - - -# -# German Manual -# - -# GNU Info -mysql.de.info: manual.de.texi include.texi - cd $(srcdir) && $(MAKEINFO) --no-split -I $(srcdir) $< - -# Plain Text -manual.de.txt: manual.de.texi include.texi - cd $(srcdir) && \ - $(MAKEINFO) -I $(srcdir) --no-headers --no-split --output $@ $< - -# HTML, all in one file -manual.de.html: manual.de.texi include.texi $(srcdir)/Support/texi2html - cd $(srcdir) && @PERL@ $(srcdir)/Support/texi2html $(TEXI2HTML_FLAGS) $< -manual_toc.de.html: manual.html - -# PDF, Portable Document Format -manual.de.pdf: manual.de.texi - sed -e 's|@image{[^}]*} *||g' <$< >manual-tmp.texi - pdftex --interaction=nonstopmode manual-tmp.texi - texindex manual-tmp.?? - pdftex --interaction=nonstopmode manual-tmp.texi - texindex manual-tmp.?? - pdftex --interaction=nonstopmode manual-tmp.texi - mv manual-tmp.pdf $@ - rm -f manual-tmp.* - touch $@ - -# XML, DocBook 4.0 -mysql.de.xml: manual.de.texi include.texi - $(MAKEINFO) --force --no-ifinfo --docbook $< - mv $@ mysql-tmp.xml - Support/docbook-fixup.pl $@ - rm -f mysql-tmp.xml - -# Postscript, A4 Paper -manual_a4.de.ps: manual.de.texi include.texi - TEXINPUTS=$(srcdir):$$TEXINPUTS \ - MAKEINFO='$(MAKEINFO) -I $(srcdir)' \ - $(TEXI2DVI) --batch --texinfo --quiet '@afourpaper' $< - $(DVIPS) -t a4 manual.de.dvi -o $@ - touch $@ - -# Postscript, US Letter Paper -manual_letter.de.ps: manual.de.texi include.texi - TEXINPUTS=$(srcdir):$$TEXINPUTS \ - MAKEINFO='$(MAKEINFO) -I $(srcdir)' \ - $(TEXI2DVI) --batch $< - $(DVIPS) -t letter manual.de.dvi -o $@ - touch $@ - -# -# Miscellaneous -# - -# Target to produce NuSphere Manual -nusphere.pdf: manual.texi - sed -e 's/@example/@smallexample/g' \ - -e 's/@end example/@end smallexample/g' \ - -e 's/@c ifnusphere //g' \ - -e 's|@image{[^}]*} *||g' \ - <$< >manual-tmp.texi - pdftex --interaction=nonstopmode manual-tmp.texi - texindex manual-tmp.?? - pdftex --interaction=nonstopmode manual-tmp.texi - texindex manual-tmp.?? - pdftex --interaction=nonstopmode manual-tmp.texi - mv manual-tmp.pdf $@ - rm -f manual-tmp.* - touch $@ - -# Include images for the manual in the distribution -dist-hook: - BD=`cd $(top_srcdir); pwd`; \ - echo "PostScript and PDF versions suitable for printing" \ - > $(distdir)/manual.ps - echo "are available from http://dev.mysql.com/doc/" \ - >> $(distdir)/manual.ps - echo "or any mirror site" \ - >> $(distdir)/manual.ps +CLEAN_FILES: $(txt_files) + touch $(txt_files) GT = $(srcdir)/Support/generate-text-files.pl @@ -202,9 +35,6 @@ GT = $(srcdir)/Support/generate-text-files.pl INSTALL-BINARY: mysql.info $(GT) perl -w $(GT) mysql.info "Installing binary" "Installing source" > $@ -../COPYING: mysql.info $(GT) - perl -w $(GT) mysql.info "GPL license" "MySQL FLOSS License Exception" > $@ - ../EXCEPTIONS-CLIENT: mysql.info $(GT) perl -w $(GT) mysql.info "MySQL FLOSS License Exception" "Function Index" > $@ diff --git a/Docs/Support/generate-mirror-listing.pl b/Docs/Support/generate-mirror-listing.pl deleted file mode 100755 index 1c6e579b330..00000000000 --- a/Docs/Support/generate-mirror-listing.pl +++ /dev/null @@ -1,27 +0,0 @@ -#!/my/gnu/bin/perl -w -*- perl -*- - -# Generate a mirror listing - -line: while (<>) { last line if /START_OF_MIRROR_LISTING/;}; - -print "MySQL mirror listing\n"; - -line: while (<>) -{ - last line if /END_OF_MIRROR_LISTING/; - if (/^\@strong\{([A-Za-z ]+):\}$/) - { - print "\n*** $1\n"; - } - elsif (m|^\@image\{Img/[a-z-]+\} ([A-Za-z]+) \[(.*)\]|) - { - print "\n$1 [$2]\n"; - } - # A hacky URL regexp - # (m!^\@uref\{((http\|ftp)://[^,]*), (FTP\|WWW)\}!) - elsif (m!^\@uref\{((http|ftp)://[^,]*), (FTP|WWW)\}!) - { - $addr = $1; - print " $addr\n"; - } -} diff --git a/Docs/Support/texi2html b/Docs/Support/texi2html deleted file mode 100755 index f13c006c7dc..00000000000 --- a/Docs/Support/texi2html +++ /dev/null @@ -1,2259 +0,0 @@ -#!/usr/bin/perl -# Add path to perl on the previous line and make this executable -# if you want to use this as a normal script. -'di '; -'ig 00 '; -#+############################################################################## -# # -# File: texi2html # -# # -# Description: Program to transform most Texinfo documents to HTML # -# # -#-############################################################################## - -# @(#)texi2html 1.52 971230 Written (mainly) by Lionel Cons, Lionel.Cons@cern.ch -# Enhanced by David Axmark - -# The man page for this program is included at the end of this file and can be -# viewed using the command 'nroff -man texi2html'. -# Please read the copyright at the end of the man page. - -#+++############################################################################ -# # -# Constants # -# # -#---############################################################################ - -$DEBUG_TOC = 1; -$DEBUG_INDEX = 2; -$DEBUG_BIB = 4; -$DEBUG_GLOSS = 8; -$DEBUG_DEF = 16; -$DEBUG_HTML = 32; -$DEBUG_USER = 64; - -$BIBRE = '\[[\w\/]+\]'; # RE for a bibliography reference -$FILERE = '[\/\w.+-]+'; # RE for a file name -$VARRE = '[^\s\{\}]+'; # RE for a variable name -$NODERE = '[^@{}:\'`",]+'; # RE for a node name -$NODESRE = '[^@{}:\'`"]+'; # RE for a list of node names -$XREFRE = '[^@{}]+'; # RE for a xref (should use NODERE) - -$ERROR = "***"; # prefix for errors and warnings -$THISPROG = "texi2html 1.52 (with additions by MySQL AB)"; # program name and version -$TODAY = &pretty_date; # like "20 September 1993" -$SPLITTAG = "\n"; # tag to know where to split -$PROTECTTAG = "_ThisIsProtected_"; # tag to recognize protected sections -$html2_doctype = ''; - -# -# language dependent constants -# -#$LDC_SEE = 'see'; -#$LDC_SECTION = 'section'; -#$LDC_IN = 'in'; -#$LDC_TOC = 'Table of Contents'; -#$LDC_GOTO = 'Go to the'; -#$LDC_FOOT = 'Footnotes'; -# TODO: @def* shortcuts - -#$user_sub{"email"} = "fix_email"; - -# -# pre-defined indices -# -%predefined_index = ( - 'cp', 'c', - 'fn', 'f', - 'vr', 'v', - 'ky', 'k', - 'pg', 'p', - 'tp', 't', - ); - -# -# valid indices -# -%valid_index = ( - 'c', 1, - 'f', 1, - 'v', 1, - 'k', 1, - 'p', 1, - 't', 1, - ); - -# -# texinfo section names to level -# -%sec2level = ( - 'top', 0, - 'chapter', 1, - 'unnumbered', 1, - 'majorheading', 1, - 'chapheading', 1, - 'appendix', 1, - 'section', 2, - 'unnumberedsec', 2, - 'heading', 2, - 'appendixsec', 2, - 'appendixsection', 2, - 'subsection', 3, - 'unnumberedsubsec', 3, - 'subheading', 3, - 'appendixsubsec', 3, - 'subsubsection', 4, - 'unnumberedsubsubsec', 4, - 'subsubheading', 4, - 'appendixsubsubsec', 4, - ); - -# -# accent map, TeX command to ISO name -# -%accent_map = ( - '"', 'uml', - '\'', 'acute', - ',{', 'cedil', - '~', 'tilde', - '^', 'circ', - '`', 'grave', - 'ringaccent{', 'ring', - ); - -# -# texinfo "simple things" (@foo) to HTML ones -# -%simple_map = ( - # cf. makeinfo.c - "*", "
", # HTML+ - " ", " ", - "\n", "\n", - "|", "", - # spacing commands - ":", "", - "!", "!", - "?", "?", - ".", ".", - # @- means "allow word break", not — - "-", "", - ); - -# -# texinfo "things" (@foo{}) to HTML ones -# -%things_map = ( - 'TeX', 'TeX', - 'br', '

', # paragraph break - 'bullet', '*', - 'copyright', '(C)', - 'registeredsymbol', '(R)', - 'dots', '...', - 'equiv', '==', - 'error', 'error-->', - 'expansion', '==>', - 'minus', '-', - 'point', '-!-', - 'print', '-|', - 'result', '=>', - 'today', $TODAY, - ); - -# -# texinfo styles (@foo{bar}) to HTML ones -# -%style_map = ( - 'asis', '', - 'b', 'B', - 'cite', 'cite', - 'code', 'code', - 'command', 'code', - 'ctrl', '&do_ctrl', # special case - 'dfn', 'strong', # DFN tag is illegal in the standard - 'dmn', '', # useless - 'email', '&fix_email', # special - 'emph', 'em', - 'file', '"tt', # will put quotes, cf. &apply_style - 'i', 'i', - 'kbd', 'kbd', - 'key', 'kbd', - 'r', '', # unsupported - 'samp', '"samp', # will put quotes, cf. &apply_style - 'sc', '&do_sc', # special case - 'strong', 'strong', - 't', 'tt', - 'titlefont', '', # useless - 'image', '&fix_image', # Image - 'url', '&fix_url', # URL - 'uref', '&fix_uref', # URL Reference - 'var', 'var', - 'w', '', # unsupported - ); - -# -# texinfo format (@foo/@end foo) to HTML ones -# -%format_map = ( - 'display', 'PRE', - 'example', 'PRE', - 'format', 'PRE', - 'lisp', 'PRE', - 'quotation', 'BLOCKQUOTE', - 'smallexample', 'PRE', - 'smalllisp', 'PRE', - # lists - 'itemize', 'UL', - 'enumerate', 'OL', - # poorly supported - 'flushleft', 'PRE', - 'flushright', 'PRE', - ); - -# -# texinfo definition shortcuts to real ones -# -%def_map = ( - # basic commands - 'deffn', 0, - 'defvr', 0, - 'deftypefn', 0, - 'deftypevr', 0, - 'defcv', 0, - 'defop', 0, - 'deftp', 0, - # basic x commands - 'deffnx', 0, - 'defvrx', 0, - 'deftypefnx', 0, - 'deftypevrx', 0, - 'defcvx', 0, - 'defopx', 0, - 'deftpx', 0, - # shortcuts - 'defun', 'deffn Function', - 'defmac', 'deffn Macro', - 'defspec', 'deffn {Special Form}', - 'defvar', 'defvr Variable', - 'defopt', 'defvr {User Option}', - 'deftypefun', 'deftypefn Function', - 'deftypevar', 'deftypevr Variable', - 'defivar', 'defcv {Instance Variable}', - 'defmethod', 'defop Method', - # x shortcuts - 'defunx', 'deffnx Function', - 'defmacx', 'deffnx Macro', - 'defspecx', 'deffnx {Special Form}', - 'defvarx', 'defvrx Variable', - 'defoptx', 'defvrx {User Option}', - 'deftypefunx', 'deftypefnx Function', - 'deftypevarx', 'deftypevrx Variable', - 'defivarx', 'defcvx {Instance Variable}', - 'defmethodx', 'defopx Method', - ); - -# -# things to skip -# -%to_skip = ( - # comments - 'c', 1, - 'comment', 1, - # useless - 'contents', 1, - 'shortcontents', 1, - 'summarycontents', 1, - 'footnotestyle', 1, - 'end ifclear', 1, - 'end ifset', 1, - 'titlepage', 1, - 'end titlepage', 1, - # unsupported commands (formatting) - 'afourpaper', 1, - 'cropmarks', 1, - 'finalout', 1, - 'headings', 1, - 'need', 1, - 'page', 1, - 'setchapternewpage', 1, - 'everyheading', 1, - 'everyfooting', 1, - 'evenheading', 1, - 'evenfooting', 1, - 'oddheading', 1, - 'oddfooting', 1, - 'smallbook', 1, - 'vskip', 1, - 'filbreak', 1, - # unsupported formats - 'cartouche', 1, - 'end cartouche', 1, - 'group', 1, - 'end group', 1, - ); - -#+++############################################################################ -# # -# Argument parsing, initialisation # -# # -#---############################################################################ - -%value = (); # hold texinfo variables - -$use_bibliography = 1; -$use_acc = 0; -$debug = 0; -$doctype = ''; -$check = 0; -$expandinfo = 0; -$use_glossary = 0; -$invisible_mark = ''; -$use_iso = 0; -@include_dirs = (); -$show_menu = 0; -$number_sections = 0; -$split_node = 0; -$split_chapter = 0; -$monolithic = 0; -$verbose = 0; -$opt_use_numbers = 0; -$opt_empty_headers = 0; -$opt_special_links = ""; -$usage = <= 0 && $ARGV[0] =~ /^-/) -{ - $_ = shift(@ARGV); - if (/^-acc$/) { $use_acc = 1; next; } - if (/^-d(ebug)?(\d+)?$/) { $debug = $2 || shift(@ARGV); next; } - if (/^-doctype$/) { $doctype = shift(@ARGV); next; } - if (/^-c(heck)?$/) { $check = 1; next; } - if (/^-e(xpandinfo)?$/) { $expandinfo = 1; next; } - if (/^-g(lossary)?$/) { $use_glossary = 1; next; } - if (/^-i(nvisible)?$/) { $invisible_mark = shift(@ARGV); next; } - if (/^-iso$/) { $use_iso = 1; next; } - if (/^-I(.+)?$/) { push(@include_dirs, $2 || shift(@ARGV)); next; } - if (/^-D([a-zA-Z0-9]+)=?(.+)?$/) - { $value{$1} = $2 ? $2 : 1; next; } - if (/^-m(enu)?$/) { $show_menu = 1; next; } - if (/^-mono(lithic)?$/) { $monolithic = 1; next; } - if (/^-n(umber)?$/) { $number_sections = 1; next; } - if (/^-ref_num$/) { $opt_use_numbers = 1; next; } - if (/^-empty_headers$/) { $opt_empty_headers = 1; next; } - if (/^-special_links$/) { $opt_special_links = $2 || shift(@ARGV); next; } - if (/^-s(plit)?_?(n(ode)?|c(hapter)?)?$/) { - if ($2 =~ /^n/) { - $split_node = 1; - } else { - $split_chapter = 1; - } - next; - } - if (/^-v(erbose)?$/) { $verbose = 1; next; } - die $usage; -} -if ($check) { - die $usage unless @ARGV > 0; - ✓ - exit; -} - -die "Can't use -special_links with -ref_num.\n" - if $opt_special_links && $opt_use_numbers; -die "Must have -split_node with -special_links.\n" - if $opt_special_links && !$split_node; - -if (($split_node || $split_chapter) && $monolithic) { - warn "Can't use -monolithic with -split, -monolithic ignored.\n"; - $monolithic = 0; -} -if ($expandinfo) { - $to_skip{'ifinfo'}++; - $to_skip{'end ifinfo'}++; -} else { - $to_skip{'iftex'}++; - $to_skip{'end iftex'}++; -} -$invisible_mark = '' if $invisible_mark eq 'xbm'; -die $usage unless @ARGV == 1; -$docu = shift(@ARGV); -if ($docu =~ /.*\//) { - chop($docu_dir = $&); - $docu_name = $'; -} else { - $docu_dir = '.'; - $docu_name = $docu; -} -unshift(@include_dirs, $docu_dir); -$docu_name =~ s/\.te?x(i|info)?$//; # basename of the document - -$docu_doc = "$docu_name.html"; # document's contents -$link_doc = $docu_doc; -if ($monolithic) { - $docu_toc = $docu_foot = $docu_doc; -} else { - $docu_toc = "${docu_name}_toc.html"; # document's table of contents - $docu_foot = "${docu_name}_foot.html"; # document's footnotes -} - -# -# variables -# -$value{'html'} = 1; # predefine html (the output format) -$value{'texi2html'} = '1.52'; # predefine texi2html (the translator) -# _foo: internal to track @foo -foreach ('_author', '_title', '_subtitle', - '_settitle', '_setfilename') { - $value{$_} = ''; # prevent -w warnings -} -%node2sec = (); # node to section name -%node2href = (); # node to HREF -%bib2href = (); # bibliography reference to HREF -%gloss2href = (); # glossary term to HREF -@sections = (); # list of sections -%tag2pro = (); # protected sections - -# -# initial indexes -# -$bib_num = 0; -$foot_num = 0; -$gloss_num = 0; -$idx_num = 0; -$sec_num = 0; -$doc_num = 0; -$current_chapter_link = ""; -@maybe_wrong_links = (); -$html_num = 0; - -# -# can I use ISO8879 characters? (HTML+) -# -if ($use_iso) { - $things_map{'bullet'} = "•"; - $things_map{'copyright'} = "©"; - $things_map{'registeredsymbol'} = "®"; - $things_map{'dots'} = "…"; - $things_map{'equiv'} = "≡"; - $things_map{'expansion'} = "→"; - $things_map{'point'} = "∗"; - $things_map{'result'} = "⇒"; - $things_map{'ss'} = "ß"; - $things_map{'o'} = "ø"; - $things_map{'O'} = "Ø"; -} - -# -# read texi2html extensions (if any) -# -$extensions = 'texi2html.ext'; # extensions in working directory -if (-f $extensions) { - print "# reading extensions from $extensions\n" if $verbose; - require($extensions); -} -($progdir = $0) =~ s/[^\/]+$//; -if ($progdir && ($progdir ne './')) -{ - $extensions = "${progdir}texi2html.ext"; # extensions in texi2html directory - if (-f $extensions) { - print "# reading extensions from $extensions\n" if $verbose; - require($extensions); - } -} - - print "# reading from $docu\n" if $verbose; - -#+++############################################################################ -# # -# Pass 1: read source, handle command, variable, simple substitution # -# # -#---############################################################################ - -@lines = (); # whole document -@toc_lines = (); # table of contents -$toplevel = 0; # top level seen in hierarchy -$curlevel = 0; # current level in TOC -$node = ''; # current node name -$in_table = 0; # am I inside a table -$table_type = ''; # type of table ('', 'f', 'v') -@tables = (); # nested table support -$in_bibliography = 0; # am I inside a bibliography -$in_glossary = 0; # am I inside a glossary -$in_top = 0; # am I inside the top node -$in_pre = 0; # am I inside a preformatted section -$in_list = 0; # am I inside a list -$in_html = 0; # am I inside an HTML section -$first_line = 1; # is it the first line -$dont_html = 0; # don't protect HTML on this line -$split_num = 0; # split index -$deferred_ref = ''; # deferred reference for indexes -@html_stack = (); # HTML elements stack -$html_element = ''; # current HTML element -&html_reset; - -# build code for simple substitutions -# the maps used (%simple_map and %things_map) MUST be aware of this -# watch out for regexps, / and escaped characters! -$subst_code = ''; -foreach (keys(%simple_map)) { - $re = quotemeta $_; # protect regexp chars - $sub = quotemeta $simple_map{$_}; - $subst_code .= "s/\\\@$re/$sub/g;\n"; -} -foreach (keys(%things_map)) { - $re = quotemeta $_; # protect regexp chars - $sub = quotemeta $things_map{$_}; - $subst_code .= "s/\\\@$re\\{\\}/$sub/g;\n"; -} -if ($use_acc) { - # accentuated characters - foreach (keys(%accent_map)) { - my $brace = /{$/ ? '}' : ''; - if ($_ eq "`") { - $subst_code .= "s/$;3"; - } elsif ($_ eq "'") { - $subst_code .= "s/$;4"; - } else { - $subst_code .= "s/\\\@\\Q$_\\E"; - } - $subst_code .= "(\\w)$brace/&\${1}$accent_map{$_};/gi;\n"; - } -} -eval("sub simple_substitutions { $subst_code }"); - -&init_input; -READ_LINE: while ($_ = &next_line) -{ - # - # remove \input on the first lines only - # - if ($first_line) { - next if /^\\input/; - $first_line = 0; - } - # - # parse texinfo tags - # - $tag = ''; - $end_tag = ''; - if (/^\s*\@end\s+(\w+)\b/) { - $end_tag = $1; - } elsif (/^\s*\@(\w+)\b/) { - $tag = $1; - } - # - # handle @ifhtml / @end ifhtml - # - if ($in_html) { - if ($end_tag eq 'ifhtml') { - $in_html = 0; - } else { - $tag2pro{$in_html} .= $_; - } - next; - } elsif ($tag eq 'ifhtml') { - $in_html = $PROTECTTAG . ++$html_num; - push(@lines, $in_html); - next; - } - # - # try to skip the line - # - if ($end_tag) { - next if $to_skip{"end $end_tag"}; - } elsif ($tag) { - next if $to_skip{$tag}; - last if $tag eq 'bye'; - } - if ($in_top) { - # parsing the top node - if ($tag eq 'node' || $tag eq 'include' || $sec2level{$tag}) { - # no more in top - $in_top = 0; - } else { - # skip it - next; - } - } - # - # try to remove inlined comments - # syntax from tex-mode.el comment-start-skip - # - s/((^|[^\s*\@])(\@\@)*)\@c(omment)? .*/$1/; - # non-@ substitutions cf. texinfmt.el - # Since these changes break code examples in the source they were removed. David 990729 - #s/``/\"/g; - #s/''/\"/g; - s/([\w ])---([\w ])/$1--$2/g; - # - # analyze the tag - # - if ($tag) { - # skip lines - &skip_until($tag), next if $tag eq 'ignore'; - if ($expandinfo) { - &skip_until($tag), next if $tag eq 'iftex'; - } else { - &skip_until($tag), next if $tag eq 'ifinfo'; - } - &skip_until($tag), next if $tag eq 'tex'; - # handle special tables - if ($tag eq 'table') { - $table_type = ''; - } elsif ($tag eq 'ftable') { - $tag = 'table'; - $table_type = 'f'; - } elsif ($tag eq 'vtable') { - $tag = 'table'; - $table_type = 'v'; - } - # special cases - if ($tag eq 'top' || ($tag eq 'node' && /^\s*\@node\s+top\s*,/i)) { - $in_top = 1; - @lines = (); # ignore all lines before top (title page garbage) - next; - } elsif ($tag eq 'node') { - $in_top = 0; - warn "$ERROR Bad node line: $_" unless $_ =~ /^\s*\@node\s$NODESRE$/o; - $_ = &protect_html($_); # if node contains '&' for instance - s/^\s*\@node\s+//; - ($node) = split(/,/); - &normalise_node($node); - if ($split_node) { - ($doc_node_name[$doc_num + 1] = $node) =~ s|[ /]|_|g; - $doc_node_name_links[$doc_num + 1] = $current_chapter_link; - &next_doc; - push(@lines, $SPLITTAG) if $split_num++; - push(@sections, $node); - } - next; - } elsif ($tag eq 'include') { - if (/^\s*\@include\s+($FILERE)\s*$/o) { - $file = $1; - unless (-e $file) { - foreach $dir (@include_dirs) { - $file = "$dir/$1"; - last if -e $file; - } - } - if (-e $file) { - &open($file); - print "# including $file\n" if $verbose; - } else { - warn "$ERROR Can't find $file, skipping"; - } - } else { - warn "$ERROR Bad include line: $_"; - } - next; - } elsif ($tag eq 'ifclear') { - if (/^\s*\@ifclear\s+($VARRE)\s*$/o) { - next unless defined($value{$1}); - &skip_until($tag); - } else { - warn "$ERROR Bad ifclear line: $_"; - } - next; - } elsif ($tag eq 'ifset') { - if (/^\s*\@ifset\s+($VARRE)\s*$/o) { - next if defined($value{$1}); - &skip_until($tag); - } else { - warn "$ERROR Bad ifset line: $_"; - } - next; - } elsif ($tag eq 'menu') { - unless ($show_menu) { - &skip_until($tag); - next; - } - &html_push_if($tag); - push(@lines, &html_debug("\n", __LINE__)); - } elsif ($format_map{$tag}) { - $in_pre = 1 if $format_map{$tag} eq 'PRE'; - &html_push_if($format_map{$tag}); - push(@lines, &html_debug("\n", __LINE__)); - $in_list++ if $format_map{$tag} eq 'UL' || $format_map{$tag} eq 'OL' ; - push(@lines, &debug("<$format_map{$tag}>\n", __LINE__)); - next; - } elsif ($tag eq 'table') { - if (/^\s*\@[fv]?table\s+\@(\w+)\s*$/) { - $in_table = $1; - unshift(@tables, join($;, $table_type, $in_table)); - push(@lines, &debug("

\n", __LINE__)); - &html_push_if('DL'); - push(@lines, &html_debug("\n", __LINE__)); - } else { - warn "$ERROR Bad table line: $_"; - } - next; - } elsif ($tag eq 'multitable') { - if (/^\s*\@multitable\s*\@columnfractions\s+([\.\d\s]+)\s*$/ || - /^\s*\@multitable\s*({[^{}]+})+\s*$/) - { - $in_multitable = 1; - html_push('TABLE'); - my($col_list) = $1; - $multitable_cols = ($col_list =~ /\@columnfractions/ ? s/[\d.]+\s+//g : - s/{[^{}]+}//g); - print "# Multitable with $multitable_cols columns\n" - if $debug and $DEBUG_USER; - push(@lines, &debug("\n", __LINE__)); - } else { - warn "$ERROR Bad table line: $_"; - } - next; - } elsif ($tag eq 'synindex' || $tag eq 'syncodeindex') { - if (/^\s*\@$tag\s+(\w)\w\s+(\w)\w\s*$/) { - eval("*${1}index = *${2}index"); - } else { - warn "$ERROR Bad syn*index line: $_"; - } - next; - } elsif ($tag eq 'sp') { - push(@lines, &debug("

\n", __LINE__)); - next; - } elsif ($tag eq 'setref') { - &protect_html; # if setref contains '&' for instance - if (/^\s*\@$tag\s*{($NODERE)}\s*$/) { - $setref = $1; - $setref =~ s/\s+/ /g; # normalize - $setref =~ s/ $//; - $node2sec{$setref} = $name; - $node2href{$setref} = "$link_doc#$docid"; - push(@maybe_wrong_links, $setref); - } else { - warn "$ERROR Bad setref line: $_"; - } - next; - } elsif ($tag eq 'defindex' || $tag eq 'defcodeindex') { - if (/^\s*\@$tag\s+(\w\w)\s*$/) { - $valid_index{$1} = 1; - } else { - warn "$ERROR Bad defindex line: $_"; - } - next; - } elsif (defined($def_map{$tag})) { - if ($def_map{$tag}) { - s/^\s*\@$tag\s+//; - $tag = $def_map{$tag}; - $_ = "\@$tag $_"; - $tag =~ s/\s.*//; - } - } elsif (defined($user_sub{$tag})) { - s/^\s*\@$tag\s+//; - $sub = $user_sub{$tag}; - print "# user $tag = $sub, arg: $_" if $debug & $DEBUG_USER; - if (defined(&$sub)) { - chop($_); - &$sub($_); - } else { - warn "$ERROR Bad user sub for $tag: $sub\n"; - } - next; - } - if (defined($def_map{$tag})) { - s/^\s*\@$tag\s+//; - if ($tag =~ /x$/) { - # extra definition line - $tag = $`; - $is_extra = 1; - } else { - $is_extra = 0; - } - while (/\{([^\{\}]*)\}/) { - # this is a {} construct - ($before, $contents, $after) = ($`, $1, $'); - # protect spaces - $contents =~ s/\s+/$;9/g; - # restore $_ protecting {} - $_ = "$before$;7$contents$;8$after"; - } - @args = split(/\s+/, &protect_html($_)); - foreach (@args) { - s/$;9/ /g; # unprotect spaces - s/$;7/\{/g; # ... { - s/$;8/\}/g; # ... } - } - $type = shift(@args); - $type =~ s/^\{(.*)\}$/$1/; - print "# def ($tag): {$type} ", join(', ', @args), "\n" - if $debug & $DEBUG_DEF; - $type .= ':'; # it's nicer like this - $name = shift(@args); - $name =~ s/^\{(.*)\}$/$1/; - if ($is_extra) { - $_ = &debug("

", __LINE__); - } else { - $_ = &debug("
\n
", __LINE__); - } - if ($tag eq 'deffn' || $tag eq 'defvr' || $tag eq 'deftp') { - $_ .= "$type $name"; - $_ .= " @args" if @args; - } elsif ($tag eq 'deftypefn' || $tag eq 'deftypevr' - || $tag eq 'defcv' || $tag eq 'defop') { - $ftype = $name; - $name = shift(@args); - $name =~ s/^\{(.*)\}$/$1/; - $_ .= "$type $ftype $name"; - $_ .= " @args" if @args; - } else { - warn "$ERROR Unknown definition type: $tag\n"; - $_ .= "$type $name"; - $_ .= " @args" if @args; - } - $_ .= &debug("\n
", __LINE__); - $name = &unprotect_html($name); - if ($tag eq 'deffn' || $tag eq 'deftypefn') { - unshift(@input_spool, "\@findex $name\n"); - } elsif ($tag eq 'defop') { - unshift(@input_spool, "\@findex $name on $ftype\n"); - } elsif ($tag eq 'defvr' || $tag eq 'deftypevr' || $tag eq 'defcv') { - unshift(@input_spool, "\@vindex $name\n"); - } else { - unshift(@input_spool, "\@tindex $name\n"); - } - $dont_html = 1; - } - } elsif ($end_tag) { - if ($format_map{$end_tag}) { - $in_pre = 0 if $format_map{$end_tag} eq 'PRE'; - $in_list-- if $format_map{$end_tag} eq 'UL' || $format_map{$end_tag} eq 'OL' ; - &html_pop_if('LI', 'P'); - &html_pop_if(); - push(@lines, &debug("\n", __LINE__)); - push(@lines, &html_debug("\n", __LINE__)); - } elsif ($end_tag eq 'table' || - $end_tag eq 'ftable' || - $end_tag eq 'vtable') { - shift(@tables); - if (@tables) { - ($table_type, $in_table) = split($;, $tables[0]); - } else { - $in_table = 0; - $table_type = ''; - } - push(@lines, "
\n"); - &html_pop_if('DD'); - &html_pop_if(); - } elsif ($end_tag eq 'multitable') { - print "# end of multitable with $multitable_cols columns\n" - if $debug and $DEBUG_USER; - $in_multitable = 0; - push(@lines, "\n"); - &html_pop_if('TR'); - push(@lines, "
\n"); -&html_pop_if('TABLE'); - } elsif (defined($def_map{$end_tag})) { - push(@lines, &debug("
\n", __LINE__)); - } elsif ($end_tag eq 'menu') { - &html_pop_if(); - push(@lines, $_); # must keep it for pass 2 - } - next; - } - # - # misc things - # - # protect texi and HTML things - &protect_texi; - $_ = &protect_html($_) unless $dont_html; - $dont_html = 0; - # substitution (unsupported things) - s/^\s*\@center\s+//g; - s/^\s*\@exdent\s+//g; - s/\@noindent\s+//g; - s/\@refill\s+//g; - # other substitutions - &simple_substitutions; - s/\@value{($VARRE)}/$value{$1}/eg; - s/\@footnote\{/\@footnote$docu_doc\{/g; # mark footnotes, cf. pass 4 - s/(^|\s+)\@tab\s*/ <\/TD> /g if ($in_multitable); - - # - # analyze the tag again - # - if ($tag) { - if (defined($sec2level{$tag}) && $sec2level{$tag} > 0) { - if (/^\s*\@$tag\s+(.+)$/) { - $name = $1; - $name =~ s/\s+$//; - $level = $sec2level{$tag}; - $name = &update_sec_num($tag, $level) . " $name" - if $number_sections && $tag !~ /^unnumbered/ && $tag ne 'subsubheading'; - if ($tag =~ /heading$/) { - push(@lines, &html_debug("\n", __LINE__)); - if ($html_element ne 'body') { - # We are in a nice pickle here. We are trying to get a H? heading - # even though we are not in the body level. So, we convert - # it to a nice, bold, line by itself. - $_ = &debug("\n\n

$name

\n\n", __LINE__); - } else { - $_ = &debug("$name\n", __LINE__); - &html_push_if('body'); - } - print "# heading, section $name, level $level\n" - if $debug & $DEBUG_TOC; - } else { - if ($split_chapter) { - unless ($toplevel) { - # first time we see a "section" - unless ($level == 1) { - warn "$ERROR The first section found is not of level 1: $_"; - warn "$ERROR I'll split on sections of level $level...\n"; - } - $toplevel = $level; - }; - if ($level == $toplevel) { - print "# Splitting at section $name\n" - if $debug & $DEBUG_TOC; - ($doc_node_name[$doc_num + 1] = $node) =~ s|[ /]|_|g; - &next_doc; - push(@lines, $SPLITTAG) if $split_num++; - push(@sections, $name); - } - } elsif ($split_node && $opt_special_links) { - $toplevel = $level unless $toplevel; - if ($level == $toplevel) { - ($current_chapter_link = $node) =~ s|[ /]|_|g; - # Set this again to the right value. - $doc_node_name_links[$doc_num] = $current_chapter_link; - ($docu_doc, $link_doc) = &doc_name($doc_num); - } - } - $sec_num++; - # Was "SEC$sec_num" - ($docid = "$node") =~ s|[ /]|_|g; - ($tocid = "$node") =~ s|[ /]|_|g; -$docid = "SEC$sec_num" unless $docid; -$tocid = "SEC$sec_num" unless $tocid; - # check biblio and glossary - $in_bibliography = - ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*bibliography$/i); - $in_glossary = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*glossary$/i); - # check node - if ($node) { - if ($node2sec{$node}) { - warn "$ERROR Duplicate node found: $node\n"; - } else { - $node2sec{$node} = $name; - $node2href{$node} = "$link_doc#$docid"; - push(@maybe_wrong_links, $node); - print "# node $node, section $name, level $level\n" - if $debug & $DEBUG_TOC; - } - $node = ''; - } else { - print "# no node, section $name, level $level\n" - if $debug & $DEBUG_TOC; - } - # update TOC - while ($level > $curlevel) { - $curlevel++; - push(@toc_lines, "
    \n"); - } - while ($level < $curlevel) { - $curlevel--; - push(@toc_lines, "
\n"); - } - $_ = "
  • " . &anchor($tocid, "$link_doc#$docid", $name, 1); - push(@toc_lines, &substitute_style($_)); - # update DOC - push(@lines, &html_debug("\n", __LINE__)); - &html_reset; - $_ = "".&anchor($docid, $opt_empty_headers ? "" : "$docu_toc#$tocid", - $name)."\n"; - $_ = &debug($_, __LINE__); - push(@lines, &html_debug("\n", __LINE__)); - } - # update DOC - foreach $line (split(/\n+/, $_)) { - push(@lines, "$line\n"); - } - next; - } else { - warn "$ERROR Bad section line: $_"; - } - } else { - # track variables - $value{$1} = $2, next if /^\s*\@set\s+($VARRE)\s+(.*)$/o; - delete $value{$1}, next if /^\s*\@clear\s+($VARRE)\s*$/o; - # store things - $value{'_setfilename'} = $1, next if /^\s*\@setfilename\s+(.*)$/; - $value{'_settitle'} = $1, next if /^\s*\@settitle\s+(.*)$/; - $value{'_author'} .= "$1\n", next if /^\s*\@author\s+(.*)$/; - $value{'_subtitle'} .= "$1\n", next if /^\s*\@subtitle\s+(.*)$/; - $value{'_title'} .= "$1\n", next if /^\s*\@title\s+(.*)$/; - # index - if (/^\s*\@(..?)index\s+/) { - unless ($valid_index{$1}) { - warn "$ERROR Undefined index command: $_"; - next; - } - $id = 'IDX' . ++$idx_num; - $index = $1 . 'index'; - $what = &substitute_style($'); - $what =~ s/\s+$//; - print "# found $index for '$what' id $id\n" - if $debug & $DEBUG_INDEX; - eval(<\n", __LINE__)); - push(@lines, &anchor($id, '', $invisible_mark, !$in_pre)); - &html_push('P'); - } elsif ($html_element eq 'DL' || - $html_element eq 'UL' || - $html_element eq 'OL' || - $html_element eq 'TR') { - $deferred_ref .= - &anchor($id, '', $invisible_mark, !$in_pre) . " "; - } - next; - } - # list item - if (/^\s*\@itemx?\s+/) - { - $what = $'; - $what =~ s/\s+$//; - - # add an index before the item if applicable - if ($table_type ne '' && !$in_multitable) { - print "# Adding table index (type $table_type) for $what\n" - if $debug & $DEBUG_INDEX; - # This is realy ugly. We should do a pass before this to - # add index entrys before instead. - if ($global_added_this_index) { - $global_added_this_index = 0; - } else { - unshift(@input_spool, "\@${table_type}index $what\n", $_); - $global_added_this_index = 1; - next READ_LINE; - } - } - - if ($in_bibliography && $use_bibliography) { - if ($what =~ /^$BIBRE$/o) { - $id = 'BIB' . ++$bib_num; - $bib2href{$what} = "$link_doc#$id"; - print "# found bibliography for '$what' id $id\n" - if $debug & $DEBUG_BIB; - $what = &anchor($id, '', $what); - } - } elsif ($in_glossary && $use_glossary) { - $id = 'GLOSS' . ++$gloss_num; - $entry = $what; - $entry =~ tr/A-Z/a-z/ unless $entry =~ /^[A-Z\s]+$/; - $gloss2href{$entry} = "$link_doc#$id"; - print "# found glossary for '$entry' id $id\n" - if $debug & $DEBUG_GLOSS; - $what = &anchor($id, '', $what); - } - if ($in_multitable) - { - # All this is a **HACK**. - # It does only work for a FEW SIMPLE CASES !!! - push(@lines, &debug("\n", __LINE__)) - unless $html_element eq 'TABLE'; - &html_pop_if('TR'); - $what =~ s/(^|\s+)\@tab\s*/ <\/TD> /g; - push(@lines, &debug("$what\n", __LINE__)); - &html_push('TR'); - if ($deferred_ref) - { - push(@lines, &debug("$deferred_ref\n", __LINE__)); - $deferred_ref = ''; - } - next; - } - else - { - &html_pop_if('P'); - if ($html_element eq 'DL' || $html_element eq 'DD') { - if ($things_map{$in_table} && !$what) { - # special case to allow @table @bullet for instance - push(@lines, &debug("
    $things_map{$in_table}\n", __LINE__)); - } else { - push(@lines, &debug("
    \@$in_table\{$what\}\n", __LINE__)); - } - push(@lines, "
    "); - &html_push('DD') unless $html_element eq 'DD'; - # Old index add was here - } else { - push(@lines, &debug("
  • $what\n", __LINE__)); - &html_push('LI') unless $html_element eq 'LI'; - } - push(@lines, &html_debug("\n", __LINE__)); - if ($deferred_ref) { - push(@lines, &debug("$deferred_ref\n", __LINE__)); - $deferred_ref = ''; - } - next; - } - } - } - } - # paragraph separator - if ($_ eq "\n") { - next if $#lines >= 0 && $lines[$#lines] eq "\n"; - if ($html_element eq 'P') { - push(@lines, "\n"); - $_ = &debug("

    \n", __LINE__); - &html_pop; - } - } elsif ($html_element eq 'body' || $html_element eq 'BLOCKQUOTE') { - push(@lines, "

    \n"); - &html_push('P'); - $_ = &debug($_, __LINE__); - } - # otherwise - push(@lines, $_); -} - -# finish TOC -$level = 0; -while ($level < $curlevel) -{ - $curlevel--; - push(@toc_lines, "\n"); -} - -print "# end of pass 1\n" if $verbose; - -#+++############################################################################ -# # -# Pass 2/3: handle style, menu, index, cross-reference # -# # -#---############################################################################ - -@lines2 = (); # whole document (2nd pass) -@lines3 = (); # whole document (3rd pass) -$in_menu = 0; # am I inside a menu - -while (@lines) -{ - $_ = shift(@lines); - # - # special case (protected sections) - # - if (/^$PROTECTTAG/o) { - push(@lines2, $_); - next; - } - # - # menu - # - $in_menu = 1, push(@lines2, &debug("

      \n", __LINE__)), next if /^\s*\@menu\b/; - $in_menu = 0, push(@lines2, &debug("
    \n", __LINE__)), next if /^\s*\@end\s+menu\b/; - if ($in_menu) { - if (/^\*\s+($NODERE)::/o) { - $descr = $'; - chop($descr); - &menu_entry($1, $1, $descr); - } elsif (/^\*\s+(.+):\s+([^\t,\.\n]+)[\t,\.\n]/) { - $descr = $'; - chop($descr); - &menu_entry($1, $2, $descr); - } elsif (/^\*/) { - warn "$ERROR Bad menu line: $_"; - } else { # description continued? - push(@lines2, $_); - } - next; - } - # - # printindex - # - if (/^\s*\@printindex\s+(\w\w)\b/) { - local($index, *ary, @keys, $key, $letter, $last_letter, @refs); - if ($predefined_index{$1}) { - $index = $predefined_index{$1} . 'index'; - } else { - $index = $1 . 'index'; - } - eval("*ary = *$index"); - @keys = keys(%ary); - foreach $key (@keys) { - $_ = $key; - 1 while s/<(\w+)>\`(.*)\'<\/\1>/$2/; # remove HTML tags with quotes - 1 while s/<(\w+)>(.*)<\/\1>/$2/; # remove HTML tags - $_ = &unprotect_html($_); - &unprotect_texi; - tr/A-Z/a-z/; # lowercase - $key2alpha{$key} = $_; - print "# index $key sorted as $_\n" - if $key ne $_ && $debug & $DEBUG_INDEX; - } - $last_letter = undef; - foreach $key (sort byalpha @keys) { - $letter = substr($key2alpha{$key}, 0, 1); - $letter = substr($key2alpha{$key}, 0, 2) if $letter eq $;; - $letter = " " unless $letter =~ /[a-zA-Z]/; - if (!defined($last_letter) || $letter ne $last_letter) { - push(@lines2, "
  • \n") if defined($last_letter); - push(@lines2, "

    " . &protect_html(uc($letter)) . "

    \n"); - push(@lines2, "\n"); - $last_letter = $letter; - } - @refs = (); - foreach (split(/$;/, $ary{$key})) { - push(@refs, &anchor('', $_, $key, 0)); - } - push(@lines2, "
  • " . join(", ", @refs) . "\n"); - } - push(@lines2, "
  • \n") if defined($last_letter); - next; - } - # - # simple style substitutions - # - $_ = &substitute_style($_); - # - # xref - # - while (/\@(x|px|info|)ref{($XREFRE)(}?)/o) { - # note: Texinfo may accept other characters - ($type, $nodes, $full) = ($1, $2, $3); - ($before, $after) = ($`, $'); - if (! $full && $after) { - warn "$ERROR Bad xref (no ending } on line): $_"; - $_ = "$before$;0${type}ref\{$nodes$after"; - next; # while xref - } - if ($type eq 'x') { - $type = 'See '; - } elsif ($type eq 'px') { - $type = 'see '; - } elsif ($type eq 'info') { - $type = 'See Info'; - } elsif ($type eq 'u') { - $type = 'See '; - } else { - $type = ''; - } - unless ($full) { - $next = shift(@lines); - $next = &substitute_style($next); - chop($nodes); # remove final newline - if ($next =~ /\}/) { # split on 2 lines - $nodes .= " $`"; - $after = $'; - } else { - $nodes .= " $next"; - $next = shift(@lines); - $next = &substitute_style($next); - chop($nodes); - if ($next =~ /\}/) { # split on 3 lines - $nodes .= " $`"; - $after = $'; - } else { - warn "$ERROR Bad xref (no ending }): $_"; - $_ = "$before$;0xref\{$nodes$after"; - unshift(@lines, $next); - next; # while xref - } - } - } - $nodes =~ s/\s+/ /g; # remove useless spaces - @args = split(/\s*,\s*/, $nodes); - $node = $args[0]; # the node is always the first arg - &normalise_node($node); - $sec = $node2sec{$node}; - if (@args == 5) { # reference to another manual - $sec = $args[2] || $node; - $man = $args[4] || $args[3]; - $_ = "${before}${type}section `$sec' in \@cite{$man}$after"; - } elsif ($type =~ /Info/) { # inforef - warn "$ERROR Wrong number of arguments: $_" unless @args == 3; - ($nn, $_, $in) = @args; - $_ = "${before}${type} file `$in', node `$nn'$after"; - } elsif ($sec) { - $href = $node2href{$node}; - $_ = "${before}${type}section " . &anchor('', $href, $sec) . $after; - } else { - warn "$ERROR Undefined node ($node): $_"; - $_ = "$before$;0xref{$nodes}$after"; - } - } - # - # try to guess bibliography references or glossary terms - # - # This checked for NAME="SEC\d". The current version is probably broken. - unless (/^/) { - $done .= $pre . &anchor('', $href, $what); - } else { - $done .= "$pre$what"; - } - $_ = $post; - } - $_ = $done . $_; - } - if ($use_glossary) { - $done = ''; - while (/\b\w+\b/) { - ($pre, $what, $post) = ($`, $&, $'); - $entry = $what; - $entry =~ tr/A-Z/a-z/ unless $entry =~ /^[A-Z\s]+$/; - $href = $gloss2href{$entry}; - if (defined($href) && $post !~ /^[^<]*<\/A>/) { - $done .= $pre . &anchor('', $href, $what); - } else { - $done .= "$pre$what"; - } - $_ = $post; - } - $_ = $done . $_; - } - } - # otherwise - push(@lines2, $_); -} -print "# end of pass 2\n" if $verbose; - -# -# split style substitutions -# -while (@lines2) -{ - $_ = shift(@lines2); - # - # special case (protected sections) - # - if (/^$PROTECTTAG/o) { - push(@lines3, $_); - next; - } - # - # split style substitutions - # - $old = ''; - while ($old ne $_) { - $old = $_; - if (/\@(\w+)\{/) { - ($before, $style, $after) = ($`, $1, $'); - if (defined($style_map{$style})) { - $_ = $after; - $text = ''; - $after = ''; - $failed = 1; - while (@lines2) { - if (/\}/) { - $text .= $`; - $after = $'; - $failed = 0; - last; - } else { - $text .= $_; - $_ = shift(@lines2); - } - } - if ($failed) { - die "* Bad syntax (\@$style) after: $before\n"; - } else { - $text = &apply_style($style, $text); - $_ = "$before$text$after"; - } - } - } - } - # otherwise - push(@lines3, $_); -} -print "# end of pass 3\n" if $verbose; - -#+++############################################################################ -# # -# Pass 4: foot notes, final cleanup # -# # -#---############################################################################ - -@foot_lines = (); # footnotes -@doc_lines = (); # final document -$end_of_para = 0; # true if last line is

    - -while (@lines3) -{ - $_ = shift(@lines3); - # - # special case (protected sections) - # - if (/^$PROTECTTAG/o) { - push(@doc_lines, $_); - $end_of_para = 0; - next; - } - # - # footnotes - # - while (/\@footnote([^\{\s]+)\{/) { - ($before, $d, $after) = ($`, $1, $'); - $_ = $after; - $text = ''; - $after = ''; - $failed = 1; - while (@lines3) { - if (/\}/) { - $text .= $`; - $after = $'; - $failed = 0; - last; - } else { - $text .= $_; - $_ = shift(@lines3); - } - } - if ($failed) { - die "* Bad syntax (\@footnote) after: $before\n"; - } else { - $foot_num++; - $docid = "DOCF$foot_num"; - $footid = "FOOT$foot_num"; - $foot = "($foot_num)"; - push(@foot_lines, "

    " . &anchor($footid, "$d#$docid", $foot) . "

    \n"); - $text = "

    $text" unless $text =~ /^\s*

    /; - push(@foot_lines, "$text\n"); - $_ = $before . &anchor($docid, "$docu_foot#$footid", $foot) . $after; - } - } - # - # remove unnecessary

    - # - if (/^\s*

    \s*$/) { - next if $end_of_para++; - } else { - $end_of_para = 0; - } - # otherwise - push(@doc_lines, $_); -} -print "# end of pass 4\n" if $verbose; - -#+++############################################################################ -# # -# Pass 5: print things # -# # -#---############################################################################ - - $header = ''; - $full_title = $value{'_title'} || $value{'_settitle'} || "Untitled Document"; - $title = $value{'_settitle'} || $full_title; - $_ = &substitute_style($full_title); - &unprotect_texi; - s/\n$//; # rmv last \n (if any) - $full_title = "

    " . join("

    \n

    ", split(/\n/, $_)) . "

    \n"; - -# -# print ToC -# -if (!$monolithic && @toc_lines) -{ - if (open(FILE, "> $docu_toc")) { - print "# creating $docu_toc...\n" if $verbose; - &print_toplevel_header("$title - Table of Contents"); - &print_ruler; - &print(*toc_lines, FILE); - &print_toplevel_footer; - close(FILE); - } else { - warn "$ERROR Can't write (toc) to $docu_toc: $!\n"; - } -} - -# -# print footnotes -# -if (!$monolithic && @foot_lines) -{ - if (open(FILE, "> $docu_foot")) { - print "# creating $docu_foot...\n" if $verbose; - &print_toplevel_header("$title - Footnotes"); - &print_ruler; - &print(*foot_lines, FILE); - &print_toplevel_footer; - close(FILE); - } else { - warn "$ERROR Can't write (foot) to $docu_foot: $!\n"; - } -} - -# -# print document -# - -if ($split_chapter || $split_node) -{ # split - $doc_num = 0; - $last_num = scalar(@sections); - $first_doc = &doc_name(1); - $last_doc = &doc_name($last_num); - while (@sections) { - $section = shift(@sections); - &next_doc; - # Remove added links part - if (open(FILE, ">$docu_doc")) { - print "# creating $docu_doc... ($section)\n" if $verbose; - &print_header("$title - $section") unless $opt_empty_headers; - $prev_doc = ($doc_num == 1 ? undef : &doc_name($doc_num - 1)); - $next_doc = ($doc_num == $last_num ? undef : &doc_name($doc_num + 1)); - $navigation = "Go to the "; - $navigation .= ($prev_doc ? &anchor('', $first_doc, "first") : "first"); - $navigation .= ", "; - $navigation .= ($prev_doc ? &anchor('', $prev_doc, "previous") : "previous"); - $navigation .= ", "; - $navigation .= ($next_doc ? &anchor('', $next_doc, "next") : "next"); - $navigation .= ", "; - $navigation .= ($next_doc ? &anchor('', $last_doc, "last") : "last"); - $navigation .= " section, " . &anchor('', $docu_toc, "table of contents") . ".\n"; - print FILE $navigation unless $opt_empty_headers; - &print_ruler unless $opt_empty_headers; - # find corresponding lines - @tmp_lines = (); - while (@doc_lines) { - $_ = shift(@doc_lines); - last if ($_ eq $SPLITTAG); - push(@tmp_lines, $_); - } - &print(*tmp_lines, FILE); - &print_ruler unless $opt_empty_headers; - print FILE $navigation unless $opt_empty_headers; - &print_footer unless $opt_empty_headers; - close(FILE); - } else { - warn "$ERROR Can't write (doc) to $docu_doc: $!\n"; - } - } -} -else -{ # not split - if (open(FILE, ">$docu_doc")) { - print "# creating $docu_doc...\n" if $verbose; - if ($monolithic || !@toc_lines) { - &print_toplevel_header($title); - } else { - &print_header($title); - print FILE $full_title; - } - if ($monolithic && @toc_lines) { - &print_ruler; - print FILE "

    Table of Contents

    \n"; - &print(*toc_lines, FILE); - } - &print_ruler; - &print(*doc_lines, FILE); - if ($monolithic && @foot_lines) { - &print_ruler; - print FILE "

    Footnotes

    \n"; - &print(*foot_lines, FILE); - } - if ($monolithic || !@toc_lines) { - &print_toplevel_footer; - } else { - &print_footer; - } - close(FILE); - } else { - warn "$ERROR Can't write (doc2) to $docu_doc: $!\n"; - } -} - -print "# that's all folks\n" if $verbose; - -#+++############################################################################ -# # -# Low level functions # -# # -#---############################################################################ - -sub update_sec_num -{ - local($name, $level) = @_; - - $level--; # here we start at 0 - if ($name =~ /^appendix/) { - # appendix style - if (defined(@appendix_sec_num)) { - &incr_sec_num($level, @appendix_sec_num); - } else { - @appendix_sec_num = ('A', 0, 0, 0); - } - return(join('.', @appendix_sec_num[0..$level])); - } else { - # normal style - if (defined(@normal_sec_num)) { - &incr_sec_num($level, @normal_sec_num); - } else { - @normal_sec_num = (1, 0, 0, 0); - } - return(join('.', @normal_sec_num[0..$level])); - } -} - -sub incr_sec_num -{ - local($level, $l); - $level = shift(@_); - $_[$level]++; - foreach $l ($level+1 .. 3) { - $_[$l] = 0; - } -} - -sub check -{ - local($_, %seen, %context, $before, $match, $after); - - while (<>) { - if (/\@(\*|\.|\:|\@|\{|\})/) { - $seen{$&}++; - $context{$&} .= "> $_" if $verbose; - $_ = "$`XX$'"; - redo; - } - if (/\@(\w+)/) { - ($before, $match, $after) = ($`, $&, $'); - if ($before =~ /\b[\w-]+$/ && $after =~ /^[\w-.]*\b/) { # e-mail address - $seen{'e-mail address'}++; - $context{'e-mail address'} .= "> $_" if $verbose; - } else { - $seen{$match}++; - $context{$match} .= "> $_" if $verbose; - } - $match =~ s/^\s*\@/X/; - $_ = "$before$match$after"; - redo; - } - } - - foreach (sort(keys(%seen))) { - if ($verbose) { - print "$_\n"; - print $context{$_}; - } else { - print "$_ ($seen{$_})\n"; - } - } -} - -sub open -{ - local($name) = @_; - - ++$fh_name; - if (open($fh_name, $name)) { - unshift(@fhs, $fh_name); - } else { - warn "$ERROR Can't read file $name: $!\n"; - } -} - -sub init_input -{ - @fhs = (); # hold the file handles to read - @input_spool = (); # spooled lines to read - $fh_name = 'FH000'; - &open($docu); -} - -sub next_line -{ - local($fh, $line); - - if (@input_spool) { - $line = shift(@input_spool); - return($line); - } - while (@fhs) { - $fh = $fhs[0]; - $line = <$fh>; - return($line) if $line; - close($fh); - shift(@fhs); - } - return(undef); -} - -# used in pass 1, use &next_line -sub skip_until -{ - local($tag) = @_; - local($_); - - while ($_ = &next_line) { - return if /^\s*\@end\s+$tag\s*$/; - } - die "* Failed to find '$tag' after: " . $lines[$#lines]; -} - -# -# HTML stacking to have a better HTML output -# - -sub html_reset -{ - @html_stack = ('html'); - $html_element = 'body'; -} - -sub html_push -{ - local($what) = @_; - push(@html_stack, $html_element); - $html_element = $what; -} - -sub html_push_if -{ - local($what) = @_; - push(@html_stack, $html_element) - if ($html_element && $html_element ne 'P'); - $html_element = $what; -} - -sub html_pop -{ - $html_element = pop(@html_stack); -} - -sub html_pop_if -{ - local($elt); - - if (@_) { - foreach $elt (@_) { - if ($elt eq $html_element) { - $html_element = pop(@html_stack) if @html_stack; - last; - } - } - } else { - $html_element = pop(@html_stack) if @html_stack; - } -} - -sub html_debug -{ - local($what, $line) = @_; - return("$what") - if $debug & $DEBUG_HTML; - return($what); -} - -# to debug the output... -sub debug -{ - local($what, $line) = @_; - return("$what") - if $debug & $DEBUG_HTML; - return($what); -} - -sub normalise_node -{ - $_[0] =~ s/\s+/ /g; - $_[0] =~ s/ $//; - $_[0] =~ s/^ //; -} - -sub menu_entry -{ - local($entry, $node, $descr) = @_; - local($href); - - &normalise_node($node); - $href = $node2href{$node}; - if ($href) { - $descr =~ s/^\s+//; - $descr = ": $descr" if $descr; - push(@lines2, "
  • " . &anchor('', $href, $entry) . "$descr\n"); - } else { - warn "$ERROR Undefined node ($node): $_"; - } -} - -sub do_ctrl { "^$_[0]" } - -sub do_sc { "\U$_[0]\E" } - -sub fix_image -{ - my($text) = @_; - my($arg1, $ext); - $text =~ /^([^,]*)/; - die "error in image: '$text'" unless defined($1); - $arg1 = $1; - $arg1 =~ s/@@/@/g; - foreach (@include_dirs) { - $ext = "jpg" if -f "$_/$arg1.jpg"; - $ext = "gif" if -f "$_/$arg1.gif"; - } - if (defined($ext)) - { - ""; - } - else - { - warn "Image $arg1 not found"; - ""; - } -} - -sub fix_url -{ - my($text) = @_; - $text =~ s/@@/@/g; - $text; -} - -sub fix_uref -{ - my($text) = @_; - my($arg1, $arg2); - $text =~ /^([^,]*),?([^,]*)?$/; - die "error in uref: '$text'" unless defined($1); - $arg1 = $1; - $arg2 = (defined($2) && $2) ? $2 : $arg1; - $arg1 =~ s/@@/@/g; - $arg2 =~ s/@@/@/g; - "$arg2"; -} - -sub fix_email -{ - my($text) = @_; - my($arg1, $arg2); - $text =~ /^([^,]*)(,[^,]*)?$/; - die "error in email: '$text'" unless defined($1); - $arg1 = $1; - $arg2 = defined($2) ? $2 : $arg1; - $arg1 =~ s/@@/@/g; - $arg2 =~ s/@@/@/g; - "$arg2"; -} - -sub apply_style -{ - local($texi_style, $text) = @_; - local($style); - - $style = $style_map{$texi_style}; - if (defined($style)) { # known style - if ($style =~ /^\"/) { # add quotes - $style = $'; - $text = "\`$text\'"; - } - if ($style =~ /^\&/) { # custom - $style = $'; - $text = &$style($text); - } elsif ($style) { # good style - $text = "<$style>$text"; - } else { # no style - } - } else { # unknown style - $text = undef; - } - return($text); -} - -# remove Texinfo styles -sub remove_style -{ - local($_) = @_; - s/\@\w+{([^\{\}]+)}/$1/g; - return($_); -} - -sub substitute_style -{ - local($_) = @_; - local($changed, $done, $style, $text); - - $changed = 1; - while ($changed) { - $changed = 0; - $done = ''; - while (/\@(\w+){([^\{\}]+)}/) { - $text = &apply_style($1, $2); - if ($text) { - $_ = "$`$text$'"; - $changed = 1; - } else { - $done .= "$`\@$1"; - $_ = "{$2}$'"; - } - } - $_ = $done . $_; - } - return($_); -} - -sub anchor -{ - local($name, $href, $text, $newline) = @_; - local($result); - - $result = "

    \n"; -} - -sub print_header -{ - local($_); - - # clean the title - $_ = &remove_style($_[0]); - &unprotect_texi; - # print the header - if ($doctype eq 'html2') { - print FILE $html2_doctype; - } elsif ($doctype) { - print FILE $doctype; - } - my($tags) = defined($value{"_body_tags"}) ? " " . $value{"_body_tags"} : ""; - my($et) = defined($value{"_extra_head"}) ? " " . $value{"_extra_head"} : ""; - $et = &unprotect_html($et); - print FILE < - - $header - $_ - $et - - -EOT -} - -sub print_toplevel_header -{ - local($_); - - &print_header unless $opt_empty_headers; # pass given arg... - print FILE $full_title; - if ($value{'_subtitle'}) { - $value{'_subtitle'} =~ s/\n+$//; - foreach (split(/\n/, $value{'_subtitle'})) { - $_ = &substitute_style($_); - &unprotect_texi; - print FILE "

    $_

    \n"; - } - } - if ($value{'_author'}) { - $value{'_author'} =~ s/\n+$//; - foreach (split(/\n/, $value{'_author'})) { - $_ = &substitute_style($_); - &unprotect_texi; - s/[\w.-]+\@[\w.-]+/$&<\/A>/g; - print FILE "
    $_
    \n"; - } - } - print FILE "

    \n"; -} - -sub print_footer -{ - print FILE < - -EOT -} - -sub print_toplevel_footer -{ - &print_footer unless $opt_empty_headers; -} - -sub protect_texi -{ - # protect @ { } ` ' - s/\@\@/$;0/go; - s/\@\{/$;1/go; - s/\@\}/$;2/go; - s/\@\`/$;3/go; - s/\@\'/$;4/go; -} - -sub protect_html -{ - local($what) = @_; - # protect & < > - # hack for the two entity-like variable reference in existing examples - $what =~ s/\&(length|ts);/\&\#38;$1;/g; - # this leaves alone entities, but encodes standalone ampersands - $what =~ s/\&(?!([a-z0-9]+|#\d+);)/\&\#38;/ig; - $what =~ s/\/\&\#62;/g; - # but recognize some HTML things - $what =~ s/\&\#60;\/A\&\#62;/<\/A>/g; # - $what =~ s/\&\#60;A ([^\&]+)\&\#62;//g; # - $what =~ s/\&\#60;IMG ([^\&]+)\&\#62;//g; # - return($what); -} - -sub unprotect_texi -{ - s/$;0/\@/go; - s/$;1/\{/go; - s/$;2/\}/go; - s/$;3/\`/go; - s/$;4/\'/go; -} - -sub unprotect_html -{ - local($what) = @_; - $what =~ s/\&\#38;/\&/g; - $what =~ s/\&\#60;/\/g; - return($what); -} - -sub byalpha -{ - $key2alpha{$a} cmp $key2alpha{$b}; -} - -############################################################################## - - # These next few lines are legal in both Perl and nroff. - - .00 ; # finish .ig - - 'di \" finish diversion--previous line must be blank -.nr nl 0-1 \" fake up transition to first page again -.nr % 0 \" start at page 1 -'; __END__ ############# From here on it's a standard manual page ############ -.TH TEXI2HTML 1 "09/10/96" -.AT 3 -.SH NAME -texi2html \- a Texinfo to HTML converter -.SH SYNOPSIS -.B texi2html [options] file -.PP -.B texi2html -check [-verbose] files -.SH DESCRIPTION -.I Texi2html -converts the given Texinfo file to a set of HTML files. It tries to handle -most of the Texinfo commands. It creates hypertext links for cross-references, -footnotes... -.PP -It also tries to add links from a reference to its corresponding entry in the -bibliography (if any). It may also handle a glossary (see the -.B \-glossary -option). -.PP -.I Texi2html -creates several files depending on the contents of the Texinfo file and on -the chosen options (see FILES). -.PP -The HTML files created by -.I texi2html -are closer to TeX than to Info, that's why -.I texi2html -converts @iftex sections and not @ifinfo ones by default. You can reverse -this with the \-expandinfo option. -.SH OPTIONS -.TP 12 -.B \-check -Check the given file and give the list of all things that may be Texinfo commands. -This may be used to check the output of -.I texi2html -to find the Texinfo commands that have been left in the HTML file. -.TP -.B \-expandinfo -Expand @ifinfo sections, not @iftex ones. -.TP -.B \-glossary -Use the section named 'Glossary' to build a list of terms and put links in the HTML -document from each term toward its definition. -.TP -.B \-invisible \fIname\fP -Use \fIname\fP to create invisible destination anchors for index links. This is a workaround -for a known bug of many WWW browsers, including xmosaic. -.TP -.B \-I \fIdir\fP -Look also in \fIdir\fP to find included files. -.TP -.B \-menu -Show the Texinfo menus; by default they are ignored. -.TP -.B \-monolithic -Output only one file, including the table of contents and footnotes. -.TP -.B \-number -Number the sections. -.TP -.B \-split_chapter -Split the output into several HTML files (one per main section: -chapter, appendix...). -.TP -.B \-split_node -Split the output into several HTML files (one per node). -.TP -.B \-usage -Print usage instructions, listing the current available command-line options. -.TP -.B \-verbose -Give a verbose output. Can be used with the -.B \-check -option. -.PP -.SH FILES -By default -.I texi2html -creates the following files (foo being the name of the Texinfo file): -.TP 16 -.B foo_toc.html -The table of contents. -.TP -.B foo.html -The document's contents. -.TP -.B foo_foot.html -The footnotes (if any). -.PP -When used with the -.B \-split -option, it creates several files (one per chapter or node), named -.B foo_n.html -(n being the indice of the chapter or node), instead of the single -.B foo.html -file. -.PP -When used with the -.B \-monolithic -option, it creates only one file: -.B foo.html -.SH VARIABLES -.I texi2html -predefines the following variables: \fBhtml\fP, \fBtexi2html\fP. -.SH ADDITIONAL COMMANDS -.I texi2html -implements the following non-Texinfo commands: -.TP 16 -.B @ifhtml -This indicates the start of an HTML section, this section will passed through -without any modofication. -.TP -.B @end ifhtml -This indcates the end of an HTML section. -.SH VERSION -This is \fItexi2html\fP version 1.52, 09/10/96. -.PP -The latest version of \fItexi2html\fP can be found in WWW, cf. URL -http://wwwcn.cern.ch/dci/texi2html/ -.SH AUTHOR -The main author is Lionel Cons, CERN CN/DCI/UWS, Lionel.Cons@cern.ch. -Many other people around the net contributed to this program. -.SH COPYRIGHT -This program is the intellectual property of the European -Laboratory for Particle Physics (known as CERN). No guarantee whatsoever is -provided by CERN. No liability whatsoever is accepted for any loss or damage -of any kind resulting from any defect or inaccuracy in this information or -code. -.PP -CERN, 1211 Geneva 23, Switzerland -.SH "SEE ALSO" -GNU Texinfo Documentation Format, -HyperText Markup Language (HTML), -World Wide Web (WWW). -.SH BUGS -This program does not understand all Texinfo commands (yet). -.PP -TeX specific commands (normally enclosed in @iftex) will be -passed unmodified. -.ex diff --git a/Docs/Support/texinfo.tex b/Docs/Support/texinfo.tex deleted file mode 100644 index 3299693244b..00000000000 --- a/Docs/Support/texinfo.tex +++ /dev/null @@ -1,5868 +0,0 @@ -% texinfo.tex -- TeX macros to handle Texinfo files. -% -% Load plain if necessary, i.e., if running under initex. -\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi -% -\def\texinfoversion{1999-05-25.6}% -% -% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 -% Free Software Foundation, Inc. -% -% This texinfo.tex file 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; either version 2, or (at -% your option) any later version. -% -% This texinfo.tex file 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 texinfo.tex file; see the file COPYING. If not, write -% to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -% Boston, MA 02111-1307, USA. -% -% In other words, you are welcome to use, share and improve this program. -% You are forbidden to forbid anyone else to use, share and improve -% what you give them. Help stamp out software-hoarding! -% -% Please try the latest version of texinfo.tex before submitting bug -% reports; you can get the latest version from: -% ftp://ftp.gnu.org/pub/gnu/texinfo.tex -% (and all GNU mirrors, see http://www.gnu.org/order/ftp.html) -% ftp://tug.org/tex/texinfo.tex -% ftp://ctan.org/macros/texinfo/texinfo.tex -% (and all CTAN mirrors, finger ctan@ctan.org for a list). -% /home/gd/gnu/doc/texinfo.tex on the GNU machines. -% The texinfo.tex in any given Texinfo distribution could well be out -% of date, so if that's what you're using, please check. -% There is a small home page for Texinfo at http://texinfo.org/. -% -% Send bug reports to bug-texinfo@gnu.org. Please include including a -% complete document in each bug report with which we can reproduce the -% problem. Patches are, of course, greatly appreciated. -% -% To process a Texinfo manual with TeX, it's most reliable to use the -% texi2dvi shell script that comes with the distribution. For a simple -% manual foo.texi, however, you can get away with this: -% tex foo.texi -% texindex foo.?? -% tex foo.texi -% tex foo.texi -% dvips foo.dvi -o # or whatever, to process the dvi file; this makes foo.ps. -% The extra runs of TeX get the cross-reference information correct. -% Sometimes one run after texindex suffices, and sometimes you need more -% than two; texi2dvi does it as many times as necessary. -% -% It is possible to adapt texinfo.tex for other languages. You can get -% the existing language-specific files from ftp://ftp.gnu.org/gnu/texinfo/. - -\message{Loading texinfo [version \texinfoversion]:} - -% If in a .fmt file, print the version number -% and turn on active characters that we couldn't do earlier because -% they might have appeared in the input file name. -\everyjob{\message{[Texinfo version \texinfoversion]}% - \catcode`+=\active \catcode`\_=\active} - -% Save some parts of plain tex whose names we will redefine. -\let\ptexb=\b -\let\ptexbullet=\bullet -\let\ptexc=\c -\let\ptexcomma=\, -\let\ptexdot=\. -\let\ptexdots=\dots -\let\ptexend=\end -\let\ptexequiv=\equiv -\let\ptexexclam=\! -\let\ptexi=\i -\let\ptexlbrace=\{ -\let\ptexrbrace=\} -\let\ptexstar=\* -\let\ptext=\t - -% We never want plain's outer \+ definition in Texinfo. -% For @tex, we can use \tabalign. -\let\+ = \relax - -% Get ready for pdf. -\newif\ifpdf -\ifx\pdfoutput\undefined\else - \input pdfcolor - \pdfoutput=1 - \pdftrue -\fi - -\message{Basics,} -\chardef\other=12 - -% If this character appears in an error message or help string, it -% starts a new line in the output. -\newlinechar = `^^J - -% Set up fixed words for English if not already set. -\ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi -\ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi -\ifx\putwordfile\undefined \gdef\putwordfile{file}\fi -\ifx\putwordin\undefined \gdef\putwordin{in}\fi -\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi -\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi -\ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi -\ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi -\ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi -\ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi -\ifx\putwordof\undefined \gdef\putwordof{of}\fi -\ifx\putwordon\undefined \gdef\putwordon{on}\fi -\ifx\putwordpage\undefined \gdef\putwordpage{page}\fi -\ifx\putwordsection\undefined \gdef\putwordsection{section}\fi -\ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi -\ifx\putwordsee\undefined \gdef\putwordsee{see}\fi -\ifx\putwordSee\undefined \gdef\putwordSee{See}\fi -\ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi -\ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi -% -\ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi -\ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi -\ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi -\ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi -\ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi -\ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi -\ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi -\ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi -\ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi -\ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi -\ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi -\ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi -% -\ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi -\ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi -\ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi -\ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi -\ifx\putwordDeftypevar\undefined\gdef\putwordDeftypevar{Variable}\fi -\ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi -\ifx\putwordDeftypefun\undefined\gdef\putwordDeftypefun{Function}\fi - -% Ignore a token. -% -\def\gobble#1{} - -\hyphenation{ap-pen-dix} -\hyphenation{mini-buf-fer mini-buf-fers} -\hyphenation{eshell} -\hyphenation{white-space} - -% Margin to add to right of even pages, to left of odd pages. -\newdimen \bindingoffset -\newdimen \normaloffset -\newdimen\pagewidth \newdimen\pageheight - -% Sometimes it is convenient to have everything in the transcript file -% and nothing on the terminal. We don't just call \tracingall here, -% since that produces some useless output on the terminal. -% -\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% -\ifx\eTeXversion\undefined -\def\loggingall{\tracingcommands2 \tracingstats2 - \tracingpages1 \tracingoutput1 \tracinglostchars1 - \tracingmacros2 \tracingparagraphs1 \tracingrestores1 - \showboxbreadth\maxdimen\showboxdepth\maxdimen -}% -\else -\def\loggingall{\tracingcommands3 \tracingstats2 - \tracingpages1 \tracingoutput1 \tracinglostchars1 - \tracingmacros2 \tracingparagraphs1 \tracingrestores1 - \tracingscantokens1 \tracingassigns1 \tracingifs1 - \tracinggroups1 \tracingnesting2 - \showboxbreadth\maxdimen\showboxdepth\maxdimen -}% -\fi - -% For @cropmarks command. -% Do @cropmarks to get crop marks. -% -\newif\ifcropmarks -\let\cropmarks = \cropmarkstrue -% -% Dimensions to add cropmarks at corners. -% Added by P. A. MacKay, 12 Nov. 1986 -% -\newdimen\outerhsize \newdimen\outervsize % set by the paper size routines -\newdimen\cornerlong \cornerlong=1pc -\newdimen\cornerthick \cornerthick=.3pt -\newdimen\topandbottommargin \topandbottommargin=.75in - -% Main output routine. -\chardef\PAGE = 255 -\output = {\onepageout{\pagecontents\PAGE}} - -\newbox\headlinebox -\newbox\footlinebox - -% \onepageout takes a vbox as an argument. Note that \pagecontents -% does insertions, but you have to call it yourself. -\def\onepageout#1{% - \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi - % - \ifodd\pageno \advance\hoffset by \bindingoffset - \else \advance\hoffset by -\bindingoffset\fi - % - % Do this outside of the \shipout so @code etc. will be expanded in - % the headline as they should be, not taken literally (outputting ''code). - \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}% - \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}% - % - {% - % Have to do this stuff outside the \shipout because we want it to - % take effect in \write's, yet the group defined by the \vbox ends - % before the \shipout runs. - % - \escapechar = `\\ % use backslash in output files. - \indexdummies % don't expand commands in the output. - \normalturnoffactive % \ in index entries must not stay \, e.g., if - % the page break happens to be in the middle of an example. - \shipout\vbox{% - \ifcropmarks \vbox to \outervsize\bgroup - \hsize = \outerhsize - \vskip-\topandbottommargin - \vtop to0pt{% - \line{\ewtop\hfil\ewtop}% - \nointerlineskip - \line{% - \vbox{\moveleft\cornerthick\nstop}% - \hfill - \vbox{\moveright\cornerthick\nstop}% - }% - \vss}% - \vskip\topandbottommargin - \line\bgroup - \hfil % center the page within the outer (page) hsize. - \ifodd\pageno\hskip\bindingoffset\fi - \vbox\bgroup - \fi - % - \unvbox\headlinebox - \pagebody{#1}% - \ifdim\ht\footlinebox > 0pt - % Only leave this space if the footline is nonempty. - % (We lessened \vsize for it in \oddfootingxxx.) - % The \baselineskip=24pt in plain's \makefootline has no effect. - \vskip 2\baselineskip - \unvbox\footlinebox - \fi - % - \ifpdf\pdfmkdest{\the\pageno}\fi - % - \ifcropmarks - \egroup % end of \vbox\bgroup - \hfil\egroup % end of (centering) \line\bgroup - \vskip\topandbottommargin plus1fill minus1fill - \boxmaxdepth = \cornerthick - \vbox to0pt{\vss - \line{% - \vbox{\moveleft\cornerthick\nsbot}% - \hfill - \vbox{\moveright\cornerthick\nsbot}% - }% - \nointerlineskip - \line{\ewbot\hfil\ewbot}% - }% - \egroup % \vbox from first cropmarks clause - \fi - }% end of \shipout\vbox - }% end of group with \turnoffactive - \advancepageno - \ifnum\outputpenalty>-20000 \else\dosupereject\fi -} - -\newinsert\margin \dimen\margin=\maxdimen - -\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} -{\catcode`\@ =11 -\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi -% marginal hacks, juha@viisa.uucp (Juha Takala) -\ifvoid\margin\else % marginal info is present - \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi -\dimen@=\dp#1 \unvbox#1 -\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi -\ifr@ggedbottom \kern-\dimen@ \vfil \fi} -} - -% Here are the rules for the cropmarks. Note that they are -% offset so that the space between them is truly \outerhsize or \outervsize -% (P. A. MacKay, 12 November, 1986) -% -\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} -\def\nstop{\vbox - {\hrule height\cornerthick depth\cornerlong width\cornerthick}} -\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} -\def\nsbot{\vbox - {\hrule height\cornerlong depth\cornerthick width\cornerthick}} - -% Parse an argument, then pass it to #1. The argument is the rest of -% the input line (except we remove a trailing comment). #1 should be a -% macro which expects an ordinary undelimited TeX argument. -% -\def\parsearg#1{% - \let\next = #1% - \begingroup - \obeylines - \futurelet\temp\parseargx -} - -% If the next token is an obeyed space (from an @example environment or -% the like), remove it and recurse. Otherwise, we're done. -\def\parseargx{% - % \obeyedspace is defined far below, after the definition of \sepspaces. - \ifx\obeyedspace\temp - \expandafter\parseargdiscardspace - \else - \expandafter\parseargline - \fi -} - -% Remove a single space (as the delimiter token to the macro call). -{\obeyspaces % - \gdef\parseargdiscardspace {\futurelet\temp\parseargx}} - -{\obeylines % - \gdef\parseargline#1^^M{% - \endgroup % End of the group started in \parsearg. - % - % First remove any @c comment, then any @comment. - % Result of each macro is put in \toks0. - \argremovec #1\c\relax % - \expandafter\argremovecomment \the\toks0 \comment\relax % - % - % Call the caller's macro, saved as \next in \parsearg. - \expandafter\next\expandafter{\the\toks0}% - }% -} - -% Since all \c{,omment} does is throw away the argument, we can let TeX -% do that for us. The \relax here is matched by the \relax in the call -% in \parseargline; it could be more or less anything, its purpose is -% just to delimit the argument to the \c. -\def\argremovec#1\c#2\relax{\toks0 = {#1}} -\def\argremovecomment#1\comment#2\relax{\toks0 = {#1}} - -% \argremovec{,omment} might leave us with trailing spaces, though; e.g., -% @end itemize @c foo -% will have two active spaces as part of the argument with the -% `itemize'. Here we remove all active spaces from #1, and assign the -% result to \toks0. -% -% This loses if there are any *other* active characters besides spaces -% in the argument -- _ ^ +, for example -- since they get expanded. -% Fortunately, Texinfo does not define any such commands. (If it ever -% does, the catcode of the characters in questionwill have to be changed -% here.) But this means we cannot call \removeactivespaces as part of -% \argremovec{,omment}, since @c uses \parsearg, and thus the argument -% that \parsearg gets might well have any character at all in it. -% -\def\removeactivespaces#1{% - \begingroup - \ignoreactivespaces - \edef\temp{#1}% - \global\toks0 = \expandafter{\temp}% - \endgroup -} - -% Change the active space to expand to nothing. -% -\begingroup - \obeyspaces - \gdef\ignoreactivespaces{\obeyspaces\let =\empty} -\endgroup - - -\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} - -%% These are used to keep @begin/@end levels from running away -%% Call \inENV within environments (after a \begingroup) -\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi} -\def\ENVcheck{% -\ifENV\errmessage{Still within an environment; press RETURN to continue} -\endgroup\fi} % This is not perfect, but it should reduce lossage - -% @begin foo is the same as @foo, for now. -\newhelp\EMsimple{Press RETURN to continue.} - -\outer\def\begin{\parsearg\beginxxx} - -\def\beginxxx #1{% -\expandafter\ifx\csname #1\endcsname\relax -{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else -\csname #1\endcsname\fi} - -% @end foo executes the definition of \Efoo. -% -\def\end{\parsearg\endxxx} -\def\endxxx #1{% - \removeactivespaces{#1}% - \edef\endthing{\the\toks0}% - % - \expandafter\ifx\csname E\endthing\endcsname\relax - \expandafter\ifx\csname \endthing\endcsname\relax - % There's no \foo, i.e., no ``environment'' foo. - \errhelp = \EMsimple - \errmessage{Undefined command `@end \endthing'}% - \else - \unmatchedenderror\endthing - \fi - \else - % Everything's ok; the right environment has been started. - \csname E\endthing\endcsname - \fi -} - -% There is an environment #1, but it hasn't been started. Give an error. -% -\def\unmatchedenderror#1{% - \errhelp = \EMsimple - \errmessage{This `@end #1' doesn't have a matching `@#1'}% -} - -% Define the control sequence \E#1 to give an unmatched @end error. -% -\def\defineunmatchedend#1{% - \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}% -} - - -% Single-spacing is done by various environments (specifically, in -% \nonfillstart and \quotations). -\newskip\singlespaceskip \singlespaceskip = 12.5pt -\def\singlespace{% - % Why was this kern here? It messes up equalizing space above and below - % environments. --karl, 6may93 - %{\advance \baselineskip by -\singlespaceskip - %\kern \baselineskip}% - \setleading \singlespaceskip -} - -%% Simple single-character @ commands - -% @@ prints an @ -% Kludge this until the fonts are right (grr). -\def\@{{\tt\char64}} - -% This is turned off because it was never documented -% and you can use @w{...} around a quote to suppress ligatures. -%% Define @` and @' to be the same as ` and ' -%% but suppressing ligatures. -%\def\`{{`}} -%\def\'{{'}} - -% Used to generate quoted braces. -\def\mylbrace {{\tt\char123}} -\def\myrbrace {{\tt\char125}} -\let\{=\mylbrace -\let\}=\myrbrace -\begingroup - % Definitions to produce actual \{ & \} command in an index. - \catcode`\{ = 12 \catcode`\} = 12 - \catcode`\[ = 1 \catcode`\] = 2 - \catcode`\@ = 0 \catcode`\\ = 12 - @gdef@lbracecmd[\{]% - @gdef@rbracecmd[\}]% -@endgroup - -% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent -% Others are defined by plain TeX: @` @' @" @^ @~ @= @v @H. -\let\, = \c -\let\dotaccent = \. -\def\ringaccent#1{{\accent23 #1}} -\let\tieaccent = \t -\let\ubaraccent = \b -\let\udotaccent = \d - -% Other special characters: @questiondown @exclamdown -% Plain TeX defines: @AA @AE @O @OE @L (and lowercase versions) @ss. -\def\questiondown{?`} -\def\exclamdown{!`} - -% Dotless i and dotless j, used for accents. -\def\imacro{i} -\def\jmacro{j} -\def\dotless#1{% - \def\temp{#1}% - \ifx\temp\imacro \ptexi - \else\ifx\temp\jmacro \j - \else \errmessage{@dotless can be used only with i or j}% - \fi\fi -} - -% Be sure we're in horizontal mode when doing a tie, since we make space -% equivalent to this in @example-like environments. Otherwise, a space -% at the beginning of a line will start with \penalty -- and -% since \penalty is valid in vertical mode, we'd end up putting the -% penalty on the vertical list instead of in the new paragraph. -{\catcode`@ = 11 - % Avoid using \@M directly, because that causes trouble - % if the definition is written into an index file. - \global\let\tiepenalty = \@M - \gdef\tie{\leavevmode\penalty\tiepenalty\ } -} - -% @: forces normal size whitespace following. -\def\:{\spacefactor=1000 } - -% @* forces a line break. -\def\*{\hfil\break\hbox{}\ignorespaces} - -% @. is an end-of-sentence period. -\def\.{.\spacefactor=3000 } - -% @! is an end-of-sentence bang. -\def\!{!\spacefactor=3000 } - -% @? is an end-of-sentence query. -\def\?{?\spacefactor=3000 } - -% @w prevents a word break. Without the \leavevmode, @w at the -% beginning of a paragraph, when TeX is still in vertical mode, would -% produce a whole line of output instead of starting the paragraph. -\def\w#1{\leavevmode\hbox{#1}} - -% @group ... @end group forces ... to be all on one page, by enclosing -% it in a TeX vbox. We use \vtop instead of \vbox to construct the box -% to keep its height that of a normal line. According to the rules for -% \topskip (p.114 of the TeXbook), the glue inserted is -% max (\topskip - \ht (first item), 0). If that height is large, -% therefore, no glue is inserted, and the space between the headline and -% the text is small, which looks bad. -% -\def\group{\begingroup - \ifnum\catcode13=\active \else - \errhelp = \groupinvalidhelp - \errmessage{@group invalid in context where filling is enabled}% - \fi - % - % The \vtop we start below produces a box with normal height and large - % depth; thus, TeX puts \baselineskip glue before it, and (when the - % next line of text is done) \lineskip glue after it. (See p.82 of - % the TeXbook.) Thus, space below is not quite equal to space - % above. But it's pretty close. - \def\Egroup{% - \egroup % End the \vtop. - \endgroup % End the \group. - }% - % - \vtop\bgroup - % We have to put a strut on the last line in case the @group is in - % the midst of an example, rather than completely enclosing it. - % Otherwise, the interline space between the last line of the group - % and the first line afterwards is too small. But we can't put the - % strut in \Egroup, since there it would be on a line by itself. - % Hence this just inserts a strut at the beginning of each line. - \everypar = {\strut}% - % - % Since we have a strut on every line, we don't need any of TeX's - % normal interline spacing. - \offinterlineskip - % - % OK, but now we have to do something about blank - % lines in the input in @example-like environments, which normally - % just turn into \lisppar, which will insert no space now that we've - % turned off the interline space. Simplest is to make them be an - % empty paragraph. - \ifx\par\lisppar - \edef\par{\leavevmode \par}% - % - % Reset ^^M's definition to new definition of \par. - \obeylines - \fi - % - % Do @comment since we are called inside an environment such as - % @example, where each end-of-line in the input causes an - % end-of-line in the output. We don't want the end-of-line after - % the `@group' to put extra space in the output. Since @group - % should appear on a line by itself (according to the Texinfo - % manual), we don't worry about eating any user text. - \comment -} -% -% TeX puts in an \escapechar (i.e., `@') at the beginning of the help -% message, so this ends up printing `@group can only ...'. -% -\newhelp\groupinvalidhelp{% -group can only be used in environments such as @example,^^J% -where each line of input produces a line of output.} - -% @need space-in-mils -% forces a page break if there is not space-in-mils remaining. - -\newdimen\mil \mil=0.001in - -\def\need{\parsearg\needx} - -% Old definition--didn't work. -%\def\needx #1{\par % -%% This method tries to make TeX break the page naturally -%% if the depth of the box does not fit. -%{\baselineskip=0pt% -%\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak -%\prevdepth=-1000pt -%}} - -\def\needx#1{% - % Go into vertical mode, so we don't make a big box in the middle of a - % paragraph. - \par - % - % Don't add any leading before our big empty box, but allow a page - % break, since the best break might be right here. - \allowbreak - \nointerlineskip - \vtop to #1\mil{\vfil}% - % - % TeX does not even consider page breaks if a penalty added to the - % main vertical list is 10000 or more. But in order to see if the - % empty box we just added fits on the page, we must make it consider - % page breaks. On the other hand, we don't want to actually break the - % page after the empty box. So we use a penalty of 9999. - % - % There is an extremely small chance that TeX will actually break the - % page at this \penalty, if there are no other feasible breakpoints in - % sight. (If the user is using lots of big @group commands, which - % almost-but-not-quite fill up a page, TeX will have a hard time doing - % good page breaking, for example.) However, I could not construct an - % example where a page broke at this \penalty; if it happens in a real - % document, then we can reconsider our strategy. - \penalty9999 - % - % Back up by the size of the box, whether we did a page break or not. - \kern -#1\mil - % - % Do not allow a page break right after this kern. - \nobreak -} - -% @br forces paragraph break - -\let\br = \par - -% @dots{} output an ellipsis using the current font. -% We do .5em per period so that it has the same spacing in a typewriter -% font as three actual period characters. -% -\def\dots{% - \leavevmode - \hbox to 1.5em{% - \hskip 0pt plus 0.25fil minus 0.25fil - .\hss.\hss.% - \hskip 0pt plus 0.5fil minus 0.5fil - }% -} - -% @enddots{} is an end-of-sentence ellipsis. -% -\def\enddots{% - \leavevmode - \hbox to 2em{% - \hskip 0pt plus 0.25fil minus 0.25fil - .\hss.\hss.\hss.% - \hskip 0pt plus 0.5fil minus 0.5fil - }% - \spacefactor=3000 -} - - -% @page forces the start of a new page -% -\def\page{\par\vfill\supereject} - -% @exdent text.... -% outputs text on separate line in roman font, starting at standard page margin - -% This records the amount of indent in the innermost environment. -% That's how much \exdent should take out. -\newskip\exdentamount - -% This defn is used inside fill environments such as @defun. -\def\exdent{\parsearg\exdentyyy} -\def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}} - -% This defn is used inside nofill environments such as @example. -\def\nofillexdent{\parsearg\nofillexdentyyy} -\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount -\leftline{\hskip\leftskip{\rm#1}}}} - -% @inmargin{TEXT} puts TEXT in the margin next to the current paragraph. - -\def\inmargin#1{% -\strut\vadjust{\nobreak\kern-\strutdepth - \vtop to \strutdepth{\baselineskip\strutdepth\vss - \llap{\rightskip=\inmarginspacing \vbox{\noindent #1}}\null}}} -\newskip\inmarginspacing \inmarginspacing=1cm -\def\strutdepth{\dp\strutbox} - -%\hbox{{\rm#1}}\hfil\break}} - -% @include file insert text of that file as input. -% Allow normal characters that we make active in the argument (a file name). -\def\include{\begingroup - \catcode`\\=12 - \catcode`~=12 - \catcode`^=12 - \catcode`_=12 - \catcode`|=12 - \catcode`<=12 - \catcode`>=12 - \catcode`+=12 - \parsearg\includezzz} -% Restore active chars for included file. -\def\includezzz#1{\endgroup\begingroup - % Read the included file in a group so nested @include's work. - \def\thisfile{#1}% - \input\thisfile -\endgroup} - -\def\thisfile{} - -% @center line outputs that line, centered - -\def\center{\parsearg\centerzzz} -\def\centerzzz #1{{\advance\hsize by -\leftskip -\advance\hsize by -\rightskip -\centerline{#1}}} - -% @sp n outputs n lines of vertical space - -\def\sp{\parsearg\spxxx} -\def\spxxx #1{\vskip #1\baselineskip} - -% @comment ...line which is ignored... -% @c is the same as @comment -% @ignore ... @end ignore is another way to write a comment - -\def\comment{\begingroup \catcode`\^^M=\other% -\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% -\commentxxx} -{\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}} - -\let\c=\comment - -% @paragraphindent NCHARS -% We'll use ems for NCHARS, close enough. -% We cannot implement @paragraphindent asis, though. -% -\def\asisword{asis} % no translation, these are keywords -\def\noneword{none} -% -\def\paragraphindent{\parsearg\doparagraphindent} -\def\doparagraphindent#1{% - \def\temp{#1}% - \ifx\temp\asisword - \else - \ifx\temp\noneword - \defaultparindent = 0pt - \else - \defaultparindent = #1em - \fi - \fi - \parindent = \defaultparindent -} - -% @exampleindent NCHARS -% We'll use ems for NCHARS like @paragraphindent. -% It seems @exampleindent asis isn't necessary, but -% I preserve it to make it similar to @paragraphindent. -\def\exampleindent{\parsearg\doexampleindent} -\def\doexampleindent#1{% - \def\temp{#1}% - \ifx\temp\asisword - \else - \ifx\temp\noneword - \lispnarrowing = 0pt - \else - \lispnarrowing = #1em - \fi - \fi -} - -% @asis just yields its argument. Used with @table, for example. -% -\def\asis#1{#1} - -% @math means output in math mode. -% We don't use $'s directly in the definition of \math because control -% sequences like \math are expanded when the toc file is written. Then, -% we read the toc file back, the $'s will be normal characters (as they -% should be, according to the definition of Texinfo). So we must use a -% control sequence to switch into and out of math mode. -% -% This isn't quite enough for @math to work properly in indices, but it -% seems unlikely it will ever be needed there. -% -\let\implicitmath = $ -\def\math#1{\implicitmath #1\implicitmath} - -% @bullet and @minus need the same treatment as @math, just above. -\def\bullet{\implicitmath\ptexbullet\implicitmath} -\def\minus{\implicitmath-\implicitmath} - -% @refill is a no-op. -\let\refill=\relax - -% If working on a large document in chapters, it is convenient to -% be able to disable indexing, cross-referencing, and contents, for test runs. -% This is done with @novalidate (before @setfilename). -% -\newif\iflinks \linkstrue % by default we want the aux files. -\let\novalidate = \linksfalse - -% @setfilename is done at the beginning of every texinfo file. -% So open here the files we need to have open while reading the input. -% This makes it possible to make a .fmt file for texinfo. -\def\setfilename{% - \iflinks - \readauxfile - \fi % \openindices needs to do some work in any case. - \openindices - \fixbackslash % Turn off hack to swallow `\input texinfo'. - \global\let\setfilename=\comment % Ignore extra @setfilename cmds. - % - % If texinfo.cnf is present on the system, read it. - % Useful for site-wide @afourpaper, etc. - % Just to be on the safe side, close the input stream before the \input. - \openin 1 texinfo.cnf - \ifeof1 \let\temp=\relax \else \def\temp{\input texinfo.cnf }\fi - \closein1 - \temp - % - \comment % Ignore the actual filename. -} - -% Called from \setfilename. -% -\def\openindices{% - \newindex{cp}% - \newcodeindex{fn}% - \newcodeindex{vr}% - \newcodeindex{tp}% - \newcodeindex{ky}% - \newcodeindex{pg}% -} - -% @bye. -\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} - - -\message{pdf,} -% adobe `portable' document format - -\newcount\tempnum -\newcount\lnkcount -\newtoks\filename -\newcount\filenamelength -\newcount\pgn - -\ifpdf -\def\pdfmkdest#1{\pdfdest name{#1@} xyz} -\def\pdfmkpgn#1{#1@} - -% Adding outlines to PDF; macros for calculating structure of outlines -% come from Petr Olsak -\def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% - \else \csname#1\endcsname \fi} -\def\advancenumber#1{\tempnum=\expnumber{#1}\relax - \advance\tempnum by1 - \expandafter\xdef\csname#1\endcsname{\the\tempnum}} -\def\pdfmakeoutlines{{% - \openin 1 \jobname.toc - \ifeof 1\else\bgroup - \closein 1 - \def\code##1{##1} - \def\file##1{##1} - \def\TeX##1{TeX} - \def\tt{} - \def\char{char} - \def\samp##1{##1} - \def\kbd##1{##1} - \def\key##1{##1} - \def\rawbackslashxx{\string\\} - \def\chapentry ##1##2##3{} - \def\unnumbchapentry ##1##2{} - \def\secentry ##1##2##3##4{\advancenumber{chap##2}} - \def\unnumbsecentry ##1##2{} - \def\subsecentry ##1##2##3##4##5{\advancenumber{sec##2.##3}} - \def\unnumbsubsecentry ##1##2{} - \def\subsubsecentry ##1##2##3##4##5##6{\advancenumber{subsec##2.##3.##4}} - \def\unnumbsubsubsecentry ##1##2{} - \input \jobname.toc - \def\chapentry ##1##2##3{% - \pdfoutline goto name{\pdfmkpgn{##3}}count-\expnumber{chap##2}{##1}} - \def\unnumbchapentry ##1##2{% - \pdfoutline goto name{\pdfmkpgn{##2}}{##1}} - \def\secentry ##1##2##3##4{% - \pdfoutline goto name{\pdfmkpgn{##4}}count-\expnumber{sec##2.##3}{##1}} - \def\unnumbsecentry ##1##2{% - \pdfoutline goto name{\pdfmkpgn{##2}}{##1}} - \def\subsecentry ##1##2##3##4##5{% - \pdfoutline goto name{\pdfmkpgn{##5}}count-\expnumber{subsec##2.##3.##4}{##1}} - \def\unnumbsubsecentry ##1##2{% - \pdfoutline goto name{\pdfmkpgn{##2}}{##1}} - \def\subsubsecentry ##1##2##3##4##5##6{% - \pdfoutline goto name{\pdfmkpgn{##6}}{##1}} - \def\unnumbsubsubsecentry ##1##2{% - \pdfoutline goto name{\pdfmkpgn{##2}}{##1}} - \input \jobname.toc - \egroup\fi -}} -\pdfmakeoutlines - -\def\makelinks #1,{% - \def\params{#1}\def\E{END}% - \ifx\params\E - \let\nextmakelinks=\relax - \else - \let\nextmakelinks=\makelinks - \ifnum\lnkcount>0,\fi - \picknum{#1}% - \Blue\pdfannotlink attr{/Border [0 0 0]} - goto name{\pdfmkpgn{\the\pgn}}% - #1% - \advance\lnkcount by 1% - \Black\pdfendlink - \fi - \nextmakelinks -} - -\def\picknum#1{\expandafter\pn#1} -\def\pn#1{% - \def\p{#1}% - \ifx\p\lbrace - \let\nextpn=\ppn - \else - \let\nextpn=\ppnn - \def\first{#1} - \fi - \nextpn -} -\def\ppn#1{\pgn=#1\gobble} -\def\ppnn{\pgn=\first} -\def\pdfmklnk#1{\lnkcount=0\makelinks #1,END,} - -\def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} -\def\skipspaces#1{\def\PP{#1}\def\D{|}% - \ifx\PP\D\let\nextsp\relax - \else\let\nextsp\skipspaces - \ifx\p\space\else\addtokens{\filename}{\PP}% - \advance\filenamelength by 1 - \fi - \fi - \nextsp} -\def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax} - -\def\pdflink#1{% - \leavevmode\Red - \begingroup - \normalturnoffactive\def\@{@}% - \pdfannotlink - attr{/Border [0 0 0]}% - user{/Subtype /Link /A << /S /URI /URI (#1) >>}% - \endgroup -} - -\else -\let\pdflink = \gobble -\fi % end \ifpdf - -\message{fonts,} -% Font-change commands. - -% Texinfo sort of supports the sans serif font style, which plain TeX does not. -% So we set up a \sf analogous to plain's \rm, etc. -\newfam\sffam -\def\sf{\fam=\sffam \tensf} -\let\li = \sf % Sometimes we call it \li, not \sf. - -% We don't need math for this one. -\def\ttsl{\tenttsl} - -% Use Computer Modern fonts at \magstephalf (11pt). -\newcount\mainmagstep -\mainmagstep=\magstephalf - -% Set the font macro #1 to the font named #2, adding on the -% specified font prefix (normally `cm'). -% #3 is the font's design size, #4 is a scale factor -\def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4} - -% Use cm as the default font prefix. -% To specify the font prefix, you must define \fontprefix -% before you read in texinfo.tex. -\ifx\fontprefix\undefined -\def\fontprefix{cm} -\fi -% Support font families that don't use the same naming scheme as CM. -\def\rmshape{r} -\def\rmbshape{bx} %where the normal face is bold -\def\bfshape{b} -\def\bxshape{bx} -\def\ttshape{tt} -\def\ttbshape{tt} -\def\ttslshape{sltt} -\def\itshape{ti} -\def\itbshape{bxti} -\def\slshape{sl} -\def\slbshape{bxsl} -\def\sfshape{ss} -\def\sfbshape{ss} -\def\scshape{csc} -\def\scbshape{csc} - -\ifx\bigger\relax -\let\mainmagstep=\magstep1 -\setfont\textrm\rmshape{12}{1000} -\setfont\texttt\ttshape{12}{1000} -\else -\setfont\textrm\rmshape{10}{\mainmagstep} -\setfont\texttt\ttshape{10}{\mainmagstep} -\fi -% Instead of cmb10, you many want to use cmbx10. -% cmbx10 is a prettier font on its own, but cmb10 -% looks better when embedded in a line with cmr10. -\setfont\textbf\bfshape{10}{\mainmagstep} -\setfont\textit\itshape{10}{\mainmagstep} -\setfont\textsl\slshape{10}{\mainmagstep} -\setfont\textsf\sfshape{10}{\mainmagstep} -\setfont\textsc\scshape{10}{\mainmagstep} -\setfont\textttsl\ttslshape{10}{\mainmagstep} -\font\texti=cmmi10 scaled \mainmagstep -\font\textsy=cmsy10 scaled \mainmagstep - -% A few fonts for @defun, etc. -\setfont\defbf\bxshape{10}{\magstep1} %was 1314 -\setfont\deftt\ttshape{10}{\magstep1} -\def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} - -% Fonts for indices and small examples (9pt). -% We actually use the slanted font rather than the italic, -% because texinfo normally uses the slanted fonts for that. -% Do not make many font distinctions in general in the index, since they -% aren't very useful. -\setfont\ninett\ttshape{9}{1000} -\setfont\ninettsl\ttslshape{10}{900} -\setfont\indrm\rmshape{9}{1000} -\setfont\indit\itshape{9}{1000} -\setfont\indsl\slshape{9}{1000} -\let\indtt=\ninett -\let\indttsl=\ninettsl -\let\indsf=\indrm -\let\indbf=\indrm -\setfont\indsc\scshape{10}{900} -\font\indi=cmmi9 -\font\indsy=cmsy9 - -% Fonts for title page: -\setfont\titlerm\rmbshape{12}{\magstep3} -\setfont\titleit\itbshape{10}{\magstep4} -\setfont\titlesl\slbshape{10}{\magstep4} -\setfont\titlett\ttbshape{12}{\magstep3} -\setfont\titlettsl\ttslshape{10}{\magstep4} -\setfont\titlesf\sfbshape{17}{\magstep1} -\let\titlebf=\titlerm -\setfont\titlesc\scbshape{10}{\magstep4} -\font\titlei=cmmi12 scaled \magstep3 -\font\titlesy=cmsy10 scaled \magstep4 -\def\authorrm{\secrm} - -% Chapter (and unnumbered) fonts (17.28pt). -\setfont\chaprm\rmbshape{12}{\magstep2} -\setfont\chapit\itbshape{10}{\magstep3} -\setfont\chapsl\slbshape{10}{\magstep3} -\setfont\chaptt\ttbshape{12}{\magstep2} -\setfont\chapttsl\ttslshape{10}{\magstep3} -\setfont\chapsf\sfbshape{17}{1000} -\let\chapbf=\chaprm -\setfont\chapsc\scbshape{10}{\magstep3} -\font\chapi=cmmi12 scaled \magstep2 -\font\chapsy=cmsy10 scaled \magstep3 - -% Section fonts (14.4pt). -\setfont\secrm\rmbshape{12}{\magstep1} -\setfont\secit\itbshape{10}{\magstep2} -\setfont\secsl\slbshape{10}{\magstep2} -\setfont\sectt\ttbshape{12}{\magstep1} -\setfont\secttsl\ttslshape{10}{\magstep2} -\setfont\secsf\sfbshape{12}{\magstep1} -\let\secbf\secrm -\setfont\secsc\scbshape{10}{\magstep2} -\font\seci=cmmi12 scaled \magstep1 -\font\secsy=cmsy10 scaled \magstep2 - -% \setfont\ssecrm\bxshape{10}{\magstep1} % This size an font looked bad. -% \setfont\ssecit\itshape{10}{\magstep1} % The letters were too crowded. -% \setfont\ssecsl\slshape{10}{\magstep1} -% \setfont\ssectt\ttshape{10}{\magstep1} -% \setfont\ssecsf\sfshape{10}{\magstep1} - -%\setfont\ssecrm\bfshape{10}{1315} % Note the use of cmb rather than cmbx. -%\setfont\ssecit\itshape{10}{1315} % Also, the size is a little larger than -%\setfont\ssecsl\slshape{10}{1315} % being scaled magstep1. -%\setfont\ssectt\ttshape{10}{1315} -%\setfont\ssecsf\sfshape{10}{1315} - -%\let\ssecbf=\ssecrm - -% Subsection fonts (13.15pt). -\setfont\ssecrm\rmbshape{12}{\magstephalf} -\setfont\ssecit\itbshape{10}{1315} -\setfont\ssecsl\slbshape{10}{1315} -\setfont\ssectt\ttbshape{12}{\magstephalf} -\setfont\ssecttsl\ttslshape{10}{1315} -\setfont\ssecsf\sfbshape{12}{\magstephalf} -\let\ssecbf\ssecrm -\setfont\ssecsc\scbshape{10}{\magstep1} -\font\sseci=cmmi12 scaled \magstephalf -\font\ssecsy=cmsy10 scaled 1315 -% The smallcaps and symbol fonts should actually be scaled \magstep1.5, -% but that is not a standard magnification. - -% In order for the font changes to affect most math symbols and letters, -% we have to define the \textfont of the standard families. Since -% texinfo doesn't allow for producing subscripts and superscripts, we -% don't bother to reset \scriptfont and \scriptscriptfont (which would -% also require loading a lot more fonts). -% -\def\resetmathfonts{% - \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy - \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf - \textfont\ttfam = \tentt \textfont\sffam = \tensf -} - - -% The font-changing commands redefine the meanings of \tenSTYLE, instead -% of just \STYLE. We do this so that font changes will continue to work -% in math mode, where it is the current \fam that is relevant in most -% cases, not the current font. Plain TeX does \def\bf{\fam=\bffam -% \tenbf}, for example. By redefining \tenbf, we obviate the need to -% redefine \bf itself. -\def\textfonts{% - \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl - \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc - \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl - \resetmathfonts} -\def\titlefonts{% - \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl - \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc - \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy - \let\tenttsl=\titlettsl - \resetmathfonts \setleading{25pt}} -\def\titlefont#1{{\titlefonts\rm #1}} -\def\chapfonts{% - \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl - \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc - \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl - \resetmathfonts \setleading{19pt}} -\def\secfonts{% - \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl - \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc - \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl - \resetmathfonts \setleading{16pt}} -\def\subsecfonts{% - \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl - \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc - \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl - \resetmathfonts \setleading{15pt}} -\let\subsubsecfonts = \subsecfonts % Maybe make sssec fonts scaled magstephalf? -\def\indexfonts{% - \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl - \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc - \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy \let\tenttsl=\indttsl - \resetmathfonts \setleading{12pt}} - -% Set up the default fonts, so we can use them for creating boxes. -% -\textfonts - -% Define these so they can be easily changed for other fonts. -\def\angleleft{$\langle$} -\def\angleright{$\rangle$} - -% Count depth in font-changes, for error checks -\newcount\fontdepth \fontdepth=0 - -% Fonts for short table of contents. -\setfont\shortcontrm\rmshape{12}{1000} -\setfont\shortcontbf\bxshape{12}{1000} -\setfont\shortcontsl\slshape{12}{1000} - -%% Add scribe-like font environments, plus @l for inline lisp (usually sans -%% serif) and @ii for TeX italic - -% \smartitalic{ARG} outputs arg in italics, followed by an italic correction -% unless the following character is such as not to need one. -\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi} -\def\smartslanted#1{{\sl #1}\futurelet\next\smartitalicx} -\def\smartitalic#1{{\it #1}\futurelet\next\smartitalicx} - -\let\i=\smartitalic -\let\var=\smartslanted -\let\dfn=\smartslanted -\let\emph=\smartitalic -\let\cite=\smartslanted - -\def\b#1{{\bf #1}} -\let\strong=\b - -% We can't just use \exhyphenpenalty, because that only has effect at -% the end of a paragraph. Restore normal hyphenation at the end of the -% group within which \nohyphenation is presumably called. -% -\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} -\def\restorehyphenation{\hyphenchar\font = `- } - -\def\t#1{% - {\tt \rawbackslash \frenchspacing #1}% - \null -} -\let\ttfont=\t -\def\samp#1{`\tclose{#1}'\null} -\setfont\smallrm\rmshape{8}{1000} -\font\smallsy=cmsy9 -\def\key#1{{\smallrm\textfont2=\smallsy \leavevmode\hbox{% - \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% - \vbox{\hrule\kern-0.4pt - \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% - \kern-0.4pt\hrule}% - \kern-.06em\raise0.4pt\hbox{\angleright}}}} -% The old definition, with no lozenge: -%\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null} -\def\ctrl #1{{\tt \rawbackslash \hat}#1} - -% @file, @option are the same as @samp. -\let\file=\samp -\let\option=\samp - -% @code is a modification of @t, -% which makes spaces the same size as normal in the surrounding text. -\def\tclose#1{% - {% - % Change normal interword space to be same as for the current font. - \spaceskip = \fontdimen2\font - % - % Switch to typewriter. - \tt - % - % But `\ ' produces the large typewriter interword space. - \def\ {{\spaceskip = 0pt{} }}% - % - % Turn off hyphenation. - \nohyphenation - % - \rawbackslash - \frenchspacing - #1% - }% - \null -} - -% We *must* turn on hyphenation at `-' and `_' in \code. -% Otherwise, it is too hard to avoid overfull hboxes -% in the Emacs manual, the Library manual, etc. - -% Unfortunately, TeX uses one parameter (\hyphenchar) to control -% both hyphenation at - and hyphenation within words. -% We must therefore turn them both off (\tclose does that) -% and arrange explicitly to hyphenate at a dash. -% -- rms. -{ - \catcode`\-=\active - \catcode`\_=\active - % - \global\def\code{\begingroup - \catcode`\-=\active \let-\codedash - \catcode`\_=\active \let_\codeunder - \codex - } - % - % If we end up with any active - characters when handling the index, - % just treat them as a normal -. - \global\def\indexbreaks{\catcode`\-=\active \let-\realdash} -} - -\def\realdash{-} -\def\codedash{-\discretionary{}{}{}} -\def\codeunder{\ifusingtt{\normalunderscore\discretionary{}{}{}}{\_}} -\def\codex #1{\tclose{#1}\endgroup} - -%\let\exp=\tclose %Was temporary - -% @kbd is like @code, except that if the argument is just one @key command, -% then @kbd has no effect. - -% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), -% `example' (@kbd uses ttsl only inside of @example and friends), -% or `code' (@kbd uses normal tty font always). -\def\kbdinputstyle{\parsearg\kbdinputstylexxx} -\def\kbdinputstylexxx#1{% - \def\arg{#1}% - \ifx\arg\worddistinct - \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% - \else\ifx\arg\wordexample - \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% - \else\ifx\arg\wordcode - \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% - \fi\fi\fi -} -\def\worddistinct{distinct} -\def\wordexample{example} -\def\wordcode{code} - -% Default is kbdinputdistinct. (Too much of a hassle to call the macro, -% the catcodes are wrong for parsearg to work.) -\gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl} - -\def\xkey{\key} -\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% -\ifx\one\xkey\ifx\threex\three \key{#2}% -\else{\tclose{\kbdfont\look}}\fi -\else{\tclose{\kbdfont\look}}\fi} - -% For @url, @env, @command quotes seem unnecessary, so use \code. -\let\url=\code -\let\env=\code -\let\command=\code - -% @uref (abbreviation for `urlref') takes an optional (comma-separated) -% second argument specifying the text to display and an optional third -% arg as text to display instead of (rather than in addition to) the url -% itself. First (mandatory) arg is the url. Perhaps eventually put in -% a hypertex \special here. -% -\def\uref#1{\douref #1,,,\finish} -\def\douref#1,#2,#3,#4\finish{% - \pdflink{#1}% - \setbox0 = \hbox{\ignorespaces #3}% - \ifdim\wd0 > 0pt - \unhbox0 % third arg given, show only that - \else - \setbox0 = \hbox{\ignorespaces #2}% - \ifdim\wd0 > 0pt - \ifpdf - \unhbox0 % PDF: 2nd arg given, show only it - \else - \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url - \fi - \else - \code{#1}% only url given, so show it - \fi - \fi - % - \ifpdf - \Black\pdfendlink - \fi -} - -% rms does not like angle brackets --karl, 17may97. -% So now @email is just like @uref, unless we are pdf. -% -%\def\email#1{\angleleft{\tt #1}\angleright} -\ifpdf - \def\email#1{\doemail#1,,\finish} - \def\doemail#1,#2,#3\finish{% - \pdflink{mailto:#1}% - \setbox0 = \hbox{\ignorespaces #2}% - \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi - \Black\pdfendlink - } -\else - \let\email=\uref -\fi - -% Check if we are currently using a typewriter font. Since all the -% Computer Modern typewriter fonts have zero interword stretch (and -% shrink), and it is reasonable to expect all typewriter fonts to have -% this property, we can check that font parameter. -% -\def\ifmonospace{\ifdim\fontdimen3\font=0pt } - -% Typeset a dimension, e.g., `in' or `pt'. The only reason for the -% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt. -% -\def\dmn#1{\thinspace #1} - -\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par} - -% @l was never documented to mean ``switch to the Lisp font'', -% and it is not used as such in any manual I can find. We need it for -% Polish suppressed-l. --karl, 22sep96. -%\def\l#1{{\li #1}\null} - -% Explicit font changes: @r, @sc, undocumented @ii. -\def\r#1{{\rm #1}} % roman font -\def\sc#1{{\smallcaps#1}} % smallcaps font -\def\ii#1{{\it #1}} % italic font - -% @acronym downcases the argument and prints in smallcaps. -\def\acronym#1{{\smallcaps \lowercase{#1}}} - -% @pounds{} is a sterling sign. -\def\pounds{{\it\$}} - - -\message{page headings,} - -\newskip\titlepagetopglue \titlepagetopglue = 1.5in -\newskip\titlepagebottomglue \titlepagebottomglue = 2pc - -% First the title page. Must do @settitle before @titlepage. -\newif\ifseenauthor -\newif\iffinishedtitlepage - -% Do an implicit @contents or @shortcontents after @end titlepage if the -% user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage. -% -\newif\ifsetcontentsaftertitlepage - \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue -\newif\ifsetshortcontentsaftertitlepage - \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue - -\def\shorttitlepage{\parsearg\shorttitlepagezzz} -\def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% - \endgroup\page\hbox{}\page} - -\def\titlepage{\begingroup \parindent=0pt \textfonts - \let\subtitlerm=\tenrm - \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}% - % - \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}% - % - % Leave some space at the very top of the page. - \vglue\titlepagetopglue - % - % Now you can print the title using @title. - \def\title{\parsearg\titlezzz}% - \def\titlezzz##1{\leftline{\titlefonts\rm ##1} - % print a rule at the page bottom also. - \finishedtitlepagefalse - \vskip4pt \hrule height 4pt width \hsize \vskip4pt}% - % No rule at page bottom unless we print one at the top with @title. - \finishedtitlepagetrue - % - % Now you can put text using @subtitle. - \def\subtitle{\parsearg\subtitlezzz}% - \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}% - % - % @author should come last, but may come many times. - \def\author{\parsearg\authorzzz}% - \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi - {\authorfont \leftline{##1}}}% - % - % Most title ``pages'' are actually two pages long, with space - % at the top of the second. We don't want the ragged left on the second. - \let\oldpage = \page - \def\page{% - \iffinishedtitlepage\else - \finishtitlepage - \fi - \oldpage - \let\page = \oldpage - \hbox{}}% -% \def\page{\oldpage \hbox{}} -} - -\def\Etitlepage{% - \iffinishedtitlepage\else - \finishtitlepage - \fi - % It is important to do the page break before ending the group, - % because the headline and footline are only empty inside the group. - % If we use the new definition of \page, we always get a blank page - % after the title page, which we certainly don't want. - \oldpage - \endgroup - % - % If they want short, they certainly want long too. - \ifsetshortcontentsaftertitlepage - \shortcontents - \contents - \global\let\shortcontents = \relax - \global\let\contents = \relax - \fi - % - \ifsetcontentsaftertitlepage - \contents - \global\let\contents = \relax - \global\let\shortcontents = \relax - \fi - % - \HEADINGSon -} - -\def\finishtitlepage{% - \vskip4pt \hrule height 2pt width \hsize - \vskip\titlepagebottomglue - \finishedtitlepagetrue -} - -%%% Set up page headings and footings. - -\let\thispage=\folio - -\newtoks\evenheadline % headline on even pages -\newtoks\oddheadline % headline on odd pages -\newtoks\evenfootline % footline on even pages -\newtoks\oddfootline % footline on odd pages - -% Now make Tex use those variables -\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline - \else \the\evenheadline \fi}} -\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline - \else \the\evenfootline \fi}\HEADINGShook} -\let\HEADINGShook=\relax - -% Commands to set those variables. -% For example, this is what @headings on does -% @evenheading @thistitle|@thispage|@thischapter -% @oddheading @thischapter|@thispage|@thistitle -% @evenfooting @thisfile|| -% @oddfooting ||@thisfile - -\def\evenheading{\parsearg\evenheadingxxx} -\def\oddheading{\parsearg\oddheadingxxx} -\def\everyheading{\parsearg\everyheadingxxx} - -\def\evenfooting{\parsearg\evenfootingxxx} -\def\oddfooting{\parsearg\oddfootingxxx} -\def\everyfooting{\parsearg\everyfootingxxx} - -{\catcode`\@=0 % - -\gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish} -\gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{% -\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish} -\gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{% -\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\everyheadingxxx#1{\oddheadingxxx{#1}\evenheadingxxx{#1}}% - -\gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish} -\gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{% -\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} - -\gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish} -\gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{% - \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}% - % - % Leave some space for the footline. Hopefully ok to assume - % @evenfooting will not be used by itself. - \global\advance\pageheight by -\baselineskip - \global\advance\vsize by -\baselineskip -} - -\gdef\everyfootingxxx#1{\oddfootingxxx{#1}\evenfootingxxx{#1}} -% -}% unbind the catcode of @. - -% @headings double turns headings on for double-sided printing. -% @headings single turns headings on for single-sided printing. -% @headings off turns them off. -% @headings on same as @headings double, retained for compatibility. -% @headings after turns on double-sided headings after this page. -% @headings doubleafter turns on double-sided headings after this page. -% @headings singleafter turns on single-sided headings after this page. -% By default, they are off at the start of a document, -% and turned `on' after @end titlepage. - -\def\headings #1 {\csname HEADINGS#1\endcsname} - -\def\HEADINGSoff{ -\global\evenheadline={\hfil} \global\evenfootline={\hfil} -\global\oddheadline={\hfil} \global\oddfootline={\hfil}} -\HEADINGSoff -% When we turn headings on, set the page number to 1. -% For double-sided printing, put current file name in lower left corner, -% chapter name on inside top of right hand pages, document -% title on inside top of left hand pages, and page numbers on outside top -% edge of all pages. -\def\HEADINGSdouble{ -\global\pageno=1 -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\folio\hfil\thistitle}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -\global\let\contentsalignmacro = \chapoddpage -} -\let\contentsalignmacro = \chappager - -% For single-sided printing, chapter title goes across top left of page, -% page number on top right. -\def\HEADINGSsingle{ -\global\pageno=1 -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\thischapter\hfil\folio}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -\global\let\contentsalignmacro = \chappager -} -\def\HEADINGSon{\HEADINGSdouble} - -\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} -\let\HEADINGSdoubleafter=\HEADINGSafter -\def\HEADINGSdoublex{% -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\folio\hfil\thistitle}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -\global\let\contentsalignmacro = \chapoddpage -} - -\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} -\def\HEADINGSsinglex{% -\global\evenfootline={\hfil} -\global\oddfootline={\hfil} -\global\evenheadline={\line{\thischapter\hfil\folio}} -\global\oddheadline={\line{\thischapter\hfil\folio}} -\global\let\contentsalignmacro = \chappager -} - -% Subroutines used in generating headings -% Produces Day Month Year style of output. -\def\today{% - \number\day\space - \ifcase\month - \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr - \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug - \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec - \fi - \space\number\year} - -% @settitle line... specifies the title of the document, for headings. -% It generates no output of its own. -\def\thistitle{\putwordNoTitle} -\def\settitle{\parsearg\settitlezzz} -\def\settitlezzz #1{\gdef\thistitle{#1}} - - -\message{tables,} -% Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x). - -% default indentation of table text -\newdimen\tableindent \tableindent=.8in -% default indentation of @itemize and @enumerate text -\newdimen\itemindent \itemindent=.3in -% margin between end of table item and start of table text. -\newdimen\itemmargin \itemmargin=.1in - -% used internally for \itemindent minus \itemmargin -\newdimen\itemmax - -% Note @table, @vtable, and @vtable define @item, @itemx, etc., with -% these defs. -% They also define \itemindex -% to index the item name in whatever manner is desired (perhaps none). - -\newif\ifitemxneedsnegativevskip - -\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi} - -\def\internalBitem{\smallbreak \parsearg\itemzzz} -\def\internalBitemx{\itemxpar \parsearg\itemzzz} - -\def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz} -\def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz} - -\def\internalBkitem{\smallbreak \parsearg\kitemzzz} -\def\internalBkitemx{\itemxpar \parsearg\kitemzzz} - -\def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}% - \itemzzz {#1}} - -\def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}% - \itemzzz {#1}} - -\def\itemzzz #1{\begingroup % - \advance\hsize by -\rightskip - \advance\hsize by -\tableindent - \setbox0=\hbox{\itemfont{#1}}% - \itemindex{#1}% - \nobreak % This prevents a break before @itemx. - % - % If the item text does not fit in the space we have, put it on a line - % by itself, and do not allow a page break either before or after that - % line. We do not start a paragraph here because then if the next - % command is, e.g., @kindex, the whatsit would get put into the - % horizontal list on a line by itself, resulting in extra blank space. - \ifdim \wd0>\itemmax - % - % Make this a paragraph so we get the \parskip glue and wrapping, - % but leave it ragged-right. - \begingroup - \advance\leftskip by-\tableindent - \advance\hsize by\tableindent - \advance\rightskip by0pt plus1fil - \leavevmode\unhbox0\par - \endgroup - % - % We're going to be starting a paragraph, but we don't want the - % \parskip glue -- logically it's part of the @item we just started. - \nobreak \vskip-\parskip - % - % Stop a page break at the \parskip glue coming up. Unfortunately - % we can't prevent a possible page break at the following - % \baselineskip glue. - \nobreak - \endgroup - \itemxneedsnegativevskipfalse - \else - % The item text fits into the space. Start a paragraph, so that the - % following text (if any) will end up on the same line. - \noindent - % Do this with kerns and \unhbox so that if there is a footnote in - % the item text, it can migrate to the main vertical list and - % eventually be printed. - \nobreak\kern-\tableindent - \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0 - \unhbox0 - \nobreak\kern\dimen0 - \endgroup - \itemxneedsnegativevskiptrue - \fi -} - -\def\item{\errmessage{@item while not in a table}} -\def\itemx{\errmessage{@itemx while not in a table}} -\def\kitem{\errmessage{@kitem while not in a table}} -\def\kitemx{\errmessage{@kitemx while not in a table}} -\def\xitem{\errmessage{@xitem while not in a table}} -\def\xitemx{\errmessage{@xitemx while not in a table}} - -% Contains a kludge to get @end[description] to work. -\def\description{\tablez{\dontindex}{1}{}{}{}{}} - -% @table, @ftable, @vtable. -\def\table{\begingroup\inENV\obeylines\obeyspaces\tablex} -{\obeylines\obeyspaces% -\gdef\tablex #1^^M{% -\tabley\dontindex#1 \endtabley}} - -\def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex} -{\obeylines\obeyspaces% -\gdef\ftablex #1^^M{% -\tabley\fnitemindex#1 \endtabley -\def\Eftable{\endgraf\afterenvbreak\endgroup}% -\let\Etable=\relax}} - -\def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex} -{\obeylines\obeyspaces% -\gdef\vtablex #1^^M{% -\tabley\vritemindex#1 \endtabley -\def\Evtable{\endgraf\afterenvbreak\endgroup}% -\let\Etable=\relax}} - -\def\dontindex #1{} -\def\fnitemindex #1{\doind {fn}{\code{#1}}}% -\def\vritemindex #1{\doind {vr}{\code{#1}}}% - -{\obeyspaces % -\gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup% -\tablez{#1}{#2}{#3}{#4}{#5}{#6}}} - -\def\tablez #1#2#3#4#5#6{% -\aboveenvbreak % -\begingroup % -\def\Edescription{\Etable}% Necessary kludge. -\let\itemindex=#1% -\ifnum 0#3>0 \advance \leftskip by #3\mil \fi % -\ifnum 0#4>0 \tableindent=#4\mil \fi % -\ifnum 0#5>0 \advance \rightskip by #5\mil \fi % -\def\itemfont{#2}% -\itemmax=\tableindent % -\advance \itemmax by -\itemmargin % -\advance \leftskip by \tableindent % -\exdentamount=\tableindent -\parindent = 0pt -\parskip = \smallskipamount -\ifdim \parskip=0pt \parskip=2pt \fi% -\def\Etable{\endgraf\afterenvbreak\endgroup}% -\let\item = \internalBitem % -\let\itemx = \internalBitemx % -\let\kitem = \internalBkitem % -\let\kitemx = \internalBkitemx % -\let\xitem = \internalBxitem % -\let\xitemx = \internalBxitemx % -} - -% This is the counter used by @enumerate, which is really @itemize - -\newcount \itemno - -\def\itemize{\parsearg\itemizezzz} - -\def\itemizezzz #1{% - \begingroup % ended by the @end itemize - \itemizey {#1}{\Eitemize} -} - -\def\itemizey #1#2{% -\aboveenvbreak % -\itemmax=\itemindent % -\advance \itemmax by -\itemmargin % -\advance \leftskip by \itemindent % -\exdentamount=\itemindent -\parindent = 0pt % -\parskip = \smallskipamount % -\ifdim \parskip=0pt \parskip=2pt \fi% -\def#2{\endgraf\afterenvbreak\endgroup}% -\def\itemcontents{#1}% -\let\item=\itemizeitem} - -% Set sfcode to normal for the chars that usually have another value. -% These are `.?!:;,' -\def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000 - \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 } - -% \splitoff TOKENS\endmark defines \first to be the first token in -% TOKENS, and \rest to be the remainder. -% -\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% - -% Allow an optional argument of an uppercase letter, lowercase letter, -% or number, to specify the first label in the enumerated list. No -% argument is the same as `1'. -% -\def\enumerate{\parsearg\enumeratezzz} -\def\enumeratezzz #1{\enumeratey #1 \endenumeratey} -\def\enumeratey #1 #2\endenumeratey{% - \begingroup % ended by the @end enumerate - % - % If we were given no argument, pretend we were given `1'. - \def\thearg{#1}% - \ifx\thearg\empty \def\thearg{1}\fi - % - % Detect if the argument is a single token. If so, it might be a - % letter. Otherwise, the only valid thing it can be is a number. - % (We will always have one token, because of the test we just made. - % This is a good thing, since \splitoff doesn't work given nothing at - % all -- the first parameter is undelimited.) - \expandafter\splitoff\thearg\endmark - \ifx\rest\empty - % Only one token in the argument. It could still be anything. - % A ``lowercase letter'' is one whose \lccode is nonzero. - % An ``uppercase letter'' is one whose \lccode is both nonzero, and - % not equal to itself. - % Otherwise, we assume it's a number. - % - % We need the \relax at the end of the \ifnum lines to stop TeX from - % continuing to look for a . - % - \ifnum\lccode\expandafter`\thearg=0\relax - \numericenumerate % a number (we hope) - \else - % It's a letter. - \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax - \lowercaseenumerate % lowercase letter - \else - \uppercaseenumerate % uppercase letter - \fi - \fi - \else - % Multiple tokens in the argument. We hope it's a number. - \numericenumerate - \fi -} - -% An @enumerate whose labels are integers. The starting integer is -% given in \thearg. -% -\def\numericenumerate{% - \itemno = \thearg - \startenumeration{\the\itemno}% -} - -% The starting (lowercase) letter is in \thearg. -\def\lowercaseenumerate{% - \itemno = \expandafter`\thearg - \startenumeration{% - % Be sure we're not beyond the end of the alphabet. - \ifnum\itemno=0 - \errmessage{No more lowercase letters in @enumerate; get a bigger - alphabet}% - \fi - \char\lccode\itemno - }% -} - -% The starting (uppercase) letter is in \thearg. -\def\uppercaseenumerate{% - \itemno = \expandafter`\thearg - \startenumeration{% - % Be sure we're not beyond the end of the alphabet. - \ifnum\itemno=0 - \errmessage{No more uppercase letters in @enumerate; get a bigger - alphabet} - \fi - \char\uccode\itemno - }% -} - -% Call itemizey, adding a period to the first argument and supplying the -% common last two arguments. Also subtract one from the initial value in -% \itemno, since @item increments \itemno. -% -\def\startenumeration#1{% - \advance\itemno by -1 - \itemizey{#1.}\Eenumerate\flushcr -} - -% @alphaenumerate and @capsenumerate are abbreviations for giving an arg -% to @enumerate. -% -\def\alphaenumerate{\enumerate{a}} -\def\capsenumerate{\enumerate{A}} -\def\Ealphaenumerate{\Eenumerate} -\def\Ecapsenumerate{\Eenumerate} - -% Definition of @item while inside @itemize. - -\def\itemizeitem{% -\advance\itemno by 1 -{\let\par=\endgraf \smallbreak}% -\ifhmode \errmessage{In hmode at itemizeitem}\fi -{\parskip=0in \hskip 0pt -\hbox to 0pt{\hss \itemcontents\hskip \itemmargin}% -\vadjust{\penalty 1200}}% -\flushcr} - -% @multitable macros -% Amy Hendrickson, 8/18/94, 3/6/96 -% -% @multitable ... @end multitable will make as many columns as desired. -% Contents of each column will wrap at width given in preamble. Width -% can be specified either with sample text given in a template line, -% or in percent of \hsize, the current width of text on page. - -% Table can continue over pages but will only break between lines. - -% To make preamble: -% -% Either define widths of columns in terms of percent of \hsize: -% @multitable @columnfractions .25 .3 .45 -% @item ... -% -% Numbers following @columnfractions are the percent of the total -% current hsize to be used for each column. You may use as many -% columns as desired. - - -% Or use a template: -% @multitable {Column 1 template} {Column 2 template} {Column 3 template} -% @item ... -% using the widest term desired in each column. -% -% For those who want to use more than one line's worth of words in -% the preamble, break the line within one argument and it -% will parse correctly, i.e., -% -% @multitable {Column 1 template} {Column 2 template} {Column 3 -% template} -% Not: -% @multitable {Column 1 template} {Column 2 template} -% {Column 3 template} - -% Each new table line starts with @item, each subsequent new column -% starts with @tab. Empty columns may be produced by supplying @tab's -% with nothing between them for as many times as empty columns are needed, -% ie, @tab@tab@tab will produce two empty columns. - -% @item, @tab, @multitable or @end multitable do not need to be on their -% own lines, but it will not hurt if they are. - -% Sample multitable: - -% @multitable {Column 1 template} {Column 2 template} {Column 3 template} -% @item first col stuff @tab second col stuff @tab third col -% @item -% first col stuff -% @tab -% second col stuff -% @tab -% third col -% @item first col stuff @tab second col stuff -% @tab Many paragraphs of text may be used in any column. -% -% They will wrap at the width determined by the template. -% @item@tab@tab This will be in third column. -% @end multitable - -% Default dimensions may be reset by user. -% @multitableparskip is vertical space between paragraphs in table. -% @multitableparindent is paragraph indent in table. -% @multitablecolmargin is horizontal space to be left between columns. -% @multitablelinespace is space to leave between table items, baseline -% to baseline. -% 0pt means it depends on current normal line spacing. -% -\newskip\multitableparskip -\newskip\multitableparindent -\newdimen\multitablecolspace -\newskip\multitablelinespace -\multitableparskip=0pt -\multitableparindent=6pt -\multitablecolspace=12pt -\multitablelinespace=0pt - -% Macros used to set up halign preamble: -% -\let\endsetuptable\relax -\def\xendsetuptable{\endsetuptable} -\let\columnfractions\relax -\def\xcolumnfractions{\columnfractions} -\newif\ifsetpercent - -% #1 is the part of the @columnfraction before the decimal point, which -% is presumably either 0 or the empty string (but we don't check, we -% just throw it away). #2 is the decimal part, which we use as the -% percent of \hsize for this column. -\def\pickupwholefraction#1.#2 {% - \global\advance\colcount by 1 - \expandafter\xdef\csname col\the\colcount\endcsname{.#2\hsize}% - \setuptable -} - -\newcount\colcount -\def\setuptable#1{% - \def\firstarg{#1}% - \ifx\firstarg\xendsetuptable - \let\go = \relax - \else - \ifx\firstarg\xcolumnfractions - \global\setpercenttrue - \else - \ifsetpercent - \let\go\pickupwholefraction - \else - \global\advance\colcount by 1 - \setbox0=\hbox{#1\unskip }% Add a normal word space as a separator; - % typically that is always in the input, anyway. - \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% - \fi - \fi - \ifx\go\pickupwholefraction - % Put the argument back for the \pickupwholefraction call, so - % we'll always have a period there to be parsed. - \def\go{\pickupwholefraction#1}% - \else - \let\go = \setuptable - \fi% - \fi - \go -} - -% This used to have \hskip1sp. But then the space in a template line is -% not enough. That is bad. So let's go back to just & until we -% encounter the problem it was intended to solve again. -% --karl, nathan@acm.org, 20apr99. -\def\tab{&} - -% @multitable ... @end multitable definitions: -% -\def\multitable{\parsearg\dotable} -\def\dotable#1{\bgroup - \vskip\parskip - \let\item\crcr - \tolerance=9500 - \hbadness=9500 - \setmultitablespacing - \parskip=\multitableparskip - \parindent=\multitableparindent - \overfullrule=0pt - \global\colcount=0 - \def\Emultitable{\global\setpercentfalse\cr\egroup\egroup}% - % - % To parse everything between @multitable and @item: - \setuptable#1 \endsetuptable - % - % \everycr will reset column counter, \colcount, at the end of - % each line. Every column entry will cause \colcount to advance by one. - % The table preamble - % looks at the current \colcount to find the correct column width. - \everycr{\noalign{% - % - % \filbreak%% keeps underfull box messages off when table breaks over pages. - % Maybe so, but it also creates really weird page breaks when the table - % breaks over pages. Wouldn't \vfil be better? Wait until the problem - % manifests itself, so it can be fixed for real --karl. - \global\colcount=0\relax}}% - % - % This preamble sets up a generic column definition, which will - % be used as many times as user calls for columns. - % \vtop will set a single line and will also let text wrap and - % continue for many paragraphs if desired. - \halign\bgroup&\global\advance\colcount by 1\relax - \multistrut\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname - % - % In order to keep entries from bumping into each other - % we will add a \leftskip of \multitablecolspace to all columns after - % the first one. - % - % If a template has been used, we will add \multitablecolspace - % to the width of each template entry. - % - % If the user has set preamble in terms of percent of \hsize we will - % use that dimension as the width of the column, and the \leftskip - % will keep entries from bumping into each other. Table will start at - % left margin and final column will justify at right margin. - % - % Make sure we don't inherit \rightskip from the outer environment. - \rightskip=0pt - \ifnum\colcount=1 - % The first column will be indented with the surrounding text. - \advance\hsize by\leftskip - \else - \ifsetpercent \else - % If user has not set preamble in terms of percent of \hsize - % we will advance \hsize by \multitablecolspace. - \advance\hsize by \multitablecolspace - \fi - % In either case we will make \leftskip=\multitablecolspace: - \leftskip=\multitablecolspace - \fi - % Ignoring space at the beginning and end avoids an occasional spurious - % blank line, when TeX decides to break the line at the space before the - % box from the multistrut, so the strut ends up on a line by itself. - % For example: - % @multitable @columnfractions .11 .89 - % @item @code{#} - % @tab Legal holiday which is valid in major parts of the whole country. - % Is automatically provided with highlighting sequences respectively marking - % characters. - \noindent\ignorespaces##\unskip\multistrut}\cr -} - -\def\setmultitablespacing{% test to see if user has set \multitablelinespace. -% If so, do nothing. If not, give it an appropriate dimension based on -% current baselineskip. -\ifdim\multitablelinespace=0pt -%% strut to put in table in case some entry doesn't have descenders, -%% to keep lines equally spaced -\let\multistrut = \strut -%% Test to see if parskip is larger than space between lines of -%% table. If not, do nothing. -%% If so, set to same dimension as multitablelinespace. -\else -\gdef\multistrut{\vrule height\multitablelinespace depth\dp0 -width0pt\relax} \fi -\ifdim\multitableparskip>\multitablelinespace -\global\multitableparskip=\multitablelinespace -\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller - %% than skip between lines in the table. -\fi% -\ifdim\multitableparskip=0pt -\global\multitableparskip=\multitablelinespace -\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller - %% than skip between lines in the table. -\fi} - - -\message{conditionals,} -% Prevent errors for section commands. -% Used in @ignore and in failing conditionals. -\def\ignoresections{% - \let\chapter=\relax - \let\unnumbered=\relax - \let\top=\relax - \let\unnumberedsec=\relax - \let\unnumberedsection=\relax - \let\unnumberedsubsec=\relax - \let\unnumberedsubsection=\relax - \let\unnumberedsubsubsec=\relax - \let\unnumberedsubsubsection=\relax - \let\section=\relax - \let\subsec=\relax - \let\subsubsec=\relax - \let\subsection=\relax - \let\subsubsection=\relax - \let\appendix=\relax - \let\appendixsec=\relax - \let\appendixsection=\relax - \let\appendixsubsec=\relax - \let\appendixsubsection=\relax - \let\appendixsubsubsec=\relax - \let\appendixsubsubsection=\relax - \let\contents=\relax - \let\smallbook=\relax - \let\titlepage=\relax -} - -% Used in nested conditionals, where we have to parse the Texinfo source -% and so want to turn off most commands, in case they are used -% incorrectly. -% -\def\ignoremorecommands{% - \let\defcodeindex = \relax - \let\defcv = \relax - \let\deffn = \relax - \let\deffnx = \relax - \let\defindex = \relax - \let\defivar = \relax - \let\defmac = \relax - \let\defmethod = \relax - \let\defop = \relax - \let\defopt = \relax - \let\defspec = \relax - \let\deftp = \relax - \let\deftypefn = \relax - \let\deftypefun = \relax - \let\deftypeivar = \relax - \let\deftypevar = \relax - \let\deftypevr = \relax - \let\defun = \relax - \let\defvar = \relax - \let\defvr = \relax - \let\ref = \relax - \let\xref = \relax - \let\printindex = \relax - \let\pxref = \relax - \let\settitle = \relax - \let\setchapternewpage = \relax - \let\setchapterstyle = \relax - \let\everyheading = \relax - \let\evenheading = \relax - \let\oddheading = \relax - \let\everyfooting = \relax - \let\evenfooting = \relax - \let\oddfooting = \relax - \let\headings = \relax - \let\include = \relax - \let\lowersections = \relax - \let\down = \relax - \let\raisesections = \relax - \let\up = \relax - \let\set = \relax - \let\clear = \relax - \let\item = \relax -} - -% Ignore @ignore ... @end ignore. -% -\def\ignore{\doignore{ignore}} - -% Ignore @ifinfo, @ifhtml, @ifnottex, @html, @menu, and @direntry text. -% -\def\ifinfo{\doignore{ifinfo}} -\def\ifhtml{\doignore{ifhtml}} -\def\ifnottex{\doignore{ifnottex}} -\def\html{\doignore{html}} -\def\menu{\doignore{menu}} -\def\direntry{\doignore{direntry}} - -% @dircategory CATEGORY -- specify a category of the dir file -% which this file should belong to. Ignore this in TeX. -\let\dircategory = \comment - -% Ignore text until a line `@end #1'. -% -\def\doignore#1{\begingroup - % Don't complain about control sequences we have declared \outer. - \ignoresections - % - % Define a command to swallow text until we reach `@end #1'. - % This @ is a catcode 12 token (that is the normal catcode of @ in - % this texinfo.tex file). We change the catcode of @ below to match. - \long\def\doignoretext##1@end #1{\enddoignore}% - % - % Make sure that spaces turn into tokens that match what \doignoretext wants. - \catcode32 = 10 - % - % Ignore braces, too, so mismatched braces don't cause trouble. - \catcode`\{ = 9 - \catcode`\} = 9 - % - % We must not have @c interpreted as a control sequence. - \catcode`\@ = 12 - % - % Make the letter c a comment character so that the rest of the line - % will be ignored. This way, the document can have (for example) - % @c @end ifinfo - % and the @end ifinfo will be properly ignored. - % (We've just changed @ to catcode 12.) - \catcode`\c = 14 - % - % And now expand that command. - \doignoretext -} - -% What we do to finish off ignored text. -% -\def\enddoignore{\endgroup\ignorespaces}% - -\newif\ifwarnedobs\warnedobsfalse -\def\obstexwarn{% - \ifwarnedobs\relax\else - % We need to warn folks that they may have trouble with TeX 3.0. - % This uses \immediate\write16 rather than \message to get newlines. - \immediate\write16{} - \immediate\write16{WARNING: for users of Unix TeX 3.0!} - \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).} - \immediate\write16{If you are running another version of TeX, relax.} - \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.} - \immediate\write16{ Then upgrade your TeX installation if you can.} - \immediate\write16{ (See ftp://ftp.gnu.org/pub/gnu/TeX.README.)} - \immediate\write16{If you are stuck with version 3.0, run the} - \immediate\write16{ script ``tex3patch'' from the Texinfo distribution} - \immediate\write16{ to use a workaround.} - \immediate\write16{} - \global\warnedobstrue - \fi -} - -% **In TeX 3.0, setting text in \nullfont hangs tex. For a -% workaround (which requires the file ``dummy.tfm'' to be installed), -% uncomment the following line: -\font\nullfont=dummy\let\obstexwarn=\relax - -% Ignore text, except that we keep track of conditional commands for -% purposes of nesting, up to an `@end #1' command. -% -\def\nestedignore#1{% - \obstexwarn - % We must actually expand the ignored text to look for the @end - % command, so that nested ignore constructs work. Thus, we put the - % text into a \vbox and then do nothing with the result. To minimize - % the change of memory overflow, we follow the approach outlined on - % page 401 of the TeXbook: make the current font be a dummy font. - % - \setbox0 = \vbox\bgroup - % Don't complain about control sequences we have declared \outer. - \ignoresections - % - % Define `@end #1' to end the box, which will in turn undefine the - % @end command again. - \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}% - % - % We are going to be parsing Texinfo commands. Most cause no - % trouble when they are used incorrectly, but some commands do - % complicated argument parsing or otherwise get confused, so we - % undefine them. - % - % We can't do anything about stray @-signs, unfortunately; - % they'll produce `undefined control sequence' errors. - \ignoremorecommands - % - % Set the current font to be \nullfont, a TeX primitive, and define - % all the font commands to also use \nullfont. We don't use - % dummy.tfm, as suggested in the TeXbook, because not all sites - % might have that installed. Therefore, math mode will still - % produce output, but that should be an extremely small amount of - % stuff compared to the main input. - % - \nullfont - \let\tenrm = \nullfont \let\tenit = \nullfont \let\tensl = \nullfont - \let\tenbf = \nullfont \let\tentt = \nullfont \let\smallcaps = \nullfont - \let\tensf = \nullfont - % Similarly for index fonts (mostly for their use in - % smallexample) - \let\indrm = \nullfont \let\indit = \nullfont \let\indsl = \nullfont - \let\indbf = \nullfont \let\indtt = \nullfont \let\indsc = \nullfont - \let\indsf = \nullfont - % - % Don't complain when characters are missing from the fonts. - \tracinglostchars = 0 - % - % Don't bother to do space factor calculations. - \frenchspacing - % - % Don't report underfull hboxes. - \hbadness = 10000 - % - % Do minimal line-breaking. - \pretolerance = 10000 - % - % Do not execute instructions in @tex - \def\tex{\doignore{tex}}% - % Do not execute macro definitions. - % `c' is a comment character, so the word `macro' will get cut off. - \def\macro{\doignore{ma}}% -} - -% @set VAR sets the variable VAR to an empty value. -% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. -% -% Since we want to separate VAR from REST-OF-LINE (which might be -% empty), we can't just use \parsearg; we have to insert a space of our -% own to delimit the rest of the line, and then take it out again if we -% didn't need it. Make sure the catcode of space is correct to avoid -% losing inside @example, for instance. -% -\def\set{\begingroup\catcode` =10 - \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR. - \parsearg\setxxx} -\def\setxxx#1{\setyyy#1 \endsetyyy} -\def\setyyy#1 #2\endsetyyy{% - \def\temp{#2}% - \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty - \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted. - \fi - \endgroup -} -% Can't use \xdef to pre-expand #2 and save some time, since \temp or -% \next or other control sequences that we've defined might get us into -% an infinite loop. Consider `@set foo @cite{bar}'. -\def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}} - -% @clear VAR clears (i.e., unsets) the variable VAR. -% -\def\clear{\parsearg\clearxxx} -\def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax} - -% @value{foo} gets the text saved in variable foo. -{ - \catcode`\_ = \active - % - % We might end up with active _ or - characters in the argument if - % we're called from @code, as @code{@value{foo-bar_}}. So \let any - % such active characters to their normal equivalents. - \gdef\value{\begingroup - \catcode`\-=12 \catcode`\_=12 - \indexbreaks \let_\normalunderscore - \valuexxx} -} -\def\valuexxx#1{\expandablevalue{#1}\endgroup} - -% We have this subroutine so that we can handle at least some @value's -% properly in indexes (we \let\value to this in \indexdummies). Ones -% whose names contain - or _ still won't work, but we can't do anything -% about that. The command has to be fully expandable, since the result -% winds up in the index file. This means that if the variable's value -% contains other Texinfo commands, it's almost certain it will fail -% (although perhaps we could fix that with sufficient work to do a -% one-level expansion on the result, instead of complete). -% -\def\expandablevalue#1{% - \expandafter\ifx\csname SET#1\endcsname\relax - {[No value for ``#1'']}% - \else - \csname SET#1\endcsname - \fi -} - -% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined -% with @set. -% -\def\ifset{\parsearg\ifsetxxx} -\def\ifsetxxx #1{% - \expandafter\ifx\csname SET#1\endcsname\relax - \expandafter\ifsetfail - \else - \expandafter\ifsetsucceed - \fi -} -\def\ifsetsucceed{\conditionalsucceed{ifset}} -\def\ifsetfail{\nestedignore{ifset}} -\defineunmatchedend{ifset} - -% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been -% defined with @set, or has been undefined with @clear. -% -\def\ifclear{\parsearg\ifclearxxx} -\def\ifclearxxx #1{% - \expandafter\ifx\csname SET#1\endcsname\relax - \expandafter\ifclearsucceed - \else - \expandafter\ifclearfail - \fi -} -\def\ifclearsucceed{\conditionalsucceed{ifclear}} -\def\ifclearfail{\nestedignore{ifclear}} -\defineunmatchedend{ifclear} - -% @iftex, @ifnothtml, @ifnotinfo always succeed; we read the text -% following, through the first @end iftex (etc.). Make `@end iftex' -% (etc.) valid only after an @iftex. -% -\def\iftex{\conditionalsucceed{iftex}} -\def\ifnothtml{\conditionalsucceed{ifnothtml}} -\def\ifnotinfo{\conditionalsucceed{ifnotinfo}} -\defineunmatchedend{iftex} -\defineunmatchedend{ifnothtml} -\defineunmatchedend{ifnotinfo} - -% We can't just want to start a group at @iftex (for example) and end it -% at @end iftex, since then @set commands inside the conditional have no -% effect (they'd get reverted at the end of the group). So we must -% define \Eiftex to redefine itself to be its previous value. (We can't -% just define it to fail again with an ``unmatched end'' error, since -% the @ifset might be nested.) -% -\def\conditionalsucceed#1{% - \edef\temp{% - % Remember the current value of \E#1. - \let\nece{prevE#1} = \nece{E#1}% - % - % At the `@end #1', redefine \E#1 to be its previous value. - \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}% - }% - \temp -} - -% We need to expand lots of \csname's, but we don't want to expand the -% control sequences after we've constructed them. -% -\def\nece#1{\expandafter\noexpand\csname#1\endcsname} - -% @defininfoenclose. -\let\definfoenclose=\comment - - -\message{indexing,} -% Index generation facilities - -% Define \newwrite to be identical to plain tex's \newwrite -% except not \outer, so it can be used within \newindex. -{\catcode`\@=11 -\gdef\newwrite{\alloc@7\write\chardef\sixt@@n}} - -% \newindex {foo} defines an index named foo. -% It automatically defines \fooindex such that -% \fooindex ...rest of line... puts an entry in the index foo. -% It also defines \fooindfile to be the number of the output channel for -% the file that accumulates this index. The file's extension is foo. -% The name of an index should be no more than 2 characters long -% for the sake of vms. -% -\def\newindex#1{% - \iflinks - \expandafter\newwrite \csname#1indfile\endcsname - \openout \csname#1indfile\endcsname \jobname.#1 % Open the file - \fi - \expandafter\xdef\csname#1index\endcsname{% % Define @#1index - \noexpand\doindex{#1}} -} - -% @defindex foo == \newindex{foo} - -\def\defindex{\parsearg\newindex} - -% Define @defcodeindex, like @defindex except put all entries in @code. - -\def\newcodeindex#1{% - \iflinks - \expandafter\newwrite \csname#1indfile\endcsname - \openout \csname#1indfile\endcsname \jobname.#1 - \fi - \expandafter\xdef\csname#1index\endcsname{% - \noexpand\docodeindex{#1}} -} - -\def\defcodeindex{\parsearg\newcodeindex} - -% @synindex foo bar makes index foo feed into index bar. -% Do this instead of @defindex foo if you don't want it as a separate index. -% The \closeout helps reduce unnecessary open files; the limit on the -% Acorn RISC OS is a mere 16 files. -\def\synindex#1 #2 {% - \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname - \expandafter\closeout\csname#1indfile\endcsname - \expandafter\let\csname#1indfile\endcsname=\synindexfoo - \expandafter\xdef\csname#1index\endcsname{% define \xxxindex - \noexpand\doindex{#2}}% -} - -% @syncodeindex foo bar similar, but put all entries made for index foo -% inside @code. -\def\syncodeindex#1 #2 {% - \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname - \expandafter\closeout\csname#1indfile\endcsname - \expandafter\let\csname#1indfile\endcsname=\synindexfoo - \expandafter\xdef\csname#1index\endcsname{% define \xxxindex - \noexpand\docodeindex{#2}}% -} - -% Define \doindex, the driver for all \fooindex macros. -% Argument #1 is generated by the calling \fooindex macro, -% and it is "foo", the name of the index. - -% \doindex just uses \parsearg; it calls \doind for the actual work. -% This is because \doind is more useful to call from other macros. - -% There is also \dosubind {index}{topic}{subtopic} -% which makes an entry in a two-level index such as the operation index. - -\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} -\def\singleindexer #1{\doind{\indexname}{#1}} - -% like the previous two, but they put @code around the argument. -\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} -\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} - -\def\indexdummies{% -\def\ { }% -% Take care of the plain tex accent commands. -\def\"{\realbackslash "}% -\def\`{\realbackslash `}% -\def\'{\realbackslash '}% -\def\^{\realbackslash ^}% -\def\~{\realbackslash ~}% -\def\={\realbackslash =}% -\def\b{\realbackslash b}% -\def\c{\realbackslash c}% -\def\d{\realbackslash d}% -\def\u{\realbackslash u}% -\def\v{\realbackslash v}% -\def\H{\realbackslash H}% -% Take care of the plain tex special European modified letters. -\def\oe{\realbackslash oe}% -\def\ae{\realbackslash ae}% -\def\aa{\realbackslash aa}% -\def\OE{\realbackslash OE}% -\def\AE{\realbackslash AE}% -\def\AA{\realbackslash AA}% -\def\o{\realbackslash o}% -\def\O{\realbackslash O}% -\def\l{\realbackslash l}% -\def\L{\realbackslash L}% -\def\ss{\realbackslash ss}% -% Take care of texinfo commands likely to appear in an index entry. -% (Must be a way to avoid doing expansion at all, and thus not have to -% laboriously list every single command here.) -\def\@{@}% will be @@ when we switch to @ as escape char. -% Need these in case \tex is in effect and \{ is a \delimiter again. -% But can't use \lbracecmd and \rbracecmd because texindex assumes -% braces and backslashes are used only as delimiters. -\let\{ = \mylbrace -\let\} = \myrbrace -\def\_{{\realbackslash _}}% -\def\w{\realbackslash w }% -\def\bf{\realbackslash bf }% -%\def\rm{\realbackslash rm }% -\def\sl{\realbackslash sl }% -\def\sf{\realbackslash sf}% -\def\tt{\realbackslash tt}% -\def\gtr{\realbackslash gtr}% -\def\less{\realbackslash less}% -\def\hat{\realbackslash hat}% -\def\TeX{\realbackslash TeX}% -\def\dots{\realbackslash dots }% -\def\result{\realbackslash result}% -\def\equiv{\realbackslash equiv}% -\def\expansion{\realbackslash expansion}% -\def\print{\realbackslash print}% -\def\error{\realbackslash error}% -\def\point{\realbackslash point}% -\def\copyright{\realbackslash copyright}% -\def\tclose##1{\realbackslash tclose {##1}}% -\def\code##1{\realbackslash code {##1}}% -\def\uref##1{\realbackslash uref {##1}}% -\def\url##1{\realbackslash url {##1}}% -\def\env##1{\realbackslash env {##1}}% -\def\command##1{\realbackslash command {##1}}% -\def\option##1{\realbackslash option {##1}}% -\def\dotless##1{\realbackslash dotless {##1}}% -\def\samp##1{\realbackslash samp {##1}}% -\def\,##1{\realbackslash ,{##1}}% -\def\t##1{\realbackslash t {##1}}% -\def\r##1{\realbackslash r {##1}}% -\def\i##1{\realbackslash i {##1}}% -\def\b##1{\realbackslash b {##1}}% -\def\sc##1{\realbackslash sc {##1}}% -\def\cite##1{\realbackslash cite {##1}}% -\def\key##1{\realbackslash key {##1}}% -\def\file##1{\realbackslash file {##1}}% -\def\var##1{\realbackslash var {##1}}% -\def\kbd##1{\realbackslash kbd {##1}}% -\def\dfn##1{\realbackslash dfn {##1}}% -\def\emph##1{\realbackslash emph {##1}}% -\def\acronym##1{\realbackslash acronym {##1}}% -% -% Handle some cases of @value -- where the variable name does not -% contain - or _, and the value does not contain any -% (non-fully-expandable) commands. -\let\value = \expandablevalue -% -\unsepspaces -% Turn off macro expansion -\turnoffmacros -} - -% If an index command is used in an @example environment, any spaces -% therein should become regular spaces in the raw index file, not the -% expansion of \tie (\\leavevmode \penalty \@M \ ). -{\obeyspaces - \gdef\unsepspaces{\obeyspaces\let =\space}} - -% \indexnofonts no-ops all font-change commands. -% This is used when outputting the strings to sort the index by. -\def\indexdummyfont#1{#1} -\def\indexdummytex{TeX} -\def\indexdummydots{...} - -\def\indexnofonts{% -% Just ignore accents. -\let\,=\indexdummyfont -\let\"=\indexdummyfont -\let\`=\indexdummyfont -\let\'=\indexdummyfont -\let\^=\indexdummyfont -\let\~=\indexdummyfont -\let\==\indexdummyfont -\let\b=\indexdummyfont -\let\c=\indexdummyfont -\let\d=\indexdummyfont -\let\u=\indexdummyfont -\let\v=\indexdummyfont -\let\H=\indexdummyfont -\let\dotless=\indexdummyfont -% Take care of the plain tex special European modified letters. -\def\oe{oe}% -\def\ae{ae}% -\def\aa{aa}% -\def\OE{OE}% -\def\AE{AE}% -\def\AA{AA}% -\def\o{o}% -\def\O{O}% -\def\l{l}% -\def\L{L}% -\def\ss{ss}% -\let\w=\indexdummyfont -\let\t=\indexdummyfont -\let\r=\indexdummyfont -\let\i=\indexdummyfont -\let\b=\indexdummyfont -\let\emph=\indexdummyfont -\let\strong=\indexdummyfont -\let\cite=\indexdummyfont -\let\sc=\indexdummyfont -%Don't no-op \tt, since it isn't a user-level command -% and is used in the definitions of the active chars like <, >, |... -%\let\tt=\indexdummyfont -\let\tclose=\indexdummyfont -\let\code=\indexdummyfont -\let\url=\indexdummyfont -\let\uref=\indexdummyfont -\let\env=\indexdummyfont -\let\command=\indexdummyfont -\let\option=\indexdummyfont -\let\file=\indexdummyfont -\let\samp=\indexdummyfont -\let\kbd=\indexdummyfont -\let\key=\indexdummyfont -\let\var=\indexdummyfont -\let\TeX=\indexdummytex -\let\dots=\indexdummydots -\def\@{@}% -} - -% To define \realbackslash, we must make \ not be an escape. -% We must first make another character (@) an escape -% so we do not become unable to do a definition. - -{\catcode`\@=0 \catcode`\\=\other - @gdef@realbackslash{\}} - -\let\indexbackslash=0 %overridden during \printindex. -\let\SETmarginindex=\relax % put index entries in margin (undocumented)? - -% For \ifx comparisons. -\def\emptymacro{\empty} - -% Most index entries go through here, but \dosubind is the general case. -% -\def\doind#1#2{\dosubind{#1}{#2}\empty} - -% Workhorse for all \fooindexes. -% #1 is name of index, #2 is stuff to put there, #3 is subentry -- -% \empty if called from \doind, as we usually are. The main exception -% is with defuns, which call us directly. -% -\def\dosubind#1#2#3{% - % Put the index entry in the margin if desired. - \ifx\SETmarginindex\relax\else - \insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}% - \fi - {% - \count255=\lastpenalty - {% - \indexdummies % Must do this here, since \bf, etc expand at this stage - \escapechar=`\\ - {% - \let\folio = 0% We will expand all macros now EXCEPT \folio. - \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now - % so it will be output as is; and it will print as backslash. - % - \def\thirdarg{#3}% - % - % If third arg is present, precede it with space in sort key. - \ifx\thirdarg\emptymacro - \let\subentry = \empty - \else - \def\subentry{ #3}% - \fi - % - % First process the index entry with all font commands turned - % off to get the string to sort by. - {\indexnofonts \xdef\indexsorttmp{#2\subentry}}% - % - % Now the real index entry with the fonts. - \toks0 = {#2}% - % - % If third (subentry) arg is present, add it to the index - % string. And include a space. - \ifx\thirdarg\emptymacro \else - \toks0 = \expandafter{\the\toks0 \space #3}% - \fi - % - % Set up the complete index entry, with both the sort key - % and the original text, including any font commands. We write - % three arguments to \entry to the .?? file, texindex reduces to - % two when writing the .??s sorted result. - \edef\temp{% - \write\csname#1indfile\endcsname{% - \realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}% - }% - % - % If a skip is the last thing on the list now, preserve it - % by backing up by \lastskip, doing the \write, then inserting - % the skip again. Otherwise, the whatsit generated by the - % \write will make \lastskip zero. The result is that sequences - % like this: - % @end defun - % @tindex whatever - % @defun ... - % will have extra space inserted, because the \medbreak in the - % start of the @defun won't see the skip inserted by the @end of - % the previous defun. - % - % But don't do any of this if we're not in vertical mode. We - % don't want to do a \vskip and prematurely end a paragraph. - % - % Avoid page breaks due to these extra skips, too. - % - \iflinks - \ifvmode - \skip0 = \lastskip - \ifdim\lastskip = 0pt \else \nobreak\vskip-\lastskip \fi - \fi - % - \temp % do the write - % - % - \ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi - \fi - }% - }% - \penalty\count255 - }% -} - -% The index entry written in the file actually looks like -% \entry {sortstring}{page}{topic} -% or -% \entry {sortstring}{page}{topic}{subtopic} -% The texindex program reads in these files and writes files -% containing these kinds of lines: -% \initial {c} -% before the first topic whose initial is c -% \entry {topic}{pagelist} -% for a topic that is used without subtopics -% \primary {topic} -% for the beginning of a topic that is used with subtopics -% \secondary {subtopic}{pagelist} -% for each subtopic. - -% Define the user-accessible indexing commands -% @findex, @vindex, @kindex, @cindex. - -\def\findex {\fnindex} -\def\kindex {\kyindex} -\def\cindex {\cpindex} -\def\vindex {\vrindex} -\def\tindex {\tpindex} -\def\pindex {\pgindex} - -\def\cindexsub {\begingroup\obeylines\cindexsub} -{\obeylines % -\gdef\cindexsub "#1" #2^^M{\endgroup % -\dosubind{cp}{#2}{#1}}} - -% Define the macros used in formatting output of the sorted index material. - -% @printindex causes a particular index (the ??s file) to get printed. -% It does not print any chapter heading (usually an @unnumbered). -% -\def\printindex{\parsearg\doprintindex} -\def\doprintindex#1{\begingroup - \dobreak \chapheadingskip{10000}% - % - \indexfonts \rm - \tolerance = 9500 - \indexbreaks - % - % See if the index file exists and is nonempty. - % Change catcode of @ here so that if the index file contains - % \initial {@} - % as its first line, TeX doesn't complain about mismatched braces - % (because it thinks @} is a control sequence). - \catcode`\@ = 11 - \openin 1 \jobname.#1s - \ifeof 1 - % \enddoublecolumns gets confused if there is no text in the index, - % and it loses the chapter title and the aux file entries for the - % index. The easiest way to prevent this problem is to make sure - % there is some text. - \putwordIndexNonexistent - \else - % - % If the index file exists but is empty, then \openin leaves \ifeof - % false. We have to make TeX try to read something from the file, so - % it can discover if there is anything in it. - \read 1 to \temp - \ifeof 1 - \putwordIndexIsEmpty - \else - % Index files are almost Texinfo source, but we use \ as the escape - % character. It would be better to use @, but that's too big a change - % to make right now. - \def\indexbackslash{\rawbackslashxx}% - \catcode`\\ = 0 - \escapechar = `\\ - \begindoublecolumns - \input \jobname.#1s - \enddoublecolumns - \fi - \fi - \closein 1 -\endgroup} - -% These macros are used by the sorted index file itself. -% Change them to control the appearance of the index. - -\def\initial#1{{% - % Some minor font changes for the special characters. - \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt - % - % Remove any glue we may have, we'll be inserting our own. - \removelastskip - % - % We like breaks before the index initials, so insert a bonus. - \penalty -300 - % - % Typeset the initial. Making this add up to a whole number of - % baselineskips increases the chance of the dots lining up from column - % to column. It still won't often be perfect, because of the stretch - % we need before each entry, but it's better. - % - % No shrink because it confuses \balancecolumns. - \vskip 1.67\baselineskip plus .5\baselineskip - \leftline{\secbf #1}% - \vskip .33\baselineskip plus .1\baselineskip - % - % Do our best not to break after the initial. - \nobreak -}} - -% This typesets a paragraph consisting of #1, dot leaders, and then #2 -% flush to the right margin. It is used for index and table of contents -% entries. The paragraph is indented by \leftskip. -% -\def\entry#1#2{\begingroup - % - % Start a new paragraph if necessary, so our assignments below can't - % affect previous text. - \par - % - % Do not fill out the last line with white space. - \parfillskip = 0in - % - % No extra space above this paragraph. - \parskip = 0in - % - % Do not prefer a separate line ending with a hyphen to fewer lines. - \finalhyphendemerits = 0 - % - % \hangindent is only relevant when the entry text and page number - % don't both fit on one line. In that case, bob suggests starting the - % dots pretty far over on the line. Unfortunately, a large - % indentation looks wrong when the entry text itself is broken across - % lines. So we use a small indentation and put up with long leaders. - % - % \hangafter is reset to 1 (which is the value we want) at the start - % of each paragraph, so we need not do anything with that. - \hangindent = 2em - % - % When the entry text needs to be broken, just fill out the first line - % with blank space. - \rightskip = 0pt plus1fil - % - % A bit of stretch before each entry for the benefit of balancing columns. - \vskip 0pt plus1pt - % - % Start a ``paragraph'' for the index entry so the line breaking - % parameters we've set above will have an effect. - \noindent - % - % Insert the text of the index entry. TeX will do line-breaking on it. - #1% - % The following is kludged to not output a line of dots in the index if - % there are no page numbers. The next person who breaks this will be - % cursed by a Unix daemon. - \def\tempa{{\rm }}% - \def\tempb{#2}% - \edef\tempc{\tempa}% - \edef\tempd{\tempb}% - \ifx\tempc\tempd\ \else% - % - % If we must, put the page number on a line of its own, and fill out - % this line with blank space. (The \hfil is overwhelmed with the - % fill leaders glue in \indexdotfill if the page number does fit.) - \hfil\penalty50 - \null\nobreak\indexdotfill % Have leaders before the page number. - % - % The `\ ' here is removed by the implicit \unskip that TeX does as - % part of (the primitive) \par. Without it, a spurious underfull - % \hbox ensues. - \ #2% The page number ends the paragraph. - \fi% - \par -\endgroup} - -% Like \dotfill except takes at least 1 em. -\def\indexdotfill{\cleaders - \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill} - -\def\primary #1{\line{#1\hfil}} - -\newskip\secondaryindent \secondaryindent=0.5cm - -\def\secondary #1#2{ -{\parfillskip=0in \parskip=0in -\hangindent =1in \hangafter=1 -\noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par -}} - -% Define two-column mode, which we use to typeset indexes. -% Adapted from the TeXbook, page 416, which is to say, -% the manmac.tex format used to print the TeXbook itself. -\catcode`\@=11 - -\newbox\partialpage -\newdimen\doublecolumnhsize - -\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns - % Grab any single-column material above us. - \output = {% - % - % Here is a possibility not foreseen in manmac: if we accumulate a - % whole lot of material, we might end up calling this \output - % routine twice in a row (see the doublecol-lose test, which is - % essentially a couple of indexes with @setchapternewpage off). In - % that case we just ship out what is in \partialpage with the normal - % output routine. Generally, \partialpage will be empty when this - % runs and this will be a no-op. See the indexspread.tex test case. - \ifvoid\partialpage \else - \onepageout{\pagecontents\partialpage}% - \fi - % - \global\setbox\partialpage = \vbox{% - % Unvbox the main output page. - \unvbox\PAGE - \kern-\topskip \kern\baselineskip - }% - }% - \eject % run that output routine to set \partialpage - % - % Use the double-column output routine for subsequent pages. - \output = {\doublecolumnout}% - % - % Change the page size parameters. We could do this once outside this - % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 - % format, but then we repeat the same computation. Repeating a couple - % of assignments once per index is clearly meaningless for the - % execution time, so we may as well do it in one place. - % - % First we halve the line length, less a little for the gutter between - % the columns. We compute the gutter based on the line length, so it - % changes automatically with the paper format. The magic constant - % below is chosen so that the gutter has the same value (well, +-<1pt) - % as it did when we hard-coded it. - % - % We put the result in a separate register, \doublecolumhsize, so we - % can restore it in \pagesofar, after \hsize itself has (potentially) - % been clobbered. - % - \doublecolumnhsize = \hsize - \advance\doublecolumnhsize by -.04154\hsize - \divide\doublecolumnhsize by 2 - \hsize = \doublecolumnhsize - % - % Double the \vsize as well. (We don't need a separate register here, - % since nobody clobbers \vsize.) - \advance\vsize by -\ht\partialpage - \vsize = 2\vsize -} - -% The double-column output routine for all double-column pages except -% the last. -% -\def\doublecolumnout{% - \splittopskip=\topskip \splitmaxdepth=\maxdepth - % Get the available space for the double columns -- the normal - % (undoubled) page height minus any material left over from the - % previous page. - \dimen@ = \vsize - \divide\dimen@ by 2 - % - % box0 will be the left-hand column, box2 the right. - \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ - \onepageout\pagesofar - \unvbox255 - \penalty\outputpenalty -} -\def\pagesofar{% - % Re-output the contents of the output page -- any previous material, - % followed by the two boxes we just split, in box0 and box2. - \unvbox\partialpage - % - \hsize = \doublecolumnhsize - \wd0=\hsize \wd2=\hsize - \hbox to\pagewidth{\box0\hfil\box2}% -} -\def\enddoublecolumns{% - \output = {% - % Split the last of the double-column material. Leave it on the - % current page, no automatic page break. - \balancecolumns - % - % If we end up splitting too much material for the current page, - % though, there will be another page break right after this \output - % invocation ends. Having called \balancecolumns once, we do not - % want to call it again. Therefore, reset \output to its normal - % definition right away. (We hope \balancecolumns will never be - % called on to balance too much material, but if it is, this makes - % the output somewhat more palatable.) - \global\output = {\onepageout{\pagecontents\PAGE}}% - }% - \eject - \endgroup % started in \begindoublecolumns - % - % \pagegoal was set to the doubled \vsize above, since we restarted - % the current page. We're now back to normal single-column - % typesetting, so reset \pagegoal to the normal \vsize (after the - % \endgroup where \vsize got restored). - \pagegoal = \vsize -} -\def\balancecolumns{% - % Called at the end of the double column material. - \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120. - \dimen@ = \ht0 - \advance\dimen@ by \topskip - \advance\dimen@ by-\baselineskip - \divide\dimen@ by 2 % target to split to - %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}% - \splittopskip = \topskip - % Loop until we get a decent breakpoint. - {% - \vbadness = 10000 - \loop - \global\setbox3 = \copy0 - \global\setbox1 = \vsplit3 to \dimen@ - \ifdim\ht3>\dimen@ - \global\advance\dimen@ by 1pt - \repeat - }% - %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}% - \setbox0=\vbox to\dimen@{\unvbox1}% - \setbox2=\vbox to\dimen@{\unvbox3}% - % - \pagesofar -} -\catcode`\@ = \other - - -\message{sectioning,} -% Chapters, sections, etc. - -\newcount\chapno -\newcount\secno \secno=0 -\newcount\subsecno \subsecno=0 -\newcount\subsubsecno \subsubsecno=0 - -% This counter is funny since it counts through charcodes of letters A, B, ... -% The \the is necessary, despite appearances, because \appendixletter is -% expanded while writing the .toc file. \char\appendixno is not -% expandable, thus it is written literally, thus all appendixes come out -% with the same letter (or @) in the toc without it. -\newcount\appendixno \appendixno = `\@ -\def\appendixletter{\char\the\appendixno} - -% Each @chapter defines this as the name of the chapter. -% page headings and footings can use it. @section does likewise. -\def\thischapter{} -\def\thissection{} - -\newcount\absseclevel % used to calculate proper heading level -\newcount\secbase\secbase=0 % @raise/lowersections modify this count - -% @raisesections: treat @section as chapter, @subsection as section, etc. -\def\raisesections{\global\advance\secbase by -1} -\let\up=\raisesections % original BFox name - -% @lowersections: treat @chapter as section, @section as subsection, etc. -\def\lowersections{\global\advance\secbase by 1} -\let\down=\lowersections % original BFox name - -% Choose a numbered-heading macro -% #1 is heading level if unmodified by @raisesections or @lowersections -% #2 is text for heading -\def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 -\ifcase\absseclevel - \chapterzzz{#2} -\or - \seczzz{#2} -\or - \numberedsubseczzz{#2} -\or - \numberedsubsubseczzz{#2} -\else - \ifnum \absseclevel<0 - \chapterzzz{#2} - \else - \numberedsubsubseczzz{#2} - \fi -\fi -} - -% like \numhead, but chooses appendix heading levels -\def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 -\ifcase\absseclevel - \appendixzzz{#2} -\or - \appendixsectionzzz{#2} -\or - \appendixsubseczzz{#2} -\or - \appendixsubsubseczzz{#2} -\else - \ifnum \absseclevel<0 - \appendixzzz{#2} - \else - \appendixsubsubseczzz{#2} - \fi -\fi -} - -% like \numhead, but chooses numberless heading levels -\def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 -\ifcase\absseclevel - \unnumberedzzz{#2} -\or - \unnumberedseczzz{#2} -\or - \unnumberedsubseczzz{#2} -\or - \unnumberedsubsubseczzz{#2} -\else - \ifnum \absseclevel<0 - \unnumberedzzz{#2} - \else - \unnumberedsubsubseczzz{#2} - \fi -\fi -} - -% @chapter, @appendix, @unnumbered. -\def\thischaptername{No Chapter Title} -\outer\def\chapter{\parsearg\chapteryyy} -\def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz -\def\chapterzzz #1{% -\secno=0 \subsecno=0 \subsubsecno=0 -\global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}% -\chapmacro {#1}{\the\chapno}% -\gdef\thissection{#1}% -\gdef\thischaptername{#1}% -% We don't substitute the actual chapter name into \thischapter -% because we don't want its macros evaluated now. -\xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}% - {\the\chapno}}}% -\temp -\donoderef -\global\let\section = \numberedsec -\global\let\subsection = \numberedsubsec -\global\let\subsubsection = \numberedsubsubsec -} - -\outer\def\appendix{\parsearg\appendixyyy} -\def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz -\def\appendixzzz #1{% -\secno=0 \subsecno=0 \subsubsecno=0 -\global\advance \appendixno by 1 -\message{\putwordAppendix\space \appendixletter}% -\chapmacro {#1}{\putwordAppendix{} \appendixletter}% -\gdef\thissection{#1}% -\gdef\thischaptername{#1}% -\xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}% - {\putwordAppendix{} \appendixletter}}}% -\temp -\appendixnoderef -\global\let\section = \appendixsec -\global\let\subsection = \appendixsubsec -\global\let\subsubsection = \appendixsubsubsec -} - -% @centerchap is like @unnumbered, but the heading is centered. -\outer\def\centerchap{\parsearg\centerchapyyy} -\def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}} - -% @top is like @unnumbered. -\outer\def\top{\parsearg\unnumberedyyy} - -\outer\def\unnumbered{\parsearg\unnumberedyyy} -\def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz -\def\unnumberedzzz #1{% -\secno=0 \subsecno=0 \subsubsecno=0 -% -% This used to be simply \message{#1}, but TeX fully expands the -% argument to \message. Therefore, if #1 contained @-commands, TeX -% expanded them. For example, in `@unnumbered The @cite{Book}', TeX -% expanded @cite (which turns out to cause errors because \cite is meant -% to be executed, not expanded). -% -% Anyway, we don't want the fully-expanded definition of @cite to appear -% as a result of the \message, we just want `@cite' itself. We use -% \the to achieve this: TeX expands \the only once, -% simply yielding the contents of . (We also do this for -% the toc entries.) -\toks0 = {#1}\message{(\the\toks0)}% -% -\unnumbchapmacro {#1}% -\gdef\thischapter{#1}\gdef\thissection{#1}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash unnumbchapentry{\the\toks0}}}% -\temp -\unnumbnoderef -\global\let\section = \unnumberedsec -\global\let\subsection = \unnumberedsubsec -\global\let\subsubsection = \unnumberedsubsubsec -} - -% Sections. -\outer\def\numberedsec{\parsearg\secyyy} -\def\secyyy #1{\numhead1{#1}} % normally calls seczzz -\def\seczzz #1{% -\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % -\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}% - {\the\chapno}{\the\secno}}}% -\temp -\donoderef -\nobreak -} - -\outer\def\appendixsection{\parsearg\appendixsecyyy} -\outer\def\appendixsec{\parsearg\appendixsecyyy} -\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz -\def\appendixsectionzzz #1{% -\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % -\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}% - {\appendixletter}{\the\secno}}}% -\temp -\appendixnoderef -\nobreak -} - -\outer\def\unnumberedsec{\parsearg\unnumberedsecyyy} -\def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz -\def\unnumberedseczzz #1{% -\plainsecheading {#1}\gdef\thissection{#1}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsecentry{\the\toks0}}}% -\temp -\unnumbnoderef -\nobreak -} - -% Subsections. -\outer\def\numberedsubsec{\parsearg\numberedsubsecyyy} -\def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz -\def\numberedsubseczzz #1{% -\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % -\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}% - {\the\chapno}{\the\secno}{\the\subsecno}}}% -\temp -\donoderef -\nobreak -} - -\outer\def\appendixsubsec{\parsearg\appendixsubsecyyy} -\def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz -\def\appendixsubseczzz #1{% -\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % -\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}% - {\appendixletter}{\the\secno}{\the\subsecno}}}% -\temp -\appendixnoderef -\nobreak -} - -\outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy} -\def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz -\def\unnumberedsubseczzz #1{% -\plainsubsecheading {#1}\gdef\thissection{#1}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsecentry% - {\the\toks0}}}% -\temp -\unnumbnoderef -\nobreak -} - -% Subsubsections. -\outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy} -\def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz -\def\numberedsubsubseczzz #1{% -\gdef\thissection{#1}\global\advance \subsubsecno by 1 % -\subsubsecheading {#1} - {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}% - {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}% -\temp -\donoderef -\nobreak -} - -\outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy} -\def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz -\def\appendixsubsubseczzz #1{% -\gdef\thissection{#1}\global\advance \subsubsecno by 1 % -\subsubsecheading {#1} - {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}% - {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}% -\temp -\appendixnoderef -\nobreak -} - -\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy} -\def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz -\def\unnumberedsubsubseczzz #1{% -\plainsubsubsecheading {#1}\gdef\thissection{#1}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsubsecentry% - {\the\toks0}}}% -\temp -\unnumbnoderef -\nobreak -} - -% These are variants which are not "outer", so they can appear in @ifinfo. -% Actually, they should now be obsolete; ordinary section commands should work. -\def\infotop{\parsearg\unnumberedzzz} -\def\infounnumbered{\parsearg\unnumberedzzz} -\def\infounnumberedsec{\parsearg\unnumberedseczzz} -\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz} -\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} - -\def\infoappendix{\parsearg\appendixzzz} -\def\infoappendixsec{\parsearg\appendixseczzz} -\def\infoappendixsubsec{\parsearg\appendixsubseczzz} -\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz} - -\def\infochapter{\parsearg\chapterzzz} -\def\infosection{\parsearg\sectionzzz} -\def\infosubsection{\parsearg\subsectionzzz} -\def\infosubsubsection{\parsearg\subsubsectionzzz} - -% These macros control what the section commands do, according -% to what kind of chapter we are in (ordinary, appendix, or unnumbered). -% Define them by default for a numbered chapter. -\global\let\section = \numberedsec -\global\let\subsection = \numberedsubsec -\global\let\subsubsection = \numberedsubsubsec - -% Define @majorheading, @heading and @subheading - -% NOTE on use of \vbox for chapter headings, section headings, and such: -% 1) We use \vbox rather than the earlier \line to permit -% overlong headings to fold. -% 2) \hyphenpenalty is set to 10000 because hyphenation in a -% heading is obnoxious; this forbids it. -% 3) Likewise, headings look best if no \parindent is used, and -% if justification is not attempted. Hence \raggedright. - - -\def\majorheading{\parsearg\majorheadingzzz} -\def\majorheadingzzz #1{% -{\advance\chapheadingskip by 10pt \chapbreak }% -{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 200} - -\def\chapheading{\parsearg\chapheadingzzz} -\def\chapheadingzzz #1{\chapbreak % -{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 200} - -% @heading, @subheading, @subsubheading. -\def\heading{\parsearg\plainsecheading} -\def\subheading{\parsearg\plainsubsecheading} -\def\subsubheading{\parsearg\plainsubsubsecheading} - -% These macros generate a chapter, section, etc. heading only -% (including whitespace, linebreaking, etc. around it), -% given all the information in convenient, parsed form. - -%%% Args are the skip and penalty (usually negative) -\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} - -\def\setchapterstyle #1 {\csname CHAPF#1\endcsname} - -%%% Define plain chapter starts, and page on/off switching for it -% Parameter controlling skip before chapter headings (if needed) - -\newskip\chapheadingskip - -\def\chapbreak{\dobreak \chapheadingskip {-4000}} -\def\chappager{\par\vfill\supereject} -\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi} - -\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} - -\def\CHAPPAGoff{% -\global\let\contentsalignmacro = \chappager -\global\let\pchapsepmacro=\chapbreak -\global\let\pagealignmacro=\chappager} - -\def\CHAPPAGon{% -\global\let\contentsalignmacro = \chappager -\global\let\pchapsepmacro=\chappager -\global\let\pagealignmacro=\chappager -\global\def\HEADINGSon{\HEADINGSsingle}} - -\def\CHAPPAGodd{ -\global\let\contentsalignmacro = \chapoddpage -\global\let\pchapsepmacro=\chapoddpage -\global\let\pagealignmacro=\chapoddpage -\global\def\HEADINGSon{\HEADINGSdouble}} - -\CHAPPAGon - -\def\CHAPFplain{ -\global\let\chapmacro=\chfplain -\global\let\unnumbchapmacro=\unnchfplain -\global\let\centerchapmacro=\centerchfplain} - -% Plain chapter opening. -% #1 is the text, #2 the chapter number or empty if unnumbered. -\def\chfplain#1#2{% - \pchapsepmacro - {% - \chapfonts \rm - \def\chapnum{#2}% - \setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}% - \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright - \hangindent = \wd0 \centerparametersmaybe - \unhbox0 #1\par}% - }% - \nobreak\bigskip % no page break after a chapter title - \nobreak -} - -% Plain opening for unnumbered. -\def\unnchfplain#1{\chfplain{#1}{}} - -% @centerchap -- centered and unnumbered. -\let\centerparametersmaybe = \relax -\def\centerchfplain#1{{% - \def\centerparametersmaybe{% - \advance\rightskip by 3\rightskip - \leftskip = \rightskip - \parfillskip = 0pt - }% - \chfplain{#1}{}% -}} - -\CHAPFplain % The default - -\def\unnchfopen #1{% -\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\nobreak -} - -\def\chfopen #1#2{\chapoddpage {\chapfonts -\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% -\par\penalty 5000 % -} - -\def\centerchfopen #1{% -\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt - \hfill {\rm #1}\hfill}}\bigskip \par\nobreak -} - -\def\CHAPFopen{ -\global\let\chapmacro=\chfopen -\global\let\unnumbchapmacro=\unnchfopen -\global\let\centerchapmacro=\centerchfopen} - - -% Section titles. -\newskip\secheadingskip -\def\secheadingbreak{\dobreak \secheadingskip {-1000}} -\def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}} -\def\plainsecheading#1{\sectionheading{sec}{}{#1}} - -% Subsection titles. -\newskip \subsecheadingskip -\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} -\def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}} -\def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}} - -% Subsubsection titles. -\let\subsubsecheadingskip = \subsecheadingskip -\let\subsubsecheadingbreak = \subsecheadingbreak -\def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}} -\def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}} - - -% Print any size section title. -% -% #1 is the section type (sec/subsec/subsubsec), #2 is the section -% number (maybe empty), #3 the text. -\def\sectionheading#1#2#3{% - {% - \expandafter\advance\csname #1headingskip\endcsname by \parskip - \csname #1headingbreak\endcsname - }% - {% - % Switch to the right set of fonts. - \csname #1fonts\endcsname \rm - % - % Only insert the separating space if we have a section number. - \def\secnum{#2}% - \setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}% - % - \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright - \hangindent = \wd0 % zero if no section number - \unhbox0 #3}% - }% - \ifdim\parskip<10pt \nobreak\kern10pt\nobreak\kern-\parskip\fi \nobreak -} - - -\message{toc,} -% Table of contents. -\newwrite\tocfile - -% Write an entry to the toc file, opening it if necessary. -% Called from @chapter, etc. We supply {\folio} at the end of the -% argument, which will end up as the last argument to the \...entry macro. -% -% We open the .toc file here instead of at @setfilename or any other -% given time so that @contents can be put in the document anywhere. -% -\newif\iftocfileopened -\def\writetocentry#1{% - \iftocfileopened\else - \immediate\openout\tocfile = \jobname.toc - \global\tocfileopenedtrue - \fi - \iflinks \write\tocfile{#1{\folio}}\fi -} - -\newskip\contentsrightmargin \contentsrightmargin=1in -\newcount\savepageno -\newcount\lastnegativepageno \lastnegativepageno = -1 - -% Finish up the main text and prepare to read what we've written -% to \tocfile. -% -\def\startcontents#1{% - % If @setchapternewpage on, and @headings double, the contents should - % start on an odd page, unlike chapters. Thus, we maintain - % \contentsalignmacro in parallel with \pagealignmacro. - % From: Torbjorn Granlund - \contentsalignmacro - \immediate\closeout\tocfile - % - % Don't need to put `Contents' or `Short Contents' in the headline. - % It is abundantly clear what they are. - \unnumbchapmacro{#1}\def\thischapter{}% - \savepageno = \pageno - \begingroup % Set up to handle contents files properly. - \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 - % We can't do this, because then an actual ^ in a section - % title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97. - %\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi - \raggedbottom % Worry more about breakpoints than the bottom. - \advance\hsize by -\contentsrightmargin % Don't use the full line length. - % - % Roman numerals for page numbers. - \ifnum \pageno>0 \pageno = \lastnegativepageno \fi -} - - -% Normal (long) toc. -\def\contents{% - \startcontents{\putwordTOC}% - \openin 1 \jobname.toc - \ifeof 1 \else - \closein 1 - \input \jobname.toc - \fi - \vfill \eject - \contentsalignmacro % in case @setchapternewpage odd is in effect - \endgroup - \lastnegativepageno = \pageno - \pageno = \savepageno -} - -% And just the chapters. -\def\summarycontents{% - \startcontents{\putwordShortTOC}% - % - \let\chapentry = \shortchapentry - \let\unnumbchapentry = \shortunnumberedentry - % We want a true roman here for the page numbers. - \secfonts - \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl - \rm - \hyphenpenalty = 10000 - \advance\baselineskip by 1pt % Open it up a little. - \def\secentry ##1##2##3##4{} - \def\unnumbsecentry ##1##2{} - \def\subsecentry ##1##2##3##4##5{} - \def\unnumbsubsecentry ##1##2{} - \def\subsubsecentry ##1##2##3##4##5##6{} - \def\unnumbsubsubsecentry ##1##2{} - \openin 1 \jobname.toc - \ifeof 1 \else - \closein 1 - \input \jobname.toc - \fi - \vfill \eject - \contentsalignmacro % in case @setchapternewpage odd is in effect - \endgroup - \lastnegativepageno = \pageno - \pageno = \savepageno -} -\let\shortcontents = \summarycontents - -\ifpdf - \pdfcatalog{/PageMode /UseOutlines}% -\fi - -% These macros generate individual entries in the table of contents. -% The first argument is the chapter or section name. -% The last argument is the page number. -% The arguments in between are the chapter number, section number, ... - -% Chapter-level things, for both the long and short contents. -\def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}} - -% See comments in \dochapentry re vbox and related settings -\def\shortchapentry#1#2#3{% - \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}% -} - -% Typeset the label for a chapter or appendix for the short contents. -% The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter. -% We could simplify the code here by writing out an \appendixentry -% command in the toc file for appendices, instead of using \chapentry -% for both, but it doesn't seem worth it. -\setbox0 = \hbox{\shortcontrm \putwordAppendix } -\newdimen\shortappendixwidth \shortappendixwidth = \wd0 - -\def\shortchaplabel#1{% - % We typeset #1 in a box of constant width, regardless of the text of - % #1, so the chapter titles will come out aligned. - \setbox0 = \hbox{#1}% - \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi - % - % This space should be plenty, since a single number is .5em, and the - % widest letter (M) is 1em, at least in the Computer Modern fonts. - % (This space doesn't include the extra space that gets added after - % the label; that gets put in by \shortchapentry above.) - \advance\dimen0 by 1.1em - \hbox to \dimen0{#1\hfil}% -} - -\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}} -\def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}} - -% Sections. -\def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}} -\def\unnumbsecentry#1#2{\dosecentry{#1}{#2}} - -% Subsections. -\def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}} -\def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}} - -% And subsubsections. -\def\subsubsecentry#1#2#3#4#5#6{% - \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}} -\def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}} - -% This parameter controls the indentation of the various levels. -\newdimen\tocindent \tocindent = 3pc - -% Now for the actual typesetting. In all these, #1 is the text and #2 is the -% page number. -% -% If the toc has to be broken over pages, we want it to be at chapters -% if at all possible; hence the \penalty. -\def\dochapentry#1#2{% - \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip - \begingroup - \chapentryfonts - \tocentry{#1}{\dopageno{#2}}% - \endgroup - \nobreak\vskip .25\baselineskip plus.1\baselineskip -} - -\def\dosecentry#1#2{\begingroup - \secentryfonts \leftskip=\tocindent - \tocentry{#1}{\dopageno{#2}}% -\endgroup} - -\def\dosubsecentry#1#2{\begingroup - \subsecentryfonts \leftskip=2\tocindent - \tocentry{#1}{\dopageno{#2}}% -\endgroup} - -\def\dosubsubsecentry#1#2{\begingroup - \subsubsecentryfonts \leftskip=3\tocindent - \tocentry{#1}{\dopageno{#2}}% -\endgroup} - -% Final typesetting of a toc entry; we use the same \entry macro as for -% the index entries, but we want to suppress hyphenation here. (We -% can't do that in the \entry macro, since index entries might consist -% of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.) -\def\tocentry#1#2{\begingroup - \vskip 0pt plus1pt % allow a little stretch for the sake of nice page breaks - % Do not use \turnoffactive in these arguments. Since the toc is - % typeset in cmr, so characters such as _ would come out wrong; we - % have to do the usual translation tricks. - \entry{#1}{#2}% -\endgroup} - -% Space between chapter (or whatever) number and the title. -\def\labelspace{\hskip1em \relax} - -\def\dopageno#1{{\rm #1}} -\def\doshortpageno#1{{\rm #1}} - -\def\chapentryfonts{\secfonts \rm} -\def\secentryfonts{\textfonts} -\let\subsecentryfonts = \textfonts -\let\subsubsecentryfonts = \textfonts - - -\message{environments,} -% @foo ... @end foo. - -% Since these characters are used in examples, it should be an even number of -% \tt widths. Each \tt character is 1en, so two makes it 1em. -% Furthermore, these definitions must come after we define our fonts. -\newbox\dblarrowbox \newbox\longdblarrowbox -\newbox\pushcharbox \newbox\bullbox -\newbox\equivbox \newbox\errorbox - -%{\tentt -%\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil} -%\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil} -%\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil} -%\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil} -% Adapted from the manmac format (p.420 of TeXbook) -%\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex -% depth .1ex\hfil} -%} - -% @point{}, @result{}, @expansion{}, @print{}, @equiv{}. -\def\point{$\star$} -\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} -\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}} -\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} -\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}} - -% Adapted from the TeXbook's \boxit. -{\tentt \global\dimen0 = 3em}% Width of the box. -\dimen2 = .55pt % Thickness of rules -% The text. (`r' is open on the right, `e' somewhat less so on the left.) -\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} - -\global\setbox\errorbox=\hbox to \dimen0{\hfil - \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. - \advance\hsize by -2\dimen2 % Rules. - \vbox{ - \hrule height\dimen2 - \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. - \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. - \kern3pt\vrule width\dimen2}% Space to right. - \hrule height\dimen2} - \hfil} - -% The @error{} command. -\def\error{\leavevmode\lower.7ex\copy\errorbox} - -% @tex ... @end tex escapes into raw Tex temporarily. -% One exception: @ is still an escape character, so that @end tex works. -% But \@ or @@ will get a plain tex @ character. - -\def\tex{\begingroup - \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 - \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 - \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie - \catcode `\%=14 - \catcode 43=12 % plus - \catcode`\"=12 - \catcode`\==12 - \catcode`\|=12 - \catcode`\<=12 - \catcode`\>=12 - \escapechar=`\\ - % - \let\b=\ptexb - \let\bullet=\ptexbullet - \let\c=\ptexc - \let\,=\ptexcomma - \let\.=\ptexdot - \let\dots=\ptexdots - \let\equiv=\ptexequiv - \let\!=\ptexexclam - \let\i=\ptexi - \let\{=\ptexlbrace - \let\+=\tabalign - \let\}=\ptexrbrace - \let\*=\ptexstar - \let\t=\ptext - % - \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% - \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% - \def\@{@}% -\let\Etex=\endgroup} - -% Define @lisp ... @endlisp. -% @lisp does a \begingroup so it can rebind things, -% including the definition of @endlisp (which normally is erroneous). - -% Amount to narrow the margins by for @lisp. -\newskip\lispnarrowing \lispnarrowing=0.4in - -% This is the definition that ^^M gets inside @lisp, @example, and other -% such environments. \null is better than a space, since it doesn't -% have any width. -\def\lisppar{\null\endgraf} - -% Make each space character in the input produce a normal interword -% space in the output. Don't allow a line break at this space, as this -% is used only in environments like @example, where each line of input -% should produce a line of output anyway. -% -{\obeyspaces % -\gdef\sepspaces{\obeyspaces\let =\tie}} - -% Define \obeyedspace to be our active space, whatever it is. This is -% for use in \parsearg. -{\sepspaces% -\global\let\obeyedspace= } - -% This space is always present above and below environments. -\newskip\envskipamount \envskipamount = 0pt - -% Make spacing and below environment symmetrical. We use \parskip here -% to help in doing that, since in @example-like environments \parskip -% is reset to zero; thus the \afterenvbreak inserts no space -- but the -% start of the next paragraph will insert \parskip -% -\def\aboveenvbreak{{\advance\envskipamount by \parskip -\endgraf \ifdim\lastskip<\envskipamount -\removelastskip \penalty-50 \vskip\envskipamount \fi}} - -\let\afterenvbreak = \aboveenvbreak - -% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins. -\let\nonarrowing=\relax - -% @cartouche ... @end cartouche: draw rectangle w/rounded corners around -% environment contents. -\font\circle=lcircle10 -\newdimen\circthick -\newdimen\cartouter\newdimen\cartinner -\newskip\normbskip\newskip\normpskip\newskip\normlskip -\circthick=\fontdimen8\circle -% -\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth -\def\ctr{{\hskip 6pt\circle\char'010}} -\def\cbl{{\circle\char'012\hskip -6pt}} -\def\cbr{{\hskip 6pt\circle\char'011}} -\def\carttop{\hbox to \cartouter{\hskip\lskip - \ctl\leaders\hrule height\circthick\hfil\ctr - \hskip\rskip}} -\def\cartbot{\hbox to \cartouter{\hskip\lskip - \cbl\leaders\hrule height\circthick\hfil\cbr - \hskip\rskip}} -% -\newskip\lskip\newskip\rskip - -\long\def\cartouche{% -\begingroup - \lskip=\leftskip \rskip=\rightskip - \leftskip=0pt\rightskip=0pt %we want these *outside*. - \cartinner=\hsize \advance\cartinner by-\lskip - \advance\cartinner by-\rskip - \cartouter=\hsize - \advance\cartouter by 18.4pt % allow for 3pt kerns on either -% side, and for 6pt waste from -% each corner char, and rule thickness - \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip - % Flag to tell @lisp, etc., not to narrow margin. - \let\nonarrowing=\comment - \vbox\bgroup - \baselineskip=0pt\parskip=0pt\lineskip=0pt - \carttop - \hbox\bgroup - \hskip\lskip - \vrule\kern3pt - \vbox\bgroup - \hsize=\cartinner - \kern3pt - \begingroup - \baselineskip=\normbskip - \lineskip=\normlskip - \parskip=\normpskip - \vskip -\parskip -\def\Ecartouche{% - \endgroup - \kern3pt - \egroup - \kern3pt\vrule - \hskip\rskip - \egroup - \cartbot - \egroup -\endgroup -}} - - -% This macro is called at the beginning of all the @example variants, -% inside a group. -\def\nonfillstart{% - \aboveenvbreak - \inENV % This group ends at the end of the body - \hfuzz = 12pt % Don't be fussy - \sepspaces % Make spaces be word-separators rather than space tokens. - \singlespace - \let\par = \lisppar % don't ignore blank lines - \obeylines % each line of input is a line of output - \parskip = 0pt - \parindent = 0pt - \emergencystretch = 0pt % don't try to avoid overfull boxes - % @cartouche defines \nonarrowing to inhibit narrowing - % at next level down. - \ifx\nonarrowing\relax - \advance \leftskip by \lispnarrowing - \exdentamount=\lispnarrowing - \let\exdent=\nofillexdent - \let\nonarrowing=\relax - \fi -} - -% Define the \E... control sequence only if we are inside the particular -% environment, so the error checking in \end will work. -% -% To end an @example-like environment, we first end the paragraph (via -% \afterenvbreak's vertical glue), and then the group. That way we keep -% the zero \parskip that the environments set -- \parskip glue will be -% inserted at the beginning of the next paragraph in the document, after -% the environment. -% -\def\nonfillfinish{\afterenvbreak\endgroup} - -% @lisp: indented, narrowed, typewriter font. -\def\lisp{\begingroup - \nonfillstart - \let\Elisp = \nonfillfinish - \tt - \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. - \gobble % eat return -} - -% @example: Same as @lisp. -\def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp} - -% @small... is usually equivalent to the non-small (@smallbook -% redefines). We must call \example (or whatever) last in the -% definition, since it reads the return following the @example (or -% whatever) command. -% -% This actually allows (for example) @end display inside an -% @smalldisplay. Too bad, but makeinfo will catch the error anyway. -% -\def\smalldisplay{\begingroup\def\Esmalldisplay{\nonfillfinish\endgroup}\display} -\def\smallexample{\begingroup\def\Esmallexample{\nonfillfinish\endgroup}\lisp} -\def\smallformat{\begingroup\def\Esmallformat{\nonfillfinish\endgroup}\format} -\def\smalllisp{\begingroup\def\Esmalllisp{\nonfillfinish\endgroup}\lisp} - -% Real @smallexample and @smalllisp (when @smallbook): use smaller fonts. -% Originally contributed by Pavel@xerox. -\def\smalllispx{\begingroup - \def\Esmalllisp{\nonfillfinish\endgroup}% - \def\Esmallexample{\nonfillfinish\endgroup}% - \indexfonts - \lisp -} - -% @display: same as @lisp except keep current font. -% -\def\display{\begingroup - \nonfillstart - \let\Edisplay = \nonfillfinish - \gobble -} - -% @smalldisplay (when @smallbook): @display plus smaller fonts. -% -\def\smalldisplayx{\begingroup - \def\Esmalldisplay{\nonfillfinish\endgroup}% - \indexfonts \rm - \display -} - -% @format: same as @display except don't narrow margins. -% -\def\format{\begingroup - \let\nonarrowing = t - \nonfillstart - \let\Eformat = \nonfillfinish - \gobble -} - -% @smallformat (when @smallbook): @format plus smaller fonts. -% -\def\smallformatx{\begingroup - \def\Esmallformat{\nonfillfinish\endgroup}% - \indexfonts \rm - \format -} - -% @flushleft (same as @format). -% -\def\flushleft{\begingroup \def\Eflushleft{\nonfillfinish\endgroup}\format} - -% @flushright. -% -\def\flushright{\begingroup - \let\nonarrowing = t - \nonfillstart - \let\Eflushright = \nonfillfinish - \advance\leftskip by 0pt plus 1fill - \gobble -} - -% @quotation does normal linebreaking (hence we can't use \nonfillstart) -% and narrows the margins. -% -\def\quotation{% - \begingroup\inENV %This group ends at the end of the @quotation body - {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip - \singlespace - \parindent=0pt - % We have retained a nonzero parskip for the environment, since we're - % doing normal filling. So to avoid extra space below the environment... - \def\Equotation{\parskip = 0pt \nonfillfinish}% - % - % @cartouche defines \nonarrowing to inhibit narrowing at next level down. - \ifx\nonarrowing\relax - \advance\leftskip by \lispnarrowing - \advance\rightskip by \lispnarrowing - \exdentamount = \lispnarrowing - \let\nonarrowing = \relax - \fi -} - - -\message{defuns,} -% @defun etc. - -% Allow user to change definition object font (\df) internally -\def\setdeffont #1 {\csname DEF#1\endcsname} - -\newskip\defbodyindent \defbodyindent=.4in -\newskip\defargsindent \defargsindent=50pt -\newskip\deftypemargin \deftypemargin=12pt -\newskip\deflastargmargin \deflastargmargin=18pt - -\newcount\parencount -% define \functionparens, which makes ( and ) and & do special things. -% \functionparens affects the group it is contained in. -\def\activeparens{% -\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active -\catcode`\[=\active \catcode`\]=\active} - -% Make control sequences which act like normal parenthesis chars. -\let\lparen = ( \let\rparen = ) - -{\activeparens % Now, smart parens don't turn on until &foo (see \amprm) - -% Be sure that we always have a definition for `(', etc. For example, -% if the fn name has parens in it, \boldbrax will not be in effect yet, -% so TeX would otherwise complain about undefined control sequence. -\global\let(=\lparen \global\let)=\rparen -\global\let[=\lbrack \global\let]=\rbrack - -\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 } -\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} -% This is used to turn on special parens -% but make & act ordinary (given that it's active). -\gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr} - -% Definitions of (, ) and & used in args for functions. -% This is the definition of ( outside of all parentheses. -\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested - \global\advance\parencount by 1 -} -% -% This is the definition of ( when already inside a level of parens. -\gdef\opnested{\char`\(\global\advance\parencount by 1 } -% -\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0. - % also in that case restore the outer-level definition of (. - \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi - \global\advance \parencount by -1 } -% If we encounter &foo, then turn on ()-hacking afterwards -\gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ } -% -\gdef\normalparens{\boldbrax\let&=\ampnr} -} % End of definition inside \activeparens -%% These parens (in \boldbrax) actually are a little bolder than the -%% contained text. This is especially needed for [ and ] -\def\opnr{{\sf\char`\(}\global\advance\parencount by 1 } -\def\clnr{{\sf\char`\)}\global\advance\parencount by -1 } -\let\ampnr = \& -\def\lbrb{{\bf\char`\[}} -\def\rbrb{{\bf\char`\]}} - -% Active &'s sneak into the index arguments, so make sure it's defined. -{ - \catcode`& = 13 - \global\let& = \ampnr -} - -% First, defname, which formats the header line itself. -% #1 should be the function name. -% #2 should be the type of definition, such as "Function". - -\def\defname #1#2{% -% Get the values of \leftskip and \rightskip as they were -% outside the @def... -\dimen2=\leftskip -\advance\dimen2 by -\defbodyindent -\noindent -\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}% -\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line -\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations -\parshape 2 0in \dimen0 \defargsindent \dimen1 -% Now output arg 2 ("Function" or some such) -% ending at \deftypemargin from the right margin, -% but stuck inside a box of width 0 so it does not interfere with linebreaking -{% Adjust \hsize to exclude the ambient margins, -% so that \rightline will obey them. -\advance \hsize by -\dimen2 -\rlap{\rightline{{\rm #2}\hskip -1.25pc }}}% -% Make all lines underfull and no complaints: -\tolerance=10000 \hbadness=10000 -\advance\leftskip by -\defbodyindent -\exdentamount=\defbodyindent -{\df #1}\enskip % Generate function name -} - -% Actually process the body of a definition -% #1 should be the terminating control sequence, such as \Edefun. -% #2 should be the "another name" control sequence, such as \defunx. -% #3 should be the control sequence that actually processes the header, -% such as \defunheader. - -\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2{\begingroup\obeylines\activeparens\spacesplit#3}% -\parindent=0in -\advance\leftskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup % -\catcode 61=\active % 61 is `=' -\obeylines\activeparens\spacesplit#3} - -% #1 is the \E... control sequence to end the definition (which we define). -% #2 is the \...x control sequence for consecutive fns (which we define). -% #3 is the control sequence to call to resume processing. -% #4, delimited by the space, is the class name. -% -\def\defmethparsebody#1#2#3#4 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}% -\parindent=0in -\advance\leftskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\activeparens\spacesplit{#3{#4}}} - -% @deftypemethod has an extra argument that nothing else does. Sigh. -% #1 is the \E... control sequence to end the definition (which we define). -% #2 is the \...x control sequence for consecutive fns (which we define). -% #3 is the control sequence to call to resume processing. -% #4, delimited by the space, is the class name. -% #5 is the method's return type. -% -\def\deftypemethparsebody#1#2#3#4 #5 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 ##2 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}{##2}}}% -\parindent=0in -\advance\leftskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\activeparens\spacesplit{#3{#4}{#5}}} - -\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 ##2 {\def#4{##1}% -\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}% -\parindent=0in -\advance\leftskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\activeparens\spacesplit{#3{#5}}} - -% These parsing functions are similar to the preceding ones -% except that they do not make parens into active characters. -% These are used for "variables" since they have no arguments. - -\def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2{\begingroup\obeylines\spacesplit#3}% -\parindent=0in -\advance\leftskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup % -\catcode 61=\active % -\obeylines\spacesplit#3} - -% This is used for \def{tp,vr}parsebody. It could probably be used for -% some of the others, too, with some judicious conditionals. -% -\def\parsebodycommon#1#2#3{% - \begingroup\inENV % - \medbreak % - % Define the end token that this defining construct specifies - % so that it will exit this group. - \def#1{\endgraf\endgroup\medbreak}% - \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% - \parindent=0in - \advance\leftskip by \defbodyindent - \exdentamount=\defbodyindent - \begingroup\obeylines -} - -\def\defvrparsebody#1#2#3#4 {% - \parsebodycommon{#1}{#2}{#3}% - \spacesplit{#3{#4}}% -} - -% This loses on `@deftp {Data Type} {struct termios}' -- it thinks the -% type is just `struct', because we lose the braces in `{struct -% termios}' when \spacesplit reads its undelimited argument. Sigh. -% \let\deftpparsebody=\defvrparsebody -% -% So, to get around this, we put \empty in with the type name. That -% way, TeX won't find exactly `{...}' as an undelimited argument, and -% won't strip off the braces. -% -\def\deftpparsebody #1#2#3#4 {% - \parsebodycommon{#1}{#2}{#3}% - \spacesplit{\parsetpheaderline{#3{#4}}}\empty -} - -% Fine, but then we have to eventually remove the \empty *and* the -% braces (if any). That's what this does. -% -\def\removeemptybraces\empty#1\relax{#1} - -% After \spacesplit has done its work, this is called -- #1 is the final -% thing to call, #2 the type name (which starts with \empty), and #3 -% (which might be empty) the arguments. -% -\def\parsetpheaderline#1#2#3{% - #1{\removeemptybraces#2\relax}{#3}% -}% - -\def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 ##2 {\def#4{##1}% -\begingroup\obeylines\spacesplit{#3{##2}}}% -\parindent=0in -\advance\leftskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\spacesplit{#3{#5}}} - -% Split up #2 at the first space token. -% call #1 with two arguments: -% the first is all of #2 before the space token, -% the second is all of #2 after that space token. -% If #2 contains no space token, all of it is passed as the first arg -% and the second is passed as empty. - -{\obeylines -\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}% -\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{% -\ifx\relax #3% -#1{#2}{}\else #1{#2}{#3#4}\fi}} - -% So much for the things common to all kinds of definitions. - -% Define @defun. - -% First, define the processing that is wanted for arguments of \defun -% Use this to expand the args and terminate the paragraph they make up - -\def\defunargs#1{\functionparens \sl -% Expand, preventing hyphenation at `-' chars. -% Note that groups don't affect changes in \hyphenchar. -% Set the font temporarily and use \font in case \setfont made \tensl a macro. -{\tensl\hyphenchar\font=0}% -#1% -{\tensl\hyphenchar\font=45}% -\ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi% -\interlinepenalty=10000 -\advance\rightskip by 0pt plus 1fil -\endgraf\nobreak\vskip -\parskip\nobreak -} - -\def\deftypefunargs #1{% -% Expand, preventing hyphenation at `-' chars. -% Note that groups don't affect changes in \hyphenchar. -% Use \boldbraxnoamp, not \functionparens, so that & is not special. -\boldbraxnoamp -\tclose{#1}% avoid \code because of side effects on active chars -\interlinepenalty=10000 -\advance\rightskip by 0pt plus 1fil -\endgraf\nobreak\vskip -\parskip\nobreak -} - -% Do complete processing of one @defun or @defunx line already parsed. - -% @deffn Command forward-char nchars - -\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader} - -\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}% -\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defun == @deffn Function - -\def\defun{\defparsebody\Edefun\defunx\defunheader} - -\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index -\begingroup\defname {#1}{\putwordDeffunc}% -\defunargs {#2}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @deftypefun int foobar (int @var{foo}, float @var{bar}) - -\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader} - -% #1 is the data type. #2 is the name and args. -\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax} -% #1 is the data type, #2 the name, #3 the args. -\def\deftypefunheaderx #1#2 #3\relax{% -\doind {fn}{\code{#2}}% Make entry in function index -\begingroup\defname {\defheaderxcond#1\relax$$$#2}{\putwordDeftypefun}% -\deftypefunargs {#3}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) - -\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader} - -% \defheaderxcond#1\relax$$$ -% puts #1 in @code, followed by a space, but does nothing if #1 is null. -\def\defheaderxcond#1#2$$${\ifx#1\relax\else\code{#1#2} \fi} - -% #1 is the classification. #2 is the data type. #3 is the name and args. -\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax} -% #1 is the classification, #2 the data type, #3 the name, #4 the args. -\def\deftypefnheaderx #1#2#3 #4\relax{% -\doind {fn}{\code{#3}}% Make entry in function index -\begingroup -\normalparens % notably, turn off `&' magic, which prevents -% at least some C++ text from working -\defname {\defheaderxcond#2\relax$$$#3}{#1}% -\deftypefunargs {#4}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defmac == @deffn Macro - -\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader} - -\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index -\begingroup\defname {#1}{\putwordDefmac}% -\defunargs {#2}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defspec == @deffn Special Form - -\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader} - -\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index -\begingroup\defname {#1}{\putwordDefspec}% -\defunargs {#2}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defop CATEGORY CLASS OPERATION ARG... -% -\def\defop #1 {\def\defoptype{#1}% -\defopparsebody\Edefop\defopx\defopheader\defoptype} -% -\def\defopheader #1#2#3{% -\dosubind {fn}{\code{#2}}{\putwordon\ #1}% Make entry in function index -\begingroup\defname {#2}{\defoptype\ \putwordon\ #1}% -\defunargs {#3}\endgroup % -} - -% @deftypemethod CLASS RETURN-TYPE METHOD ARG... -% -\def\deftypemethod{% - \deftypemethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader} -% -% #1 is the class name, #2 the data type, #3 the method name, #4 the args. -\def\deftypemethodheader#1#2#3#4{% - \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index - \begingroup - \defname{\defheaderxcond#2\relax$$$#3}{\putwordMethodon\ \code{#1}}% - \deftypefunargs{#4}% - \endgroup -} - -% @deftypeivar CLASS TYPE VARNAME -% -\def\deftypeivar{% - \deftypemethparsebody\Edeftypeivar\deftypeivarx\deftypeivarheader} -% -% #1 is the class name, #2 the data type, #3 the variable name. -\def\deftypeivarheader#1#2#3{% - \dosubind{vr}{\code{#3}}{\putwordof\ \code{#1}}% entry in variable index - \begingroup - \defname{#3}{\putwordInstanceVariableof\ \code{#1}}% - \defvarargs{#3}% - \endgroup -} - -% @defmethod == @defop Method -% -\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader} -% -% #1 is the class name, #2 the method name, #3 the args. -\def\defmethodheader#1#2#3{% - \dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% entry in function index - \begingroup - \defname{#2}{\putwordMethodon\ \code{#1}}% - \defunargs{#3}% - \endgroup -} - -% @defcv {Class Option} foo-class foo-flag - -\def\defcv #1 {\def\defcvtype{#1}% -\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype} - -\def\defcvarheader #1#2#3{% -\dosubind {vr}{\code{#2}}{\putwordof\ #1}% Make entry in var index -\begingroup\defname {#2}{\defcvtype\ \putwordof\ #1}% -\defvarargs {#3}\endgroup % -} - -% @defivar CLASS VARNAME == @defcv {Instance Variable} CLASS VARNAME -% -\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader} -% -\def\defivarheader#1#2#3{% - \dosubind {vr}{\code{#2}}{\putwordof\ #1}% entry in var index - \begingroup - \defname{#2}{\putwordInstanceVariableof\ #1}% - \defvarargs{#3}% - \endgroup -} - -% @defvar -% First, define the processing that is wanted for arguments of @defvar. -% This is actually simple: just print them in roman. -% This must expand the args and terminate the paragraph they make up -\def\defvarargs #1{\normalparens #1% -\interlinepenalty=10000 -\endgraf\nobreak\vskip -\parskip\nobreak} - -% @defvr Counter foo-count - -\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader} - -\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}% -\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup} - -% @defvar == @defvr Variable - -\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader} - -\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index -\begingroup\defname {#1}{\putwordDefvar}% -\defvarargs {#2}\endgroup % -} - -% @defopt == @defvr {User Option} - -\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader} - -\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index -\begingroup\defname {#1}{\putwordDefopt}% -\defvarargs {#2}\endgroup % -} - -% @deftypevar int foobar - -\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader} - -% #1 is the data type. #2 is the name, perhaps followed by text that -% is actually part of the data type, which should not be put into the index. -\def\deftypevarheader #1#2{% -\dovarind#2 \relax% Make entry in variables index -\begingroup\defname {\defheaderxcond#1\relax$$$#2}{\putwordDeftypevar}% -\interlinepenalty=10000 -\endgraf\nobreak\vskip -\parskip\nobreak -\endgroup} -\def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}} - -% @deftypevr {Global Flag} int enable - -\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} - -\def\deftypevrheader #1#2#3{\dovarind#3 \relax% -\begingroup\defname {\defheaderxcond#2\relax$$$#3}{#1} -\interlinepenalty=10000 -\endgraf\nobreak\vskip -\parskip\nobreak -\endgroup} - -% Now define @deftp -% Args are printed in bold, a slight difference from @defvar. - -\def\deftpargs #1{\bf \defvarargs{#1}} - -% @deftp Class window height width ... - -\def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader} - -\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}% -\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup} - -% These definitions are used if you use @defunx (etc.) -% anywhere other than immediately after a @defun or @defunx. -% -\def\defcvx#1 {\errmessage{@defcvx in invalid context}} -\def\deffnx#1 {\errmessage{@deffnx in invalid context}} -\def\defivarx#1 {\errmessage{@defivarx in invalid context}} -\def\defmacx#1 {\errmessage{@defmacx in invalid context}} -\def\defmethodx#1 {\errmessage{@defmethodx in invalid context}} -\def\defoptx #1 {\errmessage{@defoptx in invalid context}} -\def\defopx#1 {\errmessage{@defopx in invalid context}} -\def\defspecx#1 {\errmessage{@defspecx in invalid context}} -\def\deftpx#1 {\errmessage{@deftpx in invalid context}} -\def\deftypefnx#1 {\errmessage{@deftypefnx in invalid context}} -\def\deftypefunx#1 {\errmessage{@deftypefunx in invalid context}} -\def\deftypeivarx#1 {\errmessage{@deftypeivarx in invalid context}} -\def\deftypemethodx#1 {\errmessage{@deftypemethodx in invalid context}} -\def\deftypevarx#1 {\errmessage{@deftypevarx in invalid context}} -\def\deftypevrx#1 {\errmessage{@deftypevrx in invalid context}} -\def\defunx#1 {\errmessage{@defunx in invalid context}} -\def\defvarx#1 {\errmessage{@defvarx in invalid context}} -\def\defvrx#1 {\errmessage{@defvrx in invalid context}} - - -\message{macros,} -% @macro. - -% To do this right we need a feature of e-TeX, \scantokens, -% which we arrange to emulate with a temporary file in ordinary TeX. -\ifx\eTeXversion\undefined - \newwrite\macscribble - \def\scanmacro#1{% - \begingroup \newlinechar`\^^M - % Undo catcode changes of \startcontents and \doprintindex - \catcode`\@=0 \catcode`\\=12 \escapechar=`\@ - % Append \endinput to make sure that TeX does not see the ending newline. - \toks0={#1\endinput}% - \immediate\openout\macscribble=\jobname.tmp - \immediate\write\macscribble{\the\toks0}% - \immediate\closeout\macscribble - \let\xeatspaces\eatspaces - \input \jobname.tmp - \endgroup -} -\else -\def\scanmacro#1{% -\begingroup \newlinechar`\^^M -% Undo catcode changes of \startcontents and \doprintindex -\catcode`\@=0 \catcode`\\=12 \escapechar=`\@ -\let\xeatspaces\eatspaces\scantokens{#1\endinput}\endgroup} -\fi - -\newcount\paramno % Count of parameters -\newtoks\macname % Macro name -\newif\ifrecursive % Is it recursive? -\def\macrolist{} % List of all defined macros in the form - % \do\macro1\do\macro2... - -% Utility routines. -% Thisdoes \let #1 = #2, except with \csnames. -\def\cslet#1#2{% -\expandafter\expandafter -\expandafter\let -\expandafter\expandafter -\csname#1\endcsname -\csname#2\endcsname} - -% Trim leading and trailing spaces off a string. -% Concepts from aro-bend problem 15 (see CTAN). -{\catcode`\@=11 -\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }} -\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@} -\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @} -\def\unbrace#1{#1} -\unbrace{\gdef\trim@@@ #1 } #2@{#1} -} - -% Trim a single trailing ^^M off a string. -{\catcode`\^^M=12\catcode`\Q=3% -\gdef\eatcr #1{\eatcra #1Q^^MQ}% -\gdef\eatcra#1^^MQ{\eatcrb#1Q}% -\gdef\eatcrb#1Q#2Q{#1}% -} - -% Macro bodies are absorbed as an argument in a context where -% all characters are catcode 10, 11 or 12, except \ which is active -% (as in normal texinfo). It is necessary to change the definition of \. - -% It's necessary to have hard CRs when the macro is executed. This is -% done by making ^^M (\endlinechar) catcode 12 when reading the macro -% body, and then making it the \newlinechar in \scanmacro. - -\def\macrobodyctxt{% - \catcode`\~=12 - \catcode`\^=12 - \catcode`\_=12 - \catcode`\|=12 - \catcode`\<=12 - \catcode`\>=12 - \catcode`\+=12 - \catcode`\{=12 - \catcode`\}=12 - \catcode`\@=12 - \catcode`\^^M=12 - \usembodybackslash} - -\def\macroargctxt{% - \catcode`\~=12 - \catcode`\^=12 - \catcode`\_=12 - \catcode`\|=12 - \catcode`\<=12 - \catcode`\>=12 - \catcode`\+=12 - \catcode`\@=12 - \catcode`\\=12} - -% \mbodybackslash is the definition of \ in @macro bodies. -% It maps \foo\ => \csname macarg.foo\endcsname => #N -% where N is the macro parameter number. -% We define \csname macarg.\endcsname to be \realbackslash, so -% \\ in macro replacement text gets you a backslash. - -{\catcode`@=0 @catcode`@\=@active - @gdef@usembodybackslash{@let\=@mbodybackslash} - @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} -} -\expandafter\def\csname macarg.\endcsname{\realbackslash} - -\def\macro{\recursivefalse\parsearg\macroxxx} -\def\rmacro{\recursivetrue\parsearg\macroxxx} - -\def\macroxxx#1{% - \getargs{#1}% now \macname is the macname and \argl the arglist - \ifx\argl\empty % no arguments - \paramno=0% - \else - \expandafter\parsemargdef \argl;% - \fi - \if1\csname ismacro.\the\macname\endcsname - \message{Warning: redefining \the\macname}% - \else - \expandafter\ifx\csname \the\macname\endcsname \relax - \else \errmessage{The name \the\macname\space is reserved}\fi - \global\cslet{macsave.\the\macname}{\the\macname}% - \global\expandafter\let\csname ismacro.\the\macname\endcsname=1% - % Add the macroname to \macrolist - \toks0 = \expandafter{\macrolist\do}% - \xdef\macrolist{\the\toks0 - \expandafter\noexpand\csname\the\macname\endcsname}% - \fi - \begingroup \macrobodyctxt - \ifrecursive \expandafter\parsermacbody - \else \expandafter\parsemacbody - \fi} - -\def\unmacro{\parsearg\unmacroxxx} -\def\unmacroxxx#1{% - \if1\csname ismacro.#1\endcsname - \global\cslet{#1}{macsave.#1}% - \global\expandafter\let \csname ismacro.#1\endcsname=0% - % Remove the macro name from \macrolist - \begingroup - \edef\tempa{\expandafter\noexpand\csname#1\endcsname}% - \def\do##1{% - \def\tempb{##1}% - \ifx\tempa\tempb - % remove this - \else - \toks0 = \expandafter{\newmacrolist\do}% - \edef\newmacrolist{\the\toks0\expandafter\noexpand\tempa}% - \fi}% - \def\newmacrolist{}% - % Execute macro list to define \newmacrolist - \macrolist - \global\let\macrolist\newmacrolist - \endgroup - \else - \errmessage{Macro #1 not defined}% - \fi -} - -% This makes use of the obscure feature that if the last token of a -% is #, then the preceding argument is delimited by -% an opening brace, and that opening brace is not consumed. -\def\getargs#1{\getargsxxx#1{}} -\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} -\def\getmacname #1 #2\relax{\macname={#1}} -\def\getmacargs#1{\def\argl{#1}} - -% Parse the optional {params} list. Set up \paramno and \paramlist -% so \defmacro knows what to do. Define \macarg.blah for each blah -% in the params list, to be ##N where N is the position in that list. -% That gets used by \mbodybackslash (above). - -% We need to get `macro parameter char #' into several definitions. -% The technique used is stolen from LaTeX: let \hash be something -% unexpandable, insert that wherever you need a #, and then redefine -% it to # just before using the token list produced. -% -% The same technique is used to protect \eatspaces till just before -% the macro is used. - -\def\parsemargdef#1;{\paramno=0\def\paramlist{}% - \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,} -\def\parsemargdefxxx#1,{% - \if#1;\let\next=\relax - \else \let\next=\parsemargdefxxx - \advance\paramno by 1% - \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname - {\xeatspaces{\hash\the\paramno}}% - \edef\paramlist{\paramlist\hash\the\paramno,}% - \fi\next} - -% These two commands read recursive and nonrecursive macro bodies. -% (They're different since rec and nonrec macros end differently.) - -\long\def\parsemacbody#1@end macro% -{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% -\long\def\parsermacbody#1@end rmacro% -{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% - -% This defines the macro itself. There are six cases: recursive and -% nonrecursive macros of zero, one, and many arguments. -% Much magic with \expandafter here. -% \xdef is used so that macro definitions will survive the file -% they're defined in; @include reads the file inside a group. -\def\defmacro{% - \let\hash=##% convert placeholders to macro parameter chars - \ifrecursive - \ifcase\paramno - % 0 - \expandafter\xdef\csname\the\macname\endcsname{% - \noexpand\scanmacro{\temp}}% - \or % 1 - \expandafter\xdef\csname\the\macname\endcsname{% - \bgroup\noexpand\macroargctxt - \noexpand\braceorline - \expandafter\noexpand\csname\the\macname xxx\endcsname}% - \expandafter\xdef\csname\the\macname xxx\endcsname##1{% - \egroup\noexpand\scanmacro{\temp}}% - \else % many - \expandafter\xdef\csname\the\macname\endcsname{% - \bgroup\noexpand\macroargctxt - \noexpand\csname\the\macname xx\endcsname}% - \expandafter\xdef\csname\the\macname xx\endcsname##1{% - \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% - \expandafter\expandafter - \expandafter\xdef - \expandafter\expandafter - \csname\the\macname xxx\endcsname - \paramlist{\egroup\noexpand\scanmacro{\temp}}% - \fi - \else - \ifcase\paramno - % 0 - \expandafter\xdef\csname\the\macname\endcsname{% - \noexpand\norecurse{\the\macname}% - \noexpand\scanmacro{\temp}\egroup}% - \or % 1 - \expandafter\xdef\csname\the\macname\endcsname{% - \bgroup\noexpand\macroargctxt - \noexpand\braceorline - \expandafter\noexpand\csname\the\macname xxx\endcsname}% - \expandafter\xdef\csname\the\macname xxx\endcsname##1{% - \egroup - \noexpand\norecurse{\the\macname}% - \noexpand\scanmacro{\temp}\egroup}% - \else % many - \expandafter\xdef\csname\the\macname\endcsname{% - \bgroup\noexpand\macroargctxt - \expandafter\noexpand\csname\the\macname xx\endcsname}% - \expandafter\xdef\csname\the\macname xx\endcsname##1{% - \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% - \expandafter\expandafter - \expandafter\xdef - \expandafter\expandafter - \csname\the\macname xxx\endcsname - \paramlist{% - \egroup - \noexpand\norecurse{\the\macname}% - \noexpand\scanmacro{\temp}\egroup}% - \fi - \fi} - -\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} - -% \braceorline decides whether the next nonwhitespace character is a -% {. If so it reads up to the closing }, if not, it reads the whole -% line. Whatever was read is then fed to the next control sequence -% as an argument (by \parsebrace or \parsearg) -\def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx} -\def\braceorlinexxx{% - \ifx\nchar\bgroup\else - \expandafter\parsearg - \fi \next} - -% We mant to disable all macros during \shipout so that they are not -% expanded by \write. -\def\turnoffmacros{\begingroup \def\do##1{\let\noexpand##1=\relax}% - \edef\next{\macrolist}\expandafter\endgroup\next} - - -% @alias. -\def\alias#1=#2{\gdef#1{#2}} - - -\message{cross references,} -% @xref etc. - -\newwrite\auxfile - -\newif\ifhavexrefs % True if xref values are known. -\newif\ifwarnedxrefs % True if we warned once that they aren't known. - -% @inforef is relatively simple. -\def\inforef #1{\inforefzzz #1,,,,**} -\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, - node \samp{\ignorespaces#1{}}} - -% @node's job is to define \lastnode. -\def\node{\ENVcheck\parsearg\nodezzz} -\def\nodezzz#1{\nodexxx [#1,]} -\def\nodexxx[#1,#2]{\gdef\lastnode{#1}} -\let\nwnode=\node -\let\lastnode=\relax - -% The sectioning commands (@chapter, etc.) call these. -\def\donoderef{% - \ifx\lastnode\relax\else - \expandafter\expandafter\expandafter\setref{\lastnode}% - {Ysectionnumberandtype}% - \global\let\lastnode=\relax - \fi -} -\def\unnumbnoderef{% - \ifx\lastnode\relax\else - \expandafter\expandafter\expandafter\setref{\lastnode}{Ynothing}% - \global\let\lastnode=\relax - \fi -} -\def\appendixnoderef{% - \ifx\lastnode\relax\else - \expandafter\expandafter\expandafter\setref{\lastnode}% - {Yappendixletterandtype}% - \global\let\lastnode=\relax - \fi -} - - -% @anchor{NAME} -- define xref target at arbitrary point. -% -{ \catcode`\@ = 11 -% From latex.ltx, to make @anchor truely invisible. -\newdimen\@savsk -\newcount\@savsf -\gdef\@bsphack{\relax - \ifhmode \@savsk\lastskip \@savsf\spacefactor \fi -} -\gdef\@esphack{\relax - \ifhmode \spacefactor\@savsf - \ifdim\@savsk>\z@ \ignorespaces \fi - \fi -} -\gdef\anchor#1{\@bsphack \setref{#1}{Ynothing}\@esphack} -} - -% \setref{NAME}{SNT} defines a cross-reference point NAME, namely -% NAME-title, NAME-pg, and NAME-SNT. Called from \foonoderef. We have -% to set \indexdummies so commands such as @code in a section title -% aren't expanded. It would be nicer not to expand the titles in the -% first place, but there's so many layers that that is hard to do. -% -\def\setref#1#2{{% - \indexdummies - \ifpdf \pdfmkdest{#1}\fi - \dosetq{#1-title}{Ytitle}% - \dosetq{#1-pg}{Ypagenumber}% - \dosetq{#1-snt}{#2}% -}} - -% @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is -% the node name, #2 the name of the Info cross-reference, #3 the printed -% node name, #4 the name of the Info file, #5 the name of the printed -% manual. All but the node name can be omitted. -% -\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} -\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} -\def\ref#1{\xrefX[#1,,,,,,,]} -\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup - \def\printedmanual{\ignorespaces #5}% - \def\printednodename{\ignorespaces #3}% - \setbox1=\hbox{\printedmanual}% - \setbox0=\hbox{\printednodename}% - \ifdim \wd0 = 0pt - % No printed node name was explicitly given. - \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax - % Use the node name inside the square brackets. - \def\printednodename{\ignorespaces #1}% - \else - % Use the actual chapter/section title appear inside - % the square brackets. Use the real section title if we have it. - \ifdim \wd1 > 0pt - % It is in another manual, so we don't have it. - \def\printednodename{\ignorespaces #1}% - \else - \ifhavexrefs - % We know the real title if we have the xref values. - \def\printednodename{\refx{#1-title}{}}% - \else - % Otherwise just copy the Info node name. - \def\printednodename{\ignorespaces #1}% - \fi% - \fi - \fi - \fi - % - % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not - % insert empty discretionaries after hyphens, which means that it will - % not find a line break at a hyphen in a node names. Since some manuals - % are best written with fairly long node names, containing hyphens, this - % is a loss. Therefore, we give the text of the node name again, so it - % is as if TeX is seeing it for the first time. - \ifpdf - \leavevmode - \getfilename{#4}% - \ifnum\filenamelength>0 - \pdfannotlink attr{/Border [0 0 0]}% - goto file{\the\filename.pdf} name{#1@}% - \else - \pdfannotlink attr{/Border [0 0 0]}% - goto name{#1@}% - \fi - \BlueGreen - \fi - % - \ifdim \wd1 > 0pt - \putwordsection{} ``\printednodename'' \putwordin{} \cite{\printedmanual}% - \else - % _ (for example) has to be the character _ for the purposes of the - % control sequence corresponding to the node, but it has to expand - % into the usual \leavevmode...\vrule stuff for purposes of - % printing. So we \turnoffactive for the \refx-snt, back on for the - % printing, back off for the \refx-pg. - {\normalturnoffactive - % Only output a following space if the -snt ref is nonempty; for - % @unnumbered and @anchor, it won't be. - \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% - \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi - }% - % [mynode], - [\printednodename],\space - % page 3 - \turnoffactive \putwordpage\tie\refx{#1-pg}{}% - \fi - \ifpdf \Black\pdfendlink \fi -\endgroup} - -% \dosetq is the interface for calls from other macros - -% Use \normalturnoffactive so that punctuation chars such as underscore -% and backslash work in node names. (\turnoffactive doesn't do \.) -\def\dosetq#1#2{% - {\let\folio=0% - \normalturnoffactive - \edef\next{\write\auxfile{\internalsetq{#1}{#2}}}% - \iflinks - \next - \fi - }% -} - -% \internalsetq {foo}{page} expands into -% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...} -% When the aux file is read, ' is the escape character - -\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}} - -% Things to be expanded by \internalsetq - -\def\Ypagenumber{\folio} - -\def\Ytitle{\thissection} - -\def\Ynothing{} - -\def\Ysectionnumberandtype{% -\ifnum\secno=0 \putwordChapter\xreftie\the\chapno % -\else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno % -\else \ifnum \subsubsecno=0 % -\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno % -\else % -\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno % -\fi \fi \fi } - -\def\Yappendixletterandtype{% -\ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}% -\else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno % -\else \ifnum \subsubsecno=0 % -\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno % -\else % -\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno % -\fi \fi \fi } - -\gdef\xreftie{'tie} - -% Use TeX 3.0's \inputlineno to get the line number, for better error -% messages, but if we're using an old version of TeX, don't do anything. -% -\ifx\inputlineno\thisisundefined - \let\linenumber = \empty % Non-3.0. -\else - \def\linenumber{\the\inputlineno:\space} -\fi - -% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. -% If its value is nonempty, SUFFIX is output afterward. - -\def\refx#1#2{% - \expandafter\ifx\csname X#1\endcsname\relax - % If not defined, say something at least. - \angleleft un\-de\-fined\angleright - \iflinks - \ifhavexrefs - \message{\linenumber Undefined cross reference `#1'.}% - \else - \ifwarnedxrefs\else - \global\warnedxrefstrue - \message{Cross reference values unknown; you must run TeX again.}% - \fi - \fi - \fi - \else - % It's defined, so just use it. - \csname X#1\endcsname - \fi - #2% Output the suffix in any case. -} - -% This is the macro invoked by entries in the aux file. -% -\def\xrdef#1{\begingroup - % Reenable \ as an escape while reading the second argument. - \catcode`\\ = 0 - \afterassignment\endgroup - \expandafter\gdef\csname X#1\endcsname -} - -% Read the last existing aux file, if any. No error if none exists. -\def\readauxfile{\begingroup - \catcode`\^^@=\other - \catcode`\^^A=\other - \catcode`\^^B=\other - \catcode`\^^C=\other - \catcode`\^^D=\other - \catcode`\^^E=\other - \catcode`\^^F=\other - \catcode`\^^G=\other - \catcode`\^^H=\other - \catcode`\^^K=\other - \catcode`\^^L=\other - \catcode`\^^N=\other - \catcode`\^^P=\other - \catcode`\^^Q=\other - \catcode`\^^R=\other - \catcode`\^^S=\other - \catcode`\^^T=\other - \catcode`\^^U=\other - \catcode`\^^V=\other - \catcode`\^^W=\other - \catcode`\^^X=\other - \catcode`\^^Z=\other - \catcode`\^^[=\other - \catcode`\^^\=\other - \catcode`\^^]=\other - \catcode`\^^^=\other - \catcode`\^^_=\other - \catcode`\@=\other - \catcode`\^=\other - % It was suggested to define this as 7, which would allow ^^e4 etc. - % in xref tags, i.e., node names. But since ^^e4 notation isn't - % supported in the main text, it doesn't seem desirable. Furthermore, - % that is not enough: for node names that actually contain a ^ - % character, we would end up writing a line like this: 'xrdef {'hat - % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first - % argument, and \hat is not an expandable control sequence. It could - % all be worked out, but why? Either we support ^^ or we don't. - % - % The other change necessary for this was to define \auxhat: - % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter - % and then to call \auxhat in \setq. - % - \catcode`\~=\other - \catcode`\[=\other - \catcode`\]=\other - \catcode`\"=\other - \catcode`\_=\other - \catcode`\|=\other - \catcode`\<=\other - \catcode`\>=\other - \catcode`\$=\other - \catcode`\#=\other - \catcode`\&=\other - \catcode`+=\other % avoid \+ for paranoia even though we've turned it off - % Make the characters 128-255 be printing characters - {% - \count 1=128 - \def\loop{% - \catcode\count 1=\other - \advance\count 1 by 1 - \ifnum \count 1<256 \loop \fi - }% - }% - % The aux file uses ' as the escape (for now). - % Turn off \ as an escape so we do not lose on - % entries which were dumped with control sequences in their names. - % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^ - % Reference to such entries still does not work the way one would wish, - % but at least they do not bomb out when the aux file is read in. - \catcode`\{=1 - \catcode`\}=2 - \catcode`\%=\other - \catcode`\'=0 - \catcode`\\=\other - % - \openin 1 \jobname.aux - \ifeof 1 \else - \closein 1 - \input \jobname.aux - \global\havexrefstrue - \global\warnedobstrue - \fi - % Open the new aux file. TeX will close it automatically at exit. - \openout\auxfile=\jobname.aux -\endgroup} - - -% Footnotes. - -\newcount \footnoteno - -% The trailing space in the following definition for supereject is -% vital for proper filling; pages come out unaligned when you do a -% pagealignmacro call if that space before the closing brace is -% removed. (Generally, numeric constants should always be followed by a -% space to prevent strange expansion errors.) -\def\supereject{\par\penalty -20000\footnoteno =0 } - -% @footnotestyle is meaningful for info output only. -\let\footnotestyle=\comment - -\let\ptexfootnote=\footnote - -{\catcode `\@=11 -% -% Auto-number footnotes. Otherwise like plain. -\gdef\footnote{% - \global\advance\footnoteno by \@ne - \edef\thisfootno{$^{\the\footnoteno}$}% - % - % In case the footnote comes at the end of a sentence, preserve the - % extra spacing after we do the footnote number. - \let\@sf\empty - \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi - % - % Remove inadvertent blank space before typesetting the footnote number. - \unskip - \thisfootno\@sf - \footnotezzz -}% - -% Don't bother with the trickery in plain.tex to not require the -% footnote text as a parameter. Our footnotes don't need to be so general. -% -% Oh yes, they do; otherwise, @ifset and anything else that uses -% \parseargline fail inside footnotes because the tokens are fixed when -% the footnote is read. --karl, 16nov96. -% -\long\gdef\footnotezzz{\insert\footins\bgroup - % We want to typeset this text as a normal paragraph, even if the - % footnote reference occurs in (for example) a display environment. - % So reset some parameters. - \interlinepenalty\interfootnotelinepenalty - \splittopskip\ht\strutbox % top baseline for broken footnotes - \splitmaxdepth\dp\strutbox - \floatingpenalty\@MM - \leftskip\z@skip - \rightskip\z@skip - \spaceskip\z@skip - \xspaceskip\z@skip - \parindent\defaultparindent - % - % Hang the footnote text off the number. - \hang - \textindent{\thisfootno}% - % - % Don't crash into the line above the footnote text. Since this - % expands into a box, it must come within the paragraph, lest it - % provide a place where TeX can split the footnote. - \footstrut - \futurelet\next\fo@t -} -\def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t - \else\let\next\f@t\fi \next} -\def\f@@t{\bgroup\aftergroup\@foot\let\next} -\def\f@t#1{#1\@foot} -\def\@foot{\strut\egroup} - -}%end \catcode `\@=11 - -% Set the baselineskip to #1, and the lineskip and strut size -% correspondingly. There is no deep meaning behind these magic numbers -% used as factors; they just match (closely enough) what Knuth defined. -% -\def\lineskipfactor{.08333} -\def\strutheightpercent{.70833} -\def\strutdepthpercent {.29167} -% -\def\setleading#1{% - \normalbaselineskip = #1\relax - \normallineskip = \lineskipfactor\normalbaselineskip - \normalbaselines - \setbox\strutbox =\hbox{% - \vrule width0pt height\strutheightpercent\baselineskip - depth \strutdepthpercent \baselineskip - }% -} - -% @| inserts a changebar to the left of the current line. It should -% surround any changed text. This approach does *not* work if the -% change spans more than two lines of output. To handle that, we would -% have adopt a much more difficult approach (putting marks into the main -% vertical list for the beginning and end of each change). -% -\def\|{% - % \vadjust can only be used in horizontal mode. - \leavevmode - % - % Append this vertical mode material after the current line in the output. - \vadjust{% - % We want to insert a rule with the height and depth of the current - % leading; that is exactly what \strutbox is supposed to record. - \vskip-\baselineskip - % - % \vadjust-items are inserted at the left edge of the type. So - % the \llap here moves out into the left-hand margin. - \llap{% - % - % For a thicker or thinner bar, change the `1pt'. - \vrule height\baselineskip width1pt - % - % This is the space between the bar and the text. - \hskip 12pt - }% - }% -} - -% For a final copy, take out the rectangles -% that mark overfull boxes (in case you have decided -% that the text looks ok even though it passes the margin). -% -\def\finalout{\overfullrule=0pt} - -% @image. We use the macros from epsf.tex to support this. -% If epsf.tex is not installed and @image is used, we complain. -% -% Check for and read epsf.tex up front. If we read it only at @image -% time, we might be inside a group, and then its definitions would get -% undone and the next image would fail. -\openin 1 = epsf.tex -\ifeof 1 \else - \closein 1 - % Do not bother showing banner with post-v2.7 epsf.tex (available in - % doc/epsf.tex until it shows up on ctan). - \def\epsfannounce{\toks0 = }% - \input epsf.tex -\fi -% -% We will only complain once about lack of epsf.tex. -\newif\ifwarnednoepsf -\newhelp\noepsfhelp{epsf.tex must be installed for images to - work. It is also included in the Texinfo distribution, or you can get - it from ftp://tug.org/tex/epsf.tex.} -% -\def\image#1{% - \ifx\epsfbox\undefined - \ifwarnednoepsf \else - \errhelp = \noepsfhelp - \errmessage{epsf.tex not found, images will be ignored}% - \global\warnednoepsftrue - \fi - \else - \imagexxx #1,,,\finish - \fi -} -% -% Arguments to @image: -% #1 is (mandatory) image filename; we tack on .eps extension. -% #2 is (optional) width, #3 is (optional) height. -% #4 is just the usual extra ignored arg for parsing this stuff. -\def\imagexxx#1,#2,#3,#4\finish{% - \ifx\pdfoutput\undefined - % \epsfbox itself resets \epsf?size at each figure. - \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi - \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi - \begingroup - \catcode`\^^M = 5 % in case we're inside an example - % If the image is by itself, center it. - \ifvmode - \nobreak\bigskip - % Usually we'll have text after the image which will insert - % \parskip glue, so insert it here too to equalize the space - % above and below. - \nobreak\vskip\parskip - \nobreak - \centerline{\epsfbox{#1.eps}}% - \bigbreak - \else - % In the middle of a paragraph, no extra space. - \epsfbox{#1.eps}% - \fi - \endgroup - \else - \centerline{\pdfimage #1.pdf}% - \fi -} - - -\message{localization,} -% and i18n. - -% @documentlanguage is usually given very early, just after -% @setfilename. If done too late, it may not override everything -% properly. Single argument is the language abbreviation. -% It would be nice if we could set up a hyphenation file here. -% -\def\documentlanguage{\parsearg\dodocumentlanguage} -\def\dodocumentlanguage#1{% - \tex % read txi-??.tex file in plain TeX. - % Read the file if it exists. - \openin 1 txi-#1.tex - \ifeof1 - \errhelp = \nolanghelp - \errmessage{Cannot read language file txi-#1.tex}% - \let\temp = \relax - \else - \def\temp{\input txi-#1.tex }% - \fi - \temp - \endgroup -} -\newhelp\nolanghelp{The given language definition file cannot be found or -is empty. Maybe you need to install it? In the current directory -should work if nowhere else does.} - - -% @documentencoding should change something in TeX eventually, most -% likely, but for now just recognize it. -\let\documentencoding = \comment - - -% Page size parameters. -% -\newdimen\defaultparindent \defaultparindent = 15pt - -\chapheadingskip = 15pt plus 4pt minus 2pt -\secheadingskip = 12pt plus 3pt minus 2pt -\subsecheadingskip = 9pt plus 2pt minus 2pt - -% Prevent underfull vbox error messages. -\vbadness = 10000 - -% Don't be so finicky about underfull hboxes, either. -\hbadness = 2000 - -% Following George Bush, just get rid of widows and orphans. -\widowpenalty=10000 -\clubpenalty=10000 - -% Use TeX 3.0's \emergencystretch to help line breaking, but if we're -% using an old version of TeX, don't do anything. We want the amount of -% stretch added to depend on the line length, hence the dependence on -% \hsize. We call this whenever the paper size is set. -% -\def\setemergencystretch{% - \ifx\emergencystretch\thisisundefined - % Allow us to assign to \emergencystretch anyway. - \def\emergencystretch{\dimen0}% - \else - \emergencystretch = .15\hsize - \fi -} - -% Parameters in order: 1) textheight; 2) textwidth; 3) voffset; -% 4) hoffset; 5) binding offset; 6) topskip. Then whoever calls us can -% set \parskip and call \setleading for \baselineskip. -% -\def\internalpagesizes#1#2#3#4#5#6{% - \voffset = #3\relax - \topskip = #6\relax - \splittopskip = \topskip - % - \vsize = #1\relax - \advance\vsize by \topskip - \outervsize = \vsize - \advance\outervsize by 2\topandbottommargin - \pageheight = \vsize - % - \hsize = #2\relax - \outerhsize = \hsize - \advance\outerhsize by 0.5in - \pagewidth = \hsize - % - \normaloffset = #4\relax - \bindingoffset = #5\relax - % - \parindent = \defaultparindent - \setemergencystretch -} - -% @letterpaper (the default). -\def\letterpaper{{\globaldefs = 1 - \parskip = 3pt plus 2pt minus 1pt - \setleading{13.2pt}% - % - % If page is nothing but text, make it come out even. - \internalpagesizes{46\baselineskip}{6in}{\voffset}{.25in}{\bindingoffset}{36pt}% -}} - -% Use @smallbook to reset parameters for 7x9.5 (or so) format. -\def\smallbook{{\globaldefs = 1 - \parskip = 2pt plus 1pt - \setleading{12pt}% - % - \internalpagesizes{7.5in}{5.in}{\voffset}{.25in}{\bindingoffset}{16pt}% - % - \lispnarrowing = 0.3in - \tolerance = 700 - \hfuzz = 1pt - \contentsrightmargin = 0pt - \deftypemargin = 0pt - \defbodyindent = .5cm - % - \let\smalldisplay = \smalldisplayx - \let\smallexample = \smalllispx - \let\smallformat = \smallformatx - \let\smalllisp = \smalllispx -}} - -% Use @afourpaper to print on European A4 paper. -\def\afourpaper{{\globaldefs = 1 - \setleading{12pt}% - \parskip = 3pt plus 2pt minus 1pt - % - \internalpagesizes{53\baselineskip}{160mm}{\voffset}{4mm}{\bindingoffset}{44pt}% - % - \tolerance = 700 - \hfuzz = 1pt -}} - -% A specific text layout, 24x15cm overall, intended for A4 paper. Top margin -% 29mm, hence bottom margin 28mm, nominal side margin 3cm. -\def\afourlatex{{\globaldefs = 1 - \setleading{13.6pt}% - % - \afourpaper - \internalpagesizes{237mm}{150mm}{3.6mm}{3.6mm}{3mm}{7mm}% - % - \globaldefs = 0 -}} - -% Use @afourwide to print on European A4 paper in wide format. -\def\afourwide{% - \afourpaper - \internalpagesizes{9.5in}{6.5in}{\hoffset}{\normaloffset}{\bindingoffset}{7mm}% - % - \globaldefs = 0 -} - -% @pagesizes TEXTHEIGHT[,TEXTWIDTH] -% Perhaps we should allow setting the margins, \topskip, \parskip, -% and/or leading, also. Or perhaps we should compute them somehow. -% -\def\pagesizes{\parsearg\pagesizesxxx} -\def\pagesizesxxx#1{\pagesizesyyy #1,,\finish} -\def\pagesizesyyy#1,#2,#3\finish{{% - \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi - \globaldefs = 1 - % - \parskip = 3pt plus 2pt minus 1pt - \setleading{13.2pt}% - % - \internalpagesizes{#1}{\hsize}{\voffset}{\normaloffset}{\bindingoffset}{44pt}% -}} - -% Set default to letter. -% -\letterpaper - - -\message{and turning on texinfo input format.} - -% Define macros to output various characters with catcode for normal text. -\catcode`\"=\other -\catcode`\~=\other -\catcode`\^=\other -\catcode`\_=\other -\catcode`\|=\other -\catcode`\<=\other -\catcode`\>=\other -\catcode`\+=\other -\catcode`\$=\other -\def\normaldoublequote{"} -\def\normaltilde{~} -\def\normalcaret{^} -\def\normalunderscore{_} -\def\normalverticalbar{|} -\def\normalless{<} -\def\normalgreater{>} -\def\normalplus{+} -\def\normaldollar{$} - -% This macro is used to make a character print one way in ttfont -% where it can probably just be output, and another way in other fonts, -% where something hairier probably needs to be done. -% -% #1 is what to print if we are indeed using \tt; #2 is what to print -% otherwise. Since all the Computer Modern typewriter fonts have zero -% interword stretch (and shrink), and it is reasonable to expect all -% typewriter fonts to have this, we can check that font parameter. -% -\def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi} - -% Same as above, but check for italic font. Actually this also catches -% non-italic slanted fonts since it is impossible to distinguish them from -% italic fonts. But since this is only used by $ and it uses \sl anyway -% this is not a problem. -\def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi} - -% Turn off all special characters except @ -% (and those which the user can use as if they were ordinary). -% Most of these we simply print from the \tt font, but for some, we can -% use math or other variants that look better in normal text. - -\catcode`\"=\active -\def\activedoublequote{{\tt\char34}} -\let"=\activedoublequote -\catcode`\~=\active -\def~{{\tt\char126}} -\chardef\hat=`\^ -\catcode`\^=\active -\def^{{\tt \hat}} - -\catcode`\_=\active -\def_{\ifusingtt\normalunderscore\_} -% Subroutine for the previous macro. -\def\_{\leavevmode \kern.06em \vbox{\hrule width.3em height.1ex}} - -\catcode`\|=\active -\def|{{\tt\char124}} -\chardef \less=`\< -\catcode`\<=\active -\def<{{\tt \less}} -\chardef \gtr=`\> -\catcode`\>=\active -\def>{{\tt \gtr}} -\catcode`\+=\active -\def+{{\tt \char 43}} -\catcode`\$=\active -\def${\ifusingit{{\sl\$}}\normaldollar} -%\catcode 27=\active -%\def^^[{$\diamondsuit$} - -% Set up an active definition for =, but don't enable it most of the time. -{\catcode`\==\active -\global\def={{\tt \char 61}}} - -\catcode`+=\active -\catcode`\_=\active - -% If a .fmt file is being used, characters that might appear in a file -% name cannot be active until we have parsed the command line. -% So turn them off again, and have \everyjob (or @setfilename) turn them on. -% \otherifyactive is called near the end of this file. -\def\otherifyactive{\catcode`+=\other \catcode`\_=\other} - -\catcode`\@=0 - -% \rawbackslashxx output one backslash character in current font -\global\chardef\rawbackslashxx=`\\ -%{\catcode`\\=\other -%@gdef@rawbackslashxx{\}} - -% \rawbackslash redefines \ as input to do \rawbackslashxx. -{\catcode`\\=\active -@gdef@rawbackslash{@let\=@rawbackslashxx }} - -% \normalbackslash outputs one backslash in fixed width font. -\def\normalbackslash{{\tt\rawbackslashxx}} - -% \catcode 17=0 % Define control-q -\catcode`\\=\active - -% Used sometimes to turn off (effectively) the active characters -% even after parsing them. -@def@turnoffactive{@let"=@normaldoublequote -@let\=@realbackslash -@let~=@normaltilde -@let^=@normalcaret -@let_=@normalunderscore -@let|=@normalverticalbar -@let<=@normalless -@let>=@normalgreater -@let+=@normalplus -@let$=@normaldollar} - -@def@normalturnoffactive{@let"=@normaldoublequote -@let\=@normalbackslash -@let~=@normaltilde -@let^=@normalcaret -@let_=@normalunderscore -@let|=@normalverticalbar -@let<=@normalless -@let>=@normalgreater -@let+=@normalplus -@let$=@normaldollar} - -% Make _ and + \other characters, temporarily. -% This is canceled by @fixbackslash. -@otherifyactive - -% If a .fmt file is being used, we don't want the `\input texinfo' to show up. -% That is what \eatinput is for; after that, the `\' should revert to printing -% a backslash. -% -@gdef@eatinput input texinfo{@fixbackslash} -@global@let\ = @eatinput - -% On the other hand, perhaps the file did not have a `\input texinfo'. Then -% the first `\{ in the file would cause an error. This macro tries to fix -% that, assuming it is called before the first `\' could plausibly occur. -% Also back turn on active characters that might appear in the input -% file name, in case not using a pre-dumped format. -% -@gdef@fixbackslash{% - @ifx\@eatinput @let\ = @normalbackslash @fi - @catcode`+=@active - @catcode`@_=@active -} - -% Say @foo, not \foo, in error messages. -@escapechar = `@@ - -% These look ok in all fonts, so just make them not special. -@catcode`@& = @other -@catcode`@# = @other -@catcode`@% = @other - -@c Set initial fonts. -@textfonts -@rm - - -@c Local variables: -@c eval: (add-hook 'write-file-hooks 'time-stamp) -@c page-delimiter: "^\\\\message" -@c time-stamp-start: "def\\\\texinfoversion{" -@c time-stamp-format: "%:y-%02m-%02d.%H" -@c time-stamp-end: "}" -@c End: diff --git a/Docs/Support/update-reserved-words.pl b/Docs/Support/update-reserved-words.pl deleted file mode 100755 index 2920e083c9c..00000000000 --- a/Docs/Support/update-reserved-words.pl +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/perl - -# Based on a Emacs macro by david@mysql.com -# Implemented in Perl by jeremy@mysql.com -# 2001-11-20 Fixups by arjen@mysql.com, 2 keywords and 15 synonyms were missing -# 2001-12-07 Fixup by arjen@mysql.com, add column headings for multitable. -# 2002-05-01 Fixup by arjen@mysql.com, use 3 columns instead of 4. -# 2002-05-03 Fixup by arjen@mysql.com, fill last row to full # of columns. -# 2002-06-14 Fixup by arjen@mysql.com, Issue a "bk edit manual.texi". - -print STDERR "Scanning lex.h for symbols..\n"; -open LEX, "<../sql/lex.h"; -while($line = ) { - if($line =~ /\{\s*\"([A-Z_]+)\"/) { - $words{$1} = $1; - } elsif($line =~ /sql_functions/) { - last; - }; -}; -close LEX; - -print STDERR "Scanning sql_yacc.yy for non-reserved words...\n"; -open YACC, "<../sql/sql_yacc.yy"; -while( !~ /^keyword:/) {}; -while(($line = ) =~ /[\s|]+([A-Z_]+)/) { - $keyword = $1; - $keyword =~ s/_SYM//; - delete $words{$keyword}; -}; -close YACC; - - -print STDERR "Copying reserved words to an array...\n"; -foreach(keys %words) { push @words, $words{$_}; }; - -print STDERR "Sorting array...\n"; -@words = sort @words; - -printf STDERR "There are %i reserved words.\n", scalar @words; - -@pre = ("\@item", " \@tab", " \@tab"); - -$list = ""; -for($i=0; $word = shift(@words); $i++) { - $list .= sprintf "%s %s\n", $pre[$i%3], "\@code\{$word\}"; -} -# Fill last row to full # of columns. -for( ; $i%3; $i++) { - $list .= sprintf "%s\n", $pre[$i%3]; -} - -`bk edit manual.texi`; - -open OLD, "manual-tmp.texi"; - -print STDERR "Copying beginning of manual.texi...\n"; -while(($line = ) !~ /START_OF_RESERVED_WORDS/) { print NEW $line; }; -print NEW "\@c START_OF_RESERVED_WORDS\n\n"; -printf NEW "\@c Reserved word list updated %s by %s.\n". - "\@c To regenerate, use Support/update-reserved-words.pl.\n\n", - &pretty_date, $ENV{USER}; - -print STDERR "Inserting list of reserved words...\n"; -# Ensure the fractions add up to 100% otherwise it looks funny in print: -print NEW "\@multitable \@columnfractions .33 .33 .34\n"; -print NEW "\@item \@strong{Word}\n \@tab \@strong{Word}\n \@tab \@strong{Word}\n"; -print NEW $list; -print NEW "\@end multitable\n"; -print STDERR "Skipping over old list...\n"; -while(($line = ) !~ /END_OF_RESERVED_WORDS/) {}; -print NEW "\n\@c END_OF_RESERVED_WORDS\n"; -print STDERR "Copying end of manual.texi...\n"; -while($line = ) { print NEW $line; }; - -close OLD; -close NEW; - -print STDERR "Moving manual-tmp.texi to manual.texi...\n"; -unlink "manual.texi"; -rename "manual-tmp.texi", "manual.texi"; - -print STDERR "Reserved word list updated successfully!\n"; - -sub pretty_date { - @time = ($time = shift)?((localtime($time))[0..6]):((localtime)[0..6]); - - ($sec, $min, $hour, $mday, $mon, $year, $wday) = @time; - $wday = (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[$wday]; - $mon = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$mon]; - $year += 1900; - - $pretty = sprintf("%s %s %2i %02i:%02i:%02i %i", - $wday, $mon, $mday, $hour, $min, $sec, $year); - - return $pretty; -}; - diff --git a/Docs/To-be-included-in-the-manual/MySQL-for-dummies b/Docs/To-be-included-in-the-manual/MySQL-for-dummies deleted file mode 100644 index 7b669af18dc..00000000000 --- a/Docs/To-be-included-in-the-manual/MySQL-for-dummies +++ /dev/null @@ -1,271 +0,0 @@ -=============================================================================== -installing/mysql/binary Fri Jul 17 13:03:03 1998 has -=============================================================================== - - MySQL for dummies - Part 1 - How to get the binary distribution running on a UNIX system - - MySQL is a trademark of TcX, Sweden. - -=============================================================================== - -Introduction: - -This is a simple cookbook for the helpless newbie taking his very first steps -with MySQL, when he needs a few hints about the options and access rights -installing the system and starting the basic modules, before he has "aha"ed -on how simple and clean the basic structure of MySQL is. It will not help -you with the intricacies and subtle possibilities of SQL as implemented in -MySQL. - -The information in this document is all contained in the MySQL manual in a -more or less obvious form, but for the newbie that document is a bit over- -whelming in size, and it contains some new concepts that take some getting -used to. Sorry if it is pitched too low for some readers. It is only -intended to get the binary distribution up and running. - -I successfully got MySQL going on both a Sun SparcStation 1 running SunOS 4.1.2 -and 2 Linux systems running SuSE release 5.0, one with kernel version 2.0.30, -one with 2.0.33 by doing exactly what is given here. If it doesn't work -for you, I suggest the problem is with your system and not with the -MySQL binary distribution. - --- Howard Schultens hs@neuro-physiol.med.uni-goettingen.de - -------------------------------------------------------------------------------- - -Nomenclature: - -In the following, 'MySQL' refers to the entire database system distributed -and licensed by TcX. 'mysql' means a specific program in this system. - -------------------------------------------------------------------------------- - -MySQL user administration and access rights ("privileges"): - -It is obvious that MySQL needs its own user management because it is a system -that is implemented on a number of architectures -- you should be able to use -it in an identical way on different operating systems. The MySQL user names -and passwords have basically nothing at all to do with user names and -passwords on whatever operating system you install it on. You will, -unfortunately, have to install your users again on MySQL. But this system has -some big advantages: it is a secure system that allows you to finely -differentiate access rights based on WHO is using a database from WHERE. It -does this by the use of its own database containing 3 tables "user" for the -user names, "db" for the databases, and "host" for the machines that access -databases. "user" and "db" are the most important for the newbie. - -Section 6 of the manual describes all this in detail. - -------------------------------------------------------------------------------- - -Doing it: - -In the following, "foo>" denotes the prompt from your system in user mode, -"foo#" as root/superuser. - - -1) Get the appropriate binary distribution from a mirror site or directly - from TcX at URL http://www.tcx.se. The file name has the form - mysql-VERSION-SYSTEM.tgz - - VERSION = Version number, e.g. 3.21.33 - SYSTEM = OS and architecture, e.g. sunos4.1.4-sparc - - i.e., you would download a file mysql-3.21.33-sunos4.1.4-sparc.tgz. - - This example is for SunOS, but it works exactly analogously on Linux. - -2) cd to /usr/local and unpack this with, e.g. the command - - foo#gzip -c -d mysql-VERSION-SYSTEM.tgz|tar xvf - - -3) The files are stored in a directory /usr/local/mysql-VERSION-SYSTEM - Make a symbolic link to this directory: - - foo#ln -s mysql-VERSION-SYSTEM mysql - - At this point, you might want to create a special user for all your - MySQL stuff. I use "mysql". Then you could do - - foo#chown -R mysql mysql-VERSION-SYSTEM - -4) FIRST, take care of all the PERL stuff: - - o) You need PERL 5.004 or later already installed on your system. Take - care of this first if necessary. - - a) cd to /usr/local/mysql/perl/DBI and do - foo#perl Makefile.PL - foo#make - foo#make test - foo#make install (if "make test" is successful) - - b) cd to /usr/local/mysql/perl/Mysql/modules and do - foo#perl Makefile.PL - foo#make - foo#make test - foo#make install (if "make test" is successful) - - c) As an option, you can install Data::ShowTable, but this is not absolutely - necessary for mysql. Get the PERL module Data-ShowTable-VER.tar.gz - (VER = version, eg. 3.3) from a CPAN mirror: I got mine at - - ftp://ftp.gwdg.de/pub/languages/perl/CPAN/modules/by-category/06_Data_Type_Utilities/Data/Data-ShowTable-3.3.tar.gz - - (You should be able to replace "ftp.gwdg.de" by the name of another - FTP mirror) - - Put this into /usr/local/mysql/perl and unpack it. - You get a directory 'Data-ShowTable-VER'. cd into there and - (as root/superuser) - foo#perl Makefile.PL - foo#make - foo#make test - foo#make install (if "make test" is successful) - -5) cd to /usr/local/mysql and do - foo#scripts/mysql_install_db - - you should be in /usr/local/mysql when you start the script. - -==>*NOTE* you might want to edit this script before you run it the first - time. See method 9b) below. - - If this is successful, one or more copies of the mysql daemon, mysqld, - will be running. On SunOS 4.1.x, you get one. On Linux, 3 are running. - -------------------------------------------------------------------------------- -In the rest of this, I will always suppose you are starting in the directory -/usr/local/mysql, even if it seems mildly inconvenient -------------------------------------------------------------------------------- - -6) You can now select the database 'test' and mess around with it using - the client program bin/mysql: start it with - - foo>bin/mysql -u root test - - This says, "start up the MySQL command-line client with the user name - 'root' and use the database named 'test', which is a subdirectory in - '/usr/local/mysql/data". (n.b. this is NOT the root user of your UNIX - system, it is a MySQL user with the same name. You will notice that you - don't need a password for this user to use mysql). - - Actually, the way the system is set up by bin/mysql_install_db, you - don't even need a user name to access the database 'test'. You can start - the client simply with - - foo>bin/mysql test - - 'mysql' should start up with a greeting and a line telling you what your - connection id and server version is. At this point, the database 'test' - is empty, no tables or anything are defined. - - When you issue SQL commands, DON'T FORGET THE FINAL SEMICOLON, or mysql acts - dumb: - - mysql>select * from user - -> - -> - - and you wonder what's going on. 'mysql' reminds you of this on startup. - -7) When you want to close down the server, do - foo>bin/mysqladmin shutdown - -8) I recommend editing the script bin/safe_mysqld for the binary release - so that it always starts up with the correct directories. I replaced - the entire header up to but not including - - pidfile=$DATADIR/`/bin/hostname`.pid - log=$DATADIR/`/bin/hostname`.log - err=$DATADIR/`/bin/hostname`.err - - with - - MY_BASEDIR_VERSION=/usr/local/mysql - DATADIR=$MY_BASEDIR_VERSION/data - ledir=$MY_BASEDIR_VERSION/bin - cd $MY_BASEDIR_VERSION - - This lets you start the mysql daemon from wherever you like. - -9) Now let's say you want to put some of your own databases and users into - the system. The simplest, most powerful, and dangerous way to do this is - to start up the mysql daemon again with: - - foo>bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data -Sg - - This skips loading the grant tables. The system is open to every kind of - mistake now, so be careful. Any user can muck up the grant tables, ie. - the lists of users, hosts, and databases themselves, so only use this - mode to do these first, very basic things. - - Start the client again now, with - foo>bin/mysql mysql - - This tells the client to use the database 'mysql', which is the directory - that contains the lists (ie. the tables) of all the users, hosts, and - databases in the system, so be careful!!!!!!!!!!!! - - All of what follows is taken essentially from section 6 of the manual. - - a) For the start, just define a couple of users for the MySQL system: - i) an administrator, such as 'mysql', with its own password, that - can do everything with the system: - - mysql> insert into user values('localhost','mysql',password('xyzzy'), - 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'); - - * For some reason, on my Linux system with a German keyboard, I have * - * to use the acute accent instead of the apostrophe, otherwise I get * - * parse errors. * - - This defines the user name 'mysql' with password 'xyzzy' that can - do everything. To look at what you just did, type in - - mysql> select * from user; - - mysql types out a table with all the known users and their privileges. - - ii) a privileged user for playing around: - - mysql> insert into user values('localhost','john',password('blah0x1'), - 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'); - - iii) create your own database for a todo list, phone numbers, whatever: - - mysql> create database johns_DB; - mysql> insert into db values('localhost','johns_DB','john','Y','Y','Y','Y','Y','Y'); - - The first line creates the databse "johns_DB", but that doesn't - make it visible to mysql. The second line does that. - - iv) When you are done installing users and databases, quit mysql and - issue the command - - foo>bin/mysqladmin reload - - b) Another method to do this was suggested by Sinisa Milivojevic, and that - is to edit the script /usr/local/mysql/scripts/mysql_install_db to - define the databases and install the more important users when you - start the system the very first time. This would have the advantage - that you can save the script and re-install the system with it if you - have to, automatically defining the important structures. It requires - a little more knowledge of the MySQL system to do this. - - You might want to use this method anyway since it saves editing - mysql_install_db to have it install a superuser with a name other - than "root". The places to change are easy to find. You can, of - course, use the first method above and remove the user named 'root' - when you are done. - - -=============================================================================== - -If anyone is interested enough in this document to make suggestions on how -to improve it, I would be glad to get emails on it. I hope it helps -someone get going with MySQL a little easier. - ---Howard - hs@neuro-physiol.med.uni-goettingen.de diff --git a/Docs/Translations/myodbc-br.texi b/Docs/Translations/myodbc-br.texi deleted file mode 100644 index 6cf7edd3e75..00000000000 --- a/Docs/Translations/myodbc-br.texi +++ /dev/null @@ -1,272 +0,0 @@ -@chapter MySQL ODBC Suporte - -@menu -* Quais ODBC OS:: Sistemas Operacionais são suportados por @strong{MyODBC} -* Problemas ODBC:: Como informar problemas com @strong{MySQL} ODBC -* Clientes MyODBC:: Programas que já foram testados com @strong{MyODBC} -* Administrador ODBC:: Como preencher os diversos campos com o programa Administrador -* ODBC e last_insert_id:: Como obter o valor de uma coluna @code{AUTO_INCREMENT} em ODBC -* Informando bug do MyODBC:: Informando problemas com MyODBC -@end menu - -@strong{MySQL} fornece suporte para ODBC através do programa @strong{MyODBC}. - - -@node Quais ODBC OS, ODBC Problemas, ODBC, ODBC -@section Sistemas Operacionais suportados por MyODBC - -@strong{MyODBC} é um driver 32-bit ODBC (2.50) nível 0 para Windows95 -e Windows NT. Nós esperamos que alguém porte o mesmo para o Windows 3.x. - -@node Problemas ODBC, clientes MyODBC, Quais ODBC OS, ODBC -@section Como informar problemas com MyODBC - -@strong{MyODBC} tem sido testado com Access, Admndemo.exe, C++-Builder, -Centura Team Developer (formalmente Gupta SQL/Windows), ColdFusion (no -Solaris e NT com svc pack 5), Crystal Reports, DataJunction, Delphi, -ERwin, Excel, iHTML, FileMaker Pro, FoxPro, Notes 4.5/4.6, SBSS, Perl -DBD-ODBC, Paradox, Powerbuilder, Powerdesigner 32 bit, VC++ e Visual -Basic. - -Se você souber de algum outro aplicativo que funcione com @strong{MyODBC}, por favor -nos escreva sobre isso através do email @email{myodbc@@lists.mysql.com}. - -@node Clientes MyODBC, Administrador ODBC, Problemas com ODBC, ODBC -@section Programas testados que funcionam com MyODBC - -A maioria dos programas que têm suporte para ODBC, funcionam com o @strong{MyODBC}, -mas cada um dos listados abaixo, têm sido testados por nós ou por informações de -usuários que confirmaram o seu funcionamento. - -@table @asis -@item @strong{Program} -@strong{Comment} -@item Access -Como fazer Accces funcionar: -@itemize @bullet -@item -Você deverá ter uma chave primária na tabela. -@item -Você deve ter um campo timestamp em todas as tabelas em que você quer controlar a -atualização. - -@item -Somente use campos doubles float. Access falha quando faz comparações com campos float -simples. -@item -Configure a opção `Return matching rows' quando conectar com o @strong{MySQL}. -@item -O Access no NT acusará colunas @code{BLOB} como @code{OLE OBJECTS}. -Se ao invés disso você quer colunas @code{MEMO}, deve trocar a coluna para -@code{TEXT} usando @code{ALTER TABLE}. -@item -Access às vezes não lida adequadamente com colunas do tipo @code{DATE}. -Se você tiver problemas com essas colunas, mude as colunas para @code{DATETIME}. -@item -Em certas situações, o Access cria consultas SQL ilegais que o -@strong{MySQL} não pode processar. Você pode resolver isso selecionando o tipo de -consulta @code{"Query|SQLSpecific|Pass-Through"} no menu do Access. -@end itemize -@item DataJunction -Você tem que trocar para mandar @code{VARCHAR} ao invés de @code{ENUM}, porque -o mesmo exporta o último de uma maneira que causa fadiga ao @strong{MySQL}. -@item Excel -Funciona. Algumas dicas: -@itemize @bullet -@item -Se você tem problemas com datas, tente selecioná-las como strings usando a -função @code{CONCAT()}. Por exemplo: -@example -select CONCAT(rise_time), CONCAT(set_time) - from sunrise_sunset; -@end example -Os dados de datas enviadas como string são corretamente reconhecidas pelo -Excel97 como dados do tipo time. - -Neste exemplo o propósito de @code{CONCAT()} é enganar o ODBC, fazendo-o pensar -que a coluna é do 'tipo string'. Sem o @code{CONCAT()}, ODBC sabe que a coluna -é do tipo time e o Excel não entenderá isso. - -Note que isso é um bug no Excel, porque o mesmo converte automaticamente a -string para time. Isto é muito bom quando o fonte é um arquivo -texto, mas não se pode dizer o mesmo quando o fonte é uma conexão -ODBC que informa o tipo exato para cada coluna. -@end itemize -@item odbcadmin -Programa Teste para ODBC. -@item Delphi -Você deverá usar DBE 3.2 ou mais atualizado. Configure o campo de opção -`Don't optimize column width' quando conectando com @strong{MySQL}. - -Também, há aqui um código muito útil que configura tanto a -inserção ODBC e a inserção BDE para MyODBC (a inserção BDE requer um BDE -Alias Editor que pode ser obtido de graça numa Delphi Super Page -perto de você.): (Obrigado a Bryan Brunton @email{bryan@@flesherfab.com} por isto) - -@example -fReg:= TRegistry.Create; - fReg.OpenKey('\Software\ODBC\ODBC.INI\DocumentsFab', True); - fReg.WriteString('Database', 'Documents'); - fReg.WriteString('Description', ' '); - fReg.WriteString('Driver', 'C:\WINNT\System32\myodbc.dll'); - fReg.WriteString('Flag', '1'); - fReg.WriteString('Password', ''); - fReg.WriteString('Port', ' '); - fReg.WriteString('Server', 'xmark'); - fReg.WriteString('User', 'winuser'); - fReg.OpenKey('\Software\ODBC\ODBC.INI\ODBC Data Sources', True); - fReg.WriteString('DocumentsFab', 'MySQL'); - fReg.CloseKey; - fReg.Free; - - Memo1.Lines.Add('DATABASE NAME='); - Memo1.Lines.Add('USER NAME='); - Memo1.Lines.Add('ODBC DSN=DocumentsFab'); - Memo1.Lines.Add('OPEN MODE=READ/WRITE'); - Memo1.Lines.Add('BATCH COUNT=200'); - Memo1.Lines.Add('LANGDRIVER='); - Memo1.Lines.Add('MAX ROWS=-1'); - Memo1.Lines.Add('SCHEMA CACHE DIR='); - Memo1.Lines.Add('SCHEMA CACHE SIZE=8'); - Memo1.Lines.Add('SCHEMA CACHE TIME=-1'); - Memo1.Lines.Add('SQLPASSTHRU MODE=SHARED AUTOCOMMIT'); - Memo1.Lines.Add('SQLQRYMODE='); - Memo1.Lines.Add('ENABLE SCHEMA CACHE=FALSE'); - Memo1.Lines.Add('ENABLE BCD=FALSE'); - Memo1.Lines.Add('ROWSET SIZE=20'); - Memo1.Lines.Add('BLOBS TO CACHE=64'); - Memo1.Lines.Add('BLOB SIZE=32'); - - AliasEditor.Add('DocumentsFab','MySQL',Memo1.Lines); -@end example - -@item C++Builder -Testado com BDE 3.0. O único problema conhecido é que quando o esquema da tabela -muda, os campos da consulta não são atualizados. BDE entretanto, parece não -reconhecer chaves primárias, somente Índice PRIMARY, não entanto isto não -tem sido um problema. - -@item Visual basic -Para atualizar uma tabela, você deverá definir uma chave primária para a tabela. -@end table - -@node Administrador ODBC, ODBC e last_insert_id, Clientes MyODBC, ODBC -@section Como preencher os diversos campos com o programa Administrador - -Existem três possibilidades para especificar o nome do servidor em -Windows95: - -@itemize @bullet -@item -Usando o endereço IP do servidor. -@item -Adicionar um arquivo @file{lmhosts} com a seguinte informação: - -@example -ip nomeservidor -@end example - -Por exemplo: - -@example -194.216.84.21 my -@end example - -@item -Configurar o PC para usar DNS. -@end itemize - -Exemplo de como preencher o ``ODBC setup'': -@example -Windows DSN name: teste -Description: Este é o meu banco de dados teste -MySql Database: teste -Server: 194.216.84.21 -User: monty -Password: minha_senha -Port: -@end example - -O valor para o campo @code{Windows DSN name} é qualquer nome que seja único -em seu Windows ODBC setup. - -Você não precisa especificar os valores para os seguintes campos: @code{Server}, -@code{User}, @code{Password} ou @code{Port} na hora de configurar o ODBC. -Entretanto, se você o faz, esses valores devem ser usados como padrão para fazer -uma conexão. Você tem a opção de trocar os valores nesse instante. - -Se o número da porta não for especificado, o valor padrão da porta (@value{default_port}) -é usado. - -Se você especificar a opção @code{Read options from C:\my.cnf}, os -grupos @code{client} e @code{odbc} devem ser lidos do arquivo @file{C:\my.cnf}. -Você pode usar todas as opções que são usadas por @code{mysql_options()}. -@xref{mysql_options, , @code{mysql_options}}. - -@node ODBC e last_insert_id, Informando bug do MyODBC, Administrador ODBC, ODBC -@section Como obter o valor de uma coluna @code{AUTO_INCREMENT} no ODBC - -Um problema muito usual consiste em como saber o valor de uma coluna do tipo -@code{INSERT} quando a mesma é gerada automaticamente. Com ODBC, você pode -fazer uma coisa como esta (assumindo que @code{auto} é um campo @code{AUTO_INCREMENT}): - -@example -INSERT INTO foo (auto,text) VALUES(NULL,'text'); -SELECT LAST_INSERT_ID(); -@end example - -Ou se você somente quer adicionar o valor noutra tabela, faça o -seguinte: - -@example -INSERT INTO foo (auto,text) VALUES(NULL,'text'); -INSERT INTO foo2 (id,text) VALUES(LAST_INSERT_ID(),'text'); -@end example - -Para o benefício de algumas aplicações ODBC (pelo menos Delphi e Access), -a seguinte consulta pode ser usada para encontrar o valor do novo registro -adicionado: - -@example -SELECT * FROM tbl_name WHERE auto IS NULL; -@end example - -@node Informando bug do MyODBC, , ODBC e last_insert_id, ODBC -@section Informando problemas com MyODBC - -Se você encontra dificuldades com MyODBC, deve começar por fazer -um arquivo log no Administrador ODBC (o log você tem quando -solicita logs do ODBCADMIN) e um log @strong{MyODBC}. Para gerar um log @strong{MyODBC}, -clique a opção `Trace MyODBC' na tela de configuração da conexão -@strong{MyODBC}. -O log será escrito no arquivo @file{C:\myodbc.log}. -Note que você deve usar a @code{MYSQL.DLL} e não a -@code{MYSQL2.DLL} para que esta opção funcione! - -Verifique as consultas que MyODBC envia para o servidor @strong{MySQL}; -Você deverá ser capaz de encontrar isto através da pesquisa da -string @code{>mysql_real_query} no arquivo @file{myodbc.log}. - -Você deve também tentar duplicar as consultas no monitor @code{mysql} -ou @code{admndemo} para encontrar se o erro é do MyODBC ou do @strong{MySQL}. - -Se você encontrar algo errado, por favor envie somente as linhas -relevantes (máximo 40 linhas) para o @email{myodbc@@lists.mysql.com}. Favor nunca -enviar os arquivos log completos do MyODBC ou do ODBC ! - -Se você não encontra o quê está errado, a última opção -é fazer um arquivo (tar ou zip) que contenha um arquivo log do MyODBC, -o arquivo log ODBC e um arquivo README que explique o problema. -Você o manda para @uref{ftp://www.mysql.com/pub/mysql/secret}. Somente nós da TCX -devemos ter acesso a esses arquivos que você manda e nós seremos muito discretos com -os dados ! - -Se você pode fazer um programa que também mostre o mesmo problema, favor mandá-lo -também! - -Se o programa funciona com outro servidor SQL, você pode fazer um -arquivo log que faça exatamente a mesma coisa com o outro servidor -SQL. - -Lembre que quanto mais informação você nos fornece, o resultado é -que nós podemos resolver o problema! diff --git a/Docs/manual-license-spanish.texi b/Docs/manual-license-spanish.texi deleted file mode 100644 index c9cf2bd53da..00000000000 --- a/Docs/manual-license-spanish.texi +++ /dev/null @@ -1,709 +0,0 @@ -@cindex Licensing terms -@cindex Support terms -@node Licensing and Support, Installing, Questions, Top -@chapter MySQL licensing and support - -@menu -* Licensing policy:: Política de licenciamento do @strong{MySQL} -* Copyright:: Direitos autorais usados por @strong{MySQL} -* Commercial use:: Distribuindo comercialmente @strong{MySQL} -* Licensing examples:: Exemplos de situações de licenciamento -* Cost:: Preços de licenciamento e suporte @strong{MySQL} -* Support:: Tipos de suporte comercial -@end menu - -Este capítulo descreve os tipos de licenciamento e suporte do @strong{MySQL}, incluindo: - -@itemize @bullet -@item -Nossa política de licenciamento para sistemas operacionais não Microsoft e Microsoft - -@item -Os direitos autorais sob os quais o @strong{MySQL} é distribuído -(@pxref{Copyright}) - -@item -Exemplo de situações quando uma licença é necessária -(@pxref{Licensing examples}) - -@item -Preços de licenciamento e suporte (@pxref{Cost}), e -benefícios do suporte (@pxref{Support}) -@end itemize - -@cindex Licensing policy -@node Licensing policy, Copyright, Licensing and Support, Licensing and Support -@section MySQL licensing policy - -Os termos formais do licenciamento para sistemas operacionais não Microsoft tais como -Unix ou OS/2 são especificados em @ref{Public license}. Basicamente, nossa política de -licenciamento é como segue: - -@itemize @bullet -@item -Para uso interno normal, o @strong{MySQL} geralmente não custa nada. Você não precisa -nos pagar se não o quiser. - -@item -Uma licença é requerida se: - -@itemize @minus -@item -Você vende o servidor @strong{MySQL} diretamente ou como parte de outro produto ou serviço. - -@item -Você cobra para instalar e manter um servidor @strong{MySQL} no local do cliente - -@item -Você incluie o @strong{MySQL} numa distribuição que não é redistribuída -e você cobra por alguma parte dessa distribuição -@end itemize - -@item -Para circunstâncias sob as quais uma licença do @strong{MySQL} é requerida, -você necessita uma licença por mâquina que roda o servidor @code{mysqld}. -Entretanto, uma mâquina com múltiplos processadores conta como uma mâquina -simples e não há restrição no número de servidores que rodam numa só mâquina -ou no número de clientes concurrentes conectados ao servidor em essa mâquina. - -@item -Você não necessita uma licença para incluir código de programas clientes -comerciais. O acesso de parte de clientes para o @strong{MySQL} é de -domínio público. O código do cliente @code{mysql} de linha de comando -incluie código da livraria @code{readline} que está sob a licença pública -GNU. - -@item -@cindex @code{myisampack} -Para clientes que tem comprado 1 licença ou suporte MySQL, nós fornecemos -funcionalidade adicional. Atualmente, isso significa o fornecimento do -utilitário @code{myisampack} para banco de dados somente de leitura, -rápidos e compactados. (O servidor incluie suporte para ler tais bancos -de dados mas não a ferramenta de compactar usada para criar os mesmos). -Quando os acordos de suporte gerem suficientes recursos, nós liberaremos -esta ferramenta sob a mesma licença do servidor @strong{MySQL}. - -@item -Se seu uso do @strong{MySQL} não requer uma licença, porém você gosta -do @strong{MySQL} e deseja encorajar um maior desenvolvimento, você é -certamente bem-vindo a adquirir uma licença de qualquer forma. - -@item -Se usa o @strong{MySQL} num contexto comercial de tal forma -que obtêm benefícios no seu uso, nós lhe solicitamos que apoie -o desenvolvimento do @strong{MySQL} através da compra de algum -nível de suporte. Nós achamos que se o @strong{MySQL} o ajuda -em seu negócio, é razoável que solicitemos sua ajuda para o @strong{MySQL}. -Por outro lado, se você nós faz perguntas de suporte, não somente está -usando de graça algo no qual nós colocamos um enorme trabalho, você -também está pedindo suporte de graça. -@end itemize - -Para uso em sistemas operacionais Microsoft (Win95/Win98/WinNT), -você precisa de uma licença @strong{MySQL} depois de 30 dias -de experiência, com a exceção que licenças podem ser requeridas -sem nenhum custo para uso educacional ou para suportar pesquisas -de governo ou universidades. @xref{Winlicense}. -Uma versão shareware do @strong{MySQL}-Win32 que você pode experimentar -antes de comprar está disponível em @uref{http://www.mysql.com/mysql_w32.htmy}. -Depois que você tenha pago, você terá uma senha que permite seu acesso a uma -nova versão @strong{MySQL}-Win32. - -Se você tem uma pergunta se for o caso ou não de requerer uma licença para -seu caso em particular do @strong{MySQL}, favor entrar em contato com nós. -@xref{Contact information}. - -Se você requer uma licença @strong{MySQL}, a forma mais fácil para pagar -a mesma é usar o formulário no seguro servidor TcX em @url{https://www.mysql.com/license.htmy}. -Outras formas de pagamento são mencionadas em @ref{Payment information}. - -@cindex Copyright -@node Copyright, Commercial use, Licensing policy, Licensing and Support -@section Copyrights used by MySQL - -@menu -* Copyright changes:: Possível futura mudança no direito autoral -@end menu - -Existem vários direitos autorais diferentes na distribuição @strong{MySQL}: - -@enumerate -@item - -O fonte específico @strong{MySQL}necessário para construir o @code{mysqlclient} -livrarias e programas no diretório @file{client} está em domínio público. -Cada arquivo que está em domínio público tem um cabeçalho que claramente notifica -este estado. Isto incluie tudo no diretório @file{client}e algumas partes -do @code{mysys}, @code{mystring} e @code{dbug} livrarias. - -@item -Algumas pequenas partes do fonte (GNU @code{getopt}) estão cobertas pela -``GNU LIBRARY LIBRARY GENERAL PUBLIC LICENSE''. Ver o arquivo -@file{mysys/COPYING.LIB}. - -@item -Algumas pequenas partes do fonte ( (GNU @code{readline}) estão cobertas pela -``GNU GENERAL PUBLIC LICENSE''. Ver o arquivo @file{readline/COPYING}. - -@item -Algumas partes do fonte (a @code{regexp} livraria) está coberta pelo estilo de -direito autoral Berkeley. - -@item -O outro fonte necessário para o servidor @strong{MySQL} em plataformas não Microsoft -está coberta pela ``MySQL FREE PUBLIC LICENSE'', a qual é baseada na -``Aladdin FREE PUBLIC LICENSE.'' @xref{Public license}. Quando o @strong{MySQL} -está rodando em qualquer sistema operacional Microsoft, outro licenciamento é aplicado. -@end enumerate - -Os seguintes pontos direcionam a filosofia sob nossa política de direito autoral: - -@itemize @bullet -@item -A livraria cliente SQL deve ser totalmente livre tal que a mesma pode ser incluída -em produtos comerciais sem nenhuma limitação. - -@item -Pessoas que querem livre acesso ao programa no qual nós temos colocado uma grande -quantidade de trabalho, podem tê-lo, tal que não procurem ganhar dinheiro diretamente -pela distribuição e para benefício. - -@item -Pessoas que querem manter o direito da propriedade de seu programa, porém também -querem o valor de nosso trabalho, podem pagar pelo previlégio. - -@item -O uso normal em casa é de GRAÇA. Mas se você usa o @strong{MySQL} para algo -importante para você, você pode ajudar o desenvolvimento futuro pela -compra de uma licença ou contrato de suporte.@xref{Support}. -@end itemize - -@node Copyright changes, , Copyright, Copyright -@subsection Possible future copyright changes - -Nós poderemos optar para distribuir versões antigas do @strong{MySQL} -com a GPL no futuro. Entretanto, essas versões devem ser identificadas -como @strong{GNU MySQL}. Também, todas notas de direitos autorais dos -arquivos relativos devem ser mudados para a GPL. - -@node Commercial use, Licensing examples, Copyright, Licensing and Support -@section Distributing MySQL commercially - -Esta seção é um esclarecimento dos termos de licença que são a base na -``MySQL FREE PUBLIC LICENSE'' (FPL). @xref{Public license}. - -O @strong{MySQL} pode ser @strong{usado} livremente , incluindo -entidades comerciais para avaliação ou uso interno sem suporte. -Entretanto, @strong{distribuição} para propósitos comerciais -do @strong{MySQL}, ou qualquer coisa contendo ou derivando do @strong{MySQL} -no seu todo ou parte, requer uma licença comercial escrita da TcX AB, -a única entidade autorizada para garantir tais licenças. - -Você não pode incluir o @strong{MySQL} ``de graça'' num pacote contendo -qualquer coisa pela qual um pagamento está sendo feito, exceto como -notado abaixo: - -A intenção da exceção providenciada na segunda claúsula da licença é -para permitir que organizações comerciais operando um servidor FTP ou -uma agência de notícias possam distribuir livremente o @strong{MySQL}, -desde que: - -@enumerate -@item -A organização complace com as outras provisões da FPL, a qual -incluie entre outras coisas um requerimento para distribuir o -código fonte inteiro do @strong{MySQL} e qualquer outro trabalho -derivado, e para distribuir a FPL em si junto com @strong{MySQL}; - -@item -A única cobrança para abaixar o @strong{MySQL} é a cobrança baseada -na distribuição do serviço e não numa baseada no contexto da -informação sendo recebida (ex: a cobrança deverá ser a mesma para -o recebimento de uma coleção qualquer de bits do mesmo tamanho); - -@item -O servidor ou BBS é acessível para o público em geral, ex. o número de -telefone ou enedereço IP não é guardado em secreto, e qualquer um pode -obter acesso para a informação (possivelmente pagando uma inscrição ou -acesso cobrado que não é dependente ou relacionado para comprar qualquer -outra coisa). -@end enumerate - -Se você quer para distribuir programas em um contexto comercial que -incorpora @strong{MySQL} e você @strong{não} quer encontrar essas -condições, você deve contatar TcX AB para encontrar um licenciamento -comercial, o qual envolve um pagamento. O único meio legal que -você pode distribuir @strong{MySQL} ou qualquer coisa contendo @strong{MySQL} -são pela distribuição do @strong{MySQL} sob os requerimentos da FPL, ou pela -obtenção de uma licença comercial da TcX AB. - -@node Licensing examples, Cost, Commercial use, Licensing and Support -@section Example licensing situations - -@menu -* Products that use MySQL:: Vendendo produtos que usam @strong{MySQL} -* MySQL services:: Vendendo serviços relacionados ao @strong{MySQL} -* ISP:: Serviços de ISP com @strong{MySQL} -* Web server:: Rodando um servidor web usando o @strong{MySQL}. -@end menu - -Esta seção descreve algumas situações ilustrando se é o caso ou não que -você deve licençar o servidor @strong{MySQL}. Geralmente esses exemplos -envolvem o fornecimento do @strong{MySQL} como parte de um produto ou -serviço que você está vendendo para um cliente, ou requer que o @strong{MySQL} -seja usado em conjunto com seu produto. Em tais casos, é sua responsabilidade -para obter uma licença para o cliente se uma é necessária (Este requerimento -pode ser deixado de lado se seu cliente já tem uma licença @strong{MySQL}. -Porém, o vendedor deve enviar informação do cliente e o número da licença -para TcX, e a licença deverá ser completa, não uma licença OEM). - -Note que uma simples licença do @strong{MySQL} cobre qualquer número de -CPUs/usuários/clientes/servidores @code{mysqld} numa só mâquina! - -@node Products that use MySQL, MySQL services, Licensing examples, Licensing examples -@subsection Selling products that use MySQL - -Para determinar caso seja necessário ou não uma licença @strong{MySQL} -quando vendendo a sua aplicação, você deve perguntar caso seja necessário -para o funcionamento adequado de sua aplicação a contingência no uso do -@strong{MySQL} e seja necessário você incluir o @strong{MySQL} com seu -produto. Existem vários casos a considerar: - -@itemize @bullet -@item -Sua aplicação precisa do @strong{MySQL} para funcionar adequadamente ? - -Se o seu produto precisa do @strong{MySQL}, você necessita uma licença -para cada mâquina que roda o servidor @code{mysqld}. Por exemplo, -se você projeta uma aplicação sobre o @strong{MySQL}, então você tem -feito realmente um produto comercial que necessita do servidor, tal que -necessita de uma licença. - -Se sua aplicação não requer o @strong{MySQL}, você não necessita obter uma -licença. Por exemplo, se o @strong{MySQL} apenas adiciona uma nova característica -a seu produto (tal como adicionando loggin a um banco de dados e se o @strong{MySQL} -é usado no lugar de um arquivo texto), o mesmo entra como um uso normal, e uma -licença não precisa ser requerida. - -Em outras palavras, você necessita de uma licença se você vende um produto -projetado para uso com o @strong{MySQL} ou que precisa do servidor @strong{MySQL} -para um funcionamento completo. Isto é verdadeiro caso haja necessidade ou não de fornecer -o @strong{MySQL} para seu cliente como parte da distribuição de seu produto. - -Isso também depende no que você está fazendo para o cliente. Você planeja fornecer -a seu cliente com instruções e detalhes na instalação do @strong{MySQL} com seu -programa ?. Então seu produto contencialmente precisa do @strong{MySQL}; -Sim é tal, você necessita comprar uma licença. Se você simplesmente usa um banco de -dados que espera já estiver instalado no instante en seu programa é comprado, então -provavelmente não necessita de uma licença. - -@item -Você incluie o @strong{MySQL} numa distribuição e cobra pela mesma ? - -Se você incluie @strong{MySQL} com a distribuição que vende para os clientes, -você necessita uma licença para cada mâquina que roda o servidor @code{mysqld}, -porque neste caso você está vendendo um sistema que incluie @strong{MySQL}. - -Isto é verdadeiro no caso que o @strong{MySQL} com seu produto seja requerido -ou opcional. - -@item -Você não requer nem incluie o @strong{MySQL} com seu produto ? - -Suponha que quer vender um produto projetado de uma maneira geral para usar -com "qualquer banco de dados" e que pode ser configurado para usar qualquer -uma das várias alternativas de sistemas de banco de dados (@strong{MySQL}, -PostgreSQL, ou qualquer outro. Isto é, seu produto não requer @strong{MySQL}, -mas pode suportar qualquer banco de dados com o nível base de funcionalidade -e você não depende de qualquer coisa que somente @strong{MySQL} suporta. -Nenhum de vocês paga para nós se o seu cliente realmente seleciona para -usar @strong{MySQL}? - -Neste caso, se você não fornece, obtêm ou configura o @strong{MySQL} para -o cliente e decide o cliente para usá-lo, nenhum de vocês precisa de uma -licença. Se você faz um serviço, vide @ref{MySQL services, , -@strong{MySQL} serviços}. -@end itemize - -@node MySQL services, ISP, Products that use MySQL, Licensing examples -@subsection Selling MySQL-related services - -Se você faz uma instalação numa mâquina de um cliente do @strong{MySQL} -e há cobrança pelo serviço (direta ou indiretamente), então você comprar -uma licença @strong{MySQL}. - -Se você vende uma aplicação para a qual o @strong{MySQL} não é estritamente -requerido, porém pode ser usado, uma licença deve indicada, dependendo -como o @strong{MySQL} é configurado. Suponha que seu produto não requera e -não incluia o @strong{MySQL} na sua distribuição, porém pode ser configurado -para usar o @strong{MySQL} para os clientes que assim o desejar. (Este pode ser -o caso, por exemplo, se seu produto pode usar qualquer um de servidores de -banco de dados). - -Se o cliente obtêm e instala o @strong{MySQL}, nenhuma licença é necessária. -Entretanto, se você faz o serviço para seu cliente, então é necessário uma -licença, porque você está vendendo um serviço que incluie o @strong{MySQL}. - -@node ISP, Web server, MySQL services, Licensing examples -@subsection ISP MySQL services - -Provedores de Serviço Internet (ISPs) às vezes hospedam servidores @strong{MySQL} -para seus cliente. - -Se você é um ISP que permite a seus clientes instalar e administrar o -@strong{MySQL} por si próprios na sua mâquina sem nenhuma assistência -de sua parte, nem você nem o cliente precisa de uma licença @strong{MySQL}. - -Se você cobra para instalar e administrar o @strong{MySQL} como parte de seu -serviço para o cliente, então você precisa de uma licença, porque está vendendo -um serviço que incluie o @strong{MySQL}. - -@node Web server, , ISP, Licensing examples -@subsection Running a web server using MySQL - -Se você usa o @strong{MySQL} em conjunto com um servidor web, você não tem -que pagar uma licença. - -Isto é verdadeiro se você roda um servidor web comercial que usa @strong{MySQL}, -desde que você não esteja vendendo o @strong{MySQL}. Entretanto, neste caso -nós gostariamos que você compre suporte @strong{MySQL}, porque @strong{MySQL} -está ajudando a sua empresa. - -@cindex Costs, licensing and support -@cindex Licensing costs -@cindex Support costs -@node Cost, Support, Licensing examples, Licensing and Support -@section MySQL licensing and support costs - -@menu -* Payment information:: Informação de Pagamento -* Contact information:: Informação de contato -@end menu - -Nossos preços atuais de licença são mostrados abaixo. Todos os preços são -em US Dólar. Se você paga com cartão de crédito, a moeda é o EURO (European Union Euro), -tais preços diferem levemente. - -@multitable @columnfractions .25 .2 .3 -@item @strong{Número de licenças} @tab @strong{Preço por cópia} @tab @strong{Total} -@item 1 @tab US $200 @tab US $200 -@item 10 pacotes @tab US $150 @tab US $1500 -@item 50 pacotes @tab US $120 @tab US $6000 -@end multitable - -Para compras em alto volume (OEM), os seguintes preços são aplicados: - -@multitable @columnfractions .25 .2 .3 .25 -@item @strong{Número de licenças} @tab @strong{Preço por cópia} @tab @strong{Mínimo de uma vez} @tab @strong{Pagamento mínimo} -@item 100-999 @tab US $40 @tab 100 @tab US $4000 -@item 1000-2499 @tab US $25 @tab 200 @tab US $5000 -@item 2500-4999 @tab US $20 @tab 400 @tab US $8000 -@end multitable - -Para compras OEM, você deve atuar como o intermediário para eventuais -problemas ou solicitações de seus usuários. Nós também requeremos que -clientes OEM tenham ao menos um contrato de suporte extended email. - -Se você tem uma margem baixa em alto volume de produtos, você pode falar -com nós sobre outros termos (por exemplo, a porcentagem dos preços de -venda). Se você faz, por favor seja informativo sobre seu produto, preço, -mercado e qualquer outra informação que seja relevante. - -@cindex @code{myisampack} -Depois de comprar 1 licença @strong{MySQL}, você terá uma cópia pessoal -do utilitário @code{myisampack}. Você não está permitido em distribuir -esse utilitário porém você pode distribuir tabelas compactadas com ele. - -Um preço completo de uma licença não é um acordo de suporte e incluie um -mínimo suporte. Isto significa que nós tentamos responder qualquer pergunta -relevante. Se a resposta está na documentação, nós direcionamos você à -apropriada seção. Se você não tem comprado uma licença ou suporte, nós -provavelmente não responderemos ao tudo. - -Se você descobre o que consideramos um real bug, nós estamos prontificados -a solucionar o erro em qualquer caso. Porém se você paga por suporte nós -o notificaremos sobre o andamento da solução ao invés de soluncioná-lo -nos próximos lançamentos. - -Suporte mais amplo é vendido separadamente. Descrições do que incluie cada -nível de suporte são dadas em @ref{Support}. Custos para os vários tipos -comerciais de suporte são mostrados abaixo. O nível de preços de suporte -estão em EURO (European Union Euro). Um EURO é aproximadamente 1.17 USD. - -@multitable @columnfractions .3 .3 -@item @strong{Tipo de suporte} @tab @strong{Custo por ano} -@item Basic email support @tab EURO 170 -@item Extended email support @tab EURO 1000 -@item Login support @tab EURO 2000 -@item Extended login support @tab EURO 5000 -@end multitable - -Você pode atualizar um nível mais baixo sw suporte para um de maior -nível, pela diferença entre os preços dos dois níveis. - -@cindex Payment information -@node Payment information, Contact information, Cost, Cost -@subsection Payment information - -Correntemente nós podemos tomar pagamentos SWIFT, cheques ou cartões de crédito. - -O pagamento poderá ser feito a: -@example -Postgirot Bank AB -105 06 STOCKHOLM, SWEDEN - -TCX DataKonsult AB -BOX 6434 -11382 STOCKHOLM, SWEDEN - -SWIFT address: PGSI SESS -Número da Conta: 96 77 06 - 3 -@end example - -Especificar: licença e/ou suporte, seu nome e endereço de e-mail. - -Em europa e Japão você pode usar EuroGiro (que pode ser menos caro) para a mesma -conta. - -Se você quer pagar através de cheque, faça-o nominal a ``Monty Program KB'' e mande -um e-mail para o endereço abaixo: - -@example -TCX DataKonsult AB -BOX 6434, Torsgatan 21 -11382 STOCKHOLM, SWEDEN -@end example - -Se você quer pagar com cartão de crédito usando a Internet, você pode -usar o seguro formulário de licença da TcX: -@uref{https://www.mysql.com/license.htmy. - -Você pode também imprimir uma cópia do formulário de licença, prenché-lo e mandá-lo -via fax para: - - -+46-8-729 69 05 - -Se você quer que nós uma cobrança para você, você pode usar o formulário de -licença e escrever ``bill us'' no campo de comentários. Você pode também -mandar uma mensagem via e-mail para @email{sales@@mysql.com} (@strong{not} -@email{mysql@@lists.mysql.com}!) com a informação de sua companhia e pedir -para nós para efetuar a cobrança. - -@cindex Contact information -@node Contact information, , Payment information, Cost -@subsection Contact information - -Para licenciamento comercial, ou se você têm qualquer pergunta sobre -informação desta seção, por favor contatar a equipe de licenciamento -do @strong{MySQL}. O mais preferido método é o e-mail para -@email{mysql-licensing@@mysql.com}. Fax é também possível porém sua -manipulação pode demorar muito (Fax +46-8-729 69 05). - -@example -David Axmark -Detron HB -Kungsgatan 65 B -753 21 UPPSALA -SWEDEN -Fone Voz +46-18-10 22 80 (Timezone GMT+1. Fala Sueco e Inglés) -@end example - -@cindex Support, types -@cindex Types of support -@node Support, , Cost, Licensing and Support -@section Types of commercial support - -@menu -* Basic email support:: Basic email support -* Extended email support:: Extended email support -* Login support:: Login support -* Extended login support:: Extended login support -@end menu - -@node Basic email support, Extended email support, Support, Support -@subsection Basic email support - -Basic email support é a opção mais barata de suporte e deverá ser vista -como uma forma de suportar nosso desenvolvimento do @strong{MySQL} que -uma real opção de suporte. - -Neste nível de suporte, a lista de e-mail do @strong{MySQL} é o preferido -meio de comunicação. Perguntas normalmente podem ser enviadas para a -principal lista de e-mail (@email{mysql@@lists.mysql.com}) ou uma das outras -listas regulares (por exemplo, @email{mysql-win32@@lists.mysql.com} relacionada -às perguntas para o @strong{MySQL} Windows, tal que qualquer pessoa pode já ter -experimentado e resolvido o problema que você tem. @xref{Asking questions}. - -Entretanto, comprando o suporte basic email support, você também tem acesso -ao e-mail @email{mysql-support@@mysql.com}, o qual não é disponível -como parte do suporte mínimo que se tem quando se adquire uma licença @strong{MySQL}. -Isto significa que para perguntas críticas, você pode mandar sua mensagem para -@email{mysql-support@@mysql.com}. (Se a mensagem tem dados privados, você só -deve mandar para o @email{mysql-support@@mysql.com}.) - -@emph{LEMBRE-SE!} para SEMPRE incluir o número de registro e data de -término quando mandar uma mensagem para -@email{mysql-support@@mysql.com}. - -Basic email support incluie os seguintes tipos de serviços: - -@itemize @bullet -@item -Se sua pergunta já está respondida no manual, nós o informamos da correta -seção na qual pode encontrar a resposta. Se a resposta não está no manual, -nós o colocamos na direção certa para resolver seu problema. - -@item -Nós garantimos em tempo apropriado a resposta das mensagem de seu e-mail. -Nós não podemos garantir que podemos resolver qualquer problema, porém ao -menos você receve uma resposta se podemos contatá-lo por e-mail. - -@item -Nós podemos ajudá-lo com problemas inesperados quando instala @strong{MySQL} -a partir de uma distribuição binária em plataformas suportadas. Este nível de -suporte não cobre instalação do @strong{MySQL} a partir de uma distribuição -fonte. Plataformas ``Suportadas'' são aquelas plataformas nas quais o @strong{MySQL} -é conhecido que funciona. -@xref{Which OS}. - -@item -Nós ajudaremos você com bugs e problemas de características. Qualquer -bug que for encontrado nós o solucionamos no próximo lançamento do @strong{MySQL}. -Se o bug é crítico para você, nós enviamos um e-mail com o patch -tão logo como o bug é resolvido. Bugs críticos têm sempre para nós a maior -prioridade, para assegurar que sejam solucionados tão pronto como possível. - -@item -Suas sugestões para desenvolvimento posterior do @strong{MySQL} são tomadas -em consideração. Obtendo o email support, você já ajuda o desenvolvimento -posterior do @strong{MySQL}. Se você quer pôr mais, faça a atualização -para um nível mais alto de suporte. - -@item -Se você quer nós ajudar a otimizar seu sistema, você deve atualizar -para um nível maior de suporte. - -@item -@cindex @code{myisampack} -Nós incluimos uma versão binária da ferramenta de compactação @code{myisampack} -para criar rápidos bancos de dados compactados, somente de leitura. O atual -servidor incluie suporte para ler esses bancos de dados mas não a ferramenta -para criar os mesmos. -@end itemize - -@node Extended email support, Login support, Basic email support, Support -@subsection Extended email support - -Extended email support incluie tudo o do basic email support com estas -adições: - -@itemize @bullet -@item -Seu e-mail será tratado antes dos e-amil dos usuários do basic email support -e dos usuários não registrados. - -@item -Suas sugestões para o próximo desenvolvimento do @strong{MySQL} receberá -uma forte consideração. Simples extensões que fazem os gols do @strong{MySQL} -são a implementação em questão de dias. adquirindo o extended email support -você auxilia daqui para frente o desenvolvimento do @strong{MySQL}. - -@item -Perguntas típicas que são cobertas pelo extended email support são: - -@itemize @minus -@item -Nós respondemos e (dentro do razoável) resolvemos as perguntas relacionadas -a possíveis bugs no @strong{MySQL}. Tão pronto como os bugs são encontrados -e corregidoa, nós mandamos por e-mail o pacth para ele. - -@item -Nós auxiliamos com inesperados problemas quando você instala o @strong{MySQL} -a partir do fonte ou distribuição binária nas plataformas suportadas. - -@item -Nós responderemos perguntas sobre características perdidad e ofereceremos -dicas como trabalhar e contornar elas. - -@item -Nós forneceremos dicas na otimização do @code{mysqld}para sua situação. -@end itemize - -@item -Você está permitido a influenciar a prioridade de itens do TODO do @strong{MySQL}. -Isso assegura que as características que você realmente precisa sejam implementadas -rapidamente que as mesmas poderia ser de outra forma. -@end itemize - -@node Login support, Extended login support, Extended email support, Support -@subsection Login support - -O Login support incluie tudo do extended email support com estas adições: - -@itemize @bullet -@item -Seu e-mail terá prioridade sobre os usuários do suporte extended email. - -@item -Suas sugestões para o próximo desenvolvimento do @strong{MySQL} será tomado -com uma alta consideração. Extensões reais que podem ser implementadas num -par de horas e que fazem os gols do @strong{MySQL} serão implementadas -tão logo como possível. - -@item -Se você tem um problema muito específico, nós tentaremos logar no seu -sistema para resolver o problema ''no local''. - -@item -Tal como qualquer outro vendedor de banco de dados, não podemos garantir que -podemos recuperar qualquer dado de tabelas corrompidas, porém se o pior acontece -nós poderemos a recuperar tanto quanto seja possível. O @strong{MySQL}tem provado -ser muito seguro, porém qualquer é possível devido a circuntâncias fora de nosso -controle (por exemplo, se seu sistema crash ou alguém kill o servidor executando -um comando @code{kill -9}). - -@item -Nós providenciaremos dicas na otimização de seu sistema e consultas. - -@item -Você está permitido para chamar um desenvolvedor @strong{MySQL} (moderadamente) e -discutir seu problemas relacionados com o @strong{MySQL}. -@end itemize - -@node Extended login support, , Login support, Support -@subsection Extended login support - -O Extended login support incluie tudo do login support com estas adições: - -@itemize @bullet -@item -Seu e-mail tem a mais alta prioridade possível. - -@item -Nós ativamente examinamos seu sistema e ajudamos a otimizá-lo assim como suas -consultas. Nós também podemos otimizar e/ou extender o @strong{MySQL} -para suprir melhor suas necessidades. - -@item -Você também pode solicitar extensões es peciais apenas para você. Por exemplo: -@example -mysql> select MY_CALCULATION(col_name1,col_name2) from tbl_name; -@end example - -@item -Nós podemos fornecer uma distribuição binária para todas as atualizações -mais importantes do @strong{MySQL} para seu sistema, tão logo como podemos -obter uma conta em um sistema similar. No pior dos casos, nós podemos requerer -acesso para seu sistema para ser capaz de criar uma distribuição binária. - -@item -Se você pode providenciar acomodações e pagar os custos de viagem para um -desenvolvedor @strong{MySQL} para vistá-lo e oferecer ajuda com seus problemas. -O suporte Extended login support entitula você para um encontro pessoal por -ano, porém nós sempre somos muito flexíveis para levar para frente nossos -clientes!. -@end itemize - -@node Installing, Compatibility, Licensing and Support, Top - diff --git a/Docs/manual.de.texi b/Docs/manual.de.texi deleted file mode 100644 index 902a9496bbb..00000000000 --- a/Docs/manual.de.texi +++ /dev/null @@ -1,107 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@c -@c ********************************************************* -@c -@c This is a dummy placeholder file for manual.de.texi in the -@c MySQL source trees. -@c -@c Note, that the manual has been moved into a separate -@c BitKeeper source tree named "mysqldoc" - do not attempt -@c to add NEWS entries or documentation to this file! All -@c changes to the manual should be done in the mysqldoc tree. -@c -@c See http://www.mysql.com/doc/en/Installing_source_tree.html -@c for information about how to work with BitKeeper source trees. -@c -@c This dummy file is being replaced with the real manual from the -@c mysqldoc tree when building the official source distribution. -@c -@c Please e-mail docs@mysql.com for more information or if -@c you are interested in doing a translation. -@c -@c ********************************************************* -@c -@c %**start of header - -@setfilename mysql.de.info - -@c We want the types in the same index -@syncodeindex tp fn - -@c Get version information. This file is generated by the Makefile!! -@include include.texi - -@ifclear tex-debug -@c This removes the black squares in the right margin -@finalout -@end ifclear - -@c Set background for HTML -@set _body_tags BGCOLOR=silver TEXT=#000000 LINK=#101090 VLINK=#7030B0 -@c Set some style elements for the manual in HTML form. 'suggested' -@c natural language colors: aqua, black, blue, fuchsia, gray, green, -@c lime, maroon, navy, olive, purple, red, silver, teal, white, and -@c yellow. From Steeve Buehler -@set _extra_head - -@settitle Dummy MySQL Reference Manual for version @value{mysql_version}. - -@c We want single-sided heading format, with chapters on new pages. To -@c get double-sided format change 'on' below to 'odd' -@setchapternewpage on - -@paragraphindent 0 - -@c %**end of header - -@ifinfo -@format -START-INFO-DIR-ENTRY -* mysql: (mysql). MySQL documentation. -END-INFO-DIR-ENTRY -@end format -@end ifinfo - -@titlepage -@sp 10 -@center @titlefont{Empty placeholder for the MySQL Reference Manual} -@sp 10 -@center Copyright @copyright{} 1995-2002 MySQL AB -@c blank page after title page makes page 1 be a page front. -@c also makes the back of the title page blank. -@page -@end titlepage - -@c This should be added. The HTML conversion also needs a MySQL version -@c number somewhere. - -@iftex -@c change this to double if you want formatting for double-sided -@c printing -@headings single - -@oddheading @thischapter @| @| @thispage -@evenheading @thispage @| @| MySQL Technical Reference for Version @value{mysql_version} - -@end iftex - -@node Top, (dir), (dir), (dir) - -@ifinfo -This is an empty placeholder file for the MySQL manual. - -The MySQL manual is now maintained in a separate BitKeeper source tree! -Please see @url{http://www.mysql.com/doc/en/Installing_source_tree.html} -for more info on how to work with BitKeeper. - -Please do not attempt to edit this file to add NEWS entries or to add -documentation! Use the one in the @code{mysqldoc} BK tree instead. - -This file will be replaced with the current @code{manual.de.texi} when building -the official source distribution. - -You can find a specific manual for any older version of MySQL -in the binary or source distribution for that version. -@end ifinfo - -@bye diff --git a/Docs/manual.texi b/Docs/manual.texi deleted file mode 100644 index 989a1836a15..00000000000 --- a/Docs/manual.texi +++ /dev/null @@ -1,107 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@c -@c ********************************************************* -@c -@c This is a dummy placeholder file for manual.texi in the -@c MySQL source trees. -@c -@c Note, that the manual has been moved into a separate -@c BitKeeper source tree named "mysqldoc" - do not attempt -@c to add NEWS entries or documentation to this file! All -@c changes to the manual should be done in the mysqldoc tree. -@c -@c See http://www.mysql.com/doc/en/Installing_source_tree.html -@c for information about how to work with BitKeeper source trees. -@c -@c This dummy file is being replaced with the real manual from the -@c mysqldoc tree when building the official source distribution. -@c -@c Please e-mail docs@mysql.com for more information or if -@c you are interested in doing a translation. -@c -@c ********************************************************* -@c -@c %**start of header - -@setfilename mysql.info - -@c We want the types in the same index -@syncodeindex tp fn - -@c Get version information. This file is generated by the Makefile!! -@include include.texi - -@ifclear tex-debug -@c This removes the black squares in the right margin -@finalout -@end ifclear - -@c Set background for HTML -@set _body_tags BGCOLOR=silver TEXT=#000000 LINK=#101090 VLINK=#7030B0 -@c Set some style elements for the manual in HTML form. 'suggested' -@c natural language colors: aqua, black, blue, fuchsia, gray, green, -@c lime, maroon, navy, olive, purple, red, silver, teal, white, and -@c yellow. From Steeve Buehler -@set _extra_head - -@settitle Dummy MySQL Reference Manual for version @value{mysql_version}. - -@c We want single-sided heading format, with chapters on new pages. To -@c get double-sided format change 'on' below to 'odd' -@setchapternewpage on - -@paragraphindent 0 - -@c %**end of header - -@ifinfo -@format -START-INFO-DIR-ENTRY -* mysql: (mysql). MySQL documentation. -END-INFO-DIR-ENTRY -@end format -@end ifinfo - -@titlepage -@sp 10 -@center @titlefont{Empty placeholder for the MySQL Reference Manual} -@sp 10 -@center Copyright @copyright{} 1995-2002 MySQL AB -@c blank page after title page makes page 1 be a page front. -@c also makes the back of the title page blank. -@page -@end titlepage - -@c This should be added. The HTML conversion also needs a MySQL version -@c number somewhere. - -@iftex -@c change this to double if you want formatting for double-sided -@c printing -@headings single - -@oddheading @thischapter @| @| @thispage -@evenheading @thispage @| @| MySQL Technical Reference for Version @value{mysql_version} - -@end iftex - -@node Top, (dir), (dir), (dir) - -@ifinfo -This is an empty placeholder file for the MySQL manual. - -The MySQL manual is now maintained in a separate BitKeeper source tree! -Please see @url{http://www.mysql.com/doc/en/Installing_source_tree.html} -for more info on how to work with BitKeeper. - -Please do not attempt to edit this file to add NEWS entries or to add -documentation! Use the one in the @code{mysqldoc} BK tree instead. - -This file will be replaced with the current @code{manual.texi} when building -the official source distribution. - -You can find a specific manual for any older version of MySQL -in the binary or source distribution for that version. -@end ifinfo - -@bye diff --git a/Docs/manual_toc.html b/Docs/manual_toc.html deleted file mode 100644 index b9014e5efb9..00000000000 --- a/Docs/manual_toc.html +++ /dev/null @@ -1,9 +0,0 @@ - - -Place holder for manual_toc.html - - -This is just a place holder for the autogenerated manual_toc.html -to make "make dist" happy. - - diff --git a/Docs/mirrors.texi b/Docs/mirrors.texi deleted file mode 100644 index 651963c57c3..00000000000 --- a/Docs/mirrors.texi +++ /dev/null @@ -1,446 +0,0 @@ -@strong{Europe:} - -@itemize @bullet - -@item -@image{Flags/armenia} Armenia [AbideWeb Technologies] @@ -WWW (@uref{http://mysql.abideweb.com/}) -FTP (@uref{ftp://mysql.abideweb.com/mirrors/MySQL/}) - -@item -@image{Flags/austria} Austria [Univ. of Technology/Vienna] @@ -WWW (@uref{http://gd.tuwien.ac.at/db/mysql/}) -FTP (@uref{ftp://gd.tuwien.ac.at/db/mysql/}) - -@item -@image{Flags/belgium} Belgium [BELNET] @@ -WWW (@uref{http://mysql.belnet.be/}) -FTP (@uref{ftp://ftp.belnet.be/mirror/ftp.mysql.com/pub/mysql/}) - -@item -@image{Flags/bulgaria} Bulgaria [online.bg/Sofia] @@ -WWW (@uref{http://mysql.online.bg/}) -FTP (@uref{ftp://mysql.online.bg/}) - -@item -@image{Flags/czech-republic} Czech Republic [Masaryk University in Brno] @@ -WWW (@uref{http://mysql.linux.cz/}) -FTP (@uref{ftp://ftp.fi.muni.cz/pub/mysql/}) - -@item -@image{Flags/czech-republic} Czech Republic [www.gin.cz] @@ -WWW (@uref{http://mysql.gin.cz/}) -FTP (@uref{ftp://ftp.gin.cz/pub/MIRRORS/www.mysql.com/}) - -@item -@image{Flags/czech-republic} Czech Republic [www.sopik.cz] @@ -WWW (@uref{http://www.mysql.cz/}) - -@item -@image{Flags/denmark} Denmark [Borsen] @@ -WWW (@uref{http://mysql.borsen.dk/}) - -@item -@image{Flags/denmark} Denmark [Cybercity Internet] @@ -WWW (@uref{http://mysql.mirrors.cybercity.dk/}) - -@item -@image{Flags/denmark} Denmark [SunSITE] @@ -WWW (@uref{http://mirrors.sunsite.dk/mysql/}) -FTP (@uref{ftp://sunsite.dk/mirrors/mysql/}) - -@item -@image{Flags/estonia} Estonia [OK Interactive] @@ -WWW (@uref{http://mysql.mirror.ok.ee/}) - -@item -@image{Flags/finland} Finland [KPNQwest] @@ -WWW (@uref{http://mysql.kpnqwest.fi/}) - -@item -@image{Flags/finland} Finland [Mediatraffic] @@ -WWW (@uref{http://mysql.mediatraffic.fi/}) - -@item -@image{Flags/finland} Finland [tonnikala.net] @@ -WWW (@uref{http://mysql.tonnikala.org/}) - -@item -@image{Flags/france} France [free.fr] @@ -WWW (@uref{http://mysql-mirror.free.fr/}) -FTP (@uref{ftp://ftp.free.fr/pub/MySQL/}) - -@item -@image{Flags/france} France [mir2.ovh.net/] @@ -WWW (@uref{http://mir2.ovh.net/ftp.mysql.com/}) -FTP (@uref{ftp://mir1.ovh.net/ftp.mysql.com/}) - -@item -@image{Flags/france} France [Netsample] @@ -WWW (@uref{http://www.mysql.netsample.com/}) - -@item -@image{Flags/france} France [Universite Paris 10] @@ -WWW (@uref{http://ftp.u-paris10.fr/mysql.com}) -FTP (@uref{ftp://ftp.u-paris10.fr/mysql.com}) - -@item -@image{Flags/germany} Germany [GWDG] @@ -WWW (@uref{http://ftp.gwdg.de/pub/misc/mysql/}) -FTP (@uref{ftp://ftp.gwdg.de/pub/misc/mysql/}) - -@item -@image{Flags/germany} Germany [SunSITE Central Europe] @@ -WWW (@uref{http://sunsite.informatik.rwth-aachen.de/mysql/}) -FTP (@uref{ftp://sunsite.informatik.rwth-aachen.de/pub/mirror/www.mysql.com/}) - -@item -@image{Flags/germany} Germany [Tiscali] @@ -WWW (@uref{http://filepile.tiscali.de/mirror/mysql/}) -FTP (@uref{ftp://filepile.tiscali.de/mirror/mysql/}) - -@item -@image{Flags/germany} Germany [Wolfenbuettel] @@ -WWW (@uref{http://www.fh-wolfenbuettel.de/ftp/pub/database/mysql/}) -FTP (@uref{ftp://ftp.fh-wolfenbuettel.de/pub/database/mysql/}) - -@item -@image{Flags/greece} Greece [NTUA, Athens] @@ -WWW (@uref{http://www.ntua.gr/mysql/}) -FTP (@uref{ftp://ftp.ntua.gr/pub/databases/mysql/}) - -@item -@image{Flags/hungary} Hungary [stop.hu] @@ -WWW (@uref{http://mysql.mirror.stop.hu/}) - -@item -@image{Flags/hungary} Hungary [TiszaneT] @@ -WWW (@uref{http://mysql.tiszanet.hu/}) -FTP (@uref{ftp://mysql.tiszanet.hu/pub/mirrors/mysql/}) - -@item -@image{Flags/hungary} Hungary [Xenia] @@ -WWW (@uref{http://mysql.sote.hu/}) -FTP (@uref{ftp://xenia.sote.hu/pub/mirrors/www.mysql.com/}) - -@item -@image{Flags/iceland} Iceland [Tvíund] @@ -WWW (@uref{http://mysql.tviund.is/}) - -@item -@image{Flags/ireland} Ireland [Esat Net] @@ -WWW (@uref{http://ftp.esat.net/mirrors/download.sourceforge.net/pub/mirrors/mysql/}) -FTP (@uref{ftp://ftp.esat.net/mirrors/download.sourceforge.net/pub/mirrors/mysql/}) - -@item -@image{Flags/ireland} Ireland [MD NMTB Media] @@ -WWW (@uref{http://mirrors.nmtbmedia.com/mysql/}) - -@item -@image{Flags/israel} Israel [fresh.co.il] @@ -WWW (@uref{http://mysql.fresh.co.il/}) - -@item -@image{Flags/italy} Italy [feelinglinux.com] @@ -WWW (@uref{http://mysql.feelinglinux.com/}) - -@item -@image{Flags/italy} Italy [Teta Srl] @@ -WWW (@uref{http://www.teta.it/mysql/}) - -@item -@image{Flags/italy} Italy [tzone.it] @@ -WWW (@uref{http://mysql.tzone.it/}) - -@item -@image{Flags/latvia} Latvia [linux.lv] @@ -FTP (@uref{ftp://ftp.linux.lv/pub/software/mysql/}) - -@item -@image{Flags/netherlands} Netherlands [OMS-Net] @@ -WWW (@uref{http://mysql.oms-net.nl/}) - -@item -@image{Flags/netherlands} Netherlands [ProServe] @@ -WWW (@uref{http://mysql.proserve.nl/}) - -@item -@image{Flags/netherlands} Netherlands [WideXS BV] @@ -WWW (@uref{http://mysql.mirror.widexs.nl/}) -FTP (@uref{ftp://mirror.widexs.nl/pub/mysql/}) - -@item -@image{Flags/norway} Norway [Brainpeddlers AS] @@ -WWW (@uref{http://mysql.brainpeddlers.com/}) - -@item -@image{Flags/poland} Poland [ncservice.com/Gdansk] @@ -WWW (@uref{http://mysql.service.net.pl/}) - -@item -@image{Flags/poland} Poland [SunSITE] @@ -WWW (@uref{http://sunsite.icm.edu.pl/mysql/}) -FTP (@uref{ftp://sunsite.icm.edu.pl/pub/unix/mysql/}) - -@item -@image{Flags/portugal} Portugal [Instituto Supertior Técnico] @@ -WWW (@uref{http://darkstar.ist.utl.pt/mysql/}) -FTP (@uref{ftp://darkstar.ist.utl.pt/pub/mysql/}) - -@item -@image{Flags/portugal} Portugal [Netvisão] @@ -WWW (@uref{http://mysql.netvisao.pt/}) -FTP (@uref{ftp://mirrors2.netvisao.pt/pub/mysql/}) - -@item -@image{Flags/portugal} Portugal [VIZZAVI] @@ -WWW (@uref{http://ftp.vizzavi.pt/pub/mysql/}) -FTP (@uref{ftp://ftp.vizzavi.pt/pub/mysql/}) - -@item -@image{Flags/romania} Romania [roedu.net/Bucharest] @@ -FTP (@uref{ftp://ftp.roedu.net/pub/mirrors/ftp.mysql.com/}) - -@item -@image{Flags/russia} Russia [DirectNet] @@ -WWW (@uref{http://mysql.directnet.ru/}) -FTP (@uref{ftp://ftp.dn.ru/pub/MySQL/}) - -@item -@image{Flags/russia} Russia [Scientific Center/Chernogolovka] @@ -FTP (@uref{ftp://ftp.chg.ru/pub/databases/mysql/}) - -@item -@image{Flags/slovenia} Slovenia [ARNES] @@ -WWW (@uref{http://ftp.arnes.si/mysql/}) -FTP (@uref{ftp://ftp.arnes.si/packages/mysql/}) - -@item -@image{Flags/sweden} Sweden [Sunet] @@ -WWW (@uref{http://ftp.sunet.se/pub/unix/databases/relational/mysql/}) -FTP (@uref{ftp://ftp.sunet.se/pub/unix/databases/relational/mysql/}) - -@item -@image{Flags/switzerland} Switzerland [SunSITE] @@ -WWW (@uref{http://sunsite.cnlab-switch.ch/ftp/mirror/mysql/}) -FTP (@uref{ftp://sunsite.cnlab-switch.ch/mirror/mysql/}) - -@item -@image{Flags/turkey} Turkey [proGEN] @@ -WWW (@uref{http://mysql.progen.com.tr/}) - -@item -@image{Flags/turkey} Turkey [Turkish National Academic Network & Information Center] @@ -WWW (@uref{http://mysql.ulak.net.tr/}) - -@item -@image{Flags/great-britain} UK [PLiG/UK] @@ -WWW (@uref{http://ftp.plig.org/pub/mysql/}) -FTP (@uref{ftp://ftp.plig.org/pub/mysql/}) - -@item -@image{Flags/ukraine} Ukraine [ISP Alkar Teleport/Dnepropetrovsk] @@ -WWW (@uref{http://mysql.dp.ua/}) -FTP (@uref{ftp://ftp.tlk-l.net/pub/mirrors/mysql.com/}) - -@item -@image{Flags/ukraine} Ukraine [PACO] @@ -WWW (@uref{http://mysql.paco.net.ua/}) -FTP (@uref{ftp://mysql.paco.net.ua/}) - -@item -@image{Flags/yugoslavia} Yugoslavia [Open Source Network of Yugoslavia] @@ -WWW (@uref{http://mysql.boa.org.yu/}) -FTP (@uref{ftp://ftp.linux.org.yu/pub/MySQL/}) - -@end itemize - -@strong{North America:} - -@itemize @bullet - -@item -@image{Flags/canada} Canada [Tryc] @@ -WWW (@uref{http://web.tryc.on.ca/mysql/}) - -@item -@image{Flags/mexico} Mexico [UAM] @@ -WWW (@uref{http://mysql.azc.uam.mx/}) -FTP (@uref{ftp://mysql.azc.uam.mx/mirrors/mysql/}) - -@item -@image{Flags/mexico} Mexico [UNAM] @@ -WWW (@uref{http://mysql.unam.mx/}) -FTP (@uref{ftp://mysql.unam.mx/pub/mysql/}) - -@item -@image{Flags/usa} USA [adgrafix.com / Boston, MA] @@ -WWW (@uref{http://mysql.adgrafix.com/}) - -@item -@image{Flags/usa} USA [Argonne National Laboratory / Chicago, IL] @@ -FTP (@uref{ftp://mirror.mcs.anl.gov/pub/mysql/}) - -@item -@image{Flags/usa} USA [Hurricane Electric / San Jose, CA] @@ -WWW (@uref{http://mysql.he.net/}) - -@item -@image{Flags/usa} USA [netNumina / Cambridge, MA] @@ -WWW (@uref{http://mysql.mirrors.netnumina.com/}) - -@item -@image{Flags/usa} USA [NIXC / Vienna, VA] @@ -WWW (@uref{http://mysql.nixc.net/}) -FTP (@uref{ftp://mysql.nixc.net/pub/mysql/}) - -@item -@image{Flags/usa} USA [Oregon State University / Corvallis, OR] @@ -WWW (@uref{http://mysql.orst.edu/}) -FTP (@uref{ftp://ftp.orst.edu/pub/mysql/}) - -@item -@image{Flags/usa} USA [University of Wisconsin / Wisconsin] @@ -WWW (@uref{http://mirror.sit.wisc.edu/mysql/}) -FTP (@uref{ftp://mirror.sit.wisc.edu/mirrors/mysql/}) - -@item -@image{Flags/usa} USA [UUNet] @@ -WWW (@uref{http://mysql.secsup.org/}) -FTP (@uref{ftp://mysql.secsup.org/pub/software/mysql/}) - -@end itemize - -@strong{South America:} - -@itemize @bullet - -@item -@image{Flags/argentina} Argentina [bannerlandia.com] @@ -WWW (@uref{http://mysql.bannerlandia.com.ar/}) -FTP (@uref{ftp://mysql.bannerlandia.com.ar/mirrors/mysql/}) - -@item -@image{Flags/chile} Chile [PSINet] @@ -WWW (@uref{http://mysql.psinet.cl/}) -FTP (@uref{ftp://ftp.psinet.cl/pub/database/mysql/}) - -@item -@image{Flags/chile} Chile [Tecnoera] @@ -WWW (@uref{http://mysql.tecnoera.com/}) - -@item -@image{Flags/chile} Chile [Vision] @@ -WWW (@uref{http://mysql.vision.cl/}) - -@item -@image{Flags/costa-rica} Costa Rica [Ogmios Communications] @@ -WWW (@uref{http://mysql.ogmios.co.cr/}) -FTP (@uref{ftp://mysql.ogmios.co.cr/pub/mysql/}) - -@end itemize - -@strong{Asia:} - -@itemize @bullet - -@item -@image{Flags/china} China [HKLPG/Hong Kong] @@ -WWW (@uref{http://mysql.hklpg.org/}) - -@item -@image{Flags/china} China [linuxforum.net] @@ -FTP (@uref{http://www2.linuxforum.net/mirror/mysql/}) - -@item -@image{Flags/china} China [shellhung.org/Hong Kong] @@ -WWW (@uref{http://mysql.shellhung.org/}) -FTP (@uref{ftp://ftp.shellhung.org/pub/Mirror/mysql/}) - -@item -@image{Flags/indonesia} Indonesia [CBN] @@ -WWW (@uref{http://mysql.cbn.net.id/}) - -@item -@image{Flags/indonesia} Indonesia [incaf.net] @@ -WWW (@uref{http://mysql.incaf.net/}) -FTP (@uref{ftp://mysql.incaf.net/}) - -@item -@image{Flags/indonesia} Indonesia [M-Web] @@ -WWW (@uref{http://mysql.mweb.net.id/}) -FTP (@uref{ftp://mysql.mweb.net.id/pub/database/mysql/}) - -@item -@image{Flags/indonesia} Indonesia [web.id] @@ -WWW (@uref{http://mysql.itb.web.id/}) -FTP (@uref{ftp://mysql.itb.web.id/pub/MySQL/}) - -@item -@image{Flags/japan} Japan [Soft Agency] @@ -WWW (@uref{http://www.softagency.co.jp/MySQL/}) - -@item -@image{Flags/japan} Japan [u-aizu.ac.jp/Aizu] @@ -FTP (@uref{ftp://ftp.u-aizu.ac.jp/ftp/pub/dbms/mysql/mysql.com/}) - -@item -@image{Flags/philippines} Philippines [Ateneo de Zamboanga University] @@ -WWW (@uref{http://mysql.adzu.edu.ph/}) - -@item -@image{Flags/singapore} Singapore [HJC] @@ -WWW (@uref{http://mysql.hjc.edu.sg/}) -FTP (@uref{ftp://ftp.hjc.edu.sg/mysql/}) - -@item -@image{Flags/south-korea} South Korea [HolyNet] @@ -WWW (@uref{http://mysql.holywar.net/}) - -@item -@image{Flags/south-korea} South Korea [Webiiz] @@ -WWW (@uref{http://mysql.webiiz.com/}) - -@item -@image{Flags/taiwan} Taiwan [I-SHOU University] @@ -WWW (@uref{http://mysql.isu.edu.tw/}) - -@item -@image{Flags/taiwan} Taiwan [nctu.edu/HsinChu] @@ -WWW (@uref{http://mysql.nctu.edu.tw/}) - -@item -@image{Flags/taiwan} Taiwan [TTN] @@ -WWW (@uref{http://mysql.ttn.net/}) - -@end itemize - -@strong{Australia:} - -@itemize @bullet - -@item -@image{Flags/australia} Australia [InterActive Consulting] @@ -WWW (@uref{http://mysql.oranged.to}) - -@item -@image{Flags/australia} Australia [planetmirror.com] @@ -WWW (@uref{http://mysql.planetmirror.com/}) -FTP (@uref{ftp://planetmirror.com/pub/mysql/}) - -@item -@image{Flags/new-zealand} New Zealand [Cubalan] @@ -WWW (@uref{http://mysql.soa.co.nz/}) - -@end itemize - -@strong{Africa:} - -@itemize @bullet - -@item -@image{Flags/south-africa} South African Republic [The Internet Solution/Johannesburg] @@ -FTP (@uref{ftp://ftp.is.co.za/linux/mysql/}) - -@end itemize - diff --git a/Docs/mysql.info b/Docs/mysql.info new file mode 100644 index 00000000000..5846d7aadf6 --- /dev/null +++ b/Docs/mysql.info @@ -0,0 +1,27 @@ +This is mysql.info, produced by makeinfo version 4.8 from manual.texi. + +START-INFO-DIR-ENTRY +* mysql: (mysql). MySQL documentation. +END-INFO-DIR-ENTRY + + +File: mysql.info, Node: Top, Next: (dir), Prev: (dir), Up: (dir) + +This is an empty placeholder file for the MySQL manual. + +The MySQL manual is now maintained in a separate BitKeeper source tree! +Please see `http://www.mysql.com/doc/en/Installing_source_tree.html' +for more info on how to work with BitKeeper. + +This file will be replaced with the current `mysql.info' when building +the official source distribution. + +You can find a specific manual for any older version of MySQL in the +binary or source distribution for that version. + + + +Tag Table: +Node: Top166 + +End Tag Table diff --git a/Docs/mysqld_error.txt b/Docs/mysqld_error.txt deleted file mode 100644 index 7f5560a5914..00000000000 --- a/Docs/mysqld_error.txt +++ /dev/null @@ -1,599 +0,0 @@ -/* Copyright Abandoned 1997 TCX DataKonsult AB & Monty Program KB & Detron HB - This file is public domain and comes with NO WARRANTY of any kind */ - -character-set=latin1 - -#define ER_HASHCHK 1000 -"hashchk", -#define ER_NISAMCHK 1001 -"isamchk", -#define ER_NO 1002 -"NO", -#define ER_YES 1003 -"YES", -#define ER_CANT_CREATE_FILE 1004 -"Can't create file '%-.64s' (errno: %d)", -#define ER_CANT_CREATE_TABLE 1005 -"Can't create table '%-.64s' (errno: %d)", -#define ER_CANT_CREATE_DB 1006 -"Can't create database '%-.64s' (errno: %d)", -#define ER_DB_CREATE_EXISTS 1007 -"Can't create database '%-.64s'; database exists", -#define ER_DB_DROP_EXISTS 1008 -"Can't drop database '%-.64s'; database doesn't exist", -#define ER_DB_DROP_DELETE 1009 -"Error dropping database (can't delete '%-.64s', errno: %d)", -#define ER_DB_DROP_RMDIR 1010 -"Error dropping database (can't rmdir '%-.64s', errno: %d)", -#define ER_CANT_DELETE_FILE 1011 -"Error on delete of '%-.64s' (errno: %d)", -#define ER_CANT_FIND_SYSTEM_REC 1012 -"Can't read record in system table", -#define ER_CANT_GET_STAT 1013 -"Can't get status of '%-.64s' (errno: %d)", -#define ER_CANT_GET_WD 1014 -"Can't get working directory (errno: %d)", -#define ER_CANT_LOCK 1015 -"Can't lock file (errno: %d)", -#define ER_CANT_OPEN_FILE 1016 -"Can't open file: '%-.64s' (errno: %d)", -#define ER_FILE_NOT_FOUND 1017 -"Can't find file: '%-.64s' (errno: %d)", -#define ER_CANT_READ_DIR 1018 -"Can't read dir of '%-.64s' (errno: %d)", -#define ER_CANT_SET_WD 1019 -"Can't change dir to '%-.64s' (errno: %d)", -#define ER_CHECKREAD 1020 -"Record has changed since last read in table '%-.64s'", -#define ER_DISK_FULL 1021 -"Disk full (%s). Waiting for someone to free some space...", -#define ER_DUP_KEY 1022 -"Can't write, duplicate key in table '%-.64s'", -#define ER_ERROR_ON_CLOSE 1023 -"Error on close of '%-.64s' (errno: %d)", -#define ER_ERROR_ON_READ 1024 -"Error reading file '%-.64s' (errno: %d)", -#define ER_ERROR_ON_RENAME 1025 -"Error on rename of '%-.64s' to '%-.64s' (errno: %d)", -#define ER_ERROR_ON_WRITE 1026 -"Error writing file '%-.64s' (errno: %d)", -#define ER_FILE_USED 1027 -"'%-.64s' is locked against change", -#define ER_FILSORT_ABORT 1028 -"Sort aborted", -#define ER_FORM_NOT_FOUND 1029 -"View '%-.64s' doesn't exist for '%-.64s'", -#define ER_GET_ERRNO 1030 -"Got error %d from storage engine", -#define ER_ILLEGAL_HA 1031 -"Table storage engine for '%-.64s' doesn't have this option", -#define ER_KEY_NOT_FOUND 1032 -"Can't find record in '%-.64s'", -#define ER_NOT_FORM_FILE 1033 -"Incorrect information in file: '%-.64s'", -#define ER_NOT_KEYFILE 1034 -"Incorrect key file for table: '%-.64s'; try to repair it", -#define ER_OLD_KEYFILE 1035 -"Old key file for table '%-.64s'; repair it!", -#define ER_OPEN_AS_READONLY 1036 -"Table '%-.64s' is read only", -#define ER_OUTOFMEMORY 1037 -"Out of memory. Restart daemon and try again (needed %d bytes)", -#define ER_OUT_OF_SORTMEMORY 1038 -"Out of sort memory. Increase daemon sort buffer size", -#define ER_UNEXPECTED_EOF 1039 -"Unexpected eof found when reading file '%-.64s' (errno: %d)", -#define ER_CON_COUNT_ERROR 1040 -"Too many connections", -#define ER_OUT_OF_RESOURCES 1041 -"Out of memory; Check if mysqld or some other process uses all available memory. If not you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space", -#define ER_BAD_HOST_ERROR 1042 -"Can't get hostname for your address", -#define ER_HANDSHAKE_ERROR 1043 -"Bad handshake", -#define ER_DBACCESS_DENIED_ERROR 1044 -"Access denied for user: '%-.32s'@'%-.64s' to database '%-.64s'", -#define ER_ACCESS_DENIED_ERROR 1045 -"Access denied for user: '%-.32s'@'%-.64s' (Using password: %s)", -#define ER_NO_DB_ERROR 1046 -"No Database Selected", -#define ER_UNKNOWN_COM_ERROR 1047 -"Unknown command", -#define ER_BAD_NULL_ERROR 1048 -"Column '%-.64s' cannot be null", -#define ER_BAD_DB_ERROR 1049 -"Unknown database '%-.64s'", -#define ER_TABLE_EXISTS_ERROR 1050 -"Table '%-.64s' already exists", -#define ER_BAD_TABLE_ERROR 1051 -"Unknown table '%-.64s'", -#define ER_NON_UNIQ_ERROR 1052 -"Column: '%-.64s' in %-.64s is ambiguous", -#define ER_SERVER_SHUTDOWN 1053 -"Server shutdown in progress", -#define ER_BAD_FIELD_ERROR 1054 -"Unknown column '%-.64s' in '%-.64s'", -#define ER_WRONG_FIELD_WITH_GROUP 1055 -"'%-.64s' isn't in GROUP BY", -#define ER_WRONG_GROUP_FIELD 1056 -"Can't group on '%-.64s'", -#define ER_WRONG_SUM_SELECT 1057 -"Statement has sum functions and columns in same statement", -#define ER_WRONG_VALUE_COUNT 1058 -"Column count doesn't match value count", -#define ER_TOO_LONG_IDENT 1059 -"Identifier name '%-.100s' is too long", -#define ER_DUP_FIELDNAME 1060 -"Duplicate column name '%-.64s'", -#define ER_DUP_KEYNAME 1061 -"Duplicate key name '%-.64s'", -#define ER_DUP_ENTRY 1062 -"Duplicate entry '%-.64s' for key %d", -#define ER_WRONG_FIELD_SPEC 1063 -"Incorrect column specifier for column '%-.64s'", -#define ER_PARSE_ERROR 1064 -"%s near '%-.80s' at line %d", -#define ER_EMPTY_QUERY 1065 -"Query was empty", -#define ER_NONUNIQ_TABLE 1066 -"Not unique table/alias: '%-.64s'", -#define ER_INVALID_DEFAULT 1067 -"Invalid default value for '%-.64s'", -#define ER_MULTIPLE_PRI_KEY 1068 -"Multiple primary key defined", -#define ER_TOO_MANY_KEYS 1069 -"Too many keys specified; max %d keys allowed", -#define ER_TOO_MANY_KEY_PARTS 1070 -"Too many key parts specified. Max %d parts allowed", -#define ER_TOO_LONG_KEY 1071 -"Specified key was too long; max key length is %d bytes", -#define ER_KEY_COLUMN_DOES_NOT_EXITS 1072 -"Key column '%-.64s' doesn't exist in table", -#define ER_BLOB_USED_AS_KEY 1073 -"BLOB column '%-.64s' can't be used in key specification with the used table type", -#define ER_TOO_BIG_FIELDLENGTH 1074 -"Too big column length for column '%-.64s' (max = %d). Use BLOB instead", -#define ER_WRONG_AUTO_KEY 1075 -"Incorrect table definition; There can only be one auto column and it must be defined as a key", -#define ER_READY 1076 -"%s: ready for connections.\nVersion: '%s' socket: '%s' port: %d\n", -#define ER_NORMAL_SHUTDOWN 1077 -"%s: Normal shutdown\n", -#define ER_GOT_SIGNAL 1078 -"%s: Got signal %d. Aborting!\n", -#define ER_SHUTDOWN_COMPLETE 1079 -"%s: Shutdown Complete\n", -#define ER_FORCING_CLOSE 1080 -"%s: Forcing close of thread %ld user: '%-.32s'\n", -#define ER_IPSOCK_ERROR 1081 -"Can't create IP socket", -#define ER_NO_SUCH_INDEX 1082 -"Table '%-.64s' has no index like the one used in CREATE INDEX. Recreate the table", -#define ER_WRONG_FIELD_TERMINATORS 1083 -"Field separator argument is not what is expected. Check the manual", -#define ER_BLOBS_AND_NO_TERMINATED 1084 -"You can't use fixed rowlength with BLOBs. Please use 'fields terminated by'", -#define ER_TEXTFILE_NOT_READABLE 1085 -"The file '%-.64s' must be in the database directory or be readable by all", -#define ER_FILE_EXISTS_ERROR 1086 -"File '%-.80s' already exists", -#define ER_LOAD_INFO 1087 -"Records: %ld Deleted: %ld Skipped: %ld Warnings: %ld", -#define ER_ALTER_INFO 1088 -"Records: %ld Duplicates: %ld", -#define ER_WRONG_SUB_KEY 1089 -"Incorrect sub part key. The used key part isn't a string, the used length is longer than the key part or the storage engine doesn't support unique sub keys", -#define ER_CANT_REMOVE_ALL_FIELDS 1090 -"You can't delete all columns with ALTER TABLE. Use DROP TABLE instead", -#define ER_CANT_DROP_FIELD_OR_KEY 1091 -"Can't DROP '%-.64s'. Check that column/key exists", -#define ER_INSERT_INFO 1092 -"Records: %ld Duplicates: %ld Warnings: %ld", -#define ER_UPDATE_TABLE_USED 1093 -"You can't specify target table '%-.64s' for update in FROM clause", -#define ER_NO_SUCH_THREAD 1094 -"Unknown thread id: %lu", -#define ER_KILL_DENIED_ERROR 1095 -"You are not owner of thread %lu", -#define ER_NO_TABLES_USED 1096 -"No tables used", -#define ER_TOO_BIG_SET 1097 -"Too many strings for column %-.64s and SET", -#define ER_NO_UNIQUE_LOGFILE 1098 -"Can't generate a unique log-filename %-.64s.(1-999)\n", -#define ER_TABLE_NOT_LOCKED_FOR_WRITE 1099 -"Table '%-.64s' was locked with a READ lock and can't be updated", -#define ER_TABLE_NOT_LOCKED 1100 -"Table '%-.64s' was not locked with LOCK TABLES", -#define ER_BLOB_CANT_HAVE_DEFAULT 1101 -"BLOB/TEXT column '%-.64s' can't have a default value", -#define ER_WRONG_DB_NAME 1102 -"Incorrect database name '%-.100s'", -#define ER_WRONG_TABLE_NAME 1103 -"Incorrect table name '%-.100s'", -#define ER_TOO_BIG_SELECT 1104 -"The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok", -#define ER_UNKNOWN_ERROR 1105 -"Unknown error", -#define ER_UNKNOWN_PROCEDURE 1106 -"Unknown procedure '%-.64s'", -#define ER_WRONG_PARAMCOUNT_TO_PROCEDURE 1107 -"Incorrect parameter count to procedure '%-.64s'", -#define ER_WRONG_PARAMETERS_TO_PROCEDURE 1108 -"Incorrect parameters to procedure '%-.64s'", -#define ER_UNKNOWN_TABLE 1109 -"Unknown table '%-.64s' in %-.32s", -#define ER_FIELD_SPECIFIED_TWICE 1110 -"Column '%-.64s' specified twice", -#define ER_INVALID_GROUP_FUNC_USE 1111 -"Invalid use of group function", -#define ER_UNSUPPORTED_EXTENSION 1112 -"Table '%-.64s' uses an extension that doesn't exist in this MySQL version", -#define ER_TABLE_MUST_HAVE_COLUMNS 1113 -"A table must have at least 1 column", -#define ER_RECORD_FILE_FULL 1114 -"The table '%-.64s' is full", -#define ER_UNKNOWN_CHARACTER_SET 1115 -"Unknown character set: '%-.64s'", -#define ER_TOO_MANY_TABLES 1116 -"Too many tables. MySQL can only use %d tables in a join", -#define ER_TOO_MANY_FIELDS 1117 -"Too many columns", -#define ER_TOO_BIG_ROWSIZE 1118 -"Too big row size. The maximum row size for the used table type, not counting BLOBs, is %ld. You have to change some fields to TEXT or BLOBs", -#define ER_STACK_OVERRUN 1119 -"Thread stack overrun: Used: %ld of a %ld stack. Use 'mysqld -O thread_stack=#' to specify a bigger stack if needed", -#define ER_WRONG_OUTER_JOIN 1120 -"Cross dependency found in OUTER JOIN. Examine your ON conditions", -#define ER_NULL_COLUMN_IN_INDEX 1121 -"Column '%-.64s' is used with UNIQUE or INDEX but is not defined as NOT NULL", -#define ER_CANT_FIND_UDF 1122 -"Can't load function '%-.64s'", -#define ER_CANT_INITIALIZE_UDF 1123 -"Can't initialize function '%-.64s'; %-.80s", -#define ER_UDF_NO_PATHS 1124 -"No paths allowed for shared library", -#define ER_UDF_EXISTS 1125 -"Function '%-.64s' already exist", -#define ER_CANT_OPEN_LIBRARY 1126 -"Can't open shared library '%-.64s' (errno: %d %-.64s)", -#define ER_CANT_FIND_DL_ENTRY 1127 -"Can't find function '%-.64s' in library'", -#define ER_FUNCTION_NOT_DEFINED 1128 -"Function '%-.64s' is not defined", -#define ER_HOST_IS_BLOCKED 1129 -"Host '%-.64s' is blocked because of many connection errors. Unblock with 'mysqladmin flush-hosts'", -#define ER_HOST_NOT_PRIVILEGED 1130 -"Host '%-.64s' is not allowed to connect to this MySQL server", -#define ER_PASSWORD_ANONYMOUS_USER 1131 -"You are using MySQL as an anonymous users and anonymous users are not allowed to change passwords", -#define ER_PASSWORD_NOT_ALLOWED 1132 -"You must have privileges to update tables in the mysql database to be able to change passwords for others", -#define ER_PASSWORD_NO_MATCH 1133 -"Can't find any matching row in the user table", -#define ER_UPDATE_INFO 1134 -"Rows matched: %ld Changed: %ld Warnings: %ld", -#define ER_CANT_CREATE_THREAD 1135 -"Can't create a new thread (errno %d). If you are not out of available memory, you can consult the manual for a possible OS-dependent bug", -#define ER_WRONG_VALUE_COUNT_ON_ROW 1136 -"Column count doesn't match value count at row %ld", -#define ER_CANT_REOPEN_TABLE 1137 -"Can't reopen table: '%-.64s'", -#define ER_INVALID_USE_OF_NULL 1138 -"Invalid use of NULL value", -#define ER_REGEXP_ERROR 1139 -"Got error '%-.64s' from regexp", -#define ER_MIX_OF_GROUP_FUNC_AND_FIELDS 1140 -"Mixing of GROUP columns (MIN(),MAX(),COUNT()...) with no GROUP columns is illegal if there is no GROUP BY clause", -#define ER_NONEXISTING_GRANT 1141 -"There is no such grant defined for user '%-.32s' on host '%-.64s'", -#define ER_TABLEACCESS_DENIED_ERROR 1142 -"%-.16s command denied to user: '%-.32s'@'%-.64s' for table '%-.64s'", -#define ER_COLUMNACCESS_DENIED_ERROR 1143 -"%-.16s command denied to user: '%-.32s'@'%-.64s' for column '%-.64s' in table '%-.64s'", -#define ER_ILLEGAL_GRANT_FOR_TABLE 1144 -"Illegal GRANT/REVOKE command. Please consult the manual which privileges can be used", -#define ER_GRANT_WRONG_HOST_OR_USER 1145 -"The host or user argument to GRANT is too long", -#define ER_NO_SUCH_TABLE 1146 -"Table '%-.64s.%-.64s' doesn't exist", -#define ER_NONEXISTING_TABLE_GRANT 1147 -"There is no such grant defined for user '%-.32s' on host '%-.64s' on table '%-.64s'", -#define ER_NOT_ALLOWED_COMMAND 1148 -"The used command is not allowed with this MySQL version", -#define ER_SYNTAX_ERROR 1149 -"You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use", -#define ER_DELAYED_CANT_CHANGE_LOCK 1150 -"Delayed insert thread couldn't get requested lock for table %-.64s", -#define ER_TOO_MANY_DELAYED_THREADS 1151 -"Too many delayed threads in use", -#define ER_ABORTING_CONNECTION 1152 -"Aborted connection %ld to db: '%-.64s' user: '%-.32s' (%-.64s)", -#define ER_NET_PACKET_TOO_LARGE 1153 -"Got a packet bigger than 'max_allowed_packet'", -#define ER_NET_READ_ERROR_FROM_PIPE 1154 -"Got a read error from the connection pipe", -#define ER_NET_FCNTL_ERROR 1155 -"Got an error from fcntl()", -#define ER_NET_PACKETS_OUT_OF_ORDER 1156 -"Got packets out of order", -#define ER_NET_UNCOMPRESS_ERROR 1157 -"Couldn't uncompress communication packet", -#define ER_NET_READ_ERROR 1158 -"Got an error reading communication packets", -#define ER_NET_READ_INTERRUPTED 1159 -"Got timeout reading communication packets", -#define ER_NET_ERROR_ON_WRITE 1160 -"Got an error writing communication packets", -#define ER_NET_WRITE_INTERRUPTED 1161 -"Got timeout writing communication packets", -#define ER_TOO_LONG_STRING 1162 -"Result string is longer than max_allowed_packet", -#define ER_TABLE_CANT_HANDLE_BLOB 1163 -"The used table type doesn't support BLOB/TEXT columns", -#define ER_TABLE_CANT_HANDLE_AUTO_INCREMENT 1164 -"The used table type doesn't support AUTO_INCREMENT columns", -#define ER_DELAYED_INSERT_TABLE_LOCKED 1165 -"INSERT DELAYED can't be used with table '%-.64s' because it is locked with LOCK TABLES", -#define ER_WRONG_COLUMN_NAME 1166 -"Incorrect column name '%-.100s'", -#define ER_WRONG_KEY_COLUMN 1167 -"The used storage engine can't index column '%-.64s'", -#define ER_WRONG_MRG_TABLE 1168 -"All tables in the MERGE table are not identically defined", -#define ER_DUP_UNIQUE 1169 -"Can't write, because of unique constraint, to table '%-.64s'", -#define ER_BLOB_KEY_WITHOUT_LENGTH 1170 -"BLOB/TEXT column '%-.64s' used in key specification without a key length", -#define ER_PRIMARY_CANT_HAVE_NULL 1171 -"All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead", -#define ER_TOO_MANY_ROWS 1172 -"Result consisted of more than one row", -#define ER_REQUIRES_PRIMARY_KEY 1173 -"This table type requires a primary key", -#define ER_NO_RAID_COMPILED 1174 -"This version of MySQL is not compiled with RAID support", -#define ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE 1175 -"You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column", -#define ER_KEY_DOES_NOT_EXITS 1176 -"Key '%-.64s' doesn't exist in table '%-.64s'", -#define ER_CHECK_NO_SUCH_TABLE 1177 -"Can't open table", -#define ER_CHECK_NOT_IMPLEMENTED 1178 -"The storage engine for the table doesn't support %s", -#define ER_CANT_DO_THIS_DURING_AN_TRANSACTION 1179 -"You are not allowed to execute this command in a transaction", -#define ER_ERROR_DURING_COMMIT 1180 -"Got error %d during COMMIT", -#define ER_ERROR_DURING_ROLLBACK 1181 -"Got error %d during ROLLBACK", -#define ER_ERROR_DURING_FLUSH_LOGS 1182 -"Got error %d during FLUSH_LOGS", -#define ER_ERROR_DURING_CHECKPOINT 1183 -"Got error %d during CHECKPOINT", -#define ER_NEW_ABORTING_CONNECTION 1184 -"Aborted connection %ld to db: '%-.64s' user: '%-.32s' host: `%-.64s' (%-.64s)", -#define ER_DUMP_NOT_IMPLEMENTED 1185 -"The storage engine for the table does not support binary table dump", -#define ER_FLUSH_MASTER_BINLOG_CLOSED 1186 -"Binlog closed, cannot RESET MASTER", -#define ER_INDEX_REBUILD 1187 -"Failed rebuilding the index of dumped table '%-.64s'", -#define ER_MASTER 1188 -"Error from master: '%-.64s'", -#define ER_MASTER_NET_READ 1189 -"Net error reading from master", -#define ER_MASTER_NET_WRITE 1190 -"Net error writing to master", -#define ER_FT_MATCHING_KEY_NOT_FOUND 1191 -"Can't find FULLTEXT index matching the column list", -#define ER_LOCK_OR_ACTIVE_TRANSACTION 1192 -"Can't execute the given command because you have active locked tables or an active transaction", -#define ER_UNKNOWN_SYSTEM_VARIABLE 1193 -"Unknown system variable '%-.64s'", -#define ER_CRASHED_ON_USAGE 1194 -"Table '%-.64s' is marked as crashed and should be repaired", -#define ER_CRASHED_ON_REPAIR 1195 -"Table '%-.64s' is marked as crashed and last (automatic?) repair failed", -#define ER_WARNING_NOT_COMPLETE_ROLLBACK 1196 -"Some non-transactional changed tables couldn't be rolled back", -#define ER_TRANS_CACHE_FULL 1197 -"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again", -#define ER_SLAVE_MUST_STOP 1198 -"This operation cannot be performed with a running slave, run STOP SLAVE first", -#define ER_SLAVE_NOT_RUNNING 1199 -"This operation requires a running slave, configure slave and do START SLAVE", -#define ER_BAD_SLAVE 1200 -"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", -#define ER_MASTER_INFO 1201 -"Could not initialize master info structure, more error messages can be found in the MySQL error log", -#define ER_SLAVE_THREAD 1202 -"Could not create slave thread, check system resources", -#define ER_TOO_MANY_USER_CONNECTIONS 1203 -"User %-.64s has already more than 'max_user_connections' active connections", -#define ER_SET_CONSTANTS_ONLY 1204 -"You may only use constant expressions with SET", -#define ER_LOCK_WAIT_TIMEOUT 1205 -"Lock wait timeout exceeded; Try restarting transaction", -#define ER_LOCK_TABLE_FULL 1206 -"The total number of locks exceeds the lock table size", -#define ER_READ_ONLY_TRANSACTION 1207 -"Update locks cannot be acquired during a READ UNCOMMITTED transaction", -#define ER_DROP_DB_WITH_READ_LOCK 1208 -"DROP DATABASE not allowed while thread is holding global read lock", -#define ER_CREATE_DB_WITH_READ_LOCK 1209 -"CREATE DATABASE not allowed while thread is holding global read lock", -#define ER_WRONG_ARGUMENTS 1210 -"Wrong arguments to %s", -#define ER_NO_PERMISSION_TO_CREATE_USER 1211 -"'%-.32s'@'%-.64s' is not allowed to create new users", -#define ER_UNION_TABLES_IN_DIFFERENT_DIR 1212 -"Incorrect table definition; all MERGE tables must be in the same database", -#define ER_LOCK_DEADLOCK 1213 -"Deadlock found when trying to get lock; Try restarting transaction", -#define ER_TABLE_CANT_HANDLE_FT 1214 -"The used table type doesn't support FULLTEXT indexes", -#define ER_CANNOT_ADD_FOREIGN 1215 -"Cannot add foreign key constraint", -#define ER_NO_REFERENCED_ROW 1216 -"Cannot add or update a child row: a foreign key constraint fails", -#define ER_ROW_IS_REFERENCED 1217 -"Cannot delete or update a parent row: a foreign key constraint fails", -#define ER_CONNECT_TO_MASTER 1218 -"Error connecting to master: %-.128s", -#define ER_QUERY_ON_MASTER 1219 -"Error running query on master: %-.128s", -#define ER_ERROR_WHEN_EXECUTING_COMMAND 1220 -"Error when executing command %s: %-.128s", -#define ER_WRONG_USAGE 1221 -"Wrong usage of %s and %s", -#define ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT 1222 -"The used SELECT statements have a different number of columns", -#define ER_CANT_UPDATE_WITH_READLOCK 1223 -"Can't execute the query because you have a conflicting read lock", -#define ER_MIXING_NOT_ALLOWED 1224 -"Mixing of transactional and non-transactional tables is disabled", -#define ER_DUP_ARGUMENT 1225 -"Option '%s' used twice in statement", -#define ER_USER_LIMIT_REACHED 1226 -"User '%-.64s' has exceeded the '%s' resource (current value: %ld)", -#define ER_SPECIFIC_ACCESS_DENIED_ERROR 1227 -"Access denied. You need the %-.128s privilege for this operation", -#define ER_LOCAL_VARIABLE 1228 -"Variable '%-.64s' is a SESSION variable and can't be used with SET GLOBAL", -#define ER_GLOBAL_VARIABLE 1229 -"Variable '%-.64s' is a GLOBAL variable and should be set with SET GLOBAL", -#define ER_NO_DEFAULT 1230 -"Variable '%-.64s' doesn't have a default value", -#define ER_WRONG_VALUE_FOR_VAR 1231 -"Variable '%-.64s' can't be set to the value of '%-.64s'", -#define ER_WRONG_TYPE_FOR_VAR 1232 -"Wrong argument type to variable '%-.64s'", -#define ER_VAR_CANT_BE_READ 1233 -"Variable '%-.64s' can only be set, not read", -#define ER_CANT_USE_OPTION_HERE 1234 -"Wrong usage/placement of '%s'", -#define 1235 -"This version of MySQL doesn't yet support '%s'", -#define ER_MASTER_FATAL_ERROR_READING_BINLOG 1236 -"Got fatal error %d: '%-.128s' from master when reading data from binary log", -#define ER_SLAVE_IGNORED_TABLE 1237 -"Slave SQL thread ignored the query because of replicate-*-table rules", -#define ER_INCORRECT_GLOBAL_LOCAL_VAR 1238 -"Variable '%-.64s' is a %s variable", -#define ER_WRONG_FK_DEF 1239 -"Wrong foreign key definition for '%-.64s': %s", -#define ER_KEY_REF_DO_NOT_MATCH_TABLE_REF 1240 -"Key reference and table reference doesn't match", -#define ER_OPERAND_COLUMNS 1241 -"Operand should contain %d column(s)", -#define ER_SUBQUERY_NO_1_ROW 1242 -"Subquery returns more than 1 row", -#define ER_UNKNOWN_STMT_HANDLER 1243 -"Unknown prepared statement handler (%ld) given to %s", -#define ER_CORRUPT_HELP_DB 1244 -"Help database is corrupt or does not exist", -#define ER_CYCLIC_REFERENCE 1245 -"Cyclic reference on subqueries", -#define ER_AUTO_CONVERT 1246 -"Converting column '%s' from %s to %s", -#define ER_ILLEGAL_REFERENCE 1247 -"Reference '%-.64s' not supported (%s)", -#define ER_DERIVED_MUST_HAVE_ALIAS 1248 -"Every derived table must have it's own alias", -#define ER_SELECT_REDUCED 1249 -"Select %u was reduced during optimisation", -#define ER_TABLENAME_NOT_ALLOWED_HERE 1250 -"Table '%-.64s' from one of SELECT's can not be used in %-.32s", -#define ER_NOT_SUPPORTED_AUTH_MODE 1251 -"Client does not support authentication protocol requested by server; consider upgrading MySQL client", -#define ER_SPATIAL_CANT_HAVE_NULL 1252 -"All parts of a SPATIAL KEY must be NOT NULL", -#define ER_COLLATION_CHARSET_MISMATCH 1253 -"COLLATION '%s' is not valid for CHARACTER SET '%s'", -#define ER_SLAVE_WAS_RUNNING 1254 -"Slave is already running", -#define ER_SLAVE_WAS_NOT_RUNNING 1255 -"Slave has already been stopped", -#define ER_TOO_BIG_FOR_UNCOMPRESS 1256 -"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)", -#define ER_ZLIB_Z_MEM_ERROR 1257 -"ZLIB: Not enough memory", -#define ER_ZLIB_Z_BUF_ERROR 1258 -"ZLIB: Not enough room in the output buffer (probably, length of uncompressed data was corrupted)", -#define ER_ZLIB_Z_DATA_ERROR 1259 -"ZLIB: Input data corrupted", -#define ER_CUT_VALUE_GROUP_CONCAT 1260 -"%d line(s) was(were) cut by group_concat()", -#define ER_WARN_TOO_FEW_RECORDS 1261 -"Row %ld doesn't contain data for all columns", -#define ER_WARN_TOO_MANY_RECORDS 1262 -"Row %ld was truncated; It contained more data than there were input columns", -#define ER_WARN_NULL_TO_NOTNULL 1263 -"Data truncated, NULL supplied to NOT NULL column '%s' at row %ld", -#define ER_WARN_DATA_OUT_OF_RANGE 1264 -"Data truncated, out of range for column '%s' at row %ld", -#define ER_WARN_DATA_TRUNCATED 1265 -"Data truncated for column '%s' at row %ld", -#define ER_WARN_USING_OTHER_HANDLER 1266 -"Using storage engine %s for table '%s'", -#define ER_CANT_AGGREGATE_2COLLATIONS 1267 -"Illegal mix of collations (%s,%s) and (%s,%s) for operation '%s'", -#define ER_HANDLE_USER 1268 -"Operation %s failed for %d of the requested users", -#define ER_REVOKE_GRANTS 1269 -"Can't revoke all privileges, grant for one or more of the requested users", -#define ER_CANT_AGGREGATE_3COLLATIONS 1270 -"Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", -#define ER_CANT_AGGREGATE_NCOLLATIONS 1271 -"Illegal mix of collations for operation '%s'", -#define ER_VARIABLE_IS_NOT_STRUCT 1272 -"Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", -#define ER_UNKNOWN_COLLATION 1273 -"Unknown collation: '%-.64s'", -#define ER_SLAVE_IGNORED_SSL_PARAMS 1274 -"SSL parameters in CHANGE MASTER are ignored because this MySQL slave was compiled without SSL support; they can be used later when MySQL slave with SSL will be started", -#define ER_SERVER_IS_IN_SECURE_AUTH_MODE 1275 -"Server is running in --secure-auth mode, but '%s'@'%s' has a password in the old format; please change the password to the new format", -#define ER_WARN_FIELD_RESOLVED 1276 -"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", -#define ER_BAD_SLAVE_UNTIL_COND 1277 -"Wrong parameter or combination of parameters for START SLAVE UNTIL", -#define ER_MISSING_SKIP_SLAVE 1278 -"It is recommended to use --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL. Otherwise you will get problems if you get an unexpected slave's mysqld restart", -#define ER_UNTIL_COND_IGNORED 1279 -"SQL thread is not to be started so UNTIL options are ignored", -#define ER_WRONG_NAME_FOR_INDEX 1280 -"Incorrect index name '%-.100s'", -#define ER_WRONG_NAME_FOR_CATALOG 1281 -"Incorrect catalog name '%-.100s'", -#define ER_WARN_QC_RESIZE 1282 -"Query cache failed to set size %lu, new query cache size is %lu", -#define ER_BAD_FT_COLUMN 1283 -"Column '%-.64s' cannot be part of FULLTEXT index", -#define ER_UNKNOWN_KEY_CACHE 1284 -"Unknown key cache '%-.100s'", -#define ER_WARN_HOSTNAME_WONT_WORK 1285 -"MySQL is started in --skip-name-resolve mode. You need to restart it without this switch for this grant to work", -#define ER_UNKNOWN_STORAGE_ENGINE 1286 -"Unknown table engine '%s'", -#define ER_WARN_DEPRECATED_SYNTAX 1287 -"'%s' is deprecated, use '%s' instead", -#define ER_NON_UPDATABLE_TABLE 1288 -"The target table %-.100s of the %s is not updatable", -#define ER_FEATURE_DISABLED 1289 -"The '%s' feature was disabled; you need MySQL built with '%s' to have it working", -#define ER_OPTION_PREVENTS_STATEMENT 1290 -"The MySQL server is running with the %s option so it cannot execute this statement", -#define ER_DUPLICATED_VALUE_IN_TYPE 1291 -"Column '%-.100s' has duplicated value '%-.64s' in %s" -#define ER_TRUNCATED_WRONG_VALUE 1292 -"Truncated wrong %-.32s value: '%-.128s'" -#define ER_TOO_MUCH_AUTO_TIMESTAMP_COLS 1293 -"Incorrect table definition; There can only be one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause" -#define ER_INVALID_ON_UPDATE 1294 -"Invalid ON UPDATE clause for '%-.64s' field", -#define ER_UNSUPPORTED_PS 1295 -"This command is not supported in the prepared statement protocol yet", -#define ER_CANT_CREATE_USER_WITH_GRANT 1296 -"You are not allowed to create a user with GRANT" diff --git a/Docs/reservedwords.texi b/Docs/reservedwords.texi deleted file mode 100644 index a6dddfe9a7a..00000000000 --- a/Docs/reservedwords.texi +++ /dev/null @@ -1,14 +0,0 @@ -@c This is a placeholder file for the autogenerated MySQL reserved -@c word list "reservedwords.texi", which is being included in -@c manual.texi when building the manual. -@c -@c This file will be replaced with the actual reserved word list -@c from the "mysqldoc" BK source tree when building the official -@c source distribution. -@c -@c Please note, that the manual is now maintained in a separate -@c "mysqldoc" BitKeeper tree! See -@c -@c http://www.mysql.com/doc/en/Installing_source_tree.html -@c -@c for more info on how to work with the MySQL BK source trees. diff --git a/VC++Files/client/mysqlclient.dsp b/VC++Files/client/mysqlclient.dsp index 75008858e55..157c576b187 100644 --- a/VC++Files/client/mysqlclient.dsp +++ b/VC++Files/client/mysqlclient.dsp @@ -147,6 +147,10 @@ SOURCE="..\strings\ctype-bin.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-cp932.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-czech.c" # End Source File # Begin Source File @@ -155,6 +159,10 @@ SOURCE="..\strings\ctype-euc_kr.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-eucjpms.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-extra.c" # End Source File # Begin Source File diff --git a/VC++Files/client/mysqlclient_ia64.dsp b/VC++Files/client/mysqlclient_ia64.dsp index e91245c12b2..a69c5cf58af 100644 --- a/VC++Files/client/mysqlclient_ia64.dsp +++ b/VC++Files/client/mysqlclient_ia64.dsp @@ -147,6 +147,10 @@ SOURCE="..\strings\ctype-bin.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-cp932.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-czech.c" # End Source File # Begin Source File @@ -155,6 +159,10 @@ SOURCE="..\strings\ctype-euc_kr.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-eucjpms.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-extra.c" # End Source File # Begin Source File diff --git a/VC++Files/libmysql/libmysql.dsp b/VC++Files/libmysql/libmysql.dsp index ce81a3b7435..34c479c73b4 100644 --- a/VC++Files/libmysql/libmysql.dsp +++ b/VC++Files/libmysql/libmysql.dsp @@ -139,6 +139,10 @@ SOURCE="..\strings\ctype-bin.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-cp932.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-czech.c" # End Source File # Begin Source File @@ -147,6 +151,10 @@ SOURCE="..\strings\ctype-euc_kr.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-eucjpms.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-extra.c" # End Source File # Begin Source File diff --git a/VC++Files/libmysql/libmysql_ia64.dsp b/VC++Files/libmysql/libmysql_ia64.dsp index 4c4776dfc2f..fa851cb81c5 100644 --- a/VC++Files/libmysql/libmysql_ia64.dsp +++ b/VC++Files/libmysql/libmysql_ia64.dsp @@ -138,6 +138,10 @@ SOURCE="..\strings\ctype-bin.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-cp932.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-czech.c" # End Source File # Begin Source File @@ -146,6 +150,10 @@ SOURCE="..\strings\ctype-euc_kr.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-eucjpms.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-extra.c" # End Source File # Begin Source File diff --git a/VC++Files/sql/mysqld.dsp b/VC++Files/sql/mysqld.dsp index 5ca468f7fc9..723c0d63b36 100644 --- a/VC++Files/sql/mysqld.dsp +++ b/VC++Files/sql/mysqld.dsp @@ -58,7 +58,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib ..\lib_release\vio.lib ..\lib_release\mysys.lib ..\lib_release\strings.lib ..\lib_release\regex.lib ..\lib_release\heap.lib /nologo /subsystem:console /pdb:none /machine:I386 /out:"../client_release/mysqld-opt.exe" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib ..\lib_release\vio.lib ..\lib_release\mysys.lib ..\lib_release\strings.lib ..\lib_release\regex.lib ..\lib_release\heap.lib /nologo /subsystem:console /pdb:none /machine:I386 /out:"../client_release/mysqld.exe" # SUBTRACT LINK32 /debug !ELSEIF "$(CFG)" == "mysqld - Win32 Debug" @@ -84,7 +84,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib ..\lib_debug\dbug.lib ..\lib_debug\vio.lib ..\lib_debug\mysys.lib ..\lib_debug\strings.lib ..\lib_debug\regex.lib ..\lib_debug\heap.lib ..\lib_debug\bdb.lib ..\lib_debug\innodb.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqld.exe" /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib ..\lib_debug\dbug.lib ..\lib_debug\vio.lib ..\lib_debug\mysys.lib ..\lib_debug\strings.lib ..\lib_debug\regex.lib ..\lib_debug\heap.lib ..\lib_debug\bdb.lib ..\lib_debug\innodb.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqld-debug.exe" /pdbtype:sept !ELSEIF "$(CFG)" == "mysqld - Win32 nt" diff --git a/VC++Files/strings/strings.dsp b/VC++Files/strings/strings.dsp index 340617344f2..320cdaf2132 100644 --- a/VC++Files/strings/strings.dsp +++ b/VC++Files/strings/strings.dsp @@ -113,10 +113,18 @@ SOURCE=".\ctype-bin.c" # End Source File # Begin Source File +SOURCE=".\ctype-cp932.c" +# End Source File +# Begin Source File + SOURCE=".\ctype-czech.c" # End Source File # Begin Source File +SOURCE=".\ctype-eucjpms.c" +# End Source File +# Begin Source File + SOURCE=".\ctype-euc_kr.c" # End Source File # Begin Source File diff --git a/VC++Files/strings/strings_ia64.dsp b/VC++Files/strings/strings_ia64.dsp index 6449b2b1355..a34a238dfdc 100644 --- a/VC++Files/strings/strings_ia64.dsp +++ b/VC++Files/strings/strings_ia64.dsp @@ -112,6 +112,10 @@ SOURCE=".\ctype-bin.c" # End Source File # Begin Source File +SOURCE=".\ctype-cp932.c" +# End Source File +# Begin Source File + SOURCE=".\ctype-czech.c" # End Source File # Begin Source File @@ -120,6 +124,10 @@ SOURCE=".\ctype-euc_kr.c" # End Source File # Begin Source File +SOURCE=".\ctype-eucjpms.c" +# End Source File +# Begin Source File + SOURCE=".\ctype-extra.c" # End Source File # Begin Source File diff --git a/VC++Files/winmysqladmin/mysql.h b/VC++Files/winmysqladmin/mysql.h index f01b55f5d3f..734d78efea0 100644 --- a/VC++Files/winmysqladmin/mysql.h +++ b/VC++Files/winmysqladmin/mysql.h @@ -145,7 +145,7 @@ typedef struct st_mysql { unsigned long thread_id; /* Id for connection in server */ my_ulonglong affected_rows; my_ulonglong insert_id; /* id if insert on table with NEXTNR */ - my_ulonglong extra_info; /* Used by mysqlshow */ + my_ulonglong extra_info; /* Not used */ unsigned long packet_length; enum mysql_status status; MYSQL_FIELD *fields; diff --git a/client/Makefile.am b/client/Makefile.am index d3307f9da42..58dcebfd852 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -23,7 +23,8 @@ LIBS = @CLIENT_LIBS@ LDADD= @CLIENT_EXTRA_LDFLAGS@ \ $(top_builddir)/libmysql/libmysqlclient.la bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \ - mysqldump mysqlimport mysqltest mysqlbinlog mysqlmanagerc mysqlmanager-pwgen + mysqldump mysqlimport mysqltest mysqlbinlog \ + mysqltestmanagerc mysqltestmanager-pwgen noinst_HEADERS = sql_string.h completion_hash.h my_readline.h \ client_priv.h mysql_SOURCES = mysql.cc readline.cc sql_string.cc completion_hash.cc @@ -33,7 +34,8 @@ mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS) mysqltest_SOURCES= mysqltest.c $(top_srcdir)/mysys/my_getsystime.c mysqltest_LDADD = $(top_builddir)/regex/libregex.a $(LDADD) mysqlbinlog_SOURCES = mysqlbinlog.cc $(top_srcdir)/mysys/mf_tempdir.c -mysqlmanagerc_SOURCES = mysqlmanagerc.c +mysqltestmanagerc_SOURCES = mysqlmanagerc.c +mysqltestmanager_pwgen_SOURCES = mysqlmanager-pwgen.c sql_src=log_event.h mysql_priv.h log_event.cc my_decimal.h my_decimal.cc strings_src=decimal.c diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 15be51853cd..c767f1c89b7 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -566,6 +566,7 @@ static void print_result() my_bool found_error=0; res = mysql_use_result(sock); + prev[0] = '\0'; for (i = 0; (row = mysql_fetch_row(res)); i++) { @@ -595,7 +596,7 @@ static void print_result() putchar('\n'); } if (found_error && opt_auto_repair && what_to_do != DO_REPAIR && - (!opt_fast || strcmp(row[3],"OK"))) + !opt_fast) insert_dynamic(&tables4repair, prev); mysql_free_result(res); } diff --git a/client/mysqldump.c b/client/mysqldump.c index 2017f923c2f..b07a36aa7ad 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -37,7 +37,7 @@ ** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov */ -#define DUMP_VERSION "10.9" +#define DUMP_VERSION "10.10" #include #include @@ -396,7 +396,7 @@ static int dump_all_databases(); static char *quote_name(const char *name, char *buff, my_bool force); static const char *check_if_ignore_table(const char *table_name); static char *primary_key_fields(const char *table_name); -static my_bool getViewStructure(char *table, char* db); +static my_bool get_view_structure(char *table, char* db); static my_bool dump_all_views_in_db(char *database); #include @@ -777,16 +777,16 @@ static int get_options(int *argc, char ***argv) /* -** DBerror -- prints mysql error message and exits the program. +** DB_error -- prints mysql error message and exits the program. */ -static void DBerror(MYSQL *mysql, const char *when) +static void DB_error(MYSQL *mysql, const char *when) { - DBUG_ENTER("DBerror"); + DBUG_ENTER("DB_error"); my_printf_error(0,"Got error: %d: %s %s", MYF(0), mysql_errno(mysql), mysql_error(mysql), when); safe_exit(EX_MYSQLERR); DBUG_VOID_RETURN; -} /* DBerror */ +} /* DB_error */ /* @@ -862,7 +862,7 @@ static int dbConnect(char *host, char *user,char *passwd) NULL,opt_mysql_port,opt_mysql_unix_port, 0))) { - DBerror(&mysql_connection, "when trying to connect"); + DB_error(&mysql_connection, "when trying to connect"); return 1; } /* @@ -1093,7 +1093,7 @@ static void print_xml_row(FILE *xml_file, const char *row_name, number of fields in table, 0 if error */ -static uint getTableStructure(char *table, char *db) +static uint get_table_structure(char *table, char *db) { MYSQL_RES *tableRes; MYSQL_ROW row; @@ -1104,7 +1104,7 @@ static uint getTableStructure(char *table, char *db) char name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3]; char table_buff2[NAME_LEN*2+3]; FILE *sql_file = md_result_file; - DBUG_ENTER("getTableStructure"); + DBUG_ENTER("get_table_structure"); delayed= opt_delayed ? " DELAYED " : ""; @@ -1457,7 +1457,7 @@ continue_xml: my_fclose(sql_file, MYF(MY_WME)); } DBUG_RETURN(numFields); -} /* getTableStructure */ +} /* get_table_structure */ static char *add_load_option(char *ptr,const char *object, @@ -1523,10 +1523,12 @@ static char *alloc_query_str(ulong size) return query; } + /* -** dumpTable saves database contents as a series of INSERT statements. +** dump_table saves database contents as a series of INSERT statements. */ -static void dumpTable(uint numFields, char *table) + +static void dump_table(uint numFields, char *table) { char query_buf[QUERY_LENGTH], *end, buff[256],table_buff[NAME_LEN+3]; char *result_table, table_buff2[NAME_LEN*2+3], *opt_quoted_table; @@ -1592,7 +1594,7 @@ static void dumpTable(uint numFields, char *table) } if (mysql_real_query(sock, query, (uint) (end - query))) { - DBerror(sock, "when executing 'SELECT INTO OUTFILE'"); + DB_error(sock, "when executing 'SELECT INTO OUTFILE'"); return; } } @@ -1639,13 +1641,13 @@ static void dumpTable(uint numFields, char *table) check_io(md_result_file); } if (mysql_query_with_error_report(sock, 0, query)) - DBerror(sock, "when retrieving data from server"); + DB_error(sock, "when retrieving data from server"); if (quick) res=mysql_use_result(sock); else res=mysql_store_result(sock); if (!res) - DBerror(sock, "when retrieving data from server"); + DB_error(sock, "when retrieving data from server"); if (verbose) fprintf(stderr, "-- Retrieving rows...\n"); if (mysql_num_fields(res) != numFields) @@ -1946,7 +1948,7 @@ err: my_free(query, MYF(MY_ALLOW_ZERO_PTR)); safe_exit(error); return; -} /* dumpTable */ +} /* dump_table */ static char *getTableName(int reset) @@ -2035,7 +2037,7 @@ static int init_dumping(char *database) if (mysql_select_db(sock, database)) { - DBerror(sock, "when selecting the database"); + DB_error(sock, "when selecting the database"); return 1; /* If --force */ } if (!path && !opt_xml) @@ -2123,14 +2125,14 @@ static int dump_all_tables_in_db(char *database) dynstr_append(&query, " READ /*!32311 LOCAL */,"); } if (numrows && mysql_real_query(sock, query.str, query.length-1)) - DBerror(sock, "when using LOCK TABLES"); + DB_error(sock, "when using LOCK TABLES"); /* We shall continue here, if --force was given */ dynstr_free(&query); } if (flush_logs) { if (mysql_refresh(sock, REFRESH_LOG)) - DBerror(sock, "when doing refresh"); + DB_error(sock, "when doing refresh"); /* We shall continue here, if --force was given */ } while ((table= getTableName(0))) @@ -2138,9 +2140,9 @@ static int dump_all_tables_in_db(char *database) char *end= strmov(afterdot, table); if (include_table(hash_key, end - hash_key)) { - numrows = getTableStructure(table, database); + numrows = get_table_structure(table, database); if (!dFlag && numrows > 0) - dumpTable(numrows,table); + dump_table(numrows,table); my_free(order_by, MYF(MY_ALLOW_ZERO_PTR)); order_by= 0; } @@ -2188,18 +2190,18 @@ static my_bool dump_all_views_in_db(char *database) dynstr_append(&query, " READ /*!32311 LOCAL */,"); } if (numrows && mysql_real_query(sock, query.str, query.length-1)) - DBerror(sock, "when using LOCK TABLES"); + DB_error(sock, "when using LOCK TABLES"); /* We shall continue here, if --force was given */ dynstr_free(&query); } if (flush_logs) { if (mysql_refresh(sock, REFRESH_LOG)) - DBerror(sock, "when doing refresh"); + DB_error(sock, "when doing refresh"); /* We shall continue here, if --force was given */ } while ((table= getTableName(0))) - getViewStructure(table, database); + get_view_structure(table, database); if (opt_xml) { fputs("\n", md_result_file); @@ -2226,7 +2228,7 @@ static int get_actual_table_name(const char *old_table_name, int buf_size) { int retval; - MYSQL_RES *tableRes; + MYSQL_RES *table_res; MYSQL_ROW row; char query[50 + 2*NAME_LEN]; char show_name_buff[FN_REFLEN]; @@ -2242,18 +2244,22 @@ static int get_actual_table_name(const char *old_table_name, safe_exit(EX_MYSQLERR); } - tableRes= mysql_store_result( sock ); retval = 1; - if (tableRes != NULL) + + if ((table_res= mysql_store_result(sock))) { - my_ulonglong numRows = mysql_num_rows(tableRes); - if (numRows > 0) - { - row= mysql_fetch_row( tableRes ); - strmake(new_table_name, row[0], buf_size-1); - retval = 0; - } - mysql_free_result(tableRes); + my_ulonglong num_rows= mysql_num_rows(table_res); + if (num_rows > 0) + { + /* + Return first row + TODO: Return all matching rows + */ + row= mysql_fetch_row(table_res); + strmake(new_table_name, row[0], buf_size-1); + retval= 0; + } + mysql_free_result(table_res); } return retval; } @@ -2278,37 +2284,36 @@ static int dump_selected_tables(char *db, char **table_names, int tables) dynstr_append(&query, " READ /*!32311 LOCAL */,"); } if (mysql_real_query(sock, query.str, query.length-1)) - DBerror(sock, "when doing LOCK TABLES"); + DB_error(sock, "when doing LOCK TABLES"); /* We shall countinue here, if --force was given */ dynstr_free(&query); } if (flush_logs) { if (mysql_refresh(sock, REFRESH_LOG)) - DBerror(sock, "when doing refresh"); + DB_error(sock, "when doing refresh"); /* We shall countinue here, if --force was given */ } if (opt_xml) print_xml_tag1(md_result_file, "", "database name=", db, "\n"); for (i=0 ; i < tables ; i++) { - char new_table_name[NAME_LEN]; + char new_table_name[NAME_LEN]; - /* the table name passed on commandline may be wrong case */ - if (!get_actual_table_name( table_names[i], new_table_name, sizeof(new_table_name) )) - { - - numrows = getTableStructure(new_table_name, db); - - dumpTable(numrows, new_table_name); - } + /* the table name passed on commandline may be wrong case */ + if (!get_actual_table_name( table_names[i], new_table_name, + sizeof(new_table_name))) + { + numrows= get_table_structure(new_table_name, db); + dump_table(numrows, new_table_name); + } my_free(order_by, MYF(MY_ALLOW_ZERO_PTR)); order_by= 0; } if (was_views) { for (i=0 ; i < tables ; i++) - getViewStructure(table_names[i], db); + get_view_structure(table_names[i], db); } if (opt_xml) { @@ -2613,7 +2618,7 @@ cleanup: Getting VIEW structure SYNOPSIS - getViewStructure() + get_view_structure() table view name db db name @@ -2622,9 +2627,9 @@ cleanup: 1 ERROR */ -static my_bool getViewStructure(char *table, char* db) +static my_bool get_view_structure(char *table, char* db) { - MYSQL_RES *tableRes; + MYSQL_RES *table_res; MYSQL_ROW row; MYSQL_FIELD *field; char *result_table, *opt_quoted_table; @@ -2632,7 +2637,7 @@ static my_bool getViewStructure(char *table, char* db) char table_buff2[NAME_LEN*2+3]; char buff[20+FN_REFLEN]; FILE *sql_file = md_result_file; - DBUG_ENTER("getViewStructure"); + DBUG_ENTER("get_view_structure"); if (tFlag) DBUG_RETURN(0); @@ -2667,8 +2672,8 @@ static my_bool getViewStructure(char *table, char* db) } write_header(sql_file, db); } - tableRes= mysql_store_result(sock); - field= mysql_fetch_field_direct(tableRes, 0); + table_res= mysql_store_result(sock); + field= mysql_fetch_field_direct(table_res, 0); if (strcmp(field->name, "View") != 0) { if (verbose) @@ -2688,10 +2693,10 @@ static my_bool getViewStructure(char *table, char* db) check_io(sql_file); } - row= mysql_fetch_row(tableRes); + row= mysql_fetch_row(table_res); fprintf(sql_file, "%s;\n", row[1]); check_io(sql_file); - mysql_free_result(tableRes); + mysql_free_result(table_res); if (sql_file != md_result_file) { diff --git a/client/mysqlshow.c b/client/mysqlshow.c index eee96a9c3eb..5631d296a54 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -611,6 +611,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table, char query[1024],*end; MYSQL_RES *result; MYSQL_ROW row; + ulong rows; if (mysql_select_db(mysql,db)) { @@ -618,6 +619,17 @@ list_fields(MYSQL *mysql,const char *db,const char *table, mysql_error(mysql)); return 1; } + sprintf(query,"select count(*) from `%s`", table); + if (mysql_query(mysql,query) || !(result=mysql_store_result(mysql))) + { + fprintf(stderr,"%s: Cannot get record count for db: %s, table: %s: %s\n", + my_progname,db,table,mysql_error(mysql)); + return 1; + } + row = mysql_fetch_row(result); + rows = (ulong) strtoull(row[0], (char**) 0, 10); + mysql_free_result(result); + end=strmov(strmov(strmov(query,"show /*!32332 FULL */ columns from `"),table),"`"); if (wild && wild[0]) strxmov(end," like '",wild,"'",NullS); @@ -628,8 +640,8 @@ list_fields(MYSQL *mysql,const char *db,const char *table, return 1; } - printf("Database: %s Table: %s Rows: %lu", db,table, - (ulong) mysql->extra_info); + printf("Database: %s Table: %s Rows: %lu", db, table, rows); + if (wild && wild[0]) printf(" Wildcard: %s",wild); putchar('\n'); diff --git a/client/mysqltest.c b/client/mysqltest.c index 4000f494c63..4991e565594 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -294,6 +294,7 @@ Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL, Q_START_TIMER, Q_END_TIMER, Q_CHARACTER_SET, Q_DISABLE_PS_PROTOCOL, Q_ENABLE_PS_PROTOCOL, Q_EXIT, +Q_DISABLE_RECONNECT, Q_ENABLE_RECONNECT, Q_UNKNOWN, /* Unknown command. */ Q_COMMENT, /* Comments, ignored. */ @@ -382,6 +383,8 @@ const char *command_names[]= "disable_ps_protocol", "enable_ps_protocol", "exit", + "disable_reconnect", + "enable_reconnect", 0 }; @@ -642,6 +645,7 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char* fname) { DBUG_PRINT("info",("Size differs: result size: %u file size: %u", ds->length, stat_info.st_size)); + DBUG_PRINT("info",("result: '%s'", ds->str)); DBUG_RETURN(2); } if (!(tmp = (char*) my_malloc(stat_info.st_size + 1, MYF(MY_WME)))) @@ -3620,8 +3624,8 @@ static void init_var_hash(MYSQL *mysql) if (hash_init(&var_hash, charset_info, 1024, 0, 0, get_var_key, var_free, MYF(0))) die("Variable hash initialization failed"); - if (opt_big_test) - my_hash_insert(&var_hash, (byte*) var_init(0,"BIG_TEST", 0, "1",0)); + my_hash_insert(&var_hash, (byte*) var_init(0,"BIG_TEST", 0, + (opt_big_test) ? "1" : "0", 0)); v= var_init(0,"MAX_TABLES", 0, (sizeof(ulong) == 4) ? "31" : "62",0); my_hash_insert(&var_hash, (byte*) v); v= var_init(0,"SERVER_VERSION", 0, mysql_get_server_info(mysql), 0); @@ -3790,6 +3794,12 @@ int main(int argc, char **argv) if (q->query == q->query_buf) q->query += q->first_word_len + 1; display_result_vertically= (q->type==Q_QUERY_VERTICAL); + if (save_file[0]) + { + strmov(q->record_file,save_file); + q->require_file=require_file; + save_file[0]=0; + } error|= run_query(&cur_con->mysql, q, QUERY_REAP|QUERY_SEND); display_result_vertically= old_display_result_vertically; break; @@ -3895,6 +3905,12 @@ int main(int argc, char **argv) case Q_ENABLE_PS_PROTOCOL: ps_protocol_enabled= ps_protocol; break; + case Q_DISABLE_RECONNECT: + cur_con->mysql.reconnect= 0; + break; + case Q_ENABLE_RECONNECT: + cur_con->mysql.reconnect= 1; + break; case Q_EXIT: abort_flag= 1; @@ -4180,8 +4196,8 @@ static REP_SET *make_new_set(REP_SETS *sets); static void make_sets_invisible(REP_SETS *sets); static void free_last_set(REP_SETS *sets); static void free_sets(REP_SETS *sets); -static void set_bit(REP_SET *set, uint bit); -static void clear_bit(REP_SET *set, uint bit); +static void internal_set_bit(REP_SET *set, uint bit); +static void internal_clear_bit(REP_SET *set, uint bit); static void or_bits(REP_SET *to,REP_SET *from); static void copy_bits(REP_SET *to,REP_SET *from); static int cmp_bits(REP_SET *set1,REP_SET *set2); @@ -4258,7 +4274,7 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count, { if (from[i][0] == '\\' && from[i][1] == '^') { - set_bit(start_states,states+1); + internal_set_bit(start_states,states+1); if (!from[i][2]) { start_states->table_offset=i; @@ -4267,8 +4283,8 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count, } else if (from[i][0] == '\\' && from[i][1] == '$') { - set_bit(start_states,states); - set_bit(word_states,states); + internal_set_bit(start_states,states); + internal_set_bit(word_states,states); if (!from[i][2] && start_states->table_offset == (uint) ~0) { start_states->table_offset=i; @@ -4277,11 +4293,11 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count, } else { - set_bit(word_states,states); + internal_set_bit(word_states,states); if (from[i][0] == '\\' && (from[i][1] == 'b' && from[i][2])) - set_bit(start_states,states+1); + internal_set_bit(start_states,states+1); else - set_bit(start_states,states); + internal_set_bit(start_states,states); } for (pos=from[i], len=0; *pos ; pos++) { @@ -4387,9 +4403,9 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count, follow[i].len > found_end) found_end=follow[i].len; if (chr && follow[i].chr) - set_bit(new_set,i+1); /* To next set */ + internal_set_bit(new_set,i+1); /* To next set */ else - set_bit(new_set,i); + internal_set_bit(new_set,i); } } if (found_end) @@ -4406,7 +4422,7 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count, if (follow[bit_nr-1].len < found_end || (new_set->found_len && (chr == 0 || !follow[bit_nr].chr))) - clear_bit(new_set,i); + internal_clear_bit(new_set,i); else { if (chr == 0 || !follow[bit_nr].chr) @@ -4555,13 +4571,13 @@ static void free_sets(REP_SETS *sets) return; } -static void set_bit(REP_SET *set, uint bit) +static void internal_set_bit(REP_SET *set, uint bit) { set->bits[bit / WORD_BIT] |= 1 << (bit % WORD_BIT); return; } -static void clear_bit(REP_SET *set, uint bit) +static void internal_clear_bit(REP_SET *set, uint bit) { set->bits[bit / WORD_BIT] &= ~ (1 << (bit % WORD_BIT)); return; diff --git a/config/ac-macros/character_sets.m4 b/config/ac-macros/character_sets.m4 index 6efd31fdb05..3ecc4bb5a03 100644 --- a/config/ac-macros/character_sets.m4 +++ b/config/ac-macros/character_sets.m4 @@ -359,16 +359,23 @@ case $default_charset in ;; utf8) default_charset_default_collation="utf8_general_ci" - define(UTFC1, utf8_general_ci utf8_bin) - define(UTFC2, utf8_czech_ci utf8_danish_ci) - define(UTFC3, utf8_estonian_ci utf8_icelandic_ci) - define(UTFC4, utf8_latvian_ci utf8_lithuanian_ci) - define(UTFC5, utf8_persian_ci utf8_polish_ci utf8_romanian_ci) - define(UTFC6, utf8_slovak_ci utf8_slovenian_ci) - define(UTFC7, utf8_spanish2_ci utf8_spanish_ci) - define(UTFC8, utf8_swedish_ci utf8_turkish_ci) - define(UTFC9, utf8_unicode_ci) - UTFC="UTFC1 UTFC2 UTFC3 UTFC4 UTFC5 UTFC6 UTFC7 UTFC8 UTFC9" + if test "$default_collation" = "utf8_general_cs"; then + # For those who explicitly desire "utf8_general_cs", support it, + # and then also set the CPP switch enabling that code. + UTFC="utf8_general_cs" + AC_DEFINE([HAVE_UTF8_GENERAL_CS], [1], [certain Japanese customer]) + else + define(UTFC1, utf8_general_ci utf8_bin) + define(UTFC2, utf8_czech_ci utf8_danish_ci) + define(UTFC3, utf8_estonian_ci utf8_icelandic_ci) + define(UTFC4, utf8_latvian_ci utf8_lithuanian_ci) + define(UTFC5, utf8_persian_ci utf8_polish_ci utf8_romanian_ci) + define(UTFC6, utf8_slovak_ci utf8_slovenian_ci) + define(UTFC7, utf8_spanish2_ci utf8_spanish_ci) + define(UTFC8, utf8_swedish_ci utf8_turkish_ci) + define(UTFC9, utf8_unicode_ci) + UTFC="UTFC1 UTFC2 UTFC3 UTFC4 UTFC5 UTFC6 UTFC7 UTFC8 UTFC9" + fi default_charset_collations="$UTFC" ;; *) diff --git a/config/ac-macros/ha_isam.m4 b/config/ac-macros/ha_isam.m4 deleted file mode 100644 index 5e354dfa624..00000000000 --- a/config/ac-macros/ha_isam.m4 +++ /dev/null @@ -1,15 +0,0 @@ -AC_DEFUN([MYSQL_CHECK_ISAM], [ - AC_ARG_WITH([isam], [ - --with-isam Enable the ISAM table type], - [with_isam="$withval"], - [with_isam=no]) - - isam_libs= - if test X"$with_isam" = X"yes" - then - AC_DEFINE([HAVE_ISAM], [1], [Using old ISAM tables]) - isam_libs="\$(top_builddir)/isam/libnisam.a\ - \$(top_builddir)/merge/libmerge.a" - fi - AC_SUBST(isam_libs) -]) diff --git a/configure.in b/configure.in index 11bd87651da..afaaa57d344 100644 --- a/configure.in +++ b/configure.in @@ -41,7 +41,6 @@ sinclude(config/ac-macros/ha_blackhole.m4) sinclude(config/ac-macros/ha_example.m4) sinclude(config/ac-macros/ha_federated.m4) sinclude(config/ac-macros/ha_innodb.m4) -sinclude(config/ac-macros/ha_isam.m4) sinclude(config/ac-macros/ha_ndbcluster.m4) sinclude(config/ac-macros/ha_tina.m4) sinclude(config/ac-macros/large_file.m4) @@ -351,11 +350,30 @@ then if echo $CXX | grep gcc > /dev/null 2>&1 then - if $CXX -v 2>&1 | grep 'version 3' > /dev/null 2>&1 - then - # Statically link the language support function's found in libsupc++.a - LIBS="$LIBS -lsupc++" - fi + GCC_VERSION=`gcc -v 2>&1 | grep version | sed -e 's/[[^0-9. ]]//g; s/^ *//g; s/ .*//g'` + case $SYSTEM_TYPE in + *freebsd*) + # The libsupc++ library on freebsd with gcc 3.4.2 is dependent on + # libstdc++, disable it since other solution works fine + GCC_VERSION="NOSUPCPP_$GCC_VERSION" + ;; + *) + ;; + esac + echo "Using gcc version '$GCC_VERSION'" + case "$GCC_VERSION" in + 3.4.*|3.5.*) + # Statically link the language support function's found in libsupc++.a + LIBS="$LIBS -lsupc++" + echo "Using -libsupc++ for static linking with gcc" + ;; + *) + # Using -lsupc++ doesn't work in gcc 3.3 on SuSE 9.2 + # (causes link failures when linking things staticly) + CXXFLAGS="$CXXFLAGS -DUSE_MYSYS_NEW -DDEFINE_CXA_PURE_VIRTUAL" + echo "Using MYSYS_NEW for static linking with gcc" + ;; + esac fi fi @@ -2735,7 +2753,7 @@ AC_CONFIG_FILES(Makefile extra/Makefile mysys/Makefile dnl dbug/Makefile scripts/Makefile dnl include/Makefile sql-bench/Makefile tools/Makefile dnl server-tools/Makefile server-tools/instance-manager/Makefile dnl - tests/Makefile Docs/Makefile Docs/Images/Makefile support-files/Makefile dnl + tests/Makefile Docs/Makefile support-files/Makefile dnl support-files/MacOSX/Makefile mysql-test/Makefile dnl netware/Makefile dnl include/mysql_version.h dnl diff --git a/include/Makefile.am b/include/Makefile.am index 08beb4b7236..5f426843950 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -24,7 +24,7 @@ pkginclude_HEADERS = my_dbug.h m_string.h my_sys.h my_list.h my_xml.h \ sslopt-vars.h sslopt-case.h sql_common.h keycache.h \ mysql_time.h $(BUILT_SOURCES) noinst_HEADERS = config-win.h config-os2.h config-netware.h \ - nisam.h heap.h merge.h my_bitmap.h\ + heap.h my_bitmap.h\ myisam.h myisampack.h myisammrg.h ft_global.h\ mysys_err.h my_base.h help_start.h help_end.h \ my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \ diff --git a/include/config-win.h b/include/config-win.h index 4ef5c9323e7..bc392ce73d8 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -351,7 +351,6 @@ inline double ulonglong2double(ulonglong value) #define DO_NOT_REMOVE_THREAD_WRAPPERS #define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V)) #define thread_safe_decrement(V,L) InterlockedDecrement((long*) &(V)) -#define thread_safe_dec_and_test(V, L) thread_safe_decrement(V,L) /* The following is only used for statistics, so it should be good enough */ #ifdef __NT__ /* This should also work on Win98 but .. */ #define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C)) @@ -379,6 +378,7 @@ inline double ulonglong2double(ulonglong value) /* #undef HAVE_CHARSET_armscii8 */ /* #undef HAVE_CHARSET_ascii */ #define HAVE_CHARSET_big5 1 +#define HAVE_CHARSET_cp932 #define HAVE_CHARSET_cp1250 1 /* #undef HAVE_CHARSET_cp1251 */ /* #undef HAVE_CHARSET_cp1256 */ @@ -387,6 +387,7 @@ inline double ulonglong2double(ulonglong value) /* #undef HAVE_CHARSET_cp852 */ /* #undef HAVE_CHARSET_cp866 */ /* #undef HAVE_CHARSET_dec8 */ +#define HAVE_CHARSET_eucjpms 1 #define HAVE_CHARSET_euckr 1 #define HAVE_CHARSET_gb2312 1 #define HAVE_CHARSET_gbk 1 diff --git a/include/m_ctype.h b/include/m_ctype.h index c41c7385b3d..61524dc4ddd 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -149,7 +149,8 @@ typedef struct my_charset_handler_st uint (*numchars)(struct charset_info_st *, const char *b, const char *e); uint (*charpos)(struct charset_info_st *, const char *b, const char *e, uint pos); uint (*well_formed_len)(struct charset_info_st *, - const char *b,const char *e, uint nchars); + const char *b,const char *e, + uint nchars, int *error); uint (*lengthsp)(struct charset_info_st *, const char *ptr, uint length); uint (*numcells)(struct charset_info_st *, const char *b, const char *e); @@ -186,7 +187,7 @@ typedef struct my_charset_handler_st int base, char **e, int *err); double (*strntod)(struct charset_info_st *, char *s, uint l, char **e, int *err); - longlong (*my_strtoll10)(struct charset_info_st *cs, + longlong (*strtoll10)(struct charset_info_st *cs, const char *nptr, char **endptr, int *error); ulong (*scan)(struct charset_info_st *, const char *b, const char *e, int sq); @@ -349,7 +350,8 @@ int my_wildcmp_8bit(CHARSET_INFO *, uint my_numchars_8bit(CHARSET_INFO *, const char *b, const char *e); uint my_numcells_8bit(CHARSET_INFO *, const char *b, const char *e); uint my_charpos_8bit(CHARSET_INFO *, const char *b, const char *e, uint pos); -uint my_well_formed_len_8bit(CHARSET_INFO *, const char *b, const char *e, uint pos); +uint my_well_formed_len_8bit(CHARSET_INFO *, const char *b, const char *e, + uint pos, int *error); int my_mbcharlen_8bit(CHARSET_INFO *, uint c); @@ -367,7 +369,8 @@ int my_wildcmp_mb(CHARSET_INFO *, uint my_numchars_mb(CHARSET_INFO *, const char *b, const char *e); uint my_numcells_mb(CHARSET_INFO *, const char *b, const char *e); uint my_charpos_mb(CHARSET_INFO *, const char *b, const char *e, uint pos); -uint my_well_formed_len_mb(CHARSET_INFO *, const char *b, const char *e, uint pos); +uint my_well_formed_len_mb(CHARSET_INFO *, const char *b, const char *e, + uint pos, int *error); uint my_instr_mb(struct charset_info_st *, const char *b, uint b_length, const char *s, uint s_length, diff --git a/include/merge.h b/include/merge.h deleted file mode 100644 index 97cea5fabb1..00000000000 --- a/include/merge.h +++ /dev/null @@ -1,93 +0,0 @@ -/* Copyright (C) 2000 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; either 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 */ - -/* This file should be included when using merge_isam_funktions */ -/* Author: Michael Widenius */ - -#ifndef _merge_h -#define _merge_h -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _my_base_h -#include -#endif -#ifndef _nisam_h -#include -#endif - -#define MRG_NAME_EXT ".MRG" - - /* Param to/from mrg_info */ - -typedef struct st_mrg_info /* Struct from h_info */ -{ - ulonglong records; /* Records in database */ - ulonglong deleted; /* Deleted records in database */ - ulonglong recpos; /* Pos for last used record */ - ulonglong data_file_length; - uint reclength; /* Recordlength */ - int errkey; /* With key was dupplicated on err */ - uint options; /* HA_OPTION_... used */ -} MERGE_INFO; - -typedef struct st_mrg_table_info -{ - N_INFO *table; - ulonglong file_offset; -} MRG_TABLE; - -typedef struct st_merge -{ - MRG_TABLE *open_tables,*current_table,*end_table,*last_used_table; - ulonglong records; /* records in tables */ - ulonglong del; /* Removed records */ - ulonglong data_file_length; - uint tables,options,reclength; - my_bool cache_in_use; - LIST open_list; -} MRG_INFO; - -typedef ulong mrg_off_t; - - /* Prototypes for merge-functions */ - -extern int mrg_close(MRG_INFO *file); -extern int mrg_delete(MRG_INFO *file,const byte *buff); -extern MRG_INFO *mrg_open(const char *name,int mode,int wait_if_locked); -extern int mrg_panic(enum ha_panic_function function); -extern int mrg_rfirst(MRG_INFO *file,byte *buf,int inx); -extern int mrg_rkey(MRG_INFO *file,byte *buf,int inx,const byte *key, - uint key_len, enum ha_rkey_function search_flag); -extern int mrg_rrnd(MRG_INFO *file,byte *buf, mrg_off_t pos); -extern int mrg_rsame(MRG_INFO *file,byte *record,int inx); -extern int mrg_update(MRG_INFO *file,const byte *old,const byte *new_rec); -extern int mrg_info(MRG_INFO *file,MERGE_INFO *x,int flag); -extern int mrg_lock_database(MRG_INFO *file,int lock_type); -extern int mrg_create(const char *name,const char **table_names); -extern int mrg_extra(MRG_INFO *file,enum ha_extra_function function); -extern ha_rows mrg_records_in_range(MRG_INFO *info,int inx, - const byte *start_key,uint start_key_len, - enum ha_rkey_function start_search_flag, - const byte *end_key,uint end_key_len, - enum ha_rkey_function end_search_flag); - -extern mrg_off_t mrg_position(MRG_INFO *info); -#ifdef __cplusplus -} -#endif -#endif diff --git a/include/my_base.h b/include/my_base.h index 1713a07f6ec..25fa683744e 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -312,7 +312,9 @@ enum ha_base_keytype { #define HA_ERR_TABLE_EXIST 156 /* The table existed in storage engine */ #define HA_ERR_NO_CONNECTION 157 /* Could not connect to storage engine */ #define HA_ERR_NULL_IN_SPATIAL 158 /* NULLs are not supported in spatial index */ -#define HA_ERR_LAST 158 /*Copy last error nr.*/ +#define HA_ERR_TABLE_DEF_CHANGED 159 /* The table changed in storage engine */ + +#define HA_ERR_LAST 159 /*Copy last error nr.*/ /* Add error numbers before HA_ERR_LAST and change it accordingly. */ #define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1) diff --git a/include/my_pthread.h b/include/my_pthread.h index b170753913b..670a4ccf63e 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -678,7 +678,6 @@ extern pthread_t shutdown_th, main_th, signal_th; #ifdef HAVE_ATOMIC_ADD #define thread_safe_increment(V,L) atomic_inc((atomic_t*) &V) #define thread_safe_decrement(V,L) atomic_dec((atomic_t*) &V) -#define thread_safe_dec_and_test(V, L) atomic_dec_and_test((atomic_t*) &V) #define thread_safe_add(V,C,L) atomic_add((C),(atomic_t*) &V) #define thread_safe_sub(V,C,L) atomic_sub((C),(atomic_t*) &V) #else @@ -689,22 +688,6 @@ extern pthread_t shutdown_th, main_th, signal_th; #define thread_safe_add(V,C,L) (pthread_mutex_lock((L)), (V)+=(C), pthread_mutex_unlock((L))) #define thread_safe_sub(V,C,L) \ (pthread_mutex_lock((L)), (V)-=(C), pthread_mutex_unlock((L))) -#ifdef __cplusplus -static inline bool thread_safe_dec_and_test(ulong &V, pthread_mutex_t *L) -{ - ulong res; - pthread_mutex_lock(L); - res=--V; - pthread_mutex_unlock(L); - return res==0; -} -#else -/* - what should we do ? define it as static ? - a regular function somewhere in mysys/ ? - for now it's only used in c++ code, so there's no need to bother -*/ -#endif #endif /* HAVE_ATOMIC_ADD */ #ifdef SAFE_STATISTICS #define statistic_increment(V,L) thread_safe_increment((V),(L)) diff --git a/include/my_sys.h b/include/my_sys.h index 523c0570de7..f63743a4c6c 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -54,11 +54,10 @@ extern int NEAR my_errno; /* Last error in mysys */ #define MY_FAE 8 /* Fatal if any error */ #define MY_WME 16 /* Write message on error */ #define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */ -#define MY_RAID 64 /* Support for RAID (not the "Johnson&Johnson"-s one ;) */ -#define MY_FULL_IO 512 /* For my_read - loop intil I/O - is complete - */ -#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */ +#define MY_IGNORE_BADFD 32 /* my_sync: ignore 'bad descriptor' errors */ +#define MY_RAID 64 /* Support for RAID */ +#define MY_FULL_IO 512 /* For my_read - loop intil I/O is complete */ +#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */ #define MY_LINK_WARNING 32 /* my_redel() gives warning if links */ #define MY_COPYTIME 64 /* my_redel() copys time */ #define MY_DELETE_OLD 256 /* my_create_with_symlink() */ @@ -72,7 +71,7 @@ extern int NEAR my_errno; /* Last error in mysys */ #define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */ #define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */ #define MY_THREADSAFE 128 /* pread/pwrite: Don't allow interrupts */ -#define MY_DONT_OVERWRITE_FILE 1024 /* my_copy; Don't overwrite file */ +#define MY_DONT_OVERWRITE_FILE 1024 /* my_copy: Don't overwrite file */ #define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */ #define MY_GIVE_INFO 2 /* Give time info about process*/ diff --git a/include/mysql.h b/include/mysql.h index b87b865608e..24f1961a260 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -231,7 +231,7 @@ typedef struct st_mysql MEM_ROOT field_alloc; my_ulonglong affected_rows; my_ulonglong insert_id; /* id if insert on table with NEXTNR */ - my_ulonglong extra_info; /* Used by mysqlshow */ + my_ulonglong extra_info; /* Not used */ unsigned long thread_id; /* Id for connection in server */ unsigned long packet_length; unsigned int port; diff --git a/include/mysql_embed.h b/include/mysql_embed.h index 603af8e83b8..311d95eda73 100644 --- a/include/mysql_embed.h +++ b/include/mysql_embed.h @@ -24,7 +24,6 @@ #undef HAVE_PSTACK /* No stacktrace */ #undef HAVE_DLOPEN /* No udf functions */ #undef HAVE_OPENSSL -#undef HAVE_ISAM #undef HAVE_SMEM /* No shared memory */ #undef HAVE_NDBCLUSTER_DB /* No NDB cluster */ diff --git a/include/nisam.h b/include/nisam.h deleted file mode 100644 index e8f29991a4e..00000000000 --- a/include/nisam.h +++ /dev/null @@ -1,212 +0,0 @@ -/* Copyright (C) 2000 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; either 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 */ - -/* This file should be included when using nisam_funktions */ -/* Author: Michael Widenius */ - -#ifndef _nisam_h -#define _nisam_h -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _my_base_h -#include -#endif - /* defines used by nisam-funktions */ - -#define N_MAXKEY 16 /* Max allowed keys */ -#define N_MAXKEY_SEG 16 /* Max segments for key */ -#define N_MAX_KEY_LENGTH 256 /* May be increased up to 500 */ -#define N_MAX_KEY_BUFF (N_MAX_KEY_LENGTH+N_MAXKEY_SEG+sizeof(double)-1) -#define N_MAX_POSSIBLE_KEY_BUFF 500+9 - -#define N_NAME_IEXT ".ISM" -#define N_NAME_DEXT ".ISD" -#define NI_POS_ERROR (~ (ulong) 0) - - - /* Param to/from nisam_info */ - -typedef struct st_n_isaminfo /* Struct from h_info */ -{ - ulong records; /* Records in database */ - ulong deleted; /* Deleted records in database */ - ulong recpos; /* Pos for last used record */ - ulong newrecpos; /* Pos if we write new record */ - ulong dupp_key_pos; /* Position to record with dupp key */ - ulong data_file_length, /* Length of data file */ - max_data_file_length, - index_file_length, - max_index_file_length, - delete_length; - uint reclength; /* Recordlength */ - uint mean_reclength; /* Mean recordlength (if packed) */ - uint keys; /* How many keys used */ - uint options; /* HA_OPTION_... used */ - int errkey, /* With key was dupplicated on err */ - sortkey; /* clustered by this key */ - File filenr; /* (uniq) filenr for datafile */ - time_t create_time; /* When table was created */ - time_t isamchk_time; - time_t update_time; - ulong *rec_per_key; /* for sql optimizing */ -} N_ISAMINFO; - - - /* Info saved on file for each info-part */ - -#ifdef __WATCOMC__ -#pragma pack(2) -#define uint uint16 /* Same format as in MSDOS */ -#endif - -#ifdef __ZTC__ -#pragma ZTC align 2 -#define uint uint16 /* Same format as in MSDOS */ -#endif - -typedef struct st_n_save_keyseg /* Key-portion */ -{ - uint8 type; /* Typ av nyckel (f|r sort) */ - uint8 flag; /* HA_DIFF_LENGTH */ - uint16 start; /* Start of key in record */ - uint16 length; /* Keylength */ -} N_SAVE_KEYSEG; - -typedef struct st_n_save_keydef /* Key definition with create & info */ -{ - uint8 flag; /* NOSAME, PACK_USED */ - uint8 keysegs; /* Number of key-segment */ - uint16 block_length; /* Length of keyblock (auto) */ - uint16 keylength; /* Tot length of keyparts (auto) */ - uint16 minlength; /* min length of (packed) key (auto) */ - uint16 maxlength; /* max length of (packed) key (auto) */ -} N_SAVE_KEYDEF; - -typedef struct st_n_save_recinfo /* Info of record */ -{ - int16 type; /* en_fieldtype */ - uint16 length; /* length of field */ -} N_SAVE_RECINFO; - - -#ifdef __ZTC__ -#pragma ZTC align -#undef uint -#endif - -#ifdef __WATCOMC__ -#pragma pack() -#undef uint -#endif - - -struct st_isam_info; /* For referense */ - -#ifndef ISAM_LIBRARY -typedef struct st_isam_info N_INFO; -#endif - -typedef struct st_n_keyseg /* Key-portion */ -{ - N_SAVE_KEYSEG base; -} N_KEYSEG; - - -typedef struct st_n_keydef /* Key definition with open & info */ -{ - N_SAVE_KEYDEF base; - N_KEYSEG seg[N_MAXKEY_SEG+1]; - int (*bin_search)(struct st_isam_info *info,struct st_n_keydef *keyinfo, - uchar *page,uchar *key, - uint key_len,uint comp_flag,uchar * *ret_pos, - uchar *buff); - uint (*get_key)(struct st_n_keydef *keyinfo,uint nod_flag,uchar * *page, - uchar *key); -} N_KEYDEF; - - -typedef struct st_decode_tree /* Decode huff-table */ -{ - uint16 *table; - uint quick_table_bits; - byte *intervalls; -} DECODE_TREE; - - -struct st_bit_buff; - -typedef struct st_n_recinfo /* Info of record */ -{ - N_SAVE_RECINFO base; -#ifndef NOT_PACKED_DATABASES - void (*unpack)(struct st_n_recinfo *rec,struct st_bit_buff *buff, - uchar *start,uchar *end); - enum en_fieldtype base_type; - uint space_length_bits,pack_type; - DECODE_TREE *huff_tree; -#endif -} N_RECINFO; - - -extern my_string nisam_log_filename; /* Name of logfile */ -extern uint nisam_block_size; -extern my_bool nisam_flush; - - /* Prototypes for nisam-functions */ - -extern int nisam_close(struct st_isam_info *file); -extern int nisam_delete(struct st_isam_info *file,const byte *buff); -extern struct st_isam_info *nisam_open(const char *name,int mode, - uint wait_if_locked); -extern int nisam_panic(enum ha_panic_function function); -extern int nisam_rfirst(struct st_isam_info *file,byte *buf,int inx); -extern int nisam_rkey(struct st_isam_info *file,byte *buf,int inx, - const byte *key, - uint key_len, enum ha_rkey_function search_flag); -extern int nisam_rlast(struct st_isam_info *file,byte *buf,int inx); -extern int nisam_rnext(struct st_isam_info *file,byte *buf,int inx); -extern int nisam_rprev(struct st_isam_info *file,byte *buf,int inx); -extern int nisam_rrnd(struct st_isam_info *file,byte *buf,ulong pos); -extern int nisam_rsame(struct st_isam_info *file,byte *record,int inx); -extern int nisam_rsame_with_pos(struct st_isam_info *file,byte *record, - int inx,ulong pos); -extern int nisam_update(struct st_isam_info *file,const byte *old, - const byte *new_record); -extern int nisam_write(struct st_isam_info *file,const byte *buff); -extern int nisam_info(struct st_isam_info *file,N_ISAMINFO *x,int flag); -extern ulong nisam_position(struct st_isam_info *info); -extern int nisam_lock_database(struct st_isam_info *file,int lock_type); -extern int nisam_create(const char *name,uint keys,N_KEYDEF *keyinfo, - N_RECINFO *recinfo,ulong records, - ulong reloc,uint flags,uint options, - ulong data_file_length); -extern int nisam_extra(struct st_isam_info *file, - enum ha_extra_function function); -extern ulong nisam_records_in_range(struct st_isam_info *info,int inx, - const byte *start_key,uint start_key_len, - enum ha_rkey_function start_search_flag, - const byte *end_key,uint end_key_len, - enum ha_rkey_function end_search_flag); -extern int nisam_log(int activate_log); -extern int nisam_is_changed(struct st_isam_info *info); -extern uint _calc_blob_length(uint length , const byte *pos); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/innobase/btr/btr0pcur.c b/innobase/btr/btr0pcur.c index ceaa4f41a18..74feff8653c 100644 --- a/innobase/btr/btr0pcur.c +++ b/innobase/btr/btr0pcur.c @@ -14,6 +14,7 @@ Created 2/23/1996 Heikki Tuuri #include "ut0byte.h" #include "rem0cmp.h" +#include "trx0trx.h" /****************************************************************** Allocates memory for a persistent cursor object and initializes the cursor. */ @@ -206,7 +207,14 @@ btr_pcur_restore_position( ut_a(cursor->pos_state == BTR_PCUR_WAS_POSITIONED || cursor->pos_state == BTR_PCUR_IS_POSITIONED); - ut_a(cursor->old_stored == BTR_PCUR_OLD_STORED); + if (cursor->old_stored != BTR_PCUR_OLD_STORED) { + ut_print_buf(stderr, (const byte*)cursor, sizeof(btr_pcur_t)); + if (cursor->trx_if_known) { + trx_print(stderr, cursor->trx_if_known); + } + + ut_a(0); + } if (cursor->rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE || cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE) { diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index 02f46ea7b18..8c9724da079 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -2201,7 +2201,8 @@ ulint dict_foreign_add_to_cache( /*======================*/ /* out: DB_SUCCESS or error code */ - dict_foreign_t* foreign) /* in, own: foreign key constraint */ + dict_foreign_t* foreign, /* in, own: foreign key constraint */ + ibool check_types) /* in: TRUE=check type compatibility */ { dict_table_t* for_table; dict_table_t* ref_table; @@ -2237,10 +2238,16 @@ dict_foreign_add_to_cache( } if (for_in_cache->referenced_table == NULL && ref_table) { + dict_index_t* types_idx; + if (check_types) { + types_idx = for_in_cache->foreign_index; + } else { + types_idx = NULL; + } index = dict_foreign_find_index(ref_table, (const char**) for_in_cache->referenced_col_names, for_in_cache->n_fields, - for_in_cache->foreign_index); + types_idx); if (index == NULL) { dict_foreign_error_report(ef, for_in_cache, @@ -2264,10 +2271,16 @@ dict_foreign_add_to_cache( } if (for_in_cache->foreign_table == NULL && for_table) { + dict_index_t* types_idx; + if (check_types) { + types_idx = for_in_cache->referenced_index; + } else { + types_idx = NULL; + } index = dict_foreign_find_index(for_table, (const char**) for_in_cache->foreign_col_names, for_in_cache->n_fields, - for_in_cache->referenced_index); + types_idx); if (index == NULL) { dict_foreign_error_report(ef, for_in_cache, @@ -3333,6 +3346,9 @@ try_find_index: "Cannot find an index in the referenced table where the\n" "referenced columns appear as the first columns, or column types\n" "in the table and the referenced table do not match for constraint.\n" +"Note that the internal storage type of ENUM and SET changed in\n" +"tables created with >= InnoDB-4.1.12, and such columns in old tables\n" +"cannot be referenced by such columns in new tables.\n" "See http://dev.mysql.com/doc/mysql/en/InnoDB_foreign_key_constraints.html\n" "for correct foreign key definition.\n", start_of_latest_foreign); diff --git a/innobase/dict/dict0load.c b/innobase/dict/dict0load.c index 289b5dab4f2..9bafcf33553 100644 --- a/innobase/dict/dict0load.c +++ b/innobase/dict/dict0load.c @@ -868,7 +868,7 @@ dict_load_table( dict_load_indexes(table, heap); - err = dict_load_foreigns(table->name); + err = dict_load_foreigns(table->name, TRUE); /* if (err != DB_SUCCESS) { @@ -1089,8 +1089,9 @@ ulint dict_load_foreign( /*==============*/ /* out: DB_SUCCESS or error code */ - const char* id) /* in: foreign constraint id as a + const char* id, /* in: foreign constraint id as a null-terminated string */ + ibool check_types)/* in: TRUE=check type compatibility */ { dict_foreign_t* foreign; dict_table_t* sys_foreign; @@ -1102,7 +1103,6 @@ dict_load_foreign( rec_t* rec; byte* field; ulint len; - ulint err; mtr_t mtr; #ifdef UNIV_SYNC_DEBUG @@ -1204,9 +1204,7 @@ dict_load_foreign( a new foreign key constraint but loading one from the data dictionary. */ - err = dict_foreign_add_to_cache(foreign); - - return(err); + return(dict_foreign_add_to_cache(foreign, check_types)); } /*************************************************************************** @@ -1220,7 +1218,8 @@ ulint dict_load_foreigns( /*===============*/ /* out: DB_SUCCESS or error code */ - const char* table_name) /* in: table name */ + const char* table_name, /* in: table name */ + ibool check_types) /* in: TRUE=check type compatibility */ { btr_pcur_t pcur; mem_heap_t* heap; @@ -1320,7 +1319,7 @@ loop: /* Load the foreign constraint definition to the dictionary cache */ - err = dict_load_foreign(id); + err = dict_load_foreign(id, check_types); if (err != DB_SUCCESS) { btr_pcur_close(&pcur); diff --git a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c index 74970648c1a..e8efdcfbce0 100644 --- a/innobase/fil/fil0fil.c +++ b/innobase/fil/fil0fil.c @@ -1450,7 +1450,8 @@ fil_write_flushed_lsn_to_data_files( cache. Note that all data files in the system tablespace 0 are always open. */ - if (space->purpose == FIL_TABLESPACE) { + if (space->purpose == FIL_TABLESPACE + && space->id == 0) { sum_of_sizes = 0; node = UT_LIST_GET_FIRST(space->chain); @@ -2934,6 +2935,44 @@ func_exit: mem_free(filepath); } +/*************************************************************************** +A fault-tolerant function that tries to read the next file name in the +directory. We retry 100 times if os_file_readdir_next_file() returns -1. The +idea is to read as much good data as we can and jump over bad data. */ +static +int +fil_file_readdir_next_file( +/*=======================*/ + /* out: 0 if ok, -1 if error even after the + retries, 1 if at the end of the directory */ + ulint* err, /* out: this is set to DB_ERROR if an error + was encountered, otherwise not changed */ + const char* dirname,/* in: directory name or path */ + os_file_dir_t dir, /* in: directory stream */ + os_file_stat_t* info) /* in/out: buffer where the info is returned */ +{ + ulint i; + int ret; + + for (i = 0; i < 100; i++) { + ret = os_file_readdir_next_file(dirname, dir, info); + + if (ret != -1) { + + return(ret); + } + + fprintf(stderr, +"InnoDB: Error: os_file_readdir_next_file() returned -1 in\n" +"InnoDB: directory %s\n" +"InnoDB: Crash recovery may have failed for some .ibd files!\n", dirname); + + *err = DB_ERROR; + } + + return(-1); +} + /************************************************************************ At the server startup, if we need crash recovery, scans the database directories under the MySQL datadir, looking for .ibd files. Those files are @@ -2954,6 +2993,7 @@ fil_load_single_table_tablespaces(void) os_file_dir_t dbdir; os_file_stat_t dbinfo; os_file_stat_t fileinfo; + ulint err = DB_SUCCESS; /* The datadir of MySQL is always the default directory of mysqld */ @@ -2969,7 +3009,7 @@ fil_load_single_table_tablespaces(void) /* Scan all directories under the datadir. They are the database directories of MySQL. */ - ret = os_file_readdir_next_file(fil_path_to_mysql_datadir, dir, + ret = fil_file_readdir_next_file(&err, fil_path_to_mysql_datadir, dir, &dbinfo); while (ret == 0) { ulint len; @@ -3007,7 +3047,7 @@ fil_load_single_table_tablespaces(void) /* We found a database directory; loop through it, looking for possible .ibd files in it */ - ret = os_file_readdir_next_file(dbpath, dbdir, + ret = fil_file_readdir_next_file(&err, dbpath, dbdir, &fileinfo); while (ret == 0) { /* printf( @@ -3029,36 +3069,29 @@ fil_load_single_table_tablespaces(void) dbinfo.name, fileinfo.name); } next_file_item: - ret = os_file_readdir_next_file(dbpath, dbdir, + ret = fil_file_readdir_next_file(&err, + dbpath, dbdir, &fileinfo); } if (0 != os_file_closedir(dbdir)) { - fputs( + fputs( "InnoDB: Warning: could not close database directory ", stderr); - ut_print_filename(stderr, dbpath); - putc('\n', stderr); + ut_print_filename(stderr, dbpath); + putc('\n', stderr); + + err = DB_ERROR; } } next_datadir_item: - ret = os_file_readdir_next_file(fil_path_to_mysql_datadir, + ret = fil_file_readdir_next_file(&err, + fil_path_to_mysql_datadir, dir, &dbinfo); } mem_free(dbpath); - /* At the end of directory we should get 1 as the return value, -1 - if there was an error */ - if (ret != 1) { - fprintf(stderr, -"InnoDB: Error: os_file_readdir_next_file returned %d in MySQL datadir\n", - ret); - os_file_closedir(dir); - - return(DB_ERROR); - } - if (0 != os_file_closedir(dir)) { fprintf(stderr, "InnoDB: Error: could not close MySQL datadir\n"); @@ -3066,7 +3099,7 @@ next_datadir_item: return(DB_ERROR); } - return(DB_SUCCESS); + return(err); } /************************************************************************ diff --git a/innobase/include/btr0pcur.h b/innobase/include/btr0pcur.h index 6384222be51..eb3822aab7a 100644 --- a/innobase/include/btr0pcur.h +++ b/innobase/include/btr0pcur.h @@ -478,6 +478,10 @@ struct btr_pcur_struct{ BTR_PCUR_WAS_POSITIONED, BTR_PCUR_NOT_POSITIONED */ ulint search_mode; /* PAGE_CUR_G, ... */ + trx_t* trx_if_known; /* the transaction, if we know it; + otherwise this field is not defined; + can ONLY BE USED in error prints in + fatal assertion failures! */ /*-----------------------------*/ /* NOTE that the following fields may possess dynamically allocated memory which should be freed if not needed anymore! */ diff --git a/innobase/include/btr0pcur.ic b/innobase/include/btr0pcur.ic index b553a569bda..9a7d7867025 100644 --- a/innobase/include/btr0pcur.ic +++ b/innobase/include/btr0pcur.ic @@ -493,6 +493,8 @@ btr_pcur_open( btr_cur_search_to_nth_level(index, 0, tuple, mode, latch_mode, btr_cursor, 0, mtr); cursor->pos_state = BTR_PCUR_IS_POSITIONED; + + cursor->trx_if_known = NULL; } /****************************************************************** @@ -535,6 +537,8 @@ btr_pcur_open_with_no_init( cursor->pos_state = BTR_PCUR_IS_POSITIONED; cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; + + cursor->trx_if_known = NULL; } /********************************************************************* @@ -568,6 +572,8 @@ btr_pcur_open_at_index_side( pcur->pos_state = BTR_PCUR_IS_POSITIONED; pcur->old_stored = BTR_PCUR_OLD_NOT_STORED; + + pcur->trx_if_known = NULL; } /************************************************************************** @@ -592,6 +598,8 @@ btr_pcur_open_at_rnd_pos( btr_pcur_get_btr_cur(cursor), mtr); cursor->pos_state = BTR_PCUR_IS_POSITIONED; cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; + + cursor->trx_if_known = NULL; } /****************************************************************** @@ -617,4 +625,6 @@ btr_pcur_close( cursor->latch_mode = BTR_NO_LATCHES; cursor->pos_state = BTR_PCUR_NOT_POSITIONED; + + cursor->trx_if_known = NULL; } diff --git a/innobase/include/dict0dict.h b/innobase/include/dict0dict.h index fdcb6c1c4e1..56f0a158a20 100644 --- a/innobase/include/dict0dict.h +++ b/innobase/include/dict0dict.h @@ -189,7 +189,8 @@ ulint dict_foreign_add_to_cache( /*======================*/ /* out: DB_SUCCESS or error code */ - dict_foreign_t* foreign); /* in, own: foreign key constraint */ + dict_foreign_t* foreign, /* in, own: foreign key constraint */ + ibool check_types); /* in: TRUE=check type compatibility */ /************************************************************************* Checks if a table is referenced by foreign keys. */ diff --git a/innobase/include/dict0load.h b/innobase/include/dict0load.h index 1f0a5407140..f13620bc6e8 100644 --- a/innobase/include/dict0load.h +++ b/innobase/include/dict0load.h @@ -81,7 +81,8 @@ ulint dict_load_foreigns( /*===============*/ /* out: DB_SUCCESS or error code */ - const char* table_name); /* in: table name */ + const char* table_name, /* in: table name */ + ibool check_types); /* in: TRUE=check type compatibility */ /************************************************************************ Prints to the standard output information on all tables found in the data dictionary system table. */ diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h index 599e78bab48..f55c345537e 100644 --- a/innobase/include/os0file.h +++ b/innobase/include/os0file.h @@ -68,6 +68,8 @@ log. */ #define OS_FILE_OVERWRITE 53 #define OS_FILE_OPEN_RAW 54 #define OS_FILE_CREATE_PATH 55 +#define OS_FILE_OPEN_RETRY 56 /* for os_file_create() on + the first ibdata file */ #define OS_FILE_READ_ONLY 333 #define OS_FILE_READ_WRITE 444 diff --git a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h index 82b132a8bac..4a1833a1a21 100644 --- a/innobase/include/srv0srv.h +++ b/innobase/include/srv0srv.h @@ -99,11 +99,13 @@ extern ulint srv_max_n_threads; extern lint srv_conc_n_threads; -extern ibool srv_fast_shutdown; -extern ibool srv_very_fast_shutdown; /* if this TRUE, do not flush the +extern ulint srv_fast_shutdown; /* If this is 1, do not do a + purge and index buffer merge. + If this 2, do not even flush the buffer pool to data files at the - shutdown; we effectively 'crash' - InnoDB */ + shutdown: we effectively 'crash' + InnoDB (but lose no committed + transactions). */ extern ibool srv_innodb_status; extern ibool srv_use_doublewrite_buf; diff --git a/innobase/log/log0log.c b/innobase/log/log0log.c index e8a720e8a88..560f51401ac 100644 --- a/innobase/log/log0log.c +++ b/innobase/log/log0log.c @@ -3059,15 +3059,13 @@ loop: goto loop; } - if (srv_very_fast_shutdown) { - /* In a 'very fast' shutdown we do not flush the buffer pool: + if (srv_fast_shutdown == 2) { + /* In this fastest shutdown we do not flush the buffer pool: it is essentially a 'crash' of the InnoDB server. - Make sure that the log is all flushed to disk, so that + Make sure that the log is all flushed to disk, so that we can recover all committed transactions in a crash recovery. - In a 'very fast' shutdown we do not flush the buffer pool: - it is essentially a 'crash' of the InnoDB server. Then we must - not write the lsn stamps to the data files, since at a + We must not write the lsn stamps to the data files, since at a startup InnoDB deduces from the stamps if the previous shutdown was clean. */ diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index eeba98a8ab2..9df26150160 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -413,8 +413,6 @@ os_file_lock( "InnoDB: using the same InnoDB data or log files.\n"); } - close(fd); - return(-1); } @@ -989,6 +987,7 @@ try_again: } else if (access_type == OS_FILE_READ_WRITE && os_file_lock(file, name)) { *success = FALSE; + close(file); file = -1; #endif } else { @@ -1101,6 +1100,7 @@ os_file_create_simple_no_error_handling( } else if (access_type == OS_FILE_READ_WRITE && os_file_lock(file, name)) { *success = FALSE; + close(file); file = -1; #endif } else { @@ -1152,7 +1152,8 @@ try_again: if (create_mode == OS_FILE_OPEN_RAW) { create_flag = OPEN_EXISTING; share_mode = FILE_SHARE_WRITE; - } else if (create_mode == OS_FILE_OPEN) { + } else if (create_mode == OS_FILE_OPEN + || create_mode == OS_FILE_OPEN_RETRY) { create_flag = OPEN_EXISTING; } else if (create_mode == OS_FILE_CREATE) { create_flag = CREATE_NEW; @@ -1243,7 +1244,8 @@ try_again: try_again: ut_a(name); - if (create_mode == OS_FILE_OPEN || create_mode == OS_FILE_OPEN_RAW) { + if (create_mode == OS_FILE_OPEN || create_mode == OS_FILE_OPEN_RAW + || create_mode == OS_FILE_OPEN_RETRY) { mode_str = "OPEN"; create_flag = O_RDWR; } else if (create_mode == OS_FILE_CREATE) { @@ -1316,6 +1318,23 @@ try_again: } else if (create_mode != OS_FILE_OPEN_RAW && os_file_lock(file, name)) { *success = FALSE; + if (create_mode == OS_FILE_OPEN_RETRY) { + int i; + ut_print_timestamp(stderr); + fputs(" InnoDB: Retrying to lock the first data file\n", + stderr); + for (i = 0; i < 100; i++) { + os_thread_sleep(1000000); + if (!os_file_lock(file, name)) { + *success = TRUE; + return(file); + } + } + ut_print_timestamp(stderr); + fputs(" InnoDB: Unable to open the first data file\n", + stderr); + } + close(file); file = -1; #endif } else { diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index b13ba056d85..7f78a5b723b 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -2075,7 +2075,7 @@ row_table_add_foreign_constraints( if (err == DB_SUCCESS) { /* Check that also referencing constraints are ok */ - err = dict_load_foreigns(name); + err = dict_load_foreigns(name, trx->check_foreigns); } if (err != DB_SUCCESS) { @@ -3784,6 +3784,8 @@ row_rename_table_for_mysql( goto funct_exit; } + err = dict_load_foreigns(new_name, trx->check_foreigns); + if (row_is_mysql_tmp_table_name(old_name)) { /* MySQL is doing an ALTER TABLE command and it @@ -3793,8 +3795,6 @@ row_rename_table_for_mysql( table. But we want to load also the foreign key constraint definitions for the original table name. */ - err = dict_load_foreigns(new_name); - if (err != DB_SUCCESS) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: in ALTER TABLE ", @@ -3813,8 +3813,6 @@ row_rename_table_for_mysql( trx->error_state = DB_SUCCESS; } } else { - err = dict_load_foreigns(new_name); - if (err != DB_SUCCESS) { ut_print_timestamp(stderr); diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c index 10fc89bbb37..94cf82d6a3d 100644 --- a/innobase/row/row0sel.c +++ b/innobase/row/row0sel.c @@ -2145,12 +2145,16 @@ row_sel_convert_mysql_key_to_innobase( } if (dtype_get_mysql_type(dfield_get_type(dfield)) - == DATA_MYSQL_TRUE_VARCHAR) { + == DATA_MYSQL_TRUE_VARCHAR + && dfield_get_type(dfield)->mtype != DATA_INT) { /* In a MySQL key value format, a true VARCHAR is always preceded by 2 bytes of a length field. dfield_get_type(dfield)->len returns the maximum 'payload' len in bytes. That does not include the - 2 bytes that tell the actual data length. */ + 2 bytes that tell the actual data length. + + We added the check != DATA_INT to make sure we do + not treat MySQL ENUM or SET as a true VARCHAR! */ data_len += 2; data_field_len += 2; @@ -2360,7 +2364,9 @@ row_sel_field_store_in_mysql_format( ut_a(templ->mbmaxlen > templ->mbminlen || templ->mysql_col_len == len); - ut_a(!templ->mbmaxlen + /* The following assertion would fail for old tables + containing UTF-8 ENUM columns due to Bug #9526. */ + ut_ad(!templ->mbmaxlen || !(templ->mysql_col_len % templ->mbmaxlen)); ut_a(len * templ->mbmaxlen >= templ->mysql_col_len); @@ -2638,6 +2644,8 @@ row_sel_get_clust_rec_for_mysql( clust_rec = btr_pcur_get_rec(prebuilt->clust_pcur); + prebuilt->clust_pcur->trx_if_known = trx; + /* Note: only if the search ends up on a non-infimum record is the low_match value the real match to the search tuple */ @@ -3400,6 +3408,8 @@ shortcut_fails_too_big_rec: btr_pcur_open_with_no_init(index, search_tuple, mode, BTR_SEARCH_LEAF, pcur, 0, &mtr); + + pcur->trx_if_known = trx; } else { if (mode == PAGE_CUR_G) { btr_pcur_open_at_index_side(TRUE, index, @@ -3483,12 +3493,12 @@ rec_loop: err = sel_set_rec_lock(rec, index, offsets, prebuilt->select_lock_type, LOCK_ORDINARY, thr); + if (err != DB_SUCCESS) { + + goto lock_wait_or_error; + } } - if (err != DB_SUCCESS) { - - goto lock_wait_or_error; - } } /* A page supremum record cannot be in the result set: skip it now that we have placed a possible lock on it */ @@ -3596,12 +3606,12 @@ rec_loop: offsets, prebuilt->select_lock_type, LOCK_GAP, thr); + if (err != DB_SUCCESS) { + + goto lock_wait_or_error; + } } - if (err != DB_SUCCESS) { - - goto lock_wait_or_error; - } } btr_pcur_store_position(pcur, &mtr); @@ -3630,12 +3640,12 @@ rec_loop: offsets, prebuilt->select_lock_type, LOCK_GAP, thr); + if (err != DB_SUCCESS) { + + goto lock_wait_or_error; + } } - if (err != DB_SUCCESS) { - - goto lock_wait_or_error; - } } btr_pcur_store_position(pcur, &mtr); @@ -3676,6 +3686,27 @@ rec_loop: } } + /* If we are doing a 'greater or equal than a primary key + value' search from a clustered index, and we find a record + that has that exact primary key value, then there is no need + to lock the gap before the record, because no insert in the + gap can be in our search range. That is, no phantom row can + appear that way. + + An example: if col1 is the primary key, the search is WHERE + col1 >= 100, and we find a record where col1 = 100, then no + need to lock the gap before that record. */ + + if (index == clust_index + && mode == PAGE_CUR_GE + && direction == 0 + && dtuple_get_n_fields_cmp(search_tuple) + == dict_index_get_n_unique(index) + && 0 == cmp_dtuple_rec(search_tuple, rec, offsets)) { + + lock_type = LOCK_REC_NOT_GAP; + } + err = sel_set_rec_lock(rec, index, offsets, prebuilt->select_lock_type, lock_type, thr); diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c index 41b0594d705..a4bfdb6162d 100644 --- a/innobase/srv/srv0srv.c +++ b/innobase/srv/srv0srv.c @@ -300,15 +300,12 @@ SQL query after it has once got the ticket at srv_conc_enter_innodb */ #define SRV_FREE_TICKETS_TO_ENTER srv_n_free_tickets_to_enter #define SRV_THREAD_SLEEP_DELAY srv_thread_sleep_delay /*-----------------------*/ -/* If the following is set TRUE then we do not run purge and insert buffer -merge to completion before shutdown */ +/* If the following is set to 1 then we do not run purge and insert buffer +merge to completion before shutdown. If it is set to 2, do not even flush the +buffer pool to data files at the shutdown: we effectively 'crash' +InnoDB (but lose no committed transactions). */ +ulint srv_fast_shutdown = 0; -ibool srv_fast_shutdown = FALSE; - -ibool srv_very_fast_shutdown = FALSE; /* if this TRUE, do not flush the - buffer pool to data files at the - shutdown; we effectively 'crash' - InnoDB */ /* Generate a innodb_status. file */ ibool srv_innodb_status = FALSE; @@ -2471,11 +2468,11 @@ background_loop: flush_loop: srv_main_thread_op_info = "flushing buffer pool pages"; - if (!srv_very_fast_shutdown) { + if (srv_fast_shutdown < 2) { n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max); } else { - /* In a 'very fast' shutdown we do not flush the buffer pool + /* In the fastest shutdown we do not flush the buffer pool to data files: we set n_pages_flushed to 0 artificially. */ n_pages_flushed = 0; diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index c65b7d3e141..e136aee43e8 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -789,6 +789,11 @@ open_or_create_data_files( files[i] = os_file_create( name, OS_FILE_OPEN_RAW, OS_FILE_NORMAL, OS_DATA_FILE, &ret); + } else if (i == 0) { + files[i] = os_file_create( + name, OS_FILE_OPEN_RETRY, + OS_FILE_NORMAL, + OS_DATA_FILE, &ret); } else { files[i] = os_file_create( name, OS_FILE_OPEN, OS_FILE_NORMAL, @@ -1724,6 +1729,15 @@ innobase_shutdown_for_mysql(void) The step 1 is the real InnoDB shutdown. The remaining steps 2 - ... just free data structures after the shutdown. */ + + if (srv_fast_shutdown == 2) { + ut_print_timestamp(stderr); + fprintf(stderr, +" InnoDB: MySQL has requested a very fast shutdown without flushing " +"the InnoDB buffer pool to data files. At the next mysqld startup " +"InnoDB will do a crash recovery!\n"); + } + #ifdef __NETWARE__ if(!panic_shutdown) #endif diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index f09b09314d0..dbdaadf86bf 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3656,7 +3656,6 @@ static void fetch_long_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, } } - /* Convert double/float column to supplied buffer of any type. @@ -3673,6 +3672,7 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, double value, int width) { char *buffer= (char *)param->buffer; + double val64 = (value < 0 ? -floor(-value) : floor(value)); switch (param->buffer_type) { case MYSQL_TYPE_NULL: /* do nothing */ @@ -3688,8 +3688,8 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, *buffer= (uint8) value; else *buffer= (int8) value; - *param->error= value != (param->is_unsigned ? (double) ((uint8) *buffer) : - (double) ((int8) *buffer)); + *param->error= val64 != (param->is_unsigned ? (double)((uint8) *buffer) : + (double)((int8) *buffer)); break; case MYSQL_TYPE_SHORT: if (param->is_unsigned) @@ -3702,7 +3702,7 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, short data= (short) value; shortstore(buffer, data); } - *param->error= value != (param->is_unsigned ? (double) (*(ushort*) buffer): + *param->error= val64 != (param->is_unsigned ? (double) (*(ushort*) buffer): (double) (*(short*) buffer)); break; case MYSQL_TYPE_LONG: @@ -3716,7 +3716,7 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, int32 data= (int32) value; longstore(buffer, data); } - *param->error= value != (param->is_unsigned ? (double) (*(uint32*) buffer): + *param->error= val64 != (param->is_unsigned ? (double) (*(uint32*) buffer): (double) (*(int32*) buffer)); break; case MYSQL_TYPE_LONGLONG: @@ -3730,7 +3730,7 @@ static void fetch_float_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, longlong data= (longlong) value; longlongstore(buffer, data); } - *param->error= value != (param->is_unsigned ? + *param->error= val64 != (param->is_unsigned ? ulonglong2double(*(ulonglong*) buffer) : (double) (*(longlong*) buffer)); break; @@ -4258,6 +4258,7 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field) case MYSQL_TYPE_MEDIUM_BLOB: case MYSQL_TYPE_LONG_BLOB: case MYSQL_TYPE_BLOB: + case MYSQL_TYPE_BIT: DBUG_ASSERT(param->buffer_length != 0); param->fetch_result= fetch_result_bin; break; @@ -4334,6 +4335,7 @@ static my_bool setup_one_fetch_function(MYSQL_BIND *param, MYSQL_FIELD *field) case MYSQL_TYPE_BLOB: case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_STRING: + case MYSQL_TYPE_BIT: param->skip_result= skip_result_string; break; default: diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 79fe36615b9..74a1c8c7922 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -709,11 +709,6 @@ bool Protocol::send_fields(List *list, uint flags) DBUG_RETURN(1); /* purecov: inspected */ } -bool Protocol::send_records_num(List *list, ulonglong records) -{ - return false; -} - bool Protocol::write() { if (!thd->mysql) // bootstrap file handling diff --git a/myisam/mi_check.c b/myisam/mi_check.c index dd8cc736741..2949b39183d 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -972,7 +972,8 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) info->checksum=mi_checksum(info,record); if (param->testflag & (T_EXTEND | T_MEDIUM | T_VERBOSE)) { - if (_mi_rec_check(info,record, info->rec_buff,block_info.rec_len)) + if (_mi_rec_check(info,record, info->rec_buff,block_info.rec_len, + test(info->s->calc_checksum))) { mi_check_print_error(param,"Found wrong packed record at %s", llstr(start_recpos,llbuff)); @@ -3025,7 +3026,9 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) if ((param->testflag & (T_EXTEND | T_REP)) || searching) { if (_mi_rec_check(info, sort_param->record, sort_param->rec_buff, - sort_param->find_length)) + sort_param->find_length, + (param->testflag & T_QUICK) && + test(info->s->calc_checksum))) { mi_check_print_info(param,"Found wrong packed record at %s", llstr(sort_param->start_recpos,llbuff)); diff --git a/myisam/mi_dynrec.c b/myisam/mi_dynrec.c index 9d8e161b8fe..3a4dafade23 100644 --- a/myisam/mi_dynrec.c +++ b/myisam/mi_dynrec.c @@ -816,7 +816,7 @@ uint _mi_rec_pack(MI_INFO *info, register byte *to, register const byte *from) */ my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *rec_buff, - ulong packed_length) + ulong packed_length, my_bool with_checksum) { uint length,new_length,flag,bit,i; char *pos,*end,*packpos,*to; @@ -920,13 +920,10 @@ my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *rec_buff, if (packed_length != (uint) (to - rec_buff) + test(info->s->calc_checksum) || (bit != 1 && (flag & ~(bit - 1)))) goto err; - if (info->s->calc_checksum) + if (with_checksum && ((uchar) info->checksum != (uchar) *to)) { - if ((uchar) info->checksum != (uchar) *to) - { - DBUG_PRINT("error",("wrong checksum for row")); - goto err; - } + DBUG_PRINT("error",("wrong checksum for row")); + goto err; } DBUG_RETURN(0); diff --git a/myisam/mi_search.c b/myisam/mi_search.c index 0c82a4c4502..c669a8be8f8 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -211,9 +211,31 @@ int _mi_bin_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, } /* _mi_bin_search */ - /* Used instead of _mi_bin_search() when key is packed */ - /* Puts smaller or identical key in buff */ - /* Key is searched sequentially */ +/* + Locate a packed key in a key page. + + SYNOPSIS + _mi_seq_search() + info Open table information. + keyinfo Key definition information. + page Key page (beginning). + key Search key. + key_len Length to use from search key or USE_WHOLE_KEY + comp_flag Search flags like SEARCH_SAME etc. + ret_pos RETURN Position in key page behind this key. + buff RETURN Copy of previous or identical unpacked key. + last_key RETURN If key is last in page. + + DESCRIPTION + Used instead of _mi_bin_search() when key is packed. + Puts smaller or identical key in buff. + Key is searched sequentially. + + RETURN + > 0 Key in 'buff' is smaller than search key. + 0 Key in 'buff' is identical to search key. + < 0 Not found. +*/ int _mi_seq_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, uchar *key, uint key_len, uint comp_flag, uchar **ret_pos, @@ -722,7 +744,19 @@ uint _mi_get_static_key(register MI_KEYDEF *keyinfo, uint nod_flag, } /* _mi_get_static_key */ -/* Key with is packed against previous key or key with a NULL column */ +/* + get key witch is packed against previous key or key with a NULL column. + + SYNOPSIS + _mi_get_pack_key() + keyinfo key definition information. + nod_flag If nod: Length of node pointer, else zero. + page_pos RETURN position in key page behind this key. + key IN/OUT in: prev key, out: unpacked key. + + RETURN + key_length + length of data pointer +*/ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, register uchar **page_pos, register uchar *key) @@ -1353,12 +1387,12 @@ _mi_calc_var_key_length(MI_KEYDEF *keyinfo,uint nod_flag, Keys are compressed the following way: - If the max length of first key segment <= 127 characters the prefix is + If the max length of first key segment <= 127 bytes the prefix is 1 byte else it's 2 byte - prefix byte The high bit is set if this is a prefix for the prev key + prefix byte(s) The high bit is set if this is a prefix for the prev key length Packed length if the previous was a prefix byte - [length] Length character of data + [length] data bytes ('length' bytes) next-key-seg Next key segments If the first segment can have NULL: @@ -1552,7 +1586,8 @@ _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag,uchar *next_key, s_temp->part_of_prev_key= new_ref_length; s_temp->prev_length= org_key_length - (new_ref_length-pack_marker); - s_temp->n_ref_length= s_temp->n_length= s_temp->prev_length; + s_temp->n_ref_length= s_temp->part_of_prev_key; + s_temp->n_length= s_temp->prev_length; n_length= get_pack_length(s_temp->prev_length); s_temp->prev_key+= (new_ref_length - pack_marker); length+= s_temp->prev_length + n_length; diff --git a/myisam/mi_write.c b/myisam/mi_write.c index 768258a0c82..5d7e245c58f 100644 --- a/myisam/mi_write.c +++ b/myisam/mi_write.c @@ -421,8 +421,30 @@ err: } /* w_search */ - /* Insert new key at right of key_pos */ - /* Returns 2 if key contains key to upper level */ +/* + Insert new key. + + SYNOPSIS + _mi_insert() + info Open table information. + keyinfo Key definition information. + key New key. + anc_buff Key page (beginning). + key_pos Position in key page where to insert. + key_buff Copy of previous key. + father_buff parent key page for balancing. + father_key_pos position in parent key page for balancing. + father_page position of parent key page in file. + insert_last If to append at end of page. + + DESCRIPTION + Insert new key at right of key_pos. + + RETURN + 2 if key contains key to upper level. + 0 OK. + < 0 Error. +*/ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *key, uchar *anc_buff, uchar *key_pos, uchar *key_buff, diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h index b66d7e71a05..a2d3dedf6df 100644 --- a/myisam/myisamdef.h +++ b/myisam/myisamdef.h @@ -584,7 +584,7 @@ extern byte *mi_alloc_rec_buff(MI_INFO *,ulong, byte**); extern ulong _mi_rec_unpack(MI_INFO *info,byte *to,byte *from, ulong reclength); extern my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *packpos, - ulong reclength); + ulong packed_length, my_bool with_checkum); extern int _mi_write_part_record(MI_INFO *info,my_off_t filepos,ulong length, my_off_t next_filepos,byte **record, ulong *reclength,int *flag); diff --git a/myisam/myisampack.c b/myisam/myisampack.c index bda620a594a..352c7954d72 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -1712,7 +1712,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) ulong tot_blob_length=0; if (! error) { - if (flush_buffer(max_calc_length+max_pack_length)) + if (flush_buffer((ulong) max_calc_length + (ulong) max_pack_length)) break; record_pos=file_buffer.pos; file_buffer.pos+=max_pack_length; @@ -1935,7 +1935,20 @@ static void init_file_buffer(File file, pbool read_buffer) static int flush_buffer(ulong neaded_length) { ulong length; - if ((ulong) (file_buffer.end - file_buffer.pos) > neaded_length) + + /* + file_buffer.end is 8 bytes lower than the real end of the buffer. + This is done so that the end-of-buffer condition does not need to be + checked for every byte (see write_bits()). Consequently, + file_buffer.pos can become greater than file_buffer.end. The + algorithms in the other functions ensure that there will never be + more than 8 bytes written to the buffer without an end-of-buffer + check. So the buffer cannot be overrun. But we need to check for the + near-to-buffer-end condition to avoid a negative result, which is + casted to unsigned and thus becomes giant. + */ + if ((file_buffer.pos < file_buffer.end) && + ((ulong) (file_buffer.end - file_buffer.pos) > neaded_length)) return 0; length=(ulong) (file_buffer.pos-file_buffer.buffer); file_buffer.pos=file_buffer.buffer; @@ -2007,7 +2020,7 @@ static void write_bits (register ulong value, register uint bits) } #endif if (file_buffer.pos >= file_buffer.end) - VOID(flush_buffer((uint) ~0)); + VOID(flush_buffer(~ (ulong) 0)); file_buffer.bits=(int) (BITS_SAVED - bits); file_buffer.current_byte=(uint) (value << (BITS_SAVED - bits)); } diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 294c135bcf3..9963074daf5 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -32,38 +32,41 @@ endif benchdir_root= $(prefix) testdir = $(benchdir_root)/mysql-test -EXTRA_SCRIPTS = mysql-test-run.sh install_test_db.sh +EXTRA_SCRIPTS = mysql-test-run.sh mysql-test-run.pl install_test_db.sh valgrind.supp EXTRA_DIST = $(EXTRA_SCRIPTS) test_SCRIPTS = mysql-test-run install_test_db test_DATA = std_data/client-key.pem std_data/client-cert.pem std_data/cacert.pem CLEANFILES = $(test_SCRIPTS) $(test_DATA) -INCLUDES = -I$(srcdir)/../include -I../include -I.. -EXTRA_PROGRAMS = mysql_test_run_new +INCLUDES = -I$(srcdir)/../include -I../include -I.. +EXTRA_PROGRAMS = mysql_test_run_new noinst_HEADERS = my_manage.h mysql_test_run_new_SOURCES= mysql_test_run_new.c my_manage.c my_create_tables.c dist-hook: mkdir -p $(distdir)/t $(distdir)/r $(distdir)/include \ - $(distdir)/std_data + $(distdir)/std_data $(distdir)/lib $(INSTALL_DATA) $(srcdir)/t/*.test $(distdir)/t -$(INSTALL_DATA) $(srcdir)/t/*.disabled $(distdir)/t $(INSTALL_DATA) $(srcdir)/t/*.opt $(srcdir)/t/*.sh $(srcdir)/t/*.slave-mi $(distdir)/t $(INSTALL_DATA) $(srcdir)/include/*.inc $(distdir)/include - $(INSTALL_DATA) $(srcdir)/r/*.result $(srcdir)/r/*.result.es $(srcdir)/r/*.require $(distdir)/r + $(INSTALL_DATA) $(srcdir)/r/*.result $(srcdir)/r/*.require $(distdir)/r $(INSTALL_DATA) $(srcdir)/std_data/Moscow_leap $(distdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.dat $(srcdir)/std_data/*.000001 $(distdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/des_key_file $(distdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.pem $(distdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.frm $(distdir)/std_data + $(INSTALL_DATA) $(srcdir)/lib/init_db.sql $(distdir)/lib + $(INSTALL_DATA) $(srcdir)/lib/*.pl $(distdir)/lib install-data-local: $(mkinstalldirs) \ $(DESTDIR)$(testdir)/t \ $(DESTDIR)$(testdir)/r \ $(DESTDIR)$(testdir)/include \ - $(DESTDIR)$(testdir)/std_data + $(DESTDIR)$(testdir)/std_data \ + $(DESTDIR)$(testdir)/lib $(INSTALL_DATA) $(srcdir)/README $(DESTDIR)$(testdir) $(INSTALL_DATA) $(srcdir)/t/*.test $(DESTDIR)$(testdir)/t -$(INSTALL_DATA) $(srcdir)/t/*.disabled $(DESTDIR)$(testdir)/t @@ -71,7 +74,6 @@ install-data-local: $(INSTALL_DATA) $(srcdir)/t/*.sh $(DESTDIR)$(testdir)/t $(INSTALL_DATA) $(srcdir)/t/*.slave-mi $(DESTDIR)$(testdir)/t $(INSTALL_DATA) $(srcdir)/r/*.result $(DESTDIR)$(testdir)/r - $(INSTALL_DATA) $(srcdir)/r/*.result.es $(DESTDIR)$(testdir)/r $(INSTALL_DATA) $(srcdir)/r/*.require $(DESTDIR)$(testdir)/r $(INSTALL_DATA) $(srcdir)/include/*.inc $(DESTDIR)$(testdir)/include $(INSTALL_DATA) $(srcdir)/std_data/*.dat $(DESTDIR)$(testdir)/std_data @@ -80,6 +82,8 @@ install-data-local: $(INSTALL_DATA) $(srcdir)/std_data/Moscow_leap $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.pem $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.frm $(DESTDIR)$(testdir)/std_data + $(INSTALL_DATA) $(srcdir)/lib/init_db.sql $(DESTDIR)$(testdir)/lib + $(INSTALL_DATA) $(srcdir)/lib/*.pl $(DESTDIR)$(testdir)/lib std_data/%.pem: @CP@ $(top_srcdir)/SSL/$(@F) $(srcdir)/std_data diff --git a/mysql-test/include/big_test.inc b/mysql-test/include/big_test.inc new file mode 100644 index 00000000000..6b149540c96 --- /dev/null +++ b/mysql-test/include/big_test.inc @@ -0,0 +1,4 @@ +--require r/big_test.require +disable_query_log; +eval select $BIG_TEST as using_big_test; +enable_query_log; diff --git a/mysql-test/include/have_isam.inc b/mysql-test/include/have_isam.inc deleted file mode 100644 index 830170c921f..00000000000 --- a/mysql-test/include/have_isam.inc +++ /dev/null @@ -1,4 +0,0 @@ --- require r/have_isam.require -disable_query_log; -show variables like "have_isam"; -enable_query_log; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 90fc97b537b..ae4136b5494 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -262,6 +262,7 @@ our $opt_socket; our $opt_source_dist; our $opt_start_and_exit; +our $opt_start_dirty; our $opt_start_from; our $opt_strace_client; @@ -305,6 +306,7 @@ sub initial_setup (); sub command_line_setup (); sub executable_setup (); sub environment_setup (); +sub kill_running_server (); sub kill_and_cleanup (); sub ndbcluster_install (); sub ndbcluster_start (); @@ -353,14 +355,22 @@ sub main () { if ( ! $glob_use_running_server ) { - kill_and_cleanup(); - mysql_install_db(); + + if ( $opt_start_dirty ) + { + kill_running_server(); + } + else + { + kill_and_cleanup(); + mysql_install_db(); # mysql_loadstd(); FIXME copying from "std_data" .frm and # .MGR but there are none?! + } } - if ( $opt_start_and_exit ) + if ( $opt_start_and_exit or $opt_start_dirty ) { if ( ndbcluster_start() ) { @@ -531,6 +541,7 @@ sub command_line_setup () { 'script-debug' => \$opt_script_debug, 'sleep=i' => \$opt_sleep, 'socket=s' => \$opt_socket, + 'start-dirty' => \$opt_start_dirty, 'start-and-exit' => \$opt_start_and_exit, 'start-from=s' => \$opt_start_from, 'timer' => \$opt_timer, @@ -635,7 +646,6 @@ sub command_line_setup () { { mtr_error("Can't use --extern with --embedded-server"); } - $opt_result_ext= ".es"; } # FIXME don't understand what this is @@ -952,7 +962,7 @@ sub handle_int_signal () { # ############################################################################## -sub kill_and_cleanup () { +sub kill_running_server () { if ( $opt_fast or $glob_use_embedded_server ) { @@ -977,6 +987,11 @@ sub kill_and_cleanup () { ndbcluster_stop(); $master->[0]->{'ndbcluster'}= 1; } +} + +sub kill_and_cleanup () { + + kill_running_server (); mtr_report("Removing Stale Files"); @@ -1462,7 +1477,15 @@ sub run_testcase ($) { # ---------------------------------------------------------------------- { - unlink("r/$tname.reject"); + # remove the old reject file + if ( $opt_suite eq "main" ) + { + unlink("r/$tname.reject"); + } + else + { + unlink("suite/$opt_suite/r/$tname.reject"); + } unlink($path_timefile); my $res= run_mysqltest($tinfo, $tinfo->{'master_opt'}); @@ -2156,7 +2179,7 @@ Options to run test on running server extern Use running server for tests FIXME DANGEROUS ndbconnectstring=STR Use running cluster, and connect using STR - user=USER The databse user name + user=USER User for connect to server Options for debugging the product @@ -2183,6 +2206,7 @@ Misc options compress Use the compressed protocol between client and server timer Show test case execution time start-and-exit Only initiate and start the "mysqld" servers + start-dirty Only start the "mysqld" servers without initiation fast Don't try to cleanup from earlier runs reorder Reorder tests to get less server restarts help Get this help text diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index ac1755cab9c..5fb4d99d4f4 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -247,7 +247,6 @@ STOP_WAIT_TIMEOUT=10 MYSQL_TEST_SSL_OPTS="" USE_TIMER="" USE_EMBEDDED_SERVER="" -RESULT_EXT="" TEST_MODE="" NDB_MGM_EXTRA_OPTS= @@ -260,7 +259,6 @@ while test $# -gt 0; do USE_EMBEDDED_SERVER=1 USE_MANAGER=0 NO_SLAVE=1 USE_RUNNING_SERVER=0 - RESULT_EXT=".es" TEST_MODE="$TEST_MODE embedded" ;; --purify) USE_PURIFY=1 @@ -418,7 +416,7 @@ while test $# -gt 0; do fi # >=2.1.2 requires the --tool option, some versions write to stdout, some to stderr valgrind --help 2>&1 | grep "\-\-tool" > /dev/null && VALGRIND="$VALGRIND --tool=memcheck" - VALGRIND="$VALGRIND --alignment=8 --leak-check=yes --num-callers=16" + VALGRIND="$VALGRIND --alignment=8 --leak-check=yes --num-callers=16 --suppressions=$CWD/valgrind.supp" EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-safemalloc --skip-bdb" EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc --skip-bdb" SLEEP_TIME_AFTER_RESTART=10 @@ -576,9 +574,9 @@ if [ x$SOURCE_DIST = x1 ] ; then CLIENT_BINDIR="$BASEDIR/client" MYSQLADMIN="$CLIENT_BINDIR/mysqladmin" WAIT_PID="$BASEDIR/extra/mysql_waitpid" - MYSQL_MANAGER_CLIENT="$CLIENT_BINDIR/mysqlmanagerc" - MYSQL_MANAGER="$BASEDIR/tools/mysqlmanager" - MYSQL_MANAGER_PWGEN="$CLIENT_BINDIR/mysqlmanager-pwgen" + MYSQL_MANAGER_CLIENT="$CLIENT_BINDIR/mysqltestmanagerc" + MYSQL_MANAGER="$BASEDIR/tools/mysqltestmanager" + MYSQL_MANAGER_PWGEN="$CLIENT_BINDIR/mysqltestmanager-pwgen" MYSQL="$CLIENT_BINDIR/mysql" LANGUAGE="$BASEDIR/sql/share/english/" CHARSETSDIR="$BASEDIR/sql/share/charsets" @@ -639,9 +637,9 @@ else MYSQL_BINLOG="$CLIENT_BINDIR/mysqlbinlog" MYSQLADMIN="$CLIENT_BINDIR/mysqladmin" WAIT_PID="$CLIENT_BINDIR/mysql_waitpid" - MYSQL_MANAGER="$CLIENT_BINDIR/mysqlmanager" - MYSQL_MANAGER_CLIENT="$CLIENT_BINDIR/mysqlmanagerc" - MYSQL_MANAGER_PWGEN="$CLIENT_BINDIR/mysqlmanager-pwgen" + MYSQL_MANAGER="$CLIENT_BINDIR/mysqltestmanager" + MYSQL_MANAGER_CLIENT="$CLIENT_BINDIR/mysqltestmanagerc" + MYSQL_MANAGER_PWGEN="$CLIENT_BINDIR/mysqltestmanager-pwgen" MYSQL="$CLIENT_BINDIR/mysql" INSTALL_DB="./install_test_db --bin" MYSQL_FIX_SYSTEM_TABLES="$CLIENT_BINDIR/mysql_fix_privilege_tables" @@ -761,13 +759,6 @@ show_failed_diff () result_file=r/$1.result eval_file=r/$1.eval - # If we have an special externsion for result files we use it if we are recording - # or a result file with that extension exists. - if [ -n "$RESULT_EXT" -a \( x$RECORD = x1 -o -f "$result_file$RESULT_EXT" \) ] - then - result_file="$result_file$RESULT_EXT" - fi - if [ -f $eval_file ] then result_file=$eval_file @@ -1188,7 +1179,7 @@ start_master() --default-character-set=$CHARACTER_SET \ --tmpdir=$MYSQL_TMP_DIR \ --language=$LANGUAGE \ - --innodb_data_file_path=ibdata1:50M \ + --innodb_data_file_path=ibdata1:128M:autoextend \ --open-files-limit=1024 \ $MASTER_40_ARGS \ $SMALL_SERVER \ @@ -1209,7 +1200,7 @@ start_master() $USE_NDBCLUSTER \ --tmpdir=$MYSQL_TMP_DIR \ --language=$LANGUAGE \ - --innodb_data_file_path=ibdata1:50M \ + --innodb_data_file_path=ibdata1:128M:autoextend \ $MASTER_40_ARGS \ $SMALL_SERVER \ $EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT \ @@ -1513,9 +1504,6 @@ run_testcase () result_file="r/$tname.result" echo $tname > $CURRENT_TEST SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0 \& \( $tname : federated \) = 0` - if [ -n "$RESULT_EXT" -a \( x$RECORD = x1 -o -f "$result_file$RESULT_EXT" \) ] ; then - result_file="$result_file$RESULT_EXT" - fi if [ "$USE_MANAGER" = 1 ] ; then many_slaves=`$EXPR \( \( $tname : rpl_failsafe \) != 0 \) \| \( \( $tname : rpl_chain_temp_table \) != 0 \)` fi @@ -1573,33 +1561,8 @@ run_testcase () # script soon anyway so it is not worth it spending the time if [ "x$USE_EMBEDDED_SERVER" = "x1" -a -z "$DO_TEST" ] ; then for t in \ - "alter_table" \ - "bdb-deadlock" \ - "connect" \ - "ctype_latin1_de" \ - "ctype_ucs" \ - "flush_block_commit" \ - "grant2" \ - "grant_cache" \ - "grant" \ - "init_connect" \ - "init_file" \ - "innodb" \ - "innodb-deadlock" \ - "innodb-lock" \ - "mix_innodb_myisam_binlog" \ - "mysqlbinlog2" \ - "mysqlbinlog" \ - "mysqldump" \ - "mysql_protocols" \ - "packet" \ - "ps_1general" \ - "rename" \ - "show_check" \ - "system_mysql_db_fix" \ - "timezone2" \ - "user_var" \ - "variables" + "init_connect" \ + "init_file" do if [ "$tname" = "$t" ] ; then skip_test $tname @@ -1623,10 +1586,8 @@ run_testcase () --result-file=*) result_file=`$ECHO "$EXTRA_MASTER_OPT" | $SED -e "s;--result-file=;;"` result_file="r/$result_file.result" - if [ -n "$RESULT_EXT" -a \( x$RECORD = x1 -o -f "$result_file$RESULT_EXT" \) ] ; then - result_file="$result_file$RESULT_EXT" - fi - # Note that this must be set to space, not "" for test-reset to work + # Note that this must be set to space, not "" for test-reset to +# work EXTRA_MASTER_OPT=" " ;; esac diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 03d0ebf5433..88b04b292ea 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -52,9 +52,9 @@ KEY NAME (NAME)); ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null; SHOW FULL COLUMNS FROM t1; Field Type Collation Null Key Default Extra Privileges Comment -GROUP_ID int(10) unsigned NULL NO PRI 0 select,insert,update,references -LANG_ID smallint(5) unsigned NULL NO PRI 0 select,insert,update,references -NAME char(80) latin1_swedish_ci NO MUL select,insert,update,references +GROUP_ID int(10) unsigned NULL NO PRI 0 # +LANG_ID smallint(5) unsigned NULL NO PRI 0 # +NAME char(80) latin1_swedish_ci NO MUL # DROP TABLE t1; create table t1 (n int); insert into t1 values(9),(3),(12),(10); @@ -117,14 +117,6 @@ name mysqltest drop table t1; drop database mysqltest; -create database mysqltest; -create table mysqltest.t1 (a int,b int,c int); -grant all on mysqltest.t1 to mysqltest_1@localhost; -alter table t1 rename t2; -ERROR 42000: INSERT,CREATE command denied to user 'mysqltest_1'@'localhost' for table 't2' -revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; -delete from mysql.user where user=_binary'mysqltest_1'; -drop database mysqltest; create table t1 (n1 int not null, n2 int, n3 int, n4 float, unique(n1), key (n1, n2, n3, n4), diff --git a/mysql-test/r/alter_table.result.es b/mysql-test/r/alter_table.result.es deleted file mode 100644 index 4f93b40a573..00000000000 --- a/mysql-test/r/alter_table.result.es +++ /dev/null @@ -1,483 +0,0 @@ -drop table if exists t1,t2; -drop database if exists mysqltest; -create table t1 ( -col1 int not null auto_increment primary key, -col2 varchar(30) not null, -col3 varchar (20) not null, -col4 varchar(4) not null, -col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null, -col6 int not null, to_be_deleted int); -insert into t1 values (2,4,3,5,"PENDING",1,7); -alter table t1 -add column col4_5 varchar(20) not null after col4, -add column col7 varchar(30) not null after col5, -add column col8 datetime not null, drop column to_be_deleted, -change column col2 fourth varchar(30) not null after col3, -modify column col6 int not null first; -select * from t1; -col6 col1 col3 fourth col4 col4_5 col5 col7 col8 -1 2 3 4 5 PENDING 0000-00-00 00:00:00 -drop table t1; -create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL); -insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12); -alter table t1 add column new_col int, order by payoutid,bandid; -select * from t1; -bandID payoutID new_col -6 1 NULL -3 4 NULL -1 6 NULL -2 6 NULL -4 9 NULL -5 10 NULL -7 12 NULL -8 12 NULL -alter table t1 order by bandid,payoutid; -select * from t1; -bandID payoutID new_col -1 6 NULL -2 6 NULL -3 4 NULL -4 9 NULL -5 10 NULL -6 1 NULL -7 12 NULL -8 12 NULL -drop table t1; -CREATE TABLE t1 ( -GROUP_ID int(10) unsigned DEFAULT '0' NOT NULL, -LANG_ID smallint(5) unsigned DEFAULT '0' NOT NULL, -NAME varchar(80) DEFAULT '' NOT NULL, -PRIMARY KEY (GROUP_ID,LANG_ID), -KEY NAME (NAME)); -ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null; -SHOW FULL COLUMNS FROM t1; -Field Type Collation Null Key Default Extra Privileges Comment -GROUP_ID int(10) unsigned NULL PRI 0 -LANG_ID smallint(5) unsigned NULL PRI 0 -NAME char(80) latin1_swedish_ci MUL -DROP TABLE t1; -create table t1 (n int); -insert into t1 values(9),(3),(12),(10); -alter table t1 order by n; -select * from t1; -n -3 -9 -10 -12 -drop table t1; -CREATE TABLE t1 ( -id int(11) unsigned NOT NULL default '0', -category_id tinyint(4) unsigned NOT NULL default '0', -type_id tinyint(4) unsigned NOT NULL default '0', -body text NOT NULL, -user_id int(11) unsigned NOT NULL default '0', -status enum('new','old') NOT NULL default 'new', -PRIMARY KEY (id) -) ENGINE=MyISAM; -ALTER TABLE t1 ORDER BY t1.id, t1.status, t1.type_id, t1.user_id, t1.body; -DROP TABLE t1; -CREATE TABLE t1 (AnamneseId int(10) unsigned NOT NULL auto_increment,B BLOB,PRIMARY KEY (AnamneseId)) engine=myisam; -insert into t1 values (null,"hello"); -LOCK TABLES t1 WRITE; -ALTER TABLE t1 ADD Column new_col int not null; -UNLOCK TABLES; -OPTIMIZE TABLE t1; -Table Op Msg_type Msg_text -test.t1 optimize status OK -DROP TABLE t1; -create table t1 (i int unsigned not null auto_increment primary key); -insert into t1 values (null),(null),(null),(null); -alter table t1 drop i,add i int unsigned not null auto_increment, drop primary key, add primary key (i); -select * from t1; -i -1 -2 -3 -4 -drop table t1; -create table t1 (name char(15)); -insert into t1 (name) values ("current"); -create database mysqltest; -create table mysqltest.t1 (name char(15)); -insert into mysqltest.t1 (name) values ("mysqltest"); -select * from t1; -name -current -select * from mysqltest.t1; -name -mysqltest -alter table t1 rename mysqltest.t1; -ERROR 42S01: Table 't1' already exists -select * from t1; -name -current -select * from mysqltest.t1; -name -mysqltest -drop table t1; -drop database mysqltest; -create database mysqltest; -create table mysqltest.t1 (a int,b int,c int); -grant all on mysqltest.t1 to mysqltest_1@localhost; -alter table t1 rename t2; -revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; -delete from mysql.user where user=_binary'mysqltest_1'; -drop database mysqltest; -create table t1 (n1 int not null, n2 int, n3 int, n4 float, -unique(n1), -key (n1, n2, n3, n4), -key (n2, n3, n4, n1), -key (n3, n4, n1, n2), -key (n4, n1, n2, n3) ); -alter table t1 disable keys; -show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 n1 1 n1 A 0 NULL NULL BTREE -t1 1 n1_2 1 n1 A NULL NULL NULL BTREE disabled -t1 1 n1_2 2 n2 A NULL NULL NULL YES BTREE disabled -t1 1 n1_2 3 n3 A NULL NULL NULL YES BTREE disabled -t1 1 n1_2 4 n4 A NULL NULL NULL YES BTREE disabled -t1 1 n2 1 n2 A NULL NULL NULL YES BTREE disabled -t1 1 n2 2 n3 A NULL NULL NULL YES BTREE disabled -t1 1 n2 3 n4 A NULL NULL NULL YES BTREE disabled -t1 1 n2 4 n1 A NULL NULL NULL BTREE disabled -t1 1 n3 1 n3 A NULL NULL NULL YES BTREE disabled -t1 1 n3 2 n4 A NULL NULL NULL YES BTREE disabled -t1 1 n3 3 n1 A NULL NULL NULL BTREE disabled -t1 1 n3 4 n2 A NULL NULL NULL YES BTREE disabled -t1 1 n4 1 n4 A NULL NULL NULL YES BTREE disabled -t1 1 n4 2 n1 A NULL NULL NULL BTREE disabled -t1 1 n4 3 n2 A NULL NULL NULL YES BTREE disabled -t1 1 n4 4 n3 A NULL NULL NULL YES BTREE disabled -insert into t1 values(10,RAND()*1000,RAND()*1000,RAND()); -insert into t1 values(9,RAND()*1000,RAND()*1000,RAND()); -insert into t1 values(8,RAND()*1000,RAND()*1000,RAND()); -insert into t1 values(7,RAND()*1000,RAND()*1000,RAND()); -insert into t1 values(6,RAND()*1000,RAND()*1000,RAND()); -insert into t1 values(5,RAND()*1000,RAND()*1000,RAND()); -insert into t1 values(4,RAND()*1000,RAND()*1000,RAND()); -insert into t1 values(3,RAND()*1000,RAND()*1000,RAND()); -insert into t1 values(2,RAND()*1000,RAND()*1000,RAND()); -insert into t1 values(1,RAND()*1000,RAND()*1000,RAND()); -alter table t1 enable keys; -show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 n1 1 n1 A 10 NULL NULL BTREE -t1 1 n1_2 1 n1 A 10 NULL NULL BTREE -t1 1 n1_2 2 n2 A 10 NULL NULL YES BTREE -t1 1 n1_2 3 n3 A 10 NULL NULL YES BTREE -t1 1 n1_2 4 n4 A 10 NULL NULL YES BTREE -t1 1 n2 1 n2 A 10 NULL NULL YES BTREE -t1 1 n2 2 n3 A 10 NULL NULL YES BTREE -t1 1 n2 3 n4 A 10 NULL NULL YES BTREE -t1 1 n2 4 n1 A 10 NULL NULL BTREE -t1 1 n3 1 n3 A 10 NULL NULL YES BTREE -t1 1 n3 2 n4 A 10 NULL NULL YES BTREE -t1 1 n3 3 n1 A 10 NULL NULL BTREE -t1 1 n3 4 n2 A 10 NULL NULL YES BTREE -t1 1 n4 1 n4 A 10 NULL NULL YES BTREE -t1 1 n4 2 n1 A 10 NULL NULL BTREE -t1 1 n4 3 n2 A 10 NULL NULL YES BTREE -t1 1 n4 4 n3 A 10 NULL NULL YES BTREE -drop table t1; -create table t1 (i int unsigned not null auto_increment primary key); -alter table t1 rename t2; -alter table t2 rename t1, add c char(10) comment "no comment"; -show columns from t1; -Field Type Null Key Default Extra -i int(10) unsigned PRI NULL auto_increment -c char(10) YES NULL -drop table t1; -create table t1 (a int, b int); -insert into t1 values(1,100), (2,100), (3, 100); -insert into t1 values(1,99), (2,99), (3, 99); -insert into t1 values(1,98), (2,98), (3, 98); -insert into t1 values(1,97), (2,97), (3, 97); -insert into t1 values(1,96), (2,96), (3, 96); -insert into t1 values(1,95), (2,95), (3, 95); -insert into t1 values(1,94), (2,94), (3, 94); -insert into t1 values(1,93), (2,93), (3, 93); -insert into t1 values(1,92), (2,92), (3, 92); -insert into t1 values(1,91), (2,91), (3, 91); -insert into t1 values(1,90), (2,90), (3, 90); -insert into t1 values(1,89), (2,89), (3, 89); -insert into t1 values(1,88), (2,88), (3, 88); -insert into t1 values(1,87), (2,87), (3, 87); -insert into t1 values(1,86), (2,86), (3, 86); -insert into t1 values(1,85), (2,85), (3, 85); -insert into t1 values(1,84), (2,84), (3, 84); -insert into t1 values(1,83), (2,83), (3, 83); -insert into t1 values(1,82), (2,82), (3, 82); -insert into t1 values(1,81), (2,81), (3, 81); -insert into t1 values(1,80), (2,80), (3, 80); -insert into t1 values(1,79), (2,79), (3, 79); -insert into t1 values(1,78), (2,78), (3, 78); -insert into t1 values(1,77), (2,77), (3, 77); -insert into t1 values(1,76), (2,76), (3, 76); -insert into t1 values(1,75), (2,75), (3, 75); -insert into t1 values(1,74), (2,74), (3, 74); -insert into t1 values(1,73), (2,73), (3, 73); -insert into t1 values(1,72), (2,72), (3, 72); -insert into t1 values(1,71), (2,71), (3, 71); -insert into t1 values(1,70), (2,70), (3, 70); -insert into t1 values(1,69), (2,69), (3, 69); -insert into t1 values(1,68), (2,68), (3, 68); -insert into t1 values(1,67), (2,67), (3, 67); -insert into t1 values(1,66), (2,66), (3, 66); -insert into t1 values(1,65), (2,65), (3, 65); -insert into t1 values(1,64), (2,64), (3, 64); -insert into t1 values(1,63), (2,63), (3, 63); -insert into t1 values(1,62), (2,62), (3, 62); -insert into t1 values(1,61), (2,61), (3, 61); -insert into t1 values(1,60), (2,60), (3, 60); -insert into t1 values(1,59), (2,59), (3, 59); -insert into t1 values(1,58), (2,58), (3, 58); -insert into t1 values(1,57), (2,57), (3, 57); -insert into t1 values(1,56), (2,56), (3, 56); -insert into t1 values(1,55), (2,55), (3, 55); -insert into t1 values(1,54), (2,54), (3, 54); -insert into t1 values(1,53), (2,53), (3, 53); -insert into t1 values(1,52), (2,52), (3, 52); -insert into t1 values(1,51), (2,51), (3, 51); -insert into t1 values(1,50), (2,50), (3, 50); -insert into t1 values(1,49), (2,49), (3, 49); -insert into t1 values(1,48), (2,48), (3, 48); -insert into t1 values(1,47), (2,47), (3, 47); -insert into t1 values(1,46), (2,46), (3, 46); -insert into t1 values(1,45), (2,45), (3, 45); -insert into t1 values(1,44), (2,44), (3, 44); -insert into t1 values(1,43), (2,43), (3, 43); -insert into t1 values(1,42), (2,42), (3, 42); -insert into t1 values(1,41), (2,41), (3, 41); -insert into t1 values(1,40), (2,40), (3, 40); -insert into t1 values(1,39), (2,39), (3, 39); -insert into t1 values(1,38), (2,38), (3, 38); -insert into t1 values(1,37), (2,37), (3, 37); -insert into t1 values(1,36), (2,36), (3, 36); -insert into t1 values(1,35), (2,35), (3, 35); -insert into t1 values(1,34), (2,34), (3, 34); -insert into t1 values(1,33), (2,33), (3, 33); -insert into t1 values(1,32), (2,32), (3, 32); -insert into t1 values(1,31), (2,31), (3, 31); -insert into t1 values(1,30), (2,30), (3, 30); -insert into t1 values(1,29), (2,29), (3, 29); -insert into t1 values(1,28), (2,28), (3, 28); -insert into t1 values(1,27), (2,27), (3, 27); -insert into t1 values(1,26), (2,26), (3, 26); -insert into t1 values(1,25), (2,25), (3, 25); -insert into t1 values(1,24), (2,24), (3, 24); -insert into t1 values(1,23), (2,23), (3, 23); -insert into t1 values(1,22), (2,22), (3, 22); -insert into t1 values(1,21), (2,21), (3, 21); -insert into t1 values(1,20), (2,20), (3, 20); -insert into t1 values(1,19), (2,19), (3, 19); -insert into t1 values(1,18), (2,18), (3, 18); -insert into t1 values(1,17), (2,17), (3, 17); -insert into t1 values(1,16), (2,16), (3, 16); -insert into t1 values(1,15), (2,15), (3, 15); -insert into t1 values(1,14), (2,14), (3, 14); -insert into t1 values(1,13), (2,13), (3, 13); -insert into t1 values(1,12), (2,12), (3, 12); -insert into t1 values(1,11), (2,11), (3, 11); -insert into t1 values(1,10), (2,10), (3, 10); -insert into t1 values(1,9), (2,9), (3, 9); -insert into t1 values(1,8), (2,8), (3, 8); -insert into t1 values(1,7), (2,7), (3, 7); -insert into t1 values(1,6), (2,6), (3, 6); -insert into t1 values(1,5), (2,5), (3, 5); -insert into t1 values(1,4), (2,4), (3, 4); -insert into t1 values(1,3), (2,3), (3, 3); -insert into t1 values(1,2), (2,2), (3, 2); -insert into t1 values(1,1), (2,1), (3, 1); -alter table t1 add unique (a,b), add key (b); -show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 a 1 a A NULL NULL NULL YES BTREE -t1 0 a 2 b A NULL NULL NULL YES BTREE -t1 1 b 1 b A 100 NULL NULL YES BTREE -analyze table t1; -Table Op Msg_type Msg_text -test.t1 analyze status OK -show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 a 1 a A 3 NULL NULL YES BTREE -t1 0 a 2 b A 300 NULL NULL YES BTREE -t1 1 b 1 b A 100 NULL NULL YES BTREE -drop table t1; -CREATE TABLE t1 (i int(10), index(i) ); -ALTER TABLE t1 DISABLE KEYS; -INSERT DELAYED INTO t1 VALUES(1),(2),(3); -ALTER TABLE t1 ENABLE KEYS; -drop table t1; -set names koi8r; -create table t1 (a char(10) character set koi8r); -insert into t1 values ('ÔÅÓÔ'); -select a,hex(a) from t1; -a hex(a) -ÔÅÓÔ D4C5D3D4 -alter table t1 change a a char(10) character set cp1251; -select a,hex(a) from t1; -a hex(a) -ÔÅÓÔ F2E5F1F2 -alter table t1 change a a binary(10); -select a,hex(a) from t1; -a hex(a) -òåñò F2E5F1F2 -alter table t1 change a a char(10) character set cp1251; -select a,hex(a) from t1; -a hex(a) -ÔÅÓÔ F2E5F1F2 -alter table t1 change a a char(10) character set koi8r; -select a,hex(a) from t1; -a hex(a) -ÔÅÓÔ D4C5D3D4 -alter table t1 change a a varchar(10) character set cp1251; -select a,hex(a) from t1; -a hex(a) -ÔÅÓÔ F2E5F1F2 -alter table t1 change a a char(10) character set koi8r; -select a,hex(a) from t1; -a hex(a) -ÔÅÓÔ D4C5D3D4 -alter table t1 change a a text character set cp1251; -select a,hex(a) from t1; -a hex(a) -ÔÅÓÔ F2E5F1F2 -alter table t1 change a a char(10) character set koi8r; -select a,hex(a) from t1; -a hex(a) -ÔÅÓÔ D4C5D3D4 -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` char(10) character set koi8r default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -alter table t1 DEFAULT CHARACTER SET latin1; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` char(10) character set koi8r default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -alter table t1 CONVERT TO CHARACTER SET latin1; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` char(10) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -alter table t1 DEFAULT CHARACTER SET cp1251; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` char(10) character set latin1 default NULL -) ENGINE=MyISAM DEFAULT CHARSET=cp1251 -drop table t1; -create table t1 (myblob longblob,mytext longtext) -default charset latin1 collate latin1_general_cs; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `myblob` longblob, - `mytext` longtext collate latin1_general_cs -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs -alter table t1 character set latin2; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `myblob` longblob, - `mytext` longtext character set latin1 collate latin1_general_cs -) ENGINE=MyISAM DEFAULT CHARSET=latin2 -drop table t1; -CREATE TABLE t1 ( -Host varchar(16) binary NOT NULL default '', -User varchar(16) binary NOT NULL default '', -PRIMARY KEY (Host,User) -) ENGINE=MyISAM; -ALTER TABLE t1 DISABLE KEYS; -LOCK TABLES t1 WRITE; -INSERT INTO t1 VALUES ('localhost','root'),('localhost',''),('games','monty'); -SHOW INDEX FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE -t1 0 PRIMARY 2 User A 3 NULL NULL BTREE -ALTER TABLE t1 ENABLE KEYS; -UNLOCK TABLES; -CHECK TABLES t1; -Table Op Msg_type Msg_text -test.t1 check status OK -DROP TABLE t1; -CREATE TABLE t1 ( -Host varchar(16) binary NOT NULL default '', -User varchar(16) binary NOT NULL default '', -PRIMARY KEY (Host,User), -KEY (Host) -) ENGINE=MyISAM; -ALTER TABLE t1 DISABLE KEYS; -SHOW INDEX FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE -t1 0 PRIMARY 2 User A 0 NULL NULL BTREE -t1 1 Host 1 Host A NULL NULL NULL BTREE disabled -LOCK TABLES t1 WRITE; -INSERT INTO t1 VALUES ('localhost','root'),('localhost',''); -SHOW INDEX FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE -t1 0 PRIMARY 2 User A 2 NULL NULL BTREE -t1 1 Host 1 Host A NULL NULL NULL BTREE disabled -ALTER TABLE t1 ENABLE KEYS; -SHOW INDEX FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE -t1 0 PRIMARY 2 User A 2 NULL NULL BTREE -t1 1 Host 1 Host A 1 NULL NULL BTREE -UNLOCK TABLES; -CHECK TABLES t1; -Table Op Msg_type Msg_text -test.t1 check status OK -LOCK TABLES t1 WRITE; -ALTER TABLE t1 RENAME t2; -UNLOCK TABLES; -select * from t2; -Host User -localhost -localhost root -DROP TABLE t2; -CREATE TABLE t1 ( -Host varchar(16) binary NOT NULL default '', -User varchar(16) binary NOT NULL default '', -PRIMARY KEY (Host,User), -KEY (Host) -) ENGINE=MyISAM; -LOCK TABLES t1 WRITE; -ALTER TABLE t1 DISABLE KEYS; -SHOW INDEX FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE -t1 0 PRIMARY 2 User A 0 NULL NULL BTREE -t1 1 Host 1 Host A NULL NULL NULL BTREE disabled -DROP TABLE t1; -CREATE TABLE t1 (a int PRIMARY KEY, b INT UNIQUE); -ALTER TABLE t1 DROP PRIMARY KEY; -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) NOT NULL default '0', - `b` int(11) default NULL, - UNIQUE KEY `b` (`b`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -ALTER TABLE t1 DROP PRIMARY KEY; -ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists -DROP TABLE t1; -create table t1 (a int, b int, key(a)); -insert into t1 values (1,1), (2,2); -alter table t1 drop key no_such_key; -ERROR 42000: Can't DROP 'no_such_key'; check that column/key exists -alter table t1 drop key a; -drop table t1; -create table t1 (a int); -alter table t1 rename to `t1\\`; -ERROR 42000: Incorrect table name 't1\\' -rename table t1 to `t1\\`; -ERROR 42000: Incorrect table name 't1\\' -drop table t1; diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result index 50e99e3ecd7..e372c307ba7 100644 --- a/mysql-test/r/bigint.result +++ b/mysql-test/r/bigint.result @@ -87,6 +87,8 @@ drop table t1; SELECT '0x8000000000000001'+0; '0x8000000000000001'+0 0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '0x8000000000000001' create table t1 ( value64 bigint unsigned not null, value32 integer not null, diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index b015648534b..feefd47c611 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -7,6 +7,9 @@ CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER) select CONVERT('-1',UNSIGNED); CONVERT('-1',UNSIGNED) 18446744073709551615 +select CAST('10 ' as unsigned integer); +CAST('10 ' as unsigned integer) +10 select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1; cast(-5 as unsigned) | 1 cast(-5 as unsigned) & -1 18446744073709551611 18446744073709551611 @@ -42,6 +45,15 @@ cast("1:2:3" as TIME) select CONVERT("2004-01-22 21:45:33",DATE); CONVERT("2004-01-22 21:45:33",DATE) 2004-01-22 +select 10+'10'; +10+'10' +20 +select 10.0+'10'; +10.0+'10' +20 +select 10E+0+'10'; +10E+0+'10' +20 select CONVERT(DATE "2004-01-22 21:45:33" USING latin1); CONVERT(DATE "2004-01-22 21:45:33" USING latin1) 2004-01-22 21:45:33 @@ -51,12 +63,43 @@ CONVERT(DATE "2004-01-22 21:45:33",CHAR) select CONVERT(DATE "2004-01-22 21:45:33",CHAR(4)); CONVERT(DATE "2004-01-22 21:45:33",CHAR(4)) 2004 +Warnings: +Warning 1292 Truncated incorrect CHAR(4) value: '2004-01-22 21:45:33' select CONVERT(DATE "2004-01-22 21:45:33",BINARY(4)); CONVERT(DATE "2004-01-22 21:45:33",BINARY(4)) 2004 +Warnings: +Warning 1292 Truncated incorrect CHAR(4) value: '2004-01-22 21:45:33' select CAST(DATE "2004-01-22 21:45:33" AS BINARY(4)); CAST(DATE "2004-01-22 21:45:33" AS BINARY(4)) 2004 +Warnings: +Warning 1292 Truncated incorrect CHAR(4) value: '2004-01-22 21:45:33' +select cast('-10a' as signed integer); +cast('-10a' as signed integer) +-10 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '-10a' +select cast('a10' as unsigned integer); +cast('a10' as unsigned integer) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'a10' +select 10+'a'; +10+'a' +10 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' +select 10.0+cast('a' as decimal); +10.0+cast('a' as decimal) +10.00 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'a' +select 10E+0+'a'; +10E+0+'a' +10 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'a' set names binary; select cast(_latin1'test' as char character set latin2); cast(_latin1'test' as char character set latin2) @@ -79,12 +122,23 @@ cast(_latin1'a ' AS char(2)) as c4, cast(_latin1'a' AS char(2)) as c5; c1 c2 c3 c4 c5 ab a ab a a +Warnings: +Warning 1292 Truncated incorrect CHAR(2) value: 'abc' +Warning 1292 Truncated incorrect CHAR(2) value: 'a ' +select cast(1000 as CHAR(3)); +cast(1000 as CHAR(3)) +100 +Warnings: +Warning 1292 Truncated incorrect CHAR(3) value: '1000' create table t1 select cast(_latin1'ab' AS char) as c1, cast(_latin1'a ' AS char) as c2, cast(_latin1'abc' AS char(2)) as c3, cast(_latin1'a ' AS char(2)) as c4, cast(_latin1'a' AS char(2)) as c5; +Warnings: +Warning 1292 Truncated incorrect CHAR(2) value: 'abc' +Warning 1292 Truncated incorrect CHAR(2) value: 'a ' select * from t1; c1 c2 c3 c4 c5 ab a ab a a @@ -106,12 +160,18 @@ cast(_koi8r' cast(_koi8r'Æ' AS nchar(2)) as c5; c1 c2 c3 c4 c5 фг Ñ„ фг Ñ„ Ñ„ +Warnings: +Warning 1292 Truncated incorrect CHAR(4) value: 'фгх' +Warning 1292 Truncated incorrect CHAR(3) value: 'Ñ„ ' create table t1 select cast(_koi8r'ÆÇ' AS nchar) as c1, cast(_koi8r'Æ ' AS nchar) as c2, cast(_koi8r'ÆÇÈ' AS nchar(2)) as c3, cast(_koi8r'Æ ' AS nchar(2)) as c4, cast(_koi8r'Æ' AS nchar(2)) as c5; +Warnings: +Warning 1292 Truncated incorrect CHAR(4) value: 'фгх' +Warning 1292 Truncated incorrect CHAR(3) value: 'Ñ„ ' select * from t1; c1 c2 c3 c4 c5 фг Ñ„ фг Ñ„ Ñ„ @@ -167,6 +227,10 @@ a CAST(a AS CHAR(3)) aac aac aab aab aaa aaa +Warnings: +Warning 1292 Truncated incorrect CHAR(2) value: 'aaa' +Warning 1292 Truncated incorrect CHAR(2) value: 'aab' +Warning 1292 Truncated incorrect CHAR(2) value: 'aac' SELECT a, CAST(a AS UNSIGNED) FROM t1 ORDER BY CAST(a AS CHAR) ; a CAST(a AS UNSIGNED) aaa 3 @@ -177,6 +241,10 @@ a CAST(a AS CHAR(2)) aaa aa aab aa aac aa +Warnings: +Warning 1292 Truncated incorrect CHAR(2) value: 'aaa' +Warning 1292 Truncated incorrect CHAR(2) value: 'aab' +Warning 1292 Truncated incorrect CHAR(2) value: 'aac' DROP TABLE t1; select date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour); date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 1c378f88e5c..cafe6f23ccf 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -44,12 +44,24 @@ create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ERROR 42000: Incorrect table name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int); ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long -create table test (a datetime default now()); +create table t1 (a datetime default now()); ERROR 42000: Invalid default value for 'a' -create table test (a datetime on update now()); +create table t1 (a datetime on update now()); ERROR HY000: Invalid ON UPDATE clause for 'a' column -create table test (a int default 100 auto_increment); +create table t1 (a int default 100 auto_increment); ERROR 42000: Invalid default value for 'a' +create table t1 (a tinyint default 1000); +ERROR 42000: Invalid default value for 'a' +create table t1 (a varchar(5) default 'abcdef'); +ERROR 42000: Invalid default value for 'a' +create table t1 (a varchar(5) default 'abcde'); +insert into t1 values(); +select * from t1; +a +abcde +alter table t1 alter column a set default 'abcdef'; +ERROR 42000: Invalid default value for 'a' +drop table t1; create table 1ea10 (1a20 int,1e int); insert into 1ea10 values(1,1); select 1ea10.1a20,1e+ 1e+10 from 1ea10; @@ -255,11 +267,15 @@ drop table t1; create table t1 (a int not null, b int, primary key (a)); insert into t1 values (1,1); create table if not exists t1 select 2; +Warnings: +Warning 1364 Field 'a' doesn't have a default value select * from t1; a b 1 1 0 2 create table if not exists t1 select 3 as 'a',4 as 'b'; +Warnings: +Warning 1364 Field 'a' doesn't have a default value create table if not exists t1 select 3 as 'a',3 as 'b'; ERROR 23000: Duplicate entry '3' for key 1 select * from t1; diff --git a/mysql-test/r/ctype_collate.result b/mysql-test/r/ctype_collate.result index e3130888a05..66266d40fb3 100644 --- a/mysql-test/r/ctype_collate.result +++ b/mysql-test/r/ctype_collate.result @@ -535,6 +535,19 @@ s2 CHAR(5) COLLATE latin1_swedish_ci); SELECT * FROM t1 WHERE s1 = s2; ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' DROP TABLE t1; +CREATE TABLE t1 +(s1 CHAR(5) COLLATE latin1_german1_ci, +s2 CHAR(5) COLLATE latin1_swedish_ci, +s3 CHAR(5) COLLATE latin1_bin); +INSERT INTO t1 VALUES ('a','A','A'); +SELECT * FROM t1 WHERE s1 = s2; +ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '=' +SELECT * FROM t1 WHERE s1 = s3; +s1 s2 s3 +SELECT * FROM t1 WHERE s2 = s3; +s1 s2 s3 +a A A +DROP TABLE t1; SET NAMES latin1; CREATE TABLE t1 (s1 char(10) COLLATE latin1_german1_ci, diff --git a/mysql-test/r/ctype_latin1_de.result b/mysql-test/r/ctype_latin1_de.result index 5e885d006cb..43947edbd48 100644 --- a/mysql-test/r/ctype_latin1_de.result +++ b/mysql-test/r/ctype_latin1_de.result @@ -220,12 +220,12 @@ select * from t1 where match a against ("te*" in boolean mode)+0; a test drop table t1; -create table t1 (word varchar(255) not null, word2 varchar(255) not null, index(word)); +create table t1 (word varchar(255) not null, word2 varchar(255) not null default '', index(word)); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `word` varchar(255) collate latin1_german2_ci NOT NULL, - `word2` varchar(255) collate latin1_german2_ci NOT NULL, + `word2` varchar(255) collate latin1_german2_ci NOT NULL default '', KEY `word` (`word`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci insert into t1 (word) values ('ss'),(0xDF),(0xE4),('ae'); diff --git a/mysql-test/r/ctype_many.result b/mysql-test/r/ctype_many.result index 5932bd75787..87b83acfe0f 100644 --- a/mysql-test/r/ctype_many.result +++ b/mysql-test/r/ctype_many.result @@ -2,27 +2,27 @@ DROP TABLE IF EXISTS t1; SET CHARACTER SET latin1; CREATE TABLE t1 ( comment CHAR(32) ASCII NOT NULL, -koi8_ru_f CHAR(32) CHARACTER SET koi8r NOT NULL +koi8_ru_f CHAR(32) CHARACTER SET koi8r NOT NULL default '' ) CHARSET=latin5; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `comment` char(32) character set latin1 NOT NULL, - `koi8_ru_f` char(32) character set koi8r NOT NULL + `koi8_ru_f` char(32) character set koi8r NOT NULL default '' ) ENGINE=MyISAM DEFAULT CHARSET=latin5 ALTER TABLE t1 CHANGE comment comment CHAR(32) CHARACTER SET latin2 NOT NULL; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `comment` char(32) character set latin2 NOT NULL, - `koi8_ru_f` char(32) character set koi8r NOT NULL + `koi8_ru_f` char(32) character set koi8r NOT NULL default '' ) ENGINE=MyISAM DEFAULT CHARSET=latin5 ALTER TABLE t1 ADD latin5_f CHAR(32) NOT NULL; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `comment` char(32) character set latin2 NOT NULL, - `koi8_ru_f` char(32) character set koi8r NOT NULL, + `koi8_ru_f` char(32) character set koi8r NOT NULL default '', `latin5_f` char(32) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin5 ALTER TABLE t1 DEFAULT CHARSET=latin2; @@ -31,7 +31,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `comment` char(32) NOT NULL, - `koi8_ru_f` char(32) character set koi8r NOT NULL, + `koi8_ru_f` char(32) character set koi8r NOT NULL default '', `latin5_f` char(32) character set latin5 NOT NULL, `latin2_f` char(32) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin2 @@ -40,7 +40,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `comment` char(32) NOT NULL, - `koi8_ru_f` char(32) character set koi8r NOT NULL + `koi8_ru_f` char(32) character set koi8r NOT NULL default '' ) ENGINE=MyISAM DEFAULT CHARSET=latin2 INSERT INTO t1 (koi8_ru_f,comment) VALUES ('a','LAT SMALL A'); INSERT INTO t1 (koi8_ru_f,comment) VALUES ('b','LAT SMALL B'); @@ -219,7 +219,7 @@ z LAT CAPIT Z 2 Ñ CYR CAPIT E 2 ÑŽ CYR CAPIT YU 2 Ñ CYR CAPIT YA 2 -ALTER TABLE t1 ADD utf8_f CHAR(32) CHARACTER SET utf8 NOT NULL; +ALTER TABLE t1 ADD utf8_f CHAR(32) CHARACTER SET utf8 NOT NULL default ''; UPDATE t1 SET utf8_f=CONVERT(koi8_ru_f USING utf8); SET CHARACTER SET koi8r; SELECT * FROM t1; @@ -340,7 +340,7 @@ CYR CAPIT SOFT SIGN CYR CAPIT E ü ü CYR CAPIT YU à à CYR CAPIT YA ñ ñ -ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL; +ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL default ''; UPDATE t1 SET bin_f=koi8_ru_f; SELECT COUNT(DISTINCT bin_f),COUNT(DISTINCT koi8_ru_f),COUNT(DISTINCT utf8_f) FROM t1; COUNT(DISTINCT bin_f) COUNT(DISTINCT koi8_ru_f) COUNT(DISTINCT utf8_f) diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result index dd5a7ebf6a4..c6e803904a3 100644 --- a/mysql-test/r/ctype_uca.result +++ b/mysql-test/r/ctype_uca.result @@ -1759,8 +1759,8 @@ P,p Ƥ,Æ¥ Q,q ĸ -R,RR,Rr,r,rr,Å”,Å•,Å–,Å—,Ř,Å™ -rR +R,r,Å”,Å•,Å–,Å—,Ř,Å™ +RR,Rr,rR,rr Ʀ S,s,Åš,Å›,Åœ,Å,Åž,ÅŸ,Å ,Å¡,Å¿ SS,Ss,sS,ss,ß diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 868bdd90051..b251044d48b 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -518,28 +518,6 @@ prepare stmt1 from @str2; execute stmt1 using @ivar; ? 1234 -SET TIMESTAMP=10000; -create table t2 (c char(30)) charset=ucs2; -set @v=convert('abc' using ucs2); -reset master; -insert into t2 values (@v); -show binlog events from 98; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # User var 1 # @`v`=_ucs2 0x006100620063 COLLATE ucs2_general_ci -master-bin.000001 # Query 1 # use `test`; insert into t2 values (@v) -/*!40019 SET @@session.max_insert_delayed_threads=0*/; -/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; -ROLLBACK; -SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`; -use test; -SET TIMESTAMP=10000; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; -SET @@session.sql_mode=0; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; -insert into t2 values (@v); -ROLLBACK; -/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; -drop table t2; set names latin1; create table t1 (a enum('x','y','z') character set ucs2); show create table t1; diff --git a/mysql-test/r/ctype_ucs_binlog.result b/mysql-test/r/ctype_ucs_binlog.result new file mode 100644 index 00000000000..4267e495959 --- /dev/null +++ b/mysql-test/r/ctype_ucs_binlog.result @@ -0,0 +1,22 @@ +SET TIMESTAMP=10000; +create table t2 (c char(30)) charset=ucs2; +set @v=convert('abc' using ucs2); +reset master; +insert into t2 values (@v); +show binlog events from 98; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 98 User var 1 138 @`v`=_ucs2 0x006100620063 COLLATE ucs2_general_ci +master-bin.000001 138 Query 1 227 use `test`; insert into t2 values (@v) +/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; +ROLLBACK; +SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`; +use test; +SET TIMESTAMP=10000; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; +SET @@session.sql_mode=0; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; +insert into t2 values (@v); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; +drop table t2; diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result index 901871f437e..979e5d48871 100644 --- a/mysql-test/r/drop.result +++ b/mysql-test/r/drop.result @@ -24,6 +24,20 @@ n drop database if exists mysqltest; affected rows: 1 create database mysqltest; +use mysqltest; +drop table table1, table2, table3, table4, table5, table6, +table7, table8, table9, table10, table11, table12, table13, +table14, table15, table16, table17, table18, table19, table20, +table21, table22, table23, table24, table25, table26, table27, +table28; +ERROR 42S02: Unknown table 'table1,table2,table3,table4,table5,table6,table7,table8,table9,table10,table11,table12,table13,table' +drop table table1, table2, table3, table4, table5, table6, +table7, table8, table9, table10, table11, table12, table13, +table14, table15, table16, table17, table18, table19, table20, +table21, table22, table23, table24, table25, table26, table27, +table28, table29, table30; +ERROR 42S02: Unknown table 'table1,table2,table3,table4,table5,table6,table7,table8,table9,table10,table11,table12,table13,table' +use test; drop database mysqltest; flush tables with read lock; create database mysqltest; diff --git a/mysql-test/r/drop_temp_table.result.es b/mysql-test/r/drop_temp_table.result.es deleted file mode 100644 index 4497022520e..00000000000 --- a/mysql-test/r/drop_temp_table.result.es +++ /dev/null @@ -1,12 +0,0 @@ -reset master; -create database `drop-temp+table-test`; -use `drop-temp+table-test`; -create temporary table `table:name` (a int); -select get_lock("a",10); -get_lock("a",10) -1 -select get_lock("a",10); -get_lock("a",10) -1 -show binlog events; -drop database `drop-temp+table-test`; diff --git a/mysql-test/r/flush_block_commit.result b/mysql-test/r/flush_block_commit.result index 2e9f1920937..2f6aca7e24a 100644 --- a/mysql-test/r/flush_block_commit.result +++ b/mysql-test/r/flush_block_commit.result @@ -37,3 +37,18 @@ show create database test; Database Create Database test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */ drop table t1; +create table t1 (a int) engine=innodb; +reset master; +set autocommit=0; +insert t1 values (1); +flush tables with read lock; +show master status; +File Position Binlog_Do_DB Binlog_Ignore_DB +master-bin.000001 98 + commit; +show master status; +File Position Binlog_Do_DB Binlog_Ignore_DB +master-bin.000001 98 +unlock tables; +drop table t1; +set autocommit=1; diff --git a/mysql-test/r/func_if.result b/mysql-test/r/func_if.result index 0ee7412cbe9..4db31121756 100644 --- a/mysql-test/r/func_if.result +++ b/mysql-test/r/func_if.result @@ -44,21 +44,26 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where; Using filesort Warnings: Note 1003 select if((`test`.`t1`.`u` = 1),`test`.`t1`.`st`,cast(`test`.`t1`.`st` as char charset binary)) AS `s` from `test`.`t1` where (`test`.`t1`.`st` like _latin1'%a%') order by if((`test`.`t1`.`u` = 1),`test`.`t1`.`st`,cast(`test`.`t1`.`st` as char charset binary)) -select nullif(u=0, 'test') from t1; -nullif(u=0, 'test') +select nullif(u, 1) from t1; +nullif(u, 1) NULL NULL NULL NULL NULL -1 -1 -explain extended select nullif(u=0, 'test') from t1; +0 +0 +explain extended select nullif(u, 1) from t1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Warnings: -Note 1003 select nullif((`test`.`t1`.`u` = 0),_latin1'test') AS `nullif(u=0, 'test')` from `test`.`t1` +Note 1003 select nullif(`test`.`t1`.`u`,1) AS `nullif(u, 1)` from `test`.`t1` drop table t1; +select nullif(1,'test'); +nullif(1,'test') +1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'test' select NULLIF(NULL,NULL), NULLIF(NULL,1), NULLIF(NULL,1.0), NULLIF(NULL,"test"); NULLIF(NULL,NULL) NULLIF(NULL,1) NULLIF(NULL,1.0) NULLIF(NULL,"test") NULL NULL NULL NULL diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index 2d464c891bf..1d9b813e68a 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -25,6 +25,8 @@ length(uuid()) charset(uuid()) length(unhex(replace(uuid(),_utf8'-',_utf8''))) select length(format('nan', 2)) > 0; length(format('nan', 2)) > 0 1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'nan' select concat("$",format(2500,2)); concat("$",format(2500,2)) $2,500.00 diff --git a/mysql-test/r/func_sapdb.result b/mysql-test/r/func_sapdb.result index 6556d2be6ad..f209866d953 100644 --- a/mysql-test/r/func_sapdb.result +++ b/mysql-test/r/func_sapdb.result @@ -195,6 +195,7 @@ insert into test values ('2001-01-01 01:01:01', '-01:01:01', '-23:59:59', "1997-12-31 23:59:59.000001"), ('1997-12-31 23:59:59.000001', '-23:59:59', '-01:01:01', '2001-01-01 01:01:01'), ('2001-01-01 01:01:01', '01:01:01', '-1 01:01:01', null), +('2001-01-01 01:01:01', '-01:01:01', '1 01:01:01', '2001-01-01 01:01:01'), ('2001-01-01 01:01:01', null, '-1 01:01:01', null), (null, null, null, null), ('2001-01-01 01:01:01', '01:01:01', '1 01:01:01', '2001-01-01 01:01:01'); @@ -204,6 +205,7 @@ ttt qqq 2001-01-01 00:00:00 -25:01:00 1997-12-31 00:00:00 -25:01:00 2001-01-01 02:02:02 -24:00:00 +2001-01-01 00:00:00 24:00:00 NULL NULL NULL NULL 2001-01-01 02:02:02 26:02:02 @@ -213,7 +215,8 @@ ttt qqq eee rrr -744:00:00 NULL NULL NULL 26305:01:02 22:58:58 -22:58:58 NULL -26305:01:02 -22:58:58 22:58:58 NULL -NULL 26:02:02 26:02:02 NULL +NULL 26:02:02 -26:02:02 NULL +00:00:00 -26:02:02 26:02:02 NULL NULL NULL NULL NULL NULL NULL NULL NULL 00:00:00 -24:00:00 24:00:00 NULL diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 1c2cfeca01e..bbb5a94606e 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -1,4 +1,4 @@ -drop table if exists t1; +drop table if exists t1,t2; set names latin1; select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo'; hello 'hello' ""hello"" 'h'e'l'l'o' hel"lo hel'lo @@ -236,6 +236,8 @@ Warning 1301 Result of repeat() was larger than max_allowed_packet (1048576) - t select position("0" in "baaa" in (1)),position("0" in "1" in (1,2,3)),position("sql" in ("mysql")); position("0" in "baaa" in (1)) position("0" in "1" in (1,2,3)) position("sql" in ("mysql")) 1 0 3 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'baaa' select position(("1" in (1,2,3)) in "01"); position(("1" in (1,2,3)) in "01") 2 @@ -393,9 +395,9 @@ select FIELD(_latin2'b','A','B'); ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field' select FIELD('b',_latin2'A','B'); ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field' -select FIELD('b',_latin2'A','B',1); -FIELD('b',_latin2'A','B',1) -1 +select FIELD('1',_latin2'3','2',1); +FIELD('1',_latin2'3','2',1) +3 select POSITION(_latin1'B' IN _latin1'abcd'); POSITION(_latin1'B' IN _latin1'abcd') 2 diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index b30fddb8de0..4293ef5bd85 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -304,6 +304,8 @@ NULL select date_sub("0000-00-00 00:00:00",INTERVAL 1 SECOND); date_sub("0000-00-00 00:00:00",INTERVAL 1 SECOND) NULL +Warnings: +Warning 1292 Truncated incorrect datetime value: '0000-00-00 00:00:00' select date_add('1998-01-30',Interval 1 month); date_add('1998-01-30',Interval 1 month) 1998-02-28 @@ -424,6 +426,9 @@ insert into t1 values ("0000-00-00", "0000-00-00", "0000-00-00", "0000-00-00"); select dayofyear("0000-00-00"),dayofyear(d),dayofyear(dt),dayofyear(t),dayofyear(c) from t1; dayofyear("0000-00-00") dayofyear(d) dayofyear(dt) dayofyear(t) dayofyear(c) NULL NULL NULL NULL NULL +Warnings: +Warning 1292 Truncated incorrect datetime value: '0000-00-00' +Warning 1292 Truncated incorrect datetime value: '0000-00-00' select dayofmonth("0000-00-00"),dayofmonth(d),dayofmonth(dt),dayofmonth(t),dayofmonth(c) from t1; dayofmonth("0000-00-00") dayofmonth(d) dayofmonth(dt) dayofmonth(t) dayofmonth(c) 0 0 0 0 0 @@ -436,15 +441,24 @@ quarter("0000-00-00") quarter(d) quarter(dt) quarter(t) quarter(c) select week("0000-00-00"),week(d),week(dt),week(t),week(c) from t1; week("0000-00-00") week(d) week(dt) week(t) week(c) NULL NULL NULL NULL NULL +Warnings: +Warning 1292 Truncated incorrect datetime value: '0000-00-00' +Warning 1292 Truncated incorrect datetime value: '0000-00-00' select year("0000-00-00"),year(d),year(dt),year(t),year(c) from t1; year("0000-00-00") year(d) year(dt) year(t) year(c) 0 0 0 0 0 select yearweek("0000-00-00"),yearweek(d),yearweek(dt),yearweek(t),yearweek(c) from t1; yearweek("0000-00-00") yearweek(d) yearweek(dt) yearweek(t) yearweek(c) NULL NULL NULL NULL NULL +Warnings: +Warning 1292 Truncated incorrect datetime value: '0000-00-00' +Warning 1292 Truncated incorrect datetime value: '0000-00-00' select to_days("0000-00-00"),to_days(d),to_days(dt),to_days(t),to_days(c) from t1; to_days("0000-00-00") to_days(d) to_days(dt) to_days(t) to_days(c) NULL NULL NULL NULL NULL +Warnings: +Warning 1292 Truncated incorrect datetime value: '0000-00-00' +Warning 1292 Truncated incorrect datetime value: '0000-00-00' select extract(MONTH FROM "0000-00-00"),extract(MONTH FROM d),extract(MONTH FROM dt),extract(MONTH FROM t),extract(MONTH FROM c) from t1; extract(MONTH FROM "0000-00-00") extract(MONTH FROM d) extract(MONTH FROM dt) extract(MONTH FROM t) extract(MONTH FROM c) 0 0 0 0 0 diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result index efd3b0f8e15..0e558e47594 100644 --- a/mysql-test/r/gis-rtree.result +++ b/mysql-test/r/gis-rtree.result @@ -758,7 +758,6 @@ SPATIAL KEY(g) INSERT INTO t1 (g) VALUES (GeomFromText('LineString(1 2, 2 3)')),(GeomFromText('LineString(1 2, 2 4)')); drop table t1; CREATE TABLE t1 ( -geoobjid INT NOT NULL, line LINESTRING NOT NULL, kind ENUM('po', 'pp', 'rr', 'dr', 'rd', 'ts', 'cl') NOT NULL DEFAULT 'po', name VARCHAR(32), diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index ecd2758fd1c..c8ae8303d99 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -157,6 +157,10 @@ select 1; 1 1 insert into mysql.user (host, user) values ('localhost', 'test11'); +Warnings: +Warning 1364 Field 'ssl_cipher' doesn't have a default value +Warning 1364 Field 'x509_issuer' doesn't have a default value +Warning 1364 Field 'x509_subject' doesn't have a default value insert into mysql.db (host, db, user, select_priv) values ('localhost', 'a%', 'test11', 'Y'), ('localhost', 'ab%', 'test11', 'Y'); alter table mysql.db order by db asc; @@ -461,3 +465,11 @@ Shutdown Server Admin To shut down the server Super Server Admin To use KILL thread, SET GLOBAL, CHANGE MASTER, etc. Update Tables To update existing rows Usage Server Admin No privileges - allow connect only +create database mysqltest; +create table mysqltest.t1 (a int,b int,c int); +grant all on mysqltest.t1 to mysqltest_1@localhost; +alter table t1 rename t2; +ERROR 42000: INSERT,CREATE command denied to user 'mysqltest_1'@'localhost' for table 't2' +revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; +delete from mysql.user where user=_binary'mysqltest_1'; +drop database mysqltest; diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result index b7639d49c7d..dd35d1c3dac 100644 --- a/mysql-test/r/grant2.result +++ b/mysql-test/r/grant2.result @@ -261,6 +261,10 @@ GRANT INSERT, UPDATE, DELETE ON `mysql`.* TO 'mysqltest_3'@'localhost' select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password; ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for table 'user' insert into mysql.user set host='%', user='mysqltest_B'; +Warnings: +Warning 1364 Field 'ssl_cipher' doesn't have a default value +Warning 1364 Field 'x509_issuer' doesn't have a default value +Warning 1364 Field 'x509_subject' doesn't have a default value create user mysqltest_A@'%'; rename user mysqltest_B@'%' to mysqltest_C@'%'; drop user mysqltest_C@'%'; diff --git a/mysql-test/r/have_isam.require b/mysql-test/r/have_isam.require deleted file mode 100644 index 9b4142361ed..00000000000 --- a/mysql-test/r/have_isam.require +++ /dev/null @@ -1,2 +0,0 @@ -Variable_name Value -have_isam YES diff --git a/mysql-test/r/heap.result b/mysql-test/r/heap.result index db20b242962..d2750fd5a43 100644 --- a/mysql-test/r/heap.result +++ b/mysql-test/r/heap.result @@ -40,7 +40,7 @@ a b 4 4 drop table t1; create table t1 (a int not null) engine=heap; -insert into t1 values (869751),(736494),(226312),(802616); +insert into t1 values (869751),(736494),(226312),(802616),(728912); select * from t1 where a > 736494; a 869751 @@ -66,7 +66,7 @@ a alter table t1 engine=myisam; explain select * from t1 where a in (869751,736494,226312,802616); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index uniq_id uniq_id 4 NULL 4 Using where; Using index +1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index drop table t1; create table t1 (x int not null, y int not null, key x (x), unique y (y)) engine=heap; @@ -436,30 +436,30 @@ f 10 g 10 h 10 i 10 -select sql_big_result v,count(t) from t1 group by v limit 10; -v count(t) +select sql_big_result trim(v),count(t) from t1 group by v limit 10; +trim(v) count(t) a 1 -a 10 -b 10 -c 10 -d 10 -e 10 -f 10 -g 10 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 h 10 -i 10 -select sql_big_result v,count(c) from t1 group by v limit 10; -v count(c) +i 10 +select sql_big_result trim(v),count(c) from t1 group by v limit 10; +trim(v) count(c) a 1 -a 10 -b 10 -c 10 -d 10 -e 10 -f 10 -g 10 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 h 10 -i 10 +i 10 select c,count(*) from t1 group by c limit 10; c count(*) a 1 @@ -520,18 +520,18 @@ f 10 g 10 h 10 i 10 -select sql_big_result t,count(t) from t1 group by t limit 10; -t count(t) +select sql_big_result trim(t),count(t) from t1 group by t limit 10; +trim(t) count(t) a 1 -a 10 -b 10 -c 10 -d 10 -e 10 -f 10 -g 10 +a 10 +b 10 +c 10 +d 10 +e 10 +f 10 +g 10 h 10 -i 10 +i 10 drop table t1; create table t1 (a char(10), unique (a)); insert into t1 values ('a'); @@ -667,14 +667,7 @@ drop table t1; set storage_engine=MyISAM; create table t1 (a bigint unsigned auto_increment primary key, b int, key (b, a)) engine=heap; -insert t1 (b) values (1); -insert t1 (b) values (1); -insert t1 (b) values (1); -insert t1 (b) values (1); -insert t1 (b) values (1); -insert t1 (b) values (1); -insert t1 (b) values (1); -insert t1 (b) values (1); +insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1); select * from t1; a b 1 1 @@ -688,14 +681,7 @@ a b drop table t1; create table t1 (a int not null, b int not null auto_increment, primary key(a, b), key(b)) engine=heap; -insert t1 (a) values (1); -insert t1 (a) values (1); -insert t1 (a) values (1); -insert t1 (a) values (1); -insert t1 (a) values (1); -insert t1 (a) values (1); -insert t1 (a) values (1); -insert t1 (a) values (1); +insert t1 (a) values (1),(1),(1),(1),(1),(1),(1),(1); select * from t1; a b 1 1 @@ -707,3 +693,6 @@ a b 1 7 1 8 drop table t1; +create table t1 (a int not null, b int not null auto_increment, +primary key(a, b)) engine=heap; +ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key diff --git a/mysql-test/r/heap_btree.result b/mysql-test/r/heap_btree.result index 8f9349ce316..374d2c63632 100644 --- a/mysql-test/r/heap_btree.result +++ b/mysql-test/r/heap_btree.result @@ -40,7 +40,7 @@ a b 4 4 drop table t1; create table t1 (a int not null) engine=heap; -insert into t1 values (869751),(736494),(226312),(802616); +insert into t1 values (869751),(736494),(226312),(802616),(728912); select * from t1 where a > 736494; a 869751 @@ -66,7 +66,7 @@ a alter table t1 engine=myisam; explain select * from t1 where a in (869751,736494,226312,802616); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index uniq_id uniq_id 4 NULL 4 Using where; Using index +1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index drop table t1; create table t1 (x int not null, y int not null, key x using BTREE (x,y), unique y using BTREE (y)) engine=heap; diff --git a/mysql-test/r/heap_hash.result b/mysql-test/r/heap_hash.result index 1e6eb866fd6..9720fe4843a 100644 --- a/mysql-test/r/heap_hash.result +++ b/mysql-test/r/heap_hash.result @@ -40,7 +40,7 @@ a b 4 4 drop table t1; create table t1 (a int not null) engine=heap; -insert into t1 values (869751),(736494),(226312),(802616); +insert into t1 values (869751),(736494),(226312),(802616),(728912); select * from t1 where a > 736494; a 869751 @@ -66,7 +66,7 @@ a alter table t1 engine=myisam; explain select * from t1 where a in (869751,736494,226312,802616); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index uniq_id uniq_id 4 NULL 4 Using where; Using index +1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index drop table t1; create table t1 (x int not null, y int not null, key x using HASH (x), unique y using HASH (y)) engine=heap; diff --git a/mysql-test/r/help.result b/mysql-test/r/help.result index edf7d0e91cb..85ca832828d 100644 --- a/mysql-test/r/help.result +++ b/mysql-test/r/help.result @@ -1,32 +1,48 @@ insert into mysql.help_category(help_category_id,name)values(1,'impossible_category_1'); +Warnings: +Warning 1364 Field 'url' doesn't have a default value select @category1_id:= 1; @category1_id:= 1 1 insert into mysql.help_category(help_category_id,name)values(2,'impossible_category_2'); +Warnings: +Warning 1364 Field 'url' doesn't have a default value select @category2_id:= 2; @category2_id:= 2 2 insert into mysql.help_category(help_category_id,name,parent_category_id)values(3,'impossible_category_3',@category2_id); +Warnings: +Warning 1364 Field 'url' doesn't have a default value select @category3_id:= 3; @category3_id:= 3 3 insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(1,'impossible_function_1',@category1_id,'description of \n impossible_function1\n','example of \n impossible_function1'); +Warnings: +Warning 1364 Field 'url' doesn't have a default value select @topic1_id:= 1; @topic1_id:= 1 1 insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(2,'impossible_function_2',@category1_id,'description of \n impossible_function2\n','example of \n impossible_function2'); +Warnings: +Warning 1364 Field 'url' doesn't have a default value select @topic2_id:= 2; @topic2_id:= 2 2 insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(3,'impossible_function_3',@category2_id,'description of \n impossible_function3\n','example of \n impossible_function3'); +Warnings: +Warning 1364 Field 'url' doesn't have a default value select @topic3_id:= 3; @topic3_id:= 3 3 insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(4,'impossible_function_4',@category2_id,'description of \n impossible_function4\n','example of \n impossible_function4'); +Warnings: +Warning 1364 Field 'url' doesn't have a default value select @topic4_id:= 4; @topic4_id:= 4 4 insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(5,'impossible_function_7',@category3_id,'description of \n impossible_function5\n','example of \n impossible_function7'); +Warnings: +Warning 1364 Field 'url' doesn't have a default value select @topic5_id:= 5; @topic5_id:= 5 5 diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 03c2cd8817c..c53779582f1 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -22,11 +22,11 @@ mysql test show databases where `database` = 't%'; Database -create database testtets; -create table testtets.t1(a int, b VARCHAR(30), KEY string_data (b)); +create database mysqltest; +create table mysqltest.t1(a int, b VARCHAR(30), KEY string_data (b)); create table test.t2(a int); create table t3(a int, KEY a_data (a)); -create table testtets.t4(a int); +create table mysqltest.t4(a int); create view v1 (c) as select table_name from information_schema.TABLES; select * from v1; c @@ -62,11 +62,28 @@ time_zone_name time_zone_transition time_zone_transition_type user +t1 +t4 t2 t3 v1 -t1 -t4 +select c,table_name from v1 +inner join information_schema.TABLES v2 on (v1.c=v2.table_name) +where v1.c like "t%"; +c table_name +TABLES TABLES +TABLE_PRIVILEGES TABLE_PRIVILEGES +TABLE_CONSTRAINTS TABLE_CONSTRAINTS +tables_priv tables_priv +time_zone time_zone +time_zone_leap_second time_zone_leap_second +time_zone_name time_zone_name +time_zone_transition time_zone_transition +time_zone_transition_type time_zone_transition_type +t1 t1 +t4 t4 +t2 t2 +t3 t3 select c,table_name from v1 left join information_schema.TABLES v2 on (v1.c=v2.table_name) where v1.c like "t%"; @@ -80,10 +97,10 @@ time_zone_leap_second time_zone_leap_second time_zone_name time_zone_name time_zone_transition time_zone_transition time_zone_transition_type time_zone_transition_type -t2 t2 -t3 t3 t1 t1 t4 t4 +t2 t2 +t3 t3 select c, v2.table_name from v1 right join information_schema.TABLES v2 on (v1.c=v2.table_name) where v1.c like "t%"; @@ -97,18 +114,18 @@ time_zone_leap_second time_zone_leap_second time_zone_name time_zone_name time_zone_transition time_zone_transition time_zone_transition_type time_zone_transition_type -t2 t2 -t3 t3 t1 t1 t4 t4 +t2 t2 +t3 t3 select table_name from information_schema.TABLES -where table_schema = "testtets" and table_name like "t%"; +where table_schema = "mysqltest" and table_name like "t%"; table_name t1 t4 -select * from information_schema.STATISTICS where TABLE_SCHEMA = "testtets"; +select * from information_schema.STATISTICS where TABLE_SCHEMA = "mysqltest"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT -NULL testtets t1 1 testtets string_data 1 b A NULL NULL NULL YES BTREE +NULL mysqltest t1 1 mysqltest string_data 1 b A NULL NULL NULL YES BTREE show keys from t3 where Key_name = "a_data"; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment t3 1 a_data 1 a A NULL NULL NULL YES BTREE @@ -133,13 +150,22 @@ c varchar(64) utf8_general_ci NO select,insert,update,references select * from information_schema.COLUMNS where table_name="t1" and column_name= "a"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT -NULL testtets t1 a 1 NULL YES int 11 11 11 0 NULL NULL int(11) select,insert,update,references -show columns from testtets.t1 where field like "%a%"; +NULL mysqltest t1 a 1 NULL YES int NULL NULL 11 0 NULL NULL int(11) select,insert,update,references +show columns from mysqltest.t1 where field like "%a%"; Field Type Null Key Default Extra a int(11) YES NULL +grant select (a) on mysqltest.t1 to mysqltest_2@localhost; +select table_name, column_name, privileges from information_schema.columns +where table_schema = 'mysqltest' and table_name = 't1'; +table_name column_name privileges +t1 a select +show columns from mysqltest.t1; +Field Type Null Key Default Extra +a int(11) YES NULL +b varchar(30) YES MUL NULL drop view v1; -drop tables testtets.t4, testtets.t1, t2, t3; -drop database testtets; +drop tables mysqltest.t4, mysqltest.t1, t2, t3; +drop database mysqltest; select * from information_schema.CHARACTER_SETS where CHARACTER_SET_NAME like 'latin1%'; CHARACTER_SET_NAME DEFAULT_COLLATE_NAME DESCRIPTION MAXLEN @@ -352,8 +378,8 @@ GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRAN 'mysqltest_1'@'localhost' NULL test t1 a REFERENCES NO delete from mysql.user where user='mysqltest_1' or user='mysqltest_2'; delete from mysql.db where user='mysqltest_1' or user='mysqltest_2'; -delete from mysql.tables_priv where user='mysqltest_1'; -delete from mysql.columns_priv where user='mysqltest_1'; +delete from mysql.tables_priv where user='mysqltest_1' or user='mysqltest_2'; +delete from mysql.columns_priv where user='mysqltest_1' or user='mysqltest_2'; flush privileges; drop table t1; create table t1 (a int null, primary key(a)); @@ -476,15 +502,15 @@ select COLUMN_NAME,COLUMN_TYPE, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE from information_schema.columns where table_name= 't1'; COLUMN_NAME COLUMN_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE -a decimal(5,3) 7 7 5 3 -b decimal(5,1) 7 7 5 1 -c float(5,2) 5 5 5 2 -d decimal(6,4) 8 8 6 4 -e float 12 12 12 NULL -f decimal(6,3) 8 8 6 3 -g int(11) 11 11 11 0 -h double(10,3) 10 10 10 3 -i double 22 22 22 NULL +a decimal(5,3) NULL NULL 5 3 +b decimal(5,1) NULL NULL 5 1 +c float(5,2) NULL NULL 5 2 +d decimal(6,4) NULL NULL 6 4 +e float NULL NULL 12 NULL +f decimal(6,3) NULL NULL 6 3 +g int(11) NULL NULL 11 0 +h double(10,3) NULL NULL 10 3 +i double NULL NULL 22 NULL drop table t1; create table t115 as select table_name, column_name, column_type from information_schema.columns where table_name = 'proc'; @@ -678,3 +704,25 @@ WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA AND A.TABLE_NAME = B.TABLE_NAME); COUNT(*) 0 +create table t1 +( x_bigint BIGINT, +x_integer INTEGER, +x_smallint SMALLINT, +x_decimal DECIMAL(5,3), +x_numeric NUMERIC(5,3), +x_real REAL, +x_float FLOAT, +x_double_precision DOUBLE PRECISION ); +SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH +FROM INFORMATION_SCHEMA.COLUMNS +WHERE TABLE_NAME= 't1'; +COLUMN_NAME CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH +x_bigint NULL NULL +x_integer NULL NULL +x_smallint NULL NULL +x_decimal NULL NULL +x_numeric NULL NULL +x_real NULL NULL +x_float NULL NULL +x_double_precision NULL NULL +drop table t1; diff --git a/mysql-test/r/innodb-big.result b/mysql-test/r/innodb-big.result new file mode 100644 index 00000000000..19204b7cc65 --- /dev/null +++ b/mysql-test/r/innodb-big.result @@ -0,0 +1,34 @@ +DROP TABLE IF EXISTS t1, t2, t3, t4; +CREATE TABLE t1 (id INTEGER) ENGINE=MYISAM; +CREATE TABLE t2 (id INTEGER primary key) ENGINE=INNODB; +CREATE TABLE t3 (a char(32) primary key,id INTEGER) ENGINE=INNODB; +CREATE TABLE t4 (a char(32) primary key,id INTEGER) ENGINE=MYISAM; +INSERT INTO t1 (id) VALUES (1); +INSERT INTO t1 SELECT id+1 FROM t1; +INSERT INTO t1 SELECT id+2 FROM t1; +INSERT INTO t1 SELECT id+4 FROM t1; +INSERT INTO t1 SELECT id+8 FROM t1; +INSERT INTO t1 SELECT id+16 FROM t1; +INSERT INTO t1 SELECT id+32 FROM t1; +INSERT INTO t1 SELECT id+64 FROM t1; +INSERT INTO t1 SELECT id+128 FROM t1; +INSERT INTO t1 SELECT id+256 FROM t1; +INSERT INTO t1 SELECT id+512 FROM t1; +INSERT INTO t1 SELECT id+1024 FROM t1; +INSERT INTO t1 SELECT id+2048 FROM t1; +INSERT INTO t1 SELECT id+4096 FROM t1; +INSERT INTO t1 SELECT id+8192 FROM t1; +INSERT INTO t1 SELECT id+16384 FROM t1; +INSERT INTO t1 SELECT id+32768 FROM t1; +INSERT INTO t1 SELECT id+65536 FROM t1; +INSERT INTO t1 SELECT id+131072 FROM t1; +INSERT INTO t1 SELECT id+262144 FROM t1; +INSERT INTO t1 SELECT id+524288 FROM t1; +INSERT INTO t1 SELECT id+1048576 FROM t1; +INSERT INTO t2 SELECT * FROM t1; +INSERT INTO t3 SELECT concat(id),id from t2 ORDER BY -id; +INSERT INTO t4 SELECT * from t3 ORDER BY concat(a); +select sum(id) from t3; +sum(id) +2199024304128 +drop table t1,t2,t3,t4; diff --git a/mysql-test/r/innodb-replace.result b/mysql-test/r/innodb-replace.result new file mode 100644 index 00000000000..a27806640ad --- /dev/null +++ b/mysql-test/r/innodb-replace.result @@ -0,0 +1,12 @@ +create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb; +select * from t1; +c1 c2 stamp +replace delayed into t1 (c1, c2) values ( "text1","11"),( "text2","12"); +ERROR HY000: Table storage engine for 't1' doesn't have this option +select * from t1; +c1 c2 stamp +replace delayed into t1 (c1, c2) values ( "text1","12"),( "text2","13"),( "text3","14", "a" ),( "text4","15", "b" ); +ERROR HY000: Table storage engine for 't1' doesn't have this option +select * from t1; +c1 c2 stamp +drop table t1; diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 7d0c4f28af9..ccd8601ace0 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1437,18 +1437,6 @@ id label 3524 Societe Test 3525 Fournisseur Test drop table t1,t2; -create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb; -select * from t1; -c1 c2 stamp -replace delayed into t1 (c1, c2) values ( "text1","11"),( "text2","12"); -ERROR HY000: Table storage engine for 't1' doesn't have this option -select * from t1; -c1 c2 stamp -replace delayed into t1 (c1, c2) values ( "text1","12"),( "text2","13"),( "text3","14", "a" ),( "text4","15", "b" ); -ERROR HY000: Table storage engine for 't1' doesn't have this option -select * from t1; -c1 c2 stamp -drop table t1; create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=myisam; create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=innodb; create table t3 (a int, b varchar(200), c text not null) checksum=1 engine=innodb; @@ -1618,7 +1606,7 @@ t2 CREATE TABLE `t2` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t2; create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb; -ERROR HY000: Can't create table './test/t2.frm' (errno: 150) +ERROR HY000: Can't create table './test/t2' (errno: 150) create table t2 (a int auto_increment primary key, b int, index(b), foreign key (b) references t1(id), unique(b)) engine=innodb; show create table t2; Table Create Table @@ -2372,7 +2360,7 @@ length(v) 65530 drop table t1; create table t1 (v varchar(65530), key(v)); -ERROR HY000: Can't create table './test/t1.frm' (errno: 139) +ERROR HY000: Can't create table './test/t1' (errno: 139) create table t1 (v varchar(65536)); Warnings: Note 1246 Converting column 'v' from VARCHAR to TEXT @@ -2394,5 +2382,3 @@ drop table t1; set storage_engine=MyISAM; create table t1 (v varchar(16384)) engine=innodb; drop table t1; -create table t1 (a bit, key(a)) engine=innodb; -ERROR 42000: The storage engine for the table doesn't support BIT FIELD diff --git a/mysql-test/r/innodb.result.es b/mysql-test/r/innodb.result.es deleted file mode 100644 index 602a034bc16..00000000000 --- a/mysql-test/r/innodb.result.es +++ /dev/null @@ -1,1653 +0,0 @@ -drop table if exists t1,t2,t3,t4; -drop database if exists mysqltest; -create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb; -insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt'); -select id, code, name from t1 order by id; -id code name -1 1 Tim -2 1 Monty -3 2 David -4 2 Erik -5 3 Sasha -6 3 Jeremy -7 4 Matt -update ignore t1 set id = 8, name = 'Sinisa' where id < 3; -select id, code, name from t1 order by id; -id code name -2 1 Monty -3 2 David -4 2 Erik -5 3 Sasha -6 3 Jeremy -7 4 Matt -8 1 Sinisa -update ignore t1 set id = id + 10, name = 'Ralph' where id < 4; -select id, code, name from t1 order by id; -id code name -3 2 David -4 2 Erik -5 3 Sasha -6 3 Jeremy -7 4 Matt -8 1 Sinisa -12 1 Ralph -drop table t1; -CREATE TABLE t1 ( -id int(11) NOT NULL auto_increment, -parent_id int(11) DEFAULT '0' NOT NULL, -level tinyint(4) DEFAULT '0' NOT NULL, -PRIMARY KEY (id), -KEY parent_id (parent_id), -KEY level (level) -) engine=innodb; -INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1),(179,5,2); -update t1 set parent_id=parent_id+100; -select * from t1 where parent_id=102; -id parent_id level -8 102 2 -9 102 2 -15 102 2 -update t1 set id=id+1000; -update t1 set id=1024 where id=1009; -Got one of the listed errors -select * from t1; -id parent_id level -1001 100 0 -1002 101 1 -1003 101 1 -1004 101 1 -1005 101 1 -1006 101 1 -1007 101 1 -1008 102 2 -1009 102 2 -1015 102 2 -1016 103 2 -1017 103 2 -1018 103 2 -1019 103 2 -1020 103 2 -1021 104 2 -1022 104 2 -1024 104 2 -1025 105 2 -1026 105 2 -1027 105 2 -1028 105 2 -1029 105 2 -1030 105 2 -1031 106 2 -1032 106 2 -1033 106 2 -1034 106 2 -1035 106 2 -1036 107 2 -1037 107 2 -1038 107 2 -1040 107 2 -1157 100 0 -1179 105 2 -1183 104 2 -1193 105 2 -1202 107 2 -1203 107 2 -update ignore t1 set id=id+1; -select * from t1; -id parent_id level -1001 100 0 -1002 101 1 -1003 101 1 -1004 101 1 -1005 101 1 -1006 101 1 -1007 101 1 -1008 102 2 -1010 102 2 -1015 102 2 -1016 103 2 -1017 103 2 -1018 103 2 -1019 103 2 -1020 103 2 -1021 104 2 -1023 104 2 -1024 104 2 -1025 105 2 -1026 105 2 -1027 105 2 -1028 105 2 -1029 105 2 -1030 105 2 -1031 106 2 -1032 106 2 -1033 106 2 -1034 106 2 -1035 106 2 -1036 107 2 -1037 107 2 -1039 107 2 -1041 107 2 -1158 100 0 -1180 105 2 -1184 104 2 -1194 105 2 -1202 107 2 -1204 107 2 -update ignore t1 set id=1023 where id=1010; -select * from t1 where parent_id=102; -id parent_id level -1008 102 2 -1010 102 2 -1015 102 2 -explain select level from t1 where level=1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref level level 1 const # Using where; Using index -explain select level,id from t1 where level=1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref level level 1 const # Using where; Using index -explain select level,id,parent_id from t1 where level=1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref level level 1 const # Using where -select level,id from t1 where level=1; -level id -1 1002 -1 1003 -1 1004 -1 1005 -1 1006 -1 1007 -select level,id,parent_id from t1 where level=1; -level id parent_id -1 1002 101 -1 1003 101 -1 1004 101 -1 1005 101 -1 1006 101 -1 1007 101 -optimize table t1; -Table Op Msg_type Msg_text -test.t1 optimize status OK -show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 id A # NULL NULL BTREE -t1 1 parent_id 1 parent_id A # NULL NULL BTREE -t1 1 level 1 level A # NULL NULL BTREE -drop table t1; -CREATE TABLE t1 ( -gesuchnr int(11) DEFAULT '0' NOT NULL, -benutzer_id int(11) DEFAULT '0' NOT NULL, -PRIMARY KEY (gesuchnr,benutzer_id) -) engine=innodb; -replace into t1 (gesuchnr,benutzer_id) values (2,1); -replace into t1 (gesuchnr,benutzer_id) values (1,1); -replace into t1 (gesuchnr,benutzer_id) values (1,1); -select * from t1; -gesuchnr benutzer_id -1 1 -2 1 -drop table t1; -create table t1 (a int) engine=innodb; -insert into t1 values (1), (2); -optimize table t1; -Table Op Msg_type Msg_text -test.t1 optimize status OK -delete from t1 where a = 1; -select * from t1; -a -2 -check table t1; -Table Op Msg_type Msg_text -test.t1 check status OK -drop table t1; -create table t1 (a int,b varchar(20)) engine=innodb; -insert into t1 values (1,""), (2,"testing"); -delete from t1 where a = 1; -select * from t1; -a b -2 testing -create index skr on t1 (a); -insert into t1 values (3,""), (4,"testing"); -analyze table t1; -Table Op Msg_type Msg_text -test.t1 analyze status OK -show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 1 skr 1 a A # NULL NULL YES BTREE -drop table t1; -create table t1 (a int,b varchar(20),key(a)) engine=innodb; -insert into t1 values (1,""), (2,"testing"); -select * from t1 where a = 1; -a b -1 -drop table t1; -create table t1 (n int not null primary key) engine=innodb; -set autocommit=0; -insert into t1 values (4); -rollback; -select n, "after rollback" from t1; -n after rollback -insert into t1 values (4); -commit; -select n, "after commit" from t1; -n after commit -4 after commit -commit; -insert into t1 values (5); -insert into t1 values (4); -ERROR 23000: Duplicate entry '4' for key 1 -commit; -select n, "after commit" from t1; -n after commit -4 after commit -5 after commit -set autocommit=1; -insert into t1 values (6); -insert into t1 values (4); -ERROR 23000: Duplicate entry '4' for key 1 -select n from t1; -n -4 -5 -6 -rollback; -drop table t1; -create table t1 (n int not null primary key) engine=innodb; -start transaction; -insert into t1 values (4); -flush tables with read lock; -commit; -unlock tables; -commit; -select * from t1; -n -4 -drop table t1; -create table t1 ( id int NOT NULL PRIMARY KEY, nom varchar(64)) engine=innodb; -begin; -insert into t1 values(1,'hamdouni'); -select id as afterbegin_id,nom as afterbegin_nom from t1; -afterbegin_id afterbegin_nom -1 hamdouni -rollback; -select id as afterrollback_id,nom as afterrollback_nom from t1; -afterrollback_id afterrollback_nom -set autocommit=0; -insert into t1 values(2,'mysql'); -select id as afterautocommit0_id,nom as afterautocommit0_nom from t1; -afterautocommit0_id afterautocommit0_nom -2 mysql -rollback; -select id as afterrollback_id,nom as afterrollback_nom from t1; -afterrollback_id afterrollback_nom -set autocommit=1; -drop table t1; -CREATE TABLE t1 (id char(8) not null primary key, val int not null) engine=innodb; -insert into t1 values ('pippo', 12); -insert into t1 values ('pippo', 12); -ERROR 23000: Duplicate entry 'pippo' for key 1 -delete from t1; -delete from t1 where id = 'pippo'; -select * from t1; -id val -insert into t1 values ('pippo', 12); -set autocommit=0; -delete from t1; -rollback; -select * from t1; -id val -pippo 12 -delete from t1; -commit; -select * from t1; -id val -drop table t1; -create table t1 (a integer) engine=innodb; -start transaction; -rename table t1 to t2; -create table t1 (b integer) engine=innodb; -insert into t1 values (1); -rollback; -drop table t1; -rename table t2 to t1; -drop table t1; -set autocommit=1; -CREATE TABLE t1 (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR(64)) ENGINE=innodb; -INSERT INTO t1 VALUES (1, 'Jochen'); -select * from t1; -ID NAME -1 Jochen -drop table t1; -CREATE TABLE t1 ( _userid VARCHAR(60) NOT NULL PRIMARY KEY) ENGINE=innodb; -set autocommit=0; -INSERT INTO t1 SET _userid='marc@anyware.co.uk'; -COMMIT; -SELECT * FROM t1; -_userid -marc@anyware.co.uk -SELECT _userid FROM t1 WHERE _userid='marc@anyware.co.uk'; -_userid -marc@anyware.co.uk -drop table t1; -set autocommit=1; -CREATE TABLE t1 ( -user_id int(10) DEFAULT '0' NOT NULL, -name varchar(100), -phone varchar(100), -ref_email varchar(100) DEFAULT '' NOT NULL, -detail varchar(200), -PRIMARY KEY (user_id,ref_email) -)engine=innodb; -INSERT INTO t1 VALUES (10292,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10292,'shirish','2333604','shirish@yahoo.com','ddsds'),(10292,'sonali','323232','sonali@bolly.com','filmstar'); -select * from t1 where user_id=10292; -user_id name phone ref_email detail -10292 sanjeev 29153373 sansh777@hotmail.com xxx -10292 shirish 2333604 shirish@yahoo.com ddsds -10292 sonali 323232 sonali@bolly.com filmstar -INSERT INTO t1 VALUES (10291,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10293,'shirish','2333604','shirish@yahoo.com','ddsds'); -select * from t1 where user_id=10292; -user_id name phone ref_email detail -10292 sanjeev 29153373 sansh777@hotmail.com xxx -10292 shirish 2333604 shirish@yahoo.com ddsds -10292 sonali 323232 sonali@bolly.com filmstar -select * from t1 where user_id>=10292; -user_id name phone ref_email detail -10292 sanjeev 29153373 sansh777@hotmail.com xxx -10292 shirish 2333604 shirish@yahoo.com ddsds -10292 sonali 323232 sonali@bolly.com filmstar -10293 shirish 2333604 shirish@yahoo.com ddsds -select * from t1 where user_id>10292; -user_id name phone ref_email detail -10293 shirish 2333604 shirish@yahoo.com ddsds -select * from t1 where user_id<10292; -user_id name phone ref_email detail -10291 sanjeev 29153373 sansh777@hotmail.com xxx -drop table t1; -CREATE TABLE t1 (a int not null, b int not null,c int not null, -key(a),primary key(a,b), unique(c),key(a),unique(b)); -show index from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 a A # NULL NULL BTREE -t1 0 PRIMARY 2 b A # NULL NULL BTREE -t1 0 c 1 c A # NULL NULL BTREE -t1 0 b 1 b A # NULL NULL BTREE -t1 1 a 1 a A # NULL NULL BTREE -t1 1 a_2 1 a A # NULL NULL BTREE -drop table t1; -create table t1 (col1 int not null, col2 char(4) not null, primary key(col1)); -alter table t1 engine=innodb; -insert into t1 values ('1','1'),('5','2'),('2','3'),('3','4'),('4','4'); -select * from t1; -col1 col2 -1 1 -2 3 -3 4 -4 4 -5 2 -update t1 set col2='7' where col1='4'; -select * from t1; -col1 col2 -1 1 -2 3 -3 4 -4 7 -5 2 -alter table t1 add co3 int not null; -select * from t1; -col1 col2 co3 -1 1 0 -2 3 0 -3 4 0 -4 7 0 -5 2 0 -update t1 set col2='9' where col1='2'; -select * from t1; -col1 col2 co3 -1 1 0 -2 9 0 -3 4 0 -4 7 0 -5 2 0 -drop table t1; -create table t1 (a int not null , b int, primary key (a)) engine = innodb; -create table t2 (a int not null , b int, primary key (a)) engine = myisam; -insert into t1 VALUES (1,3) , (2,3), (3,3); -select * from t1; -a b -1 3 -2 3 -3 3 -insert into t2 select * from t1; -select * from t2; -a b -1 3 -2 3 -3 3 -delete from t1 where b = 3; -select * from t1; -a b -insert into t1 select * from t2; -select * from t1; -a b -1 3 -2 3 -3 3 -select * from t2; -a b -1 3 -2 3 -3 3 -drop table t1,t2; -CREATE TABLE t1 ( -id int(11) NOT NULL auto_increment, -ggid varchar(32) binary DEFAULT '' NOT NULL, -email varchar(64) DEFAULT '' NOT NULL, -passwd varchar(32) binary DEFAULT '' NOT NULL, -PRIMARY KEY (id), -UNIQUE ggid (ggid) -) ENGINE=innodb; -insert into t1 (ggid,passwd) values ('test1','xxx'); -insert into t1 (ggid,passwd) values ('test2','yyy'); -insert into t1 (ggid,passwd) values ('test2','this will fail'); -ERROR 23000: Duplicate entry 'test2' for key 2 -insert into t1 (ggid,id) values ('this will fail',1); -ERROR 23000: Duplicate entry '1' for key 1 -select * from t1 where ggid='test1'; -id ggid email passwd -1 test1 xxx -select * from t1 where passwd='xxx'; -id ggid email passwd -1 test1 xxx -select * from t1 where id=2; -id ggid email passwd -2 test2 yyy -replace into t1 (ggid,id) values ('this will work',1); -replace into t1 (ggid,passwd) values ('test2','this will work'); -update t1 set id=100,ggid='test2' where id=1; -ERROR 23000: Duplicate entry 'test2' for key 2 -select * from t1; -id ggid email passwd -1 this will work -3 test2 this will work -select * from t1 where id=1; -id ggid email passwd -1 this will work -select * from t1 where id=999; -id ggid email passwd -drop table t1; -CREATE TABLE t1 ( -user_name varchar(12), -password text, -subscribed char(1), -user_id int(11) DEFAULT '0' NOT NULL, -quota bigint(20), -weight double, -access_date date, -access_time time, -approved datetime, -dummy_primary_key int(11) NOT NULL auto_increment, -PRIMARY KEY (dummy_primary_key) -) ENGINE=innodb; -INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','23:06:59','2000-09-07 23:06:59',1); -INSERT INTO t1 VALUES ('user_1','somepassword','Y',1,1,1,'2000-09-07','23:06:59','2000-09-07 23:06:59',2); -INSERT INTO t1 VALUES ('user_2','somepassword','N',2,2,1.4142135623731,'2000-09-07','23:06:59','2000-09-07 23:06:59',3); -INSERT INTO t1 VALUES ('user_3','somepassword','Y',3,3,1.7320508075689,'2000-09-07','23:06:59','2000-09-07 23:06:59',4); -INSERT INTO t1 VALUES ('user_4','somepassword','N',4,4,2,'2000-09-07','23:06:59','2000-09-07 23:06:59',5); -select user_name, password , subscribed, user_id, quota, weight, access_date, access_time, approved, dummy_primary_key from t1 order by user_name; -user_name password subscribed user_id quota weight access_date access_time approved dummy_primary_key -user_0 somepassword N 0 0 0 2000-09-07 23:06:59 2000-09-07 23:06:59 1 -user_1 somepassword Y 1 1 1 2000-09-07 23:06:59 2000-09-07 23:06:59 2 -user_2 somepassword N 2 2 1.4142135623731 2000-09-07 23:06:59 2000-09-07 23:06:59 3 -user_3 somepassword Y 3 3 1.7320508075689 2000-09-07 23:06:59 2000-09-07 23:06:59 4 -user_4 somepassword N 4 4 2 2000-09-07 23:06:59 2000-09-07 23:06:59 5 -drop table t1; -CREATE TABLE t1 ( -id int(11) NOT NULL auto_increment, -parent_id int(11) DEFAULT '0' NOT NULL, -level tinyint(4) DEFAULT '0' NOT NULL, -KEY (id), -KEY parent_id (parent_id), -KEY level (level) -) engine=innodb; -INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1); -INSERT INTO t1 values (179,5,2); -update t1 set parent_id=parent_id+100; -select * from t1 where parent_id=102; -id parent_id level -8 102 2 -9 102 2 -15 102 2 -update t1 set id=id+1000; -update t1 set id=1024 where id=1009; -select * from t1; -id parent_id level -1001 100 0 -1003 101 1 -1004 101 1 -1008 102 2 -1024 102 2 -1017 103 2 -1022 104 2 -1024 104 2 -1028 105 2 -1029 105 2 -1030 105 2 -1031 106 2 -1032 106 2 -1033 106 2 -1203 107 2 -1202 107 2 -1020 103 2 -1157 100 0 -1193 105 2 -1040 107 2 -1002 101 1 -1015 102 2 -1006 101 1 -1034 106 2 -1035 106 2 -1016 103 2 -1007 101 1 -1036 107 2 -1018 103 2 -1026 105 2 -1027 105 2 -1183 104 2 -1038 107 2 -1025 105 2 -1037 107 2 -1021 104 2 -1019 103 2 -1005 101 1 -1179 105 2 -update ignore t1 set id=id+1; -select * from t1; -id parent_id level -1002 100 0 -1004 101 1 -1005 101 1 -1009 102 2 -1025 102 2 -1018 103 2 -1023 104 2 -1025 104 2 -1029 105 2 -1030 105 2 -1031 105 2 -1032 106 2 -1033 106 2 -1034 106 2 -1204 107 2 -1203 107 2 -1021 103 2 -1158 100 0 -1194 105 2 -1041 107 2 -1003 101 1 -1016 102 2 -1007 101 1 -1035 106 2 -1036 106 2 -1017 103 2 -1008 101 1 -1037 107 2 -1019 103 2 -1027 105 2 -1028 105 2 -1184 104 2 -1039 107 2 -1026 105 2 -1038 107 2 -1022 104 2 -1020 103 2 -1006 101 1 -1180 105 2 -update ignore t1 set id=1023 where id=1010; -select * from t1 where parent_id=102; -id parent_id level -1009 102 2 -1025 102 2 -1016 102 2 -explain select level from t1 where level=1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref level level 1 const # Using where; Using index -select level,id from t1 where level=1; -level id -1 1004 -1 1005 -1 1003 -1 1007 -1 1008 -1 1006 -select level,id,parent_id from t1 where level=1; -level id parent_id -1 1004 101 -1 1005 101 -1 1003 101 -1 1007 101 -1 1008 101 -1 1006 101 -select level,id from t1 where level=1 order by id; -level id -1 1003 -1 1004 -1 1005 -1 1006 -1 1007 -1 1008 -delete from t1 where level=1; -select * from t1; -id parent_id level -1002 100 0 -1009 102 2 -1025 102 2 -1018 103 2 -1023 104 2 -1025 104 2 -1029 105 2 -1030 105 2 -1031 105 2 -1032 106 2 -1033 106 2 -1034 106 2 -1204 107 2 -1203 107 2 -1021 103 2 -1158 100 0 -1194 105 2 -1041 107 2 -1016 102 2 -1035 106 2 -1036 106 2 -1017 103 2 -1037 107 2 -1019 103 2 -1027 105 2 -1028 105 2 -1184 104 2 -1039 107 2 -1026 105 2 -1038 107 2 -1022 104 2 -1020 103 2 -1180 105 2 -drop table t1; -CREATE TABLE t1 ( -sca_code char(6) NOT NULL, -cat_code char(6) NOT NULL, -sca_desc varchar(50), -lan_code char(2) NOT NULL, -sca_pic varchar(100), -sca_sdesc varchar(50), -sca_sch_desc varchar(16), -PRIMARY KEY (sca_code, cat_code, lan_code), -INDEX sca_pic (sca_pic) -) engine = innodb ; -INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'),( 'QQ', 'N', 'RING', 'EN', 'not null', NULL, 'RING'); -select count(*) from t1 where sca_code = 'PD'; -count(*) -1 -select count(*) from t1 where sca_code <= 'PD'; -count(*) -1 -select count(*) from t1 where sca_pic is null; -count(*) -2 -alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic); -select count(*) from t1 where sca_code='PD' and sca_pic is null; -count(*) -1 -select count(*) from t1 where cat_code='E'; -count(*) -0 -alter table t1 drop index sca_pic, add index (sca_pic, cat_code); -select count(*) from t1 where sca_code='PD' and sca_pic is null; -count(*) -1 -select count(*) from t1 where sca_pic >= 'n'; -count(*) -1 -select sca_pic from t1 where sca_pic is null; -sca_pic -NULL -NULL -update t1 set sca_pic="test" where sca_pic is null; -delete from t1 where sca_code='pd'; -drop table t1; -set @a:=now(); -CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=innodb; -insert into t1 (a) values(1),(2),(3); -select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a; -a -1 -2 -3 -update t1 set a=5 where a=1; -select a from t1; -a -2 -3 -5 -drop table t1; -create table t1 (a varchar(100) not null, primary key(a), b int not null) engine=innodb; -insert into t1 values("hello",1),("world",2); -select * from t1 order by b desc; -a b -world 2 -hello 1 -optimize table t1; -Table Op Msg_type Msg_text -test.t1 optimize status OK -show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 a A # NULL NULL BTREE -drop table t1; -create table t1 (i int, j int ) ENGINE=innodb; -insert into t1 values (1,2); -select * from t1 where i=1 and j=2; -i j -1 2 -create index ax1 on t1 (i,j); -select * from t1 where i=1 and j=2; -i j -1 2 -drop table t1; -CREATE TABLE t1 ( -a int3 unsigned NOT NULL, -b int1 unsigned NOT NULL, -UNIQUE (a, b) -) ENGINE = innodb; -INSERT INTO t1 VALUES (1, 1); -SELECT MIN(B),MAX(b) FROM t1 WHERE t1.a = 1; -MIN(B) MAX(b) -1 1 -drop table t1; -CREATE TABLE t1 (a int unsigned NOT NULL) engine=innodb; -INSERT INTO t1 VALUES (1); -SELECT * FROM t1; -a -1 -DROP TABLE t1; -create table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) engine = innodb; -insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); -explain select * from t1 where a > 0 and a < 50; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL # Using where -drop table t1; -create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb; -insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); -LOCK TABLES t1 WRITE; -insert into t1 values (99,1,2,'D'),(1,1,2,'D'); -ERROR 23000: Duplicate entry '1-1' for key 1 -select id from t1; -id -0 -1 -2 -select id from t1; -id -0 -1 -2 -UNLOCK TABLES; -DROP TABLE t1; -create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb; -insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); -LOCK TABLES t1 WRITE; -begin; -insert into t1 values (99,1,2,'D'),(1,1,2,'D'); -ERROR 23000: Duplicate entry '1-1' for key 1 -select id from t1; -id -0 -1 -2 -insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D'); -commit; -select id,id3 from t1; -id id3 -0 0 -1 1 -2 2 -100 2 -UNLOCK TABLES; -DROP TABLE t1; -create table t1 (a char(20), unique (a(5))) engine=innodb; -drop table t1; -create table t1 (a char(20), index (a(5))) engine=innodb; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` char(20) default NULL, - KEY `a` (`a`(5)) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -drop table t1; -create temporary table t1 (a int not null auto_increment, primary key(a)) engine=innodb; -insert into t1 values (NULL),(NULL),(NULL); -delete from t1 where a=3; -insert into t1 values (NULL); -select * from t1; -a -1 -2 -4 -alter table t1 add b int; -select * from t1; -a b -1 NULL -2 NULL -4 NULL -drop table t1; -create table t1 -( -id int auto_increment primary key, -name varchar(32) not null, -value text not null, -uid int not null, -unique key(name,uid) -) engine=innodb; -insert into t1 values (1,'one','one value',101), -(2,'two','two value',102),(3,'three','three value',103); -set insert_id=5; -replace into t1 (value,name,uid) values ('other value','two',102); -delete from t1 where uid=102; -set insert_id=5; -replace into t1 (value,name,uid) values ('other value','two',102); -set insert_id=6; -replace into t1 (value,name,uid) values ('other value','two',102); -select * from t1; -id name value uid -1 one one value 101 -3 three three value 103 -6 two other value 102 -drop table t1; -create database mysqltest; -create table mysqltest.t1 (a int not null) engine= innodb; -insert into mysqltest.t1 values(1); -create table mysqltest.t2 (a int not null) engine= myisam; -insert into mysqltest.t2 values(1); -create table mysqltest.t3 (a int not null) engine= heap; -insert into mysqltest.t3 values(1); -commit; -drop database mysqltest; -show tables from mysqltest; -Got one of the listed errors -set autocommit=0; -create table t1 (a int not null) engine= innodb; -insert into t1 values(1),(2); -truncate table t1; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -commit; -truncate table t1; -select * from t1; -a -insert into t1 values(1),(2); -delete from t1; -select * from t1; -a -commit; -drop table t1; -set autocommit=1; -create table t1 (a int not null) engine= innodb; -insert into t1 values(1),(2); -truncate table t1; -insert into t1 values(1),(2); -select * from t1; -a -1 -2 -truncate table t1; -insert into t1 values(1),(2); -delete from t1; -select * from t1; -a -drop table t1; -create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=innodb; -insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4); -explain select * from t1 order by a; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 4 NULL # -explain select * from t1 order by b; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL b 4 NULL # -explain select * from t1 order by c; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL # Using filesort -explain select a from t1 order by a; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 4 NULL # Using index -explain select b from t1 order by b; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL b 4 NULL # Using index -explain select a,b from t1 order by b; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL b 4 NULL # Using index -explain select a,b from t1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL b 4 NULL # Using index -explain select a,b,c from t1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL # -drop table t1; -create table t1 (t int not null default 1, key (t)) engine=innodb; -desc t1; -Field Type Null Key Default Extra -t int(11) MUL 1 -drop table t1; -CREATE TABLE t1 ( -number bigint(20) NOT NULL default '0', -cname char(15) NOT NULL default '', -carrier_id smallint(6) NOT NULL default '0', -privacy tinyint(4) NOT NULL default '0', -last_mod_date timestamp(14) NOT NULL, -last_mod_id smallint(6) NOT NULL default '0', -last_app_date timestamp(14) NOT NULL, -last_app_id smallint(6) default '-1', -version smallint(6) NOT NULL default '0', -assigned_scps int(11) default '0', -status tinyint(4) default '0' -) ENGINE=InnoDB; -INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,00000000000000,-1,2,3,1); -INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0); -INSERT INTO t1 VALUES (650,'San Francisco',0,0,20011227111336,342,00000000000000,-1,1,24,1); -INSERT INTO t1 VALUES (302467,'Sue\'s Subshop',90,3,20020109113241,500,20020102115111,501,7,24,0); -INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0); -INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0); -CREATE TABLE t2 ( -number bigint(20) NOT NULL default '0', -cname char(15) NOT NULL default '', -carrier_id smallint(6) NOT NULL default '0', -privacy tinyint(4) NOT NULL default '0', -last_mod_date timestamp(14) NOT NULL, -last_mod_id smallint(6) NOT NULL default '0', -last_app_date timestamp(14) NOT NULL, -last_app_id smallint(6) default '-1', -version smallint(6) NOT NULL default '0', -assigned_scps int(11) default '0', -status tinyint(4) default '0' -) ENGINE=InnoDB; -INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,00000000000000,-1,2,3,1); -INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0); -INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,00000000000000,-1,1,24,1); -INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0); -select * from t1; -number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status -4077711111 SeanWheeler 90 2 2002-01-11 11:28:46 500 0000-00-00 00:00:00 -1 2 3 1 -9197722223 berry 90 3 2002-01-11 11:28:09 500 2002-01-02 11:45:32 501 4 10 0 -650 San Francisco 0 0 2001-12-27 11:13:36 342 0000-00-00 00:00:00 -1 1 24 1 -302467 Sue's Subshop 90 3 2002-01-09 11:32:41 500 2002-01-02 11:51:11 501 7 24 0 -6014911113 SudzCarwash 520 1 2002-01-02 11:52:34 500 2002-01-02 11:52:59 501 33 32768 0 -333 tubs 99 2 2002-01-09 11:34:40 501 2002-01-09 11:34:40 500 3 10 0 -select * from t2; -number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status -4077711111 SeanWheeler 0 2 2002-01-11 11:28:53 500 0000-00-00 00:00:00 -1 2 3 1 -9197722223 berry 90 3 2002-01-11 11:28:18 500 2002-01-02 11:45:32 501 4 10 0 -650 San Francisco 90 0 2002-01-09 11:31:58 342 0000-00-00 00:00:00 -1 1 24 1 -333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0 -delete t1, t2 from t1 left join t2 on t1.number=t2.number where (t1.carrier_id=90 and t1.number=t2.number) or (t2.carrier_id=90 and t1.number=t2.number) or (t1.carrier_id=90 and t2.number is null); -select * from t1; -number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status -6014911113 SudzCarwash 520 1 2002-01-02 11:52:34 500 2002-01-02 11:52:59 501 33 32768 0 -333 tubs 99 2 2002-01-09 11:34:40 501 2002-01-09 11:34:40 500 3 10 0 -select * from t2; -number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status -333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0 -select * from t2; -number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status -333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0 -drop table t1,t2; -create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) engine=innodb; -BEGIN; -SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE; -SELECT @@tx_isolation,@@global.tx_isolation; -@@tx_isolation @@global.tx_isolation -SERIALIZABLE REPEATABLE-READ -insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'); -select id, code, name from t1 order by id; -id code name -1 1 Tim -2 1 Monty -3 2 David -COMMIT; -BEGIN; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -insert into t1 (code, name) values (2, 'Erik'), (3, 'Sasha'); -select id, code, name from t1 order by id; -id code name -1 1 Tim -2 1 Monty -3 2 David -4 2 Erik -5 3 Sasha -COMMIT; -BEGIN; -SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; -insert into t1 (code, name) values (3, 'Jeremy'), (4, 'Matt'); -select id, code, name from t1 order by id; -id code name -1 1 Tim -2 1 Monty -3 2 David -4 2 Erik -5 3 Sasha -6 3 Jeremy -7 4 Matt -COMMIT; -DROP TABLE t1; -create table t1 (n int(10), d int(10)) engine=innodb; -create table t2 (n int(10), d int(10)) engine=innodb; -insert into t1 values(1,1),(1,2); -insert into t2 values(1,10),(2,20); -UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n; -select * from t1; -n d -1 10 -1 10 -select * from t2; -n d -1 30 -2 20 -drop table t1,t2; -create table t1 (a int, b int) engine=innodb; -insert into t1 values(20,null); -select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on -t2.b=t3.a; -b ifnull(t2.b,"this is null") -NULL this is null -select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on -t2.b=t3.a order by 1; -b ifnull(t2.b,"this is null") -NULL this is null -insert into t1 values(10,null); -select t2.b, ifnull(t2.b,"this is null") from t1 as t2 left join t1 as t3 on -t2.b=t3.a order by 1; -b ifnull(t2.b,"this is null") -NULL this is null -NULL this is null -drop table t1; -create table t1 (a varchar(10) not null) engine=myisam; -create table t2 (b varchar(10) not null unique) engine=innodb; -select t1.a from t1,t2 where t1.a=t2.b; -a -drop table t1,t2; -create table t1 (a int not null, b int, primary key (a)) engine = innodb; -create table t2 (a int not null, b int, primary key (a)) engine = innodb; -insert into t1 values (10, 20); -insert into t2 values (10, 20); -update t1, t2 set t1.b = 150, t2.b = t1.b where t2.a = t1.a and t1.a = 10; -drop table t1,t2; -CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; -CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE ) ENGINE=INNODB; -insert into t1 set id=1; -insert into t2 set id=1, t1_id=1; -delete t1,t2 from t1,t2 where t1.id=t2.t1_id; -select * from t1; -id -select * from t2; -id t1_id -drop table t2,t1; -CREATE TABLE t1(id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB; -CREATE TABLE t2(id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id) ) ENGINE=INNODB; -INSERT INTO t1 VALUES(1); -INSERT INTO t2 VALUES(1, 1); -SELECT * from t1; -id -1 -UPDATE t1,t2 SET t1.id=t1.id+1, t2.t1_id=t1.id+1; -SELECT * from t1; -id -2 -UPDATE t1,t2 SET t1.id=t1.id+1 where t1.id!=t2.id; -SELECT * from t1; -id -3 -DROP TABLE t1,t2; -set autocommit=0; -CREATE TABLE t1 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; -CREATE TABLE t2 (id CHAR(15) NOT NULL, value CHAR(40) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; -CREATE TABLE t3 (id1 CHAR(15) NOT NULL, id2 CHAR(15) NOT NULL, PRIMARY KEY(id1, id2)) ENGINE=InnoDB; -INSERT INTO t3 VALUES("my-test-1", "my-test-2"); -COMMIT; -INSERT INTO t1 VALUES("this-key", "will disappear"); -INSERT INTO t2 VALUES("this-key", "will also disappear"); -DELETE FROM t3 WHERE id1="my-test-1"; -SELECT * FROM t1; -id value -this-key will disappear -SELECT * FROM t2; -id value -this-key will also disappear -SELECT * FROM t3; -id1 id2 -ROLLBACK; -SELECT * FROM t1; -id value -SELECT * FROM t2; -id value -SELECT * FROM t3; -id1 id2 -my-test-1 my-test-2 -SELECT * FROM t3 WHERE id1="my-test-1" LOCK IN SHARE MODE; -id1 id2 -my-test-1 my-test-2 -COMMIT; -set autocommit=1; -DROP TABLE t1,t2,t3; -CREATE TABLE t1 (a int not null primary key, b int not null, unique (b)) engine=innodb; -INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9); -UPDATE t1 set a=a+100 where b between 2 and 3 and a < 1000; -SELECT * from t1; -a b -1 1 -102 2 -103 3 -4 4 -5 5 -6 6 -7 7 -8 8 -9 9 -drop table t1; -CREATE TABLE t1 (a int not null primary key, b int not null, key (b)) engine=innodb; -CREATE TABLE t2 (a int not null primary key, b int not null, key (b)) engine=innodb; -INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10),(11,11),(12,12); -INSERT INTO t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9); -update t1,t2 set t1.a=t1.a+100; -select * from t1; -a b -101 1 -102 2 -103 3 -104 4 -105 5 -106 6 -107 7 -108 8 -109 9 -110 10 -111 11 -112 12 -update t1,t2 set t1.a=t1.a+100 where t1.a=101; -select * from t1; -a b -201 1 -102 2 -103 3 -104 4 -105 5 -106 6 -107 7 -108 8 -109 9 -110 10 -111 11 -112 12 -update t1,t2 set t1.b=t1.b+10 where t1.b=2; -select * from t1; -a b -201 1 -103 3 -104 4 -105 5 -106 6 -107 7 -108 8 -109 9 -110 10 -111 11 -102 12 -112 12 -update t1,t2 set t1.b=t1.b+2,t2.b=t1.b+10 where t1.b between 3 and 5 and t1.a=t2.a+100; -select * from t1; -a b -201 1 -103 5 -104 6 -106 6 -105 7 -107 7 -108 8 -109 9 -110 10 -111 11 -102 12 -112 12 -select * from t2; -a b -1 1 -2 2 -6 6 -7 7 -8 8 -9 9 -3 13 -4 14 -5 15 -drop table t1,t2; -CREATE TABLE t2 ( NEXT_T BIGINT NOT NULL PRIMARY KEY) ENGINE=MyISAM; -CREATE TABLE t1 ( B_ID INTEGER NOT NULL PRIMARY KEY) ENGINE=InnoDB; -SET AUTOCOMMIT=0; -INSERT INTO t1 ( B_ID ) VALUES ( 1 ); -INSERT INTO t2 ( NEXT_T ) VALUES ( 1 ); -ROLLBACK; -Warnings: -Warning 1196 Some non-transactional changed tables couldn't be rolled back -SELECT * FROM t1; -B_ID -drop table t1,t2; -create table t1 ( pk int primary key, parent int not null, child int not null, index (parent) ) engine = innodb; -insert into t1 values (1,0,4), (2,1,3), (3,2,1), (4,1,2); -select distinct parent,child from t1 order by parent; -parent child -0 4 -1 2 -1 3 -2 1 -drop table t1; -create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) engine=innodb; -create table t2 (a int not null auto_increment primary key, b int); -insert into t1 (b) values (null),(null),(null),(null),(null),(null),(null); -insert into t2 (a) select b from t1; -insert into t1 (b) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; -insert into t2 (a) select b from t1; -insert into t1 (a) select b from t2; -select count(*) from t1; -count(*) -29267 -explain select * from t1 where c between 1 and 10000; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range c c 5 NULL # Using where -update t1 set c=a; -explain select * from t1 where c between 1 and 10000; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL c NULL NULL NULL # Using where -drop table t1,t2; -create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) engine=innodb; -insert into t1 (id) values (null),(null),(null),(null),(null); -update t1 set fk=69 where fk is null order by id limit 1; -SELECT * from t1; -id fk -2 NULL -3 NULL -4 NULL -5 NULL -1 69 -drop table t1; -create table t1 (a int not null, b int not null, key (a)); -insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3); -SET @tmp=0; -update t1 set b=(@tmp:=@tmp+1) order by a; -update t1 set b=99 where a=1 order by b asc limit 1; -update t1 set b=100 where a=1 order by b desc limit 2; -update t1 set a=a+10+b where a=1 order by b; -select * from t1 order by a,b; -a b -2 4 -2 5 -2 6 -3 7 -3 8 -3 9 -3 10 -3 11 -3 12 -13 2 -111 100 -111 100 -drop table t1; -create table t1 ( c char(8) not null ) engine=innodb; -insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); -insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F'); -alter table t1 add b char(8) not null; -alter table t1 add a char(8) not null; -alter table t1 add primary key (a,b,c); -update t1 set a=c, b=c; -create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=innodb; -insert into t2 select * from t1; -delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; -drop table t1,t2; -SET AUTOCOMMIT=1; -create table t1 (a integer auto_increment primary key) engine=innodb; -insert into t1 (a) values (NULL),(NULL); -truncate table t1; -insert into t1 (a) values (NULL),(NULL); -SELECT * from t1; -a -3 -4 -drop table t1; -CREATE TABLE t1 (`id 1` INT NOT NULL, PRIMARY KEY (`id 1`)) ENGINE=INNODB; -CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (`t1_id`) REFERENCES `t1`(`id 1`) ON DELETE CASCADE ) ENGINE=INNODB; -drop table t2,t1; -create table `t1` (`id` int( 11 ) not null ,primary key ( `id` )) engine = innodb; -insert into `t1`values ( 1 ) ; -create table `t2` (`id` int( 11 ) not null default '0',unique key `id` ( `id` ) ,constraint `t1_id_fk` foreign key ( `id` ) references `t1` (`id` )) engine = innodb; -insert into `t2`values ( 1 ) ; -create table `t3` (`id` int( 11 ) not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = innodb; -insert into `t3`values ( 1 ) ; -delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; -ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails -update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; -ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails -update t3 set t3.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; -ERROR 42S02: Unknown table 't1' in where clause -drop table t3,t2,t1; -create table t1( -id int primary key, -pid int, -index(pid), -foreign key(pid) references t1(id) on delete cascade) engine=innodb; -insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6), -(8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14); -delete from t1 where id=0; -ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails -delete from t1 where id=15; -delete from t1 where id=0; -drop table t1; -CREATE TABLE t1 (col1 int(1))ENGINE=InnoDB; -CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx -(stamp))ENGINE=InnoDB; -insert into t1 values (1),(2),(3); -insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000); -Warnings: -Warning 1265 Data truncated for column 'stamp' at row 3 -SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp < -'20020204120000' GROUP BY col1; -col1 -1 -2 -3 -4 -drop table t1,t2; -CREATE TABLE t1 ( -`id` int(10) unsigned NOT NULL auto_increment, -`id_object` int(10) unsigned default '0', -`id_version` int(10) unsigned NOT NULL default '1', -label varchar(100) NOT NULL default '', -`description` text, -PRIMARY KEY (`id`), -KEY `id_object` (`id_object`), -KEY `id_version` (`id_version`) -) ENGINE=InnoDB; -INSERT INTO t1 VALUES("6", "3382", "9", "Test", NULL), ("7", "102", "5", "Le Pekin (Test)", NULL),("584", "1794", "4", "Test de resto", NULL),("837", "1822", "6", "Test 3", NULL),("1119", "3524", "1", "Societe Test", NULL),("1122", "3525", "1", "Fournisseur Test", NULL); -CREATE TABLE t2 ( -`id` int(10) unsigned NOT NULL auto_increment, -`id_version` int(10) unsigned NOT NULL default '1', -PRIMARY KEY (`id`), -KEY `id_version` (`id_version`) -) ENGINE=InnoDB; -INSERT INTO t2 VALUES("3524", "1"),("3525", "1"),("1794", "4"),("102", "5"),("1822", "6"),("3382", "9"); -SELECT t2.id, t1.label FROM t2 INNER JOIN -(SELECT t1.id_object as id_object FROM t1 WHERE t1.label LIKE '%test%') AS lbl -ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object); -id label -3382 Test -102 Le Pekin (Test) -1794 Test de resto -1822 Test 3 -3524 Societe Test -3525 Fournisseur Test -drop table t1,t2; -create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb; -select * from t1; -c1 c2 stamp -replace delayed into t1 (c1, c2) values ( "text1","11"),( "text2","12"); -select * from t1; -c1 c2 stamp -text1 11 2004-12-01 13:23:14 -text2 12 2004-12-01 13:23:14 -replace delayed into t1 (c1, c2) values ( "text1","12"),( "text2","13"),( "text3","14", "a" ),( "text4","15", "b" ); -ERROR 21S01: Column count doesn't match value count at row 3 -select * from t1; -c1 c2 stamp -text1 11 2004-12-01 13:23:14 -text2 12 2004-12-01 13:23:14 -drop table t1; -create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=myisam; -create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=innodb; -create table t3 (a int, b varchar(200), c text not null) checksum=1 engine=innodb; -insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, ""); -insert t2 select * from t1; -insert t3 select * from t1; -checksum table t1, t2, t3, t4 quick; -Table Checksum -test.t1 968604391 -test.t2 NULL -test.t3 NULL -test.t4 NULL -checksum table t1, t2, t3, t4; -Table Checksum -test.t1 968604391 -test.t2 968604391 -test.t3 968604391 -test.t4 NULL -checksum table t1, t2, t3, t4 extended; -Table Checksum -test.t1 968604391 -test.t2 968604391 -test.t3 968604391 -test.t4 NULL -drop table t1,t2,t3; -create table t1 (id int, name char(10) not null, name2 char(10) not null) engine=innodb; -insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt'); -select name2 from t1 union all select name from t1 union all select id from t1; -name2 -fff -sss -ttt -first -second -third -1 -2 -3 -drop table t1; -create table t1 (a int) engine=innodb; -create table t2 like t1; -drop table t1,t2; -create table t1 (id int(11) not null, id2 int(11) not null, unique (id,id2)) engine=innodb; -create table t2 (id int(11) not null, constraint t1_id_fk foreign key ( id ) references t1 (id)) engine = innodb; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `id` int(11) NOT NULL default '0', - `id2` int(11) NOT NULL default '0', - UNIQUE KEY `id` (`id`,`id2`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `id` int(11) NOT NULL default '0', - KEY `t1_id_fk` (`id`), - CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -create index id on t2 (id); -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `id` int(11) NOT NULL default '0', - KEY `id` (`id`), - CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -create index id2 on t2 (id); -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `id` int(11) NOT NULL default '0', - KEY `id` (`id`), - KEY `id2` (`id`), - CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -drop index id2 on t2; -drop index id on t2; -Got one of the listed errors -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `id` int(11) NOT NULL default '0', - KEY `id` (`id`), - CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -drop table t2; -create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id,id2) references t1 (id,id2)) engine = innodb; -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `id` int(11) NOT NULL default '0', - `id2` int(11) NOT NULL default '0', - KEY `t1_id_fk` (`id`,`id2`), - CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`, `id2`) REFERENCES `t1` (`id`, `id2`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -create unique index id on t2 (id,id2); -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `id` int(11) NOT NULL default '0', - `id2` int(11) NOT NULL default '0', - UNIQUE KEY `id` (`id`,`id2`), - CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`, `id2`) REFERENCES `t1` (`id`, `id2`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -drop table t2; -create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb; -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `id` int(11) NOT NULL default '0', - `id2` int(11) NOT NULL default '0', - UNIQUE KEY `id` (`id`,`id2`), - KEY `t1_id_fk` (`id2`,`id`), - CONSTRAINT `t1_id_fk` FOREIGN KEY (`id2`, `id`) REFERENCES `t1` (`id`, `id2`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -drop table t2; -create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2), constraint t1_id_fk foreign key (id) references t1 (id)) engine = innodb; -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `id` int(11) NOT NULL default '0', - `id2` int(11) NOT NULL default '0', - UNIQUE KEY `id` (`id`,`id2`), - CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -drop table t2; -create table t2 (id int(11) not null, id2 int(11) not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb; -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `id` int(11) NOT NULL default '0', - `id2` int(11) NOT NULL default '0', - UNIQUE KEY `id` (`id`,`id2`), - KEY `t1_id_fk` (`id2`,`id`), - CONSTRAINT `t1_id_fk` FOREIGN KEY (`id2`, `id`) REFERENCES `t1` (`id`, `id2`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -drop table t2; -create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id), primary key (id), index (id,id2)) engine = innodb; -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `id` int(11) NOT NULL auto_increment, - `id2` int(11) NOT NULL default '0', - PRIMARY KEY (`id`), - KEY `id` (`id`,`id2`), - CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -drop table t2; -create table t2 (id int(11) not null auto_increment, id2 int(11) not null, constraint t1_id_fk foreign key (id) references t1 (id)) engine= innodb; -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `id` int(11) NOT NULL auto_increment, - `id2` int(11) NOT NULL default '0', - KEY `t1_id_fk` (`id`), - CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -alter table t2 add index id_test (id), add index id_test2 (id,id2); -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `id` int(11) NOT NULL auto_increment, - `id2` int(11) NOT NULL default '0', - KEY `id_test` (`id`), - KEY `id_test2` (`id`,`id2`), - CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -drop table t2; -create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb; -ERROR HY000: Can't create table '/home/hf/work/mysql-4.1.clean/mysql-test/var/master-data/test/t2.frm' (errno: 150) -create table t2 (a int auto_increment primary key, b int, index(b), foreign key (b) references t1(id), unique(b)) engine=innodb; -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) NOT NULL auto_increment, - `b` int(11) default NULL, - PRIMARY KEY (`a`), - UNIQUE KEY `b_2` (`b`), - KEY `b` (`b`), - CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -drop table t2; -create table t2 (a int auto_increment primary key, b int, foreign key (b) references t1(id), foreign key (b) references t1(id), unique(b)) engine=innodb; -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `a` int(11) NOT NULL auto_increment, - `b` int(11) default NULL, - PRIMARY KEY (`a`), - UNIQUE KEY `b` (`b`), - CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`), - CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`b`) REFERENCES `t1` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -drop table t2, t1; -show status like "binlog_cache_use"; -Variable_name Value -Binlog_cache_use 24 -show status like "binlog_cache_disk_use"; -Variable_name Value -Binlog_cache_disk_use 0 -create table t1 (a int) engine=innodb; -show status like "binlog_cache_use"; -Variable_name Value -Binlog_cache_use 25 -show status like "binlog_cache_disk_use"; -Variable_name Value -Binlog_cache_disk_use 1 -begin; -delete from t1; -commit; -show status like "binlog_cache_use"; -Variable_name Value -Binlog_cache_use 26 -show status like "binlog_cache_disk_use"; -Variable_name Value -Binlog_cache_disk_use 1 -drop table t1; -create table t1 (c char(10), index (c,c)) engine=innodb; -ERROR 42S21: Duplicate column name 'c' -create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb; -ERROR 42S21: Duplicate column name 'c1' -create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb; -ERROR 42S21: Duplicate column name 'c1' -create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb; -ERROR 42S21: Duplicate column name 'c1' -create table t1 (c1 char(10), c2 char(10)) engine=innodb; -alter table t1 add key (c1,c1); -ERROR 42S21: Duplicate column name 'c1' -alter table t1 add key (c2,c1,c1); -ERROR 42S21: Duplicate column name 'c1' -alter table t1 add key (c1,c2,c1); -ERROR 42S21: Duplicate column name 'c1' -alter table t1 add key (c1,c1,c2); -ERROR 42S21: Duplicate column name 'c1' -drop table t1; diff --git a/mysql-test/r/insert_select-binlog.result b/mysql-test/r/insert_select-binlog.result new file mode 100644 index 00000000000..76f460b1de2 --- /dev/null +++ b/mysql-test/r/insert_select-binlog.result @@ -0,0 +1,25 @@ +create table t1(a int, unique(a)); +insert into t1 values(2); +create table t2(a int); +insert into t2 values(1),(2); +reset master; +insert into t1 select * from t2; +ERROR 23000: Duplicate entry '2' for key 1 +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 4 Format_desc 1 98 Server ver: VERSION, Binlog ver: 4 +master-bin.000001 98 Query 1 192 use `test`; insert into t1 select * from t2 +select * from t1; +a +1 +2 +drop table t1, t2; +create table t1(a int); +insert into t1 values(1),(1); +reset master; +create table t2(unique(a)) select a from t1; +ERROR 23000: Duplicate entry '1' for key 1 +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 4 Format_desc 1 98 Server ver: VERSION, Binlog ver: 4 +drop table t1; diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index 13d4b0e22bc..d2c0a665845 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -65,31 +65,6 @@ INSERT INTO t1 (numeropost,icone,contenu,pseudo,date,signature,ip) SELECT 1718,icone,contenu,pseudo,date,signature,ip FROM t2 WHERE numeropost=9 ORDER BY numreponse ASC; DROP TABLE t1,t2; -create table t1(a int, unique(a)); -insert into t1 values(2); -create table t2(a int); -insert into t2 values(1),(2); -reset master; -insert into t1 select * from t2; -ERROR 23000: Duplicate entry '2' for key 1 -show binlog events; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 -master-bin.000001 # Query 1 # use `test`; insert into t1 select * from t2 -select * from t1; -a -1 -2 -drop table t1, t2; -create table t1(a int); -insert into t1 values(1),(1); -reset master; -create table t2(unique(a)) select a from t1; -ERROR 23000: Duplicate entry '1' for key 1 -show binlog events; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Format_desc 1 # Server ver: VERSION, Binlog ver: 4 -drop table t1; create table t1 (a int not null); create table t2 (a int not null); insert into t1 values (1); diff --git a/mysql-test/r/insert_select.result.es b/mysql-test/r/insert_select.result.es deleted file mode 100644 index 9cac6d31b8f..00000000000 --- a/mysql-test/r/insert_select.result.es +++ /dev/null @@ -1,647 +0,0 @@ -drop table if exists t1,t2; -create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL); -insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12); -create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY); -insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1; -insert into t2 (payoutID) SELECT payoutID+10 FROM t1; -ERROR 23000: Duplicate entry '16' for key 1 -insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1; -select * from t2; -payoutID -1 -4 -6 -9 -10 -11 -12 -14 -16 -19 -20 -22 -drop table t1,t2; -CREATE TABLE `t1` ( -`numeropost` bigint(20) unsigned NOT NULL default '0', -`icone` tinyint(4) unsigned NOT NULL default '0', -`numreponse` bigint(20) unsigned NOT NULL auto_increment, -`contenu` text NOT NULL, -`pseudo` varchar(50) NOT NULL default '', -`date` datetime NOT NULL default '0000-00-00 00:00:00', -`ip` bigint(11) NOT NULL default '0', -`signature` tinyint(1) unsigned NOT NULL default '0', -PRIMARY KEY (`numeropost`,`numreponse`) -,KEY `ip` (`ip`), -KEY `date` (`date`), -KEY `pseudo` (`pseudo`), -KEY `numreponse` (`numreponse`) -) ENGINE=MyISAM; -CREATE TABLE `t2` ( -`numeropost` bigint(20) unsigned NOT NULL default '0', -`icone` tinyint(4) unsigned NOT NULL default '0', -`numreponse` bigint(20) unsigned NOT NULL auto_increment, -`contenu` text NOT NULL, -`pseudo` varchar(50) NOT NULL default '', -`date` datetime NOT NULL default '0000-00-00 00:00:00', -`ip` bigint(11) NOT NULL default '0', -`signature` tinyint(1) unsigned NOT NULL default '0', -PRIMARY KEY (`numeropost`,`numreponse`), -KEY `ip` (`ip`), -KEY `date` (`date`), -KEY `pseudo` (`pseudo`), -KEY `numreponse` (`numreponse`) -) ENGINE=MyISAM; -INSERT INTO t2 -(numeropost,icone,numreponse,contenu,pseudo,date,ip,signature) VALUES -(9,1,56,'test','joce','2001-07-25 13:50:53' -,3649052399,0); -INSERT INTO t1 (numeropost,icone,contenu,pseudo,date,signature,ip) -SELECT 1618,icone,contenu,pseudo,date,signature,ip FROM t2 -WHERE numeropost=9 ORDER BY numreponse ASC; -show variables like '%bulk%'; -Variable_name Value -bulk_insert_buffer_size 8388608 -INSERT INTO t1 (numeropost,icone,contenu,pseudo,date,signature,ip) -SELECT 1718,icone,contenu,pseudo,date,signature,ip FROM t2 -WHERE numeropost=9 ORDER BY numreponse ASC; -DROP TABLE t1,t2; -create table t1(a int, unique(a)); -insert into t1 values(2); -create table t2(a int); -insert into t2 values(1),(2); -reset master; -insert into t1 select * from t2; -ERROR 23000: Duplicate entry '2' for key 1 -show binlog events; -select * from t1; -a -1 -2 -drop table t1, t2; -create table t1(a int); -insert into t1 values(1),(1); -reset master; -create table t2(unique(a)) select a from t1; -ERROR 23000: Duplicate entry '1' for key 1 -show binlog events; -drop table t1; -create table t1 (a int not null); -create table t2 (a int not null); -insert into t1 values (1); -insert into t1 values (a+2); -insert into t1 values (a+3); -insert into t1 values (4),(a+5); -insert into t1 select * from t1; -select * from t1; -a -1 -2 -3 -4 -5 -1 -2 -3 -4 -5 -insert into t1 select * from t1 as t2; -select * from t1; -a -1 -2 -3 -4 -5 -1 -2 -3 -4 -5 -1 -2 -3 -4 -5 -1 -2 -3 -4 -5 -insert into t2 select * from t1 as t2; -select * from t1; -a -1 -2 -3 -4 -5 -1 -2 -3 -4 -5 -1 -2 -3 -4 -5 -1 -2 -3 -4 -5 -insert into t1 select t2.a from t1,t2; -select * from t1; -a -1 -2 -3 -4 -5 -1 -2 -3 -4 -5 -1 -2 -3 -4 -5 -1 -2 -3 -4 -5 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -insert into t1 select * from t1,t1; -ERROR 42000: Not unique table/alias: 't1' -drop table t1,t2; -create table t1 (a int not null primary key, b char(10)); -create table t2 (a int not null, b char(10)); -insert into t1 values (1,"t1:1"),(3,"t1:3"); -insert into t2 values (2,"t2:2"), (3,"t2:3"); -insert into t1 select * from t2; -ERROR 23000: Duplicate entry '3' for key 1 -select * from t1; -a b -1 t1:1 -3 t1:3 -2 t2:2 -replace into t1 select * from t2; -select * from t1; -a b -1 t1:1 -3 t2:3 -2 t2:2 -drop table t1,t2; -CREATE TABLE t1 ( USID INTEGER UNSIGNED, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User CHAR(32) NOT NULL DEFAULT '', NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL); -CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User TEXT NOT NULL, NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL, INDEX(USID,ServerID,NASAddr,SessionID), INDEX(AssignedAddr)); -INSERT INTO t1 VALUES (39,42,'Access-Granted','46','491721000045',2130706433,17690,NULL,NULL,'Localnet','491721000045','49172200000',754974766,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2003-07-18 00:11:21',NULL,NULL,20030718001121); -INSERT INTO t2 SELECT USID, ServerID, State, SessionID, User, NASAddr, NASPort, NASPortType, ConnectSpeed, CarrierType, CallingStationID, CalledStationID, AssignedAddr, SessionTime, PacketsIn, OctetsIn, PacketsOut, OctetsOut, TerminateCause, UnauthTime, AccessRequestTime, AcctStartTime, AcctLastTime, LastModification from t1 LIMIT 1; -drop table t1,t2; -CREATE TABLE t1( -Month date NOT NULL, -Type tinyint(3) unsigned NOT NULL auto_increment, -Field int(10) unsigned NOT NULL, -Count int(10) unsigned NOT NULL, -UNIQUE KEY Month (Month,Type,Field) -); -insert into t1 Values -(20030901, 1, 1, 100), -(20030901, 1, 2, 100), -(20030901, 2, 1, 100), -(20030901, 2, 2, 100), -(20030901, 3, 1, 100); -select * from t1; -Month Type Field Count -2003-09-01 1 1 100 -2003-09-01 1 2 100 -2003-09-01 2 1 100 -2003-09-01 2 2 100 -2003-09-01 3 1 100 -Select null, Field, Count From t1 Where Month=20030901 and Type=2; -NULL Field Count -NULL 1 100 -NULL 2 100 -create table t2(No int not null, Field int not null, Count int not null); -insert into t2 Select null, Field, Count From t1 Where Month=20030901 and Type=2; -Warnings: -Warning 1263 Data truncated; NULL supplied to NOT NULL column 'No' at row 1 -Warning 1263 Data truncated; NULL supplied to NOT NULL column 'No' at row 2 -select * from t2; -No Field Count -0 1 100 -0 2 100 -drop table t1, t2; -CREATE TABLE t1 ( -ID int(11) NOT NULL auto_increment, -NO int(11) NOT NULL default '0', -SEQ int(11) NOT NULL default '0', -PRIMARY KEY (ID), -KEY t1$NO (SEQ,NO) -) ENGINE=MyISAM; -INSERT INTO t1 (SEQ, NO) SELECT "1" AS SEQ, IF(MAX(NO) IS NULL, 0, MAX(NO)) + 1 AS NO FROM t1 WHERE (SEQ = 1); -select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1); -ID NO SEQ -1 1 1 -drop table t1; diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 227ff655fcd..6db48cff57e 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -924,3 +924,22 @@ a b a b 3 1 NULL NULL 4 2 NULL NULL DROP TABLE t1,t2; +set group_concat_max_len=5; +create table t1 (a int, b varchar(20)); +create table t2 (a int, c varchar(20)); +insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb"); +insert into t2 values (1,"cccccccccc"),(2,"dddddddddd"); +select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by t1.a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 2 line(s) were cut by GROUP_CONCAT() +select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by t1.a; +group_concat(t1.b,t2.c) +aaaaa +bbbbb +Warnings: +Warning 1260 2 line(s) were cut by GROUP_CONCAT() +drop table t1, t2; +set group_concat_max_len=default; diff --git a/mysql-test/r/kill.result b/mysql-test/r/kill.result index 2413834be4f..754568093ff 100644 --- a/mysql-test/r/kill.result +++ b/mysql-test/r/kill.result @@ -5,6 +5,8 @@ select ((@id := kill_id) - kill_id) from t1; ((@id := kill_id) - kill_id) 0 kill @id; +select 1; +Got one of the listed errors select ((@id := kill_id) - kill_id) from t1; ((@id := kill_id) - kill_id) 0 diff --git a/mysql-test/r/limit.result b/mysql-test/r/limit.result index 6a3d2bffab0..1e38f762dd1 100644 --- a/mysql-test/r/limit.result +++ b/mysql-test/r/limit.result @@ -1,5 +1,5 @@ drop table if exists t1; -create table t1 (a int primary key, b int not null); +create table t1 (a int not null default 0 primary key, b int not null default 0); insert into t1 () values (); insert into t1 values (1,1),(2,1),(3,1); update t1 set a=4 where b=1 limit 1; diff --git a/mysql-test/r/lowercase_view.result b/mysql-test/r/lowercase_view.result index 0644b32015c..37252c6dde7 100644 --- a/mysql-test/r/lowercase_view.result +++ b/mysql-test/r/lowercase_view.result @@ -11,16 +11,109 @@ vie CREATE ALGORITHM=UNDEFINED VIEW `mysqltest`.`vie` AS select `mysqltest`.`tab drop database MySQLTest; use test; create table t1Aa (col1 int); -create table t2Aa (col1 int); -create view v1Aa as select * from t1Aa; -create view v2Aa as select * from v1Aa; -update v2aA set col1 = (select max(col1) from v1aA); +create table t2aA (col1 int); +create view v1Aa as select * from t1aA; +create view v2aA as select * from v1aA; +create view v3Aa as select v2Aa.col1 from v2aA,t2Aa where v2Aa.col1 = t2aA.col1; +update v2aA set col1 = (select max(col1) from v1Aa); ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause -delete from v2aA where col1 = (select max(col1) from v1aA); +update v2Aa set col1 = (select max(col1) from t1Aa); ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause +update v2aA set col1 = (select max(col1) from v2Aa); +ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause +update v2aA,t2Aa set v2Aa.col1 = (select max(col1) from v1aA) where v2aA.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause +update t1aA,t2Aa set t1Aa.col1 = (select max(col1) from v1Aa) where t1aA.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 't1aa' for update in FROM clause +update v1aA,t2Aa set v1Aa.col1 = (select max(col1) from v1aA) where v1Aa.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 'v1aa' for update in FROM clause +update t2Aa,v2Aa set v2aA.col1 = (select max(col1) from v1aA) where v2Aa.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 't2aa' for update in FROM clause +update t2Aa,t1Aa set t1aA.col1 = (select max(col1) from v1Aa) where t1Aa.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 't2aa' for update in FROM clause +update t2Aa,v1aA set v1Aa.col1 = (select max(col1) from v1aA) where v1Aa.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 't2aa' for update in FROM clause +update v2aA,t2Aa set v2Aa.col1 = (select max(col1) from t1aA) where v2aA.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause +update t1Aa,t2Aa set t1aA.col1 = (select max(col1) from t1Aa) where t1aA.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 't1aa' for update in FROM clause +update v1aA,t2Aa set v1Aa.col1 = (select max(col1) from t1Aa) where v1aA.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 'v1aa' for update in FROM clause +update t2Aa,v2Aa set v2aA.col1 = (select max(col1) from t1aA) where v2Aa.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 't2aa' for update in FROM clause +update t2Aa,t1Aa set t1aA.col1 = (select max(col1) from t1Aa) where t1aA.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 't2aa' for update in FROM clause +update t2Aa,v1Aa set v1aA.col1 = (select max(col1) from t1Aa) where v1Aa.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 't2aa' for update in FROM clause +update v2aA,t2Aa set v2Aa.col1 = (select max(col1) from v2aA) where v2Aa.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause +update t1aA,t2Aa set t1Aa.col1 = (select max(col1) from v2aA) where t1aA.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 't1aa' for update in FROM clause +update v1aA,t2Aa set v1Aa.col1 = (select max(col1) from v2Aa) where v1aA.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 'v1aa' for update in FROM clause +update t2Aa,v2aA set v2Aa.col1 = (select max(col1) from v2aA) where v2Aa.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 't2aa' for update in FROM clause +update t2Aa,t1Aa set t1aA.col1 = (select max(col1) from v2aA) where t1Aa.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 't2aa' for update in FROM clause +update t2Aa,v1Aa set v1aA.col1 = (select max(col1) from v2Aa) where v1Aa.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 't2aa' for update in FROM clause +update v3aA set v3Aa.col1 = (select max(col1) from v1aA); +ERROR HY000: You can't specify target table 'v3aa' for update in FROM clause +update v3aA set v3Aa.col1 = (select max(col1) from t1aA); +ERROR HY000: You can't specify target table 'v3aa' for update in FROM clause +update v3aA set v3Aa.col1 = (select max(col1) from v2aA); +ERROR HY000: You can't specify target table 'v3aa' for update in FROM clause +update v3aA set v3Aa.col1 = (select max(col1) from v3aA); +ERROR HY000: You can't specify target table 'v3aa' for update in FROM clause +delete from v2Aa where col1 = (select max(col1) from v1Aa); +ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause +delete from v2aA where col1 = (select max(col1) from t1Aa); +ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause +delete from v2Aa where col1 = (select max(col1) from v2aA); +ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause +delete v2Aa from v2aA,t2Aa where (select max(col1) from v1aA) > 0 and v2Aa.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause +delete t1aA from t1Aa,t2Aa where (select max(col1) from v1Aa) > 0 and t1aA.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 't1aa' for update in FROM clause +delete v1aA from v1Aa,t2Aa where (select max(col1) from v1aA) > 0 and v1Aa.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 'v1aa' for update in FROM clause +delete v2aA from v2Aa,t2Aa where (select max(col1) from t1Aa) > 0 and v2aA.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause +delete t1aA from t1Aa,t2Aa where (select max(col1) from t1aA) > 0 and t1Aa.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 't1aa' for update in FROM clause +delete v1aA from v1Aa,t2Aa where (select max(col1) from t1aA) > 0 and v1aA.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 'v1aa' for update in FROM clause +delete v2Aa from v2aA,t2Aa where (select max(col1) from v2Aa) > 0 and v2aA.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause +delete t1Aa from t1aA,t2Aa where (select max(col1) from v2Aa) > 0 and t1Aa.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 't1aa' for update in FROM clause +delete v1Aa from v1aA,t2Aa where (select max(col1) from v2aA) > 0 and v1Aa.col1 = t2aA.col1; +ERROR HY000: You can't specify target table 'v1aa' for update in FROM clause +insert into v2Aa values ((select max(col1) from v1aA)); +ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause +insert into t1aA values ((select max(col1) from v1Aa)); +ERROR HY000: You can't specify target table 't1aa' for update in FROM clause insert into v2aA values ((select max(col1) from v1aA)); ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause -drop view v2Aa,v1Aa; +insert into v2Aa values ((select max(col1) from t1Aa)); +ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause +insert into t1aA values ((select max(col1) from t1Aa)); +ERROR HY000: You can't specify target table 't1aa' for update in FROM clause +insert into v2aA values ((select max(col1) from t1aA)); +ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause +insert into v2Aa values ((select max(col1) from v2aA)); +ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause +insert into t1Aa values ((select max(col1) from v2Aa)); +ERROR HY000: You can't specify target table 't1aa' for update in FROM clause +insert into v2aA values ((select max(col1) from v2Aa)); +ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause +insert into v3Aa (col1) values ((select max(col1) from v1Aa)); +ERROR HY000: You can't specify target table 'v3aa' for update in FROM clause +insert into v3aA (col1) values ((select max(col1) from t1aA)); +ERROR HY000: You can't specify target table 'v3aa' for update in FROM clause +insert into v3Aa (col1) values ((select max(col1) from v2aA)); +ERROR HY000: You can't specify target table 'v3aa' for update in FROM clause +drop view v3aA,v2Aa,v1aA; drop table t1Aa,t2Aa; create table t1Aa (col1 int); create view v1Aa as select col1 from t1Aa as AaA; diff --git a/mysql-test/r/mix_innodb_myisam_binlog.result b/mysql-test/r/mix_innodb_myisam_binlog.result index 7821c074202..e4528450b31 100644 --- a/mysql-test/r/mix_innodb_myisam_binlog.result +++ b/mysql-test/r/mix_innodb_myisam_binlog.result @@ -11,7 +11,7 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 98 Query 1 # use `test`; BEGIN master-bin.000001 166 Query 1 # use `test`; insert into t1 values(1) master-bin.000001 253 Query 1 # use `test`; insert into t2 select * from t1 -master-bin.000001 347 Xid 1 # COMMIT /* xid=7 */ +master-bin.000001 347 Xid 1 # COMMIT /* xid=8 */ delete from t1; delete from t2; reset master; @@ -47,7 +47,7 @@ master-bin.000001 253 Query 1 # use `test`; savepoint my_savepoint master-bin.000001 338 Query 1 # use `test`; insert into t1 values(4) master-bin.000001 425 Query 1 # use `test`; insert into t2 select * from t1 master-bin.000001 519 Query 1 # use `test`; rollback to savepoint my_savepoint -master-bin.000001 616 Xid 1 # COMMIT /* xid=24 */ +master-bin.000001 616 Xid 1 # COMMIT /* xid=25 */ delete from t1; delete from t2; reset master; @@ -74,7 +74,7 @@ master-bin.000001 338 Query 1 # use `test`; insert into t1 values(6) master-bin.000001 425 Query 1 # use `test`; insert into t2 select * from t1 master-bin.000001 519 Query 1 # use `test`; rollback to savepoint my_savepoint master-bin.000001 616 Query 1 # use `test`; insert into t1 values(7) -master-bin.000001 703 Xid 1 # COMMIT /* xid=36 */ +master-bin.000001 703 Xid 1 # COMMIT /* xid=37 */ delete from t1; delete from t2; reset master; @@ -101,7 +101,7 @@ insert into t2 select * from t1; show binlog events from 98; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 98 Query 1 # use `test`; insert into t1 values(9) -master-bin.000001 185 Xid 1 # COMMIT /* xid=59 */ +master-bin.000001 185 Xid 1 # COMMIT /* xid=60 */ master-bin.000001 212 Query 1 # use `test`; insert into t2 select * from t1 delete from t1; delete from t2; @@ -112,18 +112,18 @@ insert into t2 select * from t1; show binlog events from 98; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 98 Query 1 # use `test`; insert into t1 values(10) -master-bin.000001 186 Xid 1 # COMMIT /* xid=65 */ +master-bin.000001 186 Xid 1 # COMMIT /* xid=66 */ master-bin.000001 213 Query 1 # use `test`; insert into t2 select * from t1 insert into t1 values(11); commit; show binlog events from 98; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 98 Query 1 # use `test`; insert into t1 values(10) -master-bin.000001 186 Xid 1 # COMMIT /* xid=65 */ +master-bin.000001 186 Xid 1 # COMMIT /* xid=66 */ master-bin.000001 213 Query 1 # use `test`; insert into t2 select * from t1 master-bin.000001 307 Query 1 # use `test`; BEGIN master-bin.000001 375 Query 1 # use `test`; insert into t1 values(11) -master-bin.000001 463 Xid 1 # COMMIT /* xid=67 */ +master-bin.000001 463 Xid 1 # COMMIT /* xid=68 */ alter table t2 engine=INNODB; delete from t1; delete from t2; @@ -137,7 +137,7 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 98 Query 1 # use `test`; BEGIN master-bin.000001 166 Query 1 # use `test`; insert into t1 values(12) master-bin.000001 254 Query 1 # use `test`; insert into t2 select * from t1 -master-bin.000001 348 Xid 1 # COMMIT /* xid=77 */ +master-bin.000001 348 Xid 1 # COMMIT /* xid=78 */ delete from t1; delete from t2; reset master; @@ -161,7 +161,7 @@ show binlog events from 98; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 98 Query 1 # use `test`; BEGIN master-bin.000001 166 Query 1 # use `test`; insert into t1 values(14) -master-bin.000001 254 Xid 1 # COMMIT /* xid=93 */ +master-bin.000001 254 Xid 1 # COMMIT /* xid=94 */ delete from t1; delete from t2; reset master; @@ -182,7 +182,7 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 98 Query 1 # use `test`; BEGIN master-bin.000001 166 Query 1 # use `test`; insert into t1 values(16) master-bin.000001 254 Query 1 # use `test`; insert into t1 values(18) -master-bin.000001 342 Xid 1 # COMMIT /* xid=104 */ +master-bin.000001 342 Xid 1 # COMMIT /* xid=105 */ delete from t1; delete from t2; alter table t2 type=MyISAM; diff --git a/mysql-test/r/myisam-blob.result.es b/mysql-test/r/myisam-blob.result.es deleted file mode 100644 index 4031b9cfd1c..00000000000 --- a/mysql-test/r/myisam-blob.result.es +++ /dev/null @@ -1,59 +0,0 @@ -drop table if exists t1; -CREATE TABLE t1 (data LONGBLOB) ENGINE=myisam; -INSERT INTO t1 (data) VALUES (NULL); -UPDATE t1 set data=repeat('a',18*1024*1024); -Warnings: -Warning 1301 Result of repeat() was larger than max_allowed_packet (24) - truncated -select length(data) from t1; -length(data) -NULL -delete from t1 where left(data,1)='a'; -check table t1; -Table Op Msg_type Msg_text -test.t1 check status OK -truncate table t1; -INSERT INTO t1 (data) VALUES (repeat('a',1*1024*1024)); -Warnings: -Warning 1301 Result of repeat() was larger than max_allowed_packet (24) - truncated -INSERT INTO t1 (data) VALUES (repeat('b',16*1024*1024-1024)); -Warnings: -Warning 1301 Result of repeat() was larger than max_allowed_packet (24) - truncated -delete from t1 where left(data,1)='b'; -check table t1; -Table Op Msg_type Msg_text -test.t1 check status OK -UPDATE t1 set data=repeat('c',17*1024*1024); -Warnings: -Warning 1301 Result of repeat() was larger than max_allowed_packet (24) - truncated -Warning 1301 Result of repeat() was larger than max_allowed_packet (24) - truncated -check table t1; -Table Op Msg_type Msg_text -test.t1 check status OK -delete from t1 where left(data,1)='c'; -check table t1; -Table Op Msg_type Msg_text -test.t1 check status OK -INSERT INTO t1 set data=repeat('a',18*1024*1024); -Warnings: -Warning 1301 Result of repeat() was larger than max_allowed_packet (24) - truncated -select length(data) from t1; -length(data) -NULL -NULL -NULL -alter table t1 modify data blob; -select length(data) from t1; -length(data) -NULL -NULL -NULL -drop table t1; -CREATE TABLE t1 (data BLOB) ENGINE=myisam; -INSERT INTO t1 (data) VALUES (NULL); -UPDATE t1 set data=repeat('a',18*1024*1024); -Warnings: -Warning 1301 Result of repeat() was larger than max_allowed_packet (24) - truncated -select length(data) from t1; -length(data) -NULL -drop table t1; diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 42cb1306680..539df03e6f9 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -586,6 +586,14 @@ truncate table t1; ERROR HY000: MyISAM table 't1' is in use (most likely by a MERGE table). Try FLUSH TABLES. insert into t1 values (1); drop table t1,t2; +create table t1 (c1 int, c2 varchar(4) not null default '', +key(c2(3))) default charset=utf8; +insert into t1 values (1,'A'), (2, 'B'), (3, 'A'); +update t1 set c2='A B' where c1=2; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; set storage_engine=MyISAM; drop table if exists t1,t2,t3; --- Testing varchar --- diff --git a/mysql-test/r/ndb_alter_table.result b/mysql-test/r/ndb_alter_table.result index 9bc82e7a24a..6f4d84edef5 100644 --- a/mysql-test/r/ndb_alter_table.result +++ b/mysql-test/r/ndb_alter_table.result @@ -40,7 +40,7 @@ insert into t1 values (0,4,3,5,"PENDING",1,7),(NULL,4,3,5,"PENDING",1,7),(31,4,3,5,"PENDING",1,7), (7,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7), (100,4,3,5,"PENDING",1,7), (99,4,3,5,"PENDING",1,7), (8,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ndbcluster 10 Dynamic 9 96 # # 0 # 101 # # # latin1_swedish_ci NULL # +t1 ndbcluster 10 Dynamic 9 96 # # 0 # 102 # # # latin1_swedish_ci NULL # select * from t1 order by col1; col1 col2 col3 col4 col5 col6 to_be_deleted 0 4 3 5 PENDING 1 7 @@ -179,7 +179,7 @@ a b c 2 two two alter table t1 drop index c; select * from t1 where b = 'two'; -ERROR 42S02: Table 'test.t1' doesn't exist +ERROR HY000: Table definition has changed, please retry transaction select * from t1 where b = 'two'; a b c 2 two two diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result index e1aa045d16e..6383a636cad 100644 --- a/mysql-test/r/ndb_basic.result +++ b/mysql-test/r/ndb_basic.result @@ -607,3 +607,63 @@ primary key (a)) engine=ndb max_rows=1; drop table t1; +create table t1 +(counter int(64) NOT NULL auto_increment, +datavalue char(40) default 'XXXX', +primary key (counter) +) ENGINE=ndbcluster; +insert into t1 (datavalue) values ('newval'); +insert into t1 (datavalue) values ('newval'); +select * from t1 order by counter; +counter datavalue +1 newval +2 newval +insert into t1 (datavalue) select datavalue from t1 where counter < 100; +insert into t1 (datavalue) select datavalue from t1 where counter < 100; +select * from t1 order by counter; +counter datavalue +1 newval +2 newval +3 newval +4 newval +5 newval +6 newval +7 newval +8 newval +insert into t1 (datavalue) select datavalue from t1 where counter < 100; +insert into t1 (datavalue) select datavalue from t1 where counter < 100; +select * from t1 order by counter; +counter datavalue +1 newval +2 newval +3 newval +4 newval +5 newval +6 newval +7 newval +8 newval +35 newval +36 newval +37 newval +38 newval +39 newval +40 newval +41 newval +42 newval +43 newval +44 newval +45 newval +46 newval +47 newval +48 newval +49 newval +50 newval +51 newval +52 newval +53 newval +54 newval +55 newval +56 newval +57 newval +58 newval +drop table t1; diff --git a/mysql-test/r/ndb_condition_pushdown.result b/mysql-test/r/ndb_condition_pushdown.result index f9f4104b4ea..7f769154212 100644 --- a/mysql-test/r/ndb_condition_pushdown.result +++ b/mysql-test/r/ndb_condition_pushdown.result @@ -1023,6 +1023,62 @@ auto 1 3 4 +update t1 +set medium = 17 +where +string = "aaaa" and +vstring = "aaaa" and +bin = 0xAAAA and +vbin = 0xAAAA and +tiny = -1 and +short = -1 and +medium = -1 and +long_int = -1 and +longlong = -1 and +real_float > 1.0 and real_float < 2.0 and +real_double > 1.0 and real_double < 2.0 and +real_decimal > 1.0 and real_decimal < 2.0 and +utiny = 1 and +ushort = 1 and +umedium = 1 and +ulong = 1 and +ulonglong = 1 and +/* bits = b'001' and */ +options = 'one' and +flags = 'one' and +date_field = '1901-01-01' and +year_field = '1901' and +time_field = '01:01:01' and +date_time = '1901-01-01 01:01:01'; +delete from t1 +where +string = "aaaa" and +vstring = "aaaa" and +bin = 0xAAAA and +vbin = 0xAAAA and +tiny = -1 and +short = -1 and +medium = 17 and +long_int = -1 and +longlong = -1 and +real_float > 1.0 and real_float < 2.0 and +real_double > 1.0 and real_double < 2.0 and +real_decimal > 1.0 and real_decimal < 2.0 and +utiny = 1 and +ushort = 1 and +umedium = 1 and +ulong = 1 and +ulonglong = 1 and +/* bits = b'001' and */ +options = 'one' and +flags = 'one' and +date_field = '1901-01-01' and +year_field = '1901' and +time_field = '01:01:01' and +date_time = '1901-01-01 01:01:01'; +select count(*) from t1; +count(*) +3 explain select * from t2 where attr3 is null or attr1 > 2 and pk1= 3 order by pk1; id select_type table type possible_keys key key_len ref rows Extra @@ -1078,7 +1134,7 @@ pk1 attr1 attr2 attr3 attr4 pk1 attr1 attr2 attr3 attr4 explain select auto from t1 where string = "aaaa" collate latin1_general_ci order by auto; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; Using filesort +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using filesort explain select * from t2 where (attr1 < 2) = (attr2 < 2) order by pk1; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/r/ndb_index_unique.result b/mysql-test/r/ndb_index_unique.result index 517d09ddf29..1401ae26ddb 100644 --- a/mysql-test/r/ndb_index_unique.result +++ b/mysql-test/r/ndb_index_unique.result @@ -248,8 +248,8 @@ INSERT INTO t3 VALUES (1,'V1',NULL); CREATE TABLE t4 ( uid bigint(20) unsigned NOT NULL default '0', gid bigint(20) unsigned NOT NULL, -rid bigint(20) unsigned NOT NULL default '-1', -cid bigint(20) unsigned NOT NULL default '-1', +rid bigint(20) unsigned NOT NULL, +cid bigint(20) unsigned NOT NULL, UNIQUE KEY m (uid,gid,rid,cid) ) engine=ndbcluster; INSERT INTO t4 VALUES (1,1,2,4); @@ -275,8 +275,8 @@ CREATE TABLE t7 ( mid bigint(20) unsigned NOT NULL PRIMARY KEY, uid bigint(20) unsigned NOT NULL default '0', gid bigint(20) unsigned NOT NULL, -rid bigint(20) unsigned NOT NULL default '-1', -cid bigint(20) unsigned NOT NULL default '-1', +rid bigint(20) unsigned NOT NULL, +cid bigint(20) unsigned NOT NULL, UNIQUE KEY m (uid,gid,rid,cid) ) engine=ndbcluster; INSERT INTO t7 VALUES(1, 1, 1, 1, 1); diff --git a/mysql-test/r/ndb_multi.result b/mysql-test/r/ndb_multi.result index 4a2389cd1ff..5696fda1c07 100644 --- a/mysql-test/r/ndb_multi.result +++ b/mysql-test/r/ndb_multi.result @@ -47,3 +47,4 @@ t2 t3 t4 drop table t1, t2, t3, t4; +drop table t1, t3, t4; diff --git a/mysql-test/r/ndb_types.result b/mysql-test/r/ndb_types.result index 9a45b77149b..37ce7732f65 100644 --- a/mysql-test/r/ndb_types.result +++ b/mysql-test/r/ndb_types.result @@ -2,6 +2,9 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( auto int(5) unsigned NOT NULL auto_increment, string char(10) default "hello", +vstring varchar(10) default "hello", +bin binary(7), +vbin varbinary(7), tiny tinyint(4) DEFAULT '0' NOT NULL , short smallint(6) DEFAULT '1' NOT NULL , medium mediumint(8) DEFAULT '0' NOT NULL, @@ -9,17 +12,20 @@ long_int int(11) DEFAULT '0' NOT NULL, longlong bigint(13) DEFAULT '0' NOT NULL, real_float float(13,1) DEFAULT 0.0 NOT NULL, real_double double(16,4), +real_decimal decimal(16,4), utiny tinyint(3) unsigned DEFAULT '0' NOT NULL, ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL, umedium mediumint(8) unsigned DEFAULT '0' NOT NULL, ulong int(11) unsigned DEFAULT '0' NOT NULL, ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL, -time_stamp timestamp, -date_field date, -time_field time, -date_time datetime, +bits bit(3), options enum('one','two','tree') not null, flags set('one','two','tree') not null, +date_field date, +year_field year, +time_field time, +date_time datetime, +time_stamp timestamp not null default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, PRIMARY KEY (auto), KEY (utiny), KEY (tiny), @@ -33,4 +39,37 @@ KEY (ulong), KEY (ulonglong,ulong), KEY (options,flags) ); +set @now = now(); +insert into t1 +(string,vstring,bin,vbin,tiny,short,medium,long_int,longlong, +real_float,real_double, real_decimal,utiny, ushort, umedium,ulong,ulonglong, +bits,options,flags,date_field,year_field,time_field,date_time) +values +("aaaa","aaaa",0xAAAA,0xAAAA,-1,-1,-1,-1,-1,1.1,1.1,1.1,1,1,1,1,1, +b'001','one','one', '1901-01-01','1901','01:01:01','1901-01-01 01:01:01'); +select auto,string,vstring,bin,vbin,tiny,short,medium,long_int,longlong, +real_float,real_double,real_decimal,utiny,ushort,umedium,ulong,ulonglong, +bits,options,flags,date_field,year_field,time_field,date_time +from t1; +auto string vstring bin vbin tiny short medium long_int longlong real_float real_double real_decimal utiny ushort umedium ulong ulonglong bits options flags date_field year_field time_field date_time +1 aaaa aaaa ªª ªª -1 -1 -1 -1 -1 1.1 1.1000 1.1000 1 00001 1 1 1  one one 1901-01-01 1901 01:01:01 1901-01-01 01:01:01 +select time_stamp>@now from t1; +time_stamp>@now +1 +set @now = now(); +update t1 set string="bbbb",vstring="bbbb",bin=0xBBBB,vbin=0xBBBB, +tiny=-2,short=-2,medium=-2,long_int=-2,longlong=-2,real_float=2.2, +real_double=2.2,real_decimal=2.2,utiny=2,ushort=2,umedium=2,ulong=2, +ulonglong=2, bits=b'010', +options='one',flags='one', date_field='1902-02-02',year_field='1902', +time_field='02:02:02',date_time='1902-02-02 02:02:02' where auto=1; +select auto,string,vstring,bin,vbin,tiny,short,medium,long_int,longlong, +real_float,real_double,real_decimal,utiny,ushort,umedium,ulong,ulonglong, +bits,options,flags,date_field,year_field,time_field,date_time +from t1; +auto string vstring bin vbin tiny short medium long_int longlong real_float real_double real_decimal utiny ushort umedium ulong ulonglong bits options flags date_field year_field time_field date_time +1 bbbb bbbb »» »» -2 -2 -2 -2 -2 2.2 2.2000 2.2000 2 00002 2 2 2  one one 1902-02-02 1902 02:02:02 1902-02-02 02:02:02 +select time_stamp>@now from t1; +time_stamp>@now +1 drop table t1; diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result index 9f05703e69e..c2b925072dd 100644 --- a/mysql-test/r/null.result +++ b/mysql-test/r/null.result @@ -88,7 +88,7 @@ b ifnull(t2.b,"this is null") NULL this is null NULL this is null drop table t1; -CREATE TABLE t1 (a varchar(16) NOT NULL, b smallint(6) NOT NULL, c datetime NOT NULL, d smallint(6) NOT NULL); +CREATE TABLE t1 (a varchar(16) NOT NULL default '', b smallint(6) NOT NULL default 0, c datetime NOT NULL default '0000-00-00 00:00:00', d smallint(6) NOT NULL default 0); INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55"; Warnings: Warning 1265 Data truncated for column 'd' at row 1 diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index 3474da93d75..628ca5fd958 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -257,7 +257,7 @@ favo_tijdschrift varchar(50) NOT NULL default '', favo_tv varchar(50) NOT NULL default '', favo_eten varchar(50) NOT NULL default '', favo_muziek varchar(30) NOT NULL default '', -info text NOT NULL, +info text NOT NULL default '', ipnr varchar(30) NOT NULL default '', PRIMARY KEY (member_id) ) ENGINE=MyISAM PACK_KEYS=1; diff --git a/mysql-test/r/packet.result.es b/mysql-test/r/packet.result.es deleted file mode 100644 index 0ff587b3957..00000000000 --- a/mysql-test/r/packet.result.es +++ /dev/null @@ -1,26 +0,0 @@ -set global max_allowed_packet=100; -set max_allowed_packet=100; -set global net_buffer_length=100; -set net_buffer_length=100; -SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len; -len -1024 -select repeat('a',2000); -repeat('a',2000) -NULL -Warnings: -Warning 1301 Result of repeat() was larger than max_allowed_packet (1024) - truncated -select @@net_buffer_length, @@max_allowed_packet; -@@net_buffer_length @@max_allowed_packet -1024 1024 -SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len; -set global max_allowed_packet=default; -set max_allowed_packet=default; -set global net_buffer_length=default; -set net_buffer_length=default; -SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len; -len -100 -select length(repeat('a',2000)); -length(repeat('a',2000)) -2000 diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 5b638fd58ab..bbd95da2f82 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -524,3 +524,49 @@ execute stmt using @a, @b, @c; a b c a b c deallocate prepare stmt; drop table t1,t2; +SET @aux= "SELECT COUNT(*) + FROM INFORMATION_SCHEMA.COLUMNS A, + INFORMATION_SCHEMA.COLUMNS B + WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA + AND A.TABLE_NAME = B.TABLE_NAME + AND A.COLUMN_NAME = B.COLUMN_NAME AND + A.TABLE_NAME = 'user'"; +prepare my_stmt from @aux; +execute my_stmt; +COUNT(*) +37 +execute my_stmt; +COUNT(*) +37 +execute my_stmt; +COUNT(*) +37 +deallocate prepare my_stmt; +drop procedure if exists p1| +drop table if exists t1| +create table t1 (id int)| +insert into t1 values(1)| +create procedure p1(a int, b int) +begin +declare c int; +select max(id)+1 into c from t1; +insert into t1 select a+b; +insert into t1 select a-b; +insert into t1 select a-c; +end| +set @a= 3, @b= 4| +prepare stmt from "call p1(?, ?)"| +execute stmt using @a, @b| +execute stmt using @a, @b| +select * from t1| +id +1 +7 +-1 +1 +7 +-1 +-5 +deallocate prepare stmt| +drop procedure p1| +drop table t1| diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result index 06acb72f49b..0fe907ac8c1 100644 --- a/mysql-test/r/ps_1general.result +++ b/mysql-test/r/ps_1general.result @@ -305,10 +305,6 @@ Variable_name Value sql_mode prepare stmt4 from ' show engine bdb logs '; execute stmt4; -prepare stmt4 from ' show full processlist '; -execute stmt4; -Id User Host db Command Time State Info -number root localhost test Query time NULL show full processlist prepare stmt4 from ' show grants for user '; prepare stmt4 from ' show create table t2 '; ERROR HY000: This command is not supported in the prepared statement protocol yet @@ -414,18 +410,6 @@ create database mysqltest ; prepare stmt3 from ' drop database mysqltest '; ERROR HY000: This command is not supported in the prepared statement protocol yet drop database mysqltest ; -prepare stmt3 from ' grant all on test.t1 to drop_user@localhost -identified by ''looser'' '; -ERROR HY000: This command is not supported in the prepared statement protocol yet -grant all on test.t1 to drop_user@localhost -identified by 'looser' ; -prepare stmt3 from ' revoke all privileges on test.t1 from -drop_user@localhost '; -ERROR HY000: This command is not supported in the prepared statement protocol yet -revoke all privileges on test.t1 from drop_user@localhost ; -prepare stmt3 from ' drop user drop_user@localhost '; -ERROR HY000: This command is not supported in the prepared statement protocol yet -drop user drop_user@localhost; prepare stmt3 from ' describe t2 '; execute stmt3; Field Type Null Key Default Extra @@ -464,17 +448,17 @@ select 'a' || 'b' ; ab prepare stmt4 from ' SET sql_mode="" '; execute stmt4; -select 'a' || 'b' ; -'a' || 'b' -0 -prepare stmt5 from ' select ''a'' || ''b'' ' ; +select '2' || '3' ; +'2' || '3' +1 +prepare stmt5 from ' select ''2'' || ''3'' ' ; execute stmt5; -'a' || 'b' -0 +'2' || '3' +1 SET sql_mode=ansi; execute stmt5; -'a' || 'b' -0 +'2' || '3' +1 SET sql_mode=""; prepare stmt1 from ' flush local privileges ' ; ERROR HY000: This command is not supported in the prepared statement protocol yet @@ -576,7 +560,7 @@ drop table t2; prepare stmt1 from ' rename table t5 to t6, t7 to t8 ' ; create table t5 (a int) ; execute stmt1 ; -ERROR HY000: Can't find file: './test/t7.frm' (errno: 2) +ERROR HY000: Can't find file: './test/t7' (errno: 2) create table t7 (a int) ; execute stmt1 ; execute stmt1 ; @@ -820,81 +804,3 @@ execute stmt1 ; prepare stmt1 from ' select * from t5 ' ; execute stmt1 ; drop table t5 ; -test_sequence ------- grant/revoke/drop affects a parallel session test ------ -show grants for second_user@localhost ; -ERROR 42000: There is no such grant defined for user 'second_user' on host 'localhost' -create database mysqltest; -use mysqltest; -use test; -grant usage on mysqltest.* to second_user@localhost -identified by 'looser' ; -grant select on mysqltest.t9 to second_user@localhost -identified by 'looser' ; -show grants for second_user@localhost ; -Grants for second_user@localhost -GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' -GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost' -select current_user(); -current_user() -second_user@localhost -show grants for current_user(); -Grants for second_user@localhost -GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' -GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost' -prepare s_t9 from 'select c1 as my_col - from t9 where c1= 1' ; -execute s_t9 ; -my_col -1 -select a as my_col from t1; -ERROR 42000: SELECT command denied to user 'second_user'@'localhost' for table 't1' -grant select on mysqltest.t1 to second_user@localhost -identified by 'looser' ; -show grants for second_user@localhost ; -Grants for second_user@localhost -GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' -GRANT SELECT ON `mysqltest`.`t1` TO 'second_user'@'localhost' -GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost' -drop table mysqltest.t9 ; -show grants for second_user@localhost ; -Grants for second_user@localhost -GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' -GRANT SELECT ON `mysqltest`.`t1` TO 'second_user'@'localhost' -GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost' -show grants for second_user@localhost ; -Grants for second_user@localhost -GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' -GRANT SELECT ON `mysqltest`.`t1` TO 'second_user'@'localhost' -GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost' -prepare s_t1 from 'select a as my_col from t1' ; -execute s_t1 ; -my_col -1 -2 -3 -4 -execute s_t9 ; -ERROR 42S02: Table 'mysqltest.t9' doesn't exist -revoke all privileges on mysqltest.t1 from second_user@localhost -identified by 'looser' ; -show grants for second_user@localhost ; -Grants for second_user@localhost -GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' -GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost' -show grants for second_user@localhost ; -Grants for second_user@localhost -GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' -GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost' -execute s_t1 ; -ERROR 42000: SELECT command denied to user 'second_user'@'localhost' for table 't1' -revoke all privileges, grant option from second_user@localhost ; -show grants for second_user@localhost ; -Grants for second_user@localhost -GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' -drop user second_user@localhost ; -commit ; -show grants for second_user@localhost ; -ERROR 42000: There is no such grant defined for user 'second_user' on host 'localhost' -drop table t1,t9 ; -drop database mysqltest; diff --git a/mysql-test/r/ps_grant.result b/mysql-test/r/ps_grant.result new file mode 100644 index 00000000000..3a302ba3ba8 --- /dev/null +++ b/mysql-test/r/ps_grant.result @@ -0,0 +1,93 @@ +prepare stmt4 from ' show full processlist '; +execute stmt4; +Id User Host db Command Time State Info +number root localhost test Query time NULL show full processlist +test_sequence +------ grant/revoke/drop affects a parallel session test ------ +show grants for second_user@localhost ; +ERROR 42000: There is no such grant defined for user 'second_user' on host 'localhost' +create database mysqltest; +use mysqltest; +use test; +grant usage on mysqltest.* to second_user@localhost +identified by 'looser' ; +grant select on mysqltest.t9 to second_user@localhost +identified by 'looser' ; +show grants for second_user@localhost ; +Grants for second_user@localhost +GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' +GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost' +select current_user(); +current_user() +second_user@localhost +show grants for current_user(); +Grants for second_user@localhost +GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' +GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost' +prepare s_t9 from 'select c1 as my_col + from t9 where c1= 1' ; +execute s_t9 ; +my_col +1 +select a as my_col from t1; +ERROR 42000: SELECT command denied to user 'second_user'@'localhost' for table 't1' +grant select on mysqltest.t1 to second_user@localhost +identified by 'looser' ; +show grants for second_user@localhost ; +Grants for second_user@localhost +GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' +GRANT SELECT ON `mysqltest`.`t1` TO 'second_user'@'localhost' +GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost' +drop table mysqltest.t9 ; +show grants for second_user@localhost ; +Grants for second_user@localhost +GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' +GRANT SELECT ON `mysqltest`.`t1` TO 'second_user'@'localhost' +GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost' +show grants for second_user@localhost ; +Grants for second_user@localhost +GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' +GRANT SELECT ON `mysqltest`.`t1` TO 'second_user'@'localhost' +GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost' +prepare s_t1 from 'select a as my_col from t1' ; +execute s_t1 ; +my_col +1 +2 +3 +4 +execute s_t9 ; +ERROR 42S02: Table 'mysqltest.t9' doesn't exist +revoke all privileges on mysqltest.t1 from second_user@localhost +identified by 'looser' ; +show grants for second_user@localhost ; +Grants for second_user@localhost +GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' +GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost' +show grants for second_user@localhost ; +Grants for second_user@localhost +GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' +GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost' +execute s_t1 ; +ERROR 42000: SELECT command denied to user 'second_user'@'localhost' for table 't1' +revoke all privileges, grant option from second_user@localhost ; +show grants for second_user@localhost ; +Grants for second_user@localhost +GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD '*13843FE600B19A81E32AF50D4A6FED25875FF1F3' +drop user second_user@localhost ; +commit ; +show grants for second_user@localhost ; +ERROR 42000: There is no such grant defined for user 'second_user' on host 'localhost' +drop database mysqltest; +prepare stmt3 from ' grant all on test.t1 to drop_user@localhost +identified by ''looser'' '; +ERROR HY000: This command is not supported in the prepared statement protocol yet +grant all on test.t1 to drop_user@localhost +identified by 'looser' ; +prepare stmt3 from ' revoke all privileges on test.t1 from +drop_user@localhost '; +ERROR HY000: This command is not supported in the prepared statement protocol yet +revoke all privileges on test.t1 from drop_user@localhost ; +prepare stmt3 from ' drop user drop_user@localhost '; +ERROR HY000: This command is not supported in the prepared statement protocol yet +drop user drop_user@localhost; diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index 6863534b2d8..8db57104477 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -299,6 +299,8 @@ select UNIX_TIMESTAMP() from t1; UNIX_TIMESTAMP() select USER() from t1; USER() +select CURRENT_USER() from t1; +CURRENT_USER() select benchmark(1,1) from t1; benchmark(1,1) explain extended select benchmark(1,1) from t1; diff --git a/mysql-test/r/query_cache.result.es b/mysql-test/r/query_cache.result.es deleted file mode 100644 index 7e75a3cee4c..00000000000 --- a/mysql-test/r/query_cache.result.es +++ /dev/null @@ -1,925 +0,0 @@ -set GLOBAL query_cache_size=1355776; -flush query cache; -flush query cache; -reset query cache; -flush status; -drop table if exists t1,t2,t3,t4,t11,t21; -drop database if exists mysqltest; -create table t1 (a int not null); -insert into t1 values (1),(2),(3); -select * from t1; -a -1 -2 -3 -select * from t1; -a -1 -2 -3 -select sql_no_cache * from t1; -a -1 -2 -3 -select length(now()) from t1; -length(now()) -19 -19 -19 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 1 -show status like "Qcache_inserts"; -Variable_name Value -Qcache_inserts 1 -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 1 -drop table t1; -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -create table t1 (a int not null); -insert into t1 values (1),(2),(3); -create table t2 (a int not null); -insert into t2 values (4),(5),(6); -create table t3 (a int not null) engine=MERGE UNION=(t1,t2) INSERT_METHOD=FIRST; -select * from t3; -a -1 -2 -3 -4 -5 -6 -select * from t3; -a -1 -2 -3 -4 -5 -6 -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 2 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 1 -insert into t2 values (7); -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -select * from t1; -a -1 -2 -3 -select * from t1; -a -1 -2 -3 -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 3 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 1 -insert into t3 values (8); -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -select * from t3; -a -1 -2 -3 -8 -4 -5 -6 -7 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 1 -update t2 set a=9 where a=7; -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -select * from t1; -a -1 -2 -3 -8 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 1 -update t3 set a=10 where a=1; -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -select * from t3; -a -10 -2 -3 -8 -4 -5 -6 -9 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 1 -delete from t2 where a=9; -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -select * from t1; -a -10 -2 -3 -8 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 1 -delete from t3 where a=10; -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -drop table t1, t2, t3; -create table t1 (a int not null); -insert into t1 values (1),(2),(3); -create table t2 (a int not null); -insert into t2 values (1),(2),(3); -select * from t1; -a -1 -2 -3 -select * from t2; -a -1 -2 -3 -insert into t1 values (4); -show status like "Qcache_free_blocks"; -Variable_name Value -Qcache_free_blocks 2 -flush query cache; -show status like "Qcache_free_blocks"; -Variable_name Value -Qcache_free_blocks 1 -drop table t1, t2; -create table t1 (a text not null); -create table t11 (a text not null); -create table t2 (a text not null); -create table t21 (a text not null); -create table t3 (a text not null); -insert into t1 values("1111111111111111111111111111111111111111111111111111"); -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t11 select * from t1; -insert into t21 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t3 select * from t1; -insert into t3 select * from t2; -insert into t3 select * from t1; -select * from t11; -select * from t21; -show status like "Qcache_total_blocks"; -Variable_name Value -Qcache_total_blocks 7 -show status like "Qcache_free_blocks"; -Variable_name Value -Qcache_free_blocks 1 -insert into t11 values(""); -select * from t3; -show status like "Qcache_total_blocks"; -Variable_name Value -Qcache_total_blocks 8 -show status like "Qcache_free_blocks"; -Variable_name Value -Qcache_free_blocks 2 -flush query cache; -show status like "Qcache_total_blocks"; -Variable_name Value -Qcache_total_blocks 7 -show status like "Qcache_free_blocks"; -Variable_name Value -Qcache_free_blocks 1 -drop table t1, t2, t3, t11, t21; -set query_cache_type=demand; -create table t1 (a int not null); -insert into t1 values (1),(2),(3); -select * from t1; -a -1 -2 -3 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -select sql_cache * from t1 union select * from t1; -a -1 -2 -3 -set query_cache_type=2; -select sql_cache * from t1 union select * from t1; -a -1 -2 -3 -select * from t1 union select sql_cache * from t1; -a -1 -2 -3 -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 4 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 2 -set query_cache_type=on; -reset query cache; -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -select sql_no_cache * from t1; -a -1 -2 -3 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -drop table t1; -create table t1 (a text not null); -select CONNECTION_ID() from t1; -CONNECTION_ID() -select FOUND_ROWS(); -FOUND_ROWS() -0 -select NOW() from t1; -NOW() -select CURDATE() from t1; -CURDATE() -select CURTIME() from t1; -CURTIME() -select DATABASE() from t1; -DATABASE() -select ENCRYPT("test") from t1; -ENCRYPT("test") -select LAST_INSERT_ID() from t1; -LAST_INSERT_ID() -select RAND() from t1; -RAND() -select UNIX_TIMESTAMP() from t1; -UNIX_TIMESTAMP() -select USER() from t1; -USER() -select benchmark(1,1) from t1; -benchmark(1,1) -explain extended select benchmark(1,1) from t1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found -Warnings: -Note 1003 select sql_no_cache benchmark(1,1) AS `benchmark(1,1)` from test.t1 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -create table t2 (a text not null); -insert into t1 values("1111111111111111111111111111111111111111111111111111"); -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 4 -show status like "Qcache_lowmem_prunes"; -Variable_name Value -Qcache_lowmem_prunes 0 -select a as a1, a as a2 from t1; -select a as a2, a as a3 from t1; -select a as a3, a as a4 from t1; -select a as a1, a as a2 from t1; -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 4 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 2 -show status like "Qcache_lowmem_prunes"; -Variable_name Value -Qcache_lowmem_prunes 2 -reset query cache; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -select * from t1; -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -drop table t1,t2; -create database mysqltest; -create table mysqltest.t1 (i int not null auto_increment, a int, primary key (i)); -insert into mysqltest.t1 (a) values (1); -select * from mysqltest.t1 where i is null; -i a -1 1 -create table t1(a int); -select * from t1; -a -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 2 -select * from mysqltest.t1; -i a -1 1 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 3 -drop database mysqltest; -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 1 -drop table t1; -create table t1 (a char(1) not null collate koi8r_general_ci); -insert into t1 values(_koi8r"á"); -set CHARACTER SET koi8r; -select * from t1; -a -á -set CHARACTER SET cp1251_koi8; -select * from t1; -a -À -set CHARACTER SET DEFAULT; -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 2 -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 4 -drop table t1; -create database if not exists mysqltest; -create table mysqltest.t1 (i int not null); -create table t1 (i int not null); -insert into mysqltest.t1 (i) values (1); -insert into t1 (i) values (2); -select * from t1; -i -2 -use mysqltest; -select * from t1; -i -1 -select * from t1; -i -1 -use test; -select * from t1; -i -2 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 2 -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 6 -drop database mysqltest; -drop table t1; -create table t1 (i int not null); -insert into t1 (i) values (1),(2),(3),(4); -select SQL_CALC_FOUND_ROWS * from t1 limit 2; -i -1 -2 -select FOUND_ROWS(); -FOUND_ROWS() -4 -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 6 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 1 -select * from t1 where i=1; -i -1 -select FOUND_ROWS(); -FOUND_ROWS() -1 -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 6 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 2 -select SQL_CALC_FOUND_ROWS * from t1 limit 2; -i -1 -2 -select FOUND_ROWS(); -FOUND_ROWS() -4 -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 7 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 2 -select * from t1 where i=1; -i -1 -select FOUND_ROWS(); -FOUND_ROWS() -1 -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 8 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 2 -drop table t1; -flush query cache; -reset query cache; -create table t1 (a int not null); -insert into t1 values (1),(2),(3); -select * from t1; -a -1 -2 -3 -select * from t1; -a -1 -2 -3 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 1 -insert delayed into t1 values (4); -select a from t1; -a -1 -2 -3 -4 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 1 -drop table t1; -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -show global variables like "query_cache_min_res_unit"; -Variable_name Value -query_cache_min_res_unit 4096 -set GLOBAL query_cache_min_res_unit=1001; -show global variables like "query_cache_min_res_unit"; -Variable_name Value -query_cache_min_res_unit 1008 -create table t1 (a int not null); -insert into t1 values (1),(2),(3); -create table t2 (a int not null); -insert into t2 values (1),(2),(3); -select * from t1; -a -1 -2 -3 -select * from t1; -a -1 -2 -3 -select * from t2; -a -1 -2 -3 -select * from t2; -a -1 -2 -3 -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 11 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 2 -drop table t1; -select a from t2; -a -1 -2 -3 -select a from t2; -a -1 -2 -3 -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 12 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 2 -drop table t2; -set GLOBAL query_cache_min_res_unit=default; -show global variables like "query_cache_min_res_unit"; -Variable_name Value -query_cache_min_res_unit 4096 -create table t1 (a int not null); -insert into t1 values (1); -select "aaa" from t1; -aaa -aaa -select "AAA" from t1; -AAA -AAA -drop table t1; -create table t1 (a int); -set GLOBAL query_cache_size=1000; -show global variables like "query_cache_size"; -Variable_name Value -query_cache_size 0 -select * from t1; -a -set GLOBAL query_cache_size=1024; -Warnings: -Warning 1282 Query cache failed to set size 1024; new query cache size is 0 -show global variables like "query_cache_size"; -Variable_name Value -query_cache_size 0 -select * from t1; -a -set GLOBAL query_cache_size=10240; -Warnings: -Warning 1282 Query cache failed to set size 10240; new query cache size is 0 -show global variables like "query_cache_size"; -Variable_name Value -query_cache_size 0 -select * from t1; -a -set GLOBAL query_cache_size=20480; -Warnings: -Warning 1282 Query cache failed to set size 20480; new query cache size is 0 -show global variables like "query_cache_size"; -Variable_name Value -query_cache_size 0 -select * from t1; -a -set GLOBAL query_cache_size=40960; -Warnings: -Warning 1282 Query cache failed to set size 40960; new query cache size is 0 -show global variables like "query_cache_size"; -Variable_name Value -query_cache_size 0 -select * from t1; -a -set GLOBAL query_cache_size=51200; -show global variables like "query_cache_size"; -Variable_name Value -query_cache_size 51200 -select * from t1; -a -set GLOBAL query_cache_size=61440; -show global variables like "query_cache_size"; -Variable_name Value -query_cache_size 61440 -select * from t1; -a -set GLOBAL query_cache_size=81920; -show global variables like "query_cache_size"; -Variable_name Value -query_cache_size 81920 -select * from t1; -a -set GLOBAL query_cache_size=102400; -show global variables like "query_cache_size"; -Variable_name Value -query_cache_size 102400 -select * from t1; -a -drop table t1; -set GLOBAL query_cache_size=1048576; -create table t1 (i int not null); -create table t2 (i int not null); -select * from t1; -i -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 1 -create temporary table t3 (i int not null); -select * from t2; -i -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 2 -select * from t3; -i -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 2 -update t1 set i=(select distinct 1 from (select * from t2) a); -drop table t1, t2, t3; -use mysql; -select * from db; -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -use test; -select * from mysql.db; -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -create table t1(id int auto_increment primary key); -insert into t1 values (NULL), (NULL), (NULL); -select * from t1 where id=2; -id -2 -alter table t1 rename to t2; -select * from t1 where id=2; -ERROR 42S02: Table 'test.t1' doesn't exist -drop table t2; -select * from t1 where id=2; -ERROR 42S02: Table 'test.t1' doesn't exist -create table t1 (word char(20) not null); -select * from t1; -word -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 1 -load data infile 'TEST_DIR/std_data/words.dat' into table t1; -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -select count(*) from t1; -count(*) -70 -drop table t1; -create table t1 (a int); -insert into t1 values (1),(2),(3); -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -select * from t1 into outfile "query_cache.out.file"; -select * from t1 into outfile "query_cache.out.file"; -ERROR HY000: File 'query_cache.out.file' already exists -select * from t1 limit 1 into dumpfile "query_cache.dump.file"; -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -drop table t1; -create table t1 (a int); -insert into t1 values (1),(2); -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -select * from t1; -a -1 -2 -SET OPTION SQL_SELECT_LIMIT=1; -select * from t1; -a -1 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 2 -SET OPTION SQL_SELECT_LIMIT=DEFAULT; -drop table t1; -flush query cache; -reset query cache; -flush status; -set GLOBAL query_cache_size=1048576; -create table t1 (a int not null); -insert into t1 values (1),(2),(3); -create table t2 (a text not null); -create table t3 (a text not null); -insert into t3 values("1111111111111111111111111111111111111111111111111111"); -insert into t2 select * from t3; -insert into t3 select * from t2; -insert into t2 select * from t3; -insert into t3 select * from t2; -insert into t2 select * from t3; -insert into t3 select * from t2; -insert into t2 select * from t3; -insert into t3 select * from t2; -insert into t2 select * from t3; -insert into t3 select * from t2; -drop table t2; -create table t2 (a int not null); -insert into t2 values (1),(2),(3); -create table t4 (a int not null); -insert into t4 values (1),(2),(3); -select * from t4; -select * from t2; -select * from t1 as tt, t1 as ttt where tt.a=1 and ttt.a=2; -select * from t2; -select * from t4; -select * from t1 as tt, t1 as ttt where tt.a=1 and ttt.a=2; -select * from t2; -select * from t4; -select * from t1 as tt, t1 as ttt where tt.a=1 and ttt.a=2; -delete from t2 where a=1; -flush query cache; -select * from t3; -delete from t4 where a=1; -flush query cache; -drop table t1,t2,t3,t4; -set query_cache_wlock_invalidate=1; -create table t1 (a int not null); -create table t2 (a int not null); -select * from t1; -a -select * from t2; -a -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 2 -lock table t1 write, t2 read; -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 1 -unlock table; -drop table t1,t2; -set query_cache_wlock_invalidate=default; -CREATE TABLE t1 (id INT PRIMARY KEY); -insert into t1 values (1),(2),(3); -select * from t1; -id -1 -2 -3 -create temporary table t1 (a int not null auto_increment -primary key); -select * from t1; -a -drop table t1; -drop table t1; -SET NAMES koi8r; -CREATE TABLE t1 (a char(1) character set koi8r); -INSERT INTO t1 VALUES (_koi8r'á'),(_koi8r'Á'); -SELECT a,'Â','â'='Â' FROM t1; -a  'â'='Â' -á  1 -Á  1 -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 6 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 1 -set collation_connection=koi8r_bin; -SELECT a,'Â','â'='Â' FROM t1; -a  'â'='Â' -á  0 -Á  0 -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 6 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 2 -set character_set_client=cp1251; -SELECT a,'Â','â'='Â' FROM t1; -a ÷ '×'='÷' -á ÷ 0 -Á ÷ 0 -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 6 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 3 -set character_set_results=cp1251; -SELECT a,'Â','â'='Â' FROM t1; -a  'â'='Â' -À  0 -à  0 -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 6 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 4 -DROP TABLE t1; -CREATE TABLE t1 (a int(1)); -CREATE DATABASE mysqltest; -USE mysqltest; -DROP DATABASE mysqltest; -SELECT * FROM test.t1; -a -USE test; -DROP TABLE t1; -set character_set_results=null; -select @@character_set_results; -@@character_set_results -NULL -set character_set_results=default; -set GLOBAL query_cache_size=1355776; -create table t1 (id int auto_increment primary key, c char(25)); -insert into t1 set c = repeat('x',24); -insert into t1 set c = concat(repeat('x',24),'x'); -insert into t1 set c = concat(repeat('x',24),'w'); -insert into t1 set c = concat(repeat('x',24),'y'); -set max_sort_length=200; -select c from t1 order by c, id; -c -xxxxxxxxxxxxxxxxxxxxxxxx -xxxxxxxxxxxxxxxxxxxxxxxxw -xxxxxxxxxxxxxxxxxxxxxxxxx -xxxxxxxxxxxxxxxxxxxxxxxxy -reset query cache; -set max_sort_length=20; -select c from t1 order by c, id; -c -xxxxxxxxxxxxxxxxxxxxxxxx -xxxxxxxxxxxxxxxxxxxxxxxxx -xxxxxxxxxxxxxxxxxxxxxxxxw -xxxxxxxxxxxxxxxxxxxxxxxxy -set max_sort_length=200; -select c from t1 order by c, id; -c -xxxxxxxxxxxxxxxxxxxxxxxx -xxxxxxxxxxxxxxxxxxxxxxxxw -xxxxxxxxxxxxxxxxxxxxxxxxx -xxxxxxxxxxxxxxxxxxxxxxxxy -set max_sort_length=default; -select '1' || '3' from t1; -'1' || '3' -1 -1 -1 -1 -set SQL_MODE=oracle; -select '1' || '3' from t1; -'1' || '3' -13 -13 -13 -13 -set SQL_MODE=default; -drop table t1; -create table t1 (a varchar(20), b int); -insert into t1 values ('12345678901234567890', 1); -set group_concat_max_len=10; -select group_concat(a) FROM t1 group by b; -group_concat(a) -1234567890 -Warnings: -Warning 1260 1 line(s) were cut by GROUP_CONCAT() -set group_concat_max_len=1024; -select group_concat(a) FROM t1 group by b; -group_concat(a) -12345678901234567890 -set group_concat_max_len=default; -drop table t1; -SET GLOBAL query_cache_size=0; diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 8a1d80e9f79..256c4ee6431 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -250,18 +250,18 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index x x 5 NULL 9 Using where; Using index drop table t1; CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1)); -INSERT INTO t1 VALUES (0),(0),(1),(1); +INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(1),(1); CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya)); INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2); explain select * from t1, t2 where (t1.key1 = 'honeysuckle' and fld3 <= 'honoring' order by fld3; -fld3 -honeysuckle -honoring -explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range fld3 fld3 30 NULL 2 Using where; Using index -select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; -fld1 fld3 -148504 Colombo -068305 Colombo -000000 nondecreasing -select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes'; -fld1 fld3 -232605 appendixes -1232605 appendixes -1232606 appendixes -1232607 appendixes -1232608 appendixes -1232609 appendixes -select fld1 from t2 where fld1=250501 or fld1="250502"; -fld1 -250501 -250502 -explain select fld1 from t2 where fld1=250501 or fld1="250502"; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range fld1 fld1 4 NULL 2 Using where; Using index -select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; -fld1 -250501 -250502 -250505 -250601 -explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range fld1 fld1 4 NULL 4 Using where; Using index -select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; -fld1 fld3 -218401 faithful -018007 fanatic -228311 fated -018017 featherweight -218022 feed -088303 feminine -058004 Fenton -038017 fetched -018054 fetters -208101 fiftieth -238007 filial -013606 fingerings -218008 finishers -038205 firearm -188505 fitting -202301 Fitzpatrick -238008 fixedly -012001 flanking -018103 flint -018104 flopping -188007 flurried -013602 foldout -226205 foothill -232102 forgivably -228306 forthcoming -186002 freakish -208113 freest -231315 freezes -036002 funereal -226209 furnishings -198006 furthermore -select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; -fld3 -select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); -fld3 -Chantilly -select fld1,fld3 from t2 where fld1 like "25050%"; -fld1 fld3 -250501 poisoning -250502 Iraqis -250503 heaving -250504 population -250505 bomb -select fld1,fld3 from t2 where fld1 like "25050_"; -fld1 fld3 -250501 poisoning -250502 Iraqis -250503 heaving -250504 population -250505 bomb -select distinct companynr from t2; -companynr -00 -37 -36 -50 -58 -29 -40 -53 -65 -41 -34 -68 -select distinct companynr from t2 order by companynr; -companynr -00 -29 -34 -36 -37 -40 -41 -50 -53 -58 -65 -68 -select distinct companynr from t2 order by companynr desc; -companynr -68 -65 -58 -53 -50 -41 -40 -37 -36 -34 -29 -00 -select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%"; -fld3 period -obliterates 9410 -offload 9410 -opaquely 9410 -organizer 9410 -overestimating 9410 -overlay 9410 -select distinct fld3 from t2 where companynr = 34 order by fld3; -fld3 -absentee -accessed -ahead -alphabetic -Asiaticizations -attitude -aye -bankruptcies -belays -Blythe -bomb -boulevard -bulldozes -cannot -caressing -charcoal -checksumming -chess -clubroom -colorful -cosy -creator -crying -Darius -diffusing -duality -Eiffel -Epiphany -Ernestine -explorers -exterminated -famine -forked -Gershwins -heaving -Hodges -Iraqis -Italianization -Lagos -landslide -libretto -Majorca -mastering -narrowed -occurred -offerers -Palestine -Peruvianizes -pharmaceutic -poisoning -population -Pygmalion -rats -realest -recording -regimented -retransmitting -reviver -rouses -scars -sicker -sleepwalk -stopped -sugars -translatable -uncles -unexpected -uprisings -versatility -vest -select distinct fld3 from t2 limit 10; -fld3 -abates -abiding -Abraham -abrogating -absentee -abut -accessed -accruing -accumulating -accuracies -select distinct fld3 from t2 having fld3 like "A%" limit 10; -fld3 -abates -abiding -Abraham -abrogating -absentee -abut -accessed -accruing -accumulating -accuracies -select distinct substring(fld3,1,3) from t2 where fld3 like "A%"; -substring(fld3,1,3) -aba -abi -Abr -abs -abu -acc -acq -acu -Ade -adj -Adl -adm -Ado -ads -adv -aer -aff -afi -afl -afo -agi -ahe -aim -air -Ald -alg -ali -all -alp -alr -ama -ame -amm -ana -and -ane -Ang -ani -Ann -Ant -api -app -aqu -Ara -arc -Arm -arr -Art -Asi -ask -asp -ass -ast -att -aud -Aug -aut -ave -avo -awe -aye -Azt -select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10; -a -aba -abi -Abr -abs -abu -acc -acq -acu -Ade -adj -select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10; -substring(fld3,1,3) -aba -abi -Abr -abs -abu -acc -acq -acu -Ade -adj -select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10; -a -aba -abi -Abr -abs -abu -acc -acq -acu -Ade -adj -create table t3 ( -period int not null, -name char(32) not null, -companynr int not null, -price double(11,0), -price2 double(11,0), -key (period), -key (name) -); -create temporary table tmp engine = myisam select * from t3; -insert into t3 select * from tmp; -insert into tmp select * from t3; -insert into t3 select * from tmp; -insert into tmp select * from t3; -insert into t3 select * from tmp; -insert into tmp select * from t3; -insert into t3 select * from tmp; -insert into tmp select * from t3; -insert into t3 select * from tmp; -insert into tmp select * from t3; -insert into t3 select * from tmp; -insert into tmp select * from t3; -insert into t3 select * from tmp; -insert into tmp select * from t3; -insert into t3 select * from tmp; -insert into tmp select * from t3; -insert into t3 select * from tmp; -alter table t3 add t2nr int not null auto_increment primary key first; -drop table tmp; -SET SQL_BIG_TABLES=1; -select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10; -namn -Abraham Abraham -abrogating abrogating -admonishing admonishing -Adolph Adolph -afield afield -aging aging -ammonium ammonium -analyzable analyzable -animals animals -animized animized -SET SQL_BIG_TABLES=0; -select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10; -concat(fld3," ",fld3) -Abraham Abraham -abrogating abrogating -admonishing admonishing -Adolph Adolph -afield afield -aging aging -ammonium ammonium -analyzable analyzable -animals animals -animized animized -select distinct fld5 from t2 limit 10; -fld5 -neat -Steinberg -jarring -tinily -balled -persist -attainments -fanatic -measures -rightfulness -select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10; -fld3 count(*) -affixed 1 -and 1 -annoyers 1 -Anthony 1 -assayed 1 -assurers 1 -attendants 1 -bedlam 1 -bedpost 1 -boasted 1 -SET SQL_BIG_TABLES=1; -select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10; -fld3 count(*) -affixed 1 -and 1 -annoyers 1 -Anthony 1 -assayed 1 -assurers 1 -attendants 1 -bedlam 1 -bedpost 1 -boasted 1 -SET SQL_BIG_TABLES=0; -select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10; -fld3 repeat("a",length(fld3)) count(*) -circus aaaaaa 1 -cited aaaaa 1 -Colombo aaaaaaa 1 -congresswoman aaaaaaaaaaaaa 1 -contrition aaaaaaaaaa 1 -corny aaaaa 1 -cultivation aaaaaaaaaaa 1 -definiteness aaaaaaaaaaaa 1 -demultiplex aaaaaaaaaaa 1 -disappointing aaaaaaaaaaaaa 1 -select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2; -companynr rtrim(space(512+companynr)) -37 -78 -101 -154 -311 -447 -512 -select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3; -fld3 -explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort -1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index -explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort -1 SIMPLE t3 ref period period 4 test.t1.period 4181 -explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 index period period 4 NULL 41810 -1 SIMPLE t1 ref period period 4 test.t3.period 4181 -explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index period period 4 NULL 41810 -1 SIMPLE t3 ref period period 4 test.t1.period 4181 -select period from t1; -period -9410 -select period from t1 where period=1900; -period -select fld3,period from t1,t2 where fld1 = 011401 order by period; -fld3 period -breaking 9410 -select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001; -fld3 period -breaking 1001 -explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 const fld1 fld1 4 const 1 -1 SIMPLE t3 const PRIMARY,period PRIMARY 4 const 1 -select fld3,period from t2,t1 where companynr*10 = 37*10; -fld3 period -breaking 9410 -Romans 9410 -intercepted 9410 -bewilderingly 9410 -astound 9410 -admonishing 9410 -sumac 9410 -flanking 9410 -combed 9410 -subjective 9410 -scatterbrain 9410 -Eulerian 9410 -Kane 9410 -overlay 9410 -perturb 9410 -goblins 9410 -annihilates 9410 -Wotan 9410 -snatching 9410 -concludes 9410 -laterally 9410 -yelped 9410 -grazing 9410 -Baird 9410 -celery 9410 -misunderstander 9410 -handgun 9410 -foldout 9410 -mystic 9410 -succumbed 9410 -Nabisco 9410 -fingerings 9410 -aging 9410 -afield 9410 -ammonium 9410 -boat 9410 -intelligibility 9410 -Augustine 9410 -teethe 9410 -dreaded 9410 -scholastics 9410 -audiology 9410 -wallet 9410 -parters 9410 -eschew 9410 -quitter 9410 -neat 9410 -Steinberg 9410 -jarring 9410 -tinily 9410 -balled 9410 -persist 9410 -attainments 9410 -fanatic 9410 -measures 9410 -rightfulness 9410 -capably 9410 -impulsive 9410 -starlet 9410 -terminators 9410 -untying 9410 -announces 9410 -featherweight 9410 -pessimist 9410 -daughter 9410 -decliner 9410 -lawgiver 9410 -stated 9410 -readable 9410 -attrition 9410 -cascade 9410 -motors 9410 -interrogate 9410 -pests 9410 -stairway 9410 -dopers 9410 -testicle 9410 -Parsifal 9410 -leavings 9410 -postulation 9410 -squeaking 9410 -contrasted 9410 -leftover 9410 -whiteners 9410 -erases 9410 -Punjab 9410 -Merritt 9410 -Quixotism 9410 -sweetish 9410 -dogging 9410 -scornfully 9410 -bellow 9410 -bills 9410 -cupboard 9410 -sureties 9410 -puddings 9410 -fetters 9410 -bivalves 9410 -incurring 9410 -Adolph 9410 -pithed 9410 -Miles 9410 -trimmings 9410 -tragedies 9410 -skulking 9410 -flint 9410 -flopping 9410 -relaxing 9410 -offload 9410 -suites 9410 -lists 9410 -animized 9410 -multilayer 9410 -standardizes 9410 -Judas 9410 -vacuuming 9410 -dentally 9410 -humanness 9410 -inch 9410 -Weissmuller 9410 -irresponsibly 9410 -luckily 9410 -culled 9410 -medical 9410 -bloodbath 9410 -subschema 9410 -animals 9410 -Micronesia 9410 -repetitions 9410 -Antares 9410 -ventilate 9410 -pityingly 9410 -interdependent 9410 -Graves 9410 -neonatal 9410 -chafe 9410 -honoring 9410 -realtor 9410 -elite 9410 -funereal 9410 -abrogating 9410 -sorters 9410 -Conley 9410 -lectured 9410 -Abraham 9410 -Hawaii 9410 -cage 9410 -hushes 9410 -Simla 9410 -reporters 9410 -Dutchman 9410 -descendants 9410 -groupings 9410 -dissociate 9410 -coexist 9410 -Beebe 9410 -Taoism 9410 -Connally 9410 -fetched 9410 -checkpoints 9410 -rusting 9410 -galling 9410 -obliterates 9410 -traitor 9410 -resumes 9410 -analyzable 9410 -terminator 9410 -gritty 9410 -firearm 9410 -minima 9410 -Selfridge 9410 -disable 9410 -witchcraft 9410 -betroth 9410 -Manhattanize 9410 -imprint 9410 -peeked 9410 -swelling 9410 -interrelationships 9410 -riser 9410 -Gandhian 9410 -peacock 9410 -bee 9410 -kanji 9410 -dental 9410 -scarf 9410 -chasm 9410 -insolence 9410 -syndicate 9410 -alike 9410 -imperial 9410 -convulsion 9410 -railway 9410 -validate 9410 -normalizes 9410 -comprehensive 9410 -chewing 9410 -denizen 9410 -schemer 9410 -chronicle 9410 -Kline 9410 -Anatole 9410 -partridges 9410 -brunch 9410 -recruited 9410 -dimensions 9410 -Chicana 9410 -announced 9410 -praised 9410 -employing 9410 -linear 9410 -quagmire 9410 -western 9410 -relishing 9410 -serving 9410 -scheduling 9410 -lore 9410 -eventful 9410 -arteriole 9410 -disentangle 9410 -cured 9410 -Fenton 9410 -avoidable 9410 -drains 9410 -detectably 9410 -husky 9410 -impelling 9410 -undoes 9410 -evened 9410 -squeezes 9410 -destroyer 9410 -rudeness 9410 -beaner 9410 -boorish 9410 -Everhart 9410 -encompass 9410 -mushrooms 9410 -Alison 9410 -externally 9410 -pellagra 9410 -cult 9410 -creek 9410 -Huffman 9410 -Majorca 9410 -governing 9410 -gadfly 9410 -reassigned 9410 -intentness 9410 -craziness 9410 -psychic 9410 -squabbled 9410 -burlesque 9410 -capped 9410 -extracted 9410 -DiMaggio 9410 -exclamation 9410 -subdirectory 9410 -Gothicism 9410 -feminine 9410 -metaphysically 9410 -sanding 9410 -Miltonism 9410 -freakish 9410 -index 9410 -straight 9410 -flurried 9410 -denotative 9410 -coming 9410 -commencements 9410 -gentleman 9410 -gifted 9410 -Shanghais 9410 -sportswriting 9410 -sloping 9410 -navies 9410 -leaflet 9410 -shooter 9410 -Joplin 9410 -babies 9410 -assails 9410 -admiring 9410 -swaying 9410 -Goldstine 9410 -fitting 9410 -Norwalk 9410 -analogy 9410 -deludes 9410 -cokes 9410 -Clayton 9410 -exhausts 9410 -causality 9410 -sating 9410 -icon 9410 -throttles 9410 -communicants 9410 -dehydrate 9410 -priceless 9410 -publicly 9410 -incidentals 9410 -commonplace 9410 -mumbles 9410 -furthermore 9410 -cautioned 9410 -parametrized 9410 -registration 9410 -sadly 9410 -positioning 9410 -babysitting 9410 -eternal 9410 -hoarder 9410 -congregates 9410 -rains 9410 -workers 9410 -sags 9410 -unplug 9410 -garage 9410 -boulder 9410 -specifics 9410 -Teresa 9410 -Winsett 9410 -convenient 9410 -buckboards 9410 -amenities 9410 -resplendent 9410 -sews 9410 -participated 9410 -Simon 9410 -certificates 9410 -Fitzpatrick 9410 -Evanston 9410 -misted 9410 -textures 9410 -save 9410 -count 9410 -rightful 9410 -chaperone 9410 -Lizzy 9410 -clenched 9410 -effortlessly 9410 -accessed 9410 -beaters 9410 -Hornblower 9410 -vests 9410 -indulgences 9410 -infallibly 9410 -unwilling 9410 -excrete 9410 -spools 9410 -crunches 9410 -overestimating 9410 -ineffective 9410 -humiliation 9410 -sophomore 9410 -star 9410 -rifles 9410 -dialysis 9410 -arriving 9410 -indulge 9410 -clockers 9410 -languages 9410 -Antarctica 9410 -percentage 9410 -ceiling 9410 -specification 9410 -regimented 9410 -ciphers 9410 -pictures 9410 -serpents 9410 -allot 9410 -realized 9410 -mayoral 9410 -opaquely 9410 -hostess 9410 -fiftieth 9410 -incorrectly 9410 -decomposition 9410 -stranglings 9410 -mixture 9410 -electroencephalography 9410 -similarities 9410 -charges 9410 -freest 9410 -Greenberg 9410 -tinting 9410 -expelled 9410 -warm 9410 -smoothed 9410 -deductions 9410 -Romano 9410 -bitterroot 9410 -corset 9410 -securing 9410 -environing 9410 -cute 9410 -Crays 9410 -heiress 9410 -inform 9410 -avenge 9410 -universals 9410 -Kinsey 9410 -ravines 9410 -bestseller 9410 -equilibrium 9410 -extents 9410 -relatively 9410 -pressure 9410 -critiques 9410 -befouled 9410 -rightfully 9410 -mechanizing 9410 -Latinizes 9410 -timesharing 9410 -Aden 9410 -embassies 9410 -males 9410 -shapelessly 9410 -mastering 9410 -Newtonian 9410 -finishers 9410 -abates 9410 -teem 9410 -kiting 9410 -stodgy 9410 -feed 9410 -guitars 9410 -airships 9410 -store 9410 -denounces 9410 -Pyle 9410 -Saxony 9410 -serializations 9410 -Peruvian 9410 -taxonomically 9410 -kingdom 9410 -stint 9410 -Sault 9410 -faithful 9410 -Ganymede 9410 -tidiness 9410 -gainful 9410 -contrary 9410 -Tipperary 9410 -tropics 9410 -theorizers 9410 -renew 9410 -already 9410 -terminal 9410 -Hegelian 9410 -hypothesizer 9410 -warningly 9410 -journalizing 9410 -nested 9410 -Lars 9410 -saplings 9410 -foothill 9410 -labeled 9410 -imperiously 9410 -reporters 9410 -furnishings 9410 -precipitable 9410 -discounts 9410 -excises 9410 -Stalin 9410 -despot 9410 -ripeness 9410 -Arabia 9410 -unruly 9410 -mournfulness 9410 -boom 9410 -slaughter 9410 -Sabine 9410 -handy 9410 -rural 9410 -organizer 9410 -shipyard 9410 -civics 9410 -inaccuracy 9410 -rules 9410 -juveniles 9410 -comprised 9410 -investigations 9410 -stabilizes 9410 -seminaries 9410 -Hunter 9410 -sporty 9410 -test 9410 -weasels 9410 -CERN 9410 -tempering 9410 -afore 9410 -Galatean 9410 -techniques 9410 -error 9410 -veranda 9410 -severely 9410 -Cassites 9410 -forthcoming 9410 -guides 9410 -vanish 9410 -lied 9410 -sawtooth 9410 -fated 9410 -gradually 9410 -widens 9410 -preclude 9410 -evenhandedly 9410 -percentage 9410 -disobedience 9410 -humility 9410 -gleaning 9410 -petted 9410 -bloater 9410 -minion 9410 -marginal 9410 -apiary 9410 -measures 9410 -precaution 9410 -repelled 9410 -primary 9410 -coverings 9410 -Artemia 9410 -navigate 9410 -spatial 9410 -Gurkha 9410 -meanwhile 9410 -Melinda 9410 -Butterfield 9410 -Aldrich 9410 -previewing 9410 -glut 9410 -unaffected 9410 -inmate 9410 -mineral 9410 -impending 9410 -meditation 9410 -ideas 9410 -miniaturizes 9410 -lewdly 9410 -title 9410 -youthfulness 9410 -creak 9410 -Chippewa 9410 -clamored 9410 -freezes 9410 -forgivably 9410 -reduce 9410 -McGovern 9410 -Nazis 9410 -epistle 9410 -socializes 9410 -conceptions 9410 -Kevin 9410 -uncovering 9410 -chews 9410 -appendixes 9410 -appendixes 9410 -appendixes 9410 -appendixes 9410 -appendixes 9410 -appendixes 9410 -raining 9410 -infest 9410 -compartment 9410 -minting 9410 -ducks 9410 -roped 9410 -waltz 9410 -Lillian 9410 -repressions 9410 -chillingly 9410 -noncritical 9410 -lithograph 9410 -spongers 9410 -parenthood 9410 -posed 9410 -instruments 9410 -filial 9410 -fixedly 9410 -relives 9410 -Pandora 9410 -watering 9410 -ungrateful 9410 -secures 9410 -poison 9410 -dusted 9410 -encompasses 9410 -presentation 9410 -Kantian 9410 -select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price; -fld3 period price price2 -admonishing 1002 28357832 8723648 -analyzable 1002 28357832 8723648 -annihilates 1001 5987435 234724 -Antares 1002 28357832 8723648 -astound 1001 5987435 234724 -audiology 1001 5987435 234724 -Augustine 1002 28357832 8723648 -Baird 1002 28357832 8723648 -bewilderingly 1001 5987435 234724 -breaking 1001 5987435 234724 -Conley 1001 5987435 234724 -dentally 1002 28357832 8723648 -dissociate 1002 28357832 8723648 -elite 1001 5987435 234724 -eschew 1001 5987435 234724 -Eulerian 1001 5987435 234724 -flanking 1001 5987435 234724 -foldout 1002 28357832 8723648 -funereal 1002 28357832 8723648 -galling 1002 28357832 8723648 -Graves 1001 5987435 234724 -grazing 1001 5987435 234724 -groupings 1001 5987435 234724 -handgun 1001 5987435 234724 -humility 1002 28357832 8723648 -impulsive 1002 28357832 8723648 -inch 1001 5987435 234724 -intelligibility 1001 5987435 234724 -jarring 1001 5987435 234724 -lawgiver 1001 5987435 234724 -lectured 1002 28357832 8723648 -Merritt 1002 28357832 8723648 -neonatal 1001 5987435 234724 -offload 1002 28357832 8723648 -parters 1002 28357832 8723648 -pityingly 1002 28357832 8723648 -puddings 1002 28357832 8723648 -Punjab 1001 5987435 234724 -quitter 1002 28357832 8723648 -realtor 1001 5987435 234724 -relaxing 1001 5987435 234724 -repetitions 1001 5987435 234724 -resumes 1001 5987435 234724 -Romans 1002 28357832 8723648 -rusting 1001 5987435 234724 -scholastics 1001 5987435 234724 -skulking 1002 28357832 8723648 -stated 1002 28357832 8723648 -suites 1002 28357832 8723648 -sureties 1001 5987435 234724 -testicle 1002 28357832 8723648 -tinily 1002 28357832 8723648 -tragedies 1001 5987435 234724 -trimmings 1001 5987435 234724 -vacuuming 1001 5987435 234724 -ventilate 1001 5987435 234724 -wallet 1001 5987435 234724 -Weissmuller 1002 28357832 8723648 -Wotan 1002 28357832 8723648 -select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37; -fld1 fld3 period price price2 -018201 relaxing 1001 5987435 234724 -018601 vacuuming 1001 5987435 234724 -018801 inch 1001 5987435 234724 -018811 repetitions 1001 5987435 234724 -create table t4 ( -companynr tinyint(2) unsigned zerofill NOT NULL default '00', -companyname char(30) NOT NULL default '', -PRIMARY KEY (companynr), -UNIQUE KEY companyname(companyname) -) ENGINE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames'; -select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; -companynr companyname -00 Unknown -29 company 1 -34 company 2 -36 company 3 -37 company 4 -40 company 5 -41 company 6 -50 company 11 -53 company 7 -58 company 8 -65 company 9 -68 company 10 -select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr; -companynr companyname -00 Unknown -29 company 1 -34 company 2 -36 company 3 -37 company 4 -40 company 5 -41 company 6 -50 company 11 -53 company 7 -58 company 8 -65 company 9 -68 company 10 -select * from t1,t1 t12; -Period Varor_period Period Varor_period -9410 9412 9410 9412 -select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505; -fld1 fld1 -250501 250501 -250502 250501 -250503 250501 -250504 250501 -250505 250501 -250501 250502 -250502 250502 -250503 250502 -250504 250502 -250505 250502 -250501 250503 -250502 250503 -250503 250503 -250504 250503 -250505 250503 -250501 250504 -250502 250504 -250503 250504 -250504 250504 -250505 250504 -250501 250505 -250502 250505 -250503 250505 -250504 250505 -250505 250505 -insert into t2 (fld1, companynr) values (999999,99); -select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; -companynr companyname -99 NULL -select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null; -count(*) -1199 -explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 -1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 Using where; Not exists -explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL NULL NULL NULL NULL 12 -1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 Using where; Not exists -delete from t2 where fld1=999999; -explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where -1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 -explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where -1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 -explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where -1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 Using where -explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL NULL NULL NULL NULL 12 -1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where -explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 -1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where -explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t4 ALL NULL NULL NULL NULL 12 -1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where -select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; -companynr companynr -37 36 -41 40 -explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using temporary -1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using where; Using index -select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; -fld1 companynr fld3 period -038008 37 reporters 1008 -038208 37 Selfridge 1008 -select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; -fld1 companynr fld3 period -038008 37 reporters 1008 -038208 37 Selfridge 1008 -select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009; -fld1 companynr fld3 period -038008 37 reporters 1008 -038208 37 Selfridge 1008 -select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909); -period -9410 -select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6))); -period -9410 -select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1; -fld1 -250501 -250502 -250503 -250505 -select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606); -fld1 -250502 -250503 -select fld1 from t2 where fld1 between 250502 and 250504; -fld1 -250502 -250503 -250504 -select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ; -fld3 -label -labeled -labeled -landslide -laterally -leaflet -lewdly -Lillian -luckily -select count(*) from t1; -count(*) -1 -select companynr,count(*),sum(fld1) from t2 group by companynr; -companynr count(*) sum(fld1) -00 82 10355753 -29 95 14473298 -34 70 17788966 -36 215 22786296 -37 588 83602098 -40 37 6618386 -41 52 12816335 -50 11 1595438 -53 4 793210 -58 23 2254293 -65 10 2284055 -68 12 3097288 -select companynr,count(*) from t2 group by companynr order by companynr desc limit 5; -companynr count(*) -68 12 -65 10 -58 23 -53 4 -50 11 -select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; -count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) -70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069 -explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>""; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where -Warnings: -Note 1003 select count(0) AS `count(*)`,min(test.t2.fld4) AS `min(fld4)`,max(test.t2.fld4) AS `max(fld4)`,sum(test.t2.fld1) AS `sum(fld1)`,avg(test.t2.fld1) AS `avg(fld1)`,std(test.t2.fld1) AS `std(fld1)`,variance(test.t2.fld1) AS `variance(fld1)` from test.t2 where ((test.t2.companynr = 34) and (test.t2.fld4 <> _latin1'')) -select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3; -companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1) -00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087 -29 95 abut wetness 14473298 152350.5053 8368.5480 70032594.9026 -34 70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069 -select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10; -companynr t2nr count(price) sum(price) min(price) max(price) avg(price) -37 1 1 5987435 5987435 5987435 5987435.0000 -37 2 1 28357832 28357832 28357832 28357832.0000 -37 3 1 39654943 39654943 39654943 39654943.0000 -37 11 1 5987435 5987435 5987435 5987435.0000 -37 12 1 28357832 28357832 28357832 28357832.0000 -37 13 1 39654943 39654943 39654943 39654943.0000 -37 21 1 5987435 5987435 5987435 5987435.0000 -37 22 1 28357832 28357832 28357832 28357832.0000 -37 23 1 39654943 39654943 39654943 39654943.0000 -37 31 1 5987435 5987435 5987435 5987435.0000 -select /*! SQL_SMALL_RESULT */ companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10; -companynr t2nr count(price) sum(price) min(price) max(price) avg(price) -37 1 1 5987435 5987435 5987435 5987435.0000 -37 2 1 28357832 28357832 28357832 28357832.0000 -37 3 1 39654943 39654943 39654943 39654943.0000 -37 11 1 5987435 5987435 5987435 5987435.0000 -37 12 1 28357832 28357832 28357832 28357832.0000 -37 13 1 39654943 39654943 39654943 39654943.0000 -37 21 1 5987435 5987435 5987435 5987435.0000 -37 22 1 28357832 28357832 28357832 28357832.0000 -37 23 1 39654943 39654943 39654943 39654943.0000 -37 31 1 5987435 5987435 5987435 5987435.0000 -select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ; -companynr count(price) sum(price) min(price) max(price) avg(price) -37 12543 309394878010 5987435 39654943 24666736.6667 -78 8362 414611089292 726498 98439034 49582766.0000 -101 4181 3489454238 834598 834598 834598.0000 -154 4181 4112197254950 983543950 983543950 983543950.0000 -311 4181 979599938 234298 234298 234298.0000 -447 4181 9929180954 2374834 2374834 2374834.0000 -512 4181 3288532102 786542 786542 786542.0000 -select distinct mod(companynr,10) from t4 group by companynr; -mod(companynr,10) -0 -9 -4 -6 -7 -1 -3 -8 -5 -select distinct 1 from t4 group by companynr; -1 -1 -select count(distinct fld1) from t2; -count(distinct fld1) -1199 -select companynr,count(distinct fld1) from t2 group by companynr; -companynr count(distinct fld1) -00 82 -29 95 -34 70 -36 215 -37 588 -40 37 -41 52 -50 11 -53 4 -58 23 -65 10 -68 12 -select companynr,count(*) from t2 group by companynr; -companynr count(*) -00 82 -29 95 -34 70 -36 215 -37 588 -40 37 -41 52 -50 11 -53 4 -58 23 -65 10 -68 12 -select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr; -companynr count(distinct concat(fld1,repeat(65,1000))) -00 82 -29 95 -34 70 -36 215 -37 588 -40 37 -41 52 -50 11 -53 4 -58 23 -65 10 -68 12 -select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr; -companynr count(distinct concat(fld1,repeat(65,200))) -00 82 -29 95 -34 70 -36 215 -37 588 -40 37 -41 52 -50 11 -53 4 -58 23 -65 10 -68 12 -select companynr,count(distinct floor(fld1/100)) from t2 group by companynr; -companynr count(distinct floor(fld1/100)) -00 47 -29 35 -34 14 -36 69 -37 108 -40 16 -41 11 -50 9 -53 1 -58 1 -65 1 -68 1 -select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr; -companynr count(distinct concat(repeat(65,1000),floor(fld1/100))) -00 47 -29 35 -34 14 -36 69 -37 108 -40 16 -41 11 -50 9 -53 1 -58 1 -65 1 -68 1 -select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10; -sum(fld1) fld3 -11402 Romans -select name,count(*) from t3 where name='cloakroom' group by name; -name count(*) -cloakroom 4181 -select name,count(*) from t3 where name='cloakroom' and price>10 group by name; -name count(*) -cloakroom 4181 -select count(*) from t3 where name='cloakroom' and price2=823742; -count(*) -4181 -select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name; -name count(*) -cloakroom 4181 -select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name; -name count(*) -extramarital 4181 -gazer 4181 -gems 4181 -Iranizes 4181 -spates 4181 -tucked 4181 -violinist 4181 -select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; -fld3 count(*) -spates 4181 -select companynr|0,companyname from t4 group by 1; -companynr|0 companyname -0 Unknown -29 company 1 -34 company 2 -36 company 3 -37 company 4 -40 company 5 -41 company 6 -50 company 11 -53 company 7 -58 company 8 -65 company 9 -68 company 10 -select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname; -companynr companyname count(*) -29 company 1 95 -68 company 10 12 -50 company 11 11 -34 company 2 70 -36 company 3 215 -37 company 4 588 -40 company 5 37 -41 company 6 52 -53 company 7 4 -58 company 8 23 -65 company 9 10 -00 Unknown 82 -select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name; -fld1 count(*) -158402 4181 -select sum(Period)/count(*) from t1; -sum(Period)/count(*) -9410.00 -select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr; -companynr count sum diff func -37 12543 309394878010 0.0000 464091 -78 8362 414611089292 0.0000 652236 -101 4181 3489454238 0.0000 422281 -154 4181 4112197254950 0.0000 643874 -311 4181 979599938 0.0000 1300291 -447 4181 9929180954 0.0000 1868907 -512 4181 3288532102 0.0000 2140672 -select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg; -companynr avg -154 983543950.00 -select companynr,count(*) from t2 group by companynr order by 2 desc; -companynr count(*) -37 588 -36 215 -29 95 -00 82 -34 70 -41 52 -40 37 -58 23 -68 12 -50 11 -65 10 -53 4 -select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc; -companynr count(*) -41 52 -58 23 -68 12 -50 11 -65 10 -53 4 -select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4; -fld4 fld1 count(price) sum(price) min(price) max(price) avg(price) -teethe 000001 1 5987435 5987435 5987435 5987435.0000 -dreaded 011401 1 5987435 5987435 5987435 5987435.0000 -scholastics 011402 1 28357832 28357832 28357832 28357832.0000 -audiology 011403 1 39654943 39654943 39654943 39654943.0000 -wallet 011501 1 5987435 5987435 5987435 5987435.0000 -parters 011701 1 5987435 5987435 5987435 5987435.0000 -eschew 011702 1 28357832 28357832 28357832 28357832.0000 -quitter 011703 1 39654943 39654943 39654943 39654943.0000 -neat 012001 1 5987435 5987435 5987435 5987435.0000 -Steinberg 012003 1 39654943 39654943 39654943 39654943.0000 -balled 012301 1 5987435 5987435 5987435 5987435.0000 -persist 012302 1 28357832 28357832 28357832 28357832.0000 -attainments 012303 1 39654943 39654943 39654943 39654943.0000 -capably 012501 1 5987435 5987435 5987435 5987435.0000 -impulsive 012602 1 28357832 28357832 28357832 28357832.0000 -starlet 012603 1 39654943 39654943 39654943 39654943.0000 -featherweight 012701 1 5987435 5987435 5987435 5987435.0000 -pessimist 012702 1 28357832 28357832 28357832 28357832.0000 -daughter 012703 1 39654943 39654943 39654943 39654943.0000 -lawgiver 013601 1 5987435 5987435 5987435 5987435.0000 -stated 013602 1 28357832 28357832 28357832 28357832.0000 -readable 013603 1 39654943 39654943 39654943 39654943.0000 -testicle 013801 1 5987435 5987435 5987435 5987435.0000 -Parsifal 013802 1 28357832 28357832 28357832 28357832.0000 -leavings 013803 1 39654943 39654943 39654943 39654943.0000 -squeaking 013901 1 5987435 5987435 5987435 5987435.0000 -contrasted 016001 1 5987435 5987435 5987435 5987435.0000 -leftover 016201 1 5987435 5987435 5987435 5987435.0000 -whiteners 016202 1 28357832 28357832 28357832 28357832.0000 -erases 016301 1 5987435 5987435 5987435 5987435.0000 -Punjab 016302 1 28357832 28357832 28357832 28357832.0000 -Merritt 016303 1 39654943 39654943 39654943 39654943.0000 -sweetish 018001 1 5987435 5987435 5987435 5987435.0000 -dogging 018002 1 28357832 28357832 28357832 28357832.0000 -scornfully 018003 1 39654943 39654943 39654943 39654943.0000 -fetters 018012 1 28357832 28357832 28357832 28357832.0000 -bivalves 018013 1 39654943 39654943 39654943 39654943.0000 -skulking 018021 1 5987435 5987435 5987435 5987435.0000 -flint 018022 1 28357832 28357832 28357832 28357832.0000 -flopping 018023 1 39654943 39654943 39654943 39654943.0000 -Judas 018032 1 28357832 28357832 28357832 28357832.0000 -vacuuming 018033 1 39654943 39654943 39654943 39654943.0000 -medical 018041 1 5987435 5987435 5987435 5987435.0000 -bloodbath 018042 1 28357832 28357832 28357832 28357832.0000 -subschema 018043 1 39654943 39654943 39654943 39654943.0000 -interdependent 018051 1 5987435 5987435 5987435 5987435.0000 -Graves 018052 1 28357832 28357832 28357832 28357832.0000 -neonatal 018053 1 39654943 39654943 39654943 39654943.0000 -sorters 018061 1 5987435 5987435 5987435 5987435.0000 -epistle 018062 1 28357832 28357832 28357832 28357832.0000 -Conley 018101 1 5987435 5987435 5987435 5987435.0000 -lectured 018102 1 28357832 28357832 28357832 28357832.0000 -Abraham 018103 1 39654943 39654943 39654943 39654943.0000 -cage 018201 1 5987435 5987435 5987435 5987435.0000 -hushes 018202 1 28357832 28357832 28357832 28357832.0000 -Simla 018402 1 28357832 28357832 28357832 28357832.0000 -reporters 018403 1 39654943 39654943 39654943 39654943.0000 -coexist 018601 1 5987435 5987435 5987435 5987435.0000 -Beebe 018602 1 28357832 28357832 28357832 28357832.0000 -Taoism 018603 1 39654943 39654943 39654943 39654943.0000 -Connally 018801 1 5987435 5987435 5987435 5987435.0000 -fetched 018802 1 28357832 28357832 28357832 28357832.0000 -checkpoints 018803 1 39654943 39654943 39654943 39654943.0000 -gritty 018811 1 5987435 5987435 5987435 5987435.0000 -firearm 018812 1 28357832 28357832 28357832 28357832.0000 -minima 019101 1 5987435 5987435 5987435 5987435.0000 -Selfridge 019102 1 28357832 28357832 28357832 28357832.0000 -disable 019103 1 39654943 39654943 39654943 39654943.0000 -witchcraft 019201 1 5987435 5987435 5987435 5987435.0000 -betroth 030501 1 5987435 5987435 5987435 5987435.0000 -Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000 -imprint 030503 1 39654943 39654943 39654943 39654943.0000 -swelling 031901 1 5987435 5987435 5987435 5987435.0000 -interrelationships 036001 1 5987435 5987435 5987435 5987435.0000 -riser 036002 1 28357832 28357832 28357832 28357832.0000 -bee 038001 1 5987435 5987435 5987435 5987435.0000 -kanji 038002 1 28357832 28357832 28357832 28357832.0000 -dental 038003 1 39654943 39654943 39654943 39654943.0000 -railway 038011 1 5987435 5987435 5987435 5987435.0000 -validate 038012 1 28357832 28357832 28357832 28357832.0000 -normalizes 038013 1 39654943 39654943 39654943 39654943.0000 -Kline 038101 1 5987435 5987435 5987435 5987435.0000 -Anatole 038102 1 28357832 28357832 28357832 28357832.0000 -partridges 038103 1 39654943 39654943 39654943 39654943.0000 -recruited 038201 1 5987435 5987435 5987435 5987435.0000 -dimensions 038202 1 28357832 28357832 28357832 28357832.0000 -Chicana 038203 1 39654943 39654943 39654943 39654943.0000 -select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3; -companynr fld3 sum(price) -512 boat 786542 -512 capably 786542 -512 cupboard 786542 -512 decliner 786542 -512 descendants 786542 -512 dopers 786542 -512 erases 786542 -512 Micronesia 786542 -512 Miles 786542 -512 skies 786542 -select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr; -companynr count(*) min(fld3) max(fld3) sum(price) avg(price) -00 1 Omaha Omaha 5987435 5987435.0000 -36 1 dubbed dubbed 28357832 28357832.0000 -37 83 Abraham Wotan 1908978016 22999735.1325 -50 2 scribbled tapestry 68012775 34006387.5000 -select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1; -t3.companynr+0 t2nr fld3 sum(price) -37 1 Omaha 5987435 -37 11401 breaking 5987435 -37 11402 Romans 28357832 -37 11403 intercepted 39654943 -37 11501 bewilderingly 5987435 -37 11701 astound 5987435 -37 11702 admonishing 28357832 -37 11703 sumac 39654943 -37 12001 flanking 5987435 -37 12003 combed 39654943 -37 12301 Eulerian 5987435 -37 12302 dubbed 28357832 -37 12303 Kane 39654943 -37 12501 annihilates 5987435 -37 12602 Wotan 28357832 -37 12603 snatching 39654943 -37 12701 grazing 5987435 -37 12702 Baird 28357832 -37 12703 celery 39654943 -37 13601 handgun 5987435 -37 13602 foldout 28357832 -37 13603 mystic 39654943 -37 13801 intelligibility 5987435 -37 13802 Augustine 28357832 -37 13803 teethe 39654943 -37 13901 scholastics 5987435 -37 16001 audiology 5987435 -37 16201 wallet 5987435 -37 16202 parters 28357832 -37 16301 eschew 5987435 -37 16302 quitter 28357832 -37 16303 neat 39654943 -37 18001 jarring 5987435 -37 18002 tinily 28357832 -37 18003 balled 39654943 -37 18012 impulsive 28357832 -37 18013 starlet 39654943 -37 18021 lawgiver 5987435 -37 18022 stated 28357832 -37 18023 readable 39654943 -37 18032 testicle 28357832 -37 18033 Parsifal 39654943 -37 18041 Punjab 5987435 -37 18042 Merritt 28357832 -37 18043 Quixotism 39654943 -37 18051 sureties 5987435 -37 18052 puddings 28357832 -37 18053 tapestry 39654943 -37 18061 trimmings 5987435 -37 18062 humility 28357832 -37 18101 tragedies 5987435 -37 18102 skulking 28357832 -37 18103 flint 39654943 -37 18201 relaxing 5987435 -37 18202 offload 28357832 -37 18402 suites 28357832 -37 18403 lists 39654943 -37 18601 vacuuming 5987435 -37 18602 dentally 28357832 -37 18603 humanness 39654943 -37 18801 inch 5987435 -37 18802 Weissmuller 28357832 -37 18803 irresponsibly 39654943 -37 18811 repetitions 5987435 -37 18812 Antares 28357832 -37 19101 ventilate 5987435 -37 19102 pityingly 28357832 -37 19103 interdependent 39654943 -37 19201 Graves 5987435 -37 30501 neonatal 5987435 -37 30502 scribbled 28357832 -37 30503 chafe 39654943 -37 31901 realtor 5987435 -37 36001 elite 5987435 -37 36002 funereal 28357832 -37 38001 Conley 5987435 -37 38002 lectured 28357832 -37 38003 Abraham 39654943 -37 38011 groupings 5987435 -37 38012 dissociate 28357832 -37 38013 coexist 39654943 -37 38101 rusting 5987435 -37 38102 galling 28357832 -37 38103 obliterates 39654943 -37 38201 resumes 5987435 -37 38202 analyzable 28357832 -37 38203 terminator 39654943 -select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008; -sum(price) -234298 -select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1; -fld1 sum(price) -038008 234298 -explain select fld3 from t2 where 1>2 or 2>3; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE -explain select fld3 from t2 where fld1=fld1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 -select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502; -companynr fld1 -34 250501 -34 250502 -select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502; -companynr fld1 -34 250501 -34 250502 -select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000; -companynr count sum -00 82 10355753 -29 95 14473298 -34 70 17788966 -37 588 83602098 -41 52 12816335 -select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ; -companynr -00 -29 -34 -37 -41 -select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40; -companynr companyname count(*) -68 company 10 12 -50 company 11 11 -40 company 5 37 -41 company 6 52 -53 company 7 4 -58 company 8 23 -65 company 9 10 -select count(*) from t2; -count(*) -1199 -select count(*) from t2 where fld1 < 098024; -count(*) -387 -select min(fld1) from t2 where fld1>= 098024; -min(fld1) -98024 -select max(fld1) from t2 where fld1>= 098024; -max(fld1) -1232609 -select count(*) from t3 where price2=76234234; -count(*) -4181 -select count(*) from t3 where companynr=512 and price2=76234234; -count(*) -4181 -explain select min(fld1),max(fld1),count(*) from t2; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away -select min(fld1),max(fld1),count(*) from t2; -min(fld1) max(fld1) count(*) -0 1232609 1199 -select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742; -min(t2nr) max(t2nr) -2115 2115 -select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78; -count(*) min(t2nr) max(t2nr) -4181 4 41804 -select t2nr,count(*) from t3 where name='gems' group by t2nr limit 20; -t2nr count(*) -9 1 -19 1 -29 1 -39 1 -49 1 -59 1 -69 1 -79 1 -89 1 -99 1 -109 1 -119 1 -129 1 -139 1 -149 1 -159 1 -169 1 -179 1 -189 1 -199 1 -select max(t2nr) from t3 where price=983543950; -max(t2nr) -41807 -select t1.period from t3 = t1 limit 1; -period -1001 -select t1.period from t1 as t1 limit 1; -period -9410 -select t1.period as "Nuvarande period" from t1 as t1 limit 1; -Nuvarande period -9410 -select period as ok_period from t1 limit 1; -ok_period -9410 -select period as ok_period from t1 group by ok_period limit 1; -ok_period -9410 -select 1+1 as summa from t1 group by summa limit 1; -summa -2 -select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1; -Nuvarande period -9410 -show tables; -Tables_in_test -t1 -t2 -t3 -t4 -show tables from test like "s%"; -Tables_in_test (s%) -show tables from test like "t?"; -Tables_in_test (t?) -show full columns from t2; -Field Type Collation Null Key Default Extra Privileges Comment -auto int(11) NULL PRI NULL auto_increment -fld1 int(6) unsigned zerofill NULL UNI 000000 -companynr tinyint(2) unsigned zerofill NULL 00 -fld3 char(30) latin1_swedish_ci MUL -fld4 char(35) latin1_swedish_ci -fld5 char(35) latin1_swedish_ci -fld6 char(4) latin1_swedish_ci -show full columns from t2 from test like 'f%'; -Field Type Collation Null Key Default Extra Privileges Comment -fld1 int(6) unsigned zerofill NULL UNI 000000 -fld3 char(30) latin1_swedish_ci MUL -fld4 char(35) latin1_swedish_ci -fld5 char(35) latin1_swedish_ci -fld6 char(4) latin1_swedish_ci -show full columns from t2 from test like 's%'; -Field Type Collation Null Key Default Extra Privileges Comment -show keys from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE -t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE -t2 1 fld3 1 fld3 A NULL NULL NULL BTREE -drop table t4, t3, t2, t1; -DO 1; -DO benchmark(100,1+1),1,1; -do default; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 -do foobar; -ERROR 42S22: Unknown column 'foobar' in 'field list' -CREATE TABLE t1 ( -id mediumint(8) unsigned NOT NULL auto_increment, -pseudo varchar(35) NOT NULL default '', -PRIMARY KEY (id), -UNIQUE KEY pseudo (pseudo) -); -INSERT INTO t1 (pseudo) VALUES ('test'); -INSERT INTO t1 (pseudo) VALUES ('test1'); -SELECT 1 as rnd1 from t1 where rand() > 2; -rnd1 -DROP TABLE t1; -CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp(14) NOT NULL, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) ENGINE=MyISAM; -INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL); -CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=MyISAM; -INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35); -SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; -gvid the_success the_fail the_size the_time -Warnings: -Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1 -Warning 1292 Incorrect datetime value: 'wrong-date-value' for column 'sampletime' at row 1 -SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; -gvid the_success the_fail the_size the_time -DROP TABLE t1,t2; -create table t1 ( A_Id bigint(20) NOT NULL default '0', A_UpdateBy char(10) NOT NULL default '', A_UpdateDate bigint(20) NOT NULL default '0', A_UpdateSerial int(11) NOT NULL default '0', other_types bigint(20) NOT NULL default '0', wss_type bigint(20) NOT NULL default '0'); -INSERT INTO t1 VALUES (102935998719055004,'brade',1029359987,2,102935229116544068,102935229216544093); -select wss_type from t1 where wss_type ='102935229216544106'; -wss_type -select wss_type from t1 where wss_type ='102935229216544105'; -wss_type -select wss_type from t1 where wss_type ='102935229216544104'; -wss_type -select wss_type from t1 where wss_type ='102935229216544093'; -wss_type -102935229216544093 -select wss_type from t1 where wss_type =102935229216544093; -wss_type -102935229216544093 -drop table t1; -select 1+2,"aaaa",3.13*2.0 into @a,@b,@c; -select @a; -@a -3 -select @b; -@b -aaaa -select @c; -@c -6.26 -create table t1 (a int not null auto_increment primary key); -insert into t1 values (); -insert into t1 values (); -insert into t1 values (); -select * from (t1 as t2 left join t1 as t3 using (a)), t1; -a a a -1 1 1 -2 2 1 -3 3 1 -1 1 2 -2 2 2 -3 3 2 -1 1 3 -2 2 3 -3 3 3 -select * from t1, (t1 as t2 left join t1 as t3 using (a)); -a a a -1 1 1 -2 1 1 -3 1 1 -1 2 2 -2 2 2 -3 2 2 -1 3 3 -2 3 3 -3 3 3 -select * from (t1 as t2 left join t1 as t3 using (a)) straight_join t1; -a a a -1 1 1 -2 2 1 -3 3 1 -1 1 2 -2 2 2 -3 3 2 -1 1 3 -2 2 3 -3 3 3 -select * from t1 straight_join (t1 as t2 left join t1 as t3 using (a)); -a a a -1 1 1 -2 1 1 -3 1 1 -1 2 2 -2 2 2 -3 2 2 -1 3 3 -2 3 3 -3 3 3 -select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 on t1.a>1; -a a a -1 1 2 -1 1 3 -2 2 2 -2 2 3 -3 3 2 -3 3 3 -select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; -a a a -1 1 NULL -2 1 1 -3 1 1 -1 2 NULL -2 2 2 -3 2 2 -1 3 NULL -2 3 3 -3 3 3 -select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 using ( a ); -a a a -1 1 1 -2 2 2 -3 3 3 -select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) using ( a ); -a a a -1 1 1 -2 1 NULL -3 1 NULL -1 2 NULL -2 2 2 -3 2 NULL -1 3 NULL -2 3 NULL -3 3 3 -select * from (t1 as t2 left join t1 as t3 using (a)) left outer join t1 on t1.a>1; -a a a -1 1 2 -1 1 3 -2 2 2 -2 2 3 -3 3 2 -3 3 3 -select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; -a a a -1 1 NULL -2 1 1 -3 1 1 -1 2 NULL -2 2 2 -3 2 2 -1 3 NULL -2 3 3 -3 3 3 -select * from (t1 as t2 left join t1 as t3 using (a)) left join t1 using ( a ); -a a a -1 1 1 -2 2 2 -3 3 3 -select * from t1 left join (t1 as t2 left join t1 as t3 using (a)) using ( a ); -a a a -1 1 1 -2 1 NULL -3 1 NULL -1 2 NULL -2 2 2 -3 2 NULL -1 3 NULL -2 3 NULL -3 3 3 -select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1; -a a a -1 1 1 -2 2 2 -3 3 3 -select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a)); -a a a -1 1 1 -2 2 2 -3 3 3 -select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1; -a a a -1 NULL 1 -2 NULL 1 -3 NULL 1 -1 1 2 -2 2 2 -3 3 2 -1 1 3 -2 2 3 -3 3 3 -select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1; -a a a -2 1 1 -3 1 1 -2 2 2 -3 2 2 -2 3 3 -3 3 3 -select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a ); -a a a -1 1 1 -2 NULL 1 -3 NULL 1 -1 NULL 2 -2 2 2 -3 NULL 2 -1 NULL 3 -2 NULL 3 -3 3 3 -select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a ); -a a a -1 1 1 -2 2 2 -3 3 3 -select * from (t1 as t2 left join t1 as t3 using (a)) natural right join t1; -a a a -1 1 1 -2 NULL 1 -3 NULL 1 -1 NULL 2 -2 2 2 -3 NULL 2 -1 NULL 3 -2 NULL 3 -3 3 3 -select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a)); -a a a -1 1 1 -2 2 2 -3 3 3 -select * from t1 natural join (t1 as t2 left join t1 as t3 using (a)); -a a -1 1 -2 2 -3 3 -select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1; -a a a -1 1 1 -2 2 2 -3 3 3 -drop table t1; -CREATE TABLE t1 ( aa char(2), id int(11) NOT NULL auto_increment, t2_id int(11) NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)) ENGINE=MyISAM; -INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522); -CREATE TABLE t2 ( id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) ENGINE=MyISAM; -INSERT INTO t2 VALUES (2517), (2518), (2519), (2520), (2521), (2522); -select * from t1, t2 WHERE t1.t2_id = t2.id and t1.t2_id > 0 order by t1.id LIMIT 0, 5; -aa id t2_id id -2 8299 2517 2517 -3 8301 2518 2518 -4 8302 2519 2519 -5 8303 2520 2520 -6 8304 2521 2521 -drop table t1,t2; -create table t1 (id1 int NOT NULL); -create table t2 (id2 int NOT NULL); -create table t3 (id3 int NOT NULL); -create table t4 (id4 int NOT NULL, id44 int NOT NULL, KEY (id4)); -insert into t1 values (1); -insert into t1 values (2); -insert into t2 values (1); -insert into t4 values (1,1); -explain select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 -left join t4 on id3 = id4 where id2 = 1 or id4 = 1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 system NULL NULL NULL NULL 0 const row not found -1 SIMPLE t1 ALL NULL NULL NULL NULL 2 -1 SIMPLE t2 ALL NULL NULL NULL NULL 1 -1 SIMPLE t4 ALL id4 NULL NULL NULL 1 Using where -select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3 -left join t4 on id3 = id4 where id2 = 1 or id4 = 1; -id1 id2 id3 id4 id44 -1 1 NULL NULL NULL -drop table t1,t2,t3,t4; -create table t1(s varchar(10) not null); -create table t2(s varchar(10) not null primary key); -create table t3(s varchar(10) not null primary key); -insert into t1 values ('one\t'), ('two\t'); -insert into t2 values ('one\r'), ('two\t'); -insert into t3 values ('one '), ('two\t'); -select * from t1 where s = 'one'; -s -select * from t2 where s = 'one'; -s -select * from t3 where s = 'one'; -s -one -select * from t1,t2 where t1.s = t2.s; -s s -two two -select * from t2,t3 where t2.s = t3.s; -s s -two two -drop table t1, t2, t3; -create table t1 (a integer, b integer, index(a), index(b)); -create table t2 (c integer, d integer, index(c), index(d)); -insert into t1 values (1,2), (2,2), (3,2), (4,2); -insert into t2 values (1,3), (2,3), (3,4), (4,4); -explain select * from t1 left join t2 on a=c where d in (4); -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref c,d d 5 const 2 Using where -1 SIMPLE t1 ALL a NULL NULL NULL 3 Using where -select * from t1 left join t2 on a=c where d in (4); -a b c d -3 2 3 4 -4 2 4 4 -explain select * from t1 left join t2 on a=c where d = 4; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref c,d d 5 const 2 Using where -1 SIMPLE t1 ALL a NULL NULL NULL 3 Using where -select * from t1 left join t2 on a=c where d = 4; -a b c d -3 2 3 4 -4 2 4 4 -drop table t1, t2; -CREATE TABLE t1 ( -i int(11) NOT NULL default '0', -c char(10) NOT NULL default '', -PRIMARY KEY (i), -UNIQUE KEY c (c) -) ENGINE=MyISAM; -INSERT INTO t1 VALUES (1,'a'); -INSERT INTO t1 VALUES (2,'b'); -INSERT INTO t1 VALUES (3,'c'); -EXPLAIN SELECT i FROM t1 WHERE i=1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index -DROP TABLE t1; diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index 7c34481b519..dd07e0ba755 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -195,7 +195,7 @@ h float(3,2) NULL YES NULL select,insert,update,references i float(3,0) NULL YES NULL select,insert,update,references drop table t1; create table t1 ( -type_bool bool not null, +type_bool bool not null default 0, type_tiny tinyint not null auto_increment primary key, type_short smallint(3), type_mediumint mediumint, @@ -206,9 +206,9 @@ empty_char char(0), type_char char(2), type_varchar varchar(10), type_timestamp timestamp not null, -type_date date not null, -type_time time not null, -type_datetime datetime not null, +type_date date not null default '0000-00-00', +type_time time not null default '00:00:00', +type_datetime datetime not null default '0000-00-00 00:00:00', type_year year, type_enum enum ('red', 'green', 'blue'), type_set enum ('red', 'green', 'blue'), @@ -221,7 +221,7 @@ index(type_short) show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `type_bool` tinyint(1) NOT NULL, + `type_bool` tinyint(1) NOT NULL default '0', `type_tiny` tinyint(4) NOT NULL auto_increment, `type_short` smallint(3) default NULL, `type_mediumint` mediumint(9) default NULL, @@ -232,9 +232,9 @@ t1 CREATE TABLE `t1` ( `type_char` char(2) default NULL, `type_varchar` varchar(10) default NULL, `type_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - `type_date` date NOT NULL, - `type_time` time NOT NULL, - `type_datetime` datetime NOT NULL, + `type_date` date NOT NULL default '0000-00-00', + `type_time` time NOT NULL default '00:00:00', + `type_datetime` datetime NOT NULL default '0000-00-00 00:00:00', `type_year` year(4) default NULL, `type_enum` enum('red','green','blue') default NULL, `type_set` enum('red','green','blue') default NULL, @@ -476,3 +476,24 @@ t1 CREATE TABLE `t1` ( KEY `i` USING BTREE (`i`) ) ENGINE=MEMORY DEFAULT CHARSET=latin1 DROP TABLE t1; +CREATE TABLE t1( +field1 text NOT NULL, +PRIMARY KEY(field1(1000)) +); +show index from t1; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def STATISTICS TABLE_NAME Table 253 64 2 N 1 0 63 +def STATISTICS NON_UNIQUE Non_unique 8 1 1 N 32769 0 63 +def STATISTICS INDEX_NAME Key_name 253 64 7 N 1 0 63 +def STATISTICS SEQ_IN_INDEX Seq_in_index 8 2 1 N 32769 0 63 +def STATISTICS COLUMN_NAME Column_name 253 64 6 N 1 0 63 +def STATISTICS COLLATION Collation 253 1 1 Y 0 0 63 +def STATISTICS CARDINALITY Cardinality 8 21 1 Y 32768 0 63 +def STATISTICS SUB_PART Sub_part 8 3 4 Y 32768 0 63 +def STATISTICS PACKED Packed 253 10 0 Y 0 0 63 +def STATISTICS NULLABLE Null 253 3 0 N 1 0 63 +def STATISTICS INDEX_TYPE Index_type 253 16 5 N 1 0 63 +def STATISTICS COMMENT Comment 253 16 0 Y 0 0 63 +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 PRIMARY 1 field1 A 0 1000 NULL BTREE +drop table t1; diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index c979ee34df0..3f224d790f7 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -125,13 +125,13 @@ set @x = x| create function f(x int) returns int return x+42| call p()| -ERROR 42000: Incorrect number of arguments for PROCEDURE p; expected 1, got 0 +ERROR 42000: Incorrect number of arguments for PROCEDURE test.p; expected 1, got 0 call p(1, 2)| -ERROR 42000: Incorrect number of arguments for PROCEDURE p; expected 1, got 2 +ERROR 42000: Incorrect number of arguments for PROCEDURE test.p; expected 1, got 2 select f()| -ERROR 42000: Incorrect number of arguments for FUNCTION f; expected 1, got 0 +ERROR 42000: Incorrect number of arguments for FUNCTION test.f; expected 1, got 0 select f(1, 2)| -ERROR 42000: Incorrect number of arguments for FUNCTION f; expected 1, got 2 +ERROR 42000: Incorrect number of arguments for FUNCTION test.f; expected 1, got 2 drop procedure p| drop function f| create procedure p(val int, out res int) @@ -318,6 +318,24 @@ select field from t1; label L1; end| ERROR HY000: GOTO is not allowed in a stored procedure handler +drop procedure if exists p| +create procedure p(in x int, inout y int, out z int) +begin +set y = x+y; +set z = x+y; +end| +set @tmp_x = 42| +set @tmp_y = 3| +set @tmp_z = 0| +call p(@tmp_x, @tmp_y, @tmp_z)| +select @tmp_x, @tmp_y, @tmp_z| +@tmp_x @tmp_y @tmp_z +42 45 87 +call p(42, 43, @tmp_z)| +ERROR 42000: OUT or INOUT argument 2 for routine test.p is not a variable +call p(42, @tmp_y, 43)| +ERROR 42000: OUT or INOUT argument 3 for routine test.p is not a variable +drop procedure p| create procedure bug1965() begin declare c cursor for select val from t1 order by valname; @@ -503,4 +521,68 @@ ERROR 0A000: LOCK is not allowed in stored procedures create procedure bug6600() unlock table t1| ERROR 0A000: UNLOCK is not allowed in stored procedures +drop procedure if exists bug9566| +create procedure bug9566() +begin +select * from t1; +end| +lock table t1 read| +call bug9566()| +ERROR HY000: Table 'proc' was not locked with LOCK TABLES +unlock tables| +drop procedure bug9566| +drop procedure if exists bug7299| +create procedure bug7299() +begin +declare v int; +declare c cursor for select val from t1; +declare exit handler for sqlexception select 'Error!'; +open c; +fetch c into v; +end| +delete from t1| +call bug7299()| +ERROR 02000: No data to FETCH +drop procedure bug7299| +create procedure bug9073() +begin +declare continue handler for sqlexception select 1; +declare continue handler for sqlexception select 2; +end| +ERROR 42000: Duplicate handler declared in the same block +create procedure bug9073() +begin +declare condname1 condition for 1234; +declare continue handler for condname1 select 1; +declare exit handler for condname1 select 2; +end| +ERROR 42000: Duplicate handler declared in the same block +create procedure bug9073() +begin +declare condname1 condition for sqlstate '42000'; +declare condname2 condition for sqlstate '42000'; +declare exit handler for condname1 select 1; +declare continue handler for condname2 select 2; +end| +ERROR 42000: Duplicate handler declared in the same block +create procedure bug9073() +begin +declare condname1 condition for sqlstate '42000'; +declare exit handler for condname1 select 1; +declare exit handler for sqlstate '42000' select 2; +end| +ERROR 42000: Duplicate handler declared in the same block +drop procedure if exists bug9073| +create procedure bug9073() +begin +declare condname1 condition for sqlstate '42000'; +declare continue handler for condname1 select 1; +begin +declare exit handler for sqlstate '42000' select 2; +begin +declare continue handler for sqlstate '42000' select 3; +end; +end; +end| +drop procedure bug9073| drop table t1| diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 93884bf4cf4..4bb1640f0eb 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -1,7 +1,7 @@ use test; drop table if exists t1; create table t1 ( -id char(16) not null, +id char(16) not null default '', data int not null ); drop table if exists t2; @@ -2164,7 +2164,7 @@ tinyint 1 -128 127 0 0 YES YES NO YES YES NO NULL,0 A very small integer tinyint unsigned 1 0 255 0 0 YES YES YES YES YES NO NULL,0 A very small integer Table Create Table t1 CREATE TABLE `t1` ( - `id` char(16) NOT NULL, + `id` char(16) NOT NULL default '', `data` int(11) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 Database Create Database @@ -2218,7 +2218,7 @@ tinyint 1 -128 127 0 0 YES YES NO YES YES NO NULL,0 A very small integer tinyint unsigned 1 0 255 0 0 YES YES YES YES YES NO NULL,0 A very small integer Table Create Table t1 CREATE TABLE `t1` ( - `id` char(16) NOT NULL, + `id` char(16) NOT NULL default '', `data` int(11) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 Database Create Database @@ -2779,4 +2779,183 @@ a 3.2000 drop procedure bug8937| delete from t1| +drop procedure if exists bug6900| +drop procedure if exists bug9074| +drop procedure if exists bug6900_9074| +drop table if exists t3| +create table t3 (w char unique, x char)| +insert into t3 values ('a', 'b')| +create procedure bug6900() +begin +declare exit handler for sqlexception select '1'; +begin +declare exit handler for sqlexception select '2'; +insert into t3 values ('x', 'y', 'z'); +end; +end| +create procedure bug9074() +begin +declare x1, x2, x3, x4, x5, x6 int default 0; +begin +declare continue handler for sqlstate '23000' set x5 = 1; +insert into t3 values ('a', 'b'); +set x6 = 1; +end; +begin1_label: +begin +declare continue handler for sqlstate '23000' set x1 = 1; +insert into t3 values ('a', 'b'); +set x2 = 1; +begin2_label: +begin +declare exit handler for sqlstate '23000' set x3 = 1; +set x4= 1; +insert into t3 values ('a','b'); +set x4= 0; +end begin2_label; +end begin1_label; +select x1, x2, x3, x4, x5, x6; +end| +create procedure bug6900_9074(z int) +begin +declare exit handler for sqlstate '23000' select '23000'; +begin +declare exit handler for sqlexception select 'sqlexception'; +if z = 1 then +insert into t3 values ('a', 'b'); +else +insert into t3 values ('x', 'y', 'z'); +end if; +end; +end| +call bug6900()| +2 +2 +call bug9074()| +x1 x2 x3 x4 x5 x6 +1 1 1 1 1 1 +call bug6900_9074(0)| +sqlexception +sqlexception +call bug6900_9074(1)| +23000 +23000 +drop procedure bug6900| +drop procedure bug9074| +drop procedure bug6900_9074| +drop table t3| +drop procedure if exists avg| +create procedure avg () +begin +end| +call avg ()| +drop procedure avg| +drop procedure if exists bug6129| +set @@sql_mode = 'traditional'| +create procedure bug6129(mode text) +select @@sql_mode = mode| +call bug6129(@@sql_mode)| +@@sql_mode = mode +1 +set @@sql_mode = ''| +call bug6129(@@sql_mode)| +@@sql_mode = mode +0 +drop procedure bug6129| +drop procedure if exists bug9856| +create procedure bug9856() +begin +declare v int; +declare c cursor for select data from t1; +declare exit handler for sqlexception, not found select '16'; +open c; +fetch c into v; +select v; +end| +delete from t1| +call bug9856()| +16 +16 +call bug9856()| +16 +16 +drop procedure bug9856| +drop procedure if exists bug9674_1| +drop procedure if exists bug9674_2| +create procedure bug9674_1(out arg int) +begin +declare temp_in1 int default 0; +declare temp_fl1 int default 0; +set temp_in1 = 100; +set temp_fl1 = temp_in1/10; +set arg = temp_fl1; +end| +create procedure bug9674_2() +begin +declare v int default 100; +select v/10; +end| +call bug9674_1(@sptmp)| +call bug9674_1(@sptmp)| +select @sptmp| +@sptmp +10 +call bug9674_2()| +v/10 +10.00000 +call bug9674_2()| +v/10 +10.00000 +drop procedure bug9674_1| +drop procedure bug9674_2| +drop procedure if exists bug9598_1| +drop procedure if exists bug9598_2| +create procedure bug9598_1(in var_1 char(16), +out var_2 integer, out var_3 integer) +begin +set var_2 = 50; +set var_3 = 60; +end| +create procedure bug9598_2(in v1 char(16), +in v2 integer, +in v3 integer, +in v4 integer, +in v5 integer) +begin +select v1,v2,v3,v4,v5; +call bug9598_1(v1,@tmp1,@tmp2); +select v1,v2,v3,v4,v5; +end| +call bug9598_2('Test',2,3,4,5)| +v1 v2 v3 v4 v5 +Test 2 3 4 5 +v1 v2 v3 v4 v5 +Test 2 3 4 5 +select @tmp1, @tmp2| +@tmp1 @tmp2 +50 60 +drop procedure bug9598_1| +drop procedure bug9598_2| +drop procedure if exists bug9902| +create function bug9902() returns int(11) +begin +set @x = @x + 1; +return @x; +end| +set @qcs1 = @@query_cache_size| +set global query_cache_size = 100000| +set @x = 1| +insert into t1 values ("qc", 42)| +select bug9902() from t1| +bug9902() +2 +select bug9902() from t1| +bug9902() +3 +select @x| +@x +3 +set global query_cache_size = @qcs1| +delete from t1| +drop function bug9902| drop table t1,t2; diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result index 47dbb87b990..7d1b6b67fd2 100644 --- a/mysql-test/r/strict.result +++ b/mysql-test/r/strict.result @@ -259,17 +259,23 @@ INSERT INTO t1 (col1) VALUES(CAST('2004-10-0' AS DATE)); ERROR 22007: Incorrect date value: '2004-10-00' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES(CAST('2004-0-10' AS DATE)); ERROR 22007: Incorrect date value: '2004-00-10' for column 'col1' at row 1 +INSERT INTO t1 (col1) VALUES(CAST('0000-00-00' AS DATE)); +ERROR 22007: Truncated incorrect datetime value: '0000-00-00' INSERT INTO t1 (col2) VALUES(CAST('0000-10-31 15:30' AS DATETIME)); INSERT INTO t1 (col2) VALUES(CAST('2004-10-0 15:30' AS DATETIME)); ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col2' at row 1 INSERT INTO t1 (col2) VALUES(CAST('2004-0-10 15:30' AS DATETIME)); ERROR 22007: Incorrect datetime value: '2004-00-10 15:30:00' for column 'col2' at row 1 +INSERT INTO t1 (col2) VALUES(CAST('0000-00-00' AS DATETIME)); +ERROR 22007: Truncated incorrect datetime value: '0000-00-00' INSERT INTO t1 (col3) VALUES(CAST('0000-10-31 15:30' AS DATETIME)); ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col3' at row 1 INSERT INTO t1 (col3) VALUES(CAST('2004-10-0 15:30' AS DATETIME)); ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col3' at row 1 INSERT INTO t1 (col3) VALUES(CAST('2004-0-10 15:30' AS DATETIME)); ERROR 22007: Incorrect datetime value: '2004-00-10 15:30:00' for column 'col3' at row 1 +INSERT INTO t1 (col3) VALUES(CAST('0000-00-00' AS DATETIME)); +ERROR 22007: Truncated incorrect datetime value: '0000-00-00' drop table t1; CREATE TABLE t1 (col1 date, col2 datetime, col3 timestamp); INSERT INTO t1 (col1) VALUES (CONVERT('2004-10-15',DATE)); @@ -280,17 +286,23 @@ INSERT INTO t1 (col1) VALUES(CONVERT('2004-10-0' , DATE)); ERROR 22007: Incorrect date value: '2004-10-00' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES(CONVERT('2004-0-10' , DATE)); ERROR 22007: Incorrect date value: '2004-00-10' for column 'col1' at row 1 +INSERT INTO t1 (col1) VALUES(CONVERT('0000-00-00',DATE)); +ERROR 22007: Truncated incorrect datetime value: '0000-00-00' INSERT INTO t1 (col2) VALUES(CONVERT('0000-10-31 15:30',DATETIME)); INSERT INTO t1 (col2) VALUES(CONVERT('2004-10-0 15:30',DATETIME)); ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col2' at row 1 INSERT INTO t1 (col2) VALUES(CONVERT('2004-0-10 15:30',DATETIME)); ERROR 22007: Incorrect datetime value: '2004-00-10 15:30:00' for column 'col2' at row 1 +INSERT INTO t1 (col2) VALUES(CONVERT('0000-00-00',DATETIME)); +ERROR 22007: Truncated incorrect datetime value: '0000-00-00' INSERT INTO t1 (col3) VALUES(CONVERT('0000-10-31 15:30',DATETIME)); ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col3' at row 1 INSERT INTO t1 (col3) VALUES(CONVERT('2004-10-0 15:30',DATETIME)); ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col3' at row 1 INSERT INTO t1 (col3) VALUES(CONVERT('2004-0-10 15:30',DATETIME)); ERROR 22007: Incorrect datetime value: '2004-00-10 15:30:00' for column 'col3' at row 1 +INSERT INTO t1 (col3) VALUES(CONVERT('0000-00-00',DATETIME)); +ERROR 22007: Truncated incorrect datetime value: '0000-00-00' drop table t1; CREATE TABLE t1(col1 TINYINT, col2 TINYINT UNSIGNED); INSERT INTO t1 VALUES(-128,0),(0,0),(127,255),('-128','0'),('0','0'),('127','255'),(-128.0,0.0),(0.0,0.0),(127.0,255.0); @@ -1017,7 +1029,11 @@ Warnings: Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'col1' at row 1 Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'col2' at row 1 INSERT IGNORE INTO t1 (col1) values (3); +Warnings: +Warning 1364 Field 'col2' doesn't have a default value INSERT IGNORE INTO t1 () values (); +Warnings: +Warning 1364 Field 'col2' doesn't have a default value SELECT * FROM t1; col1 col2 1 hello @@ -1089,4 +1105,130 @@ Error 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_t Error 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_time Error 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_time drop table t1; +create table t1 (col1 char(3), col2 integer); +insert into t1 (col1) values (cast(1000 as char(3))); +ERROR 22007: Truncated incorrect CHAR(3) value: '1000' +insert into t1 (col1) values (cast(1000E+0 as char(3))); +ERROR 22007: Truncated incorrect CHAR(3) value: '1000' +insert into t1 (col1) values (cast(1000.0 as char(3))); +ERROR 22007: Truncated incorrect CHAR(3) value: '1000.0' +insert into t1 (col2) values (cast('abc' as signed integer)); +ERROR 22007: Truncated incorrect INTEGER value: 'abc' +insert into t1 (col2) values (10E+0 + 'a'); +ERROR 22007: Truncated incorrect DOUBLE value: 'a' +insert into t1 (col2) values (cast('10a' as unsigned integer)); +ERROR 22007: Truncated incorrect INTEGER value: '10a' +insert into t1 (col2) values (cast('10' as unsigned integer)); +insert into t1 (col2) values (cast('10' as signed integer)); +insert into t1 (col2) values (10E+0 + '0 '); +select * from t1; +col1 col2 +NULL 10 +NULL 10 +NULL 10 +drop table t1; +create table t1 (col1 date, col2 datetime, col3 timestamp); +insert into t1 values (0,0,0); +ERROR 22007: Incorrect date value: '0' for column 'col1' at row 1 +insert into t1 values (0.0,0.0,0.0); +ERROR 22007: Incorrect date value: '0' for column 'col1' at row 1 +insert into t1 (col1) values (convert('0000-00-00',date)); +ERROR 22007: Truncated incorrect datetime value: '0000-00-00' +insert into t1 (col1) values (cast('0000-00-00' as date)); +ERROR 22007: Truncated incorrect datetime value: '0000-00-00' +set sql_mode='no_zero_date'; +insert into t1 values (0,0,0); +Warnings: +Warning 1264 Out of range value adjusted for column 'col1' at row 1 +Warning 1264 Out of range value adjusted for column 'col2' at row 1 +Warning 1265 Data truncated for column 'col3' at row 1 +insert into t1 values (0.0,0.0,0.0); +Warnings: +Warning 1264 Out of range value adjusted for column 'col1' at row 1 +Warning 1264 Out of range value adjusted for column 'col2' at row 1 +Warning 1265 Data truncated for column 'col3' at row 1 +drop table t1; +set sql_mode='traditional'; +create table t1 (col1 date); +insert ignore into t1 values ('0000-00-00'); +Warnings: +Warning 1265 Data truncated for column 'col1' at row 1 +insert into t1 select * from t1; +ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1 +insert ignore into t1 values ('0000-00-00'); +Warnings: +Warning 1265 Data truncated for column 'col1' at row 1 +insert ignore into t1 (col1) values (cast('0000-00-00' as date)); +Warnings: +Warning 1292 Truncated incorrect datetime value: '0000-00-00' +insert into t1 select * from t1; +ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1 +alter table t1 modify col1 datetime; +ERROR 22007: Incorrect datetime value: '0000-00-00' for column 'col1' at row 1 +alter ignore table t1 modify col1 datetime; +Warnings: +Warning 1264 Out of range value adjusted for column 'col1' at row 1 +Warning 1264 Out of range value adjusted for column 'col1' at row 2 +insert into t1 select * from t1; +ERROR 22007: Incorrect datetime value: '0000-00-00 00:00:00' for column 'col1' at row 1 +select * from t1; +col1 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +NULL +drop table t1; +create table t1 (col1 tinyint); +drop procedure if exists t1; +Warnings: +Note 1305 PROCEDURE t1 does not exist +create procedure t1 () begin declare exit handler for sqlexception +select'a'; insert into t1 values (200); end;| +call t1(); +a +a +select * from t1; +col1 +drop procedure t1; +drop table t1; set sql_mode=@org_mode; +SET @@sql_mode = 'traditional'; +CREATE TABLE t1 (i int not null); +INSERT INTO t1 VALUES (); +ERROR HY000: Field 'i' doesn't have a default value +INSERT INTO t1 VALUES (DEFAULT); +ERROR HY000: Field 'i' doesn't have a default value +INSERT INTO t1 VALUES (DEFAULT(i)); +ERROR HY000: Field 'i' doesn't have a default value +ALTER TABLE t1 ADD j int; +INSERT INTO t1 SET j = 1; +ERROR HY000: Field 'i' doesn't have a default value +INSERT INTO t1 SET j = 1, i = DEFAULT; +ERROR HY000: Field 'i' doesn't have a default value +INSERT INTO t1 SET j = 1, i = DEFAULT(i); +ERROR HY000: Field 'i' doesn't have a default value +INSERT INTO t1 VALUES (DEFAULT,1); +ERROR HY000: Field 'i' doesn't have a default value +DROP TABLE t1; +SET @@sql_mode = ''; +CREATE TABLE t1 (i int not null); +INSERT INTO t1 VALUES (); +Warnings: +Warning 1364 Field 'i' doesn't have a default value +INSERT INTO t1 VALUES (DEFAULT); +Warnings: +Warning 1364 Field 'i' doesn't have a default value +INSERT INTO t1 VALUES (DEFAULT(i)); +ERROR HY000: Field 'i' doesn't have a default value +ALTER TABLE t1 ADD j int; +INSERT INTO t1 SET j = 1; +Warnings: +Warning 1364 Field 'i' doesn't have a default value +INSERT INTO t1 SET j = 1, i = DEFAULT; +Warnings: +Warning 1364 Field 'i' doesn't have a default value +INSERT INTO t1 SET j = 1, i = DEFAULT(i); +ERROR HY000: Field 'i' doesn't have a default value +INSERT INTO t1 VALUES (DEFAULT,1); +Warnings: +Warning 1364 Field 'i' doesn't have a default value +DROP TABLE t1; diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 036d1631592..fa5f27b7eed 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -117,15 +117,17 @@ SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a'); SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b'); (SELECT 1.5,2,'a') = ROW(1.5,2,'b') 0 -SELECT (SELECT 1.5,2,'a') = ROW('b',2,'b'); -(SELECT 1.5,2,'a') = ROW('b',2,'b') +SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b'); +(SELECT 1.5,2,'a') = ROW('1.5b',2,'b') 0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '1.5b' SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a'); (SELECT 'b',2,'a') = ROW(1.5,2,'a') 0 -SELECT (SELECT 1.5,2,'a') = ROW(1.5,'c','a'); -(SELECT 1.5,2,'a') = ROW(1.5,'c','a') -0 +SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a'); +(SELECT 1.5,2,'a') = ROW(1.5,'2','a') +1 SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a'); (SELECT 1.5,'c','a') = ROW(1.5,2,'a') 0 @@ -2744,3 +2746,38 @@ NULL 2.00 4.00 drop table t1; +CREATE table t1 ( c1 integer ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +CREATE TABLE t2 ( c2 integer ); +INSERT INTO t2 VALUES ( 1 ); +INSERT INTO t2 VALUES ( 4 ); +INSERT INTO t2 VALUES ( 5 ); +SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2 WHERE c2 IN (1); +c1 c2 +1 1 +SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2 +WHERE c2 IN ( SELECT c2 FROM t2 WHERE c2 IN ( 1 ) ); +c1 c2 +1 1 +DROP TABLE t1,t2; +CREATE TABLE t1 ( c1 integer ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +INSERT INTO t1 VALUES ( 6 ); +CREATE TABLE t2 ( c2 integer ); +INSERT INTO t2 VALUES ( 1 ); +INSERT INTO t2 VALUES ( 4 ); +INSERT INTO t2 VALUES ( 5 ); +INSERT INTO t2 VALUES ( 6 ); +CREATE TABLE t3 ( c3 integer ); +INSERT INTO t3 VALUES ( 7 ); +INSERT INTO t3 VALUES ( 8 ); +SELECT c1,c2 FROM t1 LEFT JOIN t2 ON c1 = c2 +WHERE EXISTS (SELECT c3 FROM t3 WHERE c2 IS NULL ); +c1 c2 +2 NULL +3 NULL +DROP TABLE t1,t2,t3; diff --git a/mysql-test/r/sum_distinct-big.result b/mysql-test/r/sum_distinct-big.result new file mode 100644 index 00000000000..06bfc6b1f78 --- /dev/null +++ b/mysql-test/r/sum_distinct-big.result @@ -0,0 +1,108 @@ +using_big_test +0 +CREATE TABLE t1 (id INTEGER); +CREATE TABLE t2 (id INTEGER); +INSERT INTO t1 (id) VALUES (1), (1), (1),(1); +INSERT INTO t1 (id) SELECT id FROM t1; +/* 8 */ +INSERT INTO t1 (id) SELECT id FROM t1; +/* 12 */ +INSERT INTO t1 (id) SELECT id FROM t1; +/* 16 */ +INSERT INTO t1 (id) SELECT id FROM t1; +/* 20 */ +INSERT INTO t1 (id) SELECT id FROM t1; +/* 24 */ +INSERT INTO t1 SELECT id+1 FROM t1; +INSERT INTO t1 SELECT id+2 FROM t1; +INSERT INTO t1 SELECT id+4 FROM t1; +INSERT INTO t1 SELECT id+8 FROM t1; +INSERT INTO t1 SELECT id+16 FROM t1; +INSERT INTO t1 SELECT id+32 FROM t1; +INSERT INTO t1 SELECT id+64 FROM t1; +INSERT INTO t1 SELECT id+128 FROM t1; +INSERT INTO t1 SELECT id+256 FROM t1; +INSERT INTO t1 SELECT id+512 FROM t1; +SELECT AVG(DISTINCT id) FROM t1 GROUP BY id % 13; +AVG(DISTINCT id) +513.5000 +508.0000 +509.0000 +510.0000 +511.0000 +512.0000 +513.0000 +514.0000 +515.0000 +516.0000 +517.0000 +511.5000 +512.5000 +SELECT SUM(DISTINCT id)/COUNT(DISTINCT id) FROM t1 GROUP BY id % 13; +SUM(DISTINCT id)/COUNT(DISTINCT id) +513.50000 +508.00000 +509.00000 +510.00000 +511.00000 +512.00000 +513.00000 +514.00000 +515.00000 +516.00000 +517.00000 +511.50000 +512.50000 +INSERT INTO t1 SELECT id+1024 FROM t1; +INSERT INTO t1 SELECT id+2048 FROM t1; +INSERT INTO t1 SELECT id+4096 FROM t1; +INSERT INTO t1 SELECT id+8192 FROM t1; +INSERT INTO t2 SELECT id FROM t1 ORDER BY id*rand(); +SELECT SUM(DISTINCT id) sm FROM t1; +sm +134225920 +SELECT SUM(DISTINCT id) sm FROM t2; +sm +134225920 +SELECT SUM(DISTINCT id) sm FROM t1 group by id % 13; +sm +10327590 +10328851 +10330112 +10331373 +10332634 +10317510 +10318770 +10320030 +10321290 +10322550 +10323810 +10325070 +10326330 +SET max_heap_table_size=16384; +SHOW variables LIKE 'max_heap_table_size'; +Variable_name Value +max_heap_table_size 16384 +SELECT SUM(DISTINCT id) sm FROM t1; +sm +134225920 +SELECT SUM(DISTINCT id) sm FROM t2; +sm +134225920 +SELECT SUM(DISTINCT id) sm FROM t1 GROUP BY id % 13; +sm +10327590 +10328851 +10330112 +10331373 +10332634 +10317510 +10318770 +10320030 +10321290 +10322550 +10323810 +10325070 +10326330 +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/r/sum_distinct.result b/mysql-test/r/sum_distinct.result index 0591943e800..c615817f52d 100644 --- a/mysql-test/r/sum_distinct.result +++ b/mysql-test/r/sum_distinct.result @@ -95,109 +95,3 @@ SELECT SUM(DISTINCT id % 11) FROM t1; SUM(DISTINCT id % 11) 55 DROP TABLE t1; -CREATE TABLE t1 (id INTEGER); -CREATE TABLE t2 (id INTEGER); -INSERT INTO t1 (id) VALUES (1), (1), (1),(1); -INSERT INTO t1 (id) SELECT id FROM t1; -/* 8 */ -INSERT INTO t1 (id) SELECT id FROM t1; -/* 12 */ -INSERT INTO t1 (id) SELECT id FROM t1; -/* 16 */ -INSERT INTO t1 (id) SELECT id FROM t1; -/* 20 */ -INSERT INTO t1 (id) SELECT id FROM t1; -/* 24 */ -INSERT INTO t1 SELECT id+1 FROM t1; -INSERT INTO t1 SELECT id+2 FROM t1; -INSERT INTO t1 SELECT id+4 FROM t1; -INSERT INTO t1 SELECT id+8 FROM t1; -INSERT INTO t1 SELECT id+16 FROM t1; -INSERT INTO t1 SELECT id+32 FROM t1; -INSERT INTO t1 SELECT id+64 FROM t1; -INSERT INTO t1 SELECT id+128 FROM t1; -INSERT INTO t1 SELECT id+256 FROM t1; -INSERT INTO t1 SELECT id+512 FROM t1; -SELECT AVG(DISTINCT id) FROM t1 GROUP BY id % 13; -AVG(DISTINCT id) -513.5000 -508.0000 -509.0000 -510.0000 -511.0000 -512.0000 -513.0000 -514.0000 -515.0000 -516.0000 -517.0000 -511.5000 -512.5000 -SELECT SUM(DISTINCT id)/COUNT(DISTINCT id) FROM t1 GROUP BY id % 13; -SUM(DISTINCT id)/COUNT(DISTINCT id) -513.50000 -508.00000 -509.00000 -510.00000 -511.00000 -512.00000 -513.00000 -514.00000 -515.00000 -516.00000 -517.00000 -511.50000 -512.50000 -INSERT INTO t1 SELECT id+1024 FROM t1; -INSERT INTO t1 SELECT id+2048 FROM t1; -INSERT INTO t1 SELECT id+4096 FROM t1; -INSERT INTO t1 SELECT id+8192 FROM t1; -INSERT INTO t2 SELECT id FROM t1 ORDER BY id*rand(); -SELECT SUM(DISTINCT id) sm FROM t1; -sm -134225920 -SELECT SUM(DISTINCT id) sm FROM t2; -sm -134225920 -SELECT SUM(DISTINCT id) sm FROM t1 group by id % 13; -sm -10327590 -10328851 -10330112 -10331373 -10332634 -10317510 -10318770 -10320030 -10321290 -10322550 -10323810 -10325070 -10326330 -SET max_heap_table_size=16384; -SHOW variables LIKE 'max_heap_table_size'; -Variable_name Value -max_heap_table_size 16384 -SELECT SUM(DISTINCT id) sm FROM t1; -sm -134225920 -SELECT SUM(DISTINCT id) sm FROM t2; -sm -134225920 -SELECT SUM(DISTINCT id) sm FROM t1 GROUP BY id % 13; -sm -10327590 -10328851 -10330112 -10331373 -10332634 -10317510 -10318770 -10320030 -10321290 -10322550 -10323810 -10325070 -10326330 -DROP TABLE t1; -DROP TABLE t2; diff --git a/mysql-test/r/timezone2.result b/mysql-test/r/timezone2.result index 5ef06ae363b..a90bdf9ad5b 100644 --- a/mysql-test/r/timezone2.result +++ b/mysql-test/r/timezone2.result @@ -251,60 +251,6 @@ select convert_tz(ts, @@time_zone, 'Japan') from t1; convert_tz(ts, @@time_zone, 'Japan') 2001-09-09 10:46:40 drop table t1; -delete from mysql.user where user like 'mysqltest\_%'; -delete from mysql.db where user like 'mysqltest\_%'; -delete from mysql.tables_priv where user like 'mysqltest\_%'; -delete from mysql.columns_priv where user like 'mysqltest\_%'; -flush privileges; -create table t1 (a int, b datetime); -create table t2 (c int, d datetime); -grant all privileges on test.* to mysqltest_1@localhost; -show grants for current_user(); -Grants for mysqltest_1@localhost -GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' -GRANT ALL PRIVILEGES ON `test`.* TO 'mysqltest_1'@'localhost' -set time_zone= '+00:00'; -set time_zone= 'Europe/Moscow'; -select convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC'); -convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC') -2004-10-21 15:00:00 -select convert_tz(b, 'Europe/Moscow', 'UTC') from t1; -convert_tz(b, 'Europe/Moscow', 'UTC') -update t1, t2 set t1.b = convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC') -where t1.a = t2.c and t2.d = (select max(d) from t2); -select * from mysql.time_zone_name; -ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'time_zone_name' -select Name, convert_tz('2004-10-21 19:00:00', Name, 'UTC') from mysql.time_zone_name; -ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'time_zone_name' -delete from mysql.db where user like 'mysqltest\_%'; -flush privileges; -grant all privileges on test.t1 to mysqltest_1@localhost; -grant all privileges on test.t2 to mysqltest_1@localhost; -show grants for current_user(); -Grants for mysqltest_1@localhost -GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' -GRANT ALL PRIVILEGES ON `test`.`t2` TO 'mysqltest_1'@'localhost' -GRANT ALL PRIVILEGES ON `test`.`t1` TO 'mysqltest_1'@'localhost' -set time_zone= '+00:00'; -set time_zone= 'Europe/Moscow'; -select convert_tz('2004-11-31 12:00:00', 'Europe/Moscow', 'UTC'); -convert_tz('2004-11-31 12:00:00', 'Europe/Moscow', 'UTC') -NULL -Warnings: -Warning 1292 Truncated incorrect datetime value: '2004-11-31 12:00:00' -select convert_tz(b, 'Europe/Moscow', 'UTC') from t1; -convert_tz(b, 'Europe/Moscow', 'UTC') -update t1, t2 set t1.b = convert_tz('2004-11-30 12:00:00', 'Europe/Moscow', 'UTC') -where t1.a = t2.c and t2.d = (select max(d) from t2); -select * from mysql.time_zone_name; -ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'time_zone_name' -select Name, convert_tz('2004-11-30 12:00:00', Name, 'UTC') from mysql.time_zone_name; -ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'time_zone_name' -delete from mysql.user where user like 'mysqltest\_%'; -delete from mysql.db where user like 'mysqltest\_%'; -delete from mysql.tables_priv where user like 'mysqltest\_%'; -flush privileges; -drop table t1, t2; select convert_tz('2005-01-14 17:00:00', 'UTC', custTimeZone) from (select 'UTC' as custTimeZone) as tmp; convert_tz('2005-01-14 17:00:00', 'UTC', custTimeZone) 2005-01-14 17:00:00 diff --git a/mysql-test/r/timezone_grant.result b/mysql-test/r/timezone_grant.result new file mode 100644 index 00000000000..dfe0b75ee43 --- /dev/null +++ b/mysql-test/r/timezone_grant.result @@ -0,0 +1,54 @@ +delete from mysql.user where user like 'mysqltest\_%'; +delete from mysql.db where user like 'mysqltest\_%'; +delete from mysql.tables_priv where user like 'mysqltest\_%'; +delete from mysql.columns_priv where user like 'mysqltest\_%'; +flush privileges; +create table t1 (a int, b datetime); +create table t2 (c int, d datetime); +grant all privileges on test.* to mysqltest_1@localhost; +show grants for current_user(); +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' +GRANT ALL PRIVILEGES ON `test`.* TO 'mysqltest_1'@'localhost' +set time_zone= '+00:00'; +set time_zone= 'Europe/Moscow'; +select convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC'); +convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC') +2004-10-21 15:00:00 +select convert_tz(b, 'Europe/Moscow', 'UTC') from t1; +convert_tz(b, 'Europe/Moscow', 'UTC') +update t1, t2 set t1.b = convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC') +where t1.a = t2.c and t2.d = (select max(d) from t2); +select * from mysql.time_zone_name; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'time_zone_name' +select Name, convert_tz('2004-10-21 19:00:00', Name, 'UTC') from mysql.time_zone_name; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'time_zone_name' +delete from mysql.db where user like 'mysqltest\_%'; +flush privileges; +grant all privileges on test.t1 to mysqltest_1@localhost; +grant all privileges on test.t2 to mysqltest_1@localhost; +show grants for current_user(); +Grants for mysqltest_1@localhost +GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' +GRANT ALL PRIVILEGES ON `test`.`t2` TO 'mysqltest_1'@'localhost' +GRANT ALL PRIVILEGES ON `test`.`t1` TO 'mysqltest_1'@'localhost' +set time_zone= '+00:00'; +set time_zone= 'Europe/Moscow'; +select convert_tz('2004-11-31 12:00:00', 'Europe/Moscow', 'UTC'); +convert_tz('2004-11-31 12:00:00', 'Europe/Moscow', 'UTC') +NULL +Warnings: +Warning 1292 Truncated incorrect datetime value: '2004-11-31 12:00:00' +select convert_tz(b, 'Europe/Moscow', 'UTC') from t1; +convert_tz(b, 'Europe/Moscow', 'UTC') +update t1, t2 set t1.b = convert_tz('2004-11-30 12:00:00', 'Europe/Moscow', 'UTC') +where t1.a = t2.c and t2.d = (select max(d) from t2); +select * from mysql.time_zone_name; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'time_zone_name' +select Name, convert_tz('2004-11-30 12:00:00', Name, 'UTC') from mysql.time_zone_name; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'time_zone_name' +delete from mysql.user where user like 'mysqltest\_%'; +delete from mysql.db where user like 'mysqltest\_%'; +delete from mysql.tables_priv where user like 'mysqltest\_%'; +flush privileges; +drop table t1, t2; diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index 4a85097cfce..cf0e0e8f564 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -1,5 +1,6 @@ drop table if exists t1, t2; drop view if exists v1; +drop database if exists mysqltest; create table t1 (i int); create trigger trg before insert on t1 for each row set @a:=1; set @a:=0; @@ -190,3 +191,18 @@ select @del_before, @del_after; drop trigger t1.trg1; drop trigger t1.trg2; drop table t1; +create table t1 (a int); +create trigger trg1 before insert on t1 for each row set new.a= 10; +drop table t1; +create table t1 (a int); +insert into t1 values (); +select * from t1; +a +NULL +drop table t1; +create database mysqltest; +use mysqltest; +create table t1 (i int); +create trigger trg1 before insert on t1 for each row set @a:= 1; +drop database mysqltest; +use test; diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result index c926ebb6878..b0cd4150c9d 100644 --- a/mysql-test/r/type_bit.result +++ b/mysql-test/r/type_bit.result @@ -377,3 +377,63 @@ hex(concat(a)) hex(concat(b)) 07 0FFE 01 01FF drop table t1; +create table t1(a int, b bit not null); +alter table t1 add primary key (a); +drop table t1; +create table t1 (a bit(19), b bit(5)); +insert into t1 values (1000, 10), (3, 8), (200, 6), (2303, 2), (12345, 4), (1, 0); +select a+0, b+0 from t1; +a+0 b+0 +1000 10 +3 8 +200 6 +2303 2 +12345 4 +1 0 +alter table t1 engine=heap; +select a+0, b+0 from t1; +a+0 b+0 +1000 10 +3 8 +200 6 +2303 2 +12345 4 +1 0 +alter table t1 add key(a, b); +select a+0, b+0 from t1; +a+0 b+0 +1000 10 +3 8 +200 6 +2303 2 +12345 4 +1 0 +alter table t1 engine=myisam; +select a+0, b+0 from t1; +a+0 b+0 +1 0 +3 8 +200 6 +1000 10 +2303 2 +12345 4 +create table t2 engine=heap select * from t1; +select a+0, b+0 from t2; +a+0 b+0 +1 0 +3 8 +200 6 +1000 10 +2303 2 +12345 4 +drop table t1; +create table t1 select * from t2; +select a+0, b+0 from t1; +a+0 b+0 +1 0 +3 8 +200 6 +1000 10 +2303 2 +12345 4 +drop table t1, t2; diff --git a/mysql-test/r/type_bit_innodb.result b/mysql-test/r/type_bit_innodb.result new file mode 100644 index 00000000000..f3e9dad3baa --- /dev/null +++ b/mysql-test/r/type_bit_innodb.result @@ -0,0 +1,404 @@ +select 0 + b'1'; +0 + b'1' +1 +select 0 + b'0'; +0 + b'0' +0 +select 0 + b'000001'; +0 + b'000001' +1 +select 0 + b'000011'; +0 + b'000011' +3 +select 0 + b'000101'; +0 + b'000101' +5 +select 0 + b'000000'; +0 + b'000000' +0 +select 0 + b'10000000'; +0 + b'10000000' +128 +select 0 + b'11111111'; +0 + b'11111111' +255 +select 0 + b'10000001'; +0 + b'10000001' +129 +select 0 + b'1000000000000000'; +0 + b'1000000000000000' +32768 +select 0 + b'1111111111111111'; +0 + b'1111111111111111' +65535 +select 0 + b'1000000000000001'; +0 + b'1000000000000001' +32769 +drop table if exists t1; +create table t1 (a bit(65)) engine=innodb; +ERROR 42000: Column length too big for column 'a' (max = 64); use BLOB or TEXT instead +create table t1 (a bit(0)) engine=innodb; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bit(1) default NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t1; +create table t1 (a bit(64)) engine=innodb; +insert into t1 values +(b'1111111111111111111111111111111111111111111111111111111111111111'), +(b'1000000000000000000000000000000000000000000000000000000000000000'), +(b'0000000000000000000000000000000000000000000000000000000000000001'), +(b'1010101010101010101010101010101010101010101010101010101010101010'), +(b'0101010101010101010101010101010101010101010101010101010101010101'); +select hex(a) from t1; +hex(a) +FFFFFFFFFFFFFFFF +8000000000000000 +1 +AAAAAAAAAAAAAAAA +5555555555555555 +drop table t1; +create table t1 (a bit) engine=innodb; +insert into t1 values (b'0'), (b'1'), (b'000'), (b'100'), (b'001'); +Warnings: +Warning 1264 Out of range value adjusted for column 'a' at row 4 +select hex(a) from t1; +hex(a) +0 +1 +0 +1 +1 +alter table t1 add unique (a); +ERROR 23000: Duplicate entry '' for key 1 +drop table t1; +create table t1 (a bit(2)) engine=innodb; +insert into t1 values (b'00'), (b'01'), (b'10'), (b'100'); +Warnings: +Warning 1264 Out of range value adjusted for column 'a' at row 4 +select a+0 from t1; +a+0 +0 +1 +2 +3 +alter table t1 add key (a); +explain select a+0 from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 2 NULL 4 Using index +select a+0 from t1; +a+0 +0 +1 +2 +3 +drop table t1; +create table t1 (a bit(7), b bit(9), key(a, b)) engine=innodb; +insert into t1 values +(94, 46), (31, 438), (61, 152), (78, 123), (88, 411), (122, 118), (0, 177), +(75, 42), (108, 67), (79, 349), (59, 188), (68, 206), (49, 345), (118, 380), +(111, 368), (94, 468), (56, 379), (77, 133), (29, 399), (9, 363), (23, 36), +(116, 390), (119, 368), (87, 351), (123, 411), (24, 398), (34, 202), (28, 499), +(30, 83), (5, 178), (60, 343), (4, 245), (104, 280), (106, 446), (127, 403), +(44, 307), (68, 454), (57, 135); +explain select a+0 from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 5 NULL 38 Using index +select a+0 from t1; +a+0 +0 +4 +5 +9 +23 +24 +28 +29 +30 +31 +34 +44 +49 +56 +57 +59 +60 +61 +68 +68 +75 +77 +78 +79 +87 +88 +94 +94 +104 +106 +108 +111 +116 +118 +119 +122 +123 +127 +explain select b+0 from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 5 NULL 38 Using index +select b+0 from t1; +b+0 +177 +245 +178 +363 +36 +398 +499 +399 +83 +438 +202 +307 +345 +379 +135 +188 +343 +152 +206 +454 +42 +133 +123 +349 +351 +411 +46 +468 +280 +446 +67 +368 +390 +380 +368 +118 +411 +403 +explain select a+0, b+0 from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 5 NULL 38 Using index +select a+0, b+0 from t1; +a+0 b+0 +0 177 +4 245 +5 178 +9 363 +23 36 +24 398 +28 499 +29 399 +30 83 +31 438 +34 202 +44 307 +49 345 +56 379 +57 135 +59 188 +60 343 +61 152 +68 206 +68 454 +75 42 +77 133 +78 123 +79 349 +87 351 +88 411 +94 46 +94 468 +104 280 +106 446 +108 67 +111 368 +116 390 +118 380 +119 368 +122 118 +123 411 +127 403 +explain select a+0, b+0 from t1 where a > 40 and b > 200 order by 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 2 NULL 19 Using where; Using index; Using filesort +select a+0, b+0 from t1 where a > 40 and b > 200 order by 1; +a+0 b+0 +44 307 +49 345 +56 379 +60 343 +68 206 +68 454 +79 349 +87 351 +88 411 +94 468 +104 280 +106 446 +111 368 +116 390 +118 380 +119 368 +123 411 +127 403 +explain select a+0, b+0 from t1 where a > 40 and a < 70 order by 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 2 NULL 8 Using where; Using index; Using filesort +select a+0, b+0 from t1 where a > 40 and a < 70 order by 2; +a+0 b+0 +57 135 +61 152 +59 188 +68 206 +44 307 +60 343 +49 345 +56 379 +68 454 +set @@max_length_for_sort_data=0; +select a+0, b+0 from t1 where a > 40 and a < 70 order by 2; +a+0 b+0 +57 135 +61 152 +59 188 +68 206 +44 307 +60 343 +49 345 +56 379 +68 454 +select hex(min(a)) from t1; +hex(min(a)) +0 +select hex(min(b)) from t1; +hex(min(b)) +24 +select hex(min(a)), hex(max(a)), hex(min(b)), hex(max(b)) from t1; +hex(min(a)) hex(max(a)) hex(min(b)) hex(max(b)) +0 7F 24 1F3 +drop table t1; +create table t1 (a int not null, b bit, c bit(9), key(a, b, c)) engine=innodb; +insert into t1 values +(4, NULL, 1), (4, 0, 3), (2, 1, 4), (1, 1, 100), (4, 0, 23), (4, 0, 54), +(56, 0, 22), (4, 1, 100), (23, 0, 1), (4, 0, 34); +select a+0, b+0, c+0 from t1; +a+0 b+0 c+0 +1 1 100 +2 1 4 +4 NULL 1 +4 0 3 +4 0 23 +4 0 34 +4 0 54 +4 1 100 +23 0 1 +56 0 22 +select hex(min(b)) from t1 where a = 4; +hex(min(b)) +0 +select hex(min(c)) from t1 where a = 4 and b = 0; +hex(min(c)) +3 +select hex(max(b)) from t1; +hex(max(b)) +1 +select a+0, b+0, c+0 from t1 where a = 4 and b = 0 limit 2; +a+0 b+0 c+0 +4 0 3 +4 0 23 +select a+0, b+0, c+0 from t1 where a = 4 and b = 1; +a+0 b+0 c+0 +4 1 100 +select a+0, b+0, c+0 from t1 where a = 4 and b = 1 and c=100; +a+0 b+0 c+0 +4 1 100 +select a+0, b+0, c+0 from t1 order by b desc; +a+0 b+0 c+0 +2 1 4 +1 1 100 +4 1 100 +4 0 3 +4 0 23 +4 0 54 +56 0 22 +23 0 1 +4 0 34 +4 NULL 1 +select a+0, b+0, c+0 from t1 order by c; +a+0 b+0 c+0 +4 NULL 1 +23 0 1 +4 0 3 +2 1 4 +56 0 22 +4 0 23 +4 0 34 +4 0 54 +1 1 100 +4 1 100 +drop table t1; +create table t1(a bit(2), b bit(2)) engine=innodb; +insert into t1 (a) values (0x01), (0x03), (0x02); +update t1 set b= concat(a); +select a+0, b+0 from t1; +a+0 b+0 +1 1 +3 3 +2 2 +drop table t1; +create table t1 (a bit(7), key(a)) engine=innodb; +insert into t1 values (44), (57); +select a+0 from t1; +a+0 +44 +57 +drop table t1; +create table t1 (a bit(3), b bit(12)) engine=innodb; +insert into t1 values (7,(1<<12)-2), (0x01,0x01ff); +select hex(a),hex(b) from t1; +hex(a) hex(b) +7 FFE +1 1FF +select hex(concat(a)),hex(concat(b)) from t1; +hex(concat(a)) hex(concat(b)) +07 0FFE +01 01FF +drop table t1; +create table t1(a int, b bit not null) engine=innodb; +alter table t1 add primary key (a); +drop table t1; +create table t1 (a bit, b bit(10)) engine=innodb; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bit(1) default NULL, + `b` bit(10) default NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +alter table t1 engine=heap; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bit(1) default NULL, + `b` bit(10) default NULL +) ENGINE=MEMORY DEFAULT CHARSET=latin1 +alter table t1 engine=innodb; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bit(1) default NULL, + `b` bit(10) default NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t1; diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result index 3316f9bb6db..6f437ddbe0d 100644 --- a/mysql-test/r/type_blob.result +++ b/mysql-test/r/type_blob.result @@ -80,17 +80,17 @@ update t1 set c="",b=null where c="1"; lock tables t1 READ; show full fields from t1; Field Type Collation Null Key Default Extra Privileges Comment -t text latin1_swedish_ci YES NULL select,insert,update,references -c char(10) latin1_swedish_ci YES NULL select,insert,update,references -b blob NULL YES NULL select,insert,update,references -d binary(10) NULL YES NULL select,insert,update,references +t text latin1_swedish_ci YES NULL # +c char(10) latin1_swedish_ci YES NULL # +b blob NULL YES NULL # +d binary(10) NULL YES NULL # lock tables t1 WRITE; show full fields from t1; Field Type Collation Null Key Default Extra Privileges Comment -t text latin1_swedish_ci YES NULL select,insert,update,references -c char(10) latin1_swedish_ci YES NULL select,insert,update,references -b blob NULL YES NULL select,insert,update,references -d binary(10) NULL YES NULL select,insert,update,references +t text latin1_swedish_ci YES NULL # +c char(10) latin1_swedish_ci YES NULL # +b blob NULL YES NULL # +d binary(10) NULL YES NULL # unlock tables; select t from t1 where t like "hello"; t @@ -502,7 +502,7 @@ select foobar, boggle from t1 where foobar = 'fish' and boggle = 10; foobar boggle fish 10 drop table t1; -create table t1 (id integer auto_increment unique,imagem LONGBLOB not null); +create table t1 (id integer auto_increment unique,imagem LONGBLOB not null default ''); insert into t1 (id) values (1); select charset(load_file('../../std_data/words.dat')), @@ -523,10 +523,10 @@ select if(imagem is null, "ERROR", "OK"),length(imagem) from t1 where id = 1; if(imagem is null, "ERROR", "OK") length(imagem) OK 581 drop table t1; -create table t1 select load_file('../../std_data/words.dat'); +create table t1 select load_file('../../std_data/words.dat') l; show full fields from t1; Field Type Collation Null Key Default Extra Privileges Comment -load_file('../../std_data/words.dat') longblob NULL YES NULL select,insert,update,references +l longblob NULL YES NULL # drop table t1; create table t1 (id integer primary key auto_increment, txt text not null, unique index txt_index (txt (20))); insert into t1 (txt) values ('Chevy'), ('Chevy '); diff --git a/mysql-test/r/type_blob.result.es b/mysql-test/r/type_blob.result.es deleted file mode 100644 index a510eee8f38..00000000000 --- a/mysql-test/r/type_blob.result.es +++ /dev/null @@ -1,692 +0,0 @@ -drop table if exists t1,t2,t3,t4,t5,t6,t7; -CREATE TABLE t1 (a blob, b text, c blob(250), d text(70000), e text(70000000)); -show columns from t1; -Field Type Null Key Default Extra -a blob YES NULL -b text YES NULL -c blob YES NULL -d mediumtext YES NULL -e longtext YES NULL -CREATE TABLE t2 (a char(257), b varbinary(70000), c varchar(70000000)); -Warnings: -Warning 1246 Converting column 'a' from CHAR to TEXT -Warning 1246 Converting column 'b' from CHAR to BLOB -Warning 1246 Converting column 'c' from CHAR to TEXT -show columns from t2; -Field Type Null Key Default Extra -a text YES NULL -b mediumblob YES NULL -c longtext YES NULL -create table t3 (a long, b long byte); -show create TABLE t3; -Table Create Table -t3 CREATE TABLE `t3` ( - `a` mediumtext, - `b` mediumblob -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -drop table t1,t2,t3 -#; -CREATE TABLE t1 (a char(257) default "hello"); -ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB instead -CREATE TABLE t2 (a blob default "hello"); -ERROR 42000: BLOB/TEXT column 'a' can't have a default value -drop table if exists t1,t2; -create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr)); -insert into t1 values (null,"a","A"); -insert into t1 values (null,"bbb","BBB"); -insert into t1 values (null,"ccc","CCC"); -select last_insert_id(); -last_insert_id() -3 -select * from t1,t1 as t2; -nr b str nr b str -1 a A 1 a A -2 bbb BBB 1 a A -3 ccc CCC 1 a A -1 a A 2 bbb BBB -2 bbb BBB 2 bbb BBB -3 ccc CCC 2 bbb BBB -1 a A 3 ccc CCC -2 bbb BBB 3 ccc CCC -3 ccc CCC 3 ccc CCC -drop table t1; -create table t1 (a text); -insert into t1 values ('where'); -update t1 set a='Where'; -select * from t1; -a -Where -drop table t1; -create table t1 (t text,c char(10),b blob, d binary(10)); -insert into t1 values (NULL,NULL,NULL,NULL); -insert into t1 values ("","","",""); -insert into t1 values ("hello","hello","hello","hello"); -insert into t1 values ("HELLO","HELLO","HELLO","HELLO"); -insert into t1 values ("HELLO MY","HELLO MY","HELLO MY","HELLO MY"); -insert into t1 values ("a","a","a","a"); -insert into t1 values (1,1,1,1); -insert into t1 values (NULL,NULL,NULL,NULL); -update t1 set c="",b=null where c="1"; -lock tables t1 READ; -show full fields from t1; -Field Type Collation Null Key Default Extra Privileges Comment -t text latin1_swedish_ci YES NULL -c varchar(10) latin1_swedish_ci YES NULL -b blob NULL YES NULL -d varbinary(10) NULL YES NULL -lock tables t1 WRITE; -show full fields from t1; -Field Type Collation Null Key Default Extra Privileges Comment -t text latin1_swedish_ci YES NULL -c varchar(10) latin1_swedish_ci YES NULL -b blob NULL YES NULL -d varbinary(10) NULL YES NULL -unlock tables; -select t from t1 where t like "hello"; -t -hello -HELLO -select c from t1 where c like "hello"; -c -hello -HELLO -select b from t1 where b like "hello"; -b -hello -select d from t1 where d like "hello"; -d -hello -select c from t1 having c like "hello"; -c -hello -HELLO -select d from t1 having d like "hello"; -d -hello -select t from t1 where t like "%HELLO%"; -t -hello -HELLO -HELLO MY -select c from t1 where c like "%HELLO%"; -c -hello -HELLO -HELLO MY -select b from t1 where b like "%HELLO%"; -b -HELLO -HELLO MY -select d from t1 where d like "%HELLO%"; -d -HELLO -HELLO MY -select c from t1 having c like "%HELLO%"; -c -hello -HELLO -HELLO MY -select d from t1 having d like "%HELLO%"; -d -HELLO -HELLO MY -select d from t1 having d like "%HE%LLO%"; -d -HELLO -HELLO MY -select t from t1 order by t; -t -NULL -NULL - -1 -a -hello -HELLO -HELLO MY -select c from t1 order by c; -c -NULL -NULL - - -a -hello -HELLO -HELLO MY -select b from t1 order by b; -b -NULL -NULL -NULL - -HELLO -HELLO MY -a -hello -select d from t1 order by d; -d -NULL -NULL - -1 -HELLO -HELLO MY -a -hello -select distinct t from t1; -t -NULL - -hello -HELLO MY -a -1 -select distinct b from t1; -b -NULL - -hello -HELLO -HELLO MY -a -select distinct t from t1 order by t; -t -NULL - -1 -a -hello -HELLO MY -select distinct b from t1 order by b; -b -NULL - -HELLO -HELLO MY -a -hello -select t from t1 group by t; -t -NULL - -1 -a -hello -HELLO MY -select b from t1 group by b; -b -NULL - -HELLO -HELLO MY -a -hello -set option sql_big_tables=1; -select distinct t from t1; -t -NULL - -hello -HELLO MY -a -1 -select distinct b from t1; -b -NULL - -hello -HELLO -HELLO MY -a -select distinct t from t1 order by t; -t -NULL - -1 -a -hello -HELLO MY -select distinct b from t1 order by b; -b -NULL - -HELLO -HELLO MY -a -hello -select distinct c from t1; -c -NULL - -hello -HELLO MY -a -select distinct d from t1; -d -NULL - -hello -HELLO -HELLO MY -a -1 -select distinct c from t1 order by c; -c -NULL - -a -hello -HELLO MY -select distinct d from t1 order by d; -d -NULL - -1 -HELLO -HELLO MY -a -hello -select c from t1 group by c; -c -NULL - -a -hello -HELLO MY -select d from t1 group by d; -d -NULL - -1 -HELLO -HELLO MY -a -hello -set option sql_big_tables=0; -select distinct * from t1; -t c b d -NULL NULL NULL NULL - -hello hello hello hello -HELLO HELLO HELLO HELLO -HELLO MY HELLO MY HELLO MY HELLO MY -a a a a -1 NULL 1 -select t,count(*) from t1 group by t; -t count(*) -NULL 2 - 1 -1 1 -a 1 -hello 2 -HELLO MY 1 -select b,count(*) from t1 group by b; -b count(*) -NULL 3 - 1 -HELLO 1 -HELLO MY 1 -a 1 -hello 1 -select c,count(*) from t1 group by c; -c count(*) -NULL 2 - 2 -a 1 -hello 2 -HELLO MY 1 -select d,count(*) from t1 group by d; -d count(*) -NULL 2 - 1 -1 1 -HELLO 1 -HELLO MY 1 -a 1 -hello 1 -drop table t1; -create table t1 (a text, unique (a(2100))); -ERROR 42000: Specified key was too long; max key length is 1000 bytes -create table t1 (a text, key (a(2100))); -Warnings: -Warning 1071 Specified key was too long; max key length is 1000 bytes -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` text, - KEY `a` (`a`(1000)) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -drop table t1; -CREATE TABLE t1 ( -t1_id bigint(21) NOT NULL auto_increment, -_field_72 varchar(128) DEFAULT '' NOT NULL, -_field_95 varchar(32), -_field_115 tinyint(4) DEFAULT '0' NOT NULL, -_field_122 tinyint(4) DEFAULT '0' NOT NULL, -_field_126 tinyint(4), -_field_134 tinyint(4), -PRIMARY KEY (t1_id), -UNIQUE _field_72 (_field_72), -KEY _field_115 (_field_115), -KEY _field_122 (_field_122) -); -INSERT INTO t1 VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3',0,1,NULL,NULL); -INSERT INTO t1 VALUES (2,'hroberts','7415275a8c95952901e42b13a6b78566',0,1,NULL,NULL); -INSERT INTO t1 VALUES (3,'guest','d41d8cd98f00b204e9800998ecf8427e',1,0,NULL,NULL); -CREATE TABLE t2 ( -seq_0_id bigint(21) DEFAULT '0' NOT NULL, -seq_1_id bigint(21) DEFAULT '0' NOT NULL, -PRIMARY KEY (seq_0_id,seq_1_id) -); -INSERT INTO t2 VALUES (1,1); -INSERT INTO t2 VALUES (2,1); -INSERT INTO t2 VALUES (2,2); -CREATE TABLE t3 ( -t3_id bigint(21) NOT NULL auto_increment, -_field_131 varchar(128), -_field_133 tinyint(4) DEFAULT '0' NOT NULL, -_field_135 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, -_field_137 tinyint(4), -_field_139 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, -_field_140 blob, -_field_142 tinyint(4) DEFAULT '0' NOT NULL, -_field_145 tinyint(4) DEFAULT '0' NOT NULL, -_field_148 tinyint(4) DEFAULT '0' NOT NULL, -PRIMARY KEY (t3_id), -KEY _field_133 (_field_133), -KEY _field_135 (_field_135), -KEY _field_139 (_field_139), -KEY _field_142 (_field_142), -KEY _field_145 (_field_145), -KEY _field_148 (_field_148) -); -INSERT INTO t3 VALUES (1,'test job 1',0,'0000-00-00 00:00:00',0,'1999-02-25 22:43:32','test\r\njob\r\n1',0,0,0); -INSERT INTO t3 VALUES (2,'test job 2',0,'0000-00-00 00:00:00',0,'1999-02-26 21:08:04','',0,0,0); -CREATE TABLE t4 ( -seq_0_id bigint(21) DEFAULT '0' NOT NULL, -seq_1_id bigint(21) DEFAULT '0' NOT NULL, -PRIMARY KEY (seq_0_id,seq_1_id) -); -INSERT INTO t4 VALUES (1,1); -INSERT INTO t4 VALUES (2,1); -CREATE TABLE t5 ( -t5_id bigint(21) NOT NULL auto_increment, -_field_149 tinyint(4), -_field_156 varchar(128) DEFAULT '' NOT NULL, -_field_157 varchar(128) DEFAULT '' NOT NULL, -_field_158 varchar(128) DEFAULT '' NOT NULL, -_field_159 varchar(128) DEFAULT '' NOT NULL, -_field_160 varchar(128) DEFAULT '' NOT NULL, -_field_161 varchar(128) DEFAULT '' NOT NULL, -PRIMARY KEY (t5_id), -KEY _field_156 (_field_156), -KEY _field_157 (_field_157), -KEY _field_158 (_field_158), -KEY _field_159 (_field_159), -KEY _field_160 (_field_160), -KEY _field_161 (_field_161) -); -INSERT INTO t5 VALUES (1,0,'tomato','','','','',''); -INSERT INTO t5 VALUES (2,0,'cilantro','','','','',''); -CREATE TABLE t6 ( -seq_0_id bigint(21) DEFAULT '0' NOT NULL, -seq_1_id bigint(21) DEFAULT '0' NOT NULL, -PRIMARY KEY (seq_0_id,seq_1_id) -); -INSERT INTO t6 VALUES (1,1); -INSERT INTO t6 VALUES (1,2); -INSERT INTO t6 VALUES (2,2); -CREATE TABLE t7 ( -t7_id bigint(21) NOT NULL auto_increment, -_field_143 tinyint(4), -_field_165 varchar(32), -_field_166 smallint(6) DEFAULT '0' NOT NULL, -PRIMARY KEY (t7_id), -KEY _field_166 (_field_166) -); -INSERT INTO t7 VALUES (1,0,'High',1); -INSERT INTO t7 VALUES (2,0,'Medium',2); -INSERT INTO t7 VALUES (3,0,'Low',3); -select replace(t3._field_140, "\r","^M"),t3_id,min(t3._field_131), min(t3._field_135), min(t3._field_139), min(t3._field_137), min(link_alias_142._field_165), min(link_alias_133._field_72), min(t3._field_145), min(link_alias_148._field_156), replace(min(t3._field_140), "\r","^M"),t3.t3_id from t3 left join t4 on t4.seq_0_id = t3.t3_id left join t7 link_alias_142 on t4.seq_1_id = link_alias_142.t7_id left join t6 on t6.seq_0_id = t3.t3_id left join t1 link_alias_133 on t6.seq_1_id = link_alias_133.t1_id left join t2 on t2.seq_0_id = t3.t3_id left join t5 link_alias_148 on t2.seq_1_id = link_alias_148.t5_id where t3.t3_id in (1) group by t3.t3_id order by link_alias_142._field_166, _field_139, link_alias_133._field_72, _field_135, link_alias_148._field_156; -replace(t3._field_140, "\r","^M") t3_id min(t3._field_131) min(t3._field_135) min(t3._field_139) min(t3._field_137) min(link_alias_142._field_165) min(link_alias_133._field_72) min(t3._field_145) min(link_alias_148._field_156) replace(min(t3._field_140), "\r","^M") t3_id -test^M -job^M -1 1 test job 1 0000-00-00 00:00:00 1999-02-25 22:43:32 0 High admin 0 tomato test^M -job^M -1 1 -drop table t1,t2,t3,t4,t5,t6,t7; -create table t1 (a blob); -insert into t1 values ("empty"),(""); -select a,reverse(a) from t1; -a reverse(a) -empty ytpme - -drop table t1; -create table t1 (a blob, key (a(10))); -insert into t1 values ("bye"),("hello"),("hello"),("hello word"); -select * from t1 where a like "hello%"; -a -hello -hello -hello word -drop table t1; -CREATE TABLE t1 ( -f1 int(11) DEFAULT '0' NOT NULL, -f2 varchar(16) DEFAULT '' NOT NULL, -f5 text, -KEY index_name (f1,f2,f5(16)) -); -INSERT INTO t1 VALUES (0,'traktor','1111111111111'); -INSERT INTO t1 VALUES (1,'traktor','1111111111111111111111111'); -select count(*) from t1 where f2='traktor'; -count(*) -2 -drop table t1; -create table t1 (foobar tinyblob not null, boggle smallint not null, key (foobar(32), boggle)); -insert into t1 values ('fish', 10),('bear', 20); -select foobar, boggle from t1 where foobar = 'fish'; -foobar boggle -fish 10 -select foobar, boggle from t1 where foobar = 'fish' and boggle = 10; -foobar boggle -fish 10 -drop table t1; -create table t1 (id integer auto_increment unique,imagem LONGBLOB not null); -insert into t1 (id) values (1); -select -charset(load_file('../../std_data/words.dat')), -collation(load_file('../../std_data/words.dat')), -coercibility(load_file('../../std_data/words.dat')); -charset(load_file('../../std_data/words.dat')) collation(load_file('../../std_data/words.dat')) coercibility(load_file('../../std_data/words.dat')) -NULL NULL 3 -explain extended select -charset(load_file('../../std_data/words.dat')), -collation(load_file('../../std_data/words.dat')), -coercibility(load_file('../../std_data/words.dat')); -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used -Warnings: -Note 1003 select sql_no_cache charset(load_file(_latin1'../../std_data/words.dat')) AS `charset(load_file('../../std_data/words.dat'))`,collation(load_file(_latin1'../../std_data/words.dat')) AS `collation(load_file('../../std_data/words.dat'))`,coercibility(load_file(_latin1'../../std_data/words.dat')) AS `coercibility(load_file('../../std_data/words.dat'))` -update t1 set imagem=load_file('../../std_data/words.dat') where id=1; -Warnings: -Warning 1263 Data truncated; NULL supplied to NOT NULL column 'imagem' at row 1 -select if(imagem is null, "ERROR", "OK"),length(imagem) from t1 where id = 1; -if(imagem is null, "ERROR", "OK") length(imagem) -OK 0 -drop table t1; -create table t1 select load_file('../../std_data/words.dat'); -show full fields from t1; -Field Type Collation Null Key Default Extra Privileges Comment -load_file('../../std_data/words.dat') longblob NULL YES NULL -drop table t1; -create table t1 (id integer primary key auto_increment, txt text not null, unique index txt_index (txt (20))); -insert into t1 (txt) values ('Chevy'), ('Chevy '); -select * from t1 where txt='Chevy'; -id txt -1 Chevy -2 Chevy -select * from t1 where txt='Chevy '; -id txt -1 Chevy -2 Chevy -select * from t1 where txt='Chevy ' or txt='Chevy'; -id txt -1 Chevy -2 Chevy -select * from t1 where txt='Chevy' or txt='Chevy '; -id txt -1 Chevy -2 Chevy -select * from t1 where id='1' or id='2'; -id txt -1 Chevy -2 Chevy -insert into t1 (txt) values('Ford'); -select * from t1 where txt='Chevy' or txt='Chevy ' or txt='Ford'; -id txt -1 Chevy -2 Chevy -3 Ford -select * from t1 where txt='Chevy' or txt='Chevy '; -id txt -1 Chevy -2 Chevy -select * from t1 where txt='Chevy' or txt='Chevy ' or txt=' Chevy'; -id txt -1 Chevy -2 Chevy -select * from t1 where txt in ('Chevy ','Chevy'); -id txt -1 Chevy -2 Chevy -select * from t1 where txt in ('Chevy'); -id txt -1 Chevy -2 Chevy -select * from t1 where txt between 'Chevy' and 'Chevy'; -id txt -1 Chevy -2 Chevy -select * from t1 where txt between 'Chevy' and 'Chevy' or txt='Chevy '; -id txt -1 Chevy -2 Chevy -select * from t1 where txt between 'Chevy' and 'Chevy '; -id txt -1 Chevy -2 Chevy -select * from t1 where txt < 'Chevy '; -id txt -select * from t1 where txt <= 'Chevy'; -id txt -1 Chevy -2 Chevy -select * from t1 where txt > 'Chevy'; -id txt -3 Ford -select * from t1 where txt >= 'Chevy'; -id txt -1 Chevy -2 Chevy -3 Ford -drop table t1; -create table t1 (id integer primary key auto_increment, txt text, unique index txt_index (txt (20))); -insert into t1 (txt) values ('Chevy'), ('Chevy '), (NULL); -select * from t1 where txt='Chevy' or txt is NULL; -id txt -3 NULL -1 Chevy -2 Chevy -explain select * from t1 where txt='Chevy' or txt is NULL; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range txt_index txt_index 23 NULL 2 Using where -select * from t1 where txt='Chevy '; -id txt -1 Chevy -2 Chevy -select * from t1 where txt='Chevy ' or txt='Chevy'; -id txt -1 Chevy -2 Chevy -select * from t1 where txt='Chevy' or txt='Chevy '; -id txt -1 Chevy -2 Chevy -select * from t1 where id='1' or id='2'; -id txt -1 Chevy -2 Chevy -insert into t1 (txt) values('Ford'); -select * from t1 where txt='Chevy' or txt='Chevy ' or txt='Ford'; -id txt -1 Chevy -2 Chevy -4 Ford -select * from t1 where txt='Chevy' or txt='Chevy '; -id txt -1 Chevy -2 Chevy -select * from t1 where txt='Chevy' or txt='Chevy ' or txt=' Chevy'; -id txt -1 Chevy -2 Chevy -select * from t1 where txt in ('Chevy ','Chevy'); -id txt -1 Chevy -2 Chevy -select * from t1 where txt in ('Chevy'); -id txt -1 Chevy -2 Chevy -select * from t1 where txt between 'Chevy' and 'Chevy'; -id txt -1 Chevy -2 Chevy -select * from t1 where txt between 'Chevy' and 'Chevy' or txt='Chevy '; -id txt -1 Chevy -2 Chevy -select * from t1 where txt between 'Chevy' and 'Chevy '; -id txt -1 Chevy -2 Chevy -select * from t1 where txt < 'Chevy '; -id txt -select * from t1 where txt < 'Chevy ' or txt is NULL; -id txt -3 NULL -select * from t1 where txt <= 'Chevy'; -id txt -1 Chevy -2 Chevy -select * from t1 where txt > 'Chevy'; -id txt -4 Ford -select * from t1 where txt >= 'Chevy'; -id txt -1 Chevy -2 Chevy -4 Ford -alter table t1 modify column txt blob; -explain select * from t1 where txt='Chevy' or txt is NULL; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 2 Using where -select * from t1 where txt='Chevy' or txt is NULL; -id txt -1 Chevy -3 NULL -explain select * from t1 where txt='Chevy' or txt is NULL order by txt; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 2 Using where; Using filesort -select * from t1 where txt='Chevy' or txt is NULL order by txt; -id txt -3 NULL -1 Chevy -drop table t1; -CREATE TABLE t1 ( i int(11) NOT NULL default '0', c text NOT NULL, d varchar(1) NOT NULL DEFAULT ' ', PRIMARY KEY (i), KEY (c(1),d)); -INSERT t1 (i, c) VALUES (1,''),(2,''),(3,'asdfh'),(4,''); -select max(i) from t1 where c = ''; -max(i) -4 -drop table t1; diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index 6a0c0090e79..a01f8ee08a1 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -748,3 +748,19 @@ HAVING a <> b; i a b 6 -51.40 0.00 drop table t1; +create table t1 (c1 varchar(100), c2 longtext); +insert into t1 set c1= 'non PS, 1.0 as constant', c2=1.0; +prepare stmt from "insert into t1 set c1='PS, 1.0 as constant ', c2=1.0"; +execute stmt; +set @a=1.0; +insert into t1 set c1='non PS, 1.0 in parameter', c2=@a; +prepare stmt from "insert into t1 set c1='PS, 1.0 in parameter ', c2=?"; +execute stmt using @a; +select * from t1; +c1 c2 +non PS, 1.0 as constant 1.0 +PS, 1.0 as constant 1.0 +non PS, 1.0 in parameter 1.0 +PS, 1.0 in parameter 1.0 +deallocate prepare stmt; +drop table t1; diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index eec9701d054..3cdf35f5032 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -20,8 +20,8 @@ SELECT 2147483647E+02,21474836.47E+06; create table t1 (f1 float(24),f2 float(52)); show full columns from t1; Field Type Collation Null Key Default Extra Privileges Comment -f1 float NULL YES NULL select,insert,update,references -f2 double NULL YES NULL select,insert,update,references +f1 float NULL YES NULL # +f2 double NULL YES NULL # insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150); Warnings: Warning 1264 Out of range value adjusted for column 'f1' at row 7 @@ -106,18 +106,18 @@ drop table t1; create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(5,6)); show full columns from t1; Field Type Collation Null Key Default Extra Privileges Comment -f float NULL YES NULL select,insert,update,references -f2 float NULL YES NULL select,insert,update,references -f3 float(6,2) NULL YES NULL select,insert,update,references -d double NULL YES NULL select,insert,update,references -d2 double NULL YES NULL select,insert,update,references -d3 double(10,3) NULL YES NULL select,insert,update,references -de decimal(10,0) NULL YES NULL select,insert,update,references -de2 decimal(6,0) NULL YES NULL select,insert,update,references -de3 decimal(5,2) NULL YES NULL select,insert,update,references -n decimal(10,0) NULL YES NULL select,insert,update,references -n2 decimal(8,0) NULL YES NULL select,insert,update,references -n3 decimal(7,6) NULL YES NULL select,insert,update,references +f float NULL YES NULL # +f2 float NULL YES NULL # +f3 float(6,2) NULL YES NULL # +d double NULL YES NULL # +d2 double NULL YES NULL # +d3 double(10,3) NULL YES NULL # +de decimal(10,0) NULL YES NULL # +de2 decimal(6,0) NULL YES NULL # +de3 decimal(5,2) NULL YES NULL # +n decimal(10,0) NULL YES NULL # +n2 decimal(8,0) NULL YES NULL # +n3 decimal(7,6) NULL YES NULL # drop table t1; create table t1 (a decimal(7,3) not null, key (a)); insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1"); diff --git a/mysql-test/r/type_float.result.es b/mysql-test/r/type_float.result.es deleted file mode 100644 index f2639ef545a..00000000000 --- a/mysql-test/r/type_float.result.es +++ /dev/null @@ -1,208 +0,0 @@ -drop table if exists t1,t2; -SELECT 10,10.0,10.,.1e+2,100.0e-1; -10 10.0 10. .1e+2 100.0e-1 -10 10.0 10 10 10 -SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000; -6e-05 -6e-05 --6e-05 -6e-05+1.000000 -6e-05 -6e-05 6e-05 0.99994 -SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1; -1e1 1.e1 1.0e1 1e+1 1.e+1 1.0e+1 1e-1 1.e-1 1.0e-1 -10 10 10 10 10 10 0.1 0.1 0.1 -SELECT 0.001e+1,0.001e-1, -0.001e+01,-0.001e-01; -0.001e+1 0.001e-1 -0.001e+01 -0.001e-01 -0.01 0.0001 -0.01 -0.0001 -create table t1 (f1 float(24),f2 float(52)); -show full columns from t1; -Field Type Collation Null Key Default Extra Privileges Comment -f1 float NULL YES NULL -f2 double NULL YES NULL -insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150); -Warnings: -Warning 1264 Out of range value adjusted for column 'f1' at row 7 -Warning 1264 Out of range value adjusted for column 'f1' at row 8 -insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150); -select * from t1; -f1 f2 -10 10 -100000 100000 -1.23457e+9 1234567890 -1e+10 10000000000 -1e+15 1e+15 -1e+20 1e+20 -3.40282e+38 1e+50 -3.40282e+38 1e+150 --10 -10 -1e-5 1e-5 -1e-10 1e-10 -1e-15 1e-15 -1e-20 1e-20 -0 1e-50 -0 1e-150 -drop table t1; -create table t1 (datum double); -insert into t1 values (0.5),(1.0),(1.5),(2.0),(2.5); -select * from t1; -datum -0.5 -1 -1.5 -2 -2.5 -select * from t1 where datum < 1.5; -datum -0.5 -1 -select * from t1 where datum > 1.5; -datum -2 -2.5 -select * from t1 where datum = 1.5; -datum -1.5 -drop table t1; -create table t1 (a decimal(7,3) not null, key (a)); -insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1"); -select a from t1 order by a; -a --0.010 --0.002 --0.000 -0.000 -1.000 -select min(a) from t1; -min(a) --0.010 -drop table t1; -create table t1 (c1 double, c2 varchar(20)); -insert t1 values (121,"16"); -select c1 + c1 * (c2 / 100) as col from t1; -col -140.36 -create table t2 select c1 + c1 * (c2 / 100) as col1, round(c1, 5) as col2, round(c1, 35) as col3, sqrt(c1*1e-15) col4 from t1; -select * from t2; -col1 col2 col3 col4 -140.36 121.00000 121 3.47850542618522e-07 -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `col1` double default NULL, - `col2` double(22,5) default NULL, - `col3` double default NULL, - `col4` double default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -drop table t1,t2; -create table t1 (a float); -insert into t1 values (1); -select max(a),min(a),avg(a) from t1; -max(a) min(a) avg(a) -1 1 1 -drop table t1; -create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(5,6)); -show full columns from t1; -Field Type Collation Null Key Default Extra Privileges Comment -f float NULL YES NULL -f2 float NULL YES NULL -f3 float(6,2) NULL YES NULL -d double NULL YES NULL -d2 double NULL YES NULL -d3 double(10,3) NULL YES NULL -de decimal(10,0) NULL YES NULL -de2 decimal(6,0) NULL YES NULL -de3 decimal(5,2) NULL YES NULL -n decimal(10,0) NULL YES NULL -n2 decimal(8,0) NULL YES NULL -n3 decimal(7,6) NULL YES NULL -drop table t1; -create table t1 (a decimal(7,3) not null, key (a)); -insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1"); -select a from t1 order by a; -a --0.010 --0.002 --0.000 -0.000 -1.000 -select min(a) from t1; -min(a) --0.010 -drop table t1; -create table t1 (a float(200,100), b double(200,100)); -insert t1 values (1.0, 2.0); -select * from t1; -a b -1.000000000000000000000000000000 2.000000000000000000000000000000 -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` float(200,30) default NULL, - `b` double(200,30) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -drop table t1; -create table t1 (c20 char); -insert into t1 values (5000.0); -Warnings: -Warning 1265 Data truncated for column 'c20' at row 1 -drop table t1; -create table t1 (f float(54)); -ERROR 42000: Incorrect column specifier for column 'f' -drop table if exists t1; -create table t1 (d1 double, d2 double unsigned); -insert into t1 set d1 = -1.0; -update t1 set d2 = d1; -Warnings: -Warning 1264 Out of range value adjusted for column 'd2' at row 1 -select * from t1; -d1 d2 --1 0 -drop table t1; -create table t1 (f float(4,3)); -insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11"); -Warnings: -Warning 1264 Out of range value adjusted for column 'f' at row 1 -Warning 1264 Out of range value adjusted for column 'f' at row 2 -Warning 1264 Out of range value adjusted for column 'f' at row 3 -Warning 1264 Out of range value adjusted for column 'f' at row 4 -Warning 1264 Out of range value adjusted for column 'f' at row 5 -Warning 1264 Out of range value adjusted for column 'f' at row 6 -select * from t1; -f --9.999 --9.999 --9.999 -9.999 -9.999 -9.999 -drop table if exists t1; -create table t1 (f double(4,3)); -insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11"); -Warnings: -Warning 1264 Out of range value adjusted for column 'f' at row 1 -Warning 1264 Out of range value adjusted for column 'f' at row 2 -Warning 1264 Out of range value adjusted for column 'f' at row 3 -Warning 1264 Out of range value adjusted for column 'f' at row 4 -Warning 1264 Out of range value adjusted for column 'f' at row 5 -Warning 1264 Out of range value adjusted for column 'f' at row 6 -select * from t1; -f --9.999 --9.999 --9.999 -9.999 -9.999 -9.999 -drop table if exists t1; -create table t1 (c char(20)); -insert into t1 values (5e-28); -select * from t1; -c -5e-28 -drop table t1; -create table t1 (c char(6)); -insert into t1 values (2e5),(2e6),(2e-4),(2e-5); -select * from t1; -c -200000 -2e+06 -0.0002 -2e-05 -drop table t1; diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result index e553d9d86f2..3b07464c8f4 100644 --- a/mysql-test/r/type_ranges.result +++ b/mysql-test/r/type_ranges.result @@ -21,10 +21,10 @@ time_field time, date_time datetime, blob_col blob, tinyblob_col tinyblob, -mediumblob_col mediumblob not null, -longblob_col longblob not null, -options enum('one','two','tree') not null, -flags set('one','two','tree') not null, +mediumblob_col mediumblob not null default '', +longblob_col longblob not null default '', +options enum('one','two','tree') not null , +flags set('one','two','tree') not null default '', PRIMARY KEY (auto), KEY (utiny), KEY (tiny), @@ -40,30 +40,30 @@ KEY (options,flags) ); show full fields from t1; Field Type Collation Null Key Default Extra Privileges Comment -auto int(5) unsigned NULL NO PRI NULL auto_increment select,insert,update,references -string char(10) latin1_swedish_ci YES hello select,insert,update,references -tiny tinyint(4) NULL NO MUL 0 select,insert,update,references -short smallint(6) NULL NO MUL 1 select,insert,update,references -medium mediumint(8) NULL NO MUL 0 select,insert,update,references -long_int int(11) NULL NO 0 select,insert,update,references -longlong bigint(13) NULL NO MUL 0 select,insert,update,references -real_float float(13,1) NULL NO MUL 0.0 select,insert,update,references -real_double double(16,4) NULL YES NULL select,insert,update,references -utiny tinyint(3) unsigned NULL NO MUL 0 select,insert,update,references -ushort smallint(5) unsigned zerofill NULL NO MUL 00000 select,insert,update,references -umedium mediumint(8) unsigned NULL NO MUL 0 select,insert,update,references -ulong int(11) unsigned NULL NO MUL 0 select,insert,update,references -ulonglong bigint(13) unsigned NULL NO MUL 0 select,insert,update,references -time_stamp timestamp NULL YES CURRENT_TIMESTAMP select,insert,update,references -date_field date NULL YES NULL select,insert,update,references -time_field time NULL YES NULL select,insert,update,references -date_time datetime NULL YES NULL select,insert,update,references -blob_col blob NULL YES NULL select,insert,update,references -tinyblob_col tinyblob NULL YES NULL select,insert,update,references -mediumblob_col mediumblob NULL NO select,insert,update,references -longblob_col longblob NULL NO select,insert,update,references -options enum('one','two','tree') latin1_swedish_ci NO MUL one select,insert,update,references -flags set('one','two','tree') latin1_swedish_ci NO select,insert,update,references +auto int(5) unsigned NULL NO PRI NULL auto_increment # +string char(10) latin1_swedish_ci YES hello # +tiny tinyint(4) NULL NO MUL 0 # +short smallint(6) NULL NO MUL 1 # +medium mediumint(8) NULL NO MUL 0 # +long_int int(11) NULL NO 0 # +longlong bigint(13) NULL NO MUL 0 # +real_float float(13,1) NULL NO MUL 0.0 # +real_double double(16,4) NULL YES NULL # +utiny tinyint(3) unsigned NULL NO MUL 0 # +ushort smallint(5) unsigned zerofill NULL NO MUL 00000 # +umedium mediumint(8) unsigned NULL NO MUL 0 # +ulong int(11) unsigned NULL NO MUL 0 # +ulonglong bigint(13) unsigned NULL NO MUL 0 # +time_stamp timestamp NULL YES CURRENT_TIMESTAMP # +date_field date NULL YES NULL # +time_field time NULL YES NULL # +date_time datetime NULL YES NULL # +blob_col blob NULL YES NULL # +tinyblob_col tinyblob NULL YES NULL # +mediumblob_col mediumblob NULL NO # +longblob_col longblob NULL NO # +options enum('one','two','tree') latin1_swedish_ci NO MUL one # +flags set('one','two','tree') latin1_swedish_ci NO # show keys from t1; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment t1 0 PRIMARY 1 auto A 0 NULL NULL BTREE @@ -133,7 +133,7 @@ ALTER TABLE t1 add new_field char(10) default "new" not null, change blob_col new_blob_col varchar(20), change date_field date_field char(10), -alter column string set default "new default", +alter column string set default "newdefault", alter short drop default, DROP INDEX utiny, DROP INDEX ushort, @@ -210,56 +210,56 @@ Warning 1265 Data truncated for column 'options' at row 6 update t2 set string="changed" where auto=16; show full columns from t1; Field Type Collation Null Key Default Extra Privileges Comment -auto int(5) unsigned NULL NO MUL NULL auto_increment select,insert,update,references -string char(10) latin1_swedish_ci YES new defaul select,insert,update,references -tiny tinyint(4) NULL NO MUL 0 select,insert,update,references -short smallint(6) NULL NO MUL 0 select,insert,update,references -medium mediumint(8) NULL NO MUL 0 select,insert,update,references -long_int int(11) NULL NO 0 select,insert,update,references -longlong bigint(13) NULL NO MUL 0 select,insert,update,references -real_float float(13,1) NULL NO MUL 0.0 select,insert,update,references -real_double double(16,4) NULL YES NULL select,insert,update,references -utiny tinyint(3) unsigned NULL NO 0 select,insert,update,references -ushort smallint(5) unsigned zerofill NULL NO 00000 select,insert,update,references -umedium mediumint(8) unsigned NULL NO MUL 0 select,insert,update,references -ulong int(11) unsigned NULL NO MUL 0 select,insert,update,references -ulonglong bigint(13) unsigned NULL NO MUL 0 select,insert,update,references -time_stamp timestamp NULL YES CURRENT_TIMESTAMP select,insert,update,references -date_field char(10) latin1_swedish_ci YES NULL select,insert,update,references -time_field time NULL YES NULL select,insert,update,references -date_time datetime NULL YES NULL select,insert,update,references -new_blob_col varchar(20) latin1_swedish_ci YES NULL select,insert,update,references -tinyblob_col tinyblob NULL YES NULL select,insert,update,references -mediumblob_col mediumblob NULL NO select,insert,update,references -options enum('one','two','tree') latin1_swedish_ci NO MUL one select,insert,update,references -flags set('one','two','tree') latin1_swedish_ci NO select,insert,update,references -new_field char(10) latin1_swedish_ci NO new select,insert,update,references +auto int(5) unsigned NULL NO MUL NULL auto_increment # +string char(10) latin1_swedish_ci YES newdefault # +tiny tinyint(4) NULL NO MUL 0 # +short smallint(6) NULL NO MUL 0 # +medium mediumint(8) NULL NO MUL 0 # +long_int int(11) NULL NO 0 # +longlong bigint(13) NULL NO MUL 0 # +real_float float(13,1) NULL NO MUL 0.0 # +real_double double(16,4) NULL YES NULL # +utiny tinyint(3) unsigned NULL NO 0 # +ushort smallint(5) unsigned zerofill NULL NO 00000 # +umedium mediumint(8) unsigned NULL NO MUL 0 # +ulong int(11) unsigned NULL NO MUL 0 # +ulonglong bigint(13) unsigned NULL NO MUL 0 # +time_stamp timestamp NULL YES CURRENT_TIMESTAMP # +date_field char(10) latin1_swedish_ci YES NULL # +time_field time NULL YES NULL # +date_time datetime NULL YES NULL # +new_blob_col varchar(20) latin1_swedish_ci YES NULL # +tinyblob_col tinyblob NULL YES NULL # +mediumblob_col mediumblob NULL NO # +options enum('one','two','tree') latin1_swedish_ci NO MUL one # +flags set('one','two','tree') latin1_swedish_ci NO # +new_field char(10) latin1_swedish_ci NO new # show full columns from t2; Field Type Collation Null Key Default Extra Privileges Comment -auto int(5) unsigned NULL NO 0 select,insert,update,references -string char(10) latin1_swedish_ci YES new defaul select,insert,update,references -tiny tinyint(4) NULL NO 0 select,insert,update,references -short smallint(6) NULL NO 0 select,insert,update,references -medium mediumint(8) NULL NO 0 select,insert,update,references -long_int int(11) NULL NO 0 select,insert,update,references -longlong bigint(13) NULL NO 0 select,insert,update,references -real_float float(13,1) NULL NO 0.0 select,insert,update,references -real_double double(16,4) NULL YES NULL select,insert,update,references -utiny tinyint(3) unsigned NULL NO 0 select,insert,update,references -ushort smallint(5) unsigned zerofill NULL NO 00000 select,insert,update,references -umedium mediumint(8) unsigned NULL NO 0 select,insert,update,references -ulong int(11) unsigned NULL NO 0 select,insert,update,references -ulonglong bigint(13) unsigned NULL NO 0 select,insert,update,references -time_stamp timestamp NULL YES 0000-00-00 00:00:00 select,insert,update,references -date_field char(10) latin1_swedish_ci YES NULL select,insert,update,references -time_field time NULL YES NULL select,insert,update,references -date_time datetime NULL YES NULL select,insert,update,references -new_blob_col varchar(20) latin1_swedish_ci YES NULL select,insert,update,references -tinyblob_col tinyblob NULL YES NULL select,insert,update,references -mediumblob_col mediumblob NULL NO select,insert,update,references -options enum('one','two','tree') latin1_swedish_ci NO one select,insert,update,references -flags set('one','two','tree') latin1_swedish_ci NO select,insert,update,references -new_field char(10) latin1_swedish_ci NO new select,insert,update,references +auto int(5) unsigned NULL NO 0 # +string char(10) latin1_swedish_ci YES newdefault # +tiny tinyint(4) NULL NO 0 # +short smallint(6) NULL NO 0 # +medium mediumint(8) NULL NO 0 # +long_int int(11) NULL NO 0 # +longlong bigint(13) NULL NO 0 # +real_float float(13,1) NULL NO 0.0 # +real_double double(16,4) NULL YES NULL # +utiny tinyint(3) unsigned NULL NO 0 # +ushort smallint(5) unsigned zerofill NULL NO 00000 # +umedium mediumint(8) unsigned NULL NO 0 # +ulong int(11) unsigned NULL NO 0 # +ulonglong bigint(13) unsigned NULL NO 0 # +time_stamp timestamp NULL YES 0000-00-00 00:00:00 # +date_field char(10) latin1_swedish_ci YES NULL # +time_field time NULL YES NULL # +date_time datetime NULL YES NULL # +new_blob_col varchar(20) latin1_swedish_ci YES NULL # +tinyblob_col tinyblob NULL YES NULL # +mediumblob_col mediumblob NULL NO # +options enum('one','two','tree') latin1_swedish_ci NO one # +flags set('one','two','tree') latin1_swedish_ci NO # +new_field char(10) latin1_swedish_ci NO new # select t1.auto,t2.auto from t1,t2 where t1.auto=t2.auto and ((t1.string<>t2.string and (t1.string is not null or t2.string is not null)) or (t1.tiny<>t2.tiny and (t1.tiny is not null or t2.tiny is not null)) or (t1.short<>t2.short and (t1.short is not null or t2.short is not null)) or (t1.medium<>t2.medium and (t1.medium is not null or t2.medium is not null)) or (t1.long_int<>t2.long_int and (t1.long_int is not null or t2.long_int is not null)) or (t1.longlong<>t2.longlong and (t1.longlong is not null or t2.longlong is not null)) or (t1.real_float<>t2.real_float and (t1.real_float is not null or t2.real_float is not null)) or (t1.real_double<>t2.real_double and (t1.real_double is not null or t2.real_double is not null)) or (t1.utiny<>t2.utiny and (t1.utiny is not null or t2.utiny is not null)) or (t1.ushort<>t2.ushort and (t1.ushort is not null or t2.ushort is not null)) or (t1.umedium<>t2.umedium and (t1.umedium is not null or t2.umedium is not null)) or (t1.ulong<>t2.ulong and (t1.ulong is not null or t2.ulong is not null)) or (t1.ulonglong<>t2.ulonglong and (t1.ulonglong is not null or t2.ulonglong is not null)) or (t1.time_stamp<>t2.time_stamp and (t1.time_stamp is not null or t2.time_stamp is not null)) or (t1.date_field<>t2.date_field and (t1.date_field is not null or t2.date_field is not null)) or (t1.time_field<>t2.time_field and (t1.time_field is not null or t2.time_field is not null)) or (t1.date_time<>t2.date_time and (t1.date_time is not null or t2.date_time is not null)) or (t1.new_blob_col<>t2.new_blob_col and (t1.new_blob_col is not null or t2.new_blob_col is not null)) or (t1.tinyblob_col<>t2.tinyblob_col and (t1.tinyblob_col is not null or t2.tinyblob_col is not null)) or (t1.mediumblob_col<>t2.mediumblob_col and (t1.mediumblob_col is not null or t2.mediumblob_col is not null)) or (t1.options<>t2.options and (t1.options is not null or t2.options is not null)) or (t1.flags<>t2.flags and (t1.flags is not null or t2.flags is not null)) or (t1.new_field<>t2.new_field and (t1.new_field is not null or t2.new_field is not null))); auto auto 16 16 @@ -270,15 +270,15 @@ drop table t2; create table t2 (primary key (auto)) select auto+1 as auto,1 as t1, 'a' as t2, repeat('a',256) as t3, binary repeat('b',256) as t4, repeat('a',4096) as t5, binary repeat('b',4096) as t6, '' as t7, binary '' as t8 from t1; show full columns from t2; Field Type Collation Null Key Default Extra Privileges Comment -auto int(6) unsigned NULL NO PRI 0 select,insert,update,references -t1 bigint(1) NULL NO 0 select,insert,update,references -t2 varchar(1) latin1_swedish_ci NO select,insert,update,references -t3 varchar(256) latin1_swedish_ci NO select,insert,update,references -t4 varbinary(256) NULL NO select,insert,update,references -t5 longtext latin1_swedish_ci NO select,insert,update,references -t6 longblob NULL NO select,insert,update,references -t7 char(0) latin1_swedish_ci NO select,insert,update,references -t8 binary(0) NULL NO select,insert,update,references +auto int(6) unsigned NULL NO PRI 0 # +t1 bigint(1) NULL NO 0 # +t2 varchar(1) latin1_swedish_ci NO # +t3 varchar(256) latin1_swedish_ci NO # +t4 varbinary(256) NULL NO # +t5 longtext latin1_swedish_ci NO # +t6 longblob NULL NO # +t7 char(0) latin1_swedish_ci NO # +t8 binary(0) NULL NO # select t1,t2,length(t3),length(t4),length(t5),length(t6),t7,t8 from t2; t1 t2 length(t3) length(t4) length(t5) length(t6) t7 t8 1 a 256 256 4096 4096 @@ -297,9 +297,9 @@ ERROR 42S21: Duplicate column name 'c' create table t3 select t1.c AS c1, t2.c AS c2,1 as "const" from t1, t2; show full columns from t3; Field Type Collation Null Key Default Extra Privileges Comment -c1 int(11) NULL YES NULL select,insert,update,references -c2 int(11) NULL YES NULL select,insert,update,references -const bigint(1) NULL NO 0 select,insert,update,references +c1 int(11) NULL YES NULL # +c2 int(11) NULL YES NULL # +const bigint(1) NULL NO 0 # drop table t1,t2,t3; create table t1 ( myfield INT NOT NULL, UNIQUE INDEX (myfield), unique (myfield), index(myfield)); drop table t1; diff --git a/mysql-test/r/type_ranges.result.es b/mysql-test/r/type_ranges.result.es deleted file mode 100644 index 5e2ea2aebbc..00000000000 --- a/mysql-test/r/type_ranges.result.es +++ /dev/null @@ -1,324 +0,0 @@ -drop table if exists t1,t2,t3; -SET SQL_WARNINGS=1; -CREATE TABLE t1 ( -auto int(5) unsigned NOT NULL auto_increment, -string char(10) default "hello", -tiny tinyint(4) DEFAULT '0' NOT NULL , -short smallint(6) DEFAULT '1' NOT NULL , -medium mediumint(8) DEFAULT '0' NOT NULL, -long_int int(11) DEFAULT '0' NOT NULL, -longlong bigint(13) DEFAULT '0' NOT NULL, -real_float float(13,1) DEFAULT 0.0 NOT NULL, -real_double double(16,4), -utiny tinyint(3) unsigned DEFAULT '0' NOT NULL, -ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL, -umedium mediumint(8) unsigned DEFAULT '0' NOT NULL, -ulong int(11) unsigned DEFAULT '0' NOT NULL, -ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL, -time_stamp timestamp, -date_field date, -time_field time, -date_time datetime, -blob_col blob, -tinyblob_col tinyblob, -mediumblob_col mediumblob not null, -longblob_col longblob not null, -options enum('one','two','tree') not null, -flags set('one','two','tree') not null, -PRIMARY KEY (auto), -KEY (utiny), -KEY (tiny), -KEY (short), -KEY any_name (medium), -KEY (longlong), -KEY (real_float), -KEY (ushort), -KEY (umedium), -KEY (ulong), -KEY (ulonglong,ulong), -KEY (options,flags) -); -show full fields from t1; -Field Type Collation Null Key Default Extra Privileges Comment -auto int(5) unsigned NULL NO PRI NULL auto_increment -string char(10) latin1_swedish_ci YES hello -tiny tinyint(4) NULL NO MUL 0 -short smallint(6) NULL NO MUL 1 -medium mediumint(8) NULL NO MUL 0 -long_int int(11) NULL NO 0 -longlong bigint(13) NULL NO MUL 0 -real_float float(13,1) NULL NO MUL 0.0 -real_double double(16,4) NULL YES NULL -utiny tinyint(3) unsigned NULL NO MUL 0 -ushort smallint(5) unsigned zerofill NULL NO MUL 00000 -umedium mediumint(8) unsigned NULL NO MUL 0 -ulong int(11) unsigned NULL NO MUL 0 -ulonglong bigint(13) unsigned NULL NO MUL 0 -time_stamp timestamp NULL YES CURRENT_TIMESTAMP -date_field date NULL YES NULL -time_field time NULL YES NULL -date_time datetime NULL YES NULL -blob_col blob NULL YES NULL -tinyblob_col tinyblob NULL YES NULL -mediumblob_col mediumblob NULL NO -longblob_col longblob NULL NO -options enum('one','two','tree') latin1_swedish_ci NO MUL one -flags set('one','two','tree') latin1_swedish_ci NO -show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 auto A 0 NULL NULL BTREE -t1 1 utiny 1 utiny A NULL NULL NULL BTREE -t1 1 tiny 1 tiny A NULL NULL NULL BTREE -t1 1 short 1 short A NULL NULL NULL BTREE -t1 1 any_name 1 medium A NULL NULL NULL BTREE -t1 1 longlong 1 longlong A NULL NULL NULL BTREE -t1 1 real_float 1 real_float A NULL NULL NULL BTREE -t1 1 ushort 1 ushort A NULL NULL NULL BTREE -t1 1 umedium 1 umedium A NULL NULL NULL BTREE -t1 1 ulong 1 ulong A NULL NULL NULL BTREE -t1 1 ulonglong 1 ulonglong A NULL NULL NULL BTREE -t1 1 ulonglong 2 ulong A NULL NULL NULL BTREE -t1 1 options 1 options A NULL NULL NULL BTREE -t1 1 options 2 flags A NULL NULL NULL BTREE -CREATE UNIQUE INDEX test on t1 ( auto ) ; -CREATE INDEX test2 on t1 ( ulonglong,ulong) ; -CREATE INDEX test3 on t1 ( medium ) ; -DROP INDEX test ON t1; -insert into t1 values (10, 1,1,1,1,1,1,1,1,1,1,1,1,1,NULL,0,0,0,1,1,1,1,'one','one'); -insert into t1 values (NULL,2,2,2,2,2,2,2,2,2,2,2,2,2,NULL,NULL,NULL,NULL,NULL,NULL,2,2,'two','two,one'); -insert into t1 values (0,1/3,3,3,3,3,3,3,3,3,3,3,3,3,NULL,'19970303','10:10:10','19970303101010','','','','3',3,3); -insert into t1 values (0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,NULL,19970807,080706,19970403090807,-1,-1,-1,'-1',-1,-1); -Warnings: -Warning 1264 Out of range value adjusted for column 'utiny' at row 1 -Warning 1264 Out of range value adjusted for column 'ushort' at row 1 -Warning 1264 Out of range value adjusted for column 'umedium' at row 1 -Warning 1264 Out of range value adjusted for column 'ulong' at row 1 -Warning 1265 Data truncated for column 'options' at row 1 -Warning 1265 Data truncated for column 'flags' at row 1 -insert into t1 values (0,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,NULL,0,0,0,-4294967295,-4294967295,-4294967295,'-4294967295',0,"one,two,tree"); -Warnings: -Warning 1265 Data truncated for column 'string' at row 1 -Warning 1264 Out of range value adjusted for column 'tiny' at row 1 -Warning 1264 Out of range value adjusted for column 'short' at row 1 -Warning 1264 Out of range value adjusted for column 'medium' at row 1 -Warning 1264 Out of range value adjusted for column 'long_int' at row 1 -Warning 1264 Out of range value adjusted for column 'utiny' at row 1 -Warning 1264 Out of range value adjusted for column 'ushort' at row 1 -Warning 1264 Out of range value adjusted for column 'umedium' at row 1 -Warning 1264 Out of range value adjusted for column 'ulong' at row 1 -Warning 1265 Data truncated for column 'options' at row 1 -insert into t1 values (0,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,NULL,0,0,0,4294967295,4294967295,4294967295,'4294967295',0,0); -Warnings: -Warning 1264 Out of range value adjusted for column 'tiny' at row 1 -Warning 1264 Out of range value adjusted for column 'short' at row 1 -Warning 1264 Out of range value adjusted for column 'medium' at row 1 -Warning 1264 Out of range value adjusted for column 'long_int' at row 1 -Warning 1264 Out of range value adjusted for column 'utiny' at row 1 -Warning 1264 Out of range value adjusted for column 'ushort' at row 1 -Warning 1264 Out of range value adjusted for column 'umedium' at row 1 -Warning 1265 Data truncated for column 'options' at row 1 -insert into t1 (tiny) values (1); -select auto,string,tiny,short,medium,long_int,longlong,real_float,real_double,utiny,ushort,umedium,ulong,ulonglong,mod(floor(time_stamp/1000000),1000000)-mod(curdate(),1000000),date_field,time_field,date_time,blob_col,tinyblob_col,mediumblob_col,longblob_col from t1; -auto string tiny short medium long_int longlong real_float real_double utiny ushort umedium ulong ulonglong mod(floor(time_stamp/1000000),1000000)-mod(curdate(),1000000) date_field time_field date_time blob_col tinyblob_col mediumblob_col longblob_col -10 1 1 1 1 1 1 1.0 1.0000 1 00001 1 1 1 0 0000-00-00 00:00:00 0000-00-00 00:00:00 1 1 1 1 -11 2 2 2 2 2 2 2.0 2.0000 2 00002 2 2 2 0 NULL NULL NULL NULL NULL 2 2 -12 0.33 3 3 3 3 3 3.0 3.0000 3 00003 3 3 3 0 1997-03-03 10:10:10 1997-03-03 10:10:10 3 -13 -1 -1 -1 -1 -1 -1 -1.0 -1.0000 0 00000 0 0 18446744073709551615 0 1997-08-07 08:07:06 1997-04-03 09:08:07 -1 -1 -1 -1 -14 -429496729 -128 -32768 -8388608 -2147483648 -4294967295 -4294967296.0 -4294967295.0000 0 00000 0 0 18446744069414584321 0 0000-00-00 00:00:00 0000-00-00 00:00:00 -4294967295 -4294967295 -4294967295 -4294967295 -15 4294967295 127 32767 8388607 2147483647 4294967295 4294967296.0 4294967295.0000 255 65535 16777215 4294967295 4294967295 0 0000-00-00 00:00:00 0000-00-00 00:00:00 4294967295 4294967295 4294967295 4294967295 -16 hello 1 1 0 0 0 0.0 NULL 0 00000 0 0 0 0 NULL NULL NULL NULL NULL -ALTER TABLE t1 -add new_field char(10) default "new" not null, -change blob_col new_blob_col varchar(20), -change date_field date_field char(10), -alter column string set default "new default", -alter short drop default, -DROP INDEX utiny, -DROP INDEX ushort, -DROP PRIMARY KEY, -DROP FOREIGN KEY any_name, -ADD INDEX (auto); -LOCK TABLES t1 WRITE; -ALTER TABLE t1 -RENAME as t2, -DROP longblob_col; -UNLOCK TABLES; -ALTER TABLE t2 rename as t3; -LOCK TABLES t3 WRITE ; -ALTER TABLE t3 rename as t1; -UNLOCK TABLES; -select auto,new_field,new_blob_col,date_field from t1 ; -auto new_field new_blob_col date_field -10 new 1 0000-00-00 -11 new NULL NULL -12 new 1997-03-03 -13 new -1 1997-08-07 -14 new -4294967295 0000-00-00 -15 new 4294967295 0000-00-00 -16 new NULL NULL -CREATE TABLE t2 ( -auto int(5) unsigned NOT NULL auto_increment, -string char(20), -mediumblob_col mediumblob not null, -new_field char(2), -PRIMARY KEY (auto) -); -INSERT INTO t2 (string,mediumblob_col,new_field) SELECT string,mediumblob_col,new_field from t1 where auto > 10; -Warnings: -Warning 1265 Data truncated for column 'new_field' at row 2 -Warning 1265 Data truncated for column 'new_field' at row 3 -Warning 1265 Data truncated for column 'new_field' at row 4 -Warning 1265 Data truncated for column 'new_field' at row 5 -Warning 1265 Data truncated for column 'new_field' at row 6 -Warning 1265 Data truncated for column 'new_field' at row 7 -select * from t2; -auto string mediumblob_col new_field -1 2 2 ne -2 0.33 ne -3 -1 -1 ne -4 -429496729 -4294967295 ne -5 4294967295 4294967295 ne -6 hello ne -select distinct flags from t1; -flags - -one,two,tree -one -one,two -select flags from t1 where find_in_set("two",flags)>0; -flags -one,two,tree -one,two,tree -one,two -one,two -select flags from t1 where find_in_set("unknown",flags)>0; -flags -select options,flags from t1 where options="ONE" and flags="ONE"; -options flags -one one -select options,flags from t1 where options="one" and flags="one"; -options flags -one one -drop table t2; -create table t2 select * from t1; -Warnings: -Warning 1265 Data truncated for column 'options' at row 4 -Warning 1265 Data truncated for column 'options' at row 5 -Warning 1265 Data truncated for column 'options' at row 6 -update t2 set string="changed" where auto=16; -show full columns from t1; -Field Type Collation Null Key Default Extra Privileges Comment -auto int(5) unsigned NULL NO MUL NULL auto_increment -string char(10) latin1_swedish_ci YES new defaul -tiny tinyint(4) NULL NO MUL 0 -short smallint(6) NULL NO MUL 0 -medium mediumint(8) NULL NO MUL 0 -long_int int(11) NULL NO 0 -longlong bigint(13) NULL NO MUL 0 -real_float float(13,1) NULL NO MUL 0.0 -real_double double(16,4) NULL YES NULL -utiny tinyint(3) unsigned NULL NO 0 -ushort smallint(5) unsigned zerofill NULL NO 00000 -umedium mediumint(8) unsigned NULL NO MUL 0 -ulong int(11) unsigned NULL NO MUL 0 -ulonglong bigint(13) unsigned NULL NO MUL 0 -time_stamp timestamp NULL YES CURRENT_TIMESTAMP -date_field char(10) latin1_swedish_ci YES NULL -time_field time NULL YES NULL -date_time datetime NULL YES NULL -new_blob_col varchar(20) latin1_swedish_ci YES NULL -tinyblob_col tinyblob NULL YES NULL -mediumblob_col mediumblob NULL NO -options enum('one','two','tree') latin1_swedish_ci NO MUL one -flags set('one','two','tree') latin1_swedish_ci NO -new_field char(10) latin1_swedish_ci NO new -show full columns from t2; -Field Type Collation Null Key Default Extra Privileges Comment -auto int(5) unsigned NULL NO 0 -string char(10) latin1_swedish_ci YES new defaul -tiny tinyint(4) NULL NO 0 -short smallint(6) NULL NO 0 -medium mediumint(8) NULL NO 0 -long_int int(11) NULL NO 0 -longlong bigint(13) NULL NO 0 -real_float float(13,1) NULL NO 0.0 -real_double double(16,4) NULL YES NULL -utiny tinyint(3) unsigned NULL NO 0 -ushort smallint(5) unsigned zerofill NULL NO 00000 -umedium mediumint(8) unsigned NULL NO 0 -ulong int(11) unsigned NULL NO 0 -ulonglong bigint(13) unsigned NULL NO 0 -time_stamp timestamp NULL YES 0000-00-00 00:00:00 -date_field char(10) latin1_swedish_ci YES NULL -time_field time NULL YES NULL -date_time datetime NULL YES NULL -new_blob_col varchar(20) latin1_swedish_ci YES NULL -tinyblob_col tinyblob NULL YES NULL -mediumblob_col mediumblob NULL NO -options enum('one','two','tree') latin1_swedish_ci NO one -flags set('one','two','tree') latin1_swedish_ci NO -new_field char(10) latin1_swedish_ci NO new -select t1.auto,t2.auto from t1,t2 where t1.auto=t2.auto and ((t1.string<>t2.string and (t1.string is not null or t2.string is not null)) or (t1.tiny<>t2.tiny and (t1.tiny is not null or t2.tiny is not null)) or (t1.short<>t2.short and (t1.short is not null or t2.short is not null)) or (t1.medium<>t2.medium and (t1.medium is not null or t2.medium is not null)) or (t1.long_int<>t2.long_int and (t1.long_int is not null or t2.long_int is not null)) or (t1.longlong<>t2.longlong and (t1.longlong is not null or t2.longlong is not null)) or (t1.real_float<>t2.real_float and (t1.real_float is not null or t2.real_float is not null)) or (t1.real_double<>t2.real_double and (t1.real_double is not null or t2.real_double is not null)) or (t1.utiny<>t2.utiny and (t1.utiny is not null or t2.utiny is not null)) or (t1.ushort<>t2.ushort and (t1.ushort is not null or t2.ushort is not null)) or (t1.umedium<>t2.umedium and (t1.umedium is not null or t2.umedium is not null)) or (t1.ulong<>t2.ulong and (t1.ulong is not null or t2.ulong is not null)) or (t1.ulonglong<>t2.ulonglong and (t1.ulonglong is not null or t2.ulonglong is not null)) or (t1.time_stamp<>t2.time_stamp and (t1.time_stamp is not null or t2.time_stamp is not null)) or (t1.date_field<>t2.date_field and (t1.date_field is not null or t2.date_field is not null)) or (t1.time_field<>t2.time_field and (t1.time_field is not null or t2.time_field is not null)) or (t1.date_time<>t2.date_time and (t1.date_time is not null or t2.date_time is not null)) or (t1.new_blob_col<>t2.new_blob_col and (t1.new_blob_col is not null or t2.new_blob_col is not null)) or (t1.tinyblob_col<>t2.tinyblob_col and (t1.tinyblob_col is not null or t2.tinyblob_col is not null)) or (t1.mediumblob_col<>t2.mediumblob_col and (t1.mediumblob_col is not null or t2.mediumblob_col is not null)) or (t1.options<>t2.options and (t1.options is not null or t2.options is not null)) or (t1.flags<>t2.flags and (t1.flags is not null or t2.flags is not null)) or (t1.new_field<>t2.new_field and (t1.new_field is not null or t2.new_field is not null))); -auto auto -16 16 -select t1.auto,t2.auto from t1,t2 where t1.auto=t2.auto and not (t1.string<=>t2.string and t1.tiny<=>t2.tiny and t1.short<=>t2.short and t1.medium<=>t2.medium and t1.long_int<=>t2.long_int and t1.longlong<=>t2.longlong and t1.real_float<=>t2.real_float and t1.real_double<=>t2.real_double and t1.utiny<=>t2.utiny and t1.ushort<=>t2.ushort and t1.umedium<=>t2.umedium and t1.ulong<=>t2.ulong and t1.ulonglong<=>t2.ulonglong and t1.time_stamp<=>t2.time_stamp and t1.date_field<=>t2.date_field and t1.time_field<=>t2.time_field and t1.date_time<=>t2.date_time and t1.new_blob_col<=>t2.new_blob_col and t1.tinyblob_col<=>t2.tinyblob_col and t1.mediumblob_col<=>t2.mediumblob_col and t1.options<=>t2.options and t1.flags<=>t2.flags and t1.new_field<=>t2.new_field); -auto auto -16 16 -drop table t2; -create table t2 (primary key (auto)) select auto+1 as auto,1 as t1, 'a' as t2, repeat('a',256) as t3, binary repeat('b',256) as t4, repeat('a',4096) as t5, binary repeat('b',4096) as t6, '' as t7, binary '' as t8 from t1; -show full columns from t2; -Field Type Collation Null Key Default Extra Privileges Comment -auto bigint(17) unsigned NULL NO PRI 0 -t1 bigint(1) NULL NO 0 -t2 varchar(1) latin1_swedish_ci NO -t3 varchar(256) latin1_swedish_ci NO -t4 varbinary(256) NULL NO -t5 longtext latin1_swedish_ci NO -t6 longblob NULL NO -t7 char(0) latin1_swedish_ci NO -t8 binary(0) NULL NO -select t1,t2,length(t3),length(t4),length(t5),length(t6),t7,t8 from t2; -t1 t2 length(t3) length(t4) length(t5) length(t6) t7 t8 -1 a 256 256 4096 4096 -1 a 256 256 4096 4096 -1 a 256 256 4096 4096 -1 a 256 256 4096 4096 -1 a 256 256 4096 4096 -1 a 256 256 4096 4096 -1 a 256 256 4096 4096 -drop table t1,t2; -create table t1 (c int); -insert into t1 values(1),(2); -create table t2 select * from t1; -create table t3 select * from t1, t2; -ERROR 42S21: Duplicate column name 'c' -create table t3 select t1.c AS c1, t2.c AS c2,1 as "const" from t1, t2; -show full columns from t3; -Field Type Collation Null Key Default Extra Privileges Comment -c1 int(11) NULL YES NULL -c2 int(11) NULL YES NULL -const bigint(1) NULL NO 0 -drop table t1,t2,t3; -create table t1 ( myfield INT NOT NULL, UNIQUE INDEX (myfield), unique (myfield), index(myfield)); -drop table t1; -create table t1 ( id integer unsigned not null primary key ); -create table t2 ( id integer unsigned not null primary key ); -insert into t1 values (1), (2); -insert into t2 values (1); -select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id ); -id_A id_B -1 1 -2 NULL -create table t3 (id_A integer unsigned not null, id_B integer unsigned null ); -insert into t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id ); -select * from t3; -id_A id_B -1 1 -2 NULL -drop table t3; -create table t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id ); -select * from t3; -id_A id_B -1 1 -2 NULL -drop table t1,t2,t3; diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 8c8e12d8838..dcd364f1422 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1103,7 +1103,7 @@ count(*) drop table t1; create table t2 ( a char character set latin1 collate latin1_swedish_ci, -b char character set latin1 collate latin1_bin); +b char character set latin1 collate latin1_german1_ci); create table t1 as (select a from t2) union (select b from t2); @@ -1235,3 +1235,20 @@ show columns from t2; Field Type Null Key Default Extra a varchar(3) YES NULL drop table t2, t1; +create table t1 (a varchar(5)); +create table t2 select * from t1 union select 'abcdefghijkl'; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(12) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select row_format from information_schema.TABLES where table_schema="test" and table_name="t2"; +row_format +Dynamic +alter table t2 ROW_FORMAT=fixed; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(12) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED +drop table t1,t2; diff --git a/mysql-test/r/user_var-binlog.result b/mysql-test/r/user_var-binlog.result new file mode 100644 index 00000000000..0e9692523ef --- /dev/null +++ b/mysql-test/r/user_var-binlog.result @@ -0,0 +1,32 @@ +create table t1 (a varchar(50)); +reset master; +SET TIMESTAMP=10000; +SET @`a b`='hello'; +INSERT INTO t1 VALUES(@`a b`); +set @var1= "';aaa"; +SET @var2=char(ascii('a')); +insert into t1 values (@var1),(@var2); +show binlog events from 98; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 98 User var 1 139 @`a b`=_latin1 0x68656C6C6F COLLATE latin1_swedish_ci +master-bin.000001 139 Query 1 231 use `test`; INSERT INTO t1 VALUES(@`a b`) +master-bin.000001 231 User var 1 273 @`var1`=_latin1 0x273B616161 COLLATE latin1_swedish_ci +master-bin.000001 273 User var 1 311 @`var2`=_latin1 0x61 COLLATE latin1_swedish_ci +master-bin.000001 311 Query 1 411 use `test`; insert into t1 values (@var1),(@var2) +/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; +ROLLBACK; +SET @`a b`:=_latin1 0x68656C6C6F COLLATE `latin1_swedish_ci`; +use test; +SET TIMESTAMP=10000; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; +SET @@session.sql_mode=0; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; +INSERT INTO t1 VALUES(@`a b`); +SET @`var1`:=_latin1 0x273B616161 COLLATE `latin1_swedish_ci`; +SET @`var2`:=_latin1 0x61 COLLATE `latin1_swedish_ci`; +SET TIMESTAMP=10000; +insert into t1 values (@var1),(@var2); +ROLLBACK; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; +drop table t1; diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index bd261751938..68eae111111 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -168,38 +168,6 @@ latin2 latin2_bin 2 select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' collate latin2_general_ci; (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' collate latin2_general_ci 1 -create table t1 (a varchar(50)); -reset master; -SET TIMESTAMP=10000; -SET @`a b`='hello'; -INSERT INTO t1 VALUES(@`a b`); -set @var1= "';aaa"; -SET @var2=char(ascii('a')); -insert into t1 values (@var1),(@var2); -show binlog events from 98; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # User var 1 # @`a b`=_latin1 0x68656C6C6F COLLATE latin1_swedish_ci -master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES(@`a b`) -master-bin.000001 # User var 1 # @`var1`=_latin1 0x273B616161 COLLATE latin1_swedish_ci -master-bin.000001 # User var 1 # @`var2`=_latin1 0x61 COLLATE latin1_swedish_ci -master-bin.000001 # Query 1 # use `test`; insert into t1 values (@var1),(@var2) -/*!40019 SET @@session.max_insert_delayed_threads=0*/; -/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; -ROLLBACK; -SET @`a b`:=_latin1 0x68656C6C6F COLLATE `latin1_swedish_ci`; -use test; -SET TIMESTAMP=10000; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1; -SET @@session.sql_mode=0; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8; -INSERT INTO t1 VALUES(@`a b`); -SET @`var1`:=_latin1 0x273B616161 COLLATE `latin1_swedish_ci`; -SET @`var2`:=_latin1 0x61 COLLATE `latin1_swedish_ci`; -SET TIMESTAMP=10000; -insert into t1 values (@var1),(@var2); -ROLLBACK; -/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; -drop table t1; set @var= NULL ; select FIELD( @var,'1it','Hit') as my_column; my_column @@ -211,3 +179,6 @@ set @v1=null, @v2=1, @v3=1.1, @v4=now(); select coercibility(@v1),coercibility(@v2),coercibility(@v3),coercibility(@v4); coercibility(@v1) coercibility(@v2) coercibility(@v3) coercibility(@v4) 2 2 2 2 +set session @honk=99; +set one_shot @honk=99; +ERROR HY000: The 'SET ONE_SHOT' syntax is reserved for purposes internal to the MySQL server diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index e3b6c2c5917..0f4f25dfdb5 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -354,7 +354,6 @@ set read_buffer_size=100; set read_rnd_buffer_size=100; set global rpl_recovery_rank=100; set global server_id=100; -set global slave_net_timeout=100; set global slow_launch_time=100; set sort_buffer_size=100; set sql_auto_is_null=1; @@ -381,7 +380,6 @@ select @@sql_max_join_size,@@max_join_size; set sql_quote_show_create=1; set sql_safe_updates=1; set sql_select_limit=1; -set global sql_slave_skip_counter=100; set sql_warnings=1; set global table_cache=100; set storage_engine=myisam; diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index c5fe4bf8565..59ff6abdde2 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -192,15 +192,6 @@ c d 1 3 2 5 3 10 -grant create view on test.* to test@localhost; -show grants for test@localhost; -Grants for test@localhost -GRANT USAGE ON *.* TO 'test'@'localhost' -GRANT CREATE VIEW ON `test`.* TO 'test'@'localhost' -revoke create view on test.* from test@localhost; -show grants for test@localhost; -Grants for test@localhost -GRANT USAGE ON *.* TO 'test'@'localhost' drop view v100; ERROR 42S02: Unknown table 'test.v100' drop view t1; @@ -230,139 +221,6 @@ a a 2 2 drop view v1, v2; drop table t1; -create database mysqltest; -create table mysqltest.t1 (a int, b int); -create table mysqltest.t2 (a int, b int); -grant select on mysqltest.t1 to mysqltest_1@localhost; -grant create view,select on test.* to mysqltest_1@localhost; -create view v1 as select * from mysqltest.t1; -alter view v1 as select * from mysqltest.t1; -ERROR 42000: DELETE command denied to user 'mysqltest_1'@'localhost' for table 'v1' -create or replace view v1 as select * from mysqltest.t1; -ERROR 42000: DELETE command denied to user 'mysqltest_1'@'localhost' for table 'v1' -create view mysqltest.v2 as select * from mysqltest.t1; -ERROR 42000: CREATE VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v2' -create view v2 as select * from mysqltest.t2; -ERROR 42000: ANY command denied to user 'mysqltest_1'@'localhost' for table 't2' -revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; -revoke all privileges on test.* from mysqltest_1@localhost; -drop database mysqltest; -drop view test.v1; -create database mysqltest; -create table mysqltest.t1 (a int, b int); -create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; -grant select (c) on mysqltest.v1 to mysqltest_1@localhost; -select c from mysqltest.v1; -c -select d from mysqltest.v1; -ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'd' in table 'v1' -revoke all privileges on mysqltest.v1 from mysqltest_1@localhost; -delete from mysql.user where user='mysqltest_1'; -drop database mysqltest; -create database mysqltest; -create table mysqltest.t1 (a int, b int); -create algorithm=temptable view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; -grant select (c) on mysqltest.v1 to mysqltest_1@localhost; -select c from mysqltest.v1; -c -select d from mysqltest.v1; -ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'd' in table 'v1' -revoke all privileges on mysqltest.v1 from mysqltest_1@localhost; -delete from mysql.user where user='mysqltest_1'; -drop database mysqltest; -create database mysqltest; -create table mysqltest.t1 (a int, b int); -create table mysqltest.t2 (a int, b int); -create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; -create algorithm=temptable view mysqltest.v2 (c,d) as select a+1,b+1 from mysqltest.t1; -create view mysqltest.v3 (c,d) as select a+1,b+1 from mysqltest.t2; -create algorithm=temptable view mysqltest.v4 (c,d) as select a+1,b+1 from mysqltest.t2; -grant select on mysqltest.v1 to mysqltest_1@localhost; -grant select on mysqltest.v2 to mysqltest_1@localhost; -grant select on mysqltest.v3 to mysqltest_1@localhost; -grant select on mysqltest.v4 to mysqltest_1@localhost; -select c from mysqltest.v1; -c -select c from mysqltest.v2; -c -select c from mysqltest.v3; -c -select c from mysqltest.v4; -c -show columns from mysqltest.v1; -Field Type Null Key Default Extra -c bigint(20) YES NULL -d bigint(20) YES NULL -show columns from mysqltest.v2; -Field Type Null Key Default Extra -c bigint(20) YES NULL -d bigint(20) YES NULL -explain select c from mysqltest.v1; -ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table -show create view mysqltest.v1; -ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1' -explain select c from mysqltest.v2; -ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table -show create view mysqltest.v2; -ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v2' -explain select c from mysqltest.v3; -ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table -show create view mysqltest.v3; -ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v3' -explain select c from mysqltest.v4; -ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table -show create view mysqltest.v4; -ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v4' -grant select on mysqltest.t1 to mysqltest_1@localhost; -explain select c from mysqltest.v1; -id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found -show create view mysqltest.v1; -ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1' -explain select c from mysqltest.v2; -id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY system NULL NULL NULL NULL 0 const row not found -2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table -show create view mysqltest.v2; -ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v2' -explain select c from mysqltest.v3; -ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table -show create view mysqltest.v3; -ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v3' -explain select c from mysqltest.v4; -ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table -show create view mysqltest.v4; -ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v4' -grant show view on mysqltest.* to mysqltest_1@localhost; -explain select c from mysqltest.v1; -id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found -show create view mysqltest.v1; -View Create View -v1 CREATE ALGORITHM=UNDEFINED VIEW `mysqltest`.`v1` AS select (`mysqltest`.`t1`.`a` + 1) AS `c`,(`mysqltest`.`t1`.`b` + 1) AS `d` from `mysqltest`.`t1` -explain select c from mysqltest.v2; -id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY system NULL NULL NULL NULL 0 const row not found -2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table -show create view mysqltest.v2; -View Create View -v2 CREATE ALGORITHM=TEMPTABLE VIEW `mysqltest`.`v2` AS select (`mysqltest`.`t1`.`a` + 1) AS `c`,(`mysqltest`.`t1`.`b` + 1) AS `d` from `mysqltest`.`t1` -explain select c from mysqltest.v3; -id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t2 system NULL NULL NULL NULL 0 const row not found -show create view mysqltest.v3; -View Create View -v3 CREATE ALGORITHM=UNDEFINED VIEW `mysqltest`.`v3` AS select (`mysqltest`.`t2`.`a` + 1) AS `c`,(`mysqltest`.`t2`.`b` + 1) AS `d` from `mysqltest`.`t2` -explain select c from mysqltest.v4; -id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY system NULL NULL NULL NULL 0 const row not found -2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table -show create view mysqltest.v4; -View Create View -v4 CREATE ALGORITHM=TEMPTABLE VIEW `mysqltest`.`v4` AS select (`mysqltest`.`t2`.`a` + 1) AS `c`,(`mysqltest`.`t2`.`b` + 1) AS `d` from `mysqltest`.`t2` -revoke all privileges on mysqltest.* from mysqltest_1@localhost; -delete from mysql.user where user='mysqltest_1'; -drop database mysqltest; create table t1 (a int); insert into t1 values (1), (2), (3), (1), (2), (3); create view v1 as select distinct a from t1; @@ -509,61 +367,6 @@ a b 50 10 drop table t1,t2; drop view v1,v2; -create database mysqltest; -create table mysqltest.t1 (a int, b int, primary key(a)); -insert into mysqltest.t1 values (10,2), (20,3), (30,4), (40,5), (50,10); -create table mysqltest.t2 (x int); -insert into mysqltest.t2 values (3), (4), (5), (6); -create view mysqltest.v1 (a,c) as select a, b+1 from mysqltest.t1; -create view mysqltest.v2 (a,c) as select a, b from mysqltest.t1; -create view mysqltest.v3 (a,c) as select a, b+1 from mysqltest.t1; -grant update (a) on mysqltest.v2 to mysqltest_1@localhost; -grant update on mysqltest.v1 to mysqltest_1@localhost; -grant select on mysqltest.* to mysqltest_1@localhost; -use mysqltest; -update t2,v1 set v1.a=v1.a+v1.c where t2.x=v1.c; -select * from t1; -a b -13 2 -24 3 -35 4 -46 5 -50 10 -update v1 set a=a+c; -select * from t1; -a b -16 2 -28 3 -40 4 -52 5 -61 10 -update t2,v2 set v2.a=v2.a+v2.c where t2.x=v2.c; -select * from t1; -a b -16 2 -31 3 -44 4 -57 5 -61 10 -update v2 set a=a+c; -select * from t1; -a b -18 2 -34 3 -48 4 -62 5 -71 10 -update t2,v2 set v2.c=v2.a+v2.c where t2.x=v2.c; -ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for column 'c' in table 'v2' -update v2 set c=a+c; -ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for column 'c' in table 'v2' -update t2,v3 set v3.a=v3.a+v3.c where t2.x=v3.c; -ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for table 'v3' -update v3 set a=a+c; -ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for table 'v3' -use test; -REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; -drop database mysqltest; create table t1 (a int, b int, primary key(b)); insert into t1 values (1,20), (2,30), (3,40), (4,50), (5,100); create view v1 (c) as select b from t1 where a<3; @@ -633,34 +436,6 @@ a b 5 10 drop table t1,t2; drop view v1,v2; -create database mysqltest; -create table mysqltest.t1 (a int, b int, primary key(a)); -insert into mysqltest.t1 values (1,2), (2,3), (3,4), (4,5), (5,10); -create table mysqltest.t2 (x int); -insert into mysqltest.t2 values (3), (4), (5), (6); -create view mysqltest.v1 (a,c) as select a, b+1 from mysqltest.t1; -create view mysqltest.v2 (a,c) as select a, b+1 from mysqltest.t1; -grant delete on mysqltest.v1 to mysqltest_1@localhost; -grant select on mysqltest.* to mysqltest_1@localhost; -use mysqltest; -delete from v1 where c < 4; -select * from t1; -a b -2 3 -3 4 -4 5 -5 10 -delete v1 from t2,v1 where t2.x=v1.c; -select * from t1; -a b -5 10 -delete v2 from t2,v2 where t2.x=v2.c; -ERROR 42000: DELETE command denied to user 'mysqltest_1'@'localhost' for table 'v2' -delete from v2 where c < 4; -ERROR 42000: DELETE command denied to user 'mysqltest_1'@'localhost' for table 'v2' -use test; -REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; -drop database mysqltest; create table t1 (a int, b int, c int, primary key(a,b)); insert into t1 values (10,2,-1), (20,3,-2), (30,4,-3), (40,5,-4), (50,10,-5); create view v1 (x,y) as select a, b from t1; @@ -741,36 +516,6 @@ a b c 40 5 NULL drop table t1, t2; drop view v1,v2,v3,v4,v5; -create database mysqltest; -create table mysqltest.t1 (a int, b int, primary key(a)); -insert into mysqltest.t1 values (1,2), (2,3); -create table mysqltest.t2 (x int, y int); -insert into mysqltest.t2 values (3,4); -create view mysqltest.v1 (a,c) as select a, b from mysqltest.t1; -create view mysqltest.v2 (a,c) as select a, b from mysqltest.t1; -grant insert on mysqltest.v1 to mysqltest_1@localhost; -grant select on mysqltest.* to mysqltest_1@localhost; -use mysqltest; -insert into v1 values (5,6); -select * from t1; -a b -1 2 -2 3 -5 6 -insert into v1 select x,y from t2; -select * from t1; -a b -1 2 -2 3 -5 6 -3 4 -insert into v2 values (5,6); -ERROR 42000: INSERT command denied to user 'mysqltest_1'@'localhost' for table 'v2' -insert into v2 select x,y from t2; -ERROR 42000: INSERT command denied to user 'mysqltest_1'@'localhost' for table 'v2' -use test; -REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; -drop database mysqltest; create table t1 (a int, primary key(a)); insert into t1 values (1), (2), (3); create view v1 (x) as select a from t1 where a > 1; @@ -815,44 +560,6 @@ a b 2 2 drop view v1; drop table t1; -create database mysqltest; -create table mysqltest.t1 (a int, b int); -create table mysqltest.t2 (a int, b int); -grant update on mysqltest.t1 to mysqltest_1@localhost; -grant update(b) on mysqltest.t2 to mysqltest_1@localhost; -grant create view,update on test.* to mysqltest_1@localhost; -create view v1 as select * from mysqltest.t1; -create view v2 as select b from mysqltest.t2; -create view mysqltest.v1 as select * from mysqltest.t1; -ERROR 42000: CREATE VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1' -create view v3 as select a from mysqltest.t2; -ERROR 42000: ANY command denied to user 'mysqltest_1'@'localhost' for column 'a' in table 't2' -create table mysqltest.v3 (b int); -grant create view on mysqltest.v3 to mysqltest_1@localhost; -drop table mysqltest.v3; -create view mysqltest.v3 as select b from mysqltest.t2; -grant create view, update on mysqltest.v3 to mysqltest_1@localhost; -drop view mysqltest.v3; -create view mysqltest.v3 as select b from mysqltest.t2; -grant create view, update, insert on mysqltest.v3 to mysqltest_1@localhost; -drop view mysqltest.v3; -create view mysqltest.v3 as select b from mysqltest.t2; -ERROR 42000: create view command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 'v3' -create table mysqltest.v3 (b int); -grant select(b) on mysqltest.v3 to mysqltest_1@localhost; -drop table mysqltest.v3; -create view mysqltest.v3 as select b from mysqltest.t2; -ERROR 42000: CREATE VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v3' -create view v4 as select b+1 from mysqltest.t2; -ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2' -grant create view,update,select on test.* to mysqltest_1@localhost; -create view v4 as select b+1 from mysqltest.t2; -ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2' -grant update,select(b) on mysqltest.t2 to mysqltest_1@localhost; -create view v4 as select b+1 from mysqltest.t2; -REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; -drop database mysqltest; -drop view v1,v2,v4; set sql_mode='ansi'; create table t1 ("a*b" int); create view v1 as select "a*b" from t1; @@ -1075,7 +782,7 @@ create function `f``1` () returns int return 5; create view v1 as select test.`f``1` (); show create view v1; View Create View -v1 CREATE ALGORITHM=UNDEFINED VIEW `test`.`v1` AS select `test`.`f``1`() AS `test.``f````1`` ()` +v1 CREATE ALGORITHM=UNDEFINED VIEW `test`.`v1` AS select sql_no_cache `test`.`f``1`() AS `test.``f````1`` ()` select * from v1; test.`f``1` () 5 @@ -1176,13 +883,121 @@ create table t1 (col1 int); create table t2 (col1 int); create view v1 as select * from t1; create view v2 as select * from v1; +create view v3 as select v2.col1 from v2,t2 where v2.col1 = t2.col1; update v2 set col1 = (select max(col1) from v1); ERROR HY000: You can't specify target table 'v2' for update in FROM clause +update v2 set col1 = (select max(col1) from t1); +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +update v2 set col1 = (select max(col1) from v2); +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +update v2,t2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +update t1,t2 set t1.col1 = (select max(col1) from v1) where t1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't1' for update in FROM clause +update v1,t2 set v1.col1 = (select max(col1) from v1) where v1.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v1' for update in FROM clause +update t2,v2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1; +ERROR HY000: You can't specify target table 't2' for update in FROM clause +update t2,t1 set t1.col1 = (select max(col1) from v1) where t1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't2' for update in FROM clause +update t2,v1 set v1.col1 = (select max(col1) from v1) where v1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't2' for update in FROM clause +update v2,t2 set v2.col1 = (select max(col1) from t1) where v2.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +update t1,t2 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't1' for update in FROM clause +update v1,t2 set v1.col1 = (select max(col1) from t1) where v1.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v1' for update in FROM clause +update t2,v2 set v2.col1 = (select max(col1) from t1) where v2.col1 = t2.col1; +ERROR HY000: You can't specify target table 't2' for update in FROM clause +update t2,t1 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't2' for update in FROM clause +update t2,v1 set v1.col1 = (select max(col1) from t1) where v1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't2' for update in FROM clause +update v2,t2 set v2.col1 = (select max(col1) from v2) where v2.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +update t1,t2 set t1.col1 = (select max(col1) from v2) where t1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't1' for update in FROM clause +update v1,t2 set v1.col1 = (select max(col1) from v2) where v1.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v1' for update in FROM clause +update t2,v2 set v2.col1 = (select max(col1) from v2) where v2.col1 = t2.col1; +ERROR HY000: You can't specify target table 't2' for update in FROM clause +update t2,t1 set t1.col1 = (select max(col1) from v2) where t1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't2' for update in FROM clause +update t2,v1 set v1.col1 = (select max(col1) from v2) where v1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't2' for update in FROM clause +update v3 set v3.col1 = (select max(col1) from v1); +ERROR HY000: You can't specify target table 'v3' for update in FROM clause +update v3 set v3.col1 = (select max(col1) from t1); +ERROR HY000: You can't specify target table 'v3' for update in FROM clause +update v3 set v3.col1 = (select max(col1) from v2); +ERROR HY000: You can't specify target table 'v3' for update in FROM clause +update v3 set v3.col1 = (select max(col1) from v3); +ERROR HY000: You can't specify target table 'v3' for update in FROM clause delete from v2 where col1 = (select max(col1) from v1); ERROR HY000: You can't specify target table 'v2' for update in FROM clause +delete from v2 where col1 = (select max(col1) from t1); +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +delete from v2 where col1 = (select max(col1) from v2); +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +delete v2 from v2,t2 where (select max(col1) from v1) > 0 and v2.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +delete t1 from t1,t2 where (select max(col1) from v1) > 0 and t1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't1' for update in FROM clause +delete v1 from v1,t2 where (select max(col1) from v1) > 0 and v1.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v1' for update in FROM clause +delete v2 from v2,t2 where (select max(col1) from t1) > 0 and v2.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +delete t1 from t1,t2 where (select max(col1) from t1) > 0 and t1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't1' for update in FROM clause +delete v1 from v1,t2 where (select max(col1) from t1) > 0 and v1.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v1' for update in FROM clause +delete v2 from v2,t2 where (select max(col1) from v2) > 0 and v2.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +delete t1 from t1,t2 where (select max(col1) from v2) > 0 and t1.col1 = t2.col1; +ERROR HY000: You can't specify target table 't1' for update in FROM clause +delete v1 from v1,t2 where (select max(col1) from v2) > 0 and v1.col1 = t2.col1; +ERROR HY000: You can't specify target table 'v1' for update in FROM clause insert into v2 values ((select max(col1) from v1)); ERROR HY000: You can't specify target table 'v2' for update in FROM clause -drop view v2,v1; +insert into t1 values ((select max(col1) from v1)); +ERROR HY000: You can't specify target table 't1' for update in FROM clause +insert into v2 values ((select max(col1) from v1)); +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +insert into v2 values ((select max(col1) from t1)); +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +insert into t1 values ((select max(col1) from t1)); +ERROR HY000: You can't specify target table 't1' for update in FROM clause +insert into v2 values ((select max(col1) from t1)); +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +insert into v2 values ((select max(col1) from v2)); +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +insert into t1 values ((select max(col1) from v2)); +ERROR HY000: You can't specify target table 't1' for update in FROM clause +insert into v2 values ((select max(col1) from v2)); +ERROR HY000: You can't specify target table 'v2' for update in FROM clause +insert into v3 (col1) values ((select max(col1) from v1)); +ERROR HY000: You can't specify target table 'v3' for update in FROM clause +insert into v3 (col1) values ((select max(col1) from t1)); +ERROR HY000: You can't specify target table 'v3' for update in FROM clause +insert into v3 (col1) values ((select max(col1) from v2)); +ERROR HY000: You can't specify target table 'v3' for update in FROM clause +insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from v2)); +ERROR HY000: You can't specify target table 'v3' for update in FROM clause +insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2)); +insert into mysql.time_zone values ('', (select CONVERT_TZ('20050101000000','UTC','MET') from t2)); +ERROR 23000: Column 'Use_leap_seconds' cannot be null +create algorithm=temptable view v4 as select * from t1; +insert into t1 values (1),(2),(3); +insert into t1 (col1) values ((select max(col1) from v4)); +select * from t1; +col1 +NULL +1 +2 +3 +3 +drop view v4,v3,v2,v1; drop table t1,t2; create table t1 (s1 int); create view v1 as select * from t1; @@ -1517,13 +1332,6 @@ Field 3,'Field 4| |Field 6| | 'Field 7'| drop view v1; drop table t1; -create database mysqltest; -create table mysqltest.t1 (a int); -grant all privileges on mysqltest.* to mysqltest_1@localhost; -use mysqltest; -create view v1 as select * from t1; -revoke all privileges on mysqltest.* from mysqltest_1@localhost; -drop database mysqltest; create table t1 (s1 smallint); create view v1 as select * from t1 where 20 < (select (s1) from t1); insert into v1 values (30); @@ -1687,6 +1495,8 @@ delete from v3; ERROR HY000: Can not delete from join view 'test.v3' delete v3,t1 from v3,t1; ERROR HY000: Can not delete from join view 'test.v3' +delete t1,v3 from t1,v3; +ERROR HY000: Can not delete from join view 'test.v3' delete from t1; prepare stmt1 from "insert into v3(a) values (?);"; set @a= 100; @@ -1778,3 +1588,109 @@ select s2 from v1 vq1 where 2 = (select count(*) aa from v1 vq2 having vq1.s2 = s2 drop view v1; drop table t1; +CREATE TABLE t1 (a1 int); +CREATE TABLE t2 (a2 int); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1(a,b) AS SELECT a1,a2 FROM t1 JOIN t2 ON a1=a2 WHERE a1>1; +SELECT * FROM v1; +a b +2 2 +3 3 +CREATE TABLE t3 SELECT * FROM v1; +SELECT * FROM t3; +a b +2 2 +3 3 +DROP VIEW v1; +DROP TABLE t1,t2,t3; +create table t1 (a int); +create table t2 like t1; +create table t3 like t1; +create view v1 as select t1.a x, t2.a y from t1 join t2 where t1.a=t2.a; +insert into t3 select x from v1; +insert into t2 select x from v1; +drop view v1; +drop table t1,t2,t3; +CREATE TABLE t1 (col1 int PRIMARY KEY, col2 varchar(10)); +INSERT INTO t1 VALUES(1,'trudy'); +INSERT INTO t1 VALUES(2,'peter'); +INSERT INTO t1 VALUES(3,'sanja'); +INSERT INTO t1 VALUES(4,'monty'); +INSERT INTO t1 VALUES(5,'david'); +INSERT INTO t1 VALUES(6,'kent'); +INSERT INTO t1 VALUES(7,'carsten'); +INSERT INTO t1 VALUES(8,'ranger'); +INSERT INTO t1 VALUES(10,'matt'); +CREATE TABLE t2 (col1 int, col2 int, col3 char(1)); +INSERT INTO t2 VALUES (1,1,'y'); +INSERT INTO t2 VALUES (1,2,'y'); +INSERT INTO t2 VALUES (2,1,'n'); +INSERT INTO t2 VALUES (3,1,'n'); +INSERT INTO t2 VALUES (4,1,'y'); +INSERT INTO t2 VALUES (4,2,'n'); +INSERT INTO t2 VALUES (4,3,'n'); +INSERT INTO t2 VALUES (6,1,'n'); +INSERT INTO t2 VALUES (8,1,'y'); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT a.col1,a.col2,b.col2,b.col3 +FROM t1 a LEFT JOIN t2 b ON a.col1=b.col1 +WHERE b.col2 IS NULL OR +b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1); +col1 col2 col2 col3 +1 trudy 2 y +2 peter 1 n +3 sanja 1 n +4 monty 3 n +5 david NULL NULL +6 kent 1 n +7 carsten NULL NULL +8 ranger 1 y +10 matt NULL NULL +SELECT a.col1,a.col2,b.col2,b.col3 +FROM v1 a LEFT JOIN t2 b ON a.col1=b.col1 +WHERE b.col2 IS NULL OR +b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1); +col1 col2 col2 col3 +1 trudy 2 y +2 peter 1 n +3 sanja 1 n +4 monty 3 n +5 david NULL NULL +6 kent 1 n +7 carsten NULL NULL +8 ranger 1 y +10 matt NULL NULL +CREATE VIEW v2 AS SELECT * FROM t2; +SELECT a.col1,a.col2,b.col2,b.col3 +FROM v2 b RIGHT JOIN v1 a ON a.col1=b.col1 +WHERE b.col2 IS NULL OR +b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1); +col1 col2 col2 col3 +1 trudy 2 y +2 peter 1 n +3 sanja 1 n +4 monty 3 n +5 david NULL NULL +6 kent 1 n +7 carsten NULL NULL +8 ranger 1 y +10 matt NULL NULL +SELECT a.col1,a.col2,b.col2,b.col3 +FROM v2 b RIGHT JOIN v1 a ON a.col1=b.col1 +WHERE a.col1 IN (1,5,9) AND +(b.col2 IS NULL OR +b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1)); +col1 col2 col2 col3 +1 trudy 2 y +5 david NULL NULL +CREATE VIEW v3 AS SELECT * FROM t1 WHERE col1 IN (1,5,9); +SELECT a.col1,a.col2,b.col2,b.col3 +FROM v2 b RIGHT JOIN v3 a ON a.col1=b.col1 +WHERE b.col2 IS NULL OR +b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1); +col1 col2 col2 col3 +1 trudy 2 y +5 david NULL NULL +DROP VIEW v1,v2,v3; +DROP TABLE t1,t2; diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result new file mode 100644 index 00000000000..df8e2b04f47 --- /dev/null +++ b/mysql-test/r/view_grant.result @@ -0,0 +1,304 @@ +grant create view on test.* to test@localhost; +show grants for test@localhost; +Grants for test@localhost +GRANT USAGE ON *.* TO 'test'@'localhost' +GRANT CREATE VIEW ON `test`.* TO 'test'@'localhost' +revoke create view on test.* from test@localhost; +show grants for test@localhost; +Grants for test@localhost +GRANT USAGE ON *.* TO 'test'@'localhost' +create database mysqltest; +create table mysqltest.t1 (a int, b int); +create table mysqltest.t2 (a int, b int); +grant select on mysqltest.t1 to mysqltest_1@localhost; +grant create view,select on test.* to mysqltest_1@localhost; +create view v1 as select * from mysqltest.t1; +alter view v1 as select * from mysqltest.t1; +ERROR 42000: DROP command denied to user 'mysqltest_1'@'localhost' for table 'v1' +create or replace view v1 as select * from mysqltest.t1; +ERROR 42000: DROP command denied to user 'mysqltest_1'@'localhost' for table 'v1' +create view mysqltest.v2 as select * from mysqltest.t1; +ERROR 42000: CREATE VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v2' +create view v2 as select * from mysqltest.t2; +ERROR 42000: ANY command denied to user 'mysqltest_1'@'localhost' for table 't2' +grant create view,drop,select on test.* to mysqltest_1@localhost; +use test; +alter view v1 as select * from mysqltest.t1; +create or replace view v1 as select * from mysqltest.t1; +revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; +revoke all privileges on test.* from mysqltest_1@localhost; +drop database mysqltest; +drop view test.v1; +create database mysqltest; +create table mysqltest.t1 (a int, b int); +create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; +grant select (c) on mysqltest.v1 to mysqltest_1@localhost; +select c from mysqltest.v1; +c +select d from mysqltest.v1; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'd' in table 'v1' +revoke all privileges on mysqltest.v1 from mysqltest_1@localhost; +delete from mysql.user where user='mysqltest_1'; +drop database mysqltest; +create database mysqltest; +create table mysqltest.t1 (a int, b int); +create algorithm=temptable view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; +grant select (c) on mysqltest.v1 to mysqltest_1@localhost; +select c from mysqltest.v1; +c +select d from mysqltest.v1; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'd' in table 'v1' +revoke all privileges on mysqltest.v1 from mysqltest_1@localhost; +delete from mysql.user where user='mysqltest_1'; +drop database mysqltest; +create database mysqltest; +create table mysqltest.t1 (a int, b int); +create table mysqltest.t2 (a int, b int); +create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; +create algorithm=temptable view mysqltest.v2 (c,d) as select a+1,b+1 from mysqltest.t1; +create view mysqltest.v3 (c,d) as select a+1,b+1 from mysqltest.t2; +create algorithm=temptable view mysqltest.v4 (c,d) as select a+1,b+1 from mysqltest.t2; +grant select on mysqltest.v1 to mysqltest_1@localhost; +grant select on mysqltest.v2 to mysqltest_1@localhost; +grant select on mysqltest.v3 to mysqltest_1@localhost; +grant select on mysqltest.v4 to mysqltest_1@localhost; +select c from mysqltest.v1; +c +select c from mysqltest.v2; +c +select c from mysqltest.v3; +c +select c from mysqltest.v4; +c +show columns from mysqltest.v1; +Field Type Null Key Default Extra +c bigint(20) YES NULL +d bigint(20) YES NULL +show columns from mysqltest.v2; +Field Type Null Key Default Extra +c bigint(20) YES NULL +d bigint(20) YES NULL +explain select c from mysqltest.v1; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v1; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1' +explain select c from mysqltest.v2; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v2; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v2' +explain select c from mysqltest.v3; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v3; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v3' +explain select c from mysqltest.v4; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v4; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v4' +grant select on mysqltest.t1 to mysqltest_1@localhost; +explain select c from mysqltest.v1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found +show create view mysqltest.v1; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1' +explain select c from mysqltest.v2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY system NULL NULL NULL NULL 0 const row not found +2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table +show create view mysqltest.v2; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v2' +explain select c from mysqltest.v3; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v3; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v3' +explain select c from mysqltest.v4; +ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table +show create view mysqltest.v4; +ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v4' +grant show view on mysqltest.* to mysqltest_1@localhost; +explain select c from mysqltest.v1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found +show create view mysqltest.v1; +View Create View +v1 CREATE ALGORITHM=UNDEFINED VIEW `mysqltest`.`v1` AS select (`mysqltest`.`t1`.`a` + 1) AS `c`,(`mysqltest`.`t1`.`b` + 1) AS `d` from `mysqltest`.`t1` +explain select c from mysqltest.v2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY system NULL NULL NULL NULL 0 const row not found +2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table +show create view mysqltest.v2; +View Create View +v2 CREATE ALGORITHM=TEMPTABLE VIEW `mysqltest`.`v2` AS select (`mysqltest`.`t1`.`a` + 1) AS `c`,(`mysqltest`.`t1`.`b` + 1) AS `d` from `mysqltest`.`t1` +explain select c from mysqltest.v3; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 system NULL NULL NULL NULL 0 const row not found +show create view mysqltest.v3; +View Create View +v3 CREATE ALGORITHM=UNDEFINED VIEW `mysqltest`.`v3` AS select (`mysqltest`.`t2`.`a` + 1) AS `c`,(`mysqltest`.`t2`.`b` + 1) AS `d` from `mysqltest`.`t2` +explain select c from mysqltest.v4; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY system NULL NULL NULL NULL 0 const row not found +2 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table +show create view mysqltest.v4; +View Create View +v4 CREATE ALGORITHM=TEMPTABLE VIEW `mysqltest`.`v4` AS select (`mysqltest`.`t2`.`a` + 1) AS `c`,(`mysqltest`.`t2`.`b` + 1) AS `d` from `mysqltest`.`t2` +revoke all privileges on mysqltest.* from mysqltest_1@localhost; +delete from mysql.user where user='mysqltest_1'; +drop database mysqltest; +create database mysqltest; +create table mysqltest.t1 (a int, b int, primary key(a)); +insert into mysqltest.t1 values (10,2), (20,3), (30,4), (40,5), (50,10); +create table mysqltest.t2 (x int); +insert into mysqltest.t2 values (3), (4), (5), (6); +create view mysqltest.v1 (a,c) as select a, b+1 from mysqltest.t1; +create view mysqltest.v2 (a,c) as select a, b from mysqltest.t1; +create view mysqltest.v3 (a,c) as select a, b+1 from mysqltest.t1; +grant update (a) on mysqltest.v2 to mysqltest_1@localhost; +grant update on mysqltest.v1 to mysqltest_1@localhost; +grant select on mysqltest.* to mysqltest_1@localhost; +use mysqltest; +update t2,v1 set v1.a=v1.a+v1.c where t2.x=v1.c; +select * from t1; +a b +13 2 +24 3 +35 4 +46 5 +50 10 +update v1 set a=a+c; +select * from t1; +a b +16 2 +28 3 +40 4 +52 5 +61 10 +update t2,v2 set v2.a=v2.a+v2.c where t2.x=v2.c; +select * from t1; +a b +16 2 +31 3 +44 4 +57 5 +61 10 +update v2 set a=a+c; +select * from t1; +a b +18 2 +34 3 +48 4 +62 5 +71 10 +update t2,v2 set v2.c=v2.a+v2.c where t2.x=v2.c; +ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for column 'c' in table 'v2' +update v2 set c=a+c; +ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for column 'c' in table 'v2' +update t2,v3 set v3.a=v3.a+v3.c where t2.x=v3.c; +ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for table 'v3' +update v3 set a=a+c; +ERROR 42000: UPDATE command denied to user 'mysqltest_1'@'localhost' for table 'v3' +use test; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +create database mysqltest; +create table mysqltest.t1 (a int, b int, primary key(a)); +insert into mysqltest.t1 values (1,2), (2,3), (3,4), (4,5), (5,10); +create table mysqltest.t2 (x int); +insert into mysqltest.t2 values (3), (4), (5), (6); +create view mysqltest.v1 (a,c) as select a, b+1 from mysqltest.t1; +create view mysqltest.v2 (a,c) as select a, b+1 from mysqltest.t1; +grant delete on mysqltest.v1 to mysqltest_1@localhost; +grant select on mysqltest.* to mysqltest_1@localhost; +use mysqltest; +delete from v1 where c < 4; +select * from t1; +a b +2 3 +3 4 +4 5 +5 10 +delete v1 from t2,v1 where t2.x=v1.c; +select * from t1; +a b +5 10 +delete v2 from t2,v2 where t2.x=v2.c; +ERROR 42000: DELETE command denied to user 'mysqltest_1'@'localhost' for table 'v2' +delete from v2 where c < 4; +ERROR 42000: DELETE command denied to user 'mysqltest_1'@'localhost' for table 'v2' +use test; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +create database mysqltest; +create table mysqltest.t1 (a int, b int, primary key(a)); +insert into mysqltest.t1 values (1,2), (2,3); +create table mysqltest.t2 (x int, y int); +insert into mysqltest.t2 values (3,4); +create view mysqltest.v1 (a,c) as select a, b from mysqltest.t1; +create view mysqltest.v2 (a,c) as select a, b from mysqltest.t1; +grant insert on mysqltest.v1 to mysqltest_1@localhost; +grant select on mysqltest.* to mysqltest_1@localhost; +use mysqltest; +insert into v1 values (5,6); +select * from t1; +a b +1 2 +2 3 +5 6 +insert into v1 select x,y from t2; +select * from t1; +a b +1 2 +2 3 +5 6 +3 4 +insert into v2 values (5,6); +ERROR 42000: INSERT command denied to user 'mysqltest_1'@'localhost' for table 'v2' +insert into v2 select x,y from t2; +ERROR 42000: INSERT command denied to user 'mysqltest_1'@'localhost' for table 'v2' +use test; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +create database mysqltest; +create table mysqltest.t1 (a int, b int); +create table mysqltest.t2 (a int, b int); +grant update on mysqltest.t1 to mysqltest_1@localhost; +grant update(b) on mysqltest.t2 to mysqltest_1@localhost; +grant create view,update on test.* to mysqltest_1@localhost; +create view v1 as select * from mysqltest.t1; +create view v2 as select b from mysqltest.t2; +create view mysqltest.v1 as select * from mysqltest.t1; +ERROR 42000: CREATE VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1' +create view v3 as select a from mysqltest.t2; +ERROR 42000: ANY command denied to user 'mysqltest_1'@'localhost' for column 'a' in table 't2' +create table mysqltest.v3 (b int); +grant create view on mysqltest.v3 to mysqltest_1@localhost; +drop table mysqltest.v3; +create view mysqltest.v3 as select b from mysqltest.t2; +grant create view, update on mysqltest.v3 to mysqltest_1@localhost; +drop view mysqltest.v3; +create view mysqltest.v3 as select b from mysqltest.t2; +grant create view, update, insert on mysqltest.v3 to mysqltest_1@localhost; +drop view mysqltest.v3; +create view mysqltest.v3 as select b from mysqltest.t2; +ERROR 42000: create view command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 'v3' +create table mysqltest.v3 (b int); +grant select(b) on mysqltest.v3 to mysqltest_1@localhost; +drop table mysqltest.v3; +create view mysqltest.v3 as select b from mysqltest.t2; +ERROR 42000: CREATE VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v3' +create view v4 as select b+1 from mysqltest.t2; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2' +grant create view,update,select on test.* to mysqltest_1@localhost; +create view v4 as select b+1 from mysqltest.t2; +ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2' +grant update,select(b) on mysqltest.t2 to mysqltest_1@localhost; +create view v4 as select b+1 from mysqltest.t2; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +drop view v1,v2,v4; +create database mysqltest; +create table mysqltest.t1 (a int); +grant all privileges on mysqltest.* to mysqltest_1@localhost; +use mysqltest; +create view v1 as select * from t1; +revoke all privileges on mysqltest.* from mysqltest_1@localhost; +drop database mysqltest; diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result index d143b66ae94..442d0784953 100644 --- a/mysql-test/r/warnings.result +++ b/mysql-test/r/warnings.result @@ -117,10 +117,12 @@ Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'a' a Warning 1265 Data truncated for column 'b' at row 4 insert into t2(b) values('mysqlab'); Warnings: +Warning 1364 Field 'a' doesn't have a default value Warning 1265 Data truncated for column 'b' at row 1 set sql_warnings=1; insert into t2(b) values('mysqlab'); Warnings: +Warning 1364 Field 'a' doesn't have a default value Warning 1265 Data truncated for column 'b' at row 1 set sql_warnings=0; drop table t1, t2; diff --git a/mysql-test/r/xa.result b/mysql-test/r/xa.result new file mode 100644 index 00000000000..1dde495d6ae --- /dev/null +++ b/mysql-test/r/xa.result @@ -0,0 +1,45 @@ +drop table if exists t1, t2; +create table t1 (a int) engine=innodb; +xa start 'test1'; +insert t1 values (10); +xa end 'test1'; +xa prepare 'test1'; +xa rollback 'test1'; +select * from t1; +a +xa start 'test2'; +xa start 'test-bad'; +ERROR XAE07: XAER_RMFAIL: The command cannot be executed in the ACTIVE state +insert t1 values (20); +xa prepare 'test2'; +ERROR XAE07: XAER_RMFAIL: The command cannot be executed in the ACTIVE state +xa end 'test2'; +xa prepare 'test2'; +xa commit 'test2'; +select * from t1; +a +20 +xa start 'testa','testb'; +insert t1 values (30); +xa end 'testa','testb'; +xa start 0x7465737462, 0x2030405060, 0xb; +insert t1 values (40); +xa end 'testb',' 0@P`',11; +xa prepare 'testb',0x2030405060,11; +xa recover; +formatID gtrid_length bqual_length data +11 5 5 testb 0@P` +xa prepare 'testa','testb'; +xa recover; +formatID gtrid_length bqual_length data +11 5 5 testb 0@P` +1 5 5 testatestb +xa commit 'testb',0x2030405060,11; +xa rollback 'testa','testb'; +xa start 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +select * from t1; +a +20 +40 +drop table t1; diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index c2277dc1755..92651442041 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -41,6 +41,7 @@ PRIMARY KEY (GROUP_ID,LANG_ID), KEY NAME (NAME)); #show table status like "t1"; ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null; +--replace_column 8 # SHOW FULL COLUMNS FROM t1; DROP TABLE t1; @@ -107,25 +108,6 @@ select * from mysqltest.t1; drop table t1; drop database mysqltest; -# -# Rights for renaming test (Bug #3270) -# -connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); -connection root; ---disable_warnings -create database mysqltest; ---enable_warnings -create table mysqltest.t1 (a int,b int,c int); -grant all on mysqltest.t1 to mysqltest_1@localhost; -connect (user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK); -connection user1; --- error 1142 -alter table t1 rename t2; -connection root; -revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; -delete from mysql.user where user=_binary'mysqltest_1'; -drop database mysqltest; - # # ALTER TABLE ... ENABLE/DISABLE KEYS diff --git a/mysql-test/t/bdb-deadlock.test b/mysql-test/t/bdb-deadlock.test index d86403fcffc..5e6ca666cc2 100644 --- a/mysql-test/t/bdb-deadlock.test +++ b/mysql-test/t/bdb-deadlock.test @@ -5,7 +5,7 @@ # connection in a separate thread. # -#-- source include/not_embedded.inc +-- source include/not_embedded.inc -- source include/have_bdb.inc connect (con1,localhost,root,,); diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index 94d9590dd5f..e7dd49394ee 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -5,6 +5,7 @@ select CAST(1-2 AS UNSIGNED); select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER); select CONVERT('-1',UNSIGNED); +select CAST('10 ' as unsigned integer); select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1; select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1; select ~5, cast(~5 as signed); @@ -16,11 +17,22 @@ select cast("A" as binary) = "a", cast(BINARY "a" as CHAR) = "A"; select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME); select cast("1:2:3" as TIME); select CONVERT("2004-01-22 21:45:33",DATE); +select 10+'10'; +select 10.0+'10'; +select 10E+0+'10'; + +# The following cast creates warnings + select CONVERT(DATE "2004-01-22 21:45:33" USING latin1); select CONVERT(DATE "2004-01-22 21:45:33",CHAR); select CONVERT(DATE "2004-01-22 21:45:33",CHAR(4)); select CONVERT(DATE "2004-01-22 21:45:33",BINARY(4)); select CAST(DATE "2004-01-22 21:45:33" AS BINARY(4)); +select cast('-10a' as signed integer); +select cast('a10' as unsigned integer); +select 10+'a'; +select 10.0+cast('a' as decimal); +select 10E+0+'a'; # # Character set convertion @@ -41,6 +53,7 @@ select cast(_latin1'abc' AS char(2)) as c3, cast(_latin1'a ' AS char(2)) as c4, cast(_latin1'a' AS char(2)) as c5; +select cast(1000 as CHAR(3)); create table t1 select cast(_latin1'ab' AS char) as c1, diff --git a/mysql-test/t/client_xml.test b/mysql-test/t/client_xml.test index dd7a812b54f..58e9178ef3a 100644 --- a/mysql-test/t/client_xml.test +++ b/mysql-test/t/client_xml.test @@ -1,3 +1,6 @@ +# Can't run with embedded server +-- source include/not_embedded.inc + # Test of the xml output of the 'mysql' and 'mysqldump' clients -- makes # sure that basic encoding issues are handled properly create table t1 ( diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test index 8e1a92a586e..5d2d53a2a90 100644 --- a/mysql-test/t/connect.test +++ b/mysql-test/t/connect.test @@ -3,6 +3,9 @@ # Unfortunately the check is incomplete as we can't handle errors on connect # Also we can't connect without database +# This test makes no sense with the embedded server +--source include/not_embedded.inc + #connect (con1,localhost,root,,""); #show tables; connect (con1,localhost,root,,mysql); diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 26b467a398d..1e2cf391221 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -49,14 +49,25 @@ create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int); # -# Some wrong defaults, so these creates should fail too +# Some wrong defaults, so these creates should fail too (Bug #5902) # --error 1067 -create table test (a datetime default now()); +create table t1 (a datetime default now()); --error 1294 -create table test (a datetime on update now()); +create table t1 (a datetime on update now()); --error 1067 -create table test (a int default 100 auto_increment); +create table t1 (a int default 100 auto_increment); +--error 1067 +create table t1 (a tinyint default 1000); +--error 1067 +create table t1 (a varchar(5) default 'abcdef'); + +create table t1 (a varchar(5) default 'abcde'); +insert into t1 values(); +select * from t1; +--error 1067 +alter table t1 alter column a set default 'abcdef'; +drop table t1; # # test of dummy table names diff --git a/mysql-test/t/ctype_collate.test b/mysql-test/t/ctype_collate.test index 3599beeacc4..b65067a36cf 100644 --- a/mysql-test/t/ctype_collate.test +++ b/mysql-test/t/ctype_collate.test @@ -158,6 +158,18 @@ SELECT * FROM t1 WHERE s1 = s2; DROP TABLE t1; +CREATE TABLE t1 +(s1 CHAR(5) COLLATE latin1_german1_ci, + s2 CHAR(5) COLLATE latin1_swedish_ci, + s3 CHAR(5) COLLATE latin1_bin); +INSERT INTO t1 VALUES ('a','A','A'); +--error 1267 +SELECT * FROM t1 WHERE s1 = s2; +SELECT * FROM t1 WHERE s1 = s3; +SELECT * FROM t1 WHERE s2 = s3; +DROP TABLE t1; + + # # Test that optimizer doesn't use indexes with wrong collation # diff --git a/mysql-test/t/ctype_latin1_de.test b/mysql-test/t/ctype_latin1_de.test index 512ae88a445..e17806a54aa 100644 --- a/mysql-test/t/ctype_latin1_de.test +++ b/mysql-test/t/ctype_latin1_de.test @@ -66,7 +66,7 @@ drop table t1; # # The below checks both binary and character comparisons. # -create table t1 (word varchar(255) not null, word2 varchar(255) not null, index(word)); +create table t1 (word varchar(255) not null, word2 varchar(255) not null default '', index(word)); show create table t1; insert into t1 (word) values ('ss'),(0xDF),(0xE4),('ae'); update t1 set word2=word; diff --git a/mysql-test/t/ctype_many.test b/mysql-test/t/ctype_many.test index 26057e7c997..454e2c63cbb 100644 --- a/mysql-test/t/ctype_many.test +++ b/mysql-test/t/ctype_many.test @@ -8,7 +8,7 @@ SET CHARACTER SET latin1; CREATE TABLE t1 ( comment CHAR(32) ASCII NOT NULL, - koi8_ru_f CHAR(32) CHARACTER SET koi8r NOT NULL + koi8_ru_f CHAR(32) CHARACTER SET koi8r NOT NULL default '' ) CHARSET=latin5; SHOW CREATE TABLE t1; @@ -142,13 +142,13 @@ INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r' SET CHARACTER SET utf8; SELECT koi8_ru_f,MIN(comment),COUNT(*) FROM t1 GROUP BY 1; -ALTER TABLE t1 ADD utf8_f CHAR(32) CHARACTER SET utf8 NOT NULL; +ALTER TABLE t1 ADD utf8_f CHAR(32) CHARACTER SET utf8 NOT NULL default ''; UPDATE t1 SET utf8_f=CONVERT(koi8_ru_f USING utf8); SET CHARACTER SET koi8r; SELECT * FROM t1; -ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL; +ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL default ''; UPDATE t1 SET bin_f=koi8_ru_f; SELECT COUNT(DISTINCT bin_f),COUNT(DISTINCT koi8_ru_f),COUNT(DISTINCT utf8_f) FROM t1; diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 7ca2685a6e7..9d5bd0459b0 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -330,24 +330,6 @@ set @str2 = convert(@str1 using ucs2); prepare stmt1 from @str2; execute stmt1 using @ivar; -# -# Check correct binlogging of UCS2 user variables (BUG#3875) -# -SET TIMESTAMP=10000; -create table t2 (c char(30)) charset=ucs2; -set @v=convert('abc' using ucs2); -reset master; -insert into t2 values (@v); ---replace_column 2 # 5 # -show binlog events from 98; -# more important than SHOW BINLOG EVENTS, mysqlbinlog (where we -# absolutely need variables names to be quoted and strings to be -# escaped). ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 -drop table t2; - - # # Check that ucs2 works with ENUM and SET type # diff --git a/mysql-test/t/ctype_ucs_binlog.test b/mysql-test/t/ctype_ucs_binlog.test new file mode 100644 index 00000000000..226f128c1c2 --- /dev/null +++ b/mysql-test/t/ctype_ucs_binlog.test @@ -0,0 +1,20 @@ +--source include/not_embedded.inc +--source include/have_ucs2.inc + +# +# Check correct binlogging of UCS2 user variables (BUG#3875) +# +SET TIMESTAMP=10000; +create table t2 (c char(30)) charset=ucs2; +set @v=convert('abc' using ucs2); +reset master; +insert into t2 values (@v); +show binlog events from 98; +# more important than SHOW BINLOG EVENTS, mysqlbinlog (where we +# absolutely need variables names to be quoted and strings to be +# escaped). +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 +drop table t2; + + diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test index 6f0e5b3f14c..5e123ca0de8 100644 --- a/mysql-test/t/drop.test +++ b/mysql-test/t/drop.test @@ -30,6 +30,28 @@ select * from mysqltest.mysqltest; drop database if exists mysqltest; --disable_info create database mysqltest; + +# +# drop many tables - bug#3891 +# we'll do it in mysqltest db, to be able to use longer table names +# (tableN instead on tN) +# +use mysqltest; +--error 1051 +drop table table1, table2, table3, table4, table5, table6, +table7, table8, table9, table10, table11, table12, table13, +table14, table15, table16, table17, table18, table19, table20, +table21, table22, table23, table24, table25, table26, table27, +table28; + +--error 1051 +drop table table1, table2, table3, table4, table5, table6, +table7, table8, table9, table10, table11, table12, table13, +table14, table15, table16, table17, table18, table19, table20, +table21, table22, table23, table24, table25, table26, table27, +table28, table29, table30; + +use test; drop database mysqltest; # test drop/create database and FLUSH TABLES WITH READ LOCK diff --git a/mysql-test/t/drop_temp_table.test b/mysql-test/t/drop_temp_table.test index dcd95721179..dbe7959acb2 100644 --- a/mysql-test/t/drop_temp_table.test +++ b/mysql-test/t/drop_temp_table.test @@ -1,3 +1,6 @@ +# Embedded server doesn't support binlog +-- source include/not_embedded.inc + connect (con1,localhost,root,,); connect (con2,localhost,root,,); connection con1; diff --git a/mysql-test/t/flush_block_commit.test b/mysql-test/t/flush_block_commit.test index 87715452089..29ef7b8a0b9 100644 --- a/mysql-test/t/flush_block_commit.test +++ b/mysql-test/t/flush_block_commit.test @@ -3,6 +3,10 @@ # We verify that we did not introduce a deadlock. # This is intended to mimick how mysqldump and innobackup work. +# This test doesn't work with the embedded server +-- source include/not_embedded.inc + +# And it requires InnoDB -- source include/have_innodb.inc connect (con1,localhost,root,,); @@ -72,3 +76,24 @@ select * from t1; show create database test; drop table t1; + +# FLUSH TABLES WITH READ LOCK should block writes to binlog too +connection con1; +create table t1 (a int) engine=innodb; +reset master; +set autocommit=0; +insert t1 values (1); +connection con2; +flush tables with read lock; +show master status; +connection con1; +send commit; +connection con2; +sleep 1; +show master status; +unlock tables; +connection con1; +reap; +drop table t1; +set autocommit=1; + diff --git a/mysql-test/t/flush_read_lock_kill.test b/mysql-test/t/flush_read_lock_kill.test index b711bc63e0e..02384357711 100644 --- a/mysql-test/t/flush_read_lock_kill.test +++ b/mysql-test/t/flush_read_lock_kill.test @@ -7,6 +7,9 @@ # -master.opt. But this test is designed to still pass then (though it # won't test anything interesting). +# This also won't work with the embedded server test +-- source include/not_embedded.inc + -- source include/have_debug.inc connect (con1,localhost,root,,); diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test index 693773b18c8..a2ea26390ca 100644 --- a/mysql-test/t/func_if.test +++ b/mysql-test/t/func_if.test @@ -25,9 +25,10 @@ explain extended select if(u=1,st,binary st) s from t1 where st like "%a%" order # # NULLIF test # -select nullif(u=0, 'test') from t1; -explain extended select nullif(u=0, 'test') from t1; +select nullif(u, 1) from t1; +explain extended select nullif(u, 1) from t1; drop table t1; +select nullif(1,'test'); # # Bug 2629 diff --git a/mysql-test/t/func_sapdb.test b/mysql-test/t/func_sapdb.test index cb3ab12b5fc..bb9159eefbe 100644 --- a/mysql-test/t/func_sapdb.test +++ b/mysql-test/t/func_sapdb.test @@ -106,6 +106,7 @@ insert into test values ('2001-01-01 01:01:01', '-01:01:01', '-23:59:59', "1997-12-31 23:59:59.000001"), ('1997-12-31 23:59:59.000001', '-23:59:59', '-01:01:01', '2001-01-01 01:01:01'), ('2001-01-01 01:01:01', '01:01:01', '-1 01:01:01', null), +('2001-01-01 01:01:01', '-01:01:01', '1 01:01:01', '2001-01-01 01:01:01'), ('2001-01-01 01:01:01', null, '-1 01:01:01', null), (null, null, null, null), ('2001-01-01 01:01:01', '01:01:01', '1 01:01:01', '2001-01-01 01:01:01'); diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 8bf36431587..b3c875f7bf5 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -3,7 +3,7 @@ # Testing string functions --disable_warnings -drop table if exists t1; +drop table if exists t1,t2; --enable_warnings set names latin1; @@ -244,7 +244,7 @@ select FIELD('b','A' COLLATE latin1_bin,'B'); select FIELD(_latin2'b','A','B'); --error 1270 select FIELD('b',_latin2'A','B'); -select FIELD('b',_latin2'A','B',1); +select FIELD('1',_latin2'3','2',1); select POSITION(_latin1'B' IN _latin1'abcd'); select POSITION(_latin1'B' IN _latin1'abcd' COLLATE latin1_bin); @@ -523,4 +523,3 @@ SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id ORDER BY t1.id; DROP TABLE t1, t2; - diff --git a/mysql-test/t/gis-rtree.test b/mysql-test/t/gis-rtree.test index 716dd38a119..da59c6ae5e4 100644 --- a/mysql-test/t/gis-rtree.test +++ b/mysql-test/t/gis-rtree.test @@ -120,7 +120,6 @@ INSERT INTO t1 (g) VALUES (GeomFromText('LineString(1 2, 2 3)')),(GeomFromText(' drop table t1; CREATE TABLE t1 ( - geoobjid INT NOT NULL, line LINESTRING NOT NULL, kind ENUM('po', 'pp', 'rr', 'dr', 'rd', 'ts', 'cl') NOT NULL DEFAULT 'po', name VARCHAR(32), diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 0bb83891fe2..34d9a09cba7 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -1,5 +1,8 @@ # Test of GRANT commands +# Grant tests not performed with embedded server +-- source include/not_embedded.inc + # Cleanup --disable_warnings drop table if exists t1; @@ -381,3 +384,22 @@ drop database mysqltest_2; # just SHOW PRIVILEGES test # SHOW PRIVILEGES; + +# +# Rights for renaming test (Bug #3270) +# +connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); +connection root; +--disable_warnings +create database mysqltest; +--enable_warnings +create table mysqltest.t1 (a int,b int,c int); +grant all on mysqltest.t1 to mysqltest_1@localhost; +connect (user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK); +connection user1; +-- error 1142 +alter table t1 rename t2; +connection root; +revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; +delete from mysql.user where user=_binary'mysqltest_1'; +drop database mysqltest; diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test index 3bda5716d26..07bd6d53c4e 100644 --- a/mysql-test/t/grant2.test +++ b/mysql-test/t/grant2.test @@ -1,3 +1,6 @@ +# Grant tests not performed with embedded server +-- source include/not_embedded.inc + SET NAMES binary; # diff --git a/mysql-test/t/grant3.test b/mysql-test/t/grant3.test index 1488f910bc8..115586e807d 100644 --- a/mysql-test/t/grant3.test +++ b/mysql-test/t/grant3.test @@ -1,3 +1,6 @@ +# Can't run with embedded server +-- source include/not_embedded.inc + # Test of GRANT commands SET NAMES binary; diff --git a/mysql-test/t/grant_cache.test b/mysql-test/t/grant_cache.test index 1ec4a52fdd1..1e24d5c9c03 100644 --- a/mysql-test/t/grant_cache.test +++ b/mysql-test/t/grant_cache.test @@ -1,3 +1,5 @@ +# Grant tests not performed with embedded server +-- source include/not_embedded.inc -- source include/have_query_cache.inc # diff --git a/mysql-test/t/heap.test b/mysql-test/t/heap.test index b69649585ff..68a84e1c193 100644 --- a/mysql-test/t/heap.test +++ b/mysql-test/t/heap.test @@ -34,7 +34,7 @@ select * from t1; drop table t1; create table t1 (a int not null) engine=heap; -insert into t1 values (869751),(736494),(226312),(802616); +insert into t1 values (869751),(736494),(226312),(802616),(728912); select * from t1 where a > 736494; alter table t1 add unique uniq_id(a); select * from t1 where a > 736494; @@ -280,14 +280,14 @@ explain select * from t1 where v='a'; select v,count(*) from t1 group by v limit 10; select v,count(t) from t1 group by v limit 10; select v,count(c) from t1 group by v limit 10; -select sql_big_result v,count(t) from t1 group by v limit 10; -select sql_big_result v,count(c) from t1 group by v limit 10; +select sql_big_result trim(v),count(t) from t1 group by v limit 10; +select sql_big_result trim(v),count(c) from t1 group by v limit 10; select c,count(*) from t1 group by c limit 10; select c,count(t) from t1 group by c limit 10; select sql_big_result c,count(t) from t1 group by c limit 10; select t,count(*) from t1 group by t limit 10; select t,count(t) from t1 group by t limit 10; -select sql_big_result t,count(t) from t1 group by t limit 10; +select sql_big_result trim(t),count(t) from t1 group by t limit 10; drop table t1; # @@ -413,25 +413,16 @@ eval set storage_engine=$default; create table t1 (a bigint unsigned auto_increment primary key, b int, key (b, a)) engine=heap; -insert t1 (b) values (1); -insert t1 (b) values (1); -insert t1 (b) values (1); -insert t1 (b) values (1); -insert t1 (b) values (1); -insert t1 (b) values (1); -insert t1 (b) values (1); -insert t1 (b) values (1); -select * from t1; +insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1); +select * from t1; drop table t1; + create table t1 (a int not null, b int not null auto_increment, primary key(a, b), key(b)) engine=heap; -insert t1 (a) values (1); -insert t1 (a) values (1); -insert t1 (a) values (1); -insert t1 (a) values (1); -insert t1 (a) values (1); -insert t1 (a) values (1); -insert t1 (a) values (1); -insert t1 (a) values (1); -select * from t1; +insert t1 (a) values (1),(1),(1),(1),(1),(1),(1),(1); +select * from t1; drop table t1; + +--error 1075 +create table t1 (a int not null, b int not null auto_increment, + primary key(a, b)) engine=heap; diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test index d156d059634..6fec2ac1703 100644 --- a/mysql-test/t/heap_btree.test +++ b/mysql-test/t/heap_btree.test @@ -34,7 +34,7 @@ select * from t1; drop table t1; create table t1 (a int not null) engine=heap; -insert into t1 values (869751),(736494),(226312),(802616); +insert into t1 values (869751),(736494),(226312),(802616),(728912); select * from t1 where a > 736494; alter table t1 add unique uniq_id using BTREE (a); select * from t1 where a > 736494; diff --git a/mysql-test/t/heap_hash.test b/mysql-test/t/heap_hash.test index 6d27f19dfad..46669dd2b8f 100644 --- a/mysql-test/t/heap_hash.test +++ b/mysql-test/t/heap_hash.test @@ -34,7 +34,7 @@ select * from t1; drop table t1; create table t1 (a int not null) engine=heap; -insert into t1 values (869751),(736494),(226312),(802616); +insert into t1 values (869751),(736494),(226312),(802616),(728912); select * from t1 where a > 736494; alter table t1 add unique uniq_id using HASH (a); select * from t1 where a > 736494; diff --git a/mysql-test/t/index_merge_ror.test b/mysql-test/t/index_merge_ror.test index 223bd241d96..5375f9d1a31 100644 --- a/mysql-test/t/index_merge_ror.test +++ b/mysql-test/t/index_merge_ror.test @@ -8,13 +8,13 @@ drop table if exists t0,t1,t2; create table t1 ( /* Field names reflect value(rowid) distribution, st=STairs, swt= SaWTooth */ - st_a int not null, - swt1a int not null, - swt2a int not null, + st_a int not null default 0, + swt1a int not null default 0, + swt2a int not null default 0, - st_b int not null, - swt1b int not null, - swt2b int not null, + st_b int not null default 0, + swt1b int not null default 0, + swt2b int not null default 0, /* fields/keys for row retrieval tests */ key1 int, diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index f4d47fa68aa..b4cc118c62f 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1,3 +1,5 @@ +# This test uses grants, which can't get tested for embedded server +-- source include/not_embedded.inc # Test for information_schema.schemata & # show databases @@ -15,13 +17,18 @@ show databases where `database` = 't%'; # Test for information_schema.tables & # show tables -create database testtets; -create table testtets.t1(a int, b VARCHAR(30), KEY string_data (b)); +create database mysqltest; +create table mysqltest.t1(a int, b VARCHAR(30), KEY string_data (b)); create table test.t2(a int); create table t3(a int, KEY a_data (a)); -create table testtets.t4(a int); +create table mysqltest.t4(a int); create view v1 (c) as select table_name from information_schema.TABLES; select * from v1; + +select c,table_name from v1 +inner join information_schema.TABLES v2 on (v1.c=v2.table_name) +where v1.c like "t%"; + select c,table_name from v1 left join information_schema.TABLES v2 on (v1.c=v2.table_name) where v1.c like "t%"; @@ -31,9 +38,9 @@ right join information_schema.TABLES v2 on (v1.c=v2.table_name) where v1.c like "t%"; select table_name from information_schema.TABLES -where table_schema = "testtets" and table_name like "t%"; +where table_schema = "mysqltest" and table_name like "t%"; -select * from information_schema.STATISTICS where TABLE_SCHEMA = "testtets"; +select * from information_schema.STATISTICS where TABLE_SCHEMA = "mysqltest"; show keys from t3 where Key_name = "a_data"; show tables like 't%'; @@ -44,11 +51,19 @@ show full columns from mysql.db like "Insert%"; show full columns from v1; select * from information_schema.COLUMNS where table_name="t1" and column_name= "a"; -show columns from testtets.t1 where field like "%a%"; +show columns from mysqltest.t1 where field like "%a%"; + +grant select (a) on mysqltest.t1 to mysqltest_2@localhost; +connect (user3,localhost,mysqltest_2,,); +connection user3; +select table_name, column_name, privileges from information_schema.columns +where table_schema = 'mysqltest' and table_name = 't1'; +show columns from mysqltest.t1; +connection default; drop view v1; -drop tables testtets.t4, testtets.t1, t2, t3; -drop database testtets; +drop tables mysqltest.t4, mysqltest.t1, t2, t3; +drop database mysqltest; # Test for information_schema.CHARACTER_SETS & # SHOW CHARACTER SET @@ -105,7 +120,6 @@ mysql.proc b where a.ROUTINE_NAME = convert(b.name using utf8); select count(*) from information_schema.ROUTINES; connect (user1,localhost,mysqltest_1,,); -connect (user3,localhost,mysqltest_2,,); connection user1; select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES; --error 1305 @@ -164,8 +178,8 @@ select * from information_schema.TABLE_PRIVILEGES where grantee like '%mysqltest select * from information_schema.COLUMN_PRIVILEGES where grantee like '%mysqltest_1%'; delete from mysql.user where user='mysqltest_1' or user='mysqltest_2'; delete from mysql.db where user='mysqltest_1' or user='mysqltest_2'; -delete from mysql.tables_priv where user='mysqltest_1'; -delete from mysql.columns_priv where user='mysqltest_1'; +delete from mysql.tables_priv where user='mysqltest_1' or user='mysqltest_2'; +delete from mysql.columns_priv where user='mysqltest_1' or user='mysqltest_2'; flush privileges; drop table t1; @@ -432,3 +446,21 @@ WHERE NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS B WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA AND A.TABLE_NAME = B.TABLE_NAME); + +# +# Bug #9344 INFORMATION_SCHEMA, wrong content, numeric columns +# + +create table t1 +( x_bigint BIGINT, + x_integer INTEGER, + x_smallint SMALLINT, + x_decimal DECIMAL(5,3), + x_numeric NUMERIC(5,3), + x_real REAL, + x_float FLOAT, + x_double_precision DOUBLE PRECISION ); +SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH +FROM INFORMATION_SCHEMA.COLUMNS +WHERE TABLE_NAME= 't1'; +drop table t1; diff --git a/mysql-test/t/innodb-big.test b/mysql-test/t/innodb-big.test new file mode 100644 index 00000000000..ade69ffdb45 --- /dev/null +++ b/mysql-test/t/innodb-big.test @@ -0,0 +1,46 @@ +# +# Test some things that takes a long time + +-- source include/big_test.inc +-- source include/have_innodb.inc + +--disable_warnings +DROP TABLE IF EXISTS t1, t2, t3, t4; +--enable_warnings + +# +# Test test how filesort and buffered-record-reads works with innodb +# + +CREATE TABLE t1 (id INTEGER) ENGINE=MYISAM; +CREATE TABLE t2 (id INTEGER primary key) ENGINE=INNODB; +CREATE TABLE t3 (a char(32) primary key,id INTEGER) ENGINE=INNODB; +CREATE TABLE t4 (a char(32) primary key,id INTEGER) ENGINE=MYISAM; + +INSERT INTO t1 (id) VALUES (1); +INSERT INTO t1 SELECT id+1 FROM t1; +INSERT INTO t1 SELECT id+2 FROM t1; +INSERT INTO t1 SELECT id+4 FROM t1; +INSERT INTO t1 SELECT id+8 FROM t1; +INSERT INTO t1 SELECT id+16 FROM t1; +INSERT INTO t1 SELECT id+32 FROM t1; +INSERT INTO t1 SELECT id+64 FROM t1; +INSERT INTO t1 SELECT id+128 FROM t1; +INSERT INTO t1 SELECT id+256 FROM t1; +INSERT INTO t1 SELECT id+512 FROM t1; +INSERT INTO t1 SELECT id+1024 FROM t1; +INSERT INTO t1 SELECT id+2048 FROM t1; +INSERT INTO t1 SELECT id+4096 FROM t1; +INSERT INTO t1 SELECT id+8192 FROM t1; +INSERT INTO t1 SELECT id+16384 FROM t1; +INSERT INTO t1 SELECT id+32768 FROM t1; +INSERT INTO t1 SELECT id+65536 FROM t1; +INSERT INTO t1 SELECT id+131072 FROM t1; +INSERT INTO t1 SELECT id+262144 FROM t1; +INSERT INTO t1 SELECT id+524288 FROM t1; +INSERT INTO t1 SELECT id+1048576 FROM t1; +INSERT INTO t2 SELECT * FROM t1; +INSERT INTO t3 SELECT concat(id),id from t2 ORDER BY -id; +INSERT INTO t4 SELECT * from t3 ORDER BY concat(a); +select sum(id) from t3; +drop table t1,t2,t3,t4; diff --git a/mysql-test/t/innodb-deadlock.test b/mysql-test/t/innodb-deadlock.test index 8a36982b0c1..7a7f657f35d 100644 --- a/mysql-test/t/innodb-deadlock.test +++ b/mysql-test/t/innodb-deadlock.test @@ -1,4 +1,6 @@ -- source include/have_innodb.inc +# Can't test this with embedded server +-- source include/not_embedded.inc connect (con1,localhost,root,,); connect (con2,localhost,root,,); diff --git a/mysql-test/t/innodb-lock.test b/mysql-test/t/innodb-lock.test index a3b6f8993f2..887a664e262 100644 --- a/mysql-test/t/innodb-lock.test +++ b/mysql-test/t/innodb-lock.test @@ -1,4 +1,6 @@ -- source include/have_innodb.inc +# Can't test this with embedded server +-- source include/not_embedded.inc # # Check and select innodb lock type diff --git a/mysql-test/t/innodb-replace.test b/mysql-test/t/innodb-replace.test new file mode 100644 index 00000000000..e7e96da1443 --- /dev/null +++ b/mysql-test/t/innodb-replace.test @@ -0,0 +1,17 @@ +-- source include/have_innodb.inc +# embedded server ignores 'delayed', so skip this +-- source include/not_embedded.inc + +# +# Bug #1078 +# +create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb; +select * from t1; +--error 1031 +replace delayed into t1 (c1, c2) values ( "text1","11"),( "text2","12"); +select * from t1; +--error 1031 +replace delayed into t1 (c1, c2) values ( "text1","12"),( "text2","13"),( "text3","14", "a" ),( "text4","15", "b" ); +select * from t1; +drop table t1; + diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index a6250c5041b..bd07d2220d2 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -1049,19 +1049,6 @@ SELECT t2.id, t1.`label` FROM t2 INNER JOIN ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object); drop table t1,t2; -# -# Bug #1078 -# -create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb; -select * from t1; ---error 1031 -replace delayed into t1 (c1, c2) values ( "text1","11"),( "text2","12"); -select * from t1; ---error 1031 -replace delayed into t1 (c1, c2) values ( "text1","12"),( "text2","13"),( "text3","14", "a" ),( "text4","15", "b" ); -select * from t1; -drop table t1; - create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=myisam; create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=innodb; create table t3 (a int, b varchar(200), c text not null) checksum=1 engine=innodb; @@ -1138,7 +1125,10 @@ show create table t2; drop table t2; # Test error handling ---replace_result \\ / + +# Clean up filename -- embedded server reports whole path without .frm, +# regular server reports relative path with .frm (argh!) +--replace_result \\ / $MYSQL_TEST_DIR . /var/master-data/ / t2.frm t2 --error 1005 create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb; @@ -1293,6 +1283,9 @@ source include/varchar.inc; # Some errors/warnings on create # +# Clean up filename -- embedded server reports whole path without .frm, +# regular server reports relative path with .frm (argh!) +--replace_result \\ / $MYSQL_TEST_DIR . /var/master-data/ / t1.frm t1 --error 1005 create table t1 (v varchar(65530), key(v)); create table t1 (v varchar(65536)); @@ -1307,8 +1300,3 @@ eval set storage_engine=$default; # InnoDB specific varchar tests create table t1 (v varchar(16384)) engine=innodb; drop table t1; - -# The following should be moved to type_bit.test when innodb will support it ---error 1178 -create table t1 (a bit, key(a)) engine=innodb; - diff --git a/mysql-test/t/insert_select-binlog.test b/mysql-test/t/insert_select-binlog.test new file mode 100644 index 00000000000..9bb1ec274ef --- /dev/null +++ b/mysql-test/t/insert_select-binlog.test @@ -0,0 +1,34 @@ +# Embedded server doesn't support binlog +-- source include/not_embedded.inc + +# Check if a partly-completed INSERT SELECT in a MyISAM table goes into the +# binlog + +create table t1(a int, unique(a)); +insert into t1 values(2); +create table t2(a int); +insert into t2 values(1),(2); +reset master; +--error 1062 +insert into t1 select * from t2; +# The above should produce an error, but still be in the binlog; +# verify the binlog : +let $VERSION=`select version()`; +--replace_result $VERSION VERSION +show binlog events; +select * from t1; +drop table t1, t2; + +# Verify that a partly-completed CREATE TABLE .. SELECT does not +# get into the binlog (Bug #6682) +create table t1(a int); +insert into t1 values(1),(1); +reset master; +--error 1062 +create table t2(unique(a)) select a from t1; +# The above should produce an error, *and* not appear in the binlog +let $VERSION=`select version()`; +--replace_result $VERSION VERSION +show binlog events; +drop table t1; + diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index 371df339b57..40dc4e20093 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -71,39 +71,6 @@ WHERE numeropost=9 ORDER BY numreponse ASC; DROP TABLE t1,t2; -# Check if a partly-completed INSERT SELECT in a MyISAM table goes -# into the binlog - -create table t1(a int, unique(a)); -insert into t1 values(2); -create table t2(a int); -insert into t2 values(1),(2); -reset master; ---error 1062 -insert into t1 select * from t2; -# The above should produce an error, but still be in the binlog; -# verify the binlog : -let $VERSION=`select version()`; ---replace_result $VERSION VERSION ---replace_column 2 # 5 # -show binlog events; -select * from t1; -drop table t1, t2; - -# Verify that a partly-completed CREATE TABLE .. SELECT does not -# get into the binlog (Bug #6682) -create table t1(a int); -insert into t1 values(1),(1); -reset master; ---error 1062 -create table t2(unique(a)) select a from t1; -# The above should produce an error, *and* not appear in the binlog -let $VERSION=`select version()`; ---replace_result $VERSION VERSION ---replace_column 2 # 5 # -show binlog events; -drop table t1; - # # Test of insert ... select from same table # diff --git a/mysql-test/t/isam.test b/mysql-test/t/isam.test deleted file mode 100644 index f77d29fd20f..00000000000 --- a/mysql-test/t/isam.test +++ /dev/null @@ -1,247 +0,0 @@ --- source include/have_isam.inc - ---disable_warnings -drop table if exists t1,t2; ---enable_warnings - -# -# Test possible problem with rows that are about 65535 bytes long -# - -create table t1 (a tinyint not null auto_increment, b blob not null, primary key (a)) engine=isam; - -let $1=100; -disable_query_log; ---disable_warnings -while ($1) -{ - eval insert into t1 (b) values(repeat(char(65+$1),65540-$1)); - dec $1; -} -enable_query_log; ---enable_warnings -delete from t1 where (a & 1); -select sum(length(b)) from t1; -drop table t1; - -# -# Test of auto_increment; The test for BDB tables is in bdb.test -# - -create table t1 (a int not null auto_increment,b int, primary key (a)) engine=isam; -insert into t1 values (1,1),(NULL,2),(3,3),(NULL,4); -delete from t1 where a=4 or a=2; -insert into t1 values (NULL,4),(NULL,5),(6,6); -select * from t1; -delete from t1 where a=6; -#show table status like "t1"; -replace t1 values (3,1); -replace t1 values (3,3); -ALTER TABLE t1 add c int; -insert into t1 values (NULL,6,6); -select * from t1; -drop table t1; - -# -# Test of some CREATE TABLE's that should fail -# ---error 1121 -create table t1 (a int,b text, index(a)) engine=isam; ---error 1073 -create table t1 (a int,b text, index(b)) engine=isam; ---error 1075 -create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) engine=isam; ---error 1121 -create table t1 (ordid int(8), unique (ordid)) engine=isam; -drop table if exists t1; - -# -# Test of some show commands -# - -create table t1 (a int not null primary key, b int not null,c int not null, key(b,c)); -insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4); -create table t2 engine=isam select * from t1; -optimize table t1; -check table t1,t2; -repair table t1,t2; -check table t2,t1; -lock tables t1 write; -check table t2,t1; -show columns from t1; -show full columns from t1; -show index from t1; -drop table t1,t2; - -# -# test of table with huge number of packed fields -# - -create table t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8 -int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, i17 -int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int, -i26 int, i27 int, i28 int, i29 int, i30 int, i31 int, i32 int, i33 int, i34 -int, i35 int, i36 int, i37 int, i38 int, i39 int, i40 int, i41 int, i42 int, -i43 int, i44 int, i45 int, i46 int, i47 int, i48 int, i49 int, i50 int, i51 -int, i52 int, i53 int, i54 int, i55 int, i56 int, i57 int, i58 int, i59 int, -i60 int, i61 int, i62 int, i63 int, i64 int, i65 int, i66 int, i67 int, i68 -int, i69 int, i70 int, i71 int, i72 int, i73 int, i74 int, i75 int, i76 int, -i77 int, i78 int, i79 int, i80 int, i81 int, i82 int, i83 int, i84 int, i85 -int, i86 int, i87 int, i88 int, i89 int, i90 int, i91 int, i92 int, i93 int, -i94 int, i95 int, i96 int, i97 int, i98 int, i99 int, i100 int, i101 int, i102 -int, i103 int, i104 int, i105 int, i106 int, i107 int, i108 int, i109 int, i110 -int, i111 int, i112 int, i113 int, i114 int, i115 int, i116 int, i117 int, i118 -int, i119 int, i120 int, i121 int, i122 int, i123 int, i124 int, i125 int, i126 -int, i127 int, i128 int, i129 int, i130 int, i131 int, i132 int, i133 int, i134 -int, i135 int, i136 int, i137 int, i138 int, i139 int, i140 int, i141 int, i142 -int, i143 int, i144 int, i145 int, i146 int, i147 int, i148 int, i149 int, i150 -int, i151 int, i152 int, i153 int, i154 int, i155 int, i156 int, i157 int, i158 -int, i159 int, i160 int, i161 int, i162 int, i163 int, i164 int, i165 int, i166 -int, i167 int, i168 int, i169 int, i170 int, i171 int, i172 int, i173 int, i174 -int, i175 int, i176 int, i177 int, i178 int, i179 int, i180 int, i181 int, i182 -int, i183 int, i184 int, i185 int, i186 int, i187 int, i188 int, i189 int, i190 -int, i191 int, i192 int, i193 int, i194 int, i195 int, i196 int, i197 int, i198 -int, i199 int, i200 int, i201 int, i202 int, i203 int, i204 int, i205 int, i206 -int, i207 int, i208 int, i209 int, i210 int, i211 int, i212 int, i213 int, i214 -int, i215 int, i216 int, i217 int, i218 int, i219 int, i220 int, i221 int, i222 -int, i223 int, i224 int, i225 int, i226 int, i227 int, i228 int, i229 int, i230 -int, i231 int, i232 int, i233 int, i234 int, i235 int, i236 int, i237 int, i238 -int, i239 int, i240 int, i241 int, i242 int, i243 int, i244 int, i245 int, i246 -int, i247 int, i248 int, i249 int, i250 int, i251 int, i252 int, i253 int, i254 -int, i255 int, i256 int, i257 int, i258 int, i259 int, i260 int, i261 int, i262 -int, i263 int, i264 int, i265 int, i266 int, i267 int, i268 int, i269 int, i270 -int, i271 int, i272 int, i273 int, i274 int, i275 int, i276 int, i277 int, i278 -int, i279 int, i280 int, i281 int, i282 int, i283 int, i284 int, i285 int, i286 -int, i287 int, i288 int, i289 int, i290 int, i291 int, i292 int, i293 int, i294 -int, i295 int, i296 int, i297 int, i298 int, i299 int, i300 int, i301 int, i302 -int, i303 int, i304 int, i305 int, i306 int, i307 int, i308 int, i309 int, i310 -int, i311 int, i312 int, i313 int, i314 int, i315 int, i316 int, i317 int, i318 -int, i319 int, i320 int, i321 int, i322 int, i323 int, i324 int, i325 int, i326 -int, i327 int, i328 int, i329 int, i330 int, i331 int, i332 int, i333 int, i334 -int, i335 int, i336 int, i337 int, i338 int, i339 int, i340 int, i341 int, i342 -int, i343 int, i344 int, i345 int, i346 int, i347 int, i348 int, i349 int, i350 -int, i351 int, i352 int, i353 int, i354 int, i355 int, i356 int, i357 int, i358 -int, i359 int, i360 int, i361 int, i362 int, i363 int, i364 int, i365 int, i366 -int, i367 int, i368 int, i369 int, i370 int, i371 int, i372 int, i373 int, i374 -int, i375 int, i376 int, i377 int, i378 int, i379 int, i380 int, i381 int, i382 -int, i383 int, i384 int, i385 int, i386 int, i387 int, i388 int, i389 int, i390 -int, i391 int, i392 int, i393 int, i394 int, i395 int, i396 int, i397 int, i398 -int, i399 int, i400 int, i401 int, i402 int, i403 int, i404 int, i405 int, i406 -int, i407 int, i408 int, i409 int, i410 int, i411 int, i412 int, i413 int, i414 -int, i415 int, i416 int, i417 int, i418 int, i419 int, i420 int, i421 int, i422 -int, i423 int, i424 int, i425 int, i426 int, i427 int, i428 int, i429 int, i430 -int, i431 int, i432 int, i433 int, i434 int, i435 int, i436 int, i437 int, i438 -int, i439 int, i440 int, i441 int, i442 int, i443 int, i444 int, i445 int, i446 -int, i447 int, i448 int, i449 int, i450 int, i451 int, i452 int, i453 int, i454 -int, i455 int, i456 int, i457 int, i458 int, i459 int, i460 int, i461 int, i462 -int, i463 int, i464 int, i465 int, i466 int, i467 int, i468 int, i469 int, i470 -int, i471 int, i472 int, i473 int, i474 int, i475 int, i476 int, i477 int, i478 -int, i479 int, i480 int, i481 int, i482 int, i483 int, i484 int, i485 int, i486 -int, i487 int, i488 int, i489 int, i490 int, i491 int, i492 int, i493 int, i494 -int, i495 int, i496 int, i497 int, i498 int, i499 int, i500 int, i501 int, i502 -int, i503 int, i504 int, i505 int, i506 int, i507 int, i508 int, i509 int, i510 -int, i511 int, i512 int, i513 int, i514 int, i515 int, i516 int, i517 int, i518 -int, i519 int, i520 int, i521 int, i522 int, i523 int, i524 int, i525 int, i526 -int, i527 int, i528 int, i529 int, i530 int, i531 int, i532 int, i533 int, i534 -int, i535 int, i536 int, i537 int, i538 int, i539 int, i540 int, i541 int, i542 -int, i543 int, i544 int, i545 int, i546 int, i547 int, i548 int, i549 int, i550 -int, i551 int, i552 int, i553 int, i554 int, i555 int, i556 int, i557 int, i558 -int, i559 int, i560 int, i561 int, i562 int, i563 int, i564 int, i565 int, i566 -int, i567 int, i568 int, i569 int, i570 int, i571 int, i572 int, i573 int, i574 -int, i575 int, i576 int, i577 int, i578 int, i579 int, i580 int, i581 int, i582 -int, i583 int, i584 int, i585 int, i586 int, i587 int, i588 int, i589 int, i590 -int, i591 int, i592 int, i593 int, i594 int, i595 int, i596 int, i597 int, i598 -int, i599 int, i600 int, i601 int, i602 int, i603 int, i604 int, i605 int, i606 -int, i607 int, i608 int, i609 int, i610 int, i611 int, i612 int, i613 int, i614 -int, i615 int, i616 int, i617 int, i618 int, i619 int, i620 int, i621 int, i622 -int, i623 int, i624 int, i625 int, i626 int, i627 int, i628 int, i629 int, i630 -int, i631 int, i632 int, i633 int, i634 int, i635 int, i636 int, i637 int, i638 -int, i639 int, i640 int, i641 int, i642 int, i643 int, i644 int, i645 int, i646 -int, i647 int, i648 int, i649 int, i650 int, i651 int, i652 int, i653 int, i654 -int, i655 int, i656 int, i657 int, i658 int, i659 int, i660 int, i661 int, i662 -int, i663 int, i664 int, i665 int, i666 int, i667 int, i668 int, i669 int, i670 -int, i671 int, i672 int, i673 int, i674 int, i675 int, i676 int, i677 int, i678 -int, i679 int, i680 int, i681 int, i682 int, i683 int, i684 int, i685 int, i686 -int, i687 int, i688 int, i689 int, i690 int, i691 int, i692 int, i693 int, i694 -int, i695 int, i696 int, i697 int, i698 int, i699 int, i700 int, i701 int, i702 -int, i703 int, i704 int, i705 int, i706 int, i707 int, i708 int, i709 int, i710 -int, i711 int, i712 int, i713 int, i714 int, i715 int, i716 int, i717 int, i718 -int, i719 int, i720 int, i721 int, i722 int, i723 int, i724 int, i725 int, i726 -int, i727 int, i728 int, i729 int, i730 int, i731 int, i732 int, i733 int, i734 -int, i735 int, i736 int, i737 int, i738 int, i739 int, i740 int, i741 int, i742 -int, i743 int, i744 int, i745 int, i746 int, i747 int, i748 int, i749 int, i750 -int, i751 int, i752 int, i753 int, i754 int, i755 int, i756 int, i757 int, i758 -int, i759 int, i760 int, i761 int, i762 int, i763 int, i764 int, i765 int, i766 -int, i767 int, i768 int, i769 int, i770 int, i771 int, i772 int, i773 int, i774 -int, i775 int, i776 int, i777 int, i778 int, i779 int, i780 int, i781 int, i782 -int, i783 int, i784 int, i785 int, i786 int, i787 int, i788 int, i789 int, i790 -int, i791 int, i792 int, i793 int, i794 int, i795 int, i796 int, i797 int, i798 -int, i799 int, i800 int, i801 int, i802 int, i803 int, i804 int, i805 int, i806 -int, i807 int, i808 int, i809 int, i810 int, i811 int, i812 int, i813 int, i814 -int, i815 int, i816 int, i817 int, i818 int, i819 int, i820 int, i821 int, i822 -int, i823 int, i824 int, i825 int, i826 int, i827 int, i828 int, i829 int, i830 -int, i831 int, i832 int, i833 int, i834 int, i835 int, i836 int, i837 int, i838 -int, i839 int, i840 int, i841 int, i842 int, i843 int, i844 int, i845 int, i846 -int, i847 int, i848 int, i849 int, i850 int, i851 int, i852 int, i853 int, i854 -int, i855 int, i856 int, i857 int, i858 int, i859 int, i860 int, i861 int, i862 -int, i863 int, i864 int, i865 int, i866 int, i867 int, i868 int, i869 int, i870 -int, i871 int, i872 int, i873 int, i874 int, i875 int, i876 int, i877 int, i878 -int, i879 int, i880 int, i881 int, i882 int, i883 int, i884 int, i885 int, i886 -int, i887 int, i888 int, i889 int, i890 int, i891 int, i892 int, i893 int, i894 -int, i895 int, i896 int, i897 int, i898 int, i899 int, i900 int, i901 int, i902 -int, i903 int, i904 int, i905 int, i906 int, i907 int, i908 int, i909 int, i910 -int, i911 int, i912 int, i913 int, i914 int, i915 int, i916 int, i917 int, i918 -int, i919 int, i920 int, i921 int, i922 int, i923 int, i924 int, i925 int, i926 -int, i927 int, i928 int, i929 int, i930 int, i931 int, i932 int, i933 int, i934 -int, i935 int, i936 int, i937 int, i938 int, i939 int, i940 int, i941 int, i942 -int, i943 int, i944 int, i945 int, i946 int, i947 int, i948 int, i949 int, i950 -int, i951 int, i952 int, i953 int, i954 int, i955 int, i956 int, i957 int, i958 -int, i959 int, i960 int, i961 int, i962 int, i963 int, i964 int, i965 int, i966 -int, i967 int, i968 int, i969 int, i970 int, i971 int, i972 int, i973 int, i974 -int, i975 int, i976 int, i977 int, i978 int, i979 int, i980 int, i981 int, i982 -int, i983 int, i984 int, i985 int, i986 int, i987 int, i988 int, i989 int, i990 -int, i991 int, i992 int, i993 int, i994 int, i995 int, i996 int, i997 int, i998 -int, i999 int, i1000 int, b blob) row_format=dynamic; -insert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "Sergei"); -update t1 set b=repeat('a',256); -update t1 set i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0; -check table t1; -drop table t1; diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index 38b5ef6151f..25344af55b4 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -651,4 +651,13 @@ SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE not(0+(t1.a=30 and t2.b=1)); DROP TABLE t1,t2; - +# Bug #8681: Bad warning message when group_concat() exceeds max length +set group_concat_max_len=5; +create table t1 (a int, b varchar(20)); +create table t2 (a int, c varchar(20)); +insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb"); +insert into t2 values (1,"cccccccccc"),(2,"dddddddddd"); +select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by t1.a; +select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by t1.a; +drop table t1, t2; +set group_concat_max_len=default; diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test index 8492a2a2f8e..37e11e14df5 100644 --- a/mysql-test/t/kill.test +++ b/mysql-test/t/kill.test @@ -23,13 +23,15 @@ connection con2; select ((@id := kill_id) - kill_id) from t1; kill @id; -# Wait for thread to do. ---sleep 5 -# verify that con1 is doning a reconnect connection con1; ---ping ---ping -select ((@id := kill_id) - kill_id) from t1; + +--disable_reconnect +# this statement should fail +--error 2006,2013 +select 1; +--enable_reconnect +# this should work, and we should have a new connection_id() +select ((@id := kill_id) - kill_id) from t1; select @id != connection_id(); #make sure the server is still alive diff --git a/mysql-test/t/limit.test b/mysql-test/t/limit.test index 28b287a5d4a..3dc56295375 100644 --- a/mysql-test/t/limit.test +++ b/mysql-test/t/limit.test @@ -6,7 +6,7 @@ drop table if exists t1; --enable_warnings -create table t1 (a int primary key, b int not null); +create table t1 (a int not null default 0 primary key, b int not null default 0); insert into t1 () values (); -- Testing default values insert into t1 values (1,1),(2,1),(3,1); update t1 set a=4 where b=1 limit 1; diff --git a/mysql-test/t/lowercase_table_grant.test b/mysql-test/t/lowercase_table_grant.test index 5ac35c81c21..3d6adb477a3 100644 --- a/mysql-test/t/lowercase_table_grant.test +++ b/mysql-test/t/lowercase_table_grant.test @@ -1,3 +1,6 @@ +# Don't test with embedded server +-- source include/not_embedded.inc + # Test of grants when lower_case_table_names is on use mysql; diff --git a/mysql-test/t/lowercase_view.test b/mysql-test/t/lowercase_view.test index 4b688cfb922..b39223f71d5 100644 --- a/mysql-test/t/lowercase_view.test +++ b/mysql-test/t/lowercase_view.test @@ -19,18 +19,109 @@ use test; # test of updating and fetching from the same table check # create table t1Aa (col1 int); -create table t2Aa (col1 int); -create view v1Aa as select * from t1Aa; -create view v2Aa as select * from v1Aa; +create table t2aA (col1 int); +create view v1Aa as select * from t1aA; +create view v2aA as select * from v1aA; +create view v3Aa as select v2Aa.col1 from v2aA,t2Aa where v2Aa.col1 = t2aA.col1; -- error 1093 -update v2aA set col1 = (select max(col1) from v1aA); -#update v2aA,t2aA set v2aA.col1 = (select max(col1) from v1aA) where v2aA.col1 = t2aA.col1; +update v2aA set col1 = (select max(col1) from v1Aa); -- error 1093 -delete from v2aA where col1 = (select max(col1) from v1aA); -#delete v2aA from v2aA,t2aA where (select max(col1) from v1aA) > 0 and v2aA.col1 = t2aA.col1; +update v2Aa set col1 = (select max(col1) from t1Aa); +-- error 1093 +update v2aA set col1 = (select max(col1) from v2Aa); +-- error 1093 +update v2aA,t2Aa set v2Aa.col1 = (select max(col1) from v1aA) where v2aA.col1 = t2aA.col1; +-- error 1093 +update t1aA,t2Aa set t1Aa.col1 = (select max(col1) from v1Aa) where t1aA.col1 = t2aA.col1; +-- error 1093 +update v1aA,t2Aa set v1Aa.col1 = (select max(col1) from v1aA) where v1Aa.col1 = t2aA.col1; +-- error 1093 +update t2Aa,v2Aa set v2aA.col1 = (select max(col1) from v1aA) where v2Aa.col1 = t2aA.col1; +-- error 1093 +update t2Aa,t1Aa set t1aA.col1 = (select max(col1) from v1Aa) where t1Aa.col1 = t2aA.col1; +-- error 1093 +update t2Aa,v1aA set v1Aa.col1 = (select max(col1) from v1aA) where v1Aa.col1 = t2aA.col1; +-- error 1093 +update v2aA,t2Aa set v2Aa.col1 = (select max(col1) from t1aA) where v2aA.col1 = t2aA.col1; +-- error 1093 +update t1Aa,t2Aa set t1aA.col1 = (select max(col1) from t1Aa) where t1aA.col1 = t2aA.col1; +-- error 1093 +update v1aA,t2Aa set v1Aa.col1 = (select max(col1) from t1Aa) where v1aA.col1 = t2aA.col1; +-- error 1093 +update t2Aa,v2Aa set v2aA.col1 = (select max(col1) from t1aA) where v2Aa.col1 = t2aA.col1; +-- error 1093 +update t2Aa,t1Aa set t1aA.col1 = (select max(col1) from t1Aa) where t1aA.col1 = t2aA.col1; +-- error 1093 +update t2Aa,v1Aa set v1aA.col1 = (select max(col1) from t1Aa) where v1Aa.col1 = t2aA.col1; +-- error 1093 +update v2aA,t2Aa set v2Aa.col1 = (select max(col1) from v2aA) where v2Aa.col1 = t2aA.col1; +-- error 1093 +update t1aA,t2Aa set t1Aa.col1 = (select max(col1) from v2aA) where t1aA.col1 = t2aA.col1; +-- error 1093 +update v1aA,t2Aa set v1Aa.col1 = (select max(col1) from v2Aa) where v1aA.col1 = t2aA.col1; +-- error 1093 +update t2Aa,v2aA set v2Aa.col1 = (select max(col1) from v2aA) where v2Aa.col1 = t2aA.col1; +-- error 1093 +update t2Aa,t1Aa set t1aA.col1 = (select max(col1) from v2aA) where t1Aa.col1 = t2aA.col1; +-- error 1093 +update t2Aa,v1Aa set v1aA.col1 = (select max(col1) from v2Aa) where v1Aa.col1 = t2aA.col1; +-- error 1093 +update v3aA set v3Aa.col1 = (select max(col1) from v1aA); +-- error 1093 +update v3aA set v3Aa.col1 = (select max(col1) from t1aA); +-- error 1093 +update v3aA set v3Aa.col1 = (select max(col1) from v2aA); +-- error 1093 +update v3aA set v3Aa.col1 = (select max(col1) from v3aA); +-- error 1093 +delete from v2Aa where col1 = (select max(col1) from v1Aa); +-- error 1093 +delete from v2aA where col1 = (select max(col1) from t1Aa); +-- error 1093 +delete from v2Aa where col1 = (select max(col1) from v2aA); +-- error 1093 +delete v2Aa from v2aA,t2Aa where (select max(col1) from v1aA) > 0 and v2Aa.col1 = t2aA.col1; +-- error 1093 +delete t1aA from t1Aa,t2Aa where (select max(col1) from v1Aa) > 0 and t1aA.col1 = t2aA.col1; +-- error 1093 +delete v1aA from v1Aa,t2Aa where (select max(col1) from v1aA) > 0 and v1Aa.col1 = t2aA.col1; +-- error 1093 +delete v2aA from v2Aa,t2Aa where (select max(col1) from t1Aa) > 0 and v2aA.col1 = t2aA.col1; +-- error 1093 +delete t1aA from t1Aa,t2Aa where (select max(col1) from t1aA) > 0 and t1Aa.col1 = t2aA.col1; +-- error 1093 +delete v1aA from v1Aa,t2Aa where (select max(col1) from t1aA) > 0 and v1aA.col1 = t2aA.col1; +-- error 1093 +delete v2Aa from v2aA,t2Aa where (select max(col1) from v2Aa) > 0 and v2aA.col1 = t2aA.col1; +-- error 1093 +delete t1Aa from t1aA,t2Aa where (select max(col1) from v2Aa) > 0 and t1Aa.col1 = t2aA.col1; +-- error 1093 +delete v1Aa from v1aA,t2Aa where (select max(col1) from v2aA) > 0 and v1Aa.col1 = t2aA.col1; +-- error 1093 +insert into v2Aa values ((select max(col1) from v1aA)); +-- error 1093 +insert into t1aA values ((select max(col1) from v1Aa)); -- error 1093 insert into v2aA values ((select max(col1) from v1aA)); -drop view v2Aa,v1Aa; +-- error 1093 +insert into v2Aa values ((select max(col1) from t1Aa)); +-- error 1093 +insert into t1aA values ((select max(col1) from t1Aa)); +-- error 1093 +insert into v2aA values ((select max(col1) from t1aA)); +-- error 1093 +insert into v2Aa values ((select max(col1) from v2aA)); +-- error 1093 +insert into t1Aa values ((select max(col1) from v2Aa)); +-- error 1093 +insert into v2aA values ((select max(col1) from v2Aa)); +-- error 1093 +insert into v3Aa (col1) values ((select max(col1) from v1Aa)); +-- error 1093 +insert into v3aA (col1) values ((select max(col1) from t1aA)); +-- error 1093 +insert into v3Aa (col1) values ((select max(col1) from v2aA)); +drop view v3aA,v2Aa,v1aA; drop table t1Aa,t2Aa; # diff --git a/mysql-test/t/mix_innodb_myisam_binlog.test b/mysql-test/t/mix_innodb_myisam_binlog.test index 9894359dfc0..0641acb552f 100644 --- a/mysql-test/t/mix_innodb_myisam_binlog.test +++ b/mysql-test/t/mix_innodb_myisam_binlog.test @@ -5,6 +5,9 @@ # did some tests manually on a slave; tables are replicated fine and # Exec_Master_Log_Pos advances as expected. +# Embedded server doesn't support binlogging +-- source include/not_embedded.inc + -- source include/have_innodb.inc --disable_warnings @@ -26,7 +29,7 @@ insert into t2 select * from t1; commit; --replace_column 5 # ---replace_result "xid=12" "xid=7" +--replace_result "xid=15" "xid=8" show binlog events from 98; delete from t1; @@ -55,7 +58,7 @@ rollback to savepoint my_savepoint; commit; --replace_column 5 # ---replace_result "xid=45" "xid=24" +--replace_result "xid=48" "xid=25" show binlog events from 98; delete from t1; @@ -73,7 +76,7 @@ commit; select a from t1 order by a; # check that savepoints work :) --replace_column 5 # ---replace_result "xid=67" "xid=36" +--replace_result "xid=70" "xid=37" show binlog events from 98; # and when ROLLBACK is not explicit? @@ -106,7 +109,7 @@ insert into t1 values(9); insert into t2 select * from t1; --replace_column 5 # ---replace_result "xid=116" "xid=59" +--replace_result "xid=119" "xid=60" show binlog events from 98; # Check that when the query updat1ng the MyISAM table is the first in the @@ -119,13 +122,13 @@ insert into t1 values(10); # first make t1 non-empty begin; insert into t2 select * from t1; --replace_column 5 # ---replace_result "xid=130" "xid=65" +--replace_result "xid=133" "xid=66" show binlog events from 98; insert into t1 values(11); commit; --replace_column 5 # ---replace_result "xid=130" "xid=65" "xid=133" "xid=67" +--replace_result "xid=133" "xid=66" "xid=136" "xid=68" show binlog events from 98; @@ -144,7 +147,7 @@ insert into t2 select * from t1; commit; --replace_column 5 # ---replace_result "xid=152" "xid=77" +--replace_result "xid=155" "xid=78" show binlog events from 98; delete from t1; @@ -172,7 +175,7 @@ rollback to savepoint my_savepoint; commit; --replace_column 5 # ---replace_result "xid=184" "xid=93" +--replace_result "xid=187" "xid=94" show binlog events from 98; delete from t1; @@ -190,7 +193,7 @@ commit; select a from t1 order by a; # check that savepoints work :) --replace_column 5 # ---replace_result "xid=205" "xid=104" +--replace_result "xid=208" "xid=105" show binlog events from 98; # Test for BUG#5714, where a MyISAM update in the transaction used to diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index f3b6216e3cf..0ca42e86204 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -2,6 +2,9 @@ # Test of update statement that uses many tables. # +# Requires grants, so won't work with embedded server test +-- source include/not_embedded.inc + --disable_warnings drop table if exists t1,t2,t3; drop database if exists mysqltest; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 3fd69a24903..2b60e85fcc6 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -553,6 +553,16 @@ truncate table t1; insert into t1 values (1); drop table t1,t2; +# +# bug9188 - Corruption Can't open file: 'table.MYI' (errno: 145) +# +create table t1 (c1 int, c2 varchar(4) not null default '', + key(c2(3))) default charset=utf8; +insert into t1 values (1,'A'), (2, 'B'), (3, 'A'); +update t1 set c2='A B' where c1=2; +check table t1; +drop table t1; + # # Test varchar # diff --git a/mysql-test/t/mysql_protocols.test b/mysql-test/t/mysql_protocols.test index e5158586124..6e2d4f20429 100644 --- a/mysql-test/t/mysql_protocols.test +++ b/mysql-test/t/mysql_protocols.test @@ -1,3 +1,5 @@ +# Embedded server doesn't support external clients +--source include/not_embedded.inc # test for Bug #4998 "--protocol doesn't reject bad values" diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 0988416942c..49b8237d99f 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -1,5 +1,8 @@ # We are using .opt file since we need small binlog size +# Embedded server doesn't support binlogging +-- source include/not_embedded.inc + # we need this for getting fixed timestamps inside of this test set timestamp=1000000000; diff --git a/mysql-test/t/mysqlbinlog2.test b/mysql-test/t/mysqlbinlog2.test index cbde6c93210..6e2eda07695 100644 --- a/mysql-test/t/mysqlbinlog2.test +++ b/mysql-test/t/mysqlbinlog2.test @@ -1,6 +1,9 @@ # Test for the new options --start-datetime, stop-datetime, # and a few others. +# Embedded server doesn't support binlogging +-- source include/not_embedded.inc + --disable_warnings drop table if exists t1; --enable_warnings diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 7264e6bbc3e..ca883f5c4d2 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1,3 +1,6 @@ +# Embedded server doesn't support external clients +--source include/not_embedded.inc + --disable_warnings DROP TABLE IF EXISTS t1, `"t"1`, t1aa, t2, t2aa; drop database if exists mysqldump_test_db; diff --git a/mysql-test/t/mysqlshow.test b/mysql-test/t/mysqlshow.test index 8da29b91819..33ae8aef9a0 100644 --- a/mysql-test/t/mysqlshow.test +++ b/mysql-test/t/mysqlshow.test @@ -1,3 +1,6 @@ +# Can't run test of external client with embedded server +-- source include/not_embedded.inc + # ## Bug #5036 mysqlshow is missing a column # diff --git a/mysql-test/t/ndb_alter_table.test b/mysql-test/t/ndb_alter_table.test index 2edb358d386..18c7ff47b18 100644 --- a/mysql-test/t/ndb_alter_table.test +++ b/mysql-test/t/ndb_alter_table.test @@ -147,7 +147,7 @@ select * from t1 where b = 'two'; connection server1; alter table t1 drop index c; connection server2; ---error 1146 +--error 1412 select * from t1 where b = 'two'; select * from t1 where b = 'two'; connection server1; diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index a6064f30556..5dfc2d5ec58 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -577,3 +577,30 @@ create table t1 engine=ndb max_rows=1; drop table t1; + +# +# Test auto_increment +# + +connect (con1,localhost,,,test); +connect (con2,localhost,,,test); + +create table t1 + (counter int(64) NOT NULL auto_increment, + datavalue char(40) default 'XXXX', + primary key (counter) + ) ENGINE=ndbcluster; + +connection con1; +insert into t1 (datavalue) values ('newval'); +insert into t1 (datavalue) values ('newval'); +select * from t1 order by counter; +insert into t1 (datavalue) select datavalue from t1 where counter < 100; +insert into t1 (datavalue) select datavalue from t1 where counter < 100; +select * from t1 order by counter; +connection con2; +insert into t1 (datavalue) select datavalue from t1 where counter < 100; +insert into t1 (datavalue) select datavalue from t1 where counter < 100; +select * from t1 order by counter; + +drop table t1; diff --git a/mysql-test/t/ndb_condition_pushdown.test b/mysql-test/t/ndb_condition_pushdown.test index 540e018ad04..0ada161b813 100644 --- a/mysql-test/t/ndb_condition_pushdown.test +++ b/mysql-test/t/ndb_condition_pushdown.test @@ -954,6 +954,65 @@ bin not like concat(0xBB, '%') and vbin not like concat(0xBB, '%') order by auto; +# Update test +update t1 +set medium = 17 +where +string = "aaaa" and +vstring = "aaaa" and +bin = 0xAAAA and +vbin = 0xAAAA and +tiny = -1 and +short = -1 and +medium = -1 and +long_int = -1 and +longlong = -1 and +real_float > 1.0 and real_float < 2.0 and +real_double > 1.0 and real_double < 2.0 and +real_decimal > 1.0 and real_decimal < 2.0 and +utiny = 1 and +ushort = 1 and +umedium = 1 and +ulong = 1 and +ulonglong = 1 and +/* bits = b'001' and */ +options = 'one' and +flags = 'one' and +date_field = '1901-01-01' and +year_field = '1901' and +time_field = '01:01:01' and +date_time = '1901-01-01 01:01:01'; + +# Delete test +delete from t1 +where +string = "aaaa" and +vstring = "aaaa" and +bin = 0xAAAA and +vbin = 0xAAAA and +tiny = -1 and +short = -1 and +medium = 17 and +long_int = -1 and +longlong = -1 and +real_float > 1.0 and real_float < 2.0 and +real_double > 1.0 and real_double < 2.0 and +real_decimal > 1.0 and real_decimal < 2.0 and +utiny = 1 and +ushort = 1 and +umedium = 1 and +ulong = 1 and +ulonglong = 1 and +/* bits = b'001' and */ +options = 'one' and +flags = 'one' and +date_field = '1901-01-01' and +year_field = '1901' and +time_field = '01:01:01' and +date_time = '1901-01-01 01:01:01'; + +select count(*) from t1; + # Various tests explain select * from t2 where attr3 is null or attr1 > 2 and pk1= 3 order by pk1; diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test index 2fc7c496fea..6714f0233cf 100644 --- a/mysql-test/t/ndb_index_unique.test +++ b/mysql-test/t/ndb_index_unique.test @@ -182,8 +182,8 @@ INSERT INTO t3 VALUES (1,'V1',NULL); CREATE TABLE t4 ( uid bigint(20) unsigned NOT NULL default '0', gid bigint(20) unsigned NOT NULL, - rid bigint(20) unsigned NOT NULL default '-1', - cid bigint(20) unsigned NOT NULL default '-1', + rid bigint(20) unsigned NOT NULL, + cid bigint(20) unsigned NOT NULL, UNIQUE KEY m (uid,gid,rid,cid) ) engine=ndbcluster; INSERT INTO t4 VALUES (1,1,2,4); @@ -209,8 +209,8 @@ CREATE TABLE t7 ( mid bigint(20) unsigned NOT NULL PRIMARY KEY, uid bigint(20) unsigned NOT NULL default '0', gid bigint(20) unsigned NOT NULL, - rid bigint(20) unsigned NOT NULL default '-1', - cid bigint(20) unsigned NOT NULL default '-1', + rid bigint(20) unsigned NOT NULL, + cid bigint(20) unsigned NOT NULL, UNIQUE KEY m (uid,gid,rid,cid) ) engine=ndbcluster; INSERT INTO t7 VALUES(1, 1, 1, 1, 1); diff --git a/mysql-test/t/ndb_multi.test b/mysql-test/t/ndb_multi.test index 9286721b677..27ddd6508e9 100644 --- a/mysql-test/t/ndb_multi.test +++ b/mysql-test/t/ndb_multi.test @@ -40,5 +40,7 @@ show status like 'handler_discover%'; show tables; drop table t1, t2, t3, t4; +connection server2; +drop table t1, t3, t4; diff --git a/mysql-test/t/ndb_types.test b/mysql-test/t/ndb_types.test index d9f50c8b3fc..823ca942d57 100644 --- a/mysql-test/t/ndb_types.test +++ b/mysql-test/t/ndb_types.test @@ -7,10 +7,12 @@ DROP TABLE IF EXISTS t1; # # Test creation of different column types in NDB # - CREATE TABLE t1 ( auto int(5) unsigned NOT NULL auto_increment, string char(10) default "hello", + vstring varchar(10) default "hello", + bin binary(7), + vbin varbinary(7), tiny tinyint(4) DEFAULT '0' NOT NULL , short smallint(6) DEFAULT '1' NOT NULL , medium mediumint(8) DEFAULT '0' NOT NULL, @@ -18,17 +20,20 @@ CREATE TABLE t1 ( longlong bigint(13) DEFAULT '0' NOT NULL, real_float float(13,1) DEFAULT 0.0 NOT NULL, real_double double(16,4), + real_decimal decimal(16,4), utiny tinyint(3) unsigned DEFAULT '0' NOT NULL, ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL, umedium mediumint(8) unsigned DEFAULT '0' NOT NULL, ulong int(11) unsigned DEFAULT '0' NOT NULL, ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL, - time_stamp timestamp, - date_field date, - time_field time, - date_time datetime, + bits bit(3), options enum('one','two','tree') not null, flags set('one','two','tree') not null, + date_field date, + year_field year, + time_field time, + date_time datetime, + time_stamp timestamp not null default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, PRIMARY KEY (auto), KEY (utiny), KEY (tiny), @@ -43,5 +48,35 @@ CREATE TABLE t1 ( KEY (options,flags) ); +set @now = now(); +sleep 1; +insert into t1 +(string,vstring,bin,vbin,tiny,short,medium,long_int,longlong, + real_float,real_double, real_decimal,utiny, ushort, umedium,ulong,ulonglong, + bits,options,flags,date_field,year_field,time_field,date_time) +values +("aaaa","aaaa",0xAAAA,0xAAAA,-1,-1,-1,-1,-1,1.1,1.1,1.1,1,1,1,1,1, + b'001','one','one', '1901-01-01','1901','01:01:01','1901-01-01 01:01:01'); + +select auto,string,vstring,bin,vbin,tiny,short,medium,long_int,longlong, + real_float,real_double,real_decimal,utiny,ushort,umedium,ulong,ulonglong, + bits,options,flags,date_field,year_field,time_field,date_time +from t1; +select time_stamp>@now from t1; + +set @now = now(); +sleep 1; +update t1 set string="bbbb",vstring="bbbb",bin=0xBBBB,vbin=0xBBBB, +tiny=-2,short=-2,medium=-2,long_int=-2,longlong=-2,real_float=2.2, +real_double=2.2,real_decimal=2.2,utiny=2,ushort=2,umedium=2,ulong=2, +ulonglong=2, bits=b'010', +options='one',flags='one', date_field='1902-02-02',year_field='1902', +time_field='02:02:02',date_time='1902-02-02 02:02:02' where auto=1; + +select auto,string,vstring,bin,vbin,tiny,short,medium,long_int,longlong, + real_float,real_double,real_decimal,utiny,ushort,umedium,ulong,ulonglong, + bits,options,flags,date_field,year_field,time_field,date_time +from t1; +select time_stamp>@now from t1; drop table t1; diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test index 4bc6a4f051a..4cd20979319 100644 --- a/mysql-test/t/null.test +++ b/mysql-test/t/null.test @@ -59,7 +59,7 @@ drop table t1; # # Test inserting and updating with NULL # -CREATE TABLE t1 (a varchar(16) NOT NULL, b smallint(6) NOT NULL, c datetime NOT NULL, d smallint(6) NOT NULL); +CREATE TABLE t1 (a varchar(16) NOT NULL default '', b smallint(6) NOT NULL default 0, c datetime NOT NULL default '0000-00-00 00:00:00', d smallint(6) NOT NULL default 0); INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55"; UPDATE t1 SET d=1/NULL; UPDATE t1 SET d=NULL; diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 9608b7900ee..36eee6e43b7 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -206,7 +206,7 @@ CREATE TABLE t1 ( favo_tv varchar(50) NOT NULL default '', favo_eten varchar(50) NOT NULL default '', favo_muziek varchar(30) NOT NULL default '', - info text NOT NULL, + info text NOT NULL default '', ipnr varchar(30) NOT NULL default '', PRIMARY KEY (member_id) ) ENGINE=MyISAM PACK_KEYS=1; diff --git a/mysql-test/t/packet.test b/mysql-test/t/packet.test index cbeaa04ca52..c7f10d75d74 100644 --- a/mysql-test/t/packet.test +++ b/mysql-test/t/packet.test @@ -1,3 +1,5 @@ +# Embedded server doesn't support external clients +--source include/not_embedded.inc # # Check protocol handling diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 1af84119b79..820fae12db0 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -540,3 +540,50 @@ deallocate prepare stmt; drop table t1,t2; + +# +# Bug#9383: INFORMATION_SCHEMA.COLUMNS, JOIN, Crash, prepared statement +# + +eval SET @aux= "SELECT COUNT(*) + FROM INFORMATION_SCHEMA.COLUMNS A, + INFORMATION_SCHEMA.COLUMNS B + WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA + AND A.TABLE_NAME = B.TABLE_NAME + AND A.COLUMN_NAME = B.COLUMN_NAME AND + A.TABLE_NAME = 'user'"; + +let $exec_loop_count= 3; +eval prepare my_stmt from @aux; +while ($exec_loop_count) +{ + eval execute my_stmt; + dec $exec_loop_count; +} +deallocate prepare my_stmt; + +# Test CALL in prepared mode +delimiter |; +--disable_warnings +drop procedure if exists p1| +drop table if exists t1| +--enable_warnings +create table t1 (id int)| +insert into t1 values(1)| +create procedure p1(a int, b int) +begin + declare c int; + select max(id)+1 into c from t1; + insert into t1 select a+b; + insert into t1 select a-b; + insert into t1 select a-c; +end| +set @a= 3, @b= 4| +prepare stmt from "call p1(?, ?)"| +execute stmt using @a, @b| +execute stmt using @a, @b| +select * from t1| +deallocate prepare stmt| +drop procedure p1| +drop table t1| +delimiter ;| diff --git a/mysql-test/t/ps_1general.test b/mysql-test/t/ps_1general.test index 22a4a8bf2c9..1fa9d30eaba 100644 --- a/mysql-test/t/ps_1general.test +++ b/mysql-test/t/ps_1general.test @@ -330,9 +330,6 @@ prepare stmt4 from ' show engine bdb logs '; --disable_result_log execute stmt4; --enable_result_log -prepare stmt4 from ' show full processlist '; ---replace_column 1 number 6 time 3 localhost -execute stmt4; prepare stmt4 from ' show grants for user '; --error 1295 prepare stmt4 from ' show create table t2 '; @@ -439,20 +436,6 @@ create database mysqltest ; prepare stmt3 from ' drop database mysqltest '; drop database mysqltest ; -## grant/revoke + drop user ---error 1295 -prepare stmt3 from ' grant all on test.t1 to drop_user@localhost -identified by ''looser'' '; -grant all on test.t1 to drop_user@localhost -identified by 'looser' ; ---error 1295 -prepare stmt3 from ' revoke all privileges on test.t1 from -drop_user@localhost '; -revoke all privileges on test.t1 from drop_user@localhost ; ---error 1295 -prepare stmt3 from ' drop user drop_user@localhost '; -drop user drop_user@localhost; - #### table related commands ## describe prepare stmt3 from ' describe t2 '; @@ -500,10 +483,10 @@ select 'a' || 'b' ; prepare stmt4 from ' SET sql_mode="" '; execute stmt4; # check if the sql_mode is not ansi -select 'a' || 'b' ; +select '2' || '3' ; # Will a switch of the sqlmode affect the execution of already prepared # statements ? -prepare stmt5 from ' select ''a'' || ''b'' ' ; +prepare stmt5 from ' select ''2'' || ''3'' ' ; execute stmt5; SET sql_mode=ansi; execute stmt5; @@ -608,7 +591,8 @@ drop table t2; prepare stmt1 from ' rename table t5 to t6, t7 to t8 ' ; create table t5 (a int) ; # rename must fail, t7 does not exist ---replace_result \\ / +# Clean up the filename here because embedded server reports whole path +--replace_result \\ / $MYSQL_TEST_DIR . /var/master-data/ / t7.frm t7 --error 1017 execute stmt1 ; create table t7 (a int) ; @@ -851,117 +835,6 @@ execute stmt1 ; drop table t5 ; - -################ GRANT/REVOKE/DROP affecting a parallel session ################ ---disable_query_log -select '------ grant/revoke/drop affects a parallel session test ------' - as test_sequence ; ---enable_query_log - -#---------------------------------------------------------------------# -# Here we test that: -# 1. A new GRANT will be visible within another sessions. # -# # -# Let's assume there is a parallel session with an already prepared # -# statement for a table. # -# A DROP TABLE will affect the EXECUTE properties. # -# A REVOKE will affect the EXECUTE properties. # -#---------------------------------------------------------------------# - -# Who am I ? -# this is different across different systems: -# select current_user(), user() ; - -#### create a new user account #### -## There should be no grants for that non existing user ---error 1141 -show grants for second_user@localhost ; -## create a new user account by using GRANT statements on t9 -create database mysqltest; -# create the tables (t1 and t9) used in many tests -use mysqltest; ---disable_query_log ---source include/ps_create.inc ---source include/ps_renew.inc ---enable_query_log -eval use $DB; -grant usage on mysqltest.* to second_user@localhost -identified by 'looser' ; -grant select on mysqltest.t9 to second_user@localhost -identified by 'looser' ; -show grants for second_user@localhost ; - - -#### establish a second session to the new user account -connect (con3,localhost,second_user,looser,mysqltest); -## switch to the second session -connection con3; -# Who am I ? -select current_user(); -## check the access rights -show grants for current_user(); -prepare s_t9 from 'select c1 as my_col - from t9 where c1= 1' ; -execute s_t9 ; -# check that we cannot do a SELECT on the table t1; ---error 1142 -select a as my_col from t1; - - -#### give access rights to t1 and drop table t9 -## switch back to the first session -connection default; -grant select on mysqltest.t1 to second_user@localhost -identified by 'looser' ; -show grants for second_user@localhost ; -drop table mysqltest.t9 ; -show grants for second_user@localhost ; - - -#### check the access as new user -## switch to the second session -connection con3; -######## Question 1: The table t1 should be now accessible. ######## -show grants for second_user@localhost ; -prepare s_t1 from 'select a as my_col from t1' ; -execute s_t1 ; -######## Question 2: The table t9 does not exist. ######## ---error 1146 -execute s_t9 ; - - -#### revoke the access rights to t1 -## switch back to the first session -connection default; -revoke all privileges on mysqltest.t1 from second_user@localhost -identified by 'looser' ; -show grants for second_user@localhost ; - -#### check the access as new user -## switch to the second session -connection con3; -show grants for second_user@localhost ; -######## Question 2: The table t1 should be now not accessible. ######## ---error 1142 -execute s_t1 ; - -## cleanup -## switch back to the first session -connection default; -## disconnect the second session -disconnect con3 ; -## remove all rights of second_user@localhost -revoke all privileges, grant option from second_user@localhost ; -show grants for second_user@localhost ; -drop user second_user@localhost ; -commit ; ---error 1141 -show grants for second_user@localhost ; - -drop table t1,t9 ; -drop database mysqltest; - - ##### RULES OF THUMB TO PRESERVE THE SYSTEMATICS OF THE PS TEST CASES ##### # # 0. You don't have the time to diff --git a/mysql-test/t/ps_grant.test b/mysql-test/t/ps_grant.test new file mode 100644 index 00000000000..07bd70f6cff --- /dev/null +++ b/mysql-test/t/ps_grant.test @@ -0,0 +1,132 @@ +# Can't test grants with embedded server +-- source include/not_embedded.inc + +# Tested here simply so it is not tested with embedded server +prepare stmt4 from ' show full processlist '; +--replace_column 1 number 6 time 3 localhost +execute stmt4; + +let $type= 'MYISAM' ; + +################ GRANT/REVOKE/DROP affecting a parallel session ################ +--disable_query_log +select '------ grant/revoke/drop affects a parallel session test ------' + as test_sequence ; +--enable_query_log + +#---------------------------------------------------------------------# +# Here we test that: +# 1. A new GRANT will be visible within another sessions. # +# # +# Let's assume there is a parallel session with an already prepared # +# statement for a table. # +# A DROP TABLE will affect the EXECUTE properties. # +# A REVOKE will affect the EXECUTE properties. # +#---------------------------------------------------------------------# + +# Who am I ? +# this is different across different systems: +# select current_user(), user() ; + +#### create a new user account #### +## There should be no grants for that non existing user +--error 1141 +show grants for second_user@localhost ; +## create a new user account by using GRANT statements on t9 +create database mysqltest; +# create the tables (t1 and t9) used in many tests +use mysqltest; +--disable_query_log +--source include/ps_create.inc +--source include/ps_renew.inc +--enable_query_log +eval use $DB; +grant usage on mysqltest.* to second_user@localhost +identified by 'looser' ; +grant select on mysqltest.t9 to second_user@localhost +identified by 'looser' ; +show grants for second_user@localhost ; + + +#### establish a second session to the new user account +connect (con3,localhost,second_user,looser,mysqltest); +## switch to the second session +connection con3; +# Who am I ? +select current_user(); +## check the access rights +show grants for current_user(); +prepare s_t9 from 'select c1 as my_col + from t9 where c1= 1' ; +execute s_t9 ; +# check that we cannot do a SELECT on the table t1; +--error 1142 +select a as my_col from t1; + + +#### give access rights to t1 and drop table t9 +## switch back to the first session +connection default; +grant select on mysqltest.t1 to second_user@localhost +identified by 'looser' ; +show grants for second_user@localhost ; +drop table mysqltest.t9 ; +show grants for second_user@localhost ; + + +#### check the access as new user +## switch to the second session +connection con3; +######## Question 1: The table t1 should be now accessible. ######## +show grants for second_user@localhost ; +prepare s_t1 from 'select a as my_col from t1' ; +execute s_t1 ; +######## Question 2: The table t9 does not exist. ######## +--error 1146 +execute s_t9 ; + + +#### revoke the access rights to t1 +## switch back to the first session +connection default; +revoke all privileges on mysqltest.t1 from second_user@localhost +identified by 'looser' ; +show grants for second_user@localhost ; + +#### check the access as new user +## switch to the second session +connection con3; +show grants for second_user@localhost ; +######## Question 2: The table t1 should be now not accessible. ######## +--error 1142 +execute s_t1 ; + +## cleanup +## switch back to the first session +connection default; +## disconnect the second session +disconnect con3 ; +## remove all rights of second_user@localhost +revoke all privileges, grant option from second_user@localhost ; +show grants for second_user@localhost ; +drop user second_user@localhost ; +commit ; +--error 1141 +show grants for second_user@localhost ; + +drop database mysqltest; + +## grant/revoke + drop user +--error 1295 +prepare stmt3 from ' grant all on test.t1 to drop_user@localhost +identified by ''looser'' '; +grant all on test.t1 to drop_user@localhost +identified by 'looser' ; +--error 1295 +prepare stmt3 from ' revoke all privileges on test.t1 from +drop_user@localhost '; +revoke all privileges on test.t1 from drop_user@localhost ; +--error 1295 +prepare stmt3 from ' drop user drop_user@localhost '; +drop user drop_user@localhost; + diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index 6a3d22d2695..475ba466ea9 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -184,6 +184,7 @@ select LAST_INSERT_ID() from t1; select RAND() from t1; select UNIX_TIMESTAMP() from t1; select USER() from t1; +select CURRENT_USER() from t1; select benchmark(1,1) from t1; explain extended select benchmark(1,1) from t1; show status like "Qcache_queries_in_cache"; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 18cf614f338..84ae9674de9 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -198,7 +198,7 @@ drop table t1; # bug #1172: "Force index" option caused server crash # CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1)); -INSERT INTO t1 VALUES (0),(0),(1),(1); +INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(1),(1); CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya)); INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2); explain select * from t1, t2 where (t1.key1 (SELECT 1,2,1); SELECT ROW(1,2,3) = (SELECT 1,2,NULL); SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a'); SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b'); -SELECT (SELECT 1.5,2,'a') = ROW('b',2,'b'); +SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b'); SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a'); -SELECT (SELECT 1.5,2,'a') = ROW(1.5,'c','a'); +SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a'); SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a'); -- error 1241 @@ -1752,3 +1752,50 @@ insert into t1 values (1, 1), (2, 2), (2, 3), (3, 4), (3, 5), (3, 6), (NULL, NUL select * from t1; select min(a) from t1 group by grp; drop table t1; + +# +# Test for bug #9338: lame substitution of c1 instead of c2 +# + +CREATE table t1 ( c1 integer ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); + +CREATE TABLE t2 ( c2 integer ); +INSERT INTO t2 VALUES ( 1 ); +INSERT INTO t2 VALUES ( 4 ); +INSERT INTO t2 VALUES ( 5 ); + +SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2 WHERE c2 IN (1); + +SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2 + WHERE c2 IN ( SELECT c2 FROM t2 WHERE c2 IN ( 1 ) ); + +DROP TABLE t1,t2; + +# +# Test for bug #9516: wrong evaluation of not_null_tables attribute in SQ +# + +CREATE TABLE t1 ( c1 integer ); +INSERT INTO t1 VALUES ( 1 ); +INSERT INTO t1 VALUES ( 2 ); +INSERT INTO t1 VALUES ( 3 ); +INSERT INTO t1 VALUES ( 6 ); + +CREATE TABLE t2 ( c2 integer ); +INSERT INTO t2 VALUES ( 1 ); +INSERT INTO t2 VALUES ( 4 ); +INSERT INTO t2 VALUES ( 5 ); +INSERT INTO t2 VALUES ( 6 ); + +CREATE TABLE t3 ( c3 integer ); +INSERT INTO t3 VALUES ( 7 ); +INSERT INTO t3 VALUES ( 8 ); + +SELECT c1,c2 FROM t1 LEFT JOIN t2 ON c1 = c2 + WHERE EXISTS (SELECT c3 FROM t3 WHERE c2 IS NULL ); + +DROP TABLE t1,t2,t3; + diff --git a/mysql-test/t/sum_distinct-big.test b/mysql-test/t/sum_distinct-big.test new file mode 100644 index 00000000000..0859f4b3d89 --- /dev/null +++ b/mysql-test/t/sum_distinct-big.test @@ -0,0 +1,67 @@ +# +# Various tests for SUM(DISTINCT ...) +# + +--source include/big_test.inc +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings + +# +# Test the case when distinct values doesn't fit in memory and +# filesort is used (see uniques.cc:merge_walk) +# + +CREATE TABLE t1 (id INTEGER); +CREATE TABLE t2 (id INTEGER); + +INSERT INTO t1 (id) VALUES (1), (1), (1),(1); +INSERT INTO t1 (id) SELECT id FROM t1; /* 8 */ +INSERT INTO t1 (id) SELECT id FROM t1; /* 12 */ +INSERT INTO t1 (id) SELECT id FROM t1; /* 16 */ +INSERT INTO t1 (id) SELECT id FROM t1; /* 20 */ +INSERT INTO t1 (id) SELECT id FROM t1; /* 24 */ +INSERT INTO t1 SELECT id+1 FROM t1; +INSERT INTO t1 SELECT id+2 FROM t1; +INSERT INTO t1 SELECT id+4 FROM t1; +INSERT INTO t1 SELECT id+8 FROM t1; +INSERT INTO t1 SELECT id+16 FROM t1; +INSERT INTO t1 SELECT id+32 FROM t1; +INSERT INTO t1 SELECT id+64 FROM t1; +INSERT INTO t1 SELECT id+128 FROM t1; +INSERT INTO t1 SELECT id+256 FROM t1; +INSERT INTO t1 SELECT id+512 FROM t1; + +# Just test that AVG(DISTINCT) is there +SELECT AVG(DISTINCT id) FROM t1 GROUP BY id % 13; +SELECT SUM(DISTINCT id)/COUNT(DISTINCT id) FROM t1 GROUP BY id % 13; + +INSERT INTO t1 SELECT id+1024 FROM t1; +INSERT INTO t1 SELECT id+2048 FROM t1; +INSERT INTO t1 SELECT id+4096 FROM t1; +INSERT INTO t1 SELECT id+8192 FROM t1; +INSERT INTO t2 SELECT id FROM t1 ORDER BY id*rand(); + +# SELECT '++++++++++++++++++++++++++++++++++++++++++++++++++'; + +SELECT SUM(DISTINCT id) sm FROM t1; +SELECT SUM(DISTINCT id) sm FROM t2; +SELECT SUM(DISTINCT id) sm FROM t1 group by id % 13; + +# this limit for max_heap_table_size is set to force testing the case, when +# all distinct sum values can not fit in memory and must be stored in a +# temporary table + +SET max_heap_table_size=16384; + +# to check that max_heap_table_size was actually set (hard limit for minimum +# max_heap_table_size is set in mysqld.cc): + +SHOW variables LIKE 'max_heap_table_size'; + +SELECT SUM(DISTINCT id) sm FROM t1; +SELECT SUM(DISTINCT id) sm FROM t2; +SELECT SUM(DISTINCT id) sm FROM t1 GROUP BY id % 13; + +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/t/sum_distinct.test b/mysql-test/t/sum_distinct.test index 3b9f12354e8..c58155a8e25 100644 --- a/mysql-test/t/sum_distinct.test +++ b/mysql-test/t/sum_distinct.test @@ -93,62 +93,3 @@ SELECT SUM(DISTINCT id) FROM t1; SELECT SUM(DISTINCT id % 11) FROM t1; DROP TABLE t1; - -# -# Test the case when distinct values doesn't fit in memory and -# filesort is used (see uniques.cc:merge_walk) -# - -CREATE TABLE t1 (id INTEGER); -CREATE TABLE t2 (id INTEGER); - -INSERT INTO t1 (id) VALUES (1), (1), (1),(1); -INSERT INTO t1 (id) SELECT id FROM t1; /* 8 */ -INSERT INTO t1 (id) SELECT id FROM t1; /* 12 */ -INSERT INTO t1 (id) SELECT id FROM t1; /* 16 */ -INSERT INTO t1 (id) SELECT id FROM t1; /* 20 */ -INSERT INTO t1 (id) SELECT id FROM t1; /* 24 */ -INSERT INTO t1 SELECT id+1 FROM t1; -INSERT INTO t1 SELECT id+2 FROM t1; -INSERT INTO t1 SELECT id+4 FROM t1; -INSERT INTO t1 SELECT id+8 FROM t1; -INSERT INTO t1 SELECT id+16 FROM t1; -INSERT INTO t1 SELECT id+32 FROM t1; -INSERT INTO t1 SELECT id+64 FROM t1; -INSERT INTO t1 SELECT id+128 FROM t1; -INSERT INTO t1 SELECT id+256 FROM t1; -INSERT INTO t1 SELECT id+512 FROM t1; - -# Just test that AVG(DISTINCT) is there -SELECT AVG(DISTINCT id) FROM t1 GROUP BY id % 13; -SELECT SUM(DISTINCT id)/COUNT(DISTINCT id) FROM t1 GROUP BY id % 13; - -INSERT INTO t1 SELECT id+1024 FROM t1; -INSERT INTO t1 SELECT id+2048 FROM t1; -INSERT INTO t1 SELECT id+4096 FROM t1; -INSERT INTO t1 SELECT id+8192 FROM t1; -INSERT INTO t2 SELECT id FROM t1 ORDER BY id*rand(); - -# SELECT '++++++++++++++++++++++++++++++++++++++++++++++++++'; - -SELECT SUM(DISTINCT id) sm FROM t1; -SELECT SUM(DISTINCT id) sm FROM t2; -SELECT SUM(DISTINCT id) sm FROM t1 group by id % 13; - -# this limit for max_heap_table_size is set to force testing the case, when -# all distinct sum values can not fit in memory and must be stored in a -# temporary table - -SET max_heap_table_size=16384; - -# to check that max_heap_table_size was actually set (hard limit for minimum -# max_heap_table_size is set in mysqld.cc): - -SHOW variables LIKE 'max_heap_table_size'; - -SELECT SUM(DISTINCT id) sm FROM t1; -SELECT SUM(DISTINCT id) sm FROM t2; -SELECT SUM(DISTINCT id) sm FROM t1 GROUP BY id % 13; - -DROP TABLE t1; -DROP TABLE t2; diff --git a/mysql-test/t/system_mysql_db_fix.test b/mysql-test/t/system_mysql_db_fix.test index 2cefa167466..f47b4cba6e6 100644 --- a/mysql-test/t/system_mysql_db_fix.test +++ b/mysql-test/t/system_mysql_db_fix.test @@ -1,3 +1,6 @@ +# Embedded server doesn't support external clients +--source include/not_embedded.inc + # # This is the test for mysql_fix_privilege_tables # diff --git a/mysql-test/t/timezone2.test b/mysql-test/t/timezone2.test index 05736b92ad6..0b5aaed5d30 100644 --- a/mysql-test/t/timezone2.test +++ b/mysql-test/t/timezone2.test @@ -200,75 +200,7 @@ select convert_tz(ts, @@time_zone, 'Japan') from t1; drop table t1; # -# Test for bug #6116 "SET time_zone := ... requires access to mysql.time_zone -# tables". We should allow implicit access to time zone description tables -# even for unprivileged users. -# - -# Let us prepare playground -delete from mysql.user where user like 'mysqltest\_%'; -delete from mysql.db where user like 'mysqltest\_%'; -delete from mysql.tables_priv where user like 'mysqltest\_%'; -delete from mysql.columns_priv where user like 'mysqltest\_%'; -flush privileges; -create table t1 (a int, b datetime); -create table t2 (c int, d datetime); - -grant all privileges on test.* to mysqltest_1@localhost; -connect (tzuser, localhost, mysqltest_1,,); -connection tzuser; -show grants for current_user(); -set time_zone= '+00:00'; -set time_zone= 'Europe/Moscow'; -select convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC'); -select convert_tz(b, 'Europe/Moscow', 'UTC') from t1; -# Let us also check whenever multi-update works ok -update t1, t2 set t1.b = convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC') - where t1.a = t2.c and t2.d = (select max(d) from t2); -# But still these two statements should not work: ---error 1142 -select * from mysql.time_zone_name; ---error 1142 -select Name, convert_tz('2004-10-21 19:00:00', Name, 'UTC') from mysql.time_zone_name; - -# -# Test for bug #6765 "Implicit access to time zone description tables -# requires privileges for them if some table or column level grants -# present" -# -connection default; -# Let use some table-level grants instead of db-level -# to make life more interesting -delete from mysql.db where user like 'mysqltest\_%'; -flush privileges; -grant all privileges on test.t1 to mysqltest_1@localhost; -grant all privileges on test.t2 to mysqltest_1@localhost; -# The test itself is almost the same as previous one -connect (tzuser2, localhost, mysqltest_1,,); -connection tzuser2; -show grants for current_user(); -set time_zone= '+00:00'; -set time_zone= 'Europe/Moscow'; -select convert_tz('2004-11-31 12:00:00', 'Europe/Moscow', 'UTC'); -select convert_tz(b, 'Europe/Moscow', 'UTC') from t1; -update t1, t2 set t1.b = convert_tz('2004-11-30 12:00:00', 'Europe/Moscow', 'UTC') - where t1.a = t2.c and t2.d = (select max(d) from t2); -# Again these two statements should not work (but with different errors): ---error 1142 -select * from mysql.time_zone_name; ---error 1142 -select Name, convert_tz('2004-11-30 12:00:00', Name, 'UTC') from mysql.time_zone_name; - -# Clean-up -connection default; -delete from mysql.user where user like 'mysqltest\_%'; -delete from mysql.db where user like 'mysqltest\_%'; -delete from mysql.tables_priv where user like 'mysqltest\_%'; -flush privileges; -drop table t1, t2; - -# -# Test for bug #7705 "CONVERT_TZ() crashes with subquery/WHERE on index +# Test for bug #7705 "CONVERT_TZ() crashes with subquery/WHERE on index # column". Queries in which one of time zone arguments of CONVERT_TZ() is # determined as constant only at val() stage (not at fix_fields() stage), # should not crash server. diff --git a/mysql-test/t/timezone_grant.test b/mysql-test/t/timezone_grant.test new file mode 100644 index 00000000000..f586ba0c5fe --- /dev/null +++ b/mysql-test/t/timezone_grant.test @@ -0,0 +1,71 @@ +# Embedded server testing does not support grants +-- source include/not_embedded.inc + +# +# Test for bug #6116 "SET time_zone := ... requires access to mysql.time_zone +# tables". We should allow implicit access to time zone description tables +# even for unprivileged users. +# + +# Let us prepare playground +delete from mysql.user where user like 'mysqltest\_%'; +delete from mysql.db where user like 'mysqltest\_%'; +delete from mysql.tables_priv where user like 'mysqltest\_%'; +delete from mysql.columns_priv where user like 'mysqltest\_%'; +flush privileges; +create table t1 (a int, b datetime); +create table t2 (c int, d datetime); + +grant all privileges on test.* to mysqltest_1@localhost; +connect (tzuser, localhost, mysqltest_1,,); +connection tzuser; +show grants for current_user(); +set time_zone= '+00:00'; +set time_zone= 'Europe/Moscow'; +select convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC'); +select convert_tz(b, 'Europe/Moscow', 'UTC') from t1; +# Let us also check whenever multi-update works ok +update t1, t2 set t1.b = convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC') + where t1.a = t2.c and t2.d = (select max(d) from t2); +# But still these two statements should not work: +--error 1142 +select * from mysql.time_zone_name; +--error 1142 +select Name, convert_tz('2004-10-21 19:00:00', Name, 'UTC') from mysql.time_zone_name; + +# +# Test for bug #6765 "Implicit access to time zone description tables +# requires privileges for them if some table or column level grants +# present" +# +connection default; +# Let use some table-level grants instead of db-level +# to make life more interesting +delete from mysql.db where user like 'mysqltest\_%'; +flush privileges; +grant all privileges on test.t1 to mysqltest_1@localhost; +grant all privileges on test.t2 to mysqltest_1@localhost; +# The test itself is almost the same as previous one +connect (tzuser2, localhost, mysqltest_1,,); +connection tzuser2; +show grants for current_user(); +set time_zone= '+00:00'; +set time_zone= 'Europe/Moscow'; +select convert_tz('2004-11-31 12:00:00', 'Europe/Moscow', 'UTC'); +select convert_tz(b, 'Europe/Moscow', 'UTC') from t1; +update t1, t2 set t1.b = convert_tz('2004-11-30 12:00:00', 'Europe/Moscow', 'UTC') + where t1.a = t2.c and t2.d = (select max(d) from t2); +# Again these two statements should not work (but with different errors): +--error 1142 +select * from mysql.time_zone_name; +--error 1142 +select Name, convert_tz('2004-11-30 12:00:00', Name, 'UTC') from mysql.time_zone_name; + +# Clean-up +connection default; +delete from mysql.user where user like 'mysqltest\_%'; +delete from mysql.db where user like 'mysqltest\_%'; +delete from mysql.tables_priv where user like 'mysqltest\_%'; +flush privileges; +drop table t1, t2; + diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index bf75f09d553..53144cf3591 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -5,6 +5,7 @@ --disable_warnings drop table if exists t1, t2; drop view if exists v1; +drop database if exists mysqltest; --enable_warnings create table t1 (i int); @@ -229,3 +230,22 @@ select @del_before, @del_after; drop trigger t1.trg1; drop trigger t1.trg2; drop table t1; + +# Test for bug #5859 "DROP TABLE does not drop triggers". Trigger should not +# magically reappear when we recreate dropped table. +create table t1 (a int); +create trigger trg1 before insert on t1 for each row set new.a= 10; +drop table t1; +create table t1 (a int); +insert into t1 values (); +select * from t1; +drop table t1; + +# Test for bug #6559 "DROP DATABASE forgets to drop triggers". +create database mysqltest; +use mysqltest; +create table t1 (i int); +create trigger trg1 before insert on t1 for each row set @a:= 1; +# This should succeed +drop database mysqltest; +use test; diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test index f00fcfef7ab..1fbcf01d5a6 100644 --- a/mysql-test/t/type_bit.test +++ b/mysql-test/t/type_bit.test @@ -112,3 +112,31 @@ insert into t1 values (7,(1<<12)-2), (0x01,0x01ff); select hex(a),hex(b) from t1; select hex(concat(a)),hex(concat(b)) from t1; drop table t1; + +# +# Bug #9571: problem with primary key creation +# + +create table t1(a int, b bit not null); +alter table t1 add primary key (a); +drop table t1; + +# +# myisam <-> heap +# + +create table t1 (a bit(19), b bit(5)); +insert into t1 values (1000, 10), (3, 8), (200, 6), (2303, 2), (12345, 4), (1, 0); +select a+0, b+0 from t1; +alter table t1 engine=heap; +select a+0, b+0 from t1; +alter table t1 add key(a, b); +select a+0, b+0 from t1; +alter table t1 engine=myisam; +select a+0, b+0 from t1; +create table t2 engine=heap select * from t1; +select a+0, b+0 from t2; +drop table t1; +create table t1 select * from t2; +select a+0, b+0 from t1; +drop table t1, t2; diff --git a/mysql-test/t/type_bit_innodb.test b/mysql-test/t/type_bit_innodb.test new file mode 100644 index 00000000000..693fc169717 --- /dev/null +++ b/mysql-test/t/type_bit_innodb.test @@ -0,0 +1,135 @@ +--source include/have_innodb.inc +# +# testing of the BIT column type +# + +select 0 + b'1'; +select 0 + b'0'; +select 0 + b'000001'; +select 0 + b'000011'; +select 0 + b'000101'; +select 0 + b'000000'; +select 0 + b'10000000'; +select 0 + b'11111111'; +select 0 + b'10000001'; +select 0 + b'1000000000000000'; +select 0 + b'1111111111111111'; +select 0 + b'1000000000000001'; + +--disable_warnings +drop table if exists t1; +--enable_warnings + +--error 1074 +create table t1 (a bit(65)) engine=innodb; + +create table t1 (a bit(0)) engine=innodb; +show create table t1; +drop table t1; + +create table t1 (a bit(64)) engine=innodb; +insert into t1 values +(b'1111111111111111111111111111111111111111111111111111111111111111'), +(b'1000000000000000000000000000000000000000000000000000000000000000'), +(b'0000000000000000000000000000000000000000000000000000000000000001'), +(b'1010101010101010101010101010101010101010101010101010101010101010'), +(b'0101010101010101010101010101010101010101010101010101010101010101'); +select hex(a) from t1; +drop table t1; + +create table t1 (a bit) engine=innodb; +insert into t1 values (b'0'), (b'1'), (b'000'), (b'100'), (b'001'); +select hex(a) from t1; +--error 1062 +alter table t1 add unique (a); +drop table t1; + +create table t1 (a bit(2)) engine=innodb; +insert into t1 values (b'00'), (b'01'), (b'10'), (b'100'); +select a+0 from t1; +alter table t1 add key (a); +explain select a+0 from t1; +select a+0 from t1; +drop table t1; + +create table t1 (a bit(7), b bit(9), key(a, b)) engine=innodb; +insert into t1 values +(94, 46), (31, 438), (61, 152), (78, 123), (88, 411), (122, 118), (0, 177), +(75, 42), (108, 67), (79, 349), (59, 188), (68, 206), (49, 345), (118, 380), +(111, 368), (94, 468), (56, 379), (77, 133), (29, 399), (9, 363), (23, 36), +(116, 390), (119, 368), (87, 351), (123, 411), (24, 398), (34, 202), (28, 499), +(30, 83), (5, 178), (60, 343), (4, 245), (104, 280), (106, 446), (127, 403), +(44, 307), (68, 454), (57, 135); +explain select a+0 from t1; +select a+0 from t1; +explain select b+0 from t1; +select b+0 from t1; +explain select a+0, b+0 from t1; +select a+0, b+0 from t1; +explain select a+0, b+0 from t1 where a > 40 and b > 200 order by 1; +select a+0, b+0 from t1 where a > 40 and b > 200 order by 1; +explain select a+0, b+0 from t1 where a > 40 and a < 70 order by 2; +select a+0, b+0 from t1 where a > 40 and a < 70 order by 2; +set @@max_length_for_sort_data=0; +select a+0, b+0 from t1 where a > 40 and a < 70 order by 2; +select hex(min(a)) from t1; +select hex(min(b)) from t1; +select hex(min(a)), hex(max(a)), hex(min(b)), hex(max(b)) from t1; +drop table t1; + +create table t1 (a int not null, b bit, c bit(9), key(a, b, c)) engine=innodb; +insert into t1 values +(4, NULL, 1), (4, 0, 3), (2, 1, 4), (1, 1, 100), (4, 0, 23), (4, 0, 54), +(56, 0, 22), (4, 1, 100), (23, 0, 1), (4, 0, 34); +select a+0, b+0, c+0 from t1; +select hex(min(b)) from t1 where a = 4; +select hex(min(c)) from t1 where a = 4 and b = 0; +select hex(max(b)) from t1; +select a+0, b+0, c+0 from t1 where a = 4 and b = 0 limit 2; +select a+0, b+0, c+0 from t1 where a = 4 and b = 1; +select a+0, b+0, c+0 from t1 where a = 4 and b = 1 and c=100; +select a+0, b+0, c+0 from t1 order by b desc; +select a+0, b+0, c+0 from t1 order by c; +drop table t1; + +create table t1(a bit(2), b bit(2)) engine=innodb; +insert into t1 (a) values (0x01), (0x03), (0x02); +update t1 set b= concat(a); +select a+0, b+0 from t1; +drop table t1; + +# Some magic numbers + +create table t1 (a bit(7), key(a)) engine=innodb; +insert into t1 values (44), (57); +select a+0 from t1; +drop table t1; + +# +# Test conversion to and from strings +# +create table t1 (a bit(3), b bit(12)) engine=innodb; +insert into t1 values (7,(1<<12)-2), (0x01,0x01ff); +select hex(a),hex(b) from t1; +select hex(concat(a)),hex(concat(b)) from t1; +drop table t1; + +# +# Bug #9571: problem with primary key creation +# + +create table t1(a int, b bit not null) engine=innodb; +alter table t1 add primary key (a); +drop table t1; + +# +# altering tables +# + +create table t1 (a bit, b bit(10)) engine=innodb; +show create table t1; +alter table t1 engine=heap; +show create table t1; +alter table t1 engine=innodb; +show create table t1; +drop table t1; diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test index 20a501bb5ed..c33ea3f435d 100644 --- a/mysql-test/t/type_blob.test +++ b/mysql-test/t/type_blob.test @@ -81,8 +81,11 @@ insert into t1 values (NULL,NULL,NULL,NULL); update t1 set c="",b=null where c="1"; lock tables t1 READ; +# We mask out the Privileges column because it differs for embedded server +--replace_column 8 # show full fields from t1; lock tables t1 WRITE; +--replace_column 8 # show full fields from t1; unlock tables; @@ -301,20 +304,27 @@ drop table t1; # Bug when blob is updated # -create table t1 (id integer auto_increment unique,imagem LONGBLOB not null); +create table t1 (id integer auto_increment unique,imagem LONGBLOB not null default ''); insert into t1 (id) values (1); -select - charset(load_file('../../std_data/words.dat')), - collation(load_file('../../std_data/words.dat')), - coercibility(load_file('../../std_data/words.dat')); -explain extended select - charset(load_file('../../std_data/words.dat')), - collation(load_file('../../std_data/words.dat')), - coercibility(load_file('../../std_data/words.dat')); -update t1 set imagem=load_file('../../std_data/words.dat') where id=1; +# We have to clean up the path in the results for safe comparison +--replace_result $MYSQL_TEST_DIR ../.. +eval select + charset(load_file('$MYSQL_TEST_DIR/std_data/words.dat')), + collation(load_file('$MYSQL_TEST_DIR/std_data/words.dat')), + coercibility(load_file('$MYSQL_TEST_DIR/std_data/words.dat')); +--replace_result $MYSQL_TEST_DIR ../.. +eval explain extended select + charset(load_file('$MYSQL_TEST_DIR/std_data/words.dat')), + collation(load_file('$MYSQL_TEST_DIR/std_data/words.dat')), + coercibility(load_file('$MYSQL_TEST_DIR/std_data/words.dat')); +--replace_result $MYSQL_TEST_DIR ../.. +eval update t1 set imagem=load_file('$MYSQL_TEST_DIR/std_data/words.dat') where id=1; select if(imagem is null, "ERROR", "OK"),length(imagem) from t1 where id = 1; drop table t1; -create table t1 select load_file('../../std_data/words.dat'); +--replace_result $MYSQL_TEST_DIR ../.. +eval create table t1 select load_file('$MYSQL_TEST_DIR/std_data/words.dat') l; +# We mask out the Privileges column because it differs for embedded server +--replace_column 8 # show full fields from t1; drop table t1; diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test index 3205eabe01a..107f4a06ec5 100644 --- a/mysql-test/t/type_decimal.test +++ b/mysql-test/t/type_decimal.test @@ -326,3 +326,20 @@ SELECT i, SUM(d1) AS a, SUM(d2) AS b FROM t1 GROUP BY i HAVING a <> b; SELECT i, ROUND(SUM(d1), 2) AS a, ROUND(SUM(d2), 2) AS b FROM t1 GROUP BY i HAVING a <> b; drop table t1; + +# +# A test case for Bug#4956 "strange result, insert into longtext, parameter +# with numeric value": ensure that conversion is done identically no matter +# where the input data comes from. +# +create table t1 (c1 varchar(100), c2 longtext); +insert into t1 set c1= 'non PS, 1.0 as constant', c2=1.0; +prepare stmt from "insert into t1 set c1='PS, 1.0 as constant ', c2=1.0"; +execute stmt; +set @a=1.0; +insert into t1 set c1='non PS, 1.0 in parameter', c2=@a; +prepare stmt from "insert into t1 set c1='PS, 1.0 in parameter ', c2=?"; +execute stmt using @a; +select * from t1; +deallocate prepare stmt; +drop table t1; diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test index 6e991dc53d4..41812ef2652 100644 --- a/mysql-test/t/type_float.test +++ b/mysql-test/t/type_float.test @@ -16,6 +16,8 @@ SELECT 123.23E+02,-123.23E-02,"123.23E+02"+0.0,"-123.23E-02"+0.0; SELECT 2147483647E+02,21474836.47E+06; create table t1 (f1 float(24),f2 float(52)); +# We mask out Privileges column because it differs for embedded server +--replace_column 8 # show full columns from t1; insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150); insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150); @@ -66,6 +68,8 @@ drop table t1; # create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(5,6)); +# We mask out Privileges column because it differs for embedded server +--replace_column 8 # show full columns from t1; drop table t1; diff --git a/mysql-test/t/type_ranges.test b/mysql-test/t/type_ranges.test index 5f035921064..a2deb367e14 100644 --- a/mysql-test/t/type_ranges.test +++ b/mysql-test/t/type_ranges.test @@ -28,10 +28,10 @@ CREATE TABLE t1 ( date_time datetime, blob_col blob, tinyblob_col tinyblob, - mediumblob_col mediumblob not null, - longblob_col longblob not null, - options enum('one','two','tree') not null, - flags set('one','two','tree') not null, + mediumblob_col mediumblob not null default '', + longblob_col longblob not null default '', + options enum('one','two','tree') not null , + flags set('one','two','tree') not null default '', PRIMARY KEY (auto), KEY (utiny), KEY (tiny), @@ -46,6 +46,8 @@ CREATE TABLE t1 ( KEY (options,flags) ); +# We mask out the Privileges column because it differs with embedded server +--replace_column 8 # show full fields from t1; show keys from t1; @@ -69,7 +71,7 @@ ALTER TABLE t1 add new_field char(10) default "new" not null, change blob_col new_blob_col varchar(20), change date_field date_field char(10), -alter column string set default "new default", +alter column string set default "newdefault", alter short drop default, DROP INDEX utiny, DROP INDEX ushort, @@ -120,7 +122,10 @@ drop table t2; create table t2 select * from t1; update t2 set string="changed" where auto=16; +# We mask out the Privileges column because it differs with embedded server +--replace_column 8 # show full columns from t1; +--replace_column 8 # show full columns from t2; select t1.auto,t2.auto from t1,t2 where t1.auto=t2.auto and ((t1.string<>t2.string and (t1.string is not null or t2.string is not null)) or (t1.tiny<>t2.tiny and (t1.tiny is not null or t2.tiny is not null)) or (t1.short<>t2.short and (t1.short is not null or t2.short is not null)) or (t1.medium<>t2.medium and (t1.medium is not null or t2.medium is not null)) or (t1.long_int<>t2.long_int and (t1.long_int is not null or t2.long_int is not null)) or (t1.longlong<>t2.longlong and (t1.longlong is not null or t2.longlong is not null)) or (t1.real_float<>t2.real_float and (t1.real_float is not null or t2.real_float is not null)) or (t1.real_double<>t2.real_double and (t1.real_double is not null or t2.real_double is not null)) or (t1.utiny<>t2.utiny and (t1.utiny is not null or t2.utiny is not null)) or (t1.ushort<>t2.ushort and (t1.ushort is not null or t2.ushort is not null)) or (t1.umedium<>t2.umedium and (t1.umedium is not null or t2.umedium is not null)) or (t1.ulong<>t2.ulong and (t1.ulong is not null or t2.ulong is not null)) or (t1.ulonglong<>t2.ulonglong and (t1.ulonglong is not null or t2.ulonglong is not null)) or (t1.time_stamp<>t2.time_stamp and (t1.time_stamp is not null or t2.time_stamp is not null)) or (t1.date_field<>t2.date_field and (t1.date_field is not null or t2.date_field is not null)) or (t1.time_field<>t2.time_field and (t1.time_field is not null or t2.time_field is not null)) or (t1.date_time<>t2.date_time and (t1.date_time is not null or t2.date_time is not null)) or (t1.new_blob_col<>t2.new_blob_col and (t1.new_blob_col is not null or t2.new_blob_col is not null)) or (t1.tinyblob_col<>t2.tinyblob_col and (t1.tinyblob_col is not null or t2.tinyblob_col is not null)) or (t1.mediumblob_col<>t2.mediumblob_col and (t1.mediumblob_col is not null or t2.mediumblob_col is not null)) or (t1.options<>t2.options and (t1.options is not null or t2.options is not null)) or (t1.flags<>t2.flags and (t1.flags is not null or t2.flags is not null)) or (t1.new_field<>t2.new_field and (t1.new_field is not null or t2.new_field is not null))); select t1.auto,t2.auto from t1,t2 where t1.auto=t2.auto and not (t1.string<=>t2.string and t1.tiny<=>t2.tiny and t1.short<=>t2.short and t1.medium<=>t2.medium and t1.long_int<=>t2.long_int and t1.longlong<=>t2.longlong and t1.real_float<=>t2.real_float and t1.real_double<=>t2.real_double and t1.utiny<=>t2.utiny and t1.ushort<=>t2.ushort and t1.umedium<=>t2.umedium and t1.ulong<=>t2.ulong and t1.ulonglong<=>t2.ulonglong and t1.time_stamp<=>t2.time_stamp and t1.date_field<=>t2.date_field and t1.time_field<=>t2.time_field and t1.date_time<=>t2.date_time and t1.new_blob_col<=>t2.new_blob_col and t1.tinyblob_col<=>t2.tinyblob_col and t1.mediumblob_col<=>t2.mediumblob_col and t1.options<=>t2.options and t1.flags<=>t2.flags and t1.new_field<=>t2.new_field); @@ -128,6 +133,8 @@ select t1.auto,t2.auto from t1,t2 where t1.auto=t2.auto and not (t1.string<=>t2. drop table t2; create table t2 (primary key (auto)) select auto+1 as auto,1 as t1, 'a' as t2, repeat('a',256) as t3, binary repeat('b',256) as t4, repeat('a',4096) as t5, binary repeat('b',4096) as t6, '' as t7, binary '' as t8 from t1; +# We mask out the Privileges column because it differs with embedded server +--replace_column 8 # show full columns from t2; select t1,t2,length(t3),length(t4),length(t5),length(t6),t7,t8 from t2; drop table t1,t2; @@ -138,6 +145,8 @@ create table t2 select * from t1; --error 1060 create table t3 select * from t1, t2; # Should give an error create table t3 select t1.c AS c1, t2.c AS c2,1 as "const" from t1, t2; +# We mask out the Privileges column because it differs with embedded server +--replace_column 8 # show full columns from t3; drop table t1,t2,t3; diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 95b5d4c6aaf..239a7aaad4b 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -659,7 +659,7 @@ drop table t1; create table t2 ( a char character set latin1 collate latin1_swedish_ci, -b char character set latin1 collate latin1_bin); +b char character set latin1 collate latin1_german1_ci); --error 1271 create table t1 as (select a from t2) union @@ -760,3 +760,15 @@ create table t2 select a from t1 union select c from t1; create table t2 select a from t1 union select b from t1; show columns from t2; drop table t2, t1; + +# +# Test that union with VARCHAR produces dynamic row tables +# + +create table t1 (a varchar(5)); +create table t2 select * from t1 union select 'abcdefghijkl'; +show create table t2; +select row_format from information_schema.TABLES where table_schema="test" and table_name="t2"; +alter table t2 ROW_FORMAT=fixed; +show create table t2; +drop table t1,t2; diff --git a/mysql-test/t/user_limits.test b/mysql-test/t/user_limits.test index 729894a588a..af0f6545ac4 100644 --- a/mysql-test/t/user_limits.test +++ b/mysql-test/t/user_limits.test @@ -2,6 +2,9 @@ # Test behavior of various per-account limits (aka quotas) # +# Requires privileges to be enabled +-- source include/not_embedded.inc + # Prepare play-ground --disable_warnings drop table if exists t1; diff --git a/mysql-test/t/user_var-binlog.test b/mysql-test/t/user_var-binlog.test new file mode 100644 index 00000000000..916a7dfa47b --- /dev/null +++ b/mysql-test/t/user_var-binlog.test @@ -0,0 +1,19 @@ +# Embedded server does not support binlogging +--source include/not_embedded.inc + +# Check that user variables are binlogged correctly (BUG#3875) +create table t1 (a varchar(50)); +reset master; +SET TIMESTAMP=10000; +SET @`a b`='hello'; +INSERT INTO t1 VALUES(@`a b`); +set @var1= "';aaa"; +SET @var2=char(ascii('a')); +insert into t1 values (@var1),(@var2); +show binlog events from 98; +# more important than SHOW BINLOG EVENTS, mysqlbinlog (where we +# absolutely need variables names to be quoted and strings to be +# escaped). +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 +drop table t1; diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index 49d8e167368..ef360f2231d 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -99,25 +99,6 @@ select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST'; select charset(@a),collation(@a),coercibility(@a); select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' collate latin2_general_ci; -# Check that user variables are binlogged correctly (BUG#3875) -create table t1 (a varchar(50)); -reset master; -SET TIMESTAMP=10000; -SET @`a b`='hello'; -INSERT INTO t1 VALUES(@`a b`); -set @var1= "';aaa"; -SET @var2=char(ascii('a')); -insert into t1 values (@var1),(@var2); ---replace_column 2 # 5 # -show binlog events from 98; -# more important than SHOW BINLOG EVENTS, mysqlbinlog (where we -# absolutely need variables names to be quoted and strings to be -# escaped). ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 -drop table t1; - - # # Bug #6321 strange error: # string function FIELD(, ...) @@ -131,3 +112,10 @@ select FIELD( @var,'1it','Hit') as my_column; select @v, coercibility(@v); set @v1=null, @v2=1, @v3=1.1, @v4=now(); select coercibility(@v1),coercibility(@v2),coercibility(@v3),coercibility(@v4); + +# +# Bug #9286 SESSION/GLOBAL should be disallowed for user variables +# +set session @honk=99; +--error 1382 +set one_shot @honk=99; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index ebd6edf4045..9931b72599f 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -236,7 +236,6 @@ set read_buffer_size=100; set read_rnd_buffer_size=100; set global rpl_recovery_rank=100; set global server_id=100; -set global slave_net_timeout=100; set global slow_launch_time=100; set sort_buffer_size=100; set sql_auto_is_null=1; @@ -255,7 +254,6 @@ select @@sql_max_join_size,@@max_join_size; set sql_quote_show_create=1; set sql_safe_updates=1; set sql_select_limit=1; -set global sql_slave_skip_counter=100; set sql_warnings=1; set global table_cache=100; set storage_engine=myisam; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 7a05ebb0204..0c3c81d0b89 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -122,12 +122,6 @@ alter view v1 (c,d) as select a,max(b) from t1 group by a; select * from v1; select * from v2; -# simple test of grants -grant create view on test.* to test@localhost; -show grants for test@localhost; -revoke create view on test.* from test@localhost; -show grants for test@localhost; - # try to drop nonexistent VIEW -- error 1051 drop view v100; @@ -162,172 +156,6 @@ drop view v1, v2; drop table t1; -# -# grant create view test -# -connect (root,localhost,root,,test); -connection root; ---disable_warnings -create database mysqltest; ---enable_warnings - -create table mysqltest.t1 (a int, b int); -create table mysqltest.t2 (a int, b int); - -grant select on mysqltest.t1 to mysqltest_1@localhost; -grant create view,select on test.* to mysqltest_1@localhost; - -connect (user1,localhost,mysqltest_1,,test); -connection user1; - -create view v1 as select * from mysqltest.t1; -# try to modify view without DELETE privilege on it --- error 1142 -alter view v1 as select * from mysqltest.t1; --- error 1142 -create or replace view v1 as select * from mysqltest.t1; -# no CRETE VIEW privilege --- error 1142 -create view mysqltest.v2 as select * from mysqltest.t1; -# no SELECT privilege --- error 1142 -create view v2 as select * from mysqltest.t2; - -connection root; -revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; -revoke all privileges on test.* from mysqltest_1@localhost; - -drop database mysqltest; -drop view test.v1; - -# -# grants per columns -# -# MERGE algorithm ---disable_warnings -create database mysqltest; ---enable_warnings - -create table mysqltest.t1 (a int, b int); -create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; -grant select (c) on mysqltest.v1 to mysqltest_1@localhost; - -connection user1; -select c from mysqltest.v1; -# there are no privileges on column 'd' --- error 1143 -select d from mysqltest.v1; - -connection root; -revoke all privileges on mysqltest.v1 from mysqltest_1@localhost; -delete from mysql.user where user='mysqltest_1'; -drop database mysqltest; - -# TEMPORARY TABLE algorithm ---disable_warnings -create database mysqltest; ---enable_warnings - -create table mysqltest.t1 (a int, b int); -create algorithm=temptable view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; -grant select (c) on mysqltest.v1 to mysqltest_1@localhost; - -connection user1; -select c from mysqltest.v1; -# there are no privileges on column 'd' --- error 1143 -select d from mysqltest.v1; - -connection root; -revoke all privileges on mysqltest.v1 from mysqltest_1@localhost; -delete from mysql.user where user='mysqltest_1'; -drop database mysqltest; - -# -# EXPLAIN rights -# -connection root; ---disable_warnings -create database mysqltest; ---enable_warnings -#prepare views and tables -create table mysqltest.t1 (a int, b int); -create table mysqltest.t2 (a int, b int); -create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; -create algorithm=temptable view mysqltest.v2 (c,d) as select a+1,b+1 from mysqltest.t1; -create view mysqltest.v3 (c,d) as select a+1,b+1 from mysqltest.t2; -create algorithm=temptable view mysqltest.v4 (c,d) as select a+1,b+1 from mysqltest.t2; -grant select on mysqltest.v1 to mysqltest_1@localhost; -grant select on mysqltest.v2 to mysqltest_1@localhost; -grant select on mysqltest.v3 to mysqltest_1@localhost; -grant select on mysqltest.v4 to mysqltest_1@localhost; - -connection user1; -# all selects works -select c from mysqltest.v1; -select c from mysqltest.v2; -select c from mysqltest.v3; -select c from mysqltest.v4; -# test of show coluns -show columns from mysqltest.v1; -show columns from mysqltest.v2; -# but explain/show do not --- error 1345 -explain select c from mysqltest.v1; --- error 1142 -show create view mysqltest.v1; --- error 1345 -explain select c from mysqltest.v2; --- error 1142 -show create view mysqltest.v2; --- error 1345 -explain select c from mysqltest.v3; --- error 1142 -show create view mysqltest.v3; --- error 1345 -explain select c from mysqltest.v4; --- error 1142 -show create view mysqltest.v4; - -# allow to see one of underlying table -connection root; -grant select on mysqltest.t1 to mysqltest_1@localhost; -connection user1; -# EXPLAIN of view on above table works -explain select c from mysqltest.v1; --- error 1142 -show create view mysqltest.v1; -explain select c from mysqltest.v2; --- error 1142 -show create view mysqltest.v2; -# but other EXPLAINs do not --- error 1345 -explain select c from mysqltest.v3; --- error 1142 -show create view mysqltest.v3; --- error 1345 -explain select c from mysqltest.v4; --- error 1142 -show create view mysqltest.v4; - -# allow to see any view in mysqltest database -connection root; -grant show view on mysqltest.* to mysqltest_1@localhost; -connection user1; -explain select c from mysqltest.v1; -show create view mysqltest.v1; -explain select c from mysqltest.v2; -show create view mysqltest.v2; -explain select c from mysqltest.v3; -show create view mysqltest.v3; -explain select c from mysqltest.v4; -show create view mysqltest.v4; - -connection root; -revoke all privileges on mysqltest.* from mysqltest_1@localhost; -delete from mysql.user where user='mysqltest_1'; -drop database mysqltest; - # # DISTINCT option for VIEW # @@ -433,54 +261,6 @@ select * from t1; drop table t1,t2; drop view v1,v2; -# -# UPDATE privileges on VIEW columns and whole VIEW -# -connection root; ---disable_warnings -create database mysqltest; ---enable_warnings - -create table mysqltest.t1 (a int, b int, primary key(a)); -insert into mysqltest.t1 values (10,2), (20,3), (30,4), (40,5), (50,10); -create table mysqltest.t2 (x int); -insert into mysqltest.t2 values (3), (4), (5), (6); -create view mysqltest.v1 (a,c) as select a, b+1 from mysqltest.t1; -create view mysqltest.v2 (a,c) as select a, b from mysqltest.t1; -create view mysqltest.v3 (a,c) as select a, b+1 from mysqltest.t1; - -grant update (a) on mysqltest.v2 to mysqltest_1@localhost; -grant update on mysqltest.v1 to mysqltest_1@localhost; -grant select on mysqltest.* to mysqltest_1@localhost; - -connection user1; -use mysqltest; -# update with rights on VIEW column -update t2,v1 set v1.a=v1.a+v1.c where t2.x=v1.c; -select * from t1; -update v1 set a=a+c; -select * from t1; -# update with rights on whole VIEW -update t2,v2 set v2.a=v2.a+v2.c where t2.x=v2.c; -select * from t1; -update v2 set a=a+c; -select * from t1; -# no rights on column --- error 1143 -update t2,v2 set v2.c=v2.a+v2.c where t2.x=v2.c; --- error 1143 -update v2 set c=a+c; -# no rights for view --- error 1142 -update t2,v3 set v3.a=v3.a+v3.c where t2.x=v3.c; --- error 1142 -update v3 set a=a+c; - -use test; -connection root; -REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; -drop database mysqltest; - # # MERGE VIEW with WHERE clause # @@ -535,42 +315,6 @@ select * from t1; drop table t1,t2; drop view v1,v2; -# -# DELETE privileges on VIEW -# -connection root; ---disable_warnings -create database mysqltest; ---enable_warnings - -create table mysqltest.t1 (a int, b int, primary key(a)); -insert into mysqltest.t1 values (1,2), (2,3), (3,4), (4,5), (5,10); -create table mysqltest.t2 (x int); -insert into mysqltest.t2 values (3), (4), (5), (6); -create view mysqltest.v1 (a,c) as select a, b+1 from mysqltest.t1; -create view mysqltest.v2 (a,c) as select a, b+1 from mysqltest.t1; - -grant delete on mysqltest.v1 to mysqltest_1@localhost; -grant select on mysqltest.* to mysqltest_1@localhost; - -connection user1; -use mysqltest; -# update with rights on VIEW column -delete from v1 where c < 4; -select * from t1; -delete v1 from t2,v1 where t2.x=v1.c; -select * from t1; -# no rights for view --- error 1142 -delete v2 from t2,v2 where t2.x=v2.c; --- error 1142 -delete from v2 where c < 4; - -use test; -connection root; -REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; -drop database mysqltest; - # # key presence check # @@ -647,42 +391,6 @@ select * from t1; drop table t1, t2; drop view v1,v2,v3,v4,v5; -# -# insert privileges on VIEW -# -connection root; ---disable_warnings -create database mysqltest; ---enable_warnings - -create table mysqltest.t1 (a int, b int, primary key(a)); -insert into mysqltest.t1 values (1,2), (2,3); -create table mysqltest.t2 (x int, y int); -insert into mysqltest.t2 values (3,4); -create view mysqltest.v1 (a,c) as select a, b from mysqltest.t1; -create view mysqltest.v2 (a,c) as select a, b from mysqltest.t1; - -grant insert on mysqltest.v1 to mysqltest_1@localhost; -grant select on mysqltest.* to mysqltest_1@localhost; - -connection user1; -use mysqltest; -# update with rights on VIEW column -insert into v1 values (5,6); -select * from t1; -insert into v1 select x,y from t2; -select * from t1; -# no rights for view --- error 1142 -insert into v2 values (5,6); --- error 1142 -insert into v2 select x,y from t2; - -use test; -connection root; -REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; -drop database mysqltest; - # # outer join based on VIEW with WHERE clause # @@ -729,87 +437,6 @@ select * from t1; drop view v1; drop table t1; -# -# test of CREATE VIEW privileges if we have limited privileges -# -connection root; ---disable_warnings -create database mysqltest; ---enable_warnings - -create table mysqltest.t1 (a int, b int); -create table mysqltest.t2 (a int, b int); - -grant update on mysqltest.t1 to mysqltest_1@localhost; -grant update(b) on mysqltest.t2 to mysqltest_1@localhost; -grant create view,update on test.* to mysqltest_1@localhost; - -connection user1; - -create view v1 as select * from mysqltest.t1; -create view v2 as select b from mysqltest.t2; -# There are not rights on mysqltest.v1 --- error 1142 -create view mysqltest.v1 as select * from mysqltest.t1; -# There are not any rights on mysqltest.t2.a --- error 1143 -create view v3 as select a from mysqltest.t2; - -# give CREATE VIEW privileges (without any privileges for result column) -connection root; -create table mysqltest.v3 (b int); -grant create view on mysqltest.v3 to mysqltest_1@localhost; -drop table mysqltest.v3; -connection user1; -create view mysqltest.v3 as select b from mysqltest.t2; - -# give UPDATE privileges -connection root; -grant create view, update on mysqltest.v3 to mysqltest_1@localhost; -drop view mysqltest.v3; -connection user1; -create view mysqltest.v3 as select b from mysqltest.t2; - -# give UPDATE and INSERT privilege (to get more privileges then underlying -# table) -connection root; -grant create view, update, insert on mysqltest.v3 to mysqltest_1@localhost; -drop view mysqltest.v3; -connection user1; --- error 1143 -create view mysqltest.v3 as select b from mysqltest.t2; - - -# If we would get more privileges on VIEW then we have on -# underlying tables => creation prohibited -connection root; -create table mysqltest.v3 (b int); -grant select(b) on mysqltest.v3 to mysqltest_1@localhost; -drop table mysqltest.v3; -connection user1; --- error 1142 -create view mysqltest.v3 as select b from mysqltest.t2; - -# Expression need select privileges --- error 1143 -create view v4 as select b+1 from mysqltest.t2; - -connection root; -grant create view,update,select on test.* to mysqltest_1@localhost; -connection user1; --- error 1143 -create view v4 as select b+1 from mysqltest.t2; - -connection root; -grant update,select(b) on mysqltest.t2 to mysqltest_1@localhost; -connection user1; -create view v4 as select b+1 from mysqltest.t2; - -connection root; -REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; -drop database mysqltest; -drop view v1,v2,v4; - # # VIEW fields quoting # @@ -1198,15 +825,118 @@ create table t1 (col1 int); create table t2 (col1 int); create view v1 as select * from t1; create view v2 as select * from v1; +create view v3 as select v2.col1 from v2,t2 where v2.col1 = t2.col1; -- error 1093 update v2 set col1 = (select max(col1) from v1); -#update v2,t2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1; +-- error 1093 +update v2 set col1 = (select max(col1) from t1); +-- error 1093 +update v2 set col1 = (select max(col1) from v2); +-- error 1093 +update v2,t2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1; +-- error 1093 +update t1,t2 set t1.col1 = (select max(col1) from v1) where t1.col1 = t2.col1; +-- error 1093 +update v1,t2 set v1.col1 = (select max(col1) from v1) where v1.col1 = t2.col1; +-- error 1093 +update t2,v2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1; +-- error 1093 +update t2,t1 set t1.col1 = (select max(col1) from v1) where t1.col1 = t2.col1; +-- error 1093 +update t2,v1 set v1.col1 = (select max(col1) from v1) where v1.col1 = t2.col1; +-- error 1093 +update v2,t2 set v2.col1 = (select max(col1) from t1) where v2.col1 = t2.col1; +-- error 1093 +update t1,t2 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1; +-- error 1093 +update v1,t2 set v1.col1 = (select max(col1) from t1) where v1.col1 = t2.col1; +-- error 1093 +update t2,v2 set v2.col1 = (select max(col1) from t1) where v2.col1 = t2.col1; +-- error 1093 +update t2,t1 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1; +-- error 1093 +update t2,v1 set v1.col1 = (select max(col1) from t1) where v1.col1 = t2.col1; +-- error 1093 +update v2,t2 set v2.col1 = (select max(col1) from v2) where v2.col1 = t2.col1; +-- error 1093 +update t1,t2 set t1.col1 = (select max(col1) from v2) where t1.col1 = t2.col1; +-- error 1093 +update v1,t2 set v1.col1 = (select max(col1) from v2) where v1.col1 = t2.col1; +-- error 1093 +update t2,v2 set v2.col1 = (select max(col1) from v2) where v2.col1 = t2.col1; +-- error 1093 +update t2,t1 set t1.col1 = (select max(col1) from v2) where t1.col1 = t2.col1; +-- error 1093 +update t2,v1 set v1.col1 = (select max(col1) from v2) where v1.col1 = t2.col1; +-- error 1093 +update v3 set v3.col1 = (select max(col1) from v1); +-- error 1093 +update v3 set v3.col1 = (select max(col1) from t1); +-- error 1093 +update v3 set v3.col1 = (select max(col1) from v2); +-- error 1093 +update v3 set v3.col1 = (select max(col1) from v3); -- error 1093 delete from v2 where col1 = (select max(col1) from v1); -#delete v2 from v2,t2 where (select max(col1) from v1) > 0 and v2.col1 = t2.col1; +-- error 1093 +delete from v2 where col1 = (select max(col1) from t1); +-- error 1093 +delete from v2 where col1 = (select max(col1) from v2); +-- error 1093 +delete v2 from v2,t2 where (select max(col1) from v1) > 0 and v2.col1 = t2.col1; +-- error 1093 +delete t1 from t1,t2 where (select max(col1) from v1) > 0 and t1.col1 = t2.col1; +-- error 1093 +delete v1 from v1,t2 where (select max(col1) from v1) > 0 and v1.col1 = t2.col1; +-- error 1093 +delete v2 from v2,t2 where (select max(col1) from t1) > 0 and v2.col1 = t2.col1; +-- error 1093 +delete t1 from t1,t2 where (select max(col1) from t1) > 0 and t1.col1 = t2.col1; +-- error 1093 +delete v1 from v1,t2 where (select max(col1) from t1) > 0 and v1.col1 = t2.col1; +-- error 1093 +delete v2 from v2,t2 where (select max(col1) from v2) > 0 and v2.col1 = t2.col1; +-- error 1093 +delete t1 from t1,t2 where (select max(col1) from v2) > 0 and t1.col1 = t2.col1; +-- error 1093 +delete v1 from v1,t2 where (select max(col1) from v2) > 0 and v1.col1 = t2.col1; -- error 1093 insert into v2 values ((select max(col1) from v1)); -drop view v2,v1; +-- error 1093 +insert into t1 values ((select max(col1) from v1)); +-- error 1093 +insert into v2 values ((select max(col1) from v1)); +-- error 1093 +insert into v2 values ((select max(col1) from t1)); +-- error 1093 +insert into t1 values ((select max(col1) from t1)); +-- error 1093 +insert into v2 values ((select max(col1) from t1)); +-- error 1093 +insert into v2 values ((select max(col1) from v2)); +-- error 1093 +insert into t1 values ((select max(col1) from v2)); +-- error 1093 +insert into v2 values ((select max(col1) from v2)); +-- error 1093 +insert into v3 (col1) values ((select max(col1) from v1)); +-- error 1093 +insert into v3 (col1) values ((select max(col1) from t1)); +-- error 1093 +insert into v3 (col1) values ((select max(col1) from v2)); +#check with TZ tables in list +-- error 1093 +insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from v2)); +insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2)); +-- error 1048 +insert into mysql.time_zone values ('', (select CONVERT_TZ('20050101000000','UTC','MET') from t2)); +# temporary table algorithm view should be equal to subquery in the from clause +create algorithm=temptable view v4 as select * from t1; +insert into t1 values (1),(2),(3); +insert into t1 (col1) values ((select max(col1) from v4)); +select * from t1; + +drop view v4,v3,v2,v1; drop table t1,t2; # @@ -1499,24 +1229,6 @@ select concat('|',a,'|'), concat('|',b,'|') from v1; drop view v1; drop table t1; -# -# user with global DB privileges -# -connection root; ---disable_warnings -create database mysqltest; ---enable_warnings -create table mysqltest.t1 (a int); -grant all privileges on mysqltest.* to mysqltest_1@localhost; - -connection user1; -use mysqltest; -create view v1 as select * from t1; - -connection root; -revoke all privileges on mysqltest.* from mysqltest_1@localhost; -drop database mysqltest; - # # Trys update table from which we select using views and subqueries # @@ -1637,6 +1349,8 @@ select * from t2; delete from v3; -- error 1395 delete v3,t1 from v3,t1; +-- error 1395 +delete t1,v3 from t1,v3; # delete from t1 just to reduce result set size delete from t1; # prepare statement with insert join view @@ -1716,3 +1430,92 @@ select s2 from v1 vq1 where 2 = (select count(*) aa from v1 vq2 having vq1.s2 = drop view v1; drop table t1; +# +# Test case for bug #9398 CREATE TABLE with SELECT from a multi-table view +# +CREATE TABLE t1 (a1 int); +CREATE TABLE t2 (a2 int); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (1), (2), (3); +CREATE VIEW v1(a,b) AS SELECT a1,a2 FROM t1 JOIN t2 ON a1=a2 WHERE a1>1; + +SELECT * FROM v1; +CREATE TABLE t3 SELECT * FROM v1; +SELECT * FROM t3; + +DROP VIEW v1; +DROP TABLE t1,t2,t3; + +# +# Test for BUG#8703 "insert into table select from view crashes" +# +create table t1 (a int); +create table t2 like t1; +create table t3 like t1; +create view v1 as select t1.a x, t2.a y from t1 join t2 where t1.a=t2.a; +insert into t3 select x from v1; +insert into t2 select x from v1; +drop view v1; +drop table t1,t2,t3; + +# +# Test for BUG #6106: query over a view using subquery for the underlying table +# + +CREATE TABLE t1 (col1 int PRIMARY KEY, col2 varchar(10)); +INSERT INTO t1 VALUES(1,'trudy'); +INSERT INTO t1 VALUES(2,'peter'); +INSERT INTO t1 VALUES(3,'sanja'); +INSERT INTO t1 VALUES(4,'monty'); +INSERT INTO t1 VALUES(5,'david'); +INSERT INTO t1 VALUES(6,'kent'); +INSERT INTO t1 VALUES(7,'carsten'); +INSERT INTO t1 VALUES(8,'ranger'); +INSERT INTO t1 VALUES(10,'matt'); +CREATE TABLE t2 (col1 int, col2 int, col3 char(1)); +INSERT INTO t2 VALUES (1,1,'y'); +INSERT INTO t2 VALUES (1,2,'y'); +INSERT INTO t2 VALUES (2,1,'n'); +INSERT INTO t2 VALUES (3,1,'n'); +INSERT INTO t2 VALUES (4,1,'y'); +INSERT INTO t2 VALUES (4,2,'n'); +INSERT INTO t2 VALUES (4,3,'n'); +INSERT INTO t2 VALUES (6,1,'n'); +INSERT INTO t2 VALUES (8,1,'y'); + +CREATE VIEW v1 AS SELECT * FROM t1; + +SELECT a.col1,a.col2,b.col2,b.col3 + FROM t1 a LEFT JOIN t2 b ON a.col1=b.col1 + WHERE b.col2 IS NULL OR + b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1); + +SELECT a.col1,a.col2,b.col2,b.col3 + FROM v1 a LEFT JOIN t2 b ON a.col1=b.col1 + WHERE b.col2 IS NULL OR + b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1); + +CREATE VIEW v2 AS SELECT * FROM t2; + +SELECT a.col1,a.col2,b.col2,b.col3 + FROM v2 b RIGHT JOIN v1 a ON a.col1=b.col1 + WHERE b.col2 IS NULL OR + b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1); + +# Tests from the report for bug #6107 + +SELECT a.col1,a.col2,b.col2,b.col3 + FROM v2 b RIGHT JOIN v1 a ON a.col1=b.col1 + WHERE a.col1 IN (1,5,9) AND + (b.col2 IS NULL OR + b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1)); + +CREATE VIEW v3 AS SELECT * FROM t1 WHERE col1 IN (1,5,9); + +SELECT a.col1,a.col2,b.col2,b.col3 + FROM v2 b RIGHT JOIN v3 a ON a.col1=b.col1 + WHERE b.col2 IS NULL OR + b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1); + +DROP VIEW v1,v2,v3; +DROP TABLE t1,t2; diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test new file mode 100644 index 00000000000..bb603b75daa --- /dev/null +++ b/mysql-test/t/view_grant.test @@ -0,0 +1,403 @@ +# Can't test with embedded server +-- source include/not_embedded.inc + +# simple test of grants +grant create view on test.* to test@localhost; +show grants for test@localhost; +revoke create view on test.* from test@localhost; +show grants for test@localhost; + +# grant create view test +# +connect (root,localhost,root,,test); +connection root; +--disable_warnings +create database mysqltest; +--enable_warnings + +create table mysqltest.t1 (a int, b int); +create table mysqltest.t2 (a int, b int); + +grant select on mysqltest.t1 to mysqltest_1@localhost; +grant create view,select on test.* to mysqltest_1@localhost; + +connect (user1,localhost,mysqltest_1,,test); +connection user1; + +create view v1 as select * from mysqltest.t1; +# try to modify view without DROP privilege on it +-- error 1142 +alter view v1 as select * from mysqltest.t1; +-- error 1142 +create or replace view v1 as select * from mysqltest.t1; +# no CRETE VIEW privilege +-- error 1142 +create view mysqltest.v2 as select * from mysqltest.t1; +# no SELECT privilege +-- error 1142 +create view v2 as select * from mysqltest.t2; + +connection root; +grant create view,drop,select on test.* to mysqltest_1@localhost; + +connection user1; +# following 'use' command is workaround of bug #9582 and should be removed +# when that bug will be fixed +use test; +alter view v1 as select * from mysqltest.t1; +create or replace view v1 as select * from mysqltest.t1; + +connection root; +revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; +revoke all privileges on test.* from mysqltest_1@localhost; + +drop database mysqltest; +drop view test.v1; + +# +# grants per columns +# +# MERGE algorithm +--disable_warnings +create database mysqltest; +--enable_warnings + +create table mysqltest.t1 (a int, b int); +create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; +grant select (c) on mysqltest.v1 to mysqltest_1@localhost; + +connection user1; +select c from mysqltest.v1; +# there are no privileges on column 'd' +-- error 1143 +select d from mysqltest.v1; + +connection root; +revoke all privileges on mysqltest.v1 from mysqltest_1@localhost; +delete from mysql.user where user='mysqltest_1'; +drop database mysqltest; + +# TEMPORARY TABLE algorithm +--disable_warnings +create database mysqltest; +--enable_warnings + +create table mysqltest.t1 (a int, b int); +create algorithm=temptable view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; +grant select (c) on mysqltest.v1 to mysqltest_1@localhost; + +connection user1; +select c from mysqltest.v1; +# there are no privileges on column 'd' +-- error 1143 +select d from mysqltest.v1; + +connection root; +revoke all privileges on mysqltest.v1 from mysqltest_1@localhost; +delete from mysql.user where user='mysqltest_1'; +drop database mysqltest; + +# +# EXPLAIN rights +# +connection root; +--disable_warnings +create database mysqltest; +--enable_warnings +#prepare views and tables +create table mysqltest.t1 (a int, b int); +create table mysqltest.t2 (a int, b int); +create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1; +create algorithm=temptable view mysqltest.v2 (c,d) as select a+1,b+1 from mysqltest.t1; +create view mysqltest.v3 (c,d) as select a+1,b+1 from mysqltest.t2; +create algorithm=temptable view mysqltest.v4 (c,d) as select a+1,b+1 from mysqltest.t2; +grant select on mysqltest.v1 to mysqltest_1@localhost; +grant select on mysqltest.v2 to mysqltest_1@localhost; +grant select on mysqltest.v3 to mysqltest_1@localhost; +grant select on mysqltest.v4 to mysqltest_1@localhost; + +connection user1; +# all selects works +select c from mysqltest.v1; +select c from mysqltest.v2; +select c from mysqltest.v3; +select c from mysqltest.v4; +# test of show coluns +show columns from mysqltest.v1; +show columns from mysqltest.v2; +# but explain/show do not +-- error 1345 +explain select c from mysqltest.v1; +-- error 1142 +show create view mysqltest.v1; +-- error 1345 +explain select c from mysqltest.v2; +-- error 1142 +show create view mysqltest.v2; +-- error 1345 +explain select c from mysqltest.v3; +-- error 1142 +show create view mysqltest.v3; +-- error 1345 +explain select c from mysqltest.v4; +-- error 1142 +show create view mysqltest.v4; + +# allow to see one of underlying table +connection root; +grant select on mysqltest.t1 to mysqltest_1@localhost; +connection user1; +# EXPLAIN of view on above table works +explain select c from mysqltest.v1; +-- error 1142 +show create view mysqltest.v1; +explain select c from mysqltest.v2; +-- error 1142 +show create view mysqltest.v2; +# but other EXPLAINs do not +-- error 1345 +explain select c from mysqltest.v3; +-- error 1142 +show create view mysqltest.v3; +-- error 1345 +explain select c from mysqltest.v4; +-- error 1142 +show create view mysqltest.v4; + +# allow to see any view in mysqltest database +connection root; +grant show view on mysqltest.* to mysqltest_1@localhost; +connection user1; +explain select c from mysqltest.v1; +show create view mysqltest.v1; +explain select c from mysqltest.v2; +show create view mysqltest.v2; +explain select c from mysqltest.v3; +show create view mysqltest.v3; +explain select c from mysqltest.v4; +show create view mysqltest.v4; + +connection root; +revoke all privileges on mysqltest.* from mysqltest_1@localhost; +delete from mysql.user where user='mysqltest_1'; +drop database mysqltest; + +# +# UPDATE privileges on VIEW columns and whole VIEW +# +connection root; +--disable_warnings +create database mysqltest; +--enable_warnings + +create table mysqltest.t1 (a int, b int, primary key(a)); +insert into mysqltest.t1 values (10,2), (20,3), (30,4), (40,5), (50,10); +create table mysqltest.t2 (x int); +insert into mysqltest.t2 values (3), (4), (5), (6); +create view mysqltest.v1 (a,c) as select a, b+1 from mysqltest.t1; +create view mysqltest.v2 (a,c) as select a, b from mysqltest.t1; +create view mysqltest.v3 (a,c) as select a, b+1 from mysqltest.t1; + +grant update (a) on mysqltest.v2 to mysqltest_1@localhost; +grant update on mysqltest.v1 to mysqltest_1@localhost; +grant select on mysqltest.* to mysqltest_1@localhost; + +connection user1; +use mysqltest; +# update with rights on VIEW column +update t2,v1 set v1.a=v1.a+v1.c where t2.x=v1.c; +select * from t1; +update v1 set a=a+c; +select * from t1; +# update with rights on whole VIEW +update t2,v2 set v2.a=v2.a+v2.c where t2.x=v2.c; +select * from t1; +update v2 set a=a+c; +select * from t1; +# no rights on column +-- error 1143 +update t2,v2 set v2.c=v2.a+v2.c where t2.x=v2.c; +-- error 1143 +update v2 set c=a+c; +# no rights for view +-- error 1142 +update t2,v3 set v3.a=v3.a+v3.c where t2.x=v3.c; +-- error 1142 +update v3 set a=a+c; + +use test; +connection root; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; + +# +# DELETE privileges on VIEW +# +connection root; +--disable_warnings +create database mysqltest; +--enable_warnings + +create table mysqltest.t1 (a int, b int, primary key(a)); +insert into mysqltest.t1 values (1,2), (2,3), (3,4), (4,5), (5,10); +create table mysqltest.t2 (x int); +insert into mysqltest.t2 values (3), (4), (5), (6); +create view mysqltest.v1 (a,c) as select a, b+1 from mysqltest.t1; +create view mysqltest.v2 (a,c) as select a, b+1 from mysqltest.t1; + +grant delete on mysqltest.v1 to mysqltest_1@localhost; +grant select on mysqltest.* to mysqltest_1@localhost; + +connection user1; +use mysqltest; +# update with rights on VIEW column +delete from v1 where c < 4; +select * from t1; +delete v1 from t2,v1 where t2.x=v1.c; +select * from t1; +# no rights for view +-- error 1142 +delete v2 from t2,v2 where t2.x=v2.c; +-- error 1142 +delete from v2 where c < 4; + +use test; +connection root; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; + +# +# insert privileges on VIEW +# +connection root; +--disable_warnings +create database mysqltest; +--enable_warnings + +create table mysqltest.t1 (a int, b int, primary key(a)); +insert into mysqltest.t1 values (1,2), (2,3); +create table mysqltest.t2 (x int, y int); +insert into mysqltest.t2 values (3,4); +create view mysqltest.v1 (a,c) as select a, b from mysqltest.t1; +create view mysqltest.v2 (a,c) as select a, b from mysqltest.t1; + +grant insert on mysqltest.v1 to mysqltest_1@localhost; +grant select on mysqltest.* to mysqltest_1@localhost; + +connection user1; +use mysqltest; +# update with rights on VIEW column +insert into v1 values (5,6); +select * from t1; +insert into v1 select x,y from t2; +select * from t1; +# no rights for view +-- error 1142 +insert into v2 values (5,6); +-- error 1142 +insert into v2 select x,y from t2; + +use test; +connection root; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; + +# +# test of CREATE VIEW privileges if we have limited privileges +# +connection root; +--disable_warnings +create database mysqltest; +--enable_warnings + +create table mysqltest.t1 (a int, b int); +create table mysqltest.t2 (a int, b int); + +grant update on mysqltest.t1 to mysqltest_1@localhost; +grant update(b) on mysqltest.t2 to mysqltest_1@localhost; +grant create view,update on test.* to mysqltest_1@localhost; + +connection user1; + +create view v1 as select * from mysqltest.t1; +create view v2 as select b from mysqltest.t2; +# There are not rights on mysqltest.v1 +-- error 1142 +create view mysqltest.v1 as select * from mysqltest.t1; +# There are not any rights on mysqltest.t2.a +-- error 1143 +create view v3 as select a from mysqltest.t2; + +# give CREATE VIEW privileges (without any privileges for result column) +connection root; +create table mysqltest.v3 (b int); +grant create view on mysqltest.v3 to mysqltest_1@localhost; +drop table mysqltest.v3; +connection user1; +create view mysqltest.v3 as select b from mysqltest.t2; + +# give UPDATE privileges +connection root; +grant create view, update on mysqltest.v3 to mysqltest_1@localhost; +drop view mysqltest.v3; +connection user1; +create view mysqltest.v3 as select b from mysqltest.t2; + +# give UPDATE and INSERT privilege (to get more privileges then underlying +# table) +connection root; +grant create view, update, insert on mysqltest.v3 to mysqltest_1@localhost; +drop view mysqltest.v3; +connection user1; +-- error 1143 +create view mysqltest.v3 as select b from mysqltest.t2; + + +# If we would get more privileges on VIEW then we have on +# underlying tables => creation prohibited +connection root; +create table mysqltest.v3 (b int); +grant select(b) on mysqltest.v3 to mysqltest_1@localhost; +drop table mysqltest.v3; +connection user1; +-- error 1142 +create view mysqltest.v3 as select b from mysqltest.t2; + +# Expression need select privileges +-- error 1143 +create view v4 as select b+1 from mysqltest.t2; + +connection root; +grant create view,update,select on test.* to mysqltest_1@localhost; +connection user1; +-- error 1143 +create view v4 as select b+1 from mysqltest.t2; + +connection root; +grant update,select(b) on mysqltest.t2 to mysqltest_1@localhost; +connection user1; +create view v4 as select b+1 from mysqltest.t2; + +connection root; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; +drop database mysqltest; +drop view v1,v2,v4; + +# +# user with global DB privileges +# +connection root; +--disable_warnings +create database mysqltest; +--enable_warnings +create table mysqltest.t1 (a int); +grant all privileges on mysqltest.* to mysqltest_1@localhost; + +connection user1; +use mysqltest; +create view v1 as select * from t1; + +connection root; +revoke all privileges on mysqltest.* from mysqltest_1@localhost; +drop database mysqltest; + diff --git a/mysql-test/t/xa.test b/mysql-test/t/xa.test new file mode 100644 index 00000000000..321e5008035 --- /dev/null +++ b/mysql-test/t/xa.test @@ -0,0 +1,58 @@ +# +# WL#1756 +# +-- source include/have_innodb.inc +--disable_warnings +drop table if exists t1, t2; +--enable_warnings +create table t1 (a int) engine=innodb; +xa start 'test1'; +insert t1 values (10); +xa end 'test1'; +xa prepare 'test1'; +xa rollback 'test1'; +select * from t1; + +xa start 'test2'; +--error 1399 +xa start 'test-bad'; +insert t1 values (20); +--error 1399 +xa prepare 'test2'; +xa end 'test2'; +xa prepare 'test2'; +xa commit 'test2'; +select * from t1; + +xa start 'testa','testb'; +insert t1 values (30); +xa end 'testa','testb'; + +connect (con1,localhost,,,); +connection con1; + +# gtrid [ , bqual [ , formatID ] ] +xa start 0x7465737462, 0x2030405060, 0xb; +insert t1 values (40); +xa end 'testb',' 0@P`',11; +xa prepare 'testb',0x2030405060,11; + +xa recover; + +# uncomment the line below when binlog will be able to prepare +#disconnect con1; +connection default; + +xa prepare 'testa','testb'; + +xa recover; + +xa commit 'testb',0x2030405060,11; +xa rollback 'testa','testb'; + +--error 1064 +xa start 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'; + +select * from t1; +drop table t1; + diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp new file mode 100644 index 00000000000..d8a13ca9dfd --- /dev/null +++ b/mysql-test/valgrind.supp @@ -0,0 +1,94 @@ +# +# Suppress some common (not fatal) errors in system libraries found by valgrind +# + +# +# Pthread doesn't free all thread specific memory before program exists +# +{ + pthread allocate_tls memory loss + Memcheck:Leak + fun:calloc + fun:_dl_allocate_tls + fun:allocate_stack + fun:pthread_create@@GLIBC_2.1 +} + +{ + pthread allocate_dtv memory loss + Memcheck:Leak + fun:calloc + fun:allocate_dtv + fun:_dl_allocate_tls_storage + fun:__GI__dl_allocate_tls + fun:pthread_create +} + +{ + pthread memalign memory loss + Memcheck:Leak + fun:memalign + fun:_dl_allocate_tls_storage + fun:__GI__dl_allocate_tls + fun:pthread_create +} + +{ + pthread errno + Memcheck:Leak + fun:calloc + fun:_dlerror_run + fun:dlsym + fun:__errno_location +} + + +# +# Warnings in libz becasue it works with aligned memory(?) +# + +{ + libz tr_flush_block + Memcheck:Cond + fun:_tr_flush_block + fun:deflate_slow + fun:deflate + fun:do_flush + fun:gzclose +} + +{ + libz tr_flush_block2 + Memcheck:Cond + fun:_tr_flush_block + fun:deflate_slow + fun:deflate + fun:compress2 +} + +{ + libz longest_match + Memcheck:Cond + fun:longest_match + fun:deflate_slow + fun:deflate + fun:do_flush +} + +{ + libz longest_match2 + Memcheck:Cond + fun:longest_match + fun:deflate_slow + fun:deflate + fun:compress2 +} + +{ + libz deflate + Memcheck:Cond + obj:/usr/lib/libz.so.* + obj:/usr/lib/libz.so.* + fun:deflate + fun:compress2 +} diff --git a/mysys/charset-def.c b/mysys/charset-def.c index 92453aa0f59..0464ba893fb 100644 --- a/mysys/charset-def.c +++ b/mysys/charset-def.c @@ -62,7 +62,7 @@ extern CHARSET_INFO my_charset_utf8_slovak_uca_ci; extern CHARSET_INFO my_charset_utf8_spanish2_uca_ci; extern CHARSET_INFO my_charset_utf8_roman_uca_ci; extern CHARSET_INFO my_charset_utf8_persian_uca_ci; -#ifdef HAVE_CYBOZU_COLLATION +#ifdef HAVE_UTF8_GENERAL_CS extern CHARSET_INFO my_charset_utf8_general_cs; #endif #endif @@ -159,7 +159,7 @@ my_bool init_compiled_charsets(myf flags __attribute__((unused))) #ifdef HAVE_CHARSET_utf8 add_compiled_collation(&my_charset_utf8_general_ci); add_compiled_collation(&my_charset_utf8_bin); -#ifdef HAVE_CYBOZU_COLLATION +#ifdef HAVE_UTF8_GENERAL_CS add_compiled_collation(&my_charset_utf8_general_cs); #endif #ifdef HAVE_UCA_COLLATIONS diff --git a/mysys/default.c b/mysys/default.c index ddff4e26be5..0f33c94d17e 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -477,13 +477,13 @@ static int search_default_file_with_ext(Process_option_func opt_handler, if ((stat_info.st_mode & S_IWOTH) && (stat_info.st_mode & S_IFMT) == S_IFREG) { - fprintf(stderr, "warning: World-writable config file %s is ignored\n", + fprintf(stderr, "Warning: World-writable config file '%s' is ignored\n", name); return 0; } } #endif - if (!(fp= my_fopen(fn_format(name, name, "", "", 4), O_RDONLY, MYF(0)))) + if (!(fp= my_fopen(name, O_RDONLY, MYF(0)))) return 0; /* Ignore wrong files */ while (fgets(buff, sizeof(buff) - 1, fp)) @@ -513,15 +513,16 @@ static int search_default_file_with_ext(Process_option_func opt_handler, /* trim trailing whitespace from directory name */ end= ptr + strlen(ptr) - 1; - /* - This would work fine even if no whitespaces are met - since fgets() stores the newline character in the buffer - */ - for (; my_isspace(&my_charset_latin1, *(end - 1)); end--) - {} - end[0]= 0; + /* fgets() stores the newline character in the buffer */ + if ((end[0] == '\n') || (end[0] == '\r') || + my_isspace(&my_charset_latin1, end[0])) + { + for (; my_isspace(&my_charset_latin1, *(end - 1)); end--) + {} + end[0]= 0; + } - /* print error msg if there is nothing after !inludedir directive */ + /* print error msg if there is nothing after !includedir directive */ if (end == ptr) { fprintf(stderr, @@ -539,7 +540,7 @@ static int search_default_file_with_ext(Process_option_func opt_handler, search_file= search_dir->dir_entry + i; ext= fn_ext(search_file->name); - /* check extenstion */ + /* check extension */ for (tmp_ext= (char**) f_extensions; *tmp_ext; *tmp_ext++) { if (!strcmp(ext, *tmp_ext)) @@ -587,6 +588,14 @@ static int search_default_file_with_ext(Process_option_func opt_handler, continue; } + else + if (recursion_level >= max_recursion_level) + { + fprintf(stderr, + "warning: skipping !include directive as maximum include" + "recursion level was reached in file %s at line %d\n", + name, line); + } if (*ptr == '[') /* Group name */ { diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 53e46932167..5e93ad56cb5 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -205,7 +205,8 @@ int handle_options(int *argc, char ***argv, { if (!getopt_compare_strings(special_opt_prefix[i], opt_str, special_opt_prefix_lengths[i]) && - opt_str[special_opt_prefix_lengths[i]] == '-') + (opt_str[special_opt_prefix_lengths[i]] == '-' || + opt_str[special_opt_prefix_lengths[i]] == '_')) { /* We were called with a special prefix, we can reuse opt_found diff --git a/mysys/my_sync.c b/mysys/my_sync.c index bd372f03c87..c557324b52c 100644 --- a/mysys/my_sync.c +++ b/mysys/my_sync.c @@ -27,7 +27,14 @@ my_flags Flags (now only MY_WME is supported) NOTE - If file system supports its, only file data is synced, not inode date + If file system supports its, only file data is synced, not inode data. + + MY_IGNORE_BADFD is useful when fd is "volatile" - not protected by a + mutex. In this case by the time of fsync(), fd may be already closed by + another thread, or even reassigned to a different file. With this flag - + MY_IGNORE_BADFD - such a situation will not be considered an error. + (which is correct behaviour, if we know that the other thread synced the + file before closing) RETURN 0 ok @@ -55,10 +62,15 @@ int my_sync(File fd, myf my_flags) if (res) { - if (!(my_errno= errno)) - my_errno= -1; /* Unknown error */ - if (my_flags & MY_WME) + int er= errno; + if (!(my_errno= er)) + my_errno= -1; /* Unknown error */ + if ((my_flags & MY_IGNORE_BADFD) && + (er == EBADF || er == EINVAL || er == EROFS)) + res= 0; + else if (my_flags & MY_WME) my_error(EE_SYNC, MYF(ME_BELL+ME_WAITTANG), my_filename(fd), my_errno); } DBUG_RETURN(res); -} /* my_read */ +} /* my_sync */ + diff --git a/ndb/include/ndbapi/NdbScanOperation.hpp b/ndb/include/ndbapi/NdbScanOperation.hpp index 5da717148b5..1c9649195d2 100644 --- a/ndb/include/ndbapi/NdbScanOperation.hpp +++ b/ndb/include/ndbapi/NdbScanOperation.hpp @@ -115,7 +115,7 @@ public: /** * Close scan */ - void close(bool forceSend = false); + void close(bool forceSend = false, bool releaseOp = false); /** * Update current tuple diff --git a/ndb/include/ndbapi/NdbTransaction.hpp b/ndb/include/ndbapi/NdbTransaction.hpp index 50e4e766803..2e102b104d8 100644 --- a/ndb/include/ndbapi/NdbTransaction.hpp +++ b/ndb/include/ndbapi/NdbTransaction.hpp @@ -658,6 +658,7 @@ private: // Release all cursor operations in connection void releaseOps(NdbOperation*); void releaseScanOperations(NdbIndexScanOperation*); + void releaseExecutedScanOperation(NdbIndexScanOperation*); // Set the transaction identity of the transaction void setTransactionId(Uint64 aTransactionId); diff --git a/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp b/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp index a16c0da369b..bf73e263501 100644 --- a/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp +++ b/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp @@ -9645,10 +9645,10 @@ void Dbacc::execACC_CHECK_SCAN(Signal* signal) operationRecPtr.i = scanPtr.p->scanFirstQueuedOp; ptrCheckGuard(operationRecPtr, coprecsize, operationrec); takeOutReadyScanQueue(signal); + fragrecptr.i = operationRecPtr.p->fragptr; + ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec); if (operationRecPtr.p->elementIsDisappeared == ZTRUE) { jam(); - fragrecptr.i = operationRecPtr.p->fragptr; - ptrCheckGuard(fragrecptr, cfragmentsize, fragmentrec); if (fragrecptr.p->createLcp == ZTRUE) { if (remainingUndoPages() < ZMIN_UNDO_PAGES_AT_COMMIT) { jam(); diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index af75707560a..b2ed7acd347 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -69,6 +69,9 @@ #include #include +#include +extern EventLogger g_eventLogger; + #define SYSFILE ((Sysfile *)&sysfileData[0]) #define RETURN_IF_NODE_NOT_ALIVE(node) \ @@ -13131,6 +13134,48 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal) } } } + + if(dumpState->args[0] == 7019 && signal->getLength() == 2) + { + char buf2[8+1]; + NodeRecordPtr nodePtr; + nodePtr.i = signal->theData[1]; + ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord); + infoEvent("NF Node %d tc: %d lqh: %d dih: %d dict: %d recNODE_FAILREP: %d", + nodePtr.i, + nodePtr.p->dbtcFailCompleted, + nodePtr.p->dblqhFailCompleted, + nodePtr.p->dbdihFailCompleted, + nodePtr.p->dbdictFailCompleted, + nodePtr.p->recNODE_FAILREP); + infoEvent(" m_NF_COMPLETE_REP: %s m_nodefailSteps: %s", + nodePtr.p->m_NF_COMPLETE_REP.getText(), + nodePtr.p->m_nodefailSteps.getText(buf2)); + } + + if(dumpState->args[0] == 7020 && signal->getLength() > 3) + { + Uint32 gsn= signal->theData[1]; + Uint32 block= signal->theData[2]; + Uint32 length= signal->length() - 3; + memmove(signal->theData, signal->theData+3, 4*length); + sendSignal(numberToRef(block, getOwnNodeId()), gsn, signal, length, JBB); + + warningEvent("-- SENDING CUSTOM SIGNAL --"); + char buf[100], buf2[100]; + buf2[0]= 0; + for(Uint32 i = 0; itheData[i]); + snprintf(buf2, 100, "%s", buf); + } + warningEvent("gsn: %d block: %s, length: %d theData: %s", + gsn, getBlockName(block, "UNKNOWN"), length, buf); + + g_eventLogger.warning("-- SENDING CUSTOM SIGNAL --"); + g_eventLogger.warning("gsn: %d block: %s, length: %d theData: %s", + gsn, getBlockName(block, "UNKNOWN"), length, buf); + } if(dumpState->args[0] == DumpStateOrd::DihDumpLCPState){ infoEvent("-- Node %d LCP STATE --", getOwnNodeId()); diff --git a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index c34d4ddb566..b0d44bf1bd9 100644 --- a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -7520,13 +7520,13 @@ void Dblqh::execSCAN_FRAGREQ(Signal* signal) ndbrequire(max_rows > 0 && max_rows <= MAX_PARALLEL_OP_PER_SCAN); if (!getFragmentrec(signal, fragId)) { - errorCode = __LINE__; + errorCode = 1231; goto error_handler; }//if // Verify scan type vs table type (both sides are boolean) if (rangeScan != DictTabInfo::isOrderedIndex(fragptr.p->tableType)) { - errorCode = __LINE__; // XXX fix + errorCode = 1232; goto error_handler; }//if diff --git a/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp b/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp index c3f85cdebd5..3170d23499a 100644 --- a/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp +++ b/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp @@ -813,6 +813,7 @@ Dbtup::updateFixedSizeTHManyWordNotNULL(Uint32* inBuffer, ndbrequire(i < regTabPtr->noOfCharsets); // not const in MySQL CHARSET_INFO* cs = regTabPtr->charsetArray[i]; + int not_used; const char* ssrc = (const char*)&inBuffer[tInBufIndex + 1]; Uint32 lb, len; if (! NdbSqlUtil::get_var_length(typeId, ssrc, bytes, lb, len)) { @@ -822,7 +823,7 @@ Dbtup::updateFixedSizeTHManyWordNotNULL(Uint32* inBuffer, } // fast fix bug#7340 if (typeId != NDB_TYPE_TEXT && - (*cs->cset->well_formed_len)(cs, ssrc + lb, ssrc + lb + len, ZNIL) != len) { + (*cs->cset->well_formed_len)(cs, ssrc + lb, ssrc + lb + len, ZNIL, ¬_used) != len) { ljam(); terrorCode = ZINVALID_CHAR_FORMAT; return false; diff --git a/ndb/src/kernel/main.cpp b/ndb/src/kernel/main.cpp index bd15ef37e20..543757153d3 100644 --- a/ndb/src/kernel/main.cpp +++ b/ndb/src/kernel/main.cpp @@ -61,7 +61,9 @@ int main(int argc, char** argv) // Print to stdout/console g_eventLogger.createConsoleHandler(); g_eventLogger.setCategory("NDB"); + g_eventLogger.enable(Logger::LL_ON, Logger::LL_CRITICAL); g_eventLogger.enable(Logger::LL_ON, Logger::LL_ERROR); + g_eventLogger.enable(Logger::LL_ON, Logger::LL_WARNING); globalEmulatorData.create(); diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 21c3c4d614d..86a5f3e8f4b 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -2078,7 +2078,7 @@ MgmtSrvr::handleStopReply(NodeId nodeId, Uint32 errCode) } void -MgmtSrvr::handleStatus(NodeId nodeId, bool alive) +MgmtSrvr::handleStatus(NodeId nodeId, bool alive, bool nfComplete) { DBUG_ENTER("MgmtSrvr::handleStatus"); Uint32 theData[25]; @@ -2087,9 +2087,14 @@ MgmtSrvr::handleStatus(NodeId nodeId, bool alive) m_started_nodes.push_back(nodeId); theData[0] = NDB_LE_Connected; } else { - handleStopReply(nodeId, 0); theData[0] = NDB_LE_Disconnected; + if(nfComplete) + { + handleStopReply(nodeId, 0); + DBUG_VOID_RETURN; + } } + eventReport(_ownNodeId, theData); DBUG_VOID_RETURN; } @@ -2114,8 +2119,7 @@ MgmtSrvr::nodeStatusNotification(void* mgmSrv, Uint32 nodeId, { DBUG_ENTER("MgmtSrvr::nodeStatusNotification"); DBUG_PRINT("enter",("nodeid= %d, alive= %d, nfComplete= %d", nodeId, alive, nfComplete)); - if(!(!alive && nfComplete)) - ((MgmtSrvr*)mgmSrv)->handleStatus(nodeId, alive); + ((MgmtSrvr*)mgmSrv)->handleStatus(nodeId, alive, nfComplete); DBUG_VOID_RETURN; } diff --git a/ndb/src/mgmsrv/MgmtSrvr.hpp b/ndb/src/mgmsrv/MgmtSrvr.hpp index 95298630230..637f54f74a8 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.hpp +++ b/ndb/src/mgmsrv/MgmtSrvr.hpp @@ -584,7 +584,7 @@ private: // Returns: - //************************************************************************** - void handleStatus(NodeId nodeId, bool alive); + void handleStatus(NodeId nodeId, bool alive, bool nfComplete); //************************************************************************** // Description: Handle the death of a process // Parameters: diff --git a/ndb/src/ndbapi/Ndb.cpp b/ndb/src/ndbapi/Ndb.cpp index b047ae1bd1a..c01ce823dc0 100644 --- a/ndb/src/ndbapi/Ndb.cpp +++ b/ndb/src/ndbapi/Ndb.cpp @@ -756,26 +756,28 @@ Remark: Returns a new TupleId to the application. Uint64 Ndb::getAutoIncrementValue(const char* aTableName, Uint32 cacheSize) { - DEBUG_TRACE("getAutoIncrementValue"); + DBUG_ENTER("getAutoIncrementValue"); const char * internalTableName = internalizeTableName(aTableName); Ndb_local_table_info *info= theDictionary->get_local_table_info(internalTableName, false); if (info == 0) - return ~0; + DBUG_RETURN(~(Uint64)0); const NdbTableImpl *table= info->m_table_impl; Uint64 tupleId = getTupleIdFromNdb(table->m_tableId, cacheSize); - return tupleId; + DBUG_PRINT("info", ("value %u", tupleId)); + DBUG_RETURN(tupleId); } Uint64 Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable, Uint32 cacheSize) { - DEBUG_TRACE("getAutoIncrementValue"); + DBUG_ENTER("getAutoIncrementValue"); if (aTable == 0) - return ~0; + DBUG_RETURN(~(Uint64)0); const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable); Uint64 tupleId = getTupleIdFromNdb(table->m_tableId, cacheSize); - return tupleId; + DBUG_PRINT("info", ("value %u", tupleId)); + DBUG_RETURN(tupleId); } Uint64 @@ -783,46 +785,52 @@ Ndb::getTupleIdFromNdb(const char* aTableName, Uint32 cacheSize) { const NdbTableImpl* table = theDictionary->getTable(aTableName); if (table == 0) - return ~0; + return ~(Uint64)0; return getTupleIdFromNdb(table->m_tableId, cacheSize); } Uint64 Ndb::getTupleIdFromNdb(Uint32 aTableId, Uint32 cacheSize) { + DBUG_ENTER("getTupleIdFromNdb"); if ( theFirstTupleId[aTableId] != theLastTupleId[aTableId] ) { theFirstTupleId[aTableId]++; - return theFirstTupleId[aTableId]; + DBUG_PRINT("info", ("next cached value %u", theFirstTupleId[aTableId])); + DBUG_RETURN(theFirstTupleId[aTableId]); } else // theFirstTupleId == theLastTupleId { - return opTupleIdOnNdb(aTableId, cacheSize, 0); + DBUG_PRINT("info",("reading %u values from database", + (cacheSize == 0) ? 1 : cacheSize)); + DBUG_RETURN(opTupleIdOnNdb(aTableId, (cacheSize == 0) ? 1 : cacheSize, 0)); } } Uint64 Ndb::readAutoIncrementValue(const char* aTableName) { - DEBUG_TRACE("readtAutoIncrementValue"); + DBUG_ENTER("readtAutoIncrementValue"); const NdbTableImpl* table = theDictionary->getTable(aTableName); if (table == 0) { theError= theDictionary->getNdbError(); - return ~0; + DBUG_RETURN(~(Uint64)0); } Uint64 tupleId = readTupleIdFromNdb(table->m_tableId); - return tupleId; + DBUG_PRINT("info", ("value %u", tupleId)); + DBUG_RETURN(tupleId); } Uint64 Ndb::readAutoIncrementValue(const NdbDictionary::Table * aTable) { - DEBUG_TRACE("readtAutoIncrementValue"); + DBUG_ENTER("readtAutoIncrementValue"); if (aTable == 0) - return ~0; + DBUG_RETURN(~(Uint64)0); const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable); Uint64 tupleId = readTupleIdFromNdb(table->m_tableId); - return tupleId; + DBUG_PRINT("info", ("value %u", tupleId)); + DBUG_RETURN(tupleId); } Uint64 @@ -855,7 +863,7 @@ Ndb::setAutoIncrementValue(const NdbDictionary::Table * aTable, Uint64 val, bool { DEBUG_TRACE("setAutoIncrementValue " << val); if (aTable == 0) - return ~0; + return ~(Uint64)0; const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable); return setTupleIdInNdb(table->m_tableId, val, increase); } @@ -1010,7 +1018,7 @@ Ndb::opTupleIdOnNdb(Uint32 aTableId, Uint64 opValue, Uint32 op) theError.code, tConnection ? tConnection->theError.code : -1, tOperation ? tOperation->theError.code : -1)); - DBUG_RETURN(~0); + DBUG_RETURN(~(Uint64)0); } Uint32 diff --git a/ndb/src/ndbapi/NdbScanOperation.cpp b/ndb/src/ndbapi/NdbScanOperation.cpp index 9cd78ec721b..5980f2588bc 100644 --- a/ndb/src/ndbapi/NdbScanOperation.cpp +++ b/ndb/src/ndbapi/NdbScanOperation.cpp @@ -633,8 +633,14 @@ NdbScanOperation::doSend(int ProcessorId) return 0; } -void NdbScanOperation::close(bool forceSend) +void NdbScanOperation::close(bool forceSend, bool releaseOp) { + DBUG_ENTER("NdbScanOperation::close"); + DBUG_PRINT("enter", ("this=%x tcon=%x con=%x force=%d release=%d", + (UintPtr)this, + (UintPtr)m_transConnection, (UintPtr)theNdbCon, + forceSend, releaseOp)); + if(m_transConnection){ if(DEBUG_NEXT_RESULT) ndbout_c("close() theError.code = %d " @@ -650,13 +656,21 @@ void NdbScanOperation::close(bool forceSend) Guard guard(tp->theMutexPtr); close_impl(tp, forceSend); - } while(0); - - theNdbCon->theScanningOp = 0; - theNdb->closeTransaction(theNdbCon); - - theNdbCon = 0; + } + + NdbConnection* tCon = theNdbCon; + NdbConnection* tTransCon = m_transConnection; + theNdbCon = NULL; m_transConnection = NULL; + + if (releaseOp && tTransCon) { + NdbIndexScanOperation* tOp = (NdbIndexScanOperation*)this; + tTransCon->releaseExecutedScanOperation(tOp); + } + + tCon->theScanningOp = 0; + theNdb->closeTransaction(tCon); + DBUG_VOID_RETURN; } void diff --git a/ndb/src/ndbapi/NdbTransaction.cpp b/ndb/src/ndbapi/NdbTransaction.cpp index 67581e4a0f8..e32a7ddf70a 100644 --- a/ndb/src/ndbapi/NdbTransaction.cpp +++ b/ndb/src/ndbapi/NdbTransaction.cpp @@ -948,6 +948,37 @@ NdbTransaction::releaseScanOperations(NdbIndexScanOperation* cursorOp) } }//NdbTransaction::releaseScanOperations() +/***************************************************************************** +void releaseExecutedScanOperation(); + +Remark: Release scan op when hupp'ed trans closed (save memory) +******************************************************************************/ +void +NdbTransaction::releaseExecutedScanOperation(NdbIndexScanOperation* cursorOp) +{ + DBUG_ENTER("NdbTransaction::releaseExecutedScanOperation"); + DBUG_PRINT("enter", ("this=0x%x op=0x%x", (UintPtr)this, (UintPtr)cursorOp)) + + // here is one reason to make op lists doubly linked + if (m_firstExecutedScanOp == cursorOp) { + m_firstExecutedScanOp = (NdbIndexScanOperation*)cursorOp->theNext; + cursorOp->release(); + theNdb->releaseScanOperation(cursorOp); + } else if (m_firstExecutedScanOp != NULL) { + NdbIndexScanOperation* tOp = m_firstExecutedScanOp; + while (tOp->theNext != NULL) { + if (tOp->theNext == cursorOp) { + tOp->theNext = cursorOp->theNext; + cursorOp->release(); + theNdb->releaseScanOperation(cursorOp); + break; + } + tOp = (NdbIndexScanOperation*)tOp->theNext; + } + } + DBUG_VOID_RETURN; +}//NdbTransaction::releaseExecutedScanOperation() + /***************************************************************************** NdbOperation* getNdbOperation(const char* aTableName); diff --git a/ndb/src/ndbapi/Ndblist.cpp b/ndb/src/ndbapi/Ndblist.cpp index df90f3378ab..6dfd76c160b 100644 --- a/ndb/src/ndbapi/Ndblist.cpp +++ b/ndb/src/ndbapi/Ndblist.cpp @@ -550,10 +550,21 @@ Remark: Add a NdbScanOperation object into the signal idlelist. void Ndb::releaseScanOperation(NdbIndexScanOperation* aScanOperation) { + DBUG_ENTER("Ndb::releaseScanOperation"); + DBUG_PRINT("enter", ("op=%x", (UintPtr)aScanOperation)); +#ifdef ndb_release_check_dup + { NdbIndexScanOperation* tOp = theScanOpIdleList; + while (tOp != NULL) { + assert(tOp != aScanOperation); + tOp = (NdbIndexScanOperation*)tOp->theNext; + } + } +#endif aScanOperation->next(theScanOpIdleList); aScanOperation->theNdbCon = NULL; aScanOperation->theMagicNumber = 0xFE11D2; theScanOpIdleList = aScanOperation; + DBUG_VOID_RETURN; } /*************************************************************************** diff --git a/ndb/src/ndbapi/ndberror.c b/ndb/src/ndbapi/ndberror.c index b033d81fa33..6792210c968 100644 --- a/ndb/src/ndbapi/ndberror.c +++ b/ndb/src/ndbapi/ndberror.c @@ -356,6 +356,8 @@ ErrorBundle ErrorCodes[] = { { 1226, SE, "Table is being dropped" }, { 1228, SE, "Cannot use drop table for drop index" }, { 1229, SE, "Too long frm data supplied" }, + { 1231, SE, "Invalid table or index to scan" }, + { 1232, SE, "Invalid table or index to scan" }, /** * FunctionNotImplemented diff --git a/ndb/test/ndbapi/testOIBasic.cpp b/ndb/test/ndbapi/testOIBasic.cpp index 96926a421fb..9df983ebe99 100644 --- a/ndb/test/ndbapi/testOIBasic.cpp +++ b/ndb/test/ndbapi/testOIBasic.cpp @@ -482,16 +482,17 @@ Chs::Chs(CHARSET_INFO* cs) : for (unsigned j = 0; j < size; j++) { bytes[j] = urandom(256); } + int not_used; // check wellformed const char* sbytes = (const char*)bytes; - if ((*cs->cset->well_formed_len)(cs, sbytes, sbytes + size, 1) != size) { + if ((*cs->cset->well_formed_len)(cs, sbytes, sbytes + size, 1, ¬_used) != size) { miss1++; continue; } // check no proper prefix wellformed ok = true; for (unsigned j = 1; j < size; j++) { - if ((*cs->cset->well_formed_len)(cs, sbytes, sbytes + j, 1) == j) { + if ((*cs->cset->well_formed_len)(cs, sbytes, sbytes + j, 1, ¬_used) == j) { ok = false; break; } @@ -676,7 +677,8 @@ Col::wellformed(const void* addr) const CHARSET_INFO* cs = m_chs->m_cs; const char* src = (const char*)addr; unsigned len = m_bytelength; - assert((*cs->cset->well_formed_len)(cs, src, src + len, 0xffff) == len); + int not_used; + assert((*cs->cset->well_formed_len)(cs, src, src + len, 0xffff, ¬_used) == len); } break; case Col::Varchar: @@ -685,8 +687,9 @@ Col::wellformed(const void* addr) const const unsigned char* src = (const unsigned char*)addr; const char* ssrc = (const char*)src; unsigned len = src[0]; + int not_used; assert(len <= m_bytelength); - assert((*cs->cset->well_formed_len)(cs, ssrc + 1, ssrc + 1 + len, 0xffff) == len); + assert((*cs->cset->well_formed_len)(cs, ssrc + 1, ssrc + 1 + len, 0xffff, ¬_used) == len); } break; case Col::Longvarchar: @@ -695,8 +698,9 @@ Col::wellformed(const void* addr) const const unsigned char* src = (const unsigned char*)addr; const char* ssrc = (const char*)src; unsigned len = src[0] + (src[1] << 8); + int not_used; assert(len <= m_bytelength); - assert((*cs->cset->well_formed_len)(cs, ssrc + 2, ssrc + 2 + len, 0xffff) == len); + assert((*cs->cset->well_formed_len)(cs, ssrc + 2, ssrc + 2 + len, 0xffff, ¬_used) == len); } break; default: diff --git a/ndb/test/ndbapi/testOperations.cpp b/ndb/test/ndbapi/testOperations.cpp index e254aff58dc..9f1d5ee1191 100644 --- a/ndb/test/ndbapi/testOperations.cpp +++ b/ndb/test/ndbapi/testOperations.cpp @@ -530,6 +530,74 @@ runOperations(NDBT_Context* ctx, NDBT_Step* step) return NDBT_OK; } +int +runLockUpgrade1(NDBT_Context* ctx, NDBT_Step* step){ + // Verify that data in index match + // table data + Ndb* pNdb = GETNDB(step); + HugoOperations hugoOps(*ctx->getTab()); + HugoTransactions hugoTrans(*ctx->getTab()); + + if(hugoTrans.loadTable(pNdb, 1) != 0){ + g_err << "Load table failed" << endl; + return NDBT_FAILED; + } + + int result= NDBT_OK; + do + { + CHECK(hugoOps.startTransaction(pNdb) == 0); + CHECK(hugoOps.pkReadRecord(pNdb, 0, 1, NdbOperation::LM_Read) == 0); + CHECK(hugoOps.execute_NoCommit(pNdb) == 0); + + ctx->setProperty("READ_DONE", 1); + ctx->broadcast(); + ndbout_c("wait 2"); + ctx->getPropertyWait("READ_DONE", 2); + ndbout_c("wait 2 - done"); + ctx->setProperty("READ_DONE", 3); + ctx->broadcast(); + ndbout_c("before update"); + CHECK(hugoOps.pkUpdateRecord(pNdb, 0, 1, 2) == 0); + ndbout_c("wait update"); + CHECK(hugoOps.execute_NoCommit(pNdb) == 0); + CHECK(hugoOps.closeTransaction(pNdb)); + } while(0); + + return result; +} + +int +runLockUpgrade2(NDBT_Context* ctx, NDBT_Step* step){ + // Verify that data in index match + // table data + Ndb* pNdb = GETNDB(step); + HugoOperations hugoOps(*ctx->getTab()); + HugoTransactions hugoTrans(*ctx->getTab()); + + + int result= NDBT_OK; + do + { + CHECK(hugoOps.startTransaction(pNdb) == 0); + ndbout_c("wait 1"); + ctx->getPropertyWait("READ_DONE", 1); + ndbout_c("wait 1 - done"); + CHECK(hugoOps.pkReadRecord(pNdb, 0, 1, NdbOperation::LM_Read) == 0); + CHECK(hugoOps.execute_NoCommit(pNdb) == 0); + ctx->setProperty("READ_DONE", 2); + ctx->broadcast(); + ndbout_c("wait 3"); + ctx->getPropertyWait("READ_DONE", 3); + ndbout_c("wait 3 - done"); + + NdbSleep_MilliSleep(200); + CHECK(hugoOps.execute_Commit(pNdb) == 0); + } while(0); + + return NDBT_FAILED; +} + int main(int argc, const char** argv){ ndb_init(); @@ -538,6 +606,31 @@ main(int argc, const char** argv){ generate(tmp, 5); NDBT_TestSuite ts("testOperations"); + + { + BaseString name("bug_9749"); + NDBT_TestCaseImpl1 *pt = new NDBT_TestCaseImpl1(&ts, + name.c_str(), ""); + + pt->addInitializer(new NDBT_Initializer(pt, + "runClearTable", + runClearTable)); + + pt->addStep(new NDBT_ParallelStep(pt, + "thread1", + runLockUpgrade1)); + + + pt->addStep(new NDBT_ParallelStep(pt, + "thread2", + runLockUpgrade2)); + + pt->addFinalizer(new NDBT_Finalizer(pt, + "runClearTable", + runClearTable)); + ts.addTest(pt); + } + for(size_t i = 0; i fill_help_tables.sql +all: make_win_src_distribution make_binary_distribution make_sharedlib_distribution diff --git a/scripts/fill_help_tables.sql b/scripts/fill_help_tables.sql new file mode 100644 index 00000000000..9f527c288e9 --- /dev/null +++ b/scripts/fill_help_tables.sql @@ -0,0 +1,3 @@ +-- fill_help_tables.sql - this file is a placeholder to satisfy build dependencies - +-- it will be replaced with the appropriate content by the Boostrap script that +-- creates the official source distribution. diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index ddce55c063d..17a9be17108 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -103,6 +103,7 @@ BIN_FILES="extra/comp_err$BS extra/replace$BS extra/perror$BS \ myisam/myisamchk$BS myisam/myisampack$BS myisam/myisamlog$BS \ myisam/myisam_ftdump$BS \ sql/mysqld$BS sql/mysql_tzinfo_to_sql$BS \ + server-tools/instance-manager/mysqlmanager$BS \ client/mysql$BS client/mysqlshow$BS client/mysqladmin$BS \ client/mysqldump$BS client/mysqlimport$BS \ client/mysqltest$BS client/mysqlcheck$BS \ @@ -122,13 +123,13 @@ if [ $BASE_SYSTEM = "netware" ] ; then # For all other platforms: else BIN_FILES="$BIN_FILES \ - client/mysqlmanagerc \ - client/mysqlmanager-pwgen tools/mysqlmanager \ + client/mysqltestmanagerc \ + client/mysqltestmanager-pwgen tools/mysqltestmanager \ client/.libs/mysql client/.libs/mysqlshow client/.libs/mysqladmin \ client/.libs/mysqldump client/.libs/mysqlimport \ client/.libs/mysqltest client/.libs/mysqlcheck \ - client/.libs/mysqlbinlog client/.libs/mysqlmanagerc \ - client/.libs/mysqlmanager-pwgen tools/.libs/mysqlmanager \ + client/.libs/mysqlbinlog client/.libs/mysqltestmanagerc \ + client/.libs/mysqltestmanager-pwgen tools/.libs/mysqltestmanager \ tests/.libs/mysql_client_test \ libmysqld/examples/.libs/mysql_client_test_embedded \ libmysqld/examples/.libs/mysqltest_embedded \ @@ -207,6 +208,7 @@ rm -f $MYSQL_SHARE/Makefile* $MYSQL_SHARE/*/*.OLD for i in mysql-test/mysql-test-run mysql-test/install_test_db \ mysql-test/mysql-test-run.pl mysql-test/README \ + mysql-test/valgrind.supp \ netware/mysql_test_run.nlm netware/install_test_db.ncf do if [ -f $i ] @@ -224,14 +226,14 @@ $CP mysql-test/std_data/*.dat mysql-test/std_data/*.frm \ $BASE/mysql-test/std_data $CP mysql-test/t/*.test mysql-test/t/*.disabled mysql-test/t/*.opt \ mysql-test/t/*.slave-mi mysql-test/t/*.sh $BASE/mysql-test/t -$CP mysql-test/r/*.result mysql-test/r/*.result.es mysql-test/r/*.require \ +$CP mysql-test/r/*.result mysql-test/r/*.require \ $BASE/mysql-test/r if [ $BASE_SYSTEM != "netware" ] ; then chmod a+x $BASE/bin/* $CP scripts/* $BASE/bin $BASE/bin/replace \@localstatedir\@ ./data \@bindir\@ ./bin \@scriptdir\@ ./bin \@libexecdir\@ ./bin \@sbindir\@ ./bin \@prefix\@ . \@HOSTNAME\@ @HOSTNAME@ \@pkgdatadir\@ ./support-files < $SOURCE/scripts/mysql_install_db.sh > $BASE/scripts/mysql_install_db - $BASE/bin/replace \@prefix\@ /usr/local/mysql \@bindir\@ ./bin \@MYSQLD_USER\@ root \@localstatedir\@ /usr/local/mysql/data \@HOSTNAME\@ @HOSTNAME@ < $SOURCE/support-files/mysql.server.sh > $BASE/support-files/mysql.server + $BASE/bin/replace \@prefix\@ /usr/local/mysql \@bindir\@ ./bin \@sbindir\@ ./bin \@libexecdir\@ ./bin \@MYSQLD_USER\@ @MYSQLD_USER@ \@localstatedir\@ /usr/local/mysql/data \@HOSTNAME\@ @HOSTNAME@ < $SOURCE/support-files/mysql.server.sh > $BASE/support-files/mysql.server $BASE/bin/replace /my/gnu/bin/hostname /bin/hostname -- $BASE/bin/mysqld_safe mv $BASE/support-files/binary-configure $BASE/configure chmod a+x $BASE/bin/* $BASE/scripts/* $BASE/support-files/mysql-* $BASE/support-files/mysql.server $BASE/configure diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index 25f5726c35a..8fdf23f3119 100644 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -289,9 +289,7 @@ cd $SOURCE for i in COPYING ChangeLog README EXCEPTIONS-CLIENT\ INSTALL-SOURCE INSTALL-WIN \ INSTALL-WIN-SOURCE \ - Docs/manual_toc.html Docs/manual.html \ - Docs/manual.txt Docs/mysqld_error.txt \ - Docs/INSTALL-BINARY Docs/internals.texi + Docs/INSTALL-BINARY do print_debug "Copying file '$i'" if [ -f $i ] diff --git a/scripts/mysql_create_system_tables.sh b/scripts/mysql_create_system_tables.sh index bb4c2f08193..e76fc935b03 100644 --- a/scripts/mysql_create_system_tables.sh +++ b/scripts/mysql_create_system_tables.sh @@ -722,6 +722,7 @@ fi cat << END_OF_DATA use mysql; +set table_type=myisam; $c_d $i_d diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql index c81f4b37fca..8032388a4de 100644 --- a/scripts/mysql_fix_privilege_tables.sql +++ b/scripts/mysql_fix_privilege_tables.sql @@ -9,6 +9,8 @@ -- this sql script. -- On windows you should do 'mysql --force mysql < mysql_fix_privilege_tables.sql' +set table_type=MyISAM; + CREATE TABLE IF NOT EXISTS func ( name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, diff --git a/server-tools/instance-manager/Makefile.am b/server-tools/instance-manager/Makefile.am index 7b1d0383f46..18f62a04bfb 100644 --- a/server-tools/instance-manager/Makefile.am +++ b/server-tools/instance-manager/Makefile.am @@ -28,7 +28,7 @@ noinst_LIBRARIES= liboptions.a libnet.a liboptions_a_CXXFLAGS= $(CXXFLAGS) \ -DDEFAULT_PID_FILE_NAME="$(localstatedir)/mysqlmanager.pid" \ -DDEFAULT_LOG_FILE_NAME="$(localstatedir)/mysqlmanager.log" \ - -DDEFAULT_SOCKET_FILE_NAME="$(localstatedir)/mysqlmanager.sock" \ + -DDEFAULT_SOCKET_FILE_NAME="/tmp/mysqlmanager.sock" \ -DDEFAULT_PASSWORD_FILE_NAME="$(sysconfdir)/mysqlmanager.passwd" \ -DDEFAULT_MYSQLD_PATH="$(libexecdir)/mysqld$(EXEEXT)" \ -DDEFAULT_MONITORING_INTERVAL="20" \ diff --git a/server-tools/instance-manager/commands.cc b/server-tools/instance-manager/commands.cc index 426f0cc40b2..e1f811ef57d 100644 --- a/server-tools/instance-manager/commands.cc +++ b/server-tools/instance-manager/commands.cc @@ -294,13 +294,19 @@ int Show_instance_options::do_command(struct st_net *net, char *tmp_option, *option_value; get_dynamic(&(instance->options.options_array), (gptr) &tmp_option, i); option_value= strchr(tmp_option, '='); - /* split the option string into two parts */ - *option_value= 0; + /* split the option string into two parts if it has a value */ + position= 0; - store_to_string(&send_buff, tmp_option + 2, &position); - store_to_string(&send_buff, option_value + 1, &position); - /* join name and the value into the same option again */ - *option_value= '='; + if (option_value != NULL) + { + *option_value= 0; + store_to_string(&send_buff, tmp_option + 2, &position); + store_to_string(&send_buff, option_value + 1, &position); + /* join name and the value into the same option again */ + *option_value= '='; + } + else store_to_string(&send_buff, tmp_option + 2, &position); + if (send_buff.is_error() || my_net_write(net, send_buff.buffer, (uint) position)) goto err; diff --git a/server-tools/instance-manager/instance.cc b/server-tools/instance-manager/instance.cc index 00fcf6c3a98..9fdcab7ce7c 100644 --- a/server-tools/instance-manager/instance.cc +++ b/server-tools/instance-manager/instance.cc @@ -191,8 +191,8 @@ bool Instance::is_running() MYSQL mysql; uint port= 0; const char *socket= NULL; - const char *password= "321rarepassword213"; - const char *username= "645rareusername945"; + const char *password= "check_connection"; + const char *username= "MySQL_Instance_Manager"; const char *access_denied_message= "Access denied for user"; bool return_val; diff --git a/server-tools/instance-manager/options.cc b/server-tools/instance-manager/options.cc index 4b5ec27f302..4568d6b578d 100644 --- a/server-tools/instance-manager/options.cc +++ b/server-tools/instance-manager/options.cc @@ -130,7 +130,7 @@ static void version() } -static const char *default_groups[]= { "mysql", "manager", 0 }; +static const char *default_groups[]= { "manager", 0 }; static void usage() diff --git a/sql-common/client.c b/sql-common/client.c index f28ea65fabf..59e27e4090a 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -2211,6 +2211,29 @@ my_bool mysql_reconnect(MYSQL *mysql) } tmp_mysql.reconnect= 1; tmp_mysql.free_me= mysql->free_me; + + /* + For each stmt in mysql->stmts, move it to tmp_mysql if it is + in state MYSQL_STMT_INIT_DONE, otherwise close it. + */ + { + LIST *element= mysql->stmts; + for (; element; element= element->next) + { + MYSQL_STMT *stmt= (MYSQL_STMT *) element->data; + if (stmt->state != MYSQL_STMT_INIT_DONE) + { + stmt->mysql= 0; + } + else + { + tmp_mysql.stmts= list_add(tmp_mysql.stmts, &stmt->list); + } + /* No need to call list_delete for statement here */ + } + mysql->stmts= NULL; + } + /* Don't free options as these are now used in tmp_mysql */ bzero((char*) &mysql->options,sizeof(mysql->options)); mysql->free_me=0; @@ -2299,6 +2322,10 @@ static void mysql_close_free(MYSQL *mysql) SYNOPSYS mysql_detach_stmt_list() stmt_list pointer to mysql->stmts + + NOTE + There is similar code in mysql_reconnect(), so changes here + should also be reflected there. */ void mysql_detach_stmt_list(LIST **stmt_list __attribute__((unused))) @@ -2419,8 +2446,6 @@ get_info: if (!(mysql->server_status & SERVER_STATUS_AUTOCOMMIT)) mysql->server_status|= SERVER_STATUS_IN_TRANS; - mysql->extra_info= net_field_length_ll(&pos); /* Maybe number of rec */ - if (!(fields=(*mysql->methods->read_rows)(mysql,(MYSQL_FIELD*)0, protocol_41(mysql) ? 7 : 5))) DBUG_RETURN(1); diff --git a/sql/Makefile.am b/sql/Makefile.am index 783ea7dfda6..aabe7c08f0f 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -49,7 +49,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ mysql_priv.h item_geofunc.h sql_bitmap.h \ procedure.h sql_class.h sql_lex.h sql_list.h \ sql_manager.h sql_map.h sql_string.h unireg.h \ - field.h handler.h mysqld_suffix.h \ + sql_error.h field.h handler.h mysqld_suffix.h \ ha_myisammrg.h\ ha_heap.h ha_myisam.h ha_berkeley.h ha_innodb.h \ ha_ndbcluster.h opt_range.h protocol.h \ diff --git a/sql/field.cc b/sql/field.cc index f3666f862af..00f729d5b07 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3230,13 +3230,13 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) long store_tmp; int error; char *end; - + tmp_scan= cs->cset->scan(cs, from, from+len, MY_SEQ_SPACES); len-= tmp_scan; from+= tmp_scan; end= (char*) from+len; - tmp= cs->cset->my_strtoll10(cs, from, &end, &error); + tmp= cs->cset->strtoll10(cs, from, &end, &error); if (error != MY_ERRNO_EDOM) { @@ -4512,6 +4512,13 @@ int Field_timestamp::store(longlong nr) set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, nr, MYSQL_TIMESTAMP_DATETIME, 1); + if (!error && timestamp == 0 && + (table->in_use->variables.sql_mode & MODE_NO_ZERO_DATE)) + { + set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, + WARN_DATA_TRUNCATED, + nr, MYSQL_TIMESTAMP_DATETIME, 1); + } #ifdef WORDS_BIGENDIAN if (table->s->db_low_byte_first) @@ -5137,6 +5144,12 @@ int Field_date::store(double nr) } else tmp=(long) rint(nr); + + /* + We don't need to check for zero dates here as this date type is only + used in .frm tables from very old MySQL versions + */ + #ifdef WORDS_BIGENDIAN if (table->s->db_low_byte_first) { @@ -5165,6 +5178,7 @@ int Field_date::store(longlong nr) } else tmp=(long) nr; + #ifdef WORDS_BIGENDIAN if (table->s->db_low_byte_first) { @@ -5277,6 +5291,7 @@ void Field_date::sql_type(String &res) const res.set_ascii("date", 4); } + /**************************************************************************** ** The new date type ** This is identical to the old date type, but stored on 3 bytes instead of 4 @@ -5309,17 +5324,17 @@ int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs) return error; } + int Field_newdate::store(double nr) { if (nr < 0.0 || nr > 99991231235959.0) { - (void) Field_newdate::store((longlong) -1); + int3store(ptr,(int32) 0); set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, nr, MYSQL_TIMESTAMP_DATE); return 1; } - else - return Field_newdate::store((longlong) rint(nr)); + return Field_newdate::store((longlong) rint(nr)); } @@ -5339,6 +5354,8 @@ int Field_newdate::store(longlong nr) } else { + uint month, day; + tmp=(int32) nr; if (tmp) { @@ -5346,24 +5363,33 @@ int Field_newdate::store(longlong nr) tmp+= (uint32) 20000000L; else if (tmp < 999999L) tmp+= (uint32) 19000000L; + + month= (uint) ((tmp/100) % 100); + day= (uint) (tmp%100); + if (month > 12 || day > 31) + { + tmp=0L; // Don't allow date to change + set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, + ER_WARN_DATA_OUT_OF_RANGE, nr, + MYSQL_TIMESTAMP_DATE, 1); + error= 1; + } + else + tmp= day + month*32 + (tmp/10000)*16*32; } - uint month= (uint) ((tmp/100) % 100); - uint day= (uint) (tmp%100); - if (month > 12 || day > 31) + else if (table->in_use->variables.sql_mode & MODE_NO_ZERO_DATE) { - tmp=0L; // Don't allow date to change set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, - ER_WARN_DATA_OUT_OF_RANGE, nr, - MYSQL_TIMESTAMP_DATE, 1); + ER_WARN_DATA_OUT_OF_RANGE, + 0, MYSQL_TIMESTAMP_DATE); error= 1; } - else - tmp= day + month*32 + (tmp/10000)*16*32; } - int3store(ptr,(int32) tmp); + int3store(ptr, tmp); return error; } + int Field_newdate::store_time(TIME *ltime,timestamp_type type) { long tmp; @@ -5380,6 +5406,7 @@ int Field_newdate::store_time(TIME *ltime,timestamp_type type) return error; } + bool Field_newdate::send_binary(Protocol *protocol) { TIME tm; @@ -5387,11 +5414,13 @@ bool Field_newdate::send_binary(Protocol *protocol) return protocol->store_date(&tm); } + double Field_newdate::val_real(void) { return (double) Field_newdate::val_int(); } + longlong Field_newdate::val_int(void) { ulong j= uint3korr(ptr); @@ -5399,6 +5428,7 @@ longlong Field_newdate::val_int(void) return (longlong) j; } + String *Field_newdate::val_str(String *val_buffer, String *val_ptr __attribute__((unused))) { @@ -5426,6 +5456,7 @@ String *Field_newdate::val_str(String *val_buffer, return val_buffer; } + bool Field_newdate::get_date(TIME *ltime,uint fuzzydate) { uint32 tmp=(uint32) uint3korr(ptr); @@ -5438,11 +5469,13 @@ bool Field_newdate::get_date(TIME *ltime,uint fuzzydate) 1 : 0); } + bool Field_newdate::get_time(TIME *ltime) { return Field_newdate::get_date(ltime,0); } + int Field_newdate::cmp(const char *a_ptr, const char *b_ptr) { uint32 a,b; @@ -5451,6 +5484,7 @@ int Field_newdate::cmp(const char *a_ptr, const char *b_ptr) return (a < b) ? -1 : (a > b) ? 1 : 0; } + void Field_newdate::sort_string(char *to,uint length __attribute__((unused))) { to[0] = ptr[2]; @@ -5458,6 +5492,7 @@ void Field_newdate::sort_string(char *to,uint length __attribute__((unused))) to[2] = ptr[0]; } + void Field_newdate::sql_type(String &res) const { res.set_ascii("date", 4); @@ -5514,10 +5549,10 @@ int Field_datetime::store(double nr) set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, nr, MYSQL_TIMESTAMP_DATETIME); - nr=0.0; + nr= 0.0; error= 1; } - error |= Field_datetime::store((longlong) rint(nr)); + error|= Field_datetime::store((longlong) rint(nr)); return error; } @@ -5534,6 +5569,13 @@ int Field_datetime::store(longlong nr) set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, initial_nr, MYSQL_TIMESTAMP_DATETIME, 1); + else if (nr == 0 && table->in_use->variables.sql_mode & MODE_NO_ZERO_DATE) + { + set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, + ER_WARN_DATA_OUT_OF_RANGE, + initial_nr, MYSQL_TIMESTAMP_DATE, 1); + error= 1; + } #ifdef WORDS_BIGENDIAN if (table->s->db_low_byte_first) @@ -5735,7 +5777,7 @@ void Field_datetime::sql_type(String &res) const int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) { - int error= 0; + int error= 0, well_formed_error; uint32 not_used; char buff[STRING_BUFFER_USUAL_SIZE]; String tmpstr(buff,sizeof(buff), &my_charset_bin); @@ -5760,9 +5802,10 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) as well as don't copy a malformed data. */ copy_length= field_charset->cset->well_formed_len(field_charset, - from,from+length, - field_length/ - field_charset->mbmaxlen); + from,from+length, + field_length/ + field_charset->mbmaxlen, + &well_formed_error); memcpy(ptr,from,copy_length); if (copy_length < field_length) // Append spaces if shorter field_charset->cset->fill(field_charset,ptr+copy_length, @@ -6110,7 +6153,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs) uint32 not_used, copy_length; char buff[STRING_BUFFER_USUAL_SIZE]; String tmpstr(buff,sizeof(buff), &my_charset_bin); - int error_code= 0; + int error_code= 0, well_formed_error; enum MYSQL_ERROR::enum_warning_level level= MYSQL_ERROR::WARN_LEVEL_WARN; /* Convert character set if necessary */ @@ -6130,7 +6173,8 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs) copy_length= field_charset->cset->well_formed_len(field_charset, from,from+length, field_length/ - field_charset->mbmaxlen); + field_charset->mbmaxlen, + &well_formed_error); memcpy(ptr + length_bytes, from, copy_length); if (length_bytes == 1) *ptr= (uchar) copy_length; @@ -6704,7 +6748,7 @@ void Field_blob::put_length(char *pos, uint32 length) int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) { - int error= 0; + int error= 0, well_formed_error; if (!length) { bzero(ptr,Field_blob::pack_length()); @@ -6736,9 +6780,10 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) the 'min()' call below. */ copy_length= field_charset->cset->well_formed_len(field_charset, - from,from + - min(length, copy_length), - copy_length); + from,from + + min(length, copy_length), + copy_length, + &well_formed_error); if (copy_length < length) error= 1; Field_blob::store_length(copy_length); @@ -7834,7 +7879,7 @@ int Field_bit::key_cmp(const byte *str, uint length) str++; length--; } - return bcmp(ptr, str, length); + return memcmp(ptr, str, length); } @@ -7848,7 +7893,7 @@ int Field_bit::cmp_offset(uint row_offset) if ((flag= (int) (bits_a - bits_b))) return flag; } - return bcmp(ptr, ptr + row_offset, field_length); + return memcmp(ptr, ptr + row_offset, field_length); } @@ -7900,6 +7945,58 @@ const char *Field_bit::unpack(char *to, const char *from) } +/* + Bit field support for non-MyISAM tables. +*/ + +Field_bit_as_char::Field_bit_as_char(char *ptr_arg, uint32 len_arg, + uchar *null_ptr_arg, uchar null_bit_arg, + uchar *bit_ptr_arg, uchar bit_ofs_arg, + enum utype unireg_check_arg, + const char *field_name_arg, + struct st_table *table_arg) + : Field_bit(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, bit_ptr_arg, + bit_ofs_arg, unireg_check_arg, field_name_arg, table_arg), + create_length(len_arg) +{ + bit_ptr= 0; + bit_ofs= 0; + bit_len= 0; + field_length= ((len_arg + 7) & ~7) / 8; +} + + +int Field_bit_as_char::store(const char *from, uint length, CHARSET_INFO *cs) +{ + int delta; + uchar bits= create_length & 7; + + for (; !*from && length; from++, length--); // skip left 0's + delta= field_length - length; + + if (delta < 0 || + (delta == 0 && bits && (uint) (uchar) *from >= (uint) (1 << bits))) + { + memset(ptr, 0xff, field_length); + *ptr&= ((1 << bits) - 1); /* set first byte */ + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); + return 1; + } + bzero(ptr, delta); + memcpy(ptr + delta, from, length); + return 0; +} + + +void Field_bit_as_char::sql_type(String &res) const +{ + CHARSET_INFO *cs= res.charset(); + ulong length= cs->cset->snprintf(cs, (char*) res.ptr(), res.alloced_length(), + "bit(%d)", (int) create_length); + res.length((uint) length); +} + + /***************************************************************************** Handling of field and create_field *****************************************************************************/ @@ -7925,9 +8022,16 @@ void create_field::create_length_to_internal_length(void) key_length= pack_length; break; case MYSQL_TYPE_BIT: - pack_length= calc_pack_length(sql_type, length); - /* We need one extra byte to store the bits we save among the null bits */ - key_length= pack_length+ test(length & 7); + if (f_bit_as_char(pack_flag)) + { + key_length= pack_length= ((length + 7) & ~7) / 8; + } + else + { + pack_length= length / 8; + /* We need one extra byte to store the bits we save among the null bits */ + key_length= pack_length + test(length & 7); + } break; case MYSQL_TYPE_NEWDECIMAL: key_length= pack_length= my_decimal_get_binary_size(length, decimals); @@ -8041,7 +8145,7 @@ Field *make_field(char *ptr, uint32 field_length, uchar bit_offset; LINT_INIT(bit_ptr); LINT_INIT(bit_offset); - if (field_type == FIELD_TYPE_BIT) + if (field_type == FIELD_TYPE_BIT && !f_bit_as_char(pack_flag)) { bit_ptr= null_pos; bit_offset= null_bit; @@ -8191,7 +8295,10 @@ Field *make_field(char *ptr, uint32 field_length, case FIELD_TYPE_NULL: return new Field_null(ptr,field_length,unireg_check,field_name,table, field_charset); case FIELD_TYPE_BIT: - return new Field_bit(ptr, field_length, null_pos, null_bit, bit_ptr, + return f_bit_as_char(pack_flag) ? + new Field_bit_as_char(ptr, field_length, null_pos, null_bit, bit_ptr, + bit_offset, unireg_check, field_name, table) : + new Field_bit(ptr, field_length, null_pos, null_bit, bit_ptr, bit_offset, unireg_check, field_name, table); default: // Impossible (Wrong version) break; @@ -8251,7 +8358,9 @@ create_field::create_field(Field *old_field,Field *orig_field) break; #endif case FIELD_TYPE_BIT: - length= ((Field_bit *) old_field)->bit_len + length * 8; + length= (old_field->key_type() == HA_KEYTYPE_BIT) ? + ((Field_bit *) old_field)->bit_len + length * 8 : + ((Field_bit_as_char *) old_field)->create_length; break; default: break; @@ -8285,7 +8394,37 @@ create_field::create_field(Field *old_field,Field *orig_field) } -/* Warning handling */ +/* + maximum possible display length for blob + + SYNOPSIS + Field_blob::max_length() + + RETURN + length +*/ +uint32 Field_blob::max_length() +{ + switch (packlength) + { + case 1: + return 255; + case 2: + return 65535; + case 3: + return 16777215; + case 4: + return (uint32) 4294967295U; + default: + DBUG_ASSERT(0); // we should never go here + return 0; + } +} + + +/***************************************************************************** + Warning handling +*****************************************************************************/ /* Produce warning or note about data saved into field @@ -8301,18 +8440,20 @@ create_field::create_field(Field *old_field,Field *orig_field) if count_cuted_fields == FIELD_CHECK_IGNORE for current thread. RETURN VALUE - true - if count_cuted_fields == FIELD_CHECK_IGNORE - false - otherwise + 1 if count_cuted_fields == FIELD_CHECK_IGNORE + 0 otherwise */ + bool -Field::set_warning(uint level, uint code, int cuted_increment) +Field::set_warning(MYSQL_ERROR::enum_warning_level level, uint code, + int cuted_increment) { THD *thd= table->in_use; if (thd->count_cuted_fields) { thd->cuted_fields+= cuted_increment; - push_warning_printf(thd, (MYSQL_ERROR::enum_warning_level) level, - code, ER(code), field_name, thd->row_count); + push_warning_printf(thd, level, code, ER(code), field_name, + thd->row_count); return 0; } return 1; @@ -8336,8 +8477,9 @@ Field::set_warning(uint level, uint code, int cuted_increment) fields counter if count_cuted_fields == FIELD_CHECK_IGNORE for current thread. */ + void -Field::set_datetime_warning(const uint level, const uint code, +Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code, const char *str, uint str_length, timestamp_type ts_type, int cuted_increment) { @@ -8364,8 +8506,9 @@ Field::set_datetime_warning(const uint level, const uint code, fields counter if count_cuted_fields == FIELD_CHECK_IGNORE for current thread. */ + void -Field::set_datetime_warning(const uint level, const uint code, +Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code, longlong nr, timestamp_type ts_type, int cuted_increment) { @@ -8395,8 +8538,9 @@ Field::set_datetime_warning(const uint level, const uint code, fields counter if count_cuted_fields == FIELD_CHECK_IGNORE for current thread. */ + void -Field::set_datetime_warning(const uint level, const uint code, +Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code, double nr, timestamp_type ts_type) { if (table->in_use->really_abort_on_warning() || @@ -8409,30 +8553,3 @@ Field::set_datetime_warning(const uint level, const uint code, field_name); } } - -/* - maximum possible display length for blob - - SYNOPSIS - Field_blob::max_length() - - RETURN - length -*/ -uint32 Field_blob::max_length() -{ - switch (packlength) - { - case 1: - return 255; - case 2: - return 65535; - case 3: - return 16777215; - case 4: - return (uint32) 4294967295U; - default: - DBUG_ASSERT(0); // we should never go here - return 0; - } -} diff --git a/sql/field.h b/sql/field.h index ce6753400bb..22787850442 100644 --- a/sql/field.h +++ b/sql/field.h @@ -280,17 +280,17 @@ public: virtual CHARSET_INFO *sort_charset(void) const { return charset(); } virtual bool has_charset(void) const { return FALSE; } virtual void set_charset(CHARSET_INFO *charset) { } - bool set_warning(unsigned int level, unsigned int code, + bool set_warning(MYSQL_ERROR::enum_warning_level, unsigned int code, int cuted_increment); bool check_int(const char *str, int length, const char *int_end, CHARSET_INFO *cs); - void set_datetime_warning(const uint level, const uint code, + void set_datetime_warning(MYSQL_ERROR::enum_warning_level, uint code, const char *str, uint str_len, timestamp_type ts_type, int cuted_increment); - void set_datetime_warning(const uint level, const uint code, + void set_datetime_warning(MYSQL_ERROR::enum_warning_level, uint code, longlong nr, timestamp_type ts_type, int cuted_increment); - void set_datetime_warning(const uint level, const uint code, + void set_datetime_warning(MYSQL_ERROR::enum_warning_level, const uint code, double nr, timestamp_type ts_type); inline bool check_overflow(int op_result) { @@ -1312,6 +1312,22 @@ public: }; +class Field_bit_as_char: public Field_bit { +public: + uchar create_length; + Field_bit_as_char(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, + uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg, + enum utype unireg_check_arg, const char *field_name_arg, + struct st_table *table_arg); + enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; } + uint size_of() const { return sizeof(*this); } + int store(const char *to, uint length, CHARSET_INFO *charset); + int store(double nr) { return Field_bit::store(nr); } + int store(longlong nr) { return Field_bit::store(nr); } + void sql_type(String &str) const; +}; + + /* Create field class for CREATE TABLE */ @@ -1415,6 +1431,8 @@ int set_field_to_null_with_conversions(Field *field, bool no_conversions); #define FIELDFLAG_BLOB 1024 // mangled with decimals! #define FIELDFLAG_GEOM 2048 // mangled with decimals! +#define FIELDFLAG_TREAT_BIT_AS_CHAR 4096 /* use Field_bit_as_char */ + #define FIELDFLAG_LEFT_FULLSCREEN 8192 #define FIELDFLAG_RIGHT_FULLSCREEN 16384 #define FIELDFLAG_FORMAT_NUMBER 16384 // predit: ###,,## in output @@ -1445,3 +1463,4 @@ int set_field_to_null_with_conversions(Field *field, bool no_conversions); #define f_settype(x) (((int) x) << FIELDFLAG_PACK_SHIFT) #define f_maybe_null(x) (x & FIELDFLAG_MAYBE_NULL) #define f_no_default(x) (x & FIELDFLAG_NO_DEFAULT) +#define f_bit_as_char(x) ((x) & FIELDFLAG_TREAT_BIT_AS_CHAR) diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 57161a7063e..ae784ae0293 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -508,8 +508,16 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*) // Check if identical fields if (from->result_type() == STRING_RESULT) { + /* + If we are copying date or datetime's we have to check the dates + if we don't allow 'all' dates. + */ if (to->real_type() != from->real_type() || - !compatible_db_low_byte_first) + !compatible_db_low_byte_first || + ((to->table->in_use->variables.sql_mode & + (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) && + to->type() == FIELD_TYPE_DATE || + to->type() == FIELD_TYPE_DATETIME)) { if (from->real_type() == FIELD_TYPE_ENUM || from->real_type() == FIELD_TYPE_SET) @@ -586,11 +594,16 @@ void field_conv(Field *to,Field *from) !(to->flags & UNSIGNED_FLAG && !(from->flags & UNSIGNED_FLAG)) && to->real_type() != FIELD_TYPE_ENUM && to->real_type() != FIELD_TYPE_SET && + to->real_type() != FIELD_TYPE_BIT && (to->real_type() != FIELD_TYPE_NEWDECIMAL || (to->field_length == from->field_length && (((Field_num*)to)->dec == ((Field_num*)from)->dec))) && from->charset() == to->charset() && - to->table->s->db_low_byte_first == from->table->s->db_low_byte_first) + to->table->s->db_low_byte_first == from->table->s->db_low_byte_first && + (!(to->table->in_use->variables.sql_mode & + (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) || + to->type() != FIELD_TYPE_DATE && + to->type() != FIELD_TYPE_DATETIME)) { // Identical fields memcpy(to->ptr,from->ptr,to->pack_length()); return; diff --git a/sql/filesort.cc b/sql/filesort.cc index c50f1daa6ef..30ebd8d59e1 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -127,7 +127,8 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, param.ref_length= table->file->ref_length; param.addon_field= 0; param.addon_length= 0; - if (!(table->s->tmp_table || table->fulltext_searched)) + if (!(table->file->table_flags() & HA_FAST_KEY_READ) && + !table->fulltext_searched) { /* Get the descriptors of all fields whose values are appended @@ -1301,27 +1302,29 @@ get_addon_fields(THD *thd, Field **ptabfield, uint sortlength, uint *plength) uint length= 0; uint fields= 0; uint null_fields= 0; - - /* - If there is a reference to a field in the query add it - to the the set of appended fields. - Note for future refinement: - This this a too strong condition. - Actually we need only the fields referred in the - result set. And for some of them it makes sense to use - the values directly from sorted fields. + query_id_t query_id= thd->query_id; + /* + If there is a reference to a field in the query add it + to the the set of appended fields. + Note for future refinement: + This this a too strong condition. + Actually we need only the fields referred in the + result set. And for some of them it makes sense to use + the values directly from sorted fields. */ *plength= 0; + /* - The following statement is added to avoid sorting in alter_table. - The fact is the filter 'field->query_id != thd->query_id' - doesn't work for alter table + The following statement is added to avoid sorting in alter_table. + The fact is the filter 'field->query_id != thd->query_id' + doesn't work for alter table */ - if (thd->lex->sql_command != SQLCOM_SELECT) + if (thd->lex->sql_command != SQLCOM_SELECT && + thd->lex->sql_command != SQLCOM_INSERT_SELECT) return 0; for (pfield= ptabfield; (field= *pfield) ; pfield++) { - if (field->query_id != thd->query_id) + if (field->query_id != query_id) continue; if (field->flags & BLOB_FLAG) return 0; diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index 8000aae180d..33acc9cad0b 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -548,12 +548,12 @@ error: static int parse_url(FEDERATED_SHARE *share, TABLE *table, uint table_create_flag) { + uint error_num= (table_create_flag ? ER_CANT_CREATE_TABLE : + ER_CONNECT_TO_MASTER); DBUG_ENTER("ha_federated::parse_url"); share->port= 0; - uint error_num= (table_create_flag ? ER_CANT_CREATE_TABLE : - ER_CONNECT_TO_MASTER); - + share->socket= 0; share->scheme= my_strdup(table->s->comment, MYF(0)); if ((share->username= strstr(share->scheme, "://"))) diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index de51fad4365..0d700f6c9a5 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -548,6 +548,7 @@ int ha_heap::create(const char *name, TABLE *table_arg, hp_create_info.auto_increment= (create_info->auto_increment_value ? create_info->auto_increment_value - 1 : 0); hp_create_info.max_table_size=current_thd->variables.max_heap_table_size; + hp_create_info.with_auto_increment= found_real_auto_increment; max_rows = (ha_rows) (hp_create_info.max_table_size / mem_per_row); error= heap_create(fn_format(buff,name,"","",4+2), keys, keydef, share->reclength, diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index e29560f15a5..3f592e36219 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -116,15 +116,12 @@ char* innobase_unix_file_flush_method = NULL; values */ uint innobase_flush_log_at_trx_commit = 1; +ulong innobase_fast_shutdown = 1; my_bool innobase_log_archive = FALSE;/* unused */ my_bool innobase_use_doublewrite = TRUE; my_bool innobase_use_checksums = TRUE; my_bool innobase_use_large_pages = FALSE; my_bool innobase_use_native_aio = FALSE; -my_bool innobase_fast_shutdown = TRUE; -my_bool innobase_very_fast_shutdown = FALSE; /* this can be set to - 1 just prior calling - innobase_end() */ my_bool innobase_file_per_table = FALSE; my_bool innobase_locks_unsafe_for_binlog = FALSE; my_bool innobase_create_status_file = FALSE; @@ -748,17 +745,37 @@ ha_innobase::update_thd( } /************************************************************************* -Registers the InnoDB transaction in MySQL, to receive commit/rollback -events. This function must be called every time InnoDB starts a -transaction internally. */ -static +Registers that InnoDB takes part in an SQL statement, so that MySQL knows to +roll back the statement if the statement results in an error. This MUST be +called for every SQL statement that may be rolled back by MySQL. Calling this +several times to register the same statement is allowed, too. */ +inline void -register_trans( -/*===========*/ - THD* thd) /* in: thd to use the handle */ +innobase_register_stmt( +/*===================*/ + THD* thd) /* in: MySQL thd (connection) object */ { - /* Register the start of the statement */ + /* Register the statement */ trans_register_ha(thd, FALSE, &innobase_hton); +} + +/************************************************************************* +Registers an InnoDB transaction in MySQL, so that the MySQL XA code knows +to call the InnoDB prepare and commit, or rollback for the transaction. This +MUST be called for every transaction for which the user may call commit or +rollback. Calling this several times to register the same transaction is +allowed, too. +This function also registers the current SQL statement. */ +inline +void +innobase_register_trx_and_stmt( +/*===========================*/ + THD* thd) /* in: MySQL thd (connection) object */ +{ + /* NOTE that actually innobase_register_stmt() registers also + the transaction in the AUTOCOMMIT=1 mode. */ + + innobase_register_stmt(thd); if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) { @@ -914,7 +931,7 @@ innobase_query_caching_of_table_permitted( if (trx->active_trans == 0) { - register_trans(thd); + innobase_register_trx_and_stmt(thd); trx->active_trans = 1; } @@ -1030,7 +1047,7 @@ ha_innobase::init_table_handle_for_HANDLER(void) if (prebuilt->trx->active_trans == 0) { - register_trans(current_thd); + innobase_register_trx_and_stmt(current_thd); prebuilt->trx->active_trans = 1; } @@ -1218,8 +1235,6 @@ innobase_init(void) srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout; srv_force_recovery = (ulint) innobase_force_recovery; - srv_fast_shutdown = (ibool) innobase_fast_shutdown; - srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite; srv_use_checksums = (ibool) innobase_use_checksums; @@ -1310,17 +1325,7 @@ innobase_end(void) #endif if (innodb_inited) { -#ifndef __NETWARE__ /* NetWare can't close unclosed files, kill remaining - threads, etc, so we disable the very fast shutdown */ - if (innobase_very_fast_shutdown) { - srv_very_fast_shutdown = TRUE; - fprintf(stderr, -"InnoDB: MySQL has requested a very fast shutdown without flushing\n" -"InnoDB: the InnoDB buffer pool to data files. At the next mysqld startup\n" -"InnoDB: InnoDB will do a crash recovery!\n"); - } -#endif - + srv_fast_shutdown = (ulint) innobase_fast_shutdown; innodb_inited = 0; if (innobase_shutdown_for_mysql() != DB_SUCCESS) { err = 1; @@ -1421,7 +1426,7 @@ innobase_start_trx_and_assign_read_view( if (trx->active_trans == 0) { - register_trans(current_thd); + innobase_register_trx_and_stmt(current_thd); trx->active_trans = 1; } @@ -2213,6 +2218,7 @@ innobase_mysql_cmp( switch (mysql_tp) { + case MYSQL_TYPE_BIT: case MYSQL_TYPE_STRING: case MYSQL_TYPE_VAR_STRING: case FIELD_TYPE_TINY_BLOB: @@ -2271,13 +2277,43 @@ inline ulint get_innobase_type_from_mysql_type( /*==============================*/ - /* out: DATA_BINARY, DATA_VARCHAR, ... */ - Field* field) /* in: MySQL field */ + /* out: DATA_BINARY, DATA_VARCHAR, ... */ + ulint* unsigned_flag, /* out: DATA_UNSIGNED if an 'unsigned type'; + at least ENUM and SET, and unsigned integer + types are 'unsigned types' */ + Field* field) /* in: MySQL field */ { /* The following asserts try to check that the MySQL type code fits in 8 bits: this is used in ibuf and also when DATA_NOT_NULL is ORed to the type */ + DBUG_ASSERT((ulint)FIELD_TYPE_STRING < 256); + DBUG_ASSERT((ulint)FIELD_TYPE_VAR_STRING < 256); + DBUG_ASSERT((ulint)FIELD_TYPE_DOUBLE < 256); + DBUG_ASSERT((ulint)FIELD_TYPE_FLOAT < 256); + DBUG_ASSERT((ulint)FIELD_TYPE_DECIMAL < 256); + + if (field->flags & UNSIGNED_FLAG) { + + *unsigned_flag = DATA_UNSIGNED; + } else { + *unsigned_flag = 0; + } + + if (field->real_type() == FIELD_TYPE_ENUM + || field->real_type() == FIELD_TYPE_SET) { + + /* MySQL has field->type() a string type for these, but the + data is actually internally stored as an unsigned integer + code! */ + + *unsigned_flag = DATA_UNSIGNED; /* MySQL has its own unsigned + flag set to zero, even though + internally this is an unsigned + integer type */ + return(DATA_INT); + } + switch (field->type()) { /* NOTE that we only allow string types in DATA_MYSQL and DATA_VARMYSQL */ @@ -2292,6 +2328,7 @@ get_innobase_type_from_mysql_type( } else { return(DATA_VARMYSQL); } + case MYSQL_TYPE_BIT: case MYSQL_TYPE_STRING: if (field->binary()) { return(DATA_FIXBINARY); @@ -2313,8 +2350,6 @@ get_innobase_type_from_mysql_type( case FIELD_TYPE_DATETIME: case FIELD_TYPE_YEAR: case FIELD_TYPE_NEWDATE: - case FIELD_TYPE_ENUM: - case FIELD_TYPE_SET: case FIELD_TYPE_TIME: case FIELD_TYPE_TIMESTAMP: return(DATA_INT); @@ -2686,7 +2721,7 @@ build_template( get_field_offset(table, field); templ->mysql_col_len = (ulint) field->pack_length(); - templ->type = get_innobase_type_from_mysql_type(field); + templ->type = index->table->cols[i].type.mtype; templ->mysql_type = (ulint)field->type(); if (templ->mysql_type == DATA_MYSQL_TRUE_VARCHAR) { @@ -2698,8 +2733,8 @@ build_template( index->table->cols[i].type.prtype); templ->mbminlen = index->table->cols[i].type.mbminlen; templ->mbmaxlen = index->table->cols[i].type.mbmaxlen; - templ->is_unsigned = (ulint) (field->flags & UNSIGNED_FLAG); - + templ->is_unsigned = index->table->cols[i].type.prtype + & DATA_UNSIGNED; if (templ->type == DATA_BLOB) { prebuilt->templ_contains_blob = TRUE; } @@ -2962,7 +2997,6 @@ calc_row_difference( byte* buf; upd_field_t* ufield; ulint col_type; - ulint is_unsigned; ulint n_changed = 0; dfield_t dfield; uint i; @@ -2998,8 +3032,7 @@ calc_row_difference( field_mysql_type = field->type(); - col_type = get_innobase_type_from_mysql_type(field); - is_unsigned = (ulint) (field->flags & UNSIGNED_FLAG); + col_type = prebuilt->table->cols[i].type.mtype; switch (col_type) { @@ -3072,8 +3105,7 @@ calc_row_difference( } ufield->exp = NULL; - ufield->field_no = - (prebuilt->table->cols + i)->clust_pos; + ufield->field_no = prebuilt->table->cols[i].clust_pos; n_changed++; } } @@ -3932,19 +3964,14 @@ create_table_def( for (i = 0; i < n_cols; i++) { field = form->field[i]; - col_type = get_innobase_type_from_mysql_type(field); + col_type = get_innobase_type_from_mysql_type(&unsigned_type, + field); if (field->null_ptr) { nulls_allowed = 0; } else { nulls_allowed = DATA_NOT_NULL; } - if (field->flags & UNSIGNED_FLAG) { - unsigned_type = DATA_UNSIGNED; - } else { - unsigned_type = 0; - } - if (field->binary()) { binary_type = DATA_BINARY_TYPE; } else { @@ -4021,6 +4048,7 @@ create_index( ulint ind_type; ulint col_type; ulint prefix_len; + ulint is_unsigned; ulint i; ulint j; @@ -4070,7 +4098,8 @@ create_index( ut_a(j < form->s->fields); - col_type = get_innobase_type_from_mysql_type(key_part->field); + col_type = get_innobase_type_from_mysql_type( + &is_unsigned, key_part->field); if (DATA_BLOB == col_type || (key_part->length < field->pack_length() @@ -4629,6 +4658,10 @@ ha_innobase::rename_table( trx->mysql_thd = current_thd; trx->mysql_query_str = &((*current_thd).query); + if (current_thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) { + trx->check_foreigns = FALSE; + } + name_len1 = strlen(from); name_len2 = strlen(to); @@ -5338,6 +5371,32 @@ ha_innobase::get_foreign_key_list(THD *thd, List *f_key_list) DBUG_RETURN(0); } +/********************************************************************* +Checks if ALTER TABLE may change the storage engine of the table. +Changing storage engines is not allowed for tables for which there +are foreign key constraints (parent or child tables). */ + +bool +ha_innobase::can_switch_engines(void) +/*=================================*/ +{ + row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; + bool can_switch; + + DBUG_ENTER("ha_innobase::can_switch_engines"); + prebuilt->trx->op_info = + "determining if there are foreign key constraints"; + row_mysql_lock_data_dictionary(prebuilt->trx); + + can_switch = !UT_LIST_GET_FIRST(prebuilt->table->referenced_list) + && !UT_LIST_GET_FIRST(prebuilt->table->foreign_list); + + row_mysql_unlock_data_dictionary(prebuilt->trx); + prebuilt->trx->op_info = ""; + + DBUG_RETURN(can_switch); +} + /*********************************************************************** Checks if a table is referenced by a foreign key. The MySQL manual states that a REPLACE is either equivalent to an INSERT, or DELETE(s) + INSERT. Only a @@ -5522,9 +5581,11 @@ ha_innobase::start_stmt( /* Set the MySQL flag to mark that there is an active transaction */ if (trx->active_trans == 0) { - register_trans(thd); + innobase_register_trx_and_stmt(thd); trx->active_trans = 1; - } + } else { + innobase_register_stmt(thd); + } return(0); } @@ -5594,9 +5655,11 @@ ha_innobase::external_lock( transaction */ if (trx->active_trans == 0) { - register_trans(thd); + innobase_register_trx_and_stmt(thd); trx->active_trans = 1; - } + } else if (trx->n_mysql_tables_in_use == 0) { + innobase_register_stmt(thd); + } trx->n_mysql_tables_in_use++; prebuilt->mysql_has_locked = TRUE; @@ -5758,7 +5821,7 @@ ha_innobase::transactional_table_lock( /* Set the MySQL flag to mark that there is an active transaction */ if (trx->active_trans == 0) { - register_trans(thd); + innobase_register_trx_and_stmt(thd); trx->active_trans = 1; } @@ -6050,15 +6113,21 @@ ha_innobase::store_lock( of current handle is stored next to this array */ enum thr_lock_type lock_type) /* in: lock type to store in - 'lock' */ + 'lock'; this may also be + TL_IGNORE */ { row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; + /* NOTE: MySQL can call this function with lock 'type' TL_IGNORE! + Be careful to ignore TL_IGNORE if we are going to do something with + only 'real' locks! */ + if ((lock_type == TL_READ && thd->in_lock_tables) || (lock_type == TL_READ_HIGH_PRIORITY && thd->in_lock_tables) || lock_type == TL_READ_WITH_SHARED_LOCKS || lock_type == TL_READ_NO_INSERT || - thd->lex->sql_command != SQLCOM_SELECT) { + (thd->lex->sql_command != SQLCOM_SELECT + && lock_type != TL_IGNORE)) { /* The OR cases above are in this order: 1) MySQL is doing LOCK TABLES ... READ LOCAL, or @@ -6101,10 +6170,6 @@ ha_innobase::store_lock( } else if (lock_type != TL_IGNORE) { - /* In ha_berkeley.cc there is a comment that MySQL - may in exceptional cases call this with TL_IGNORE also - when it is NOT going to release the lock. */ - /* We set possible LOCK_X value in external_lock, not yet here even if this would be SELECT ... FOR UPDATE */ @@ -6135,7 +6200,7 @@ ha_innobase::store_lock( lock_type = TL_READ; } - lock.type=lock_type; + lock.type = lock_type; } *to++= &lock; @@ -6453,7 +6518,7 @@ prototype for this function ! */ ibool innobase_query_is_update(void) -/*===========================*/ +/*==========================*/ { THD* thd; diff --git a/sql/ha_innodb.h b/sql/ha_innodb.h index 6ad385ae848..35f95ead757 100644 --- a/sql/ha_innodb.h +++ b/sql/ha_innodb.h @@ -85,7 +85,6 @@ class ha_innobase: public handler ha_innobase(TABLE *table): handler(table), int_table_flags(HA_REC_NOT_IN_SEQ | HA_NULL_IN_KEY | - HA_FAST_KEY_READ | HA_CAN_INDEX_BLOBS | HA_CAN_SQL_HANDLER | HA_NOT_EXACT_COUNT | @@ -180,6 +179,7 @@ class ha_innobase: public handler char* update_table_comment(const char* comment); char* get_foreign_key_create_info(); int get_foreign_key_list(THD *thd, List *f_key_list); + bool can_switch_engines(); uint referenced_by_foreign_key(); void free_foreign_key_create_info(char* str); THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, @@ -210,7 +210,7 @@ class ha_innobase: public handler extern struct show_var_st innodb_status_variables[]; extern uint innobase_init_flags, innobase_lock_type; extern uint innobase_flush_log_at_trx_commit; -extern ulong innobase_cache_size; +extern ulong innobase_cache_size, innobase_fast_shutdown; extern ulong innobase_large_page_size; extern char *innobase_home, *innobase_tmpdir, *innobase_logdir; extern long innobase_lock_scan_time; @@ -229,7 +229,7 @@ extern my_bool innobase_log_archive, innobase_use_doublewrite, innobase_use_checksums, innobase_use_large_pages, - innobase_use_native_aio, innobase_fast_shutdown, + innobase_use_native_aio, innobase_file_per_table, innobase_locks_unsafe_for_binlog, innobase_create_status_file; extern my_bool innobase_very_fast_shutdown; /* set this to 1 just before diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index dd7a719eda4..020a76b667e 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -67,6 +67,8 @@ static handlerton ndbcluster_hton = { #define NDB_HIDDEN_PRIMARY_KEY_LENGTH 8 +#define NDB_FAILED_AUTO_INCREMENT ~(Uint64)0 +#define NDB_AUTO_INCREMENT_RETRIES 10 #define ERR_PRINT(err) \ DBUG_PRINT("error", ("%d message: %s", err.code, err.message)) @@ -178,7 +180,6 @@ static const err_code_mapping err_map[]= { 4244, HA_ERR_TABLE_EXIST, 1 }, { 709, HA_ERR_NO_SUCH_TABLE, 0 }, - { 284, HA_ERR_NO_SUCH_TABLE, 1 }, { 266, HA_ERR_LOCK_WAIT_TIMEOUT, 1 }, { 274, HA_ERR_LOCK_WAIT_TIMEOUT, 1 }, @@ -193,6 +194,8 @@ static const err_code_mapping err_map[]= { 827, HA_ERR_RECORD_FILE_FULL, 1 }, { 832, HA_ERR_RECORD_FILE_FULL, 1 }, + { 284, HA_ERR_TABLE_DEF_CHANGED, 0 }, + { 0, 1, 0 }, { -1, -1, 1 } @@ -448,13 +451,31 @@ void ha_ndbcluster::invalidateDictionaryCache() int ha_ndbcluster::ndb_err(NdbTransaction *trans) { int res; - const NdbError err= trans->getNdbError(); + NdbError err= trans->getNdbError(); DBUG_ENTER("ndb_err"); ERR_PRINT(err); switch (err.classification) { case NdbError::SchemaError: invalidateDictionaryCache(); + + if (err.code==284) + { + /* + Check if the table is _really_ gone or if the table has + been alterend and thus changed table id + */ + NDBDICT *dict= get_ndb()->getDictionary(); + DBUG_PRINT("info", ("Check if table %s is really gone", m_tabname)); + if (!(dict->getTable(m_tabname))) + { + err= dict->getNdbError(); + DBUG_PRINT("info", ("Table not found, error: %d", err.code)); + if (err.code != 709) + DBUG_RETURN(1); + } + DBUG_PRINT("info", ("Table exists but must have changed")); + } break; default: break; @@ -1909,7 +1930,15 @@ int ha_ndbcluster::write_row(byte *record) { // Table has hidden primary key Ndb *ndb= get_ndb(); - Uint64 auto_value= ndb->getAutoIncrementValue((const NDBTAB *) m_table); + Uint64 auto_value= NDB_FAILED_AUTO_INCREMENT; + uint retries= NDB_AUTO_INCREMENT_RETRIES; + do { + auto_value= ndb->getAutoIncrementValue((const NDBTAB *) m_table); + } while (auto_value == NDB_FAILED_AUTO_INCREMENT && + --retries && + ndb->getNdbError().status == NdbError::TemporaryError); + if (auto_value == NDB_FAILED_AUTO_INCREMENT) + ERR_RETURN(ndb->getNdbError()); if (set_hidden_key(op, table->s->fields, (const byte*)&auto_value)) ERR_RETURN(op->getNdbError()); } @@ -1919,8 +1948,12 @@ int ha_ndbcluster::write_row(byte *record) if (has_auto_increment) { + THD *thd= table->in_use; + m_skip_auto_increment= FALSE; update_auto_increment(); + /* Ensure that handler is always called for auto_increment values */ + thd->next_insert_id= 0; m_skip_auto_increment= !auto_increment_column_changed; } @@ -1953,7 +1986,7 @@ int ha_ndbcluster::write_row(byte *record) m_rows_inserted++; no_uncommitted_rows_update(1); m_bulk_insert_not_flushed= TRUE; - if ((m_rows_to_insert == 1) || + if ((m_rows_to_insert == (ha_rows) 1) || ((m_rows_inserted % m_bulk_insert_rows) == 0) || set_blob_value) { @@ -2053,7 +2086,11 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) statistic_increment(thd->status_var.ha_update_count, &LOCK_status); if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE) + { table->timestamp_field->set_time(); + // Set query_id so that field is really updated + table->timestamp_field->query_id= thd->query_id; + } /* Check for update of primary key for special handling */ if ((table->s->primary_key != MAX_KEY) && @@ -2658,7 +2695,7 @@ int ha_ndbcluster::close_scan() m_ops_pending= 0; } - cursor->close(m_force_send); + cursor->close(m_force_send, true); m_active_cursor= m_multi_cursor= NULL; DBUG_RETURN(0); } @@ -2965,8 +3002,12 @@ void ha_ndbcluster::start_bulk_insert(ha_rows rows) DBUG_ENTER("start_bulk_insert"); DBUG_PRINT("enter", ("rows: %d", (int)rows)); - m_rows_inserted= 0; - m_rows_to_insert= rows; + m_rows_inserted= (ha_rows) 0; + if (rows == (ha_rows) 0) + /* We don't know how many will be inserted, guess */ + m_rows_to_insert= m_autoincrement_prefetch; + else + m_rows_to_insert= rows; /* Calculate how many rows that should be inserted @@ -3000,7 +3041,7 @@ int ha_ndbcluster::end_bulk_insert() // Send rows to NDB DBUG_PRINT("info", ("Sending inserts to NDB, "\ "rows_inserted:%d, bulk_insert_rows: %d", - m_rows_inserted, m_bulk_insert_rows)); + (int) m_rows_inserted, (int) m_bulk_insert_rows)); m_bulk_insert_not_flushed= FALSE; if (execute_no_commit(this,trans) != 0) { no_uncommitted_rows_execute_failure(); @@ -3008,8 +3049,8 @@ int ha_ndbcluster::end_bulk_insert() } } - m_rows_inserted= 0; - m_rows_to_insert= 1; + m_rows_inserted= (ha_rows) 0; + m_rows_to_insert= (ha_rows) 1; DBUG_RETURN(error); } @@ -3191,7 +3232,8 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type) // store thread specific data first to set the right context m_force_send= thd->variables.ndb_force_send; m_ha_not_exact_count= !thd->variables.ndb_use_exact_count; - m_autoincrement_prefetch= thd->variables.ndb_autoincrement_prefetch_sz; + m_autoincrement_prefetch= + (ha_rows) thd->variables.ndb_autoincrement_prefetch_sz; if (!thd->transaction.on) m_transaction_on= FALSE; else @@ -3715,7 +3757,7 @@ static int create_ndb_column(NDBCOL &col, static void ndb_set_fragmentation(NDBTAB &tab, TABLE *form, uint pk_length) { - if (form->s->max_rows == 0) /* default setting, don't set fragmentation */ + if (form->s->max_rows == (ha_rows) 0) /* default setting, don't set fragmentation */ return; /** * get the number of fragments right @@ -4076,16 +4118,29 @@ ulonglong ha_ndbcluster::get_auto_increment() DBUG_ENTER("get_auto_increment"); DBUG_PRINT("enter", ("m_tabname: %s", m_tabname)); Ndb *ndb= get_ndb(); + + if (m_rows_inserted > m_rows_to_insert) + /* We guessed too low */ + m_rows_to_insert+= m_autoincrement_prefetch; cache_size= + (int) (m_rows_to_insert - m_rows_inserted < m_autoincrement_prefetch) ? m_rows_to_insert - m_rows_inserted : (m_rows_to_insert > m_autoincrement_prefetch) ? m_rows_to_insert : m_autoincrement_prefetch; - auto_value= - (m_skip_auto_increment) ? - ndb->readAutoIncrementValue((const NDBTAB *) m_table) - : ndb->getAutoIncrementValue((const NDBTAB *) m_table, cache_size); + auto_value= NDB_FAILED_AUTO_INCREMENT; + uint retries= NDB_AUTO_INCREMENT_RETRIES; + do { + auto_value= + (m_skip_auto_increment) ? + ndb->readAutoIncrementValue((const NDBTAB *) m_table) + : ndb->getAutoIncrementValue((const NDBTAB *) m_table, cache_size); + } while (auto_value == NDB_FAILED_AUTO_INCREMENT && + --retries && + ndb->getNdbError().status == NdbError::TemporaryError); + if (auto_value == NDB_FAILED_AUTO_INCREMENT) + ERR_RETURN(ndb->getNdbError()); DBUG_RETURN((longlong)auto_value); } @@ -4113,10 +4168,10 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg): m_primary_key_update(FALSE), m_retrieve_all_fields(FALSE), m_retrieve_primary_key(FALSE), - m_rows_to_insert(1), - m_rows_inserted(0), - m_bulk_insert_rows(1024), - m_rows_changed(0), + m_rows_to_insert((ha_rows) 1), + m_rows_inserted((ha_rows) 0), + m_bulk_insert_rows((ha_rows) 1024), + m_rows_changed((ha_rows) 0), m_bulk_insert_not_flushed(FALSE), m_ops_pending(0), m_skip_auto_increment(TRUE), @@ -4126,7 +4181,7 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg): m_dupkey((uint) -1), m_ha_not_exact_count(FALSE), m_force_send(TRUE), - m_autoincrement_prefetch(32), + m_autoincrement_prefetch((ha_rows) 32), m_transaction_on(TRUE), m_cond_stack(NULL), m_multi_cursor(NULL) @@ -5659,7 +5714,7 @@ ha_ndbcluster::read_multi_range_next(KEY_MULTI_RANGE ** multi_range_found_p) close_scan: if (res == 1) { - m_multi_cursor->close(); + m_multi_cursor->close(false, true); m_active_cursor= m_multi_cursor= 0; DBUG_MULTI_RANGE(8); continue; @@ -5799,6 +5854,7 @@ extern "C" pthread_handler_decl(ndb_util_thread_func, { thd->cleanup(); delete thd; + delete ndb; DBUG_RETURN(NULL); } @@ -5917,6 +5973,7 @@ extern "C" pthread_handler_decl(ndb_util_thread_func, thd->cleanup(); delete thd; + delete ndb; DBUG_PRINT("exit", ("ndb_util_thread")); my_thread_end(); pthread_exit(0); diff --git a/sql/handler.cc b/sql/handler.cc index 143e56fdc7c..14b8974ece9 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -25,10 +25,6 @@ #include "ha_heap.h" #include "ha_myisam.h" #include "ha_myisammrg.h" -#ifdef HAVE_ISAM -#include "ha_isam.h" -#include "ha_isammrg.h" -#endif #ifdef HAVE_BERKELEY_DB #include "ha_berkeley.h" #endif @@ -153,18 +149,27 @@ const char *ha_get_storage_engine(enum db_type db_type) return "none"; } + +my_bool ha_storage_engine_is_enabled(enum db_type database_type) +{ + show_table_type_st *types; + for (types= sys_table_types; types->type; types++) + { + if ((database_type == types->db_type) && + (*types->value == SHOW_OPTION_YES)) + return TRUE; + } + return FALSE; +} + + /* Use other database handler if databasehandler is not incompiled */ enum db_type ha_checktype(enum db_type database_type) { - show_table_type_st *types; - THD *thd= current_thd; - for (types= sys_table_types; types->type; types++) - { - if ((database_type == types->db_type) && - (*types->value == SHOW_OPTION_YES)) - return database_type; - } + THD *thd; + if (ha_storage_engine_is_enabled(database_type)) + return database_type; switch (database_type) { #ifndef NO_HASH @@ -177,6 +182,7 @@ enum db_type ha_checktype(enum db_type database_type) break; } + thd= current_thd; return ((enum db_type) thd->variables.table_type != DB_TYPE_UNKNOWN ? (enum db_type) thd->variables.table_type : (enum db_type) global_system_variables.table_type != @@ -308,6 +314,7 @@ static int ha_init_errors(void) SETMSG(HA_ERR_NO_SUCH_TABLE, "No such table: '%.64s'"); SETMSG(HA_ERR_TABLE_EXIST, ER(ER_TABLE_EXISTS_ERROR)); SETMSG(HA_ERR_NO_CONNECTION, "Could not connect to storage engine"); + SETMSG(HA_ERR_TABLE_DEF_CHANGED, ER(ER_TABLE_DEF_CHANGED)); /* Register the error messages for use with my_error(). */ return my_error_register(errmsgs, HA_ERR_FIRST, HA_ERR_LAST); @@ -509,10 +516,16 @@ void ha_close_connection(THD* thd) "beginning of transaction" and "beginning of statement"). Only storage engines registered for the transaction/statement will know when to commit/rollback it. + + NOTE + trans_register_ha is idempotent - storage engine may register many + times per transaction. + */ void trans_register_ha(THD *thd, bool all, handlerton *ht_arg) { THD_TRANS *trans; + handlerton **ht; DBUG_ENTER("trans_register_ha"); DBUG_PRINT("enter",("%s", all ? "all" : "stmt")); @@ -524,15 +537,12 @@ void trans_register_ha(THD *thd, bool all, handlerton *ht_arg) else trans= &thd->transaction.stmt; -#ifndef DBUG_OFF - handlerton **ht=trans->ht; - while (*ht) - { - DBUG_ASSERT(*ht != ht_arg); - ht++; - } -#endif + for (ht=trans->ht; *ht; ht++) + if (*ht == ht_arg) + DBUG_VOID_RETURN; /* already registered, return */ + trans->ht[trans->nht++]=ht_arg; + DBUG_ASSERT(*ht == ht_arg); trans->no_2pc|=(ht_arg->prepare==0); if (thd->transaction.xid.is_null()) thd->transaction.xid.set(thd->query_id); @@ -587,6 +597,11 @@ int ha_commit_trans(THD *thd, bool all) #ifdef USING_TRANSACTIONS if (trans->nht) { + if (is_real_trans && wait_if_global_read_lock(thd, 0, 0)) + { + ha_rollback_trans(thd, all); + DBUG_RETURN(1); + } DBUG_EXECUTE_IF("crash_commit_before", abort();); if (!trans->no_2pc && trans->nht > 1) { @@ -596,7 +611,7 @@ int ha_commit_trans(THD *thd, bool all) if ((err= (*(*ht)->prepare)(thd, all))) { my_error(ER_ERROR_DURING_COMMIT, MYF(0), err); - error=1; + error= 1; } statistic_increment(thd->status_var.ha_prepare_count,&LOCK_status); } @@ -605,20 +620,28 @@ int ha_commit_trans(THD *thd, bool all) (error= !(cookie= tc_log->log(thd, xid))))) { ha_rollback_trans(thd, all); - return 1; + error= 1; + goto end; } - DBUG_EXECUTE_IF("crash_commit_after_log", abort();); + DBUG_EXECUTE_IF("crash_commit_after_log", abort();); } error=ha_commit_one_phase(thd, all) ? cookie ? 2 : 1 : 0; DBUG_EXECUTE_IF("crash_commit_before_unlog", abort();); if (cookie) tc_log->unlog(cookie, xid); DBUG_EXECUTE_IF("crash_commit_after", abort();); +end: + if (is_real_trans) + start_waiting_global_read_lock(thd); } #endif /* USING_TRANSACTIONS */ DBUG_RETURN(error); } +/* + NOTE - this function does not care about global read lock. + A caller should. +*/ int ha_commit_one_phase(THD *thd, bool all) { int error=0; @@ -629,18 +652,6 @@ int ha_commit_one_phase(THD *thd, bool all) #ifdef USING_TRANSACTIONS if (trans->nht) { - bool need_start_waiters= 0; - if (is_real_trans) - { - if ((error= wait_if_global_read_lock(thd, 0, 0))) - { - my_error(ER_ERROR_DURING_COMMIT, MYF(0), error); - error= 1; - } - else - need_start_waiters= 1; - } - for (ht=trans->ht; *ht; ht++) { int err; @@ -665,8 +676,6 @@ int ha_commit_one_phase(THD *thd, bool all) thd->variables.tx_isolation=thd->session_tx_isolation; thd->transaction.cleanup(); } - if (need_start_waiters) - start_waiting_global_read_lock(thd); } #endif /* USING_TRANSACTIONS */ DBUG_RETURN(error); @@ -750,17 +759,15 @@ int ha_autocommit_or_rollback(THD *thd, int error) DBUG_RETURN(error); } -int ha_commit_or_rollback_by_xid(LEX_STRING *ident, bool commit) +int ha_commit_or_rollback_by_xid(XID *xid, bool commit) { - XID xid; handlerton **ht= handlertons, **end_ht=ht+total_ha; int res= 1; - xid.set(ident); for ( ; ht < end_ht ; ht++) if ((*ht)->recover) res= res && - (*(commit ? (*ht)->commit_by_xid : (*ht)->rollback_by_xid))(&xid); + (*(commit ? (*ht)->commit_by_xid : (*ht)->rollback_by_xid))(xid); return res; } @@ -1652,6 +1659,9 @@ void handler::print_error(int error, myf errflag) case HA_ERR_NO_REFERENCED_ROW: textno=ER_NO_REFERENCED_ROW; break; + case HA_ERR_TABLE_DEF_CHANGED: + textno=ER_TABLE_DEF_CHANGED; + break; case HA_ERR_NO_SUCH_TABLE: { /* @@ -2366,9 +2376,9 @@ TYPELIB *ha_known_exts(void) const char **ext, *old_ext; known_extensions_id= mysys_usage_id; - found_exts.push_back((char*) ".db"); + found_exts.push_back((char*) triggers_file_ext); for (types= sys_table_types; types->type; types++) - { + { if (*types->value == SHOW_OPTION_YES) { handler *file= get_new_handler(0,(enum db_type) types->db_type); diff --git a/sql/handler.h b/sql/handler.h index e5b63c7f25c..4c06fe8299d 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -47,14 +47,22 @@ #define HA_ADMIN_WRONG_CHECKSUM -8 /* Bits in table_flags() to show what database can do */ -#define HA_READ_RND_SAME (1 << 0) /* can switch index during the scan - with ::rnd_same() - not used yet. - see mi_rsame/heap_rsame/myrg_rsame */ + +/* + Can switch index during the scan with ::rnd_same() - not used yet. + see mi_rsame/heap_rsame/myrg_rsame +*/ +#define HA_READ_RND_SAME (1 << 0) #define HA_TABLE_SCAN_ON_INDEX (1 << 2) /* No separate data/index file */ #define HA_REC_NOT_IN_SEQ (1 << 3) /* ha_info don't return recnumber; It returns a position to ha_r_rnd */ #define HA_CAN_GEOMETRY (1 << 4) -#define HA_FAST_KEY_READ (1 << 5) /* no need for a record cache in filesort */ +/* + Reading keys in random order is as fast as reading keys in sort order + (Used in records.cc to decide if we should use a record cache and by + filesort to decide if we should sort key + data or key + pointer-to-row +*/ +#define HA_FAST_KEY_READ (1 << 5) #define HA_NULL_IN_KEY (1 << 7) /* One can have keys with NULL */ #define HA_DUPP_POS (1 << 8) /* ha_position() gives dup row */ #define HA_NO_BLOBS (1 << 9) /* Doesn't support blobs */ @@ -62,9 +70,11 @@ #define HA_AUTO_PART_KEY (1 << 11) /* auto-increment in multi-part key */ #define HA_REQUIRE_PRIMARY_KEY (1 << 12) /* .. and can't create a hidden one */ #define HA_NOT_EXACT_COUNT (1 << 13) -#define HA_CAN_INSERT_DELAYED (1 << 14) /* only handlers with table-level locks - need no special code to support - INSERT DELAYED */ +/* + INSERT_DELAYED only works with handlers that uses MySQL internal table + level locks +*/ +#define HA_CAN_INSERT_DELAYED (1 << 14) #define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15) #define HA_NOT_DELETE_WITH_CACHE (1 << 18) #define HA_NO_PREFIX_CHAR_KEYS (1 << 20) @@ -213,13 +223,22 @@ struct xid_t { long bqual_length; char data[XIDDATASIZE]; // not \0-terminated ! - bool eq(LEX_STRING *l) { return eq(l->length, 0, l->str); } + bool eq(struct xid_t *xid) + { return !memcmp(this, xid, sizeof(long)*3+gtrid_length+bqual_length); } bool eq(long g, long b, const char *d) { return g == gtrid_length && b == bqual_length && !memcmp(d, data, g+b); } - void set(LEX_STRING *l) { set(l->length, 0, l->str); } + void set(struct xid_t *xid) + { memcpy(this, xid, sizeof(long)*3+xid->gtrid_length+xid->bqual_length); } + void set(long f, const char *g, long gl, const char *b, long bl) + { + formatID= f; + memcpy(data, g, gtrid_length= gl); + memcpy(data+gl, b, bqual_length= bl); + } void set(ulonglong xid) { my_xid tmp; + formatID= 1; set(MYSQL_XID_PREFIX_LEN, 0, MYSQL_XID_PREFIX); memcpy(data+MYSQL_XID_PREFIX_LEN, &server_id, sizeof(server_id)); tmp= xid; @@ -228,7 +247,7 @@ struct xid_t { } void set(long g, long b, const char *d) { - formatID=1; + formatID= 1; gtrid_length= g; bqual_length= b; memcpy(data, d, g+b); @@ -244,7 +263,7 @@ struct xid_t { my_xid get_my_xid() { return gtrid_length == MYSQL_XID_GTRID_LEN && bqual_length == 0 && - *(ulong*)(data+MYSQL_XID_PREFIX_LEN) == server_id && + !memcmp(data+MYSQL_XID_PREFIX_LEN, &server_id, sizeof(server_id)) && !memcmp(data, MYSQL_XID_PREFIX, MYSQL_XID_PREFIX_LEN) ? quick_get_my_xid() : 0; } @@ -261,8 +280,8 @@ typedef struct xid_t XID; /* handlerton is a singleton structure - one instance per storage engine - - to provide access to storage engine functionality that works on - "global" level (unlike handler class that works on per-table basis) + to provide access to storage engine functionality that works on the + "global" level (unlike handler class that works on a per-table basis) usually handlerton instance is defined statically in ha_xxx.cc as @@ -652,6 +671,8 @@ public: virtual void append_create_info(String *packet) {} virtual char* get_foreign_key_create_info() { return(NULL);} /* gets foreign key create string from InnoDB */ + /* used in ALTER TABLE; 1 if changing storage engine is allowed */ + virtual bool can_switch_engines() { return 1; } /* used in REPLACE; is > 0 if table is referred by a FOREIGN KEY */ virtual int get_foreign_key_list(THD *thd, List *f_key_list) { return 0; } @@ -798,6 +819,7 @@ TYPELIB *ha_known_exts(void); int ha_panic(enum ha_panic_function flag); int ha_update_statistics(); void ha_close_connection(THD* thd); +my_bool ha_storage_engine_is_enabled(enum db_type database_type); bool ha_flush_logs(void); void ha_drop_database(char* path); int ha_create_table(const char *name, HA_CREATE_INFO *create_info, @@ -826,7 +848,7 @@ int ha_release_temporary_latches(THD *thd); /* transactions: interface to handlerton functions */ int ha_start_consistent_snapshot(THD *thd); -int ha_commit_or_rollback_by_xid(LEX_STRING *ident, bool commit); +int ha_commit_or_rollback_by_xid(XID *xid, bool commit); int ha_commit_one_phase(THD *thd, bool all); int ha_rollback_trans(THD *thd, bool all); int ha_prepare(THD *thd); diff --git a/sql/item.cc b/sql/item.cc index 48faa3509f4..73c8e80228b 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -46,7 +46,7 @@ void Hybrid_type_traits::fix_length_and_dec(Item *item, Item *arg) const const Hybrid_type_traits *Hybrid_type_traits::instance() { - const static Hybrid_type_traits real_traits; + static const Hybrid_type_traits real_traits; return &real_traits; } @@ -70,7 +70,7 @@ Hybrid_type_traits::val_str(Hybrid_type *val, String *to, uint8 decimals) const const Hybrid_type_traits_decimal *Hybrid_type_traits_decimal::instance() { - const static Hybrid_type_traits_decimal decimal_traits; + static const Hybrid_type_traits_decimal decimal_traits; return &decimal_traits; } @@ -146,7 +146,7 @@ Hybrid_type_traits_decimal::val_str(Hybrid_type *val, String *to, const Hybrid_type_traits_integer *Hybrid_type_traits_integer::instance() { - const static Hybrid_type_traits_integer integer_traits; + static const Hybrid_type_traits_integer integer_traits; return &integer_traits; } @@ -260,8 +260,15 @@ my_decimal *Item::val_decimal_from_string(my_decimal *decimal_value) return 0; // NULL or EOM end_ptr= (char*) res->ptr()+ res->length(); - str2my_decimal(E_DEC_FATAL_ERROR, res->ptr(), res->length(), res->charset(), - decimal_value); + if (str2my_decimal(E_DEC_FATAL_ERROR & ~E_DEC_BAD_NUM, + res->ptr(), res->length(), res->charset(), + decimal_value) & E_DEC_BAD_NUM) + { + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_TRUNCATED_WRONG_VALUE, + ER(ER_TRUNCATED_WRONG_VALUE), "DECIMAL", + str_value.c_ptr()); + } return decimal_value; } @@ -693,7 +700,7 @@ my_decimal *Item_splocal::val_decimal(my_decimal *decimal_value) { DBUG_ASSERT(fixed); Item *it= this_item(); - my_decimal value, *val= it->val_decimal(&value); + my_decimal *val= it->val_decimal(decimal_value); Item::null_value= it->null_value; return val; } @@ -929,8 +936,17 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags) set(0, DERIVATION_NONE); return 1; } + if (collation->state & MY_CS_BINSORT) + { + return 0; + } + else if (dt.collation->state & MY_CS_BINSORT) + { + set(dt); + return 0; + } CHARSET_INFO *bin= get_charset_by_csname(collation->csname, - MY_CS_BINSORT,MYF(0)); + MY_CS_BINSORT,MYF(0)); set(bin, DERIVATION_NONE); } } @@ -1455,12 +1471,67 @@ void Item_string::print(String *str) } +inline bool check_if_only_end_space(CHARSET_INFO *cs, char *str, char *end) +{ + return str+ cs->cset->scan(cs, str, end, MY_SEQ_SPACES) == end; +} + + +double Item_string::val_real() +{ + DBUG_ASSERT(fixed == 1); + int error; + char *end, *org_end; + double tmp; + CHARSET_INFO *cs= str_value.charset(); + + org_end= (char*) str_value.ptr() + str_value.length(); + tmp= my_strntod(cs, (char*) str_value.ptr(), str_value.length(), &end, + &error); + if (error || (end != org_end && !check_if_only_end_space(cs, end, org_end))) + { + /* + We can use str_value.ptr() here as Item_string is gurantee to put an + end \0 here. + */ + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_TRUNCATED_WRONG_VALUE, + ER(ER_TRUNCATED_WRONG_VALUE), "DOUBLE", + str_value.ptr()); + } + return tmp; +} + + +longlong Item_string::val_int() +{ + DBUG_ASSERT(fixed == 1); + int err; + longlong tmp; + char *end= (char*) str_value.ptr()+ str_value.length(); + char *org_end= end; + CHARSET_INFO *cs= str_value.charset(); + + tmp= (*(cs->cset->strtoll10))(cs, str_value.ptr(), &end, &err); + /* + TODO: Give error if we wanted a signed integer and we got an unsigned + one + */ + if (err > 0 || + (end != org_end && !check_if_only_end_space(cs, end, org_end))) + { + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_TRUNCATED_WRONG_VALUE, + ER(ER_TRUNCATED_WRONG_VALUE), "INTEGER", + str_value.ptr()); + } + return tmp; +} + + my_decimal *Item_string::val_decimal(my_decimal *decimal_value) { - /* following assert is redundant, because fixed=1 assigned in constructor */ - DBUG_ASSERT(fixed == 1); - string2my_decimal(E_DEC_FATAL_ERROR, &str_value, decimal_value); - return (decimal_value); + return val_decimal_from_string(decimal_value); } @@ -2907,41 +2978,38 @@ Item *Item_field::set_no_const_sub(byte *arg) /* - Set a pointer to the multiple equality the field reference belongs to + Replace an Item_field for an equal Item_field that evaluated earlier (if any) SYNOPSIS - replace_equal_field_processor() + replace_equal_field_() arg - a dummy parameter, is not used here DESCRIPTION - The function replaces a pointer to a field in the Item_field object - by a pointer to another field. - The replacement field is taken from the very beginning of - the item_equal list which the Item_field object refers to (belongs to) - If the Item_field object does not refer any Item_equal object, - nothing is done. + The function returns a pointer to an item that is taken from + the very beginning of the item_equal list which the Item_field + object refers to (belongs to). + If the Item_field object does not refer any Item_equal object + 'this' is returned NOTES This function is supposed to be called as a callback parameter in calls - of the walk method. + of the thransformer method. RETURN VALUES - 0 + pointer to a replacement Item_field if there is a better equal item; + this - otherwise. */ -bool Item_field::replace_equal_field_processor(byte *arg) +Item *Item_field::replace_equal_field(byte *arg) { if (item_equal) { Item_field *subst= item_equal->get_first(); if (!field->eq(subst->field)) - { - field= subst->field; - return 0; - } + return subst; } - return 0; + return this; } @@ -4162,6 +4230,7 @@ bool Item_default_value::fix_fields(THD *thd, return FALSE; } + void Item_default_value::print(String *str) { if (!arg) @@ -4174,6 +4243,27 @@ void Item_default_value::print(String *str) str->append(')'); } + +int Item_default_value::save_in_field(Field *field_arg, bool no_conversions) +{ + if (!arg) + { + if (field_arg->flags & NO_DEFAULT_VALUE_FLAG) + { + push_warning_printf(field_arg->table->in_use, + MYSQL_ERROR::WARN_LEVEL_WARN, + ER_NO_DEFAULT_FOR_FIELD, + ER(ER_NO_DEFAULT_FOR_FIELD), + field_arg->field_name); + return 1; + } + field_arg->set_default(); + return 0; + } + return Item_field::save_in_field(field_arg, no_conversions); +} + + bool Item_insert_value::eq(const Item *item, bool binary_cmp) const { return item->type() == INSERT_VALUE_ITEM && @@ -4848,7 +4938,7 @@ bool Item_type_holder::join_types(THD *thd, Item *item) int intp2= max_length - min(decimals, NOT_FIXED_DEC - 1); /* can't be overflow because it work only for decimals (no strings) */ int dec_length= max(intp1, intp2) + decimals; - max_length= max(max_length, max(item_length, dec_length)); + max_length= max(max_length, (uint) max(item_length, dec_length)); /* we can't allow decimals to be NOT_FIXED_DEC, to prevent creation decimal with max precision (see Field_new_decimal constcuctor) @@ -4875,8 +4965,8 @@ bool Item_type_holder::join_types(THD *thd, Item *item) } maybe_null|= item->maybe_null; get_full_info(item); - DBUG_PRINT("info:", ("become type %d len %d, dec %d", - fld_type, max_length, decimals)); + DBUG_PRINT("info", ("become type: %d len: %u dec: %u", + (int) fld_type, max_length, (uint) decimals)); DBUG_RETURN(FALSE); } diff --git a/sql/item.h b/sql/item.h index 0a2be74c76c..e86c66ca6f3 100644 --- a/sql/item.h +++ b/sql/item.h @@ -520,7 +520,7 @@ public: virtual bool collect_item_field_processor(byte * arg) { return 0; } virtual Item *equal_fields_propagator(byte * arg) { return this; } virtual Item *set_no_const_sub(byte *arg) { return this; } - virtual bool replace_equal_field_processor(byte * arg) { return 0; } + virtual Item *replace_equal_field(byte * arg) { return this; } virtual Item *this_item() { return this; } /* For SPs mostly. */ virtual Item *this_const_item() const { return const_cast(this); } /* For SPs mostly. */ @@ -545,6 +545,8 @@ public: cleanup(); delete this; } + + virtual bool is_splocal() { return 0; } /* Needed for error checking */ }; @@ -564,6 +566,8 @@ public: Item::maybe_null= TRUE; } + bool is_splocal() { return 1; } /* Needed for error checking */ + Item *this_item(); Item *this_const_item() const; @@ -750,7 +754,7 @@ public: Item_equal *find_item_equal(COND_EQUAL *cond_equal); Item *equal_fields_propagator(byte *arg); Item *set_no_const_sub(byte *arg); - bool replace_equal_field_processor(byte *arg); + Item *replace_equal_field(byte *arg); inline uint32 max_disp_length() { return field->max_length(); } Item_field *filed_for_view_update() { return this; } Item *safe_charset_converter(CHARSET_INFO *tocs); @@ -1098,21 +1102,8 @@ public: fixed= 1; } enum Type type() const { return STRING_ITEM; } - double val_real() - { - DBUG_ASSERT(fixed == 1); - int err_not_used; - char *end_not_used; - return my_strntod(str_value.charset(), (char*) str_value.ptr(), - str_value.length(), &end_not_used, &err_not_used); - } - longlong val_int() - { - DBUG_ASSERT(fixed == 1); - int err; - return my_strntoll(str_value.charset(), str_value.ptr(), - str_value.length(), 10, (char**) 0, &err); - } + double val_real(); + longlong val_int(); String *val_str(String*) { DBUG_ASSERT(fixed == 1); @@ -1515,15 +1506,7 @@ public: bool eq(const Item *item, bool binary_cmp) const; bool fix_fields(THD *, struct st_table_list *, Item **); void print(String *str); - int save_in_field(Field *field_arg, bool no_conversions) - { - if (!arg) - { - field_arg->set_default(); - return 0; - } - return Item_field::save_in_field(field_arg, no_conversions); - } + int save_in_field(Field *field_arg, bool no_conversions); table_map used_tables() const { return (table_map)0L; } bool walk(Item_processor processor, byte *args) diff --git a/sql/item_create.cc b/sql/item_create.cc index 35cc46989f7..b9073a6c0b3 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -303,6 +303,7 @@ Item *create_func_current_user() char buff[HOSTNAME_LENGTH+USERNAME_LENGTH+2]; uint length; + thd->lex->safe_to_cache_query= 0; length= (uint) (strxmov(buff, thd->priv_user, "@", thd->priv_host, NullS) - buff); return new Item_static_string_func("current_user()", diff --git a/sql/item_row.cc b/sql/item_row.cc index 00d849e55de..0c8baa332ca 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -73,8 +73,8 @@ bool Item_row::fix_fields(THD *thd, TABLE_LIST *tabl, Item **ref) with_null|= item->null_inside(); else { - item->val_int(); - with_null|= item->null_value; + if (item->is_null()) + with_null|= 1; } } maybe_null|= item->maybe_null; diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 56864109a04..1a407c695b2 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -96,6 +96,7 @@ public: virtual bool exec(); virtual void fix_length_and_dec(); table_map used_tables() const; + table_map not_null_tables() const { return 0; } bool const_item() const; inline table_map get_used_tables_cache() { return used_tables_cache; } inline bool get_const_item_cache() { return const_item_cache; } diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 3dbc3833f9e..64f23c3fc08 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -2670,7 +2670,7 @@ int dump_leaf_key(byte* key, element_count count __attribute__((unused)), { TABLE *table= item->table; char *record= (char*) table->record[0] + table->s->null_bytes; - String tmp(table->record[1], table->s->reclength, default_charset_info), tmp2; + String tmp((char *)table->record[1], table->s->reclength, default_charset_info), tmp2; String *result= &item->result; Item **arg= item->args, **arg_end= item->args + item->arg_count_field; @@ -2802,9 +2802,20 @@ Item_func_group_concat::Item_func_group_concat(THD *thd, void Item_func_group_concat::cleanup() { + THD *thd= current_thd; + DBUG_ENTER("Item_func_group_concat::cleanup"); Item_sum::cleanup(); + /* Adjust warning message to include total number of cut values */ + if (warning) + { + char warn_buff[MYSQL_ERRMSG_SIZE]; + sprintf(warn_buff, ER(ER_CUT_VALUE_GROUP_CONCAT), count_cut_values); + warning->set_msg(thd, warn_buff); + warning= 0; + } + /* Free table and tree if they belong to this item (if item have not pointer to original item from which was made copy => it own its objects ) @@ -2966,8 +2977,7 @@ bool Item_func_group_concat::setup(THD *thd) DBUG_RETURN(TRUE); if (item->const_item()) { - (void) item->val_int(); - if (item->null_value) + if (item->is_null()) { always_null= 1; DBUG_RETURN(FALSE); @@ -3060,6 +3070,10 @@ String* Item_func_group_concat::val_str(String* str) return 0; if (count_cut_values && !warning) { + /* + ER_CUT_VALUE_GROUP_CONCAT needs an argument, but this gets set in + Item_func_group_concat::cleanup(). + */ DBUG_ASSERT(table); warning= push_warning(table->in_use, MYSQL_ERROR::WARN_LEVEL_WARN, ER_CUT_VALUE_GROUP_CONCAT, diff --git a/sql/item_sum.h b/sql/item_sum.h index d03ef94b9cd..8c8360b0726 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -734,7 +734,7 @@ public: return 0; /* Null value */ cs= res->charset(); end= (char*) res->ptr()+res->length(); - return cs->cset->my_strtoll10(cs, res->ptr(), &end, &err_not_used); + return cs->cset->strtoll10(cs, res->ptr(), &end, &err_not_used); } my_decimal *val_decimal(my_decimal *dec); enum Item_result result_type () const { return STRING_RESULT; } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index c603d41fa2e..cd4777d542b 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -775,6 +775,81 @@ static bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs, } +/* + Calculate difference between two datetime values as seconds + microseconds. + + SYNOPSIS + calc_time_diff() + l_time1 - TIME/DATE/DATETIME value + l_time2 - TIME/DATE/DATETIME value + l_sign - 1 absolute values are substracted, + -1 absolute values are added. + seconds_out - Out parameter where difference between + l_time1 and l_time2 in seconds is stored. + microseconds_out- Out parameter where microsecond part of difference + between l_time1 and l_time2 is stored. + + NOTE + This function calculates difference between l_time1 and l_time2 absolute + values. So one should set l_sign and correct result if he want to take + signs into account (i.e. for TIME values). + + RETURN VALUES + Returns sign of difference. + 1 means negative result + 0 means positive result + +*/ + +static bool calc_time_diff(TIME *l_time1, TIME *l_time2, int l_sign, + longlong *seconds_out, long *microseconds_out) +{ + long days; + bool neg; + longlong microseconds; + + /* + We suppose that if first argument is MYSQL_TIMESTAMP_TIME + the second argument should be TIMESTAMP_TIME also. + We should check it before calc_time_diff call. + */ + if (l_time1->time_type == MYSQL_TIMESTAMP_TIME) // Time value + days= l_time1->day - l_sign*l_time2->day; + else + { + days= calc_daynr((uint) l_time1->year, + (uint) l_time1->month, + (uint) l_time1->day); + if (l_time2->time_type == MYSQL_TIMESTAMP_TIME) + days-= l_sign*l_time2->day; + else + days-= l_sign*calc_daynr((uint) l_time2->year, + (uint) l_time2->month, + (uint) l_time2->day); + } + + microseconds= ((longlong)days*LL(86400) + + (longlong)(l_time1->hour*3600L + + l_time1->minute*60L + + l_time1->second) - + l_sign*(longlong)(l_time2->hour*3600L + + l_time2->minute*60L + + l_time2->second)) * LL(1000000) + + (longlong)l_time1->second_part - + l_sign*(longlong)l_time2->second_part; + + neg= 0; + if (microseconds < 0) + { + microseconds= -microseconds; + neg= 1; + } + *seconds_out= microseconds/1000000L; + *microseconds_out= (long) (microseconds%1000000L); + return neg; +} + + longlong Item_func_period_add::val_int() { DBUG_ASSERT(fixed == 1); @@ -2181,39 +2256,47 @@ String *Item_char_typecast::val_str(String *str) res->set_charset(cast_cs); /* - Cut the tail if cast with length - and the result is longer than cast length, e.g. - CAST('string' AS CHAR(1)) + Cut the tail if cast with length + and the result is longer than cast length, e.g. + CAST('string' AS CHAR(1)) */ if (cast_length >= 0 && (res->length() > (length= (uint32) res->charpos(cast_length)))) { // Safe even if const arg + char char_type[40]; + my_snprintf(char_type, sizeof(char_type), "CHAR(%lu)", length); + if (!res->alloced_length()) { // Don't change const str str_value= *res; // Not malloced string res= &str_value; } + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_TRUNCATED_WRONG_VALUE, + ER(ER_TRUNCATED_WRONG_VALUE), char_type, + res->c_ptr_safe()); res->length((uint) length); } null_value= 0; return res; } + void Item_char_typecast::fix_length_and_dec() { uint32 char_length; - /* - We always force character set conversion if cast_cs - is a multi-byte character set. It garantees that the - result of CAST is a well-formed string. - For single-byte character sets we allow just to copy - from the argument. A single-byte character sets string - is always well-formed. + /* + We always force character set conversion if cast_cs is a + multi-byte character set. It garantees that the result of CAST is + a well-formed string. For single-byte character sets we allow + just to copy from the argument. A single-byte character sets + string is always well-formed. */ - charset_conversion= (cast_cs->mbmaxlen > 1) || - !my_charset_same(args[0]->collation.collation, cast_cs) && - args[0]->collation.collation != &my_charset_bin && - cast_cs != &my_charset_bin; + charset_conversion= ((cast_cs->mbmaxlen > 1) || + !my_charset_same(args[0]->collation.collation, + cast_cs) && + args[0]->collation.collation != &my_charset_bin && + cast_cs != &my_charset_bin); collation.set(cast_cs, DERIVATION_IMPLICIT); char_length= (cast_length >= 0) ? cast_length : args[0]->max_length/args[0]->collation.collation->mbmaxlen; @@ -2365,11 +2448,11 @@ String *Item_func_add_time::val_str(String *str) DBUG_ASSERT(fixed == 1); TIME l_time1, l_time2, l_time3; bool is_time= 0; - long microseconds, seconds, days= 0; + long days, microseconds; + longlong seconds; int l_sign= sign; null_value=0; - l_time3.neg= 0; if (is_date) // TIMESTAMP function { if (get_arg0_date(&l_time1, TIME_FUZZY_DATE) || @@ -2385,51 +2468,26 @@ String *Item_func_add_time::val_str(String *str) l_time2.time_type == MYSQL_TIMESTAMP_DATETIME) goto null_date; is_time= (l_time1.time_type == MYSQL_TIMESTAMP_TIME); - if (is_time && (l_time2.neg == l_time1.neg && l_time1.neg)) - l_time3.neg= 1; } if (l_time1.neg != l_time2.neg) l_sign= -l_sign; - microseconds= l_time1.second_part + l_sign*l_time2.second_part; - seconds= (l_time1.hour*3600L + l_time1.minute*60L + l_time1.second + - (l_time2.day*86400L + l_time2.hour*3600L + - l_time2.minute*60L + l_time2.second)*l_sign); - if (is_time) - seconds+= l_time1.day*86400L; - else - days+= calc_daynr((uint) l_time1.year,(uint) l_time1.month, - (uint) l_time1.day); - seconds= seconds + microseconds/1000000L; - microseconds= microseconds%1000000L; - days+= seconds/86400L; - seconds= seconds%86400L; + l_time3.neg= calc_time_diff(&l_time1, &l_time2, -l_sign, + &seconds, µseconds); - if (microseconds < 0) - { - microseconds+= 1000000L; - seconds--; - } - if (seconds < 0) - { - days+= seconds/86400L - 1; - seconds+= 86400L; - } - if (days < 0) - { - if (!is_time) - goto null_date; - if (microseconds) - { - microseconds= 1000000L - microseconds; - seconds++; - } - seconds= 86400L - seconds; - days= -(++days); - l_time3.neg= 1; - } + /* + If first argument was negative and diff between arguments + is non-zero we need to swap sign to get proper result. + */ + if (l_time1.neg && (seconds || microseconds)) + l_time3.neg= 1-l_time3.neg; // Swap sign of result - calc_time_from_sec(&l_time3, seconds, microseconds); + if (!is_time && l_time3.neg) + goto null_date; + + days= (long)(seconds/86400L); + + calc_time_from_sec(&l_time3, (long)(seconds%86400L), microseconds); if (!is_time) { get_date_from_daynr(days,&l_time3.year,&l_time3.month,&l_time3.day); @@ -2474,71 +2532,6 @@ void Item_func_add_time::print(String *str) } -/* - Calculate difference between two datetime values as seconds + microseconds. - - SYNOPSIS - calc_time_diff() - l_time1 - TIME/DATE/DATETIME value - l_time2 - TIME/DATE/DATETIME value - l_sign - 1 absolute values are substracted, - -1 absolute values are added. - seconds_out - Out parameter where difference between - l_time1 and l_time2 in seconds is stored. - microseconds_out- Out parameter where microsecond part of difference - between l_time1 and l_time2 is stored. - - NOTE - This function calculates difference between l_time1 and l_time2 absolute - values. So one should set l_sign and correct result if he want to take - signs into account (i.e. for TIME values). - - RETURN VALUES - Returns sign of difference. - 1 means negative result - 0 means positive result - -*/ - -static bool calc_time_diff(TIME *l_time1, TIME *l_time2, int l_sign, - longlong *seconds_out, long *microseconds_out) -{ - long days; - bool neg; - longlong microseconds; - - /* - We suppose that if first argument is MYSQL_TIMESTAMP_TIME - the second argument should be TIMESTAMP_TIME also. - We should check it before calc_time_diff call. - */ - if (l_time1->time_type == MYSQL_TIMESTAMP_TIME) // Time value - days= l_time1->day - l_sign*l_time2->day; - else // DateTime value - days= (calc_daynr((uint) l_time1->year, - (uint) l_time1->month, - (uint) l_time1->day) - - l_sign*calc_daynr((uint) l_time2->year, - (uint) l_time2->month, - (uint) l_time2->day)); - - microseconds= ((longlong)days*86400L + - l_time1->hour*3600L + l_time1->minute*60L + l_time1->second - - (longlong)l_sign*(l_time2->hour*3600L + l_time2->minute*60L + - l_time2->second))*1000000L + - l_time1->second_part - l_sign*l_time2->second_part; - - neg= 0; - if (microseconds < 0) - { - microseconds= -microseconds; - neg= 1; - } - *seconds_out= microseconds/1000000L; - *microseconds_out= (long) (microseconds%1000000L); - return neg; -} - /* TIMEDIFF(t,s) is a time function that calculates the time value between a start and end time. @@ -2564,16 +2557,15 @@ String *Item_func_timediff::val_str(String *str) if (l_time1.neg != l_time2.neg) l_sign= -l_sign; - l_time3.neg= calc_time_diff(&l_time1,&l_time2, l_sign, + l_time3.neg= calc_time_diff(&l_time1, &l_time2, l_sign, &seconds, µseconds); /* For MYSQL_TIMESTAMP_TIME only: - If both argumets are negative values and diff between them + If first argument was negative and diff between arguments is non-zero we need to swap sign to get proper result. */ - if ((l_time2.neg == l_time1.neg) && l_time1.neg && - (seconds || microseconds)) + if (l_time1.neg && (seconds || microseconds)) l_time3.neg= 1-l_time3.neg; // Swap sign of result calc_time_from_sec(&l_time3, (long) seconds, microseconds); diff --git a/sql/lock.cc b/sql/lock.cc index 266e8dc4d4d..a8ccba32d4f 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -736,6 +736,13 @@ static void print_lock_error(int error, const char *table) protect_against_global_read_lock count of threads which have set protection against global read lock. + access to them is protected with a mutex LOCK_global_read_lock + + (XXX: one should never take LOCK_open if LOCK_global_read_lock is taken, + otherwise a deadlock may occur - see mysql_rm_table. Other mutexes could + be a problem too - grep the code for global_read_lock if you want to use + any other mutex here) + How blocking of threads by global read lock is achieved: that's advisory. Any piece of code which should be blocked by global read lock must be designed like this: @@ -773,7 +780,7 @@ static void print_lock_error(int error, const char *table) table instance of thd2 thd1: COMMIT; # blocked by thd3. thd1 blocks thd2 which blocks thd3 which blocks thd1: deadlock. - + Note that we need to support that one thread does FLUSH TABLES WITH READ LOCK; and then COMMIT; (that's what innobackup does, for some good reason). @@ -818,7 +825,7 @@ bool lock_global_read_lock(THD *thd) } thd->global_read_lock= GOT_GLOBAL_READ_LOCK; global_read_lock++; - thd->exit_cond(old_message); + thd->exit_cond(old_message); // this unlocks LOCK_global_read_lock } /* We DON'T set global_read_lock_blocks_commit now, it will be set after @@ -887,8 +894,8 @@ bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh, The following is only true in case of a global read locks (which is rare) and if old_message is set */ - if (unlikely(need_exit_cond)) - thd->exit_cond(old_message); + if (unlikely(need_exit_cond)) + thd->exit_cond(old_message); // this unlocks LOCK_global_read_lock else pthread_mutex_unlock(&LOCK_global_read_lock); DBUG_RETURN(result); @@ -938,7 +945,7 @@ bool make_global_read_lock_block_commit(THD *thd) global_read_lock_blocks_commit--; // undo what we did else thd->global_read_lock= MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT; - thd->exit_cond(old_message); + thd->exit_cond(old_message); // this unlocks LOCK_global_read_lock DBUG_RETURN(error); } diff --git a/sql/log.cc b/sql/log.cc index 37f9c5a9122..aabf54d613a 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1532,18 +1532,20 @@ bool MYSQL_LOG::write(THD *thd,enum enum_server_command command, return 0; } - -inline bool sync_binlog(IO_CACHE *cache) +bool MYSQL_LOG::flush_and_sync() { - if (sync_binlog_period == ++sync_binlog_counter && sync_binlog_period) + int err=0, fd=log_file.file; + safe_mutex_assert_owner(&LOCK_log); + if (flush_io_cache(&log_file)) + return 1; + if (++sync_binlog_counter >= sync_binlog_period && sync_binlog_period) { sync_binlog_counter= 0; - return my_sync(cache->file, MYF(MY_WME)); + err=my_sync(fd, MYF(MY_WME)); } - return 0; + return err; } - /* Write an event to the binary log */ @@ -1677,8 +1679,8 @@ bool MYSQL_LOG::write(Log_event *event_info) } } - /* - Write the SQL command + /* + Write the SQL command */ if (event_info->write(file)) @@ -1686,8 +1688,10 @@ bool MYSQL_LOG::write(Log_event *event_info) if (file == &log_file) // we are writing to the real log (disk) { - if (flush_io_cache(file) || sync_binlog(file)) + if (flush_and_sync()) goto err; + signal_update(); + rotate_and_purge(RP_LOCK_LOG_IS_ALREADY_LOCKED); } error=0; @@ -1700,15 +1704,9 @@ err: my_error(ER_ERROR_ON_WRITE, MYF(0), name, errno); write_error=1; } - if (file == &log_file) - { - signal_update(); - rotate_and_purge(RP_LOCK_LOG_IS_ALREADY_LOCKED); - } } pthread_mutex_unlock(&LOCK_log); - DBUG_RETURN(error); } @@ -1815,7 +1813,7 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event) if (commit_event->write(&log_file)) goto err; DBUG_skip_commit: - if (flush_io_cache(&log_file) || sync_binlog(&log_file)) + if (flush_and_sync()) goto err; DBUG_EXECUTE_IF("half_binlogged_transaction", abort();); if (cache->error) // Error on read @@ -1985,26 +1983,26 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length, SYNOPSIS wait_for_update() thd Thread variable - master_or_slave If 0, the caller is the Binlog_dump thread from master; + is_slave If 0, the caller is the Binlog_dump thread from master; if 1, the caller is the SQL thread from the slave. This influences only thd->proc_info. NOTES One must have a lock on LOCK_log before calling this function. - This lock will be freed before return! That's required by + This lock will be released before return! That's required by THD::enter_cond() (see NOTES in sql_class.h). */ -void MYSQL_LOG::wait_for_update(THD* thd, bool master_or_slave) +void MYSQL_LOG::wait_for_update(THD* thd, bool is_slave) { const char *old_msg; DBUG_ENTER("wait_for_update"); old_msg= thd->enter_cond(&update_cond, &LOCK_log, - master_or_slave ? + is_slave ? "Has read all relay log; waiting for the slave I/O " - "thread to update it" : + "thread to update it" : "Has sent all binlog to slave; waiting for binlog " - "to be updated"); + "to be updated"); pthread_cond_wait(&update_cond, &LOCK_log); thd->exit_cond(old_msg); DBUG_VOID_RETURN; @@ -2053,7 +2051,12 @@ void MYSQL_LOG::close(uint exiting) my_pwrite(log_file.file, &flags, 1, offset, MYF(0)); } - if (my_close(log_file.file,MYF(0)) < 0 && ! write_error) + if (my_sync(log_file.file,MYF(MY_WME)) && ! write_error) + { + write_error=1; + sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno); + } + if (my_close(log_file.file,MYF(MY_WME)) && ! write_error) { write_error=1; sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno); @@ -2947,8 +2950,10 @@ int TC_LOG_BINLOG::log(THD *thd, my_xid xid) void TC_LOG_BINLOG::unlog(ulong cookie, my_xid xid) { - if (thread_safe_dec_and_test(prepared_xids, &LOCK_prep_xids)) + pthread_mutex_lock(&LOCK_prep_xids); + if (--prepared_xids == 0) pthread_cond_signal(&COND_prep_xids); + pthread_mutex_unlock(&LOCK_prep_xids); rotate_and_purge(0); // as ::write() did not rotate } diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc index 19b6abd7243..b4bbef4a637 100644 --- a/sql/my_decimal.cc +++ b/sql/my_decimal.cc @@ -175,7 +175,7 @@ int str2my_decimal(uint mask, const char *from, uint length, err= string2decimal((char *)from, (decimal_t*) decimal_value, &end); if (end != from_end && !err) { - /* Give warining if there is something other than end space */ + /* Give warning if there is something other than end space */ for ( ; end < from_end; end++) { if (!my_isspace(&my_charset_latin1, *end)) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 950efc07efa..8005a29e975 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -116,7 +116,7 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset; The following parameters is to decide when to use an extra cache to optimise seeks when reading a big table in sorted order */ -#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (16L*1024*1024) +#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024) #define MIN_ROWS_TO_USE_TABLE_CACHE 100 #define MIN_ROWS_TO_USE_BULK_INSERT 100 @@ -442,7 +442,6 @@ extern ulong server_id, concurrency; typedef my_bool (*qc_engine_callback)(THD *thd, char *table_key, uint key_length, ulonglong *engine_data); - #include "sql_string.h" #include "sql_list.h" #include "sql_map.h" @@ -450,6 +449,7 @@ typedef my_bool (*qc_engine_callback)(THD *thd, char *table_key, #include "handler.h" #include "parse_file.h" #include "table.h" +#include "sql_error.h" #include "field.h" /* Field definitions */ #include "protocol.h" #include "sql_udf.h" @@ -651,11 +651,6 @@ int prepare_create_field(create_field *sql_field, uint *blob_columns, int *timestamps, int *timestamps_with_niladic, uint table_flags); -int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, - List &fields, - List &keys, uint &db_options, - handler *file, KEY *&key_info_buffer, - uint &key_count, int select_field_count); bool mysql_create_table(THD *thd,const char *db, const char *table_name, HA_CREATE_INFO *create_info, List &fields, List &keys, @@ -830,14 +825,6 @@ void mysql_stmt_get_longdata(THD *thd, char *pos, ulong packet_length); void reset_stmt_for_execute(THD *thd, LEX *lex); void init_stmt_after_parse(THD*, LEX*); -/* sql_error.cc */ -MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, uint code, - const char *msg); -void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level, - uint code, const char *format, ...); -void mysql_reset_errors(THD *thd, bool force); -bool mysqld_show_warnings(THD *thd, ulong levels_to_show); - /* sql_handler.cc */ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen); bool mysql_ha_close(THD *thd, TABLE_LIST *tables); @@ -1044,6 +1031,7 @@ extern const char *first_keyword, *my_localhost, *delayed_user, *binary_keyword; extern const char **errmesg; /* Error messages */ extern const char *myisam_recover_options_str; extern const char *in_left_expr_name, *in_additional_cond; +extern const char * const triggers_file_ext; extern Eq_creator eq_creator; extern Ne_creator ne_creator; extern Gt_creator gt_creator; @@ -1126,10 +1114,6 @@ extern MY_BITMAP temp_pool; extern String my_empty_string; extern const String my_null_string; extern SHOW_VAR init_vars[],status_vars[], internal_vars[]; -extern SHOW_COMP_OPTION have_isam; -extern SHOW_COMP_OPTION have_innodb; -extern SHOW_COMP_OPTION have_berkeley_db; -extern SHOW_COMP_OPTION have_ndbcluster; extern struct system_variables global_system_variables; extern struct system_variables max_system_variables; extern struct system_status_var global_status_var; @@ -1149,12 +1133,13 @@ extern struct my_option my_long_options[]; extern SHOW_COMP_OPTION have_isam, have_innodb, have_berkeley_db; extern SHOW_COMP_OPTION have_example_db, have_archive_db, have_csv_db; extern SHOW_COMP_OPTION have_federated_db; +extern SHOW_COMP_OPTION have_blackhole_db; +extern SHOW_COMP_OPTION have_ndbcluster; extern SHOW_COMP_OPTION have_raid, have_openssl, have_symlink; -extern SHOW_COMP_OPTION have_query_cache, have_berkeley_db, have_innodb; +extern SHOW_COMP_OPTION have_query_cache; extern SHOW_COMP_OPTION have_geometry, have_rtree_keys; extern SHOW_COMP_OPTION have_crypt; extern SHOW_COMP_OPTION have_compress; -extern SHOW_COMP_OPTION have_blackhole_db; #ifndef __WIN__ extern pthread_t signal_thread; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index bbef9ca6d26..88632db7ab5 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -31,9 +31,6 @@ #include "ha_innodb.h" #endif #include "ha_myisam.h" -#ifdef HAVE_ISAM -#include "ha_isam.h" -#endif #ifdef HAVE_NDBCLUSTER_DB #include "ha_ndbcluster.h" #endif @@ -48,11 +45,6 @@ #else #define OPT_BDB_DEFAULT 0 #endif -#ifdef HAVE_ISAM_DB -#define OPT_ISAM_DEFAULT 1 -#else -#define OPT_ISAM_DEFAULT 0 -#endif #ifdef HAVE_NDBCLUSTER_DB #define OPT_NDBCLUSTER_DEFAULT 0 #if defined(NOT_ENOUGH_TESTED) \ @@ -65,7 +57,6 @@ #define OPT_NDBCLUSTER_DEFAULT 0 #endif -#include #include #include #include @@ -796,15 +787,6 @@ void kill_mysql(void) CloseHandle(hEvent); */ } -#ifdef HAVE_SMEM - /* - Send event to smem_event_connect_request for aborting - */ - if (!SetEvent(smem_event_connect_request)) - { - DBUG_PRINT("error",("Got error: %ld from SetEvent of smem_event_connect_request",GetLastError())); - } -#endif #endif #elif defined(OS2) pthread_cond_signal(&eventShutdown); // post semaphore @@ -858,6 +840,18 @@ static void __cdecl kill_server(int sig_ptr) else sql_print_error(ER(ER_GOT_SIGNAL),my_progname,sig); /* purecov: inspected */ +#if defined(HAVE_SMEM) && defined(__WIN__) + /* + Send event to smem_event_connect_request for aborting + */ + if (!SetEvent(smem_event_connect_request)) + { + DBUG_PRINT("error", + ("Got error: %ld from SetEvent of smem_event_connect_request", + GetLastError())); + } +#endif + #if defined(__NETWARE__) || (defined(USE_ONE_SIGNAL_HAND) && !defined(__WIN__) && !defined(OS2)) my_thread_init(); // If this is a new thread #endif @@ -1032,8 +1026,8 @@ void clean_up(bool print_message) (void) my_delete(pidfile_name,MYF(0)); // This may not always exist #endif finish_client_errs(); - const char **errmsgs= my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST); - x_free((gptr) errmsgs); /* Free messages */ + my_free((gptr) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST), + MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); DBUG_PRINT("quit", ("Error messages freed")); /* Tell main we are ready */ (void) pthread_mutex_lock(&LOCK_thread_count); @@ -1187,6 +1181,7 @@ static struct passwd *check_user(const char *user) err: sql_print_error("Fatal error: Can't change to run as user '%s' ; Please check that the user exists!\n",user); + unireg_abort(1); #endif return NULL; } @@ -1515,6 +1510,7 @@ void end_thread(THD *thd, bool put_in_cache) thd=thread_cache.get(); thd->real_id=pthread_self(); (void) thd->store_globals(); + thd->thr_create_time= time(NULL); threads.append(thd); pthread_mutex_unlock(&LOCK_thread_count); DBUG_VOID_RETURN; @@ -2437,8 +2433,10 @@ static int init_common_variables(const char *conf_file_name, int argc, { struct tm tm_tmp; localtime_r(&start_time,&tm_tmp); - strmov(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0]); - } + strmake(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0], + sizeof(system_time_zone)-1); + + } #endif /* We set SYSTEM time zone as reasonable default and @@ -3152,6 +3150,7 @@ we force server id to 2, but this MySQL server will not act as a slave."); if (opt_bootstrap) { + select_thread_in_use= 0; // Allow 'kill' to work bootstrap(stdin); end_thr_alarm(1); // Don't allow alarms unireg_abort(bootstrap_error ? 1 : 0); @@ -4344,7 +4343,7 @@ Disable with --skip-bdb (will save memory).", "Don't try to recover Berkeley DB tables on start.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"bdb-no-sync", OPT_BDB_NOSYNC, - "Disable synchronously flushing logs. This option is deprecated, use --skip-sync-bdb-logs or sync-bdb-logs=0 instead", + "This option is deprecated, use --skip-sync-bdb-logs instead", // (gptr*) &opt_sync_bdb_logs, (gptr*) &opt_sync_bdb_logs, 0, GET_BOOL, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"bdb-shared-data", OPT_BDB_SHARED, @@ -4501,8 +4500,24 @@ Disable with --skip-innodb-checksums.", (gptr*) &innobase_use_checksums, Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite, (gptr*) &innobase_use_doublewrite, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"innodb_fast_shutdown", OPT_INNODB_FAST_SHUTDOWN, - "Speeds up server shutdown process.", (gptr*) &innobase_fast_shutdown, - (gptr*) &innobase_fast_shutdown, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, + "Speeds up the shutdown process of the InnoDB storage engine. Possible " + "values are 0, 1 (faster)" + /* + NetWare can't close unclosed files, can't automatically kill remaining + threads, etc, so on this OS we disable the crash-like InnoDB shutdown. + */ +#ifndef __NETWARE__ + " or 2 (fastest - crash-like)" +#endif + ".", + (gptr*) &innobase_fast_shutdown, + (gptr*) &innobase_fast_shutdown, 0, GET_ULONG, OPT_ARG, 1, 0, +#ifndef __NETWARE__ + 2, +#else + 1, +#endif + 0, 0, 0}, {"innodb_file_per_table", OPT_INNODB_FILE_PER_TABLE, "Stores each InnoDB table to an .ibd file in the database dir.", (gptr*) &innobase_file_per_table, @@ -4553,9 +4568,8 @@ Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite, (gptr*) &global_system_variables.innodb_support_xa, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, #endif /* End HAVE_INNOBASE_DB */ - {"isam", OPT_ISAM, "Enable ISAM (if this version of MySQL supports it). \ -Disable with --skip-isam.", - (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, OPT_ISAM_DEFAULT, 0, 0, + {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.", + (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"language", 'L', "Client error messages in given language. May be given as a full path.", @@ -4715,7 +4729,7 @@ Disable with --skip-ndbcluster (will save memory).", "Specify number of autoincrement values that are prefetched.", (gptr*) &global_system_variables.ndb_autoincrement_prefetch_sz, (gptr*) &global_system_variables.ndb_autoincrement_prefetch_sz, - 0, GET_INT, REQUIRED_ARG, 32, 1, 256, 0, 0, 0}, + 0, GET_ULONG, REQUIRED_ARG, 32, 1, 256, 0, 0, 0}, {"ndb-force-send", OPT_NDB_FORCE_SEND, "Force send of buffers to ndb immediately without waiting for " "other threads.", @@ -5182,7 +5196,7 @@ log and this option does nothing anymore.", (gptr*) &dflt_key_cache_var.param_buff_size, (gptr*) 0, 0, (GET_ULL | GET_ASK_ADDR), - REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, UINT_MAX32, MALLOC_OVERHEAD, + REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, ~(ulong) 0, MALLOC_OVERHEAD, IO_SIZE, 0}, {"key_cache_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD, "This characterizes the number of hits a hot block has to be untouched until it is considered aged enough to be downgraded to a warm block. This specifies the percentage ratio of that number of hits to the total number of blocks in key cache", @@ -5471,36 +5485,35 @@ The minimum value for this variable is 4096.", 1, 0}, #ifdef HAVE_BERKELEY_DB {"sync-bdb-logs", OPT_BDB_SYNC, - "Synchronously flush logs. Enabled by default", + "Synchronously flush Berkeley DB logs. Enabled by default", (gptr*) &opt_sync_bdb_logs, (gptr*) &opt_sync_bdb_logs, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, #endif /* HAVE_BERKELEY_DB */ {"sync-binlog", OPT_SYNC_BINLOG, - "Sync the binlog to disk after every #th event. \ -#=0 (the default) does no sync. Syncing slows MySQL down", - (gptr*) &sync_binlog_period, - (gptr*) &sync_binlog_period, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1, - 0}, + "Synchronously flush binary log to disk after every #th event. " + "Use 0 (default) to disable synchronous flushing.", + (gptr*) &sync_binlog_period, (gptr*) &sync_binlog_period, 0, GET_ULONG, + REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0}, + {"sync-frm", OPT_SYNC_FRM, "Sync .frm to disk on create. Enabled by default.", + (gptr*) &opt_sync_frm, (gptr*) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0, + 0, 0, 0, 0}, #ifdef DOES_NOTHING_YET {"sync-replication", OPT_SYNC_REPLICATION, - "Enable synchronous replication", + "Enable synchronous replication.", (gptr*) &global_system_variables.sync_replication, (gptr*) &global_system_variables.sync_replication, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 1, 0}, {"sync-replication-slave-id", OPT_SYNC_REPLICATION_SLAVE_ID, - "Synchronous replication is wished for this slave", + "Synchronous replication is wished for this slave.", (gptr*) &global_system_variables.sync_replication_slave_id, (gptr*) &global_system_variables.sync_replication_slave_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0}, {"sync-replication-timeout", OPT_SYNC_REPLICATION_TIMEOUT, - "Synchronous replication timeout", + "Synchronous replication timeout.", (gptr*) &global_system_variables.sync_replication_timeout, (gptr*) &global_system_variables.sync_replication_timeout, 0, GET_ULONG, REQUIRED_ARG, 10, 0, ~0L, 0, 1, 0}, #endif - {"sync-frm", OPT_SYNC_FRM, "Sync .frm to disk on create. Enabled by default", - (gptr*) &opt_sync_frm, (gptr*) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0, - 0, 0, 0, 0}, {"table_cache", OPT_TABLE_CACHE, "The number of open tables for all threads.", (gptr*) &table_cache_size, (gptr*) &table_cache_size, 0, GET_ULONG, REQUIRED_ARG, 64, 1, 512*1024L, @@ -5957,11 +5970,7 @@ static void mysql_init_variables(void) #else have_innodb=SHOW_OPTION_NO; #endif -#ifdef HAVE_ISAM - have_isam=SHOW_OPTION_YES; -#else have_isam=SHOW_OPTION_NO; -#endif #ifdef HAVE_EXAMPLE_DB have_example_db= SHOW_OPTION_YES; #else @@ -6111,16 +6120,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), sf_malloc_mem_limit = atoi(argument); #endif break; -#ifdef EMBEDDED_LIBRARY - case OPT_MAX_ALLOWED_PACKET: - max_allowed_packet= atoi(argument); - global_system_variables.max_allowed_packet= max_allowed_packet; - break; - case OPT_NET_BUFFER_LENGTH: - net_buffer_length= atoi(argument); - global_system_variables.net_buffer_length= net_buffer_length; - break; -#endif #include case 'V': print_version(); @@ -6351,9 +6350,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt_error_log= 0; // Force logs to stdout break; case (int) OPT_FLUSH: -#ifdef HAVE_ISAM - nisam_flush=1; -#endif myisam_flush=1; flush_time=0; // No auto flush break; @@ -6367,9 +6363,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case OPT_STORAGE_ENGINE: { if ((enum db_type)((global_system_variables.table_type= - ha_resolve_by_name(argument, strlen(argument)))) == DB_TYPE_UNKNOWN) + ha_resolve_by_name(argument, strlen(argument)))) == + DB_TYPE_UNKNOWN) { - fprintf(stderr,"Unknown table type: %s\n",argument); + fprintf(stderr,"Unknown/unsupported table type: %s\n",argument); exit(1); } break; @@ -6458,14 +6455,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), have_berkeley_db= SHOW_OPTION_YES; else have_berkeley_db= SHOW_OPTION_DISABLED; -#endif - break; - case OPT_ISAM: -#ifdef HAVE_ISAM - if (opt_isam) - have_isam= SHOW_OPTION_YES; - else - have_isam= SHOW_OPTION_DISABLED; #endif break; case OPT_NDBCLUSTER: @@ -6518,9 +6507,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case OPT_INNODB_LOG_ARCHIVE: innobase_log_archive= argument ? test(atoi(argument)) : 1; break; - case OPT_INNODB_FAST_SHUTDOWN: - innobase_fast_shutdown= argument ? test(atoi(argument)) : 1; - break; #endif /* HAVE_INNOBASE_DB */ case OPT_MYISAM_RECOVER: { @@ -6654,6 +6640,22 @@ static void get_options(int argc,char **argv) sql_print_warning("this binary does not contain BDB storage engine"); #endif + /* + Check that the default storage engine is actually available. + */ + if (!ha_storage_engine_is_enabled((enum db_type) + global_system_variables.table_type)) + { + if (!opt_bootstrap) + { + sql_print_error("Default storage engine (%s) is not available", + ha_get_storage_engine((enum db_type) + global_system_variables.table_type)); + exit(1); + } + global_system_variables.table_type= DB_TYPE_MYISAM; + } + if (argc > 0) { fprintf(stderr, "%s: Too many arguments (first extra is '%s').\nUse --help to get a list of available options\n", my_progname, *argv); @@ -6689,6 +6691,9 @@ static void get_options(int argc,char **argv) #ifndef EMBEDDED_LIBRARY if (mysqld_chroot) set_root(mysqld_chroot); +#else + max_allowed_packet= global_system_variables.max_allowed_packet; + net_buffer_length= global_system_variables.net_buffer_length; #endif fix_paths(); diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 44e2f5ee9f2..2ced24f87bb 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -42,7 +42,6 @@ #include "mysql_priv.h" #include -#include #include "sql_select.h" #ifndef EXTRA_DEBUG @@ -51,7 +50,7 @@ #endif /* - Convert double value to #rows. Currently this does floor(), and we + Convert double value to #rows. Currently this does floor(), and we might consider using round() instead. */ #define double2rows(x) ((ha_rows)(x)) @@ -4372,6 +4371,7 @@ key_or(SEL_ARG *key1,SEL_ARG *key2) last=last->next; key1=key1->tree_delete(save); } + last->copy_min(tmp); if (last->copy_min(key2) || last->copy_max(key2)) { // Full range key1->free_tree(); diff --git a/sql/protocol.cc b/sql/protocol.cc index 71908d2a958..dc9ab7bf795 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -645,16 +645,6 @@ err: } -bool Protocol::send_records_num(List *list, ulonglong records) -{ - char *pos; - char buff[20]; - pos=net_store_length(buff, (uint) list->elements); - pos=net_store_length(pos, records); - return my_net_write(&thd->net, buff,(uint) (pos-buff)); -} - - bool Protocol::write() { DBUG_ENTER("Protocol::write"); diff --git a/sql/protocol.h b/sql/protocol.h index ad2593d3ab7..de379db541b 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -54,7 +54,6 @@ public: enum { SEND_NUM_ROWS= 1, SEND_DEFAULTS= 2, SEND_EOF= 4 }; virtual bool send_fields(List *list, uint flags); - bool send_records_num(List *list, ulonglong records); bool store(I_List *str_list); bool store(const char *from, CHARSET_INFO *cs); String *storage_packet() { return packet; } diff --git a/sql/records.cc b/sql/records.cc index 00da1ac1adc..9b05dc3e291 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -89,7 +89,8 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table, (ulonglong) MIN_FILE_LENGTH_TO_USE_ROW_CACHE && info->io_cache->end_of_file/info->ref_length * table->s->reclength > (my_off_t) MIN_ROWS_TO_USE_TABLE_CACHE && - !table->s->blob_fields) + !table->s->blob_fields && + info->ref_length <= MAX_REFLENGTH) { if (! init_rr_cache(thd, info)) { @@ -128,6 +129,13 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table, VOID(table->file->extra_opt(HA_EXTRA_CACHE, thd->variables.read_buff_size)); } + /* Condition pushdown to storage engine */ + if (thd->variables.engine_condition_pushdown && + select && select->cond && + (select->cond->used_tables() & table->map) && + !table->file->pushed_cond) + table->file->cond_push(select->cond); + DBUG_VOID_RETURN; } /* init_read_record */ @@ -341,7 +349,8 @@ static int init_rr_cache(THD *thd, READ_RECORD *info) MYF(0)))) DBUG_RETURN(1); #ifdef HAVE_purify - bzero(info->cache,rec_cache_size); // Avoid warnings in qsort + // Avoid warnings in qsort + bzero(info->cache,rec_cache_size+info->cache_records* info->struct_length+1); #endif DBUG_PRINT("info",("Allocated buffert for %d records",info->cache_records)); info->read_positions=info->cache+rec_cache_size; diff --git a/sql/set_var.cc b/sql/set_var.cc index 457df3f2947..70d64b5dac6 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -386,6 +386,8 @@ sys_var_thd_ulong sys_net_wait_timeout("wait_timeout", &SV::net_wait_timeout); #ifdef HAVE_INNOBASE_DB +sys_var_long_ptr sys_innodb_fast_shutdown("innodb_fast_shutdown", + &innobase_fast_shutdown); sys_var_long_ptr sys_innodb_max_dirty_pages_pct("innodb_max_dirty_pages_pct", &srv_max_buf_pool_modified_pct); sys_var_long_ptr sys_innodb_max_purge_lag("innodb_max_purge_lag", @@ -689,6 +691,7 @@ sys_var *sys_variables[]= &sys_tx_isolation, &sys_os, #ifdef HAVE_INNOBASE_DB + &sys_innodb_fast_shutdown, &sys_innodb_max_dirty_pages_pct, &sys_innodb_max_purge_lag, &sys_innodb_table_locks, @@ -795,7 +798,7 @@ struct show_var_st init_vars[]= { {"innodb_data_file_path", (char*) &innobase_data_file_path, SHOW_CHAR_PTR}, {"innodb_data_home_dir", (char*) &innobase_data_home_dir, SHOW_CHAR_PTR}, {"innodb_doublewrite", (char*) &innobase_use_doublewrite, SHOW_MY_BOOL}, - {"innodb_fast_shutdown", (char*) &innobase_fast_shutdown, SHOW_MY_BOOL}, + {sys_innodb_fast_shutdown.name,(char*) &sys_innodb_fast_shutdown, SHOW_SYS}, {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG }, {"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL}, {"innodb_flush_log_at_trx_commit", (char*) &innobase_flush_log_at_trx_commit, SHOW_INT}, @@ -954,9 +957,11 @@ struct show_var_st init_vars[]= { {"sql_warnings", (char*) &sys_sql_warnings, SHOW_BOOL}, #ifdef HAVE_REPLICATION {sys_sync_binlog_period.name,(char*) &sys_sync_binlog_period, SHOW_SYS}, +#ifdef DOES_NOTHING_YET {sys_sync_replication.name, (char*) &sys_sync_replication, SHOW_SYS}, {sys_sync_replication_slave_id.name, (char*) &sys_sync_replication_slave_id,SHOW_SYS}, {sys_sync_replication_timeout.name, (char*) &sys_sync_replication_timeout,SHOW_SYS}, +#endif #endif {sys_sync_frm.name, (char*) &sys_sync_frm, SHOW_SYS}, #ifdef HAVE_TZNAME @@ -2495,14 +2500,6 @@ bool sys_var_sync_binlog_period::update(THD *thd, set_var *var) { pthread_mutex_t *lock_log= mysql_bin_log.get_log_lock(); sync_binlog_period= (ulong) var->save_result.ulonglong_value; - /* - Must reset the counter otherwise it may already be beyond the new period - and so the new period will not be taken into account. Need mutex otherwise - might be cancelled by a simultanate ++ in MYSQL_LOG::write(). - */ - pthread_mutex_lock(lock_log); - sync_binlog_counter= 0; - pthread_mutex_unlock(lock_log); return 0; } #endif /* HAVE_REPLICATION */ @@ -2522,7 +2519,7 @@ bool sys_var_rand_seed2::update(THD *thd, set_var *var) bool sys_var_thd_time_zone::check(THD *thd, set_var *var) { - char buff[MAX_TIME_ZONE_NAME_LENGTH]; + char buff[MAX_TIME_ZONE_NAME_LENGTH]; String str(buff, sizeof(buff), &my_charset_latin1); String *res= var->value->val_str(&str); @@ -3128,8 +3125,8 @@ bool sys_var_thd_storage_engine::check(THD *thd, set_var *var) enum db_type db_type; if (!(res=var->value->val_str(&str)) || !(var->save_result.ulong_value= - (ulong) (db_type= ha_resolve_by_name(res->ptr(), res->length()))) || - ha_checktype(db_type) != db_type) + (ulong) (db_type= ha_resolve_by_name(res->ptr(), res->length()))) || + ha_checktype(db_type) != db_type) { value= res ? res->c_ptr() : "NULL"; goto err; diff --git a/sql/share/Makefile.am b/sql/share/Makefile.am index 608bbdb7ae6..0558fddcbb2 100644 --- a/sql/share/Makefile.am +++ b/sql/share/Makefile.am @@ -11,7 +11,7 @@ dist-hook: $(INSTALL_DATA) $(srcdir)/charsets/README $(distdir)/charsets $(INSTALL_DATA) $(srcdir)/charsets/Index.xml $(distdir)/charsets -all: english/errmsg.sys +all-local: english/errmsg.sys # Use the english errmsg.sys as a flag that all errmsg.sys needs to be # created. Normally these are created by extra/Makefile diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 71e4640e88b..e93229a4a3e 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -1214,30 +1214,30 @@ ER_TABLE_EXISTS_ERROR 42S01 swe "Tabellen '%-.64s' finns redan" ukr "ôÁÂÌÉÃÑ '%-.64s' ×ÖÅ ¦ÓÎÕ¤" ER_BAD_TABLE_ERROR 42S02 - cze "Nezn-Bámá tabulka '%-.64s'" - dan "Ukendt tabel '%-.64s'" - nla "Onbekende tabel '%-.64s'" - eng "Unknown table '%-.64s'" - jps "table '%-.64s' ‚Í‚ ‚è‚Ü‚¹‚ñ.", - est "Tundmatu tabel '%-.64s'" - fre "Table '%-.64s' inconnue" - ger "Unbekannte Tabelle '%-.64s'" - greek "Áãíùóôïò ðßíáêáò '%-.64s'" - hun "Ervenytelen tabla: '%-.64s'" - ita "Tabella '%-.64s' sconosciuta" - jpn "table '%-.64s' ¤Ï¤¢¤ê¤Þ¤»¤ó." - kor "Å×À̺í '%-.64s'´Â ¾Ë¼ö ¾øÀ½" - nor "Ukjent tabell '%-.64s'" - norwegian-ny "Ukjent tabell '%-.64s'" - pol "Nieznana tabela '%-.64s'" - por "Tabela '%-.64s' desconhecida" - rum "Tabela '%-.64s' este invalida" - rus "îÅÉÚ×ÅÓÔÎÁÑ ÔÁÂÌÉÃÁ '%-.64s'" - serbian "Nepoznata tabela '%-.64s'" - slo "Neznáma tabuµka '%-.64s'" - spa "Tabla '%-.64s' desconocida" - swe "Okänd tabell '%-.64s'" - ukr "îÅצÄÏÍÁ ÔÁÂÌÉÃÑ '%-.64s'" + cze "Nezn-Bámá tabulka '%-.100s'" + dan "Ukendt tabel '%-.100s'" + nla "Onbekende tabel '%-.100s'" + eng "Unknown table '%-.100s'" + jps "table '%-.100s' ‚Í‚ ‚è‚Ü‚¹‚ñ.", + est "Tundmatu tabel '%-.100s'" + fre "Table '%-.100s' inconnue" + ger "Unbekannte Tabelle '%-.100s'" + greek "Áãíùóôïò ðßíáêáò '%-.100s'" + hun "Ervenytelen tabla: '%-.100s'" + ita "Tabella '%-.100s' sconosciuta" + jpn "table '%-.100s' ¤Ï¤¢¤ê¤Þ¤»¤ó." + kor "Å×À̺í '%-.100s'´Â ¾Ë¼ö ¾øÀ½" + nor "Ukjent tabell '%-.100s'" + norwegian-ny "Ukjent tabell '%-.100s'" + pol "Nieznana tabela '%-.100s'" + por "Tabela '%-.100s' desconhecida" + rum "Tabela '%-.100s' este invalida" + rus "îÅÉÚ×ÅÓÔÎÁÑ ÔÁÂÌÉÃÁ '%-.100s'" + serbian "Nepoznata tabela '%-.100s'" + slo "Neznáma tabuµka '%-.100s'" + spa "Tabla '%-.100s' desconocida" + swe "Okänd tabell '%-.100s'" + ukr "îÅצÄÏÍÁ ÔÁÂÌÉÃÑ '%-.100s'" ER_NON_UNIQ_ERROR 23000 cze "Sloupec '%-.64s' v %s nen-Bí zcela jasný" dan "Felt: '%-.64s' i tabel %s er ikke entydigt" @@ -5336,3 +5336,9 @@ ER_CANT_CREATE_USER_WITH_GRANT 42000 eng "You are not allowed to create a user with GRANT" ER_WRONG_VALUE_FOR_TYPE eng "Incorrect %-.32s value: '%-.128s' for function %-.32s" +ER_TABLE_DEF_CHANGED + eng "Table definition has changed, please retry transaction" +ER_SP_DUP_HANDLER 42000 + eng "Duplicate handler declared in the same block" +ER_SP_NOT_VAR_ARG 42000 + eng "OUT or INOUT argument %d for routine %s is not a variable" diff --git a/sql/sp.cc b/sql/sp.cc index 84169ab8172..1956f32f2c6 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -64,34 +64,18 @@ db_find_routine_aux(THD *thd, int type, sp_name *name, enum thr_lock_type ltype, TABLE **tablep, bool *opened) { TABLE *table; - byte key[64+64+1]; // db, name, type - uint keylen; + byte key[NAME_LEN*2+4+1]; // db, name, optional key length type DBUG_ENTER("db_find_routine_aux"); DBUG_PRINT("enter", ("type: %d name: %*s", type, name->m_name.length, name->m_name.str)); /* - Speed up things if mysql.proc doesn't exists - mysql_proc_table_exists is set when on creates a stored procedure - or on flush privileges + Speed up things if mysql.proc doesn't exists. mysql_proc_table_exists + is set when we create or read stored procedure or on flush privileges. */ if (!mysql_proc_table_exists && ltype == TL_READ) DBUG_RETURN(SP_OPEN_TABLE_FAILED); - // Put the key used to read the row together - keylen= name->m_db.length; - if (keylen > 64) - keylen= 64; - memcpy(key, name->m_db.str, keylen); - memset(key+keylen, (int)' ', 64-keylen); // Pad with space - keylen= name->m_name.length; - if (keylen > 64) - keylen= 64; - memcpy(key+64, name->m_name.str, keylen); - memset(key+64+keylen, (int)' ', 64-keylen); // Pad with space - key[128]= type; - keylen= sizeof(key); - if (thd->lex->proc_table) table= thd->lex->proc_table->table; else @@ -113,15 +97,35 @@ db_find_routine_aux(THD *thd, int type, sp_name *name, if (! (table= open_ltable(thd, &tables, ltype))) { *tablep= NULL; - mysql_proc_table_exists= 0; + /* + Under explicit LOCK TABLES or in prelocked mode we should not + say that mysql.proc table does not exist if we are unable to + open it since this condition may be transient. + */ + if (!(thd->locked_tables || thd->prelocked_mode)) + mysql_proc_table_exists= 0; DBUG_RETURN(SP_OPEN_TABLE_FAILED); } *opened= TRUE; } mysql_proc_table_exists= 1; + /* + Create key to find row. We have to use field->store() to be able to + handle VARCHAR and CHAR fields. + Assumption here is that the three first fields in the table are + 'db', 'name' and 'type' and the first key is the primary key over the + same fields. + */ + table->field[0]->store(name->m_db.str, name->m_db.length, &my_charset_bin); + table->field[1]->store(name->m_name.str, name->m_name.length, + &my_charset_bin); + table->field[2]->store((longlong) type); + key_copy(key, table->record[0], table->key_info, + table->key_info->key_length); + if (table->file->index_read_idx(table->record[0], 0, - key, keylen, + key, table->key_info->key_length, HA_READ_KEY_EXACT)) { *tablep= NULL; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 89c4b2dbaac..0fe9c449540 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -561,7 +561,10 @@ sp_head::execute(THD *thd) // Check if an exception has occurred and a handler has been found // Note: We havo to check even if ret==0, since warnings (and some // errors don't return a non-zero value. - if (!thd->killed && ctx) + // We also have to check even if thd->killed != 0, since some + // errors return with this even when a handler has been found + // (e.g. "bad data"). + if (ctx) { uint hf; @@ -579,6 +582,7 @@ sp_head::execute(THD *thd) ctx->clear_handler(); ctx->in_handler= TRUE; thd->clear_error(); + thd->killed= THD::NOT_KILLED; continue; } } @@ -634,7 +638,7 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp) // Need to use my_printf_error here, or it will not terminate the // invoking query properly. my_error(ER_SP_WRONG_NO_OF_ARGS, MYF(0), - "FUNCTION", m_name.str, params, argcount); + "FUNCTION", m_qname.str, params, argcount); DBUG_RETURN(-1); } @@ -687,6 +691,19 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp) DBUG_RETURN(ret); } +static Item_func_get_user_var * +item_is_user_var(Item *it) +{ + if (it->type() == Item::FUNC_ITEM) + { + Item_func *fi= static_cast(it); + + if (fi->functype() == Item_func::GUSERVAR_FUNC) + return static_cast(fi); + } + return NULL; +} + int sp_head::execute_procedure(THD *thd, List *args) { @@ -704,7 +721,7 @@ sp_head::execute_procedure(THD *thd, List *args) if (args->elements != params) { my_error(ER_SP_WRONG_NO_OF_ARGS, MYF(0), "PROCEDURE", - m_name.str, params, args->elements); + m_qname.str, params, args->elements); DBUG_RETURN(-1); } @@ -724,12 +741,19 @@ sp_head::execute_procedure(THD *thd, List *args) // QQ: Should do type checking? for (i = 0 ; (it= li++) && i < params ; i++) { - sp_pvar_t *pvar = m_pcont->find_pvar(i); + sp_pvar_t *pvar= m_pcont->find_pvar(i); - if (! pvar) - nctx->set_oindex(i, -1); // Shouldn't happen - else + if (pvar) { + if (pvar->mode != sp_param_in) + { + if (!it->is_splocal() && !item_is_user_var(it)) + { + my_error(ER_SP_NOT_VAR_ARG, MYF(0), i+1, m_qname.str); + ret= -1; + break; + } + } if (pvar->mode == sp_param_out) { if (! nit) @@ -738,7 +762,7 @@ sp_head::execute_procedure(THD *thd, List *args) } else { - Item *it2= sp_eval_func_item(thd, it,pvar->type); + Item *it2= sp_eval_func_item(thd, it, pvar->type); if (it2) nctx->push_item(it2); // IN or INOUT @@ -748,13 +772,6 @@ sp_head::execute_procedure(THD *thd, List *args) break; } } - // Note: If it's OUT or INOUT, it must be a variable. - // QQ: We can check for global variables here, or should we do it - // while parsing? - if (pvar->mode == sp_param_in) - nctx->set_oindex(i, -1); // IN - else // OUT or INOUT - nctx->set_oindex(i, static_cast(it)->get_offset()); } } @@ -782,38 +799,31 @@ sp_head::execute_procedure(THD *thd, List *args) // set global user variables for (uint i = 0 ; (it= li++) && i < params ; i++) { - int oi = nctx->get_oindex(i); + sp_pvar_t *pvar= m_pcont->find_pvar(i); - if (oi >= 0) + if (pvar->mode != sp_param_in) { - if (! tmp_octx) - octx->set_item(nctx->get_oindex(i), nctx->get_item(i)); + if (it->is_splocal()) + octx->set_item(static_cast(it)->get_offset(), + nctx->get_item(i)); else { - // QQ Currently we just silently ignore non-user-variable arguments. - // We should check this during parsing, when setting up the call - // above - if (it->type() == Item::FUNC_ITEM) + Item_func_get_user_var *guv= item_is_user_var(it); + + if (guv) { - Item_func *fi= static_cast(it); + Item *item= nctx->get_item(i); + Item_func_set_user_var *suv; - if (fi->functype() == Item_func::GUSERVAR_FUNC) - { // A global user variable - Item *item= nctx->get_item(i); - Item_func_set_user_var *suv; - Item_func_get_user_var *guv= - static_cast(fi); - - suv= new Item_func_set_user_var(guv->get_name(), item); - /* - we do not check suv->fixed, because it can't be fixed after - creation - */ - suv->fix_fields(thd, NULL, &item); - suv->fix_length_and_dec(); - suv->check(); - suv->update(); - } + suv= new Item_func_set_user_var(guv->get_name(), item); + /* + we do not check suv->fixed, because it can't be fixed after + creation + */ + suv->fix_fields(thd, NULL, &item); + suv->fix_length_and_dec(); + suv->check(); + suv->update(); } } } diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc index 15d3f87ff29..26f576233f3 100644 --- a/sql/sp_pcontext.cc +++ b/sql/sp_pcontext.cc @@ -57,6 +57,7 @@ sp_pcontext::sp_pcontext(sp_pcontext *prev) VOID(my_init_dynamic_array(&m_pvar, sizeof(sp_pvar_t *), 16, 8)); VOID(my_init_dynamic_array(&m_cond, sizeof(sp_cond_type_t *), 16, 8)); VOID(my_init_dynamic_array(&m_cursor, sizeof(LEX_STRING), 16, 8)); + VOID(my_init_dynamic_array(&m_handler, sizeof(sp_cond_type_t *), 16, 8)); m_label.empty(); m_children.empty(); if (!prev) @@ -82,6 +83,7 @@ sp_pcontext::destroy() delete_dynamic(&m_pvar); delete_dynamic(&m_cond); delete_dynamic(&m_cursor); + delete_dynamic(&m_handler); } sp_pcontext * @@ -258,6 +260,41 @@ sp_pcontext::find_cond(LEX_STRING *name, my_bool scoped) return NULL; } +/* + * This only searches the current context, for error checking of + * duplicates. + * Returns TRUE if found. + */ +bool +sp_pcontext::find_handler(sp_cond_type_t *cond) +{ + uint i= m_handler.elements; + + while (i--) + { + sp_cond_type_t *p; + + get_dynamic(&m_handler, (gptr)&p, i); + if (cond->type == p->type) + { + switch (p->type) + { + case sp_cond_type_t::number: + if (cond->mysqlerr == p->mysqlerr) + return TRUE; + break; + case sp_cond_type_t::state: + if (strcmp(cond->sqlstate, p->sqlstate) == 0) + return TRUE; + break; + default: + return TRUE; + } + } + } + return FALSE; +} + void sp_pcontext::push_cursor(LEX_STRING *name) { diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h index 42d8140b78c..749b99dcf14 100644 --- a/sql/sp_pcontext.h +++ b/sql/sp_pcontext.h @@ -236,11 +236,14 @@ class sp_pcontext : public Sql_alloc // inline void - add_handler() + push_handler(sp_cond_type_t *cond) { - m_handlers+= 1; + insert_dynamic(&m_handler, (gptr)&cond); } + bool + find_handler(sp_cond_type *cond); + inline uint max_handlers() { @@ -248,7 +251,7 @@ class sp_pcontext : public Sql_alloc } inline void - push_handlers(uint n) + add_handlers(uint n) { m_handlers+= n; } @@ -293,6 +296,7 @@ private: DYNAMIC_ARRAY m_pvar; // Parameters/variables DYNAMIC_ARRAY m_cond; // Conditions DYNAMIC_ARRAY m_cursor; // Cursors + DYNAMIC_ARRAY m_handler; // Handlers, for checking of duplicates List m_label; // The label list diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index 9b29c173856..def38009eee 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -34,7 +34,6 @@ sp_rcontext::sp_rcontext(uint fsize, uint hmax, uint cmax) { in_handler= FALSE; m_frame= (Item **)sql_alloc(fsize * sizeof(Item*)); - m_outs= (int *)sql_alloc(fsize * sizeof(int)); m_handler= (sp_handler_t *)sql_alloc(hmax * sizeof(sp_handler_t)); m_hstack= (uint *)sql_alloc(hmax * sizeof(uint)); m_cstack= (sp_cursor **)sql_alloc(cmax * sizeof(sp_cursor *)); @@ -80,24 +79,24 @@ sp_rcontext::find_handler(uint sql_errno, break; case sp_cond_type_t::state: if (strcmp(sqlstate, cond->sqlstate) == 0 && - (found < 0 || m_handler[found].cond->type > sp_cond_type_t::number)) + (found < 0 || m_handler[found].cond->type > sp_cond_type_t::state)) found= i; break; case sp_cond_type_t::warning: if ((sqlstate[0] == '0' && sqlstate[1] == '1' || level == MYSQL_ERROR::WARN_LEVEL_WARN) && - (found < 0 || m_handler[found].cond->type > sp_cond_type_t::state)) + found < 0) found= i; break; case sp_cond_type_t::notfound: if (sqlstate[0] == '0' && sqlstate[1] == '2' && - (found < 0 || m_handler[found].cond->type > sp_cond_type_t::state)) + found < 0) found= i; break; case sp_cond_type_t::exception: - if ((sqlstate[0] != '0' || sqlstate[1] > '2' || - level == MYSQL_ERROR::WARN_LEVEL_ERROR) && - (found < 0 || m_handler[found].cond->type > sp_cond_type_t::state)) + if ((sqlstate[0] != '0' || sqlstate[1] > '2') && + level == MYSQL_ERROR::WARN_LEVEL_ERROR && + found < 0) found= i; break; } diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h index 37d718048a0..afcd937a369 100644 --- a/sql/sp_rcontext.h +++ b/sql/sp_rcontext.h @@ -82,18 +82,6 @@ class sp_rcontext : public Sql_alloc return m_frame[idx]; } - inline void - set_oindex(uint idx, int oidx) - { - m_outs[idx] = oidx; - } - - inline int - get_oindex(uint idx) - { - return m_outs[idx]; - } - inline void set_result(Item *it) { @@ -187,7 +175,6 @@ private: uint m_count; uint m_fsize; Item **m_frame; - int *m_outs; Item *m_result; // For FUNCTIONs diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 4750fe1386f..d79811aa4e2 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -25,7 +25,6 @@ #include #include #include -#include #ifdef __WIN__ #include #endif @@ -680,45 +679,41 @@ TABLE_LIST *find_table_in_list(TABLE_LIST *table, const char *db_name, const char *table_name) { - if (lower_case_table_names) + for (; table; table= *(TABLE_LIST **) ((char*) table + offset)) { - for (; table; table= *(TABLE_LIST **) ((char*) table + offset)) - { - if ((table->table == 0 || table->table->s->tmp_table == NO_TMP_TABLE) && - ((!strcmp(table->db, db_name) && - !strcmp(table->table_name, table_name)) || - (table->view && - !my_strcasecmp(table_alias_charset, - table->db, db_name) && - !my_strcasecmp(table_alias_charset, - table->table->alias, table_name)))) - break; - } - } - else - { - for (; table; table= *(TABLE_LIST **) ((char*) table + offset)) - { - if ((table->table == 0 || table->table->s->tmp_table == NO_TMP_TABLE) && - ((!strcmp(table->db, db_name) && - !strcmp(table->table_name, table_name)) || - (table->view && - !strcmp(table->table->s->db, db_name) && - !strcmp(table->table->alias, table_name)))) - break; - } + if ((table->table == 0 || table->table->s->tmp_table == NO_TMP_TABLE) && + strcmp(table->db, db_name) == 0 && + strcmp(table->table_name, table_name) == 0) + break; } return table; } /* - Test that table is unique + Test that table is unique (It's only exists once in the table list) SYNOPSIS unique_table() - table table which should be chaked - table_list list of tables + table table which should be checked + table_list list of tables + + NOTE: to exclude derived tables from check we use following mechanism: + a) during derived table processing set THD::derived_tables_processing + b) JOIN::prepare set SELECT::exclude_from_table_unique_test if + THD::derived_tables_processing set. (we can't use JOIN::execute + because for PS we perform only JOIN::prepare, but we can't set this + flag in JOIN::prepare if we are not sure that we are in derived table + processing loop, because multi-update call fix_fields() for some its + items (which mean JOIN::prepare for subqueries) before unique_table + call to detect which tables should be locked for write). + c) unique_table skip all tables which belong to SELECT with + SELECT::exclude_from_table_unique_test set. + Also SELECT::exclude_from_table_unique_test used to exclude from check + tables of main SELECT of multi-delete and multi-update + + TODO: when we will have table/view change detection we can do this check + only once for PS/SP RETURN found duplicate @@ -728,41 +723,50 @@ TABLE_LIST *find_table_in_list(TABLE_LIST *table, TABLE_LIST* unique_table(TABLE_LIST *table, TABLE_LIST *table_list) { TABLE_LIST *res; - const char *d_name= table->db, *t_name= table->table_name; - char d_name_buff[MAX_ALIAS_NAME], t_name_buff[MAX_ALIAS_NAME]; + const char *d_name, *t_name; DBUG_ENTER("unique_table"); DBUG_PRINT("enter", ("table alias: %s", table->alias)); - /* temporary table is always unique */ - if (table->table && table->table->s->tmp_table != NO_TMP_TABLE) - DBUG_RETURN(0); - if (table->view) + + /* + If this function called for query which update table (INSERT/UPDATE/...) + then we have in table->table pointer to TABLE object which we are + updating even if it is VIEW so we need TABLE_LIST of this TABLE object + to get right names (even if lower_case_table_names used). + + If this function called for CREATE command that we have not opened table + (table->table equal to 0) and right names is in current TABLE_LIST + object. + */ + if (table->table) { - /* it is view and table opened */ - if (lower_case_table_names) - { - strmov(t_name_buff, table->table->alias); - my_casedn_str(files_charset_info, t_name_buff); - t_name= t_name_buff; - strmov(d_name_buff, table->table->s->db); - my_casedn_str(files_charset_info, d_name_buff); - d_name= d_name_buff; - } - else - { - d_name= table->table->s->db; - t_name= table->table->alias; - } + /* temporary table is always unique */ + if (table->table && table->table->s->tmp_table != NO_TMP_TABLE) + DBUG_RETURN(0); + table= table->find_underlying_table(table->table); + /* + as far as we have table->table we have to find real TABLE_LIST of + it in underlying tables + */ + DBUG_ASSERT(table); } + d_name= table->db; + t_name= table->table_name; DBUG_PRINT("info", ("real table: %s.%s", d_name, t_name)); for(;;) { if (!(res= find_table_in_global_list(table_list, d_name, t_name)) || - !res->table || res->table != table->table) + (!res->table || res->table != table->table) && + (res->select_lex && !res->select_lex->exclude_from_table_unique_test)) break; - /* if we found entry of this table try again. */ + /* + If we found entry of this table or or table of SELECT which already + processed in derived table or top select of multi-update/multi-delete + (exclude_from_table_unique_test). + */ table_list= res->next_global; - DBUG_PRINT("info", ("found same copy of table")); + DBUG_PRINT("info", + ("found same copy of table or table which we should skip")); } DBUG_RETURN(res); } @@ -3584,7 +3588,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, COND **conds) thd->set_query_id=1; - thd->lex->current_select->no_wrap_view_item= 1; + thd->lex->current_select->no_wrap_view_item= 0; select_lex->cond_count= 0; if (*conds) { diff --git a/sql/sql_class.cc b/sql/sql_class.cc index cf7240e4dba..a6a1f4d60ef 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -161,7 +161,8 @@ THD::THD() :user_time(0), global_read_lock(0), is_fatal_error(0), rand_used(0), time_zone_used(0), last_insert_id_used(0), insert_id_used(0), clear_next_insert_id(0), - in_lock_tables(0), bootstrap(0), spcont(NULL) + in_lock_tables(0), bootstrap(0), derived_tables_processing(FALSE), + spcont(NULL) { current_arena= this; #ifndef DBUG_OFF @@ -201,10 +202,11 @@ THD::THD() #ifndef DBUG_OFF dbug_sentry=THD_SENTRY_MAGIC; #endif -#ifndef EMBEDDED_LIBRARY +#ifndef EMBEDDED_LIBRARY net.vio=0; #endif - net.last_error[0]=0; // If error on boot + net.last_error[0]=0; // If error on boot + net.query_cache_query=0; // If error on boot ull=0; system_thread= cleanup_done= abort_on_warning= no_warnings_for_error= 0; peer_port= 0; // For SHOW PROCESSLIST @@ -213,7 +215,7 @@ THD::THD() #endif #ifdef SIGNAL_WITH_VIO_CLOSE active_vio = 0; -#endif +#endif pthread_mutex_init(&LOCK_delete, MY_MUTEX_INIT_FAST); /* Variables with default values */ @@ -342,7 +344,10 @@ void THD::change_user(void) void THD::cleanup(void) { DBUG_ENTER("THD::cleanup"); - ha_rollback(this); +#ifdef ENABLE_WHEN_BINLOG_WILL_BE_ABLE_TO_PREPARE + if (transaction.xa_state != XA_PREPARED) +#endif + ha_rollback(this); if (locked_tables) { lock=locked_tables; locked_tables=0; @@ -384,17 +389,17 @@ THD::~THD() add_to_status(&global_status_var, &status_var); /* Close connection */ -#ifndef EMBEDDED_LIBRARY +#ifndef EMBEDDED_LIBRARY if (net.vio) { vio_delete(net.vio); - net_end(&net); + net_end(&net); } #endif if (!cleanup_done) cleanup(); - ha_close_connection(this); + ha_close_connection(this); sp_cache_clear(&sp_proc_cache); sp_cache_clear(&sp_func_cache); diff --git a/sql/sql_class.h b/sql/sql_class.h index c32c79e8108..a97f2566a3e 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -327,6 +327,7 @@ public: bool is_active(const char* log_file_name); int update_log_index(LOG_INFO* linfo, bool need_update_threads); void rotate_and_purge(uint flags); + bool flush_and_sync(); int purge_logs(const char *to_log, bool included, bool need_mutex, bool need_update_threads, ulonglong *decrease_log_space); @@ -483,27 +484,6 @@ public: }; -class MYSQL_ERROR: public Sql_alloc -{ -public: - enum enum_warning_level - { WARN_LEVEL_NOTE, WARN_LEVEL_WARN, WARN_LEVEL_ERROR, WARN_LEVEL_END}; - - uint code; - enum_warning_level level; - char *msg; - - MYSQL_ERROR(THD *thd, uint code_arg, enum_warning_level level_arg, - const char *msg_arg) - :code(code_arg), level(level_arg) - { - if (msg_arg) - set_msg(thd, msg_arg); - } - void set_msg(THD *thd, const char *msg_arg); -}; - - class delayed_insert; class select_result; @@ -1208,6 +1188,8 @@ public: bool no_trans_update, abort_on_warning; bool got_warning; /* Set on call to push_warning() */ bool no_warnings_for_error; /* no warnings on call to my_error() */ + /* set during loop of derived table processing */ + bool derived_tables_processing; longlong row_count_func; /* For the ROW_COUNT() function */ sp_rcontext *spcont; // SP runtime context sp_cache *sp_proc_cache; @@ -1284,18 +1266,18 @@ public: pthread_mutex_unlock(&LOCK_delete); } void close_active_vio(); -#endif +#endif void awake(THD::killed_state state_to_set); /* For enter_cond() / exit_cond() to work the mutex must be got before - enter_cond() (in 4.1 an assertion will soon ensure this); this mutex is - then released by exit_cond(). Use must be: - lock mutex; enter_cond(); your code; exit_cond(). + enter_cond(); this mutex is then released by exit_cond(). + Usage must be: lock mutex; enter_cond(); your code; exit_cond(). */ inline const char* enter_cond(pthread_cond_t *cond, pthread_mutex_t* mutex, const char* msg) { const char* old_msg = proc_info; + safe_mutex_assert_owner(mutex); mysys_var->current_mutex = mutex; mysys_var->current_cond = cond; proc_info = msg; @@ -1430,7 +1412,8 @@ public: inline void send_kill_message() const { int err= killed_errno(); - my_message(err, ER(err), MYF(0)); + if (err) + my_message(err, ER(err), MYF(0)); } /* return TRUE if we will abort query if we make a warning now */ inline bool really_abort_on_warning() diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 1f345a28d2c..3bdd800cd2f 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -1009,6 +1009,9 @@ err: replication slave SQL thread (for that thread, setting of thd->db is done in ::exec_event() methods of log_event.cc). + This function does not send the error message to the client, if that + should be sent to the client, call net_send_error after this function + RETURN VALUES 0 ok 1 error diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 642564f5d7a..d524bbcf164 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -356,12 +356,28 @@ bool mysql_multi_delete_prepare(THD *thd) &lex->select_lex.leaf_tables, FALSE, FALSE)) DBUG_RETURN(TRUE); + + /* + Multi-delete can't be constructed over-union => we always have + single SELECT on top and have to check underlying SELECTs of it + */ + lex->select_lex.exclude_from_table_unique_test= TRUE; /* Fix tables-to-be-deleted-from list to point at opened tables */ for (target_tbl= (TABLE_LIST*) aux_tables; target_tbl; target_tbl= target_tbl->next_local) { - target_tbl->table= target_tbl->correspondent_table->table; + if (!(target_tbl->table= target_tbl->correspondent_table->table)) + { + DBUG_ASSERT(target_tbl->correspondent_table->view && + target_tbl->correspondent_table->ancestor && + target_tbl->correspondent_table->ancestor->next_local); + my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0), + target_tbl->correspondent_table->view_db.str, + target_tbl->correspondent_table->view_name.str); + DBUG_RETURN(TRUE); + } + if (!target_tbl->correspondent_table->updatable || check_key_in_view(thd, target_tbl->correspondent_table)) { @@ -370,23 +386,14 @@ bool mysql_multi_delete_prepare(THD *thd) DBUG_RETURN(TRUE); } /* - Check are deleted table used somewhere inside subqueries. - - Multi-delete can't be constructed over-union => we always have - single SELECT on top and have to check underlying SELECTs of it + Check that table from which we delete is not used somewhere + inside subqueries/view. */ - for (SELECT_LEX_UNIT *un= lex->select_lex.first_inner_unit(); - un; - un= un->next_unit()) + if (unique_table(target_tbl->correspondent_table, lex->query_tables)) { - if (un->first_select()->linkage != DERIVED_TABLE_TYPE && - un->check_updateable(target_tbl->correspondent_table->db, - target_tbl->correspondent_table->table_name)) - { - my_error(ER_UPDATE_TABLE_USED, MYF(0), - target_tbl->correspondent_table->table_name); - DBUG_RETURN(TRUE); - } + my_error(ER_UPDATE_TABLE_USED, MYF(0), + target_tbl->correspondent_table->table_name); + DBUG_RETURN(TRUE); } } DBUG_RETURN(FALSE); @@ -752,12 +759,15 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) if (!ha_supports_generate(table_type) || thd->lex->sphead) { /* Probably InnoDB table */ + ulong save_options= thd->options; table_list->lock_type= TL_WRITE; + thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT); ha_enable_transaction(thd, FALSE); mysql_init_select(thd->lex); error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0, HA_POS_ERROR, 0); ha_enable_transaction(thd, TRUE); + thd->options= save_options; DBUG_RETURN(error); } if (lock_and_wait_for_table_name(thd, table_list)) diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 45718e7c7da..2ae293c1bff 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -43,8 +43,10 @@ int mysql_handle_derived(LEX *lex, int (*processor)(THD*, LEX*, TABLE_LIST*)) { + int res= 0; if (lex->derived_tables) { + lex->thd->derived_tables_processing= TRUE; for (SELECT_LEX *sl= lex->all_selects_list; sl; sl= sl->next_select_in_list()) @@ -53,9 +55,8 @@ mysql_handle_derived(LEX *lex, int (*processor)(THD*, LEX*, TABLE_LIST*)) cursor; cursor= cursor->next_local) { - int res; if ((res= (*processor)(lex->thd, lex, cursor))) - return res; + goto out; } if (lex->describe) { @@ -68,7 +69,9 @@ mysql_handle_derived(LEX *lex, int (*processor)(THD*, LEX*, TABLE_LIST*)) } } } - return 0; +out: + lex->thd->derived_tables_processing= FALSE; + return res; } diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 281ac7169c0..04fd27abef5 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -116,6 +116,27 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, if (thd->query_id != thd->warn_id) mysql_reset_errors(thd, 0); thd->got_warning= 1; + + /* Abort if we are using strict mode and we are not using IGNORE */ + if ((int) level >= (int) MYSQL_ERROR::WARN_LEVEL_WARN && + thd->really_abort_on_warning()) + { + /* Avoid my_message() calling push_warning */ + bool no_warnings_for_error= thd->no_warnings_for_error; + sp_rcontext *spcont= thd->spcont; + + thd->no_warnings_for_error= 1; + thd->spcont= 0; + + thd->killed= THD::KILL_BAD_DATA; + my_message(code, msg, MYF(0)); + + thd->spcont= spcont; + thd->no_warnings_for_error= no_warnings_for_error; + /* Store error in error list (as my_message() didn't do it) */ + level= MYSQL_ERROR::WARN_LEVEL_ERROR; + } + if (thd->spcont && thd->spcont->find_handler(code, ((int) level >= @@ -126,20 +147,6 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, DBUG_RETURN(NULL); } - /* Abort if we are using strict mode and we are not using IGNORE */ - if ((int) level >= (int) MYSQL_ERROR::WARN_LEVEL_WARN && - thd->really_abort_on_warning()) - { - /* Avoid my_message() calling push_warning */ - bool no_warnings_for_error= thd->no_warnings_for_error; - thd->no_warnings_for_error= 1; - thd->killed= THD::KILL_BAD_DATA; - my_message(code, msg, MYF(0)); - thd->no_warnings_for_error= no_warnings_for_error; - /* Store error in error list (as my_message() didn't do it in this case */ - level= MYSQL_ERROR::WARN_LEVEL_ERROR; - } - if (thd->warn_list.elements < thd->variables.max_error_count) { /* diff --git a/sql/sql_error.h b/sql/sql_error.h new file mode 100644 index 00000000000..223b50be744 --- /dev/null +++ b/sql/sql_error.h @@ -0,0 +1,42 @@ +/* Copyright (C) 2000-2003 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; either 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 */ + +class MYSQL_ERROR: public Sql_alloc +{ +public: + enum enum_warning_level + { WARN_LEVEL_NOTE, WARN_LEVEL_WARN, WARN_LEVEL_ERROR, WARN_LEVEL_END}; + + uint code; + enum_warning_level level; + char *msg; + + MYSQL_ERROR(THD *thd, uint code_arg, enum_warning_level level_arg, + const char *msg_arg) + :code(code_arg), level(level_arg) + { + if (msg_arg) + set_msg(thd, msg_arg); + } + void set_msg(THD *thd, const char *msg_arg); +}; + +MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, + uint code, const char *msg); +void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level, + uint code, const char *format, ...); +void mysql_reset_errors(THD *thd, bool force); +bool mysqld_show_warnings(THD *thd, ulong levels_to_show); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 691c7c1a98b..3b65cc6b195 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -313,7 +313,8 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES))); - if (fields.elements && check_that_all_fields_are_given_values(thd, table)) + if ((fields.elements || !value_count) && + check_that_all_fields_are_given_values(thd, table)) { /* thd->net.report_error is now set, which will abort the next loop */ error= 1; @@ -885,19 +886,20 @@ err: int check_that_all_fields_are_given_values(THD *thd, TABLE *entry) { - if (!thd->abort_on_warning) // No check if not strict mode - return 0; - + int err= 0; for (Field **field=entry->field ; *field ; field++) { if ((*field)->query_id != thd->query_id && ((*field)->flags & NO_DEFAULT_VALUE_FLAG)) { - my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), (*field)->field_name); - return 1; + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_NO_DEFAULT_FOR_FIELD, + ER(ER_NO_DEFAULT_FOR_FIELD), + (*field)->field_name); + err= 1; } } - return 0; + return thd->abort_on_warning ? err : 0; } /***************************************************************************** diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 91c4dc40c01..61f710a2fe5 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1112,7 +1112,7 @@ void st_select_lex::init_query() first_execution= 1; first_cond_optimization= 1; parsing_place= NO_MATTER; - no_wrap_view_item= 0; + exclude_from_table_unique_test= no_wrap_view_item= FALSE; link_next= 0; } @@ -1493,77 +1493,6 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num) } -/* - Find db.table which will be updated in this unit - - SYNOPSIS - st_select_lex_unit::check_updateable() - db - data base name - table - real table name - - RETURN - 1 - found - 0 - OK (table did not found) -*/ - -bool st_select_lex_unit::check_updateable(char *db, char *table) -{ - for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select()) - if (sl->check_updateable(db, table)) - return 1; - return 0; -} - - -/* - Find db.table which will be updated in this select and - underlying ones (except derived tables) - - SYNOPSIS - st_select_lex::check_updateable() - db - data base name - table - real table name - - RETURN - 1 - found - 0 - OK (table did not found) -*/ - -bool st_select_lex::check_updateable(char *db, char *table) -{ - if (find_table_in_local_list(get_table_list(), db, table)) - return 1; - - return check_updateable_in_subqueries(db, table); -} - -/* - Find db.table which will be updated in underlying subqueries - - SYNOPSIS - st_select_lex::check_updateable_in_subqueries() - db - data base name - table - real table name - - RETURN - 1 - found - 0 - OK (table did not found) -*/ - -bool st_select_lex::check_updateable_in_subqueries(char *db, char *table) -{ - for (SELECT_LEX_UNIT *un= first_inner_unit(); - un; - un= un->next_unit()) - { - if (un->first_select()->linkage != DERIVED_TABLE_TYPE && - un->check_updateable(db, table)) - return 1; - } - return 0; -} - - void st_select_lex_unit::print(String *str) { for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select()) diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 2391c0b7ef9..d8c83434423 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -443,7 +443,6 @@ public: inline void unclean() { cleaned= 0; } void reinit_exec_mechanism(); - bool check_updateable(char *db, char *table); void print(String *str); ulong init_prepare_fake_select_lex(THD *thd); @@ -526,6 +525,8 @@ public: bool first_cond_optimization; /* do not wrap view fields with Item_ref */ bool no_wrap_view_item; + /* exclude this select from check of unique_table() */ + bool exclude_from_table_unique_test; /* SELECT for SELECT command st_select_lex. Used to privent scaning @@ -616,8 +617,6 @@ public: init_select(); } bool setup_ref_array(THD *thd, uint order_group_num); - bool check_updateable(char *db, char *table); - bool check_updateable_in_subqueries(char *db, char *table); void print(THD *thd, String *str); static void print_order(String *str, ORDER *order); void print_limit(THD *thd, String *str); @@ -696,14 +695,16 @@ typedef struct st_lex Item *default_value, *on_update_value; LEX_STRING comment, ident; LEX_USER *grant_user; + XID *xid; gptr yacc_yyss,yacc_yyvs; THD *thd; CHARSET_INFO *charset; TABLE_LIST *query_tables; /* global list of all tables in this query */ /* last element next_global of previous list (used only for list building - during parsing and VIEW processing. This pointer is not valid in - mysql_execute_command + during parsing and VIEW processing. This pointer could be invalid during + processing of information schema tables(see get_schema_tables_result + function) */ TABLE_LIST **query_tables_last; TABLE_LIST *proc_table; /* refer to mysql.proc if it was opened by VIEW */ @@ -738,7 +739,7 @@ typedef struct st_lex enum enum_tx_isolation tx_isolation; enum enum_ha_read_modes ha_read_mode; union { - enum ha_rkey_function ha_rkey_mode; + enum ha_rkey_function ha_rkey_mode; enum xa_option_words xa_opt; }; enum enum_var_type option_type; @@ -764,15 +765,15 @@ typedef struct st_lex ALTER_INFO alter_info; /* Prepared statements SQL syntax:*/ LEX_STRING prepared_stmt_name; /* Statement name (in all queries) */ - /* + /* Prepared statement query text or name of variable that holds the prepared statement (in PREPARE ... queries) */ - LEX_STRING prepared_stmt_code; + LEX_STRING prepared_stmt_code; /* If true, prepared_stmt_code is a name of variable that holds the query */ bool prepared_stmt_code_is_varref; /* Names of user variables holding parameters (in EXECUTE) */ - List prepared_stmt_params; + List prepared_stmt_params; /* Points to part of global table list which contains time zone tables implicitly used by the statement. diff --git a/sql/sql_load.cc b/sql/sql_load.cc index a0fed715405..c827bbace3e 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -671,7 +671,7 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, if (field->type() == FIELD_TYPE_TIMESTAMP) ((Field_timestamp*) field)->set_time(); else if (field != table->next_number_field) - field->set_warning((uint) MYSQL_ERROR::WARN_LEVEL_WARN, + field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_NULL_TO_NOTNULL, 1); } } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 606286bfbc0..26631ecc885 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -263,13 +263,15 @@ int check_user(THD *thd, enum enum_server_command command, #ifdef NO_EMBEDDED_ACCESS_CHECKS thd->master_access= GLOBAL_ACLS; // Full rights - /* Change database if necessary: OK or FAIL is sent in mysql_change_db */ + /* Change database if necessary */ if (db && db[0]) { thd->db= 0; thd->db_length= 0; if (mysql_change_db(thd, db)) { + /* Send the error to the client */ + net_send_error(thd); if (thd->user_connect) decrease_user_connections(thd->user_connect); DBUG_RETURN(-1); @@ -398,11 +400,13 @@ int check_user(THD *thd, enum enum_server_command command, check_for_max_user_connections(thd, thd->user_connect)) DBUG_RETURN(-1); - /* Change database if necessary: OK or FAIL is sent in mysql_change_db */ + /* Change database if necessary */ if (db && db[0]) { if (mysql_change_db(thd, db)) { + /* Send error to the client */ + net_send_error(thd); if (thd->user_connect) decrease_user_connections(thd->user_connect); DBUG_RETURN(-1); @@ -1106,7 +1110,8 @@ pthread_handler_decl(handle_one_connection,arg) thd->proc_info=0; thd->set_time(); thd->init_for_queries(); - while (!net->error && net->vio != 0 && !(thd->killed == THD::KILL_CONNECTION)) + while (!net->error && net->vio != 0 && + !(thd->killed == THD::KILL_CONNECTION)) { net->no_send_error= 0; if (do_command(thd)) @@ -1691,6 +1696,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd, } else thd->query_rest.copy(packet, length, thd->query_rest.charset()); + + thd->server_status&= ~ (SERVER_QUERY_NO_INDEX_USED | + SERVER_QUERY_NO_GOOD_INDEX_USED); break; #endif /*EMBEDDED_LIBRARY*/ } @@ -1912,11 +1920,13 @@ bool dispatch_command(enum enum_server_command command, THD *thd, #endif ulong uptime = (ulong) (thd->start_time - start_time); sprintf((char*) buff, - "Uptime: %ld Threads: %d Questions: %lu Slow queries: %ld Opens: %ld Flush tables: %ld Open tables: %u Queries per second avg: %.3f", + "Uptime: %lu Threads: %d Questions: %lu Slow queries: %lu Opens: %lu Flush tables: %lu Open tables: %u Queries per second avg: %.3f", uptime, - (int) thread_count,thd->query_id,thd->status_var.long_query_count, - thd->status_var.opened_tables,refresh_version, cached_tables(), - uptime ? (float)thd->query_id/(float)uptime : 0); + (int) thread_count, (ulong) thd->query_id, + (ulong) thd->status_var.long_query_count, + thd->status_var.opened_tables, refresh_version, cached_tables(), + (uptime ? (ulonglong2double(thd->query_id) / (double) uptime) : + (double) 0)); #ifdef SAFEMALLOC if (sf_malloc_cur_memory) // Using SAFEMALLOC sprintf(strend(buff), " Memory in use: %ldK Max memory used: %ldK", @@ -3235,16 +3245,6 @@ unsent_create_error: if ((res= open_and_lock_tables(thd, all_tables))) break; - if (!first_table->table) - { - DBUG_ASSERT(first_table->view && - first_table->ancestor && first_table->ancestor->next_local); - my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0), - first_table->view_db.str, first_table->view_name.str); - res= FALSE; - break; - } - if ((res= mysql_multi_delete_prepare(thd))) goto error; @@ -4135,7 +4135,15 @@ unsent_create_error: sp= sp_find_function(thd, lex->spname); mysql_reset_errors(thd, 0); if (! sp) - result= SP_KEY_NOT_FOUND; + { + if (lex->spname->m_db.str) + result= SP_KEY_NOT_FOUND; + else + { + my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0)); + goto error; + } + } else { if (check_procedure_access(thd, ALTER_PROC_ACL, sp->m_db.str, @@ -4214,7 +4222,13 @@ unsent_create_error: } } #endif - result= SP_KEY_NOT_FOUND; + if (lex->spname->m_db.str) + result= SP_KEY_NOT_FOUND; + else + { + my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0)); + goto error; + } } res= result; switch (result) @@ -4326,7 +4340,7 @@ unsent_create_error: case SQLCOM_XA_START: if (thd->transaction.xa_state == XA_IDLE && thd->lex->xa_opt == XA_RESUME) { - if (! thd->transaction.xid.eq(&thd->lex->ident)) + if (! thd->transaction.xid.eq(thd->lex->xid)) { my_error(ER_XAER_NOTA, MYF(0)); break; @@ -4335,7 +4349,7 @@ unsent_create_error: send_ok(thd); break; } - if (thd->lex->ident.length > MAXGTRIDSIZE || thd->lex->xa_opt != XA_NONE) + if (thd->lex->xa_opt != XA_NONE) { // JOIN is not supported yet. TODO my_error(ER_XAER_INVAL, MYF(0)); break; @@ -4353,7 +4367,7 @@ unsent_create_error: } DBUG_ASSERT(thd->transaction.xid.is_null()); thd->transaction.xa_state=XA_ACTIVE; - thd->transaction.xid.set(&thd->lex->ident); + thd->transaction.xid.set(thd->lex->xid); thd->options= ((thd->options & (ulong) ~(OPTION_STATUS_NO_TRANS_UPDATE)) | OPTION_BEGIN); thd->server_status|= SERVER_STATUS_IN_TRANS; @@ -4372,7 +4386,7 @@ unsent_create_error: xa_state_names[thd->transaction.xa_state]); break; } - if (!thd->transaction.xid.eq(&thd->lex->ident)) + if (!thd->transaction.xid.eq(thd->lex->xid)) { my_error(ER_XAER_NOTA, MYF(0)); break; @@ -4387,7 +4401,7 @@ unsent_create_error: xa_state_names[thd->transaction.xa_state]); break; } - if (!thd->transaction.xid.eq(&thd->lex->ident)) + if (!thd->transaction.xid.eq(thd->lex->xid)) { my_error(ER_XAER_NOTA, MYF(0)); break; @@ -4402,9 +4416,9 @@ unsent_create_error: send_ok(thd); break; case SQLCOM_XA_COMMIT: - if (!thd->transaction.xid.eq(&thd->lex->ident)) + if (!thd->transaction.xid.eq(thd->lex->xid)) { - if (!(res= !ha_commit_or_rollback_by_xid(&thd->lex->ident, 1))) + if (!(res= !ha_commit_or_rollback_by_xid(thd->lex->xid, 1))) my_error(ER_XAER_NOTA, MYF(0)); else send_ok(thd); @@ -4421,10 +4435,19 @@ unsent_create_error: else if (thd->transaction.xa_state == XA_PREPARED && thd->lex->xa_opt == XA_NONE) { - if (ha_commit_one_phase(thd, 1)) + if (wait_if_global_read_lock(thd, 0, 0)) + { + ha_rollback(thd); my_error(ER_XAER_RMERR, MYF(0)); + } else - send_ok(thd); + { + if (ha_commit_one_phase(thd, 1)) + my_error(ER_XAER_RMERR, MYF(0)); + else + send_ok(thd); + start_waiting_global_read_lock(thd); + } } else { @@ -4437,9 +4460,9 @@ unsent_create_error: thd->transaction.xa_state=XA_NOTR; break; case SQLCOM_XA_ROLLBACK: - if (!thd->transaction.xid.eq(&thd->lex->ident)) + if (!thd->transaction.xid.eq(thd->lex->xid)) { - if (!(res= !ha_commit_or_rollback_by_xid(&thd->lex->ident, 0))) + if (!(res= !ha_commit_or_rollback_by_xid(thd->lex->xid, 0))) my_error(ER_XAER_NOTA, MYF(0)); else send_ok(thd); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index ace2a9de420..7c00299d482 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1654,6 +1654,7 @@ static int check_prepared_statement(Prepared_statement *stmt, case SQLCOM_DROP_INDEX: case SQLCOM_ROLLBACK: case SQLCOM_TRUNCATE: + case SQLCOM_CALL: break; default: @@ -1871,6 +1872,9 @@ void reset_stmt_for_execute(THD *thd, LEX *lex) /* remove option which was put by mysql_explain_union() */ sl->options&= ~SELECT_DESCRIBE; + /* see unique_table() */ + sl->exclude_from_table_unique_test= FALSE; + /* Copy WHERE clause pointers to avoid damaging they by optimisation */ diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0c00d947508..f380876577a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -111,6 +111,7 @@ static bool const_expression_in_where(COND *conds,Item *item, Item **comp_item); static bool open_tmp_table(TABLE *table); static bool create_myisam_tmp_table(TABLE *table,TMP_TABLE_PARAM *param, ulong options); +static Next_select_func setup_end_select_func(JOIN *join); static int do_select(JOIN *join,List *fields,TABLE *tmp_table, Procedure *proc); static int sub_select_cache(JOIN *join,JOIN_TAB *join_tab,bool end_of_records); @@ -316,6 +317,13 @@ JOIN::prepare(Item ***rref_pointer_array, join_list= &select_lex->top_join_list; union_part= (unit_arg->first_select()->next_select() != 0); + /* + If we have already executed SELECT, then it have not sense to prevent + its table from update (see unique_table()) + */ + if (thd->derived_tables_processing) + select_lex->exclude_from_table_unique_test= TRUE; + /* Check that all tables, fields, conds and order are ok */ if ((!(select_options & OPTION_SETUP_TABLES_DONE) && @@ -1157,7 +1165,7 @@ JOIN::exec() { int tmp_error; DBUG_ENTER("JOIN::exec"); - + error= 0; if (procedure) { @@ -1631,6 +1639,8 @@ JOIN::exec() { thd->proc_info="Sending data"; DBUG_PRINT("info", ("%s", thd->proc_info)); + result->send_fields(*curr_fields_list, + Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF); error= do_select(curr_join, curr_fields_list, NULL, procedure); thd->limit_found_rows= curr_join->send_records; thd->examined_row_count= curr_join->examined_rows; @@ -1769,12 +1779,8 @@ Cursor::open(JOIN *join_arg) thd->server_status&= ~SERVER_STATUS_CURSOR_EXISTS; /* Prepare JOIN for reading rows. */ - - Next_select_func end_select= join->sort_and_group || join->procedure && - join->procedure->flags & PROC_GROUP ? - end_send_group : end_send; - - join->join_tab[join->tables-1].next_select= end_select; + join->tmp_table= 0; + join->join_tab[join->tables-1].next_select= setup_end_select_func(join); join->send_records= 0; join->fetch_limit= join->unit->offset_limit_cnt; @@ -1795,6 +1801,11 @@ Cursor::open(JOIN *join_arg) */ DBUG_ASSERT(join_tab->table->null_row == 0); + /* + There is always at least one record in the table, as otherwise we + wouldn't have opened the cursor. Therefore a failure is the only + reason read_first_record can return not 0. + */ DBUG_RETURN(join_tab->read_first_record(join_tab)); } @@ -2224,6 +2235,8 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds, if (s->dependent & table->map) s->dependent |= table->reginfo.join_tab->dependent; } + if (s->dependent) + s->table->maybe_null= 1; } /* Catch illegal cross references for outer joins */ for (i= 0, s= stat ; i < table_count ; i++, s++) @@ -2473,6 +2486,11 @@ typedef struct key_field_t { // Used when finding key fields uint level; uint optimize; bool eq_func; + /* + If true, the condition this struct represents will not be satisfied + when val IS NULL. + */ + bool null_rejecting; } KEY_FIELD; /* Values in optimize */ @@ -2489,6 +2507,12 @@ typedef struct key_field_t { // Used when finding key fields that are internally transformed to something like: SELECT * FROM t1 WHERE t1.key=outer_ref_field or t1.key IS NULL + + KEY_FIELD::null_rejecting is processed as follows: + result has null_rejecting=true if it is set for both ORed references. + for example: + (t2.key = t1.field OR t2.key = t1.field) -> null_rejecting=true + (t2.key = t1.field OR t2.key <=> t1.field) -> null_rejecting=false */ static KEY_FIELD * @@ -2522,6 +2546,8 @@ merge_key_fields(KEY_FIELD *start,KEY_FIELD *new_fields,KEY_FIELD *end, KEY_OPTIMIZE_EXISTS) | ((old->optimize | new_fields->optimize) & KEY_OPTIMIZE_REF_OR_NULL)); + old->null_rejecting= old->null_rejecting && + new_fields->null_rejecting; } } else if (old->eq_func && new_fields->eq_func && @@ -2533,6 +2559,8 @@ merge_key_fields(KEY_FIELD *start,KEY_FIELD *new_fields,KEY_FIELD *end, KEY_OPTIMIZE_EXISTS) | ((old->optimize | new_fields->optimize) & KEY_OPTIMIZE_REF_OR_NULL)); + old->null_rejecting= old->null_rejecting && + new_fields->null_rejecting; } else if (old->eq_func && new_fields->eq_func && (old->val->is_null() || new_fields->val->is_null())) @@ -2543,6 +2571,8 @@ merge_key_fields(KEY_FIELD *start,KEY_FIELD *new_fields,KEY_FIELD *end, /* Remember the NOT NULL value */ if (old->val->is_null()) old->val= new_fields->val; + /* The referred expression can be NULL: */ + old->null_rejecting= false; } else { @@ -2598,7 +2628,7 @@ merge_key_fields(KEY_FIELD *start,KEY_FIELD *new_fields,KEY_FIELD *end, */ static void -add_key_field(KEY_FIELD **key_fields, uint and_level, COND *cond, +add_key_field(KEY_FIELD **key_fields,uint and_level, Item_func *cond, Field *field, bool eq_func, Item **value, uint num_values, table_map usable_tables) { @@ -2700,10 +2730,17 @@ add_key_field(KEY_FIELD **key_fields, uint and_level, COND *cond, (*key_fields)->val= *value; (*key_fields)->level= and_level; (*key_fields)->optimize= exists_optimize; + /* + If the condition has form "tbl.keypart = othertbl.field" and + othertbl.field can be NULL, there will be no matches if othertbl.field + has NULL value. + */ + (*key_fields)->null_rejecting= (cond->functype() == Item_func::EQ_FUNC) && + ((*value)->type() == Item::FIELD_ITEM) && + ((Item_field*)*value)->field->maybe_null(); (*key_fields)++; } - /* Add possible keys to array of possible keys originated from a simple predicate @@ -2728,7 +2765,7 @@ add_key_field(KEY_FIELD **key_fields, uint and_level, COND *cond, static void add_key_equal_fields(KEY_FIELD **key_fields, uint and_level, - COND *cond, Item_field *field_item, + Item_func *cond, Item_field *field_item, bool eq_func, Item **val, uint num_values, table_map usable_tables) { @@ -2756,7 +2793,7 @@ add_key_equal_fields(KEY_FIELD **key_fields, uint and_level, } static void -add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level, +add_key_fields(KEY_FIELD **key_fields,uint *and_level, COND *cond, table_map usable_tables) { if (cond->type() == Item_func::COND_ITEM) @@ -2768,20 +2805,20 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level, { Item *item; while ((item=li++)) - add_key_fields(stat,key_fields,and_level,item,usable_tables); + add_key_fields(key_fields,and_level,item,usable_tables); for (; org_key_fields != *key_fields ; org_key_fields++) org_key_fields->level= *and_level; } else { (*and_level)++; - add_key_fields(stat,key_fields,and_level,li++,usable_tables); + add_key_fields(key_fields,and_level,li++,usable_tables); Item *item; while ((item=li++)) { KEY_FIELD *start_key_fields= *key_fields; (*and_level)++; - add_key_fields(stat,key_fields,and_level,item,usable_tables); + add_key_fields(key_fields,and_level,item,usable_tables); *key_fields=merge_key_fields(org_key_fields,start_key_fields, *key_fields,++(*and_level)); } @@ -2869,7 +2906,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level, */ while ((item= it++)) { - add_key_field(key_fields, *and_level, cond, item->field, + add_key_field(key_fields, *and_level, cond_func, item->field, TRUE, &const_item, 1, usable_tables); } } @@ -2889,7 +2926,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level, { if (!field->eq(item->field)) { - add_key_field(key_fields, *and_level, cond, field, + add_key_field(key_fields, *and_level, cond_func, field, TRUE, (Item **) &item, 1, usable_tables); } } @@ -2941,6 +2978,7 @@ add_key_part(DYNAMIC_ARRAY *keyuse_array,KEY_FIELD *key_field) keyuse.keypart_map= (key_part_map) 1 << part; keyuse.used_tables=key_field->val->used_tables(); keyuse.optimize= key_field->optimize & KEY_OPTIMIZE_REF_OR_NULL; + keyuse.null_rejecting= key_field->null_rejecting; VOID(insert_dynamic(keyuse_array,(gptr) &keyuse)); } } @@ -3034,8 +3072,22 @@ sort_keyuse(KEYUSE *a,KEYUSE *b) /* Update keyuse array with all possible keys we can use to fetch rows - join_tab is a array in tablenr_order - stat is a reference array in 'prefered' order. + + SYNOPSIS + update_ref_and_keys() + thd + keyuse OUT Put here ordered array of KEYUSE structures + join_tab Array in tablenr_order + tables Number of tables in join + cond WHERE condition (note that the function analyzes + join_tab[i]->on_expr too) + normal_tables tables not inner w.r.t some outer join (ones for which + we can make ref access based the WHERE clause) + select_lex current SELECT + + RETURN + 0 - OK + 1 - Out of memory. */ static bool @@ -3060,7 +3112,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab, return TRUE; if (cond) { - add_key_fields(join_tab,&end,&and_level,cond,normal_tables); + add_key_fields(&end,&and_level,cond,normal_tables); for (; field != end ; field++) { add_key_part(keyuse,field); @@ -3083,7 +3135,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab, */ if (*join_tab[i].on_expr_ref) { - add_key_fields(join_tab,&end,&and_level,*join_tab[i].on_expr_ref, + add_key_fields(&end,&and_level,*join_tab[i].on_expr_ref, join_tab[i].table->map); } else @@ -3094,7 +3146,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab, { NESTED_JOIN *nested_join= embedding->nested_join; if (nested_join->join_list.head() == tab) - add_key_fields(join_tab, &end, &and_level, embedding->on_expr, + add_key_fields(&end, &and_level, embedding->on_expr, nested_join->used_tables); } } @@ -3109,10 +3161,14 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab, } /* - Special treatment for ft-keys. - Remove the following things from KEYUSE: + Sort the array of possible keys and remove the following key parts: - ref if there is a keypart which is a ref and a const. - - keyparts without previous keyparts. + (e.g. if there is a key(a,b) and the clause is a=3 and b=7 and b=t2.d, + then we skip the key part corresponding to b=t2.d) + - keyparts without previous keyparts + (e.g. if there is a key(a,b,c) but only b < 5 (or a=2 and c < 3) is + used in the query, we drop the partial key parts from consideration). + Special treatment for ft-keys. */ if (keyuse->elements) { @@ -4868,6 +4924,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse, } j->ref.key_buff2=j->ref.key_buff+ALIGN_SIZE(length); j->ref.key_err=1; + j->ref.null_rejecting= 0; keyuse=org_keyuse; store_key **ref_key= j->ref.key_copy; @@ -4892,6 +4949,8 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse, uint maybe_null= test(keyinfo->key_part[i].null_bit); j->ref.items[i]=keyuse->val; // Save for cond removal + if (keyuse->null_rejecting) + j->ref.null_rejecting |= 1 << i; keyuse_uses_no_tables= keyuse_uses_no_tables && !keyuse->used_tables; if (!keyuse->used_tables && !(join->select_options & SELECT_DESCRIBE)) @@ -5050,6 +5109,91 @@ make_simple_join(JOIN *join,TABLE *tmp_table) } +inline void add_cond_and_fix(Item **e1, Item *e2) +{ + if (*e1) + { + Item *res; + if ((res= new Item_cond_and(*e1, e2))) + { + *e1= res; + res->quick_fix_field(); + } + } + else + *e1= e2; +} + + +/* + Add to join_tab->select_cond[i] "table.field IS NOT NULL" conditions we've + inferred from ref/eq_ref access performed. + + SYNOPSIS + add_not_null_conds() + join Join to process + + NOTES + This function is a part of "Early NULL-values filtering for ref access" + optimization. + + Example of this optimization: + For query SELECT * FROM t1,t2 WHERE t2.key=t1.field + and plan " any-access(t1), ref(t2.key=t1.field) " + add "t1.field IS NOT NULL" to t1's table condition. + Description of the optimization: + + We look through equalities choosen to perform ref/eq_ref access, + pick equalities that have form "tbl.part_of_key = othertbl.field" + (where othertbl is a non-const table and othertbl.field may be NULL) + and add them to conditions on correspoding tables (othertbl in this + example). + + This optimization doesn't affect the choices that ref, range, or join + optimizer make. This was intentional because this was added after 4.1 + was GA. + + Implementation overview + 1. update_ref_and_keys() accumulates info about null-rejecting + predicates in in KEY_FIELD::null_rejecting + 1.1 add_key_part saves these to KEYUSE. + 2. create_ref_for_key copies them to TABLE_REF. + 3. add_not_null_conds adds "x IS NOT NULL" to join_tab->select_cond of + appropiate JOIN_TAB members. +*/ + +static void add_not_null_conds(JOIN *join) +{ + DBUG_ENTER("add_not_null_conds"); + for (uint i=join->const_tables ; i < join->tables ; i++) + { + JOIN_TAB *tab=join->join_tab+i; + if ((tab->type == JT_REF || tab->type == JT_REF_OR_NULL) && + !tab->table->maybe_null) + { + for (uint keypart= 0; keypart < tab->ref.key_parts; keypart++) + { + if (tab->ref.null_rejecting & (1 << keypart)) + { + Item *item= tab->ref.items[keypart]; + DBUG_ASSERT(item->type() == Item::FIELD_ITEM); + Item_field *not_null_item= (Item_field*)item; + JOIN_TAB *referred_tab= not_null_item->field->table->reginfo.join_tab; + Item_func_isnotnull *notnull; + if (!(notnull= new Item_func_isnotnull(not_null_item))) + DBUG_VOID_RETURN; + + notnull->quick_fix_field(); + DBUG_EXECUTE("where",print_where(notnull, + referred_tab->table->alias);); + add_cond_and_fix(&referred_tab->select_cond, notnull); + } + } + } + } + DBUG_VOID_RETURN; +} + /* Build a predicate guarded by match variables for embedding outer joins @@ -5187,6 +5331,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) DBUG_ENTER("make_join_select"); if (select) { + add_not_null_conds(join); table_map used_tables; if (cond) /* Because of QUICK_GROUP_MIN_MAX_SELECT */ { /* there may be a select without a cond. */ @@ -5320,6 +5465,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) tab->select_cond= sel->cond= NULL; sel->head=tab->table; + DBUG_EXECUTE("where",print_where(tmp,tab->table->alias);); if (tab->quick) { /* Use quick key read if it's a constant and it's not used @@ -6908,7 +7054,7 @@ static COND* substitute_for_best_equal_field(COND *cond, return eliminate_item_equal(0, cond_equal, item_equal); } else - cond->walk(&Item::replace_equal_field_processor, 0); + cond->transform(&Item::replace_equal_field, 0); return cond; } @@ -7458,7 +7604,7 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value) (thd->options & OPTION_AUTO_IS_NULL) && thd->insert_id()) { -#ifndef EMBEDDED_LIBRARY +#ifdef HAVE_QUERY_CACHE query_cache_abort(&thd->net); #endif COND *new_cond; @@ -8015,6 +8161,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, */ (*argp)->maybe_null=1; } + new_field->query_id= thd->query_id; } } } @@ -8061,6 +8208,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, group_null_items++; new_field->flags|= GROUP_FLAG; } + new_field->query_id= thd->query_id; *(reg_field++) =new_field; } if (!--hidden_field_count) @@ -8726,36 +8874,24 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param, } -/**************************************************************************** - Make a join of all tables and write it on socket or to table - Return: 0 if ok - 1 if error is sent - -1 if error should be sent -****************************************************************************/ +/* + SYNOPSIS + setup_end_select_func() + join join to setup the function for. -static int -do_select(JOIN *join,List *fields,TABLE *table,Procedure *procedure) + DESCRIPTION + Rows produced by a join sweep may end up in a temporary table or be sent + to a client. Setup the function of the nested loop join algorithm which + handles final fully constructed and matched records. + + RETURN + end_select function to use. This function can't fail. +*/ + +static Next_select_func setup_end_select_func(JOIN *join) { - int error= 0; - JOIN_TAB *join_tab; + TABLE *table= join->tmp_table; Next_select_func end_select; - DBUG_ENTER("do_select"); - - join->procedure=procedure; - /* - Tell the client how many fields there are in a row - */ - if (!table) - join->result->send_fields(*fields, - Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF); - else - { - VOID(table->file->extra(HA_EXTRA_WRITE_CACHE)); - empty_record(table); - } - join->tmp_table= table; /* Save for easy recursion */ - join->fields= fields; - /* Set up select_end */ if (table) { @@ -8765,8 +8901,6 @@ do_select(JOIN *join,List *fields,TABLE *table,Procedure *procedure) { DBUG_PRINT("info",("Using end_update")); end_select=end_update; - if (!table->file->inited) - table->file->ha_index_init(0); } else { @@ -8800,7 +8934,38 @@ do_select(JOIN *join,List *fields,TABLE *table,Procedure *procedure) else end_select= end_send; } - join->join_tab[join->tables-1].next_select=end_select; + return end_select; +} + + +/**************************************************************************** + Make a join of all tables and write it on socket or to table + Return: 0 if ok + 1 if error is sent + -1 if error should be sent +****************************************************************************/ + +static int +do_select(JOIN *join,List *fields,TABLE *table,Procedure *procedure) +{ + int error= 0; + JOIN_TAB *join_tab; + DBUG_ENTER("do_select"); + + join->procedure=procedure; + join->tmp_table= table; /* Save for easy recursion */ + join->fields= fields; + + if (table) + { + VOID(table->file->extra(HA_EXTRA_WRITE_CACHE)); + empty_record(table); + if (table->group && join->tmp_table_param.sum_func_count && + table->s->keys && !table->file->inited) + table->file->ha_index_init(0); + } + /* Set up select_end */ + join->join_tab[join->tables-1].next_select= setup_end_select_func(join); join_tab=join->join_tab+join->const_tables; join->send_records=0; @@ -8812,6 +8977,7 @@ do_select(JOIN *join,List *fields,TABLE *table,Procedure *procedure) */ if (!join->conds || join->conds->val_int()) { + Next_select_func end_select= join->join_tab[join->tables-1].next_select; if (!(error=(*end_select)(join,join_tab,0)) || error == -3) error=(*end_select)(join,join_tab,1); } diff --git a/sql/sql_select.h b/sql/sql_select.h index 381ccbba4fd..e9397925b6a 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -31,6 +31,11 @@ typedef struct keyuse_t { uint key, keypart, optimize; key_part_map keypart_map; ha_rows ref_table_rows; + /* + If true, the comparison this value was created from will not be + satisfied if val has NULL 'value'. + */ + bool null_rejecting; } KEYUSE; class store_key; @@ -45,6 +50,11 @@ typedef struct st_table_ref byte *key_buff2; // key_buff+key_length store_key **key_copy; // Item **items; // val()'s for each keypart + /* + (null_rejecting & (1<field[17]->store(tmp+1,end == tmp ? 0 : (uint) (end-tmp-1), cs); + table->field[1]->store(base_name, strlen(base_name), cs); table->field[2]->store(file_name, strlen(file_name), cs); table->field[3]->store(field->field_name, strlen(field->field_name), @@ -2335,11 +2361,13 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, table->field[6]->store((const char*) pos, strlen((const char*) pos), cs); if (field->has_charset()) + { table->field[8]->store((longlong) field->representation_length()/ field->charset()->mbmaxlen); - else - table->field[8]->store((longlong) field->representation_length()); - table->field[9]->store((longlong) field->representation_length()); + table->field[8]->set_notnull(); + table->field[9]->store((longlong) field->representation_length()); + table->field[9]->set_notnull(); + } { uint dec =field->decimals(); @@ -2396,31 +2424,12 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, (field->flags & MULTIPLE_KEY_FLAG) ? "MUL":""); table->field[15]->store((const char*) pos, strlen((const char*) pos), cs); - char *end= tmp; + end= tmp; if (field->unireg_check == Field::NEXT_NUMBER) end=strmov(tmp,"auto_increment"); table->field[16]->store(tmp, (uint) (end-tmp), cs); end=tmp; -#ifndef NO_EMBEDDED_ACCESS_CHECKS - uint col_access; - check_access(thd,SELECT_ACL | EXTRA_ACL, base_name, - &tables->grant.privilege, 0, 0); - col_access= get_column_grant(thd, &tables->grant, tables->db, - tables->table_name, - field->field_name) & COL_ACLS; - for (uint bitnr=0; col_access ; col_access>>=1,bitnr++) - { - if (col_access & 1) - { - *end++=','; - end=strmov(end,grant_types.type_names[bitnr]); - } - } -#else - end=strmov(end,""); -#endif - table->field[17]->store(tmp+1,end == tmp ? 0 : (uint) (end-tmp-1), cs); table->field[18]->store(field->comment.str, field->comment.length, cs); if (schema_table_store_record(thd, table)) DBUG_RETURN(1); @@ -3435,12 +3444,11 @@ bool get_schema_tables_result(JOIN *join) TABLE_LIST *table_list= tab->table->pos_in_table_list; if (table_list->schema_table && thd->fill_derived_tables()) { - TABLE_LIST *save_next_global= table_list->next_global; TABLE_LIST **query_tables_last= lex->query_tables_last; TABLE *old_derived_tables= thd->derived_tables; MYSQL_LOCK *sql_lock= thd->lock; lex->sql_command= SQLCOM_SHOW_FIELDS; - + DBUG_ASSERT(!*query_tables_last); if (&lex->unit != lex->current_select->master_unit()) // is subselect { table_list->table->file->extra(HA_EXTRA_RESET_STATE); @@ -3459,8 +3467,8 @@ bool get_schema_tables_result(JOIN *join) thd->lock= sql_lock; lex->sql_command= SQLCOM_SELECT; thd->derived_tables= old_derived_tables; - table_list->next_global= save_next_global; lex->query_tables_last= query_tables_last; + *query_tables_last= 0; } } thd->no_warnings_for_error= 0; @@ -3515,8 +3523,8 @@ ST_FIELD_INFO columns_fields_info[]= {"COLUMN_DEFAULT", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Default"}, {"IS_NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null"}, {"DATA_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, - {"CHARACTER_MAXIMUM_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 0, 0}, - {"CHARACTER_OCTET_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 0, 0}, + {"CHARACTER_MAXIMUM_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0}, + {"CHARACTER_OCTET_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0}, {"NUMERIC_PRECISION", 21 , MYSQL_TYPE_LONG, 0, 1, 0}, {"NUMERIC_SCALE", 21 , MYSQL_TYPE_LONG, 0, 1, 0}, {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0}, diff --git a/sql/sql_table.cc b/sql/sql_table.cc index b125eeaf03a..8753f62ab89 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -257,7 +257,19 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, /* Delete the table definition file */ strmov(end,reg_ext); if (!(new_error=my_delete(path,MYF(MY_WME)))) + { some_tables_deleted=1; + /* + Destroy triggers for this table if there are any. + + We won't need this as soon as we will have new .FRM format, + in which we will store trigger definitions in the same .FRM + files as table descriptions. + */ + strmov(end, triggers_file_ext); + if (!access(path, F_OK)) + new_error= my_delete(path, MYF(MY_WME)); + } error|= new_error; } } @@ -273,7 +285,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, if (wrong_tables.length()) { if (!foreign_key_error) - my_error(ER_BAD_TABLE_ERROR, MYF(0), wrong_tables.c_ptr()); + my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0), + wrong_tables.c_ptr()); else my_message(ER_ROW_IS_REFERENCED, ER(ER_ROW_IS_REFERENCED), MYF(0)); error= 1; @@ -550,12 +563,9 @@ int prepare_create_field(create_field *sql_field, sql_field->pack_flag=f_settype((uint) sql_field->sql_type); break; case FIELD_TYPE_BIT: - if (!(table_flags & HA_CAN_BIT_FIELD)) - { - my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "BIT FIELD"); - DBUG_RETURN(1); - } - sql_field->pack_flag= FIELDFLAG_NUMBER; + /* + We have sql_field->pack_flag already set here, see mysql_prepare_table(). + */ break; case FIELD_TYPE_NEWDECIMAL: sql_field->pack_flag=(FIELDFLAG_NUMBER | @@ -620,11 +630,12 @@ int prepare_create_field(create_field *sql_field, -1 error */ -int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, - List &fields, - List &keys, bool tmp_table, uint &db_options, - handler *file, KEY *&key_info_buffer, - uint *key_count, int select_field_count) +static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, + List *fields, + List *keys, bool tmp_table, + uint *db_options, + handler *file, KEY **key_info_buffer, + uint *key_count, int select_field_count) { const char *key_name; create_field *sql_field,*dup_field; @@ -636,11 +647,11 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, int timestamps= 0, timestamps_with_niladic= 0; int field_no,dup_no; int select_field_pos,auto_increment=0; - List_iterator it(fields),it2(fields); + List_iterator it(*fields),it2(*fields); uint total_uneven_bit_length= 0; DBUG_ENTER("mysql_prepare_table"); - select_field_pos=fields.elements - select_field_count; + select_field_pos= fields->elements - select_field_count; null_fields=blob_columns=0; create_info->varchar= 0; @@ -760,6 +771,15 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, set_if_smaller(sql_field->length, MAX_FIELD_WIDTH-1); } + if (sql_field->sql_type == FIELD_TYPE_BIT) + { + sql_field->pack_flag= FIELDFLAG_NUMBER; + if (file->table_flags() & HA_CAN_BIT_FIELD) + total_uneven_bit_length+= sql_field->length & 7; + else + sql_field->pack_flag|= FIELDFLAG_TREAT_BIT_AS_CHAR; + } + sql_field->create_length_to_internal_length(); if (sql_field->length > MAX_FIELD_VARCHARLENGTH && !(sql_field->flags & BLOB_FLAG)) @@ -796,9 +816,6 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, if (!(sql_field->flags & NOT_NULL_FLAG)) null_fields++; - if (sql_field->sql_type == FIELD_TYPE_BIT) - total_uneven_bit_length+= sql_field->length & 7; - if (check_column_name(sql_field->field_name)) { my_error(ER_WRONG_COLUMN_NAME, MYF(0), sql_field->field_name); @@ -845,11 +862,11 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, if ((sql_field->flags & BLOB_FLAG) || sql_field->sql_type == MYSQL_TYPE_VARCHAR && create_info->row_type != ROW_TYPE_FIXED) - db_options|= HA_OPTION_PACK_RECORD; + (*db_options)|= HA_OPTION_PACK_RECORD; it2.rewind(); } /* If fixed row records, we need one bit to check for deleted rows */ - if (!(db_options & HA_OPTION_PACK_RECORD)) + if (!((*db_options) & HA_OPTION_PACK_RECORD)) null_fields++; pos= (null_fields + total_uneven_bit_length + 7) / 8; @@ -897,7 +914,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, /* Create keys */ - List_iterator key_iterator(keys), key_iterator2(keys); + List_iterator key_iterator(*keys), key_iterator2(*keys); uint key_parts=0, fk_key_count=0; bool primary_key=0,unique_key=0; Key *key, *key2; @@ -984,9 +1001,9 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, DBUG_RETURN(-1); } - key_info_buffer=key_info=(KEY*) sql_calloc(sizeof(KEY)* *key_count); + (*key_info_buffer) = key_info= (KEY*) sql_calloc(sizeof(KEY)* *key_count); key_part_info=(KEY_PART_INFO*) sql_calloc(sizeof(KEY_PART_INFO)*key_parts); - if (!key_info_buffer || ! key_part_info) + if (!*key_info_buffer || ! key_part_info) DBUG_RETURN(-1); // Out of memory key_iterator.rewind(); @@ -1260,7 +1277,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, } key_part_info->length=(uint16) length; /* Use packed keys for long strings on the first column */ - if (!(db_options & HA_OPTION_NO_PACK_KEYS) && + if (!((*db_options) & HA_OPTION_NO_PACK_KEYS) && (length >= KEY_DEFAULT_PACK_LENGTH && (sql_field->sql_type == MYSQL_TYPE_STRING || sql_field->sql_type == MYSQL_TYPE_VARCHAR || @@ -1291,8 +1308,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, } else if (!(key_name = key->name)) key_name=make_unique_key_name(sql_field->field_name, - key_info_buffer,key_info); - if (check_if_keyname_exists(key_name,key_info_buffer,key_info)) + *key_info_buffer, key_info); + if (check_if_keyname_exists(key_name, *key_info_buffer, key_info)) { my_error(ER_DUP_KEYNAME, MYF(0), key_name); DBUG_RETURN(-1); @@ -1327,7 +1344,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, DBUG_RETURN(-1); } /* Sort keys in optimized order */ - qsort((gptr) key_info_buffer, *key_count, sizeof(KEY), + qsort((gptr) *key_info_buffer, *key_count, sizeof(KEY), (qsort_cmp) sort_keys); DBUG_RETURN(0); @@ -1393,7 +1410,7 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, ha_get_storage_engine(new_db_type), table_name); } - db_options=create_info->table_options; + db_options= create_info->table_options; if (create_info->row_type == ROW_TYPE_DYNAMIC) db_options|=HA_OPTION_PACK_RECORD; alias= table_case_name(create_info, table_name); @@ -1432,9 +1449,9 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, create_info->default_table_charset= db_info.default_table_charset; } - if (mysql_prepare_table(thd, create_info, fields, - keys, internal_tmp_table, db_options, file, - key_info_buffer, &key_count, + if (mysql_prepare_table(thd, create_info, &fields, + &keys, internal_tmp_table, &db_options, file, + &key_info_buffer, &key_count, select_field_count)) DBUG_RETURN(TRUE); @@ -2211,7 +2228,9 @@ send_result_message: TABLE_LIST *save_next_local= table->next_local, *save_next_global= table->next_global; table->next_local= table->next_global= 0; + tmp_disable_binlog(thd); // binlogging is done by caller if wanted result_code= mysql_recreate_table(thd, table, 0); + reenable_binlog(thd); close_thread_tables(thd); if (!result_code) // recreation went ok { @@ -2706,9 +2725,9 @@ int mysql_create_indexes(THD *thd, TABLE_LIST *table_list, List &keys) create_info.db_type=DB_TYPE_DEFAULT; create_info.default_table_charset= thd->variables.collation_database; db_options= 0; - if (mysql_prepare_table(thd, &create_info, fields, - keys, /*tmp_table*/ 0, db_options, table->file, - key_info_buffer, key_count, + if (mysql_prepare_table(thd, &create_info, &fields, + &keys, /*tmp_table*/ 0, &db_options, table->file, + &key_info_buffer, key_count, /*select_field_count*/ 0)) DBUG_RETURN(-1); @@ -2839,9 +2858,9 @@ int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list, { db_options= 0; if (table->file->drop_index(table, key_numbers, key_count)|| - mysql_prepare_table(thd, &create_info, fields, - keys, /*tmp_table*/ 0, db_options, table->file, - key_info_buffer, key_count, + mysql_prepare_table(thd, &create_info, &fields, + &keys, /*tmp_table*/ 0, &db_options, table->file, + &key_info_buffer, key_count, /*select_field_count*/ 0)|| (snprintf(path, sizeof(path), "%s/%s/%s%s", mysql_data_home, table_list->db, (lower_case_table_names == 2)? @@ -3288,6 +3307,10 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, /* Safety fix for innodb */ if (lower_case_table_names) my_casedn_str(files_charset_info, tmp_name); + if (new_db_type != old_db_type && !table->file->can_switch_engines()) { + my_error(ER_ROW_IS_REFERENCED, MYF(0)); + goto err; + } create_info->db_type=new_db_type; if (!create_info->comment) create_info->comment= table->s->comment; @@ -3666,6 +3689,13 @@ copy_data_between_tables(TABLE *from,TABLE *to, if (to->file->external_lock(thd, F_WRLCK)) DBUG_RETURN(-1); + + /* We can abort alter table for any table type */ + thd->no_trans_update= 0; + thd->abort_on_warning= !ignore && test(thd->variables.sql_mode & + (MODE_STRICT_TRANS_TABLES | + MODE_STRICT_ALL_TABLES)); + from->file->info(HA_STATUS_VARIABLE); to->file->start_bulk_insert(from->file->records); @@ -3719,9 +3749,11 @@ copy_data_between_tables(TABLE *from,TABLE *to, goto err; }; - /* Handler must be told explicitly to retrieve all columns, because - this function does not set field->query_id in the columns to the - current query id */ + /* + Handler must be told explicitly to retrieve all columns, because + this function does not set field->query_id in the columns to the + current query id + */ from->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS); init_read_record(&info, thd, from, (SQL_SELECT *) 0, 1,1); if (ignore || @@ -3745,6 +3777,7 @@ copy_data_between_tables(TABLE *from,TABLE *to, else to->next_number_field->reset(); } + for (Copy_field *copy_ptr=copy ; copy_ptr != copy_end ; copy_ptr++) { copy_ptr->do_copy(copy_ptr); @@ -3789,6 +3822,7 @@ copy_data_between_tables(TABLE *from,TABLE *to, err: thd->variables.sql_mode= save_sql_mode; + thd->abort_on_warning= 0; free_io_cache(from); *copied= found_count; *deleted=delete_count; diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 110841e8fd4..5b6f12eab52 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -4,7 +4,8 @@ #include "parse_file.h" static const LEX_STRING triggers_file_type= {(char *)"TRIGGERS", 8}; -static const char * const triggers_file_ext= ".TRG"; + +const char * const triggers_file_ext= ".TRG"; /* Table of .TRG file field descriptors. diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 3340c46bb6b..f5d64efb5e9 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -525,8 +525,11 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name) tables.table_name= tables.alias= (char*) "func"; if (!(table = open_ltable(thd,&tables,TL_WRITE))) goto err; - if (!table->file->index_read_idx(table->record[0],0,(byte*) udf_name->str, - (uint) udf_name->length, + table->field[0]->store(udf_name->str, udf_name->length, system_charset_info); + table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS); + if (!table->file->index_read_idx(table->record[0], 0, + (byte*) table->field[0]->ptr, + table->key_info[0].key_length, HA_READ_KEY_EXACT)) { int error; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index bb0ac31bdc7..8b8dd32b22d 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -691,16 +691,6 @@ bool mysql_multi_update_prepare(THD *thd) DBUG_RETURN(TRUE); } - /* - Multi-update can't be constructed over-union => we always have - single SELECT on top and have to check underlying SELECTs of it - */ - if (lex->select_lex.check_updateable_in_subqueries(tl->db, - tl->table_name)) - { - my_error(ER_UPDATE_TABLE_USED, MYF(0), tl->table_name); - DBUG_RETURN(TRUE); - } DBUG_PRINT("info",("setting table `%s` for update", tl->alias)); tl->lock_type= lex->multi_lock_option; tl->updating= 1; @@ -781,6 +771,11 @@ bool mysql_multi_update_prepare(THD *thd) DBUG_RETURN(TRUE); } + /* + Check that we are not using table that we are updating, but we should + skip all tables of UPDATE SELECT itself + */ + lex->select_lex.exclude_from_table_unique_test= TRUE; /* We only need SELECT privilege for columns in the values list */ for (tl= leaves; tl; tl= tl->next_leaf) { @@ -794,11 +789,19 @@ bool mysql_multi_update_prepare(THD *thd) } DBUG_PRINT("info", ("table: %s want_privilege: %u", tl->alias, (uint) table->grant.want_privilege)); + if (tl->lock_type != TL_READ && + tl->lock_type != TL_READ_NO_INSERT && + unique_table(tl, table_list)) + { + my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name); + DBUG_RETURN(TRUE); + } } if (thd->fill_derived_tables() && mysql_handle_derived(lex, &mysql_derived_filling)) DBUG_RETURN(TRUE); + DBUG_RETURN (FALSE); } diff --git a/sql/sql_view.cc b/sql/sql_view.cc index e4f30f72443..be643c36d7d 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -88,14 +88,14 @@ bool mysql_create_view(THD *thd, #ifndef NO_EMBEDDED_ACCESS_CHECKS /* Privilege check for view creation: - - user have CREATE VIEW privilege on view table - - user have DELETE privilege in case of ALTER VIEW or CREATE OR REPLACE + - user has CREATE VIEW privilege on view table + - user has DROP privilege in case of ALTER VIEW or CREATE OR REPLACE VIEW - - have some (SELECT/UPDATE/INSERT/DELETE) privileges on columns of + - user has some (SELECT/UPDATE/INSERT/DELETE) privileges on columns of underlying tables used on top of SELECT list (because it can be (theoretically) updated, so it is enough to have UPDATE privilege on them, for example) - - have SELECT privilege on columns used in expressions of VIEW select + - user has SELECT privilege on columns used in expressions of VIEW select - for columns of underly tables used on top of SELECT list also will be checked that we have not more privileges on correspondent column of view table (i.e. user will not get some privileges by view creation) @@ -104,9 +104,9 @@ bool mysql_create_view(THD *thd, 0, 0) || grant_option && check_grant(thd, CREATE_VIEW_ACL, view, 0, 1, 0)) || (mode != VIEW_CREATE_NEW && - (check_access(thd, DELETE_ACL, view->db, &view->grant.privilege, + (check_access(thd, DROP_ACL, view->db, &view->grant.privilege, 0, 0) || - grant_option && check_grant(thd, DELETE_ACL, view, 0, 1, 0)))) + grant_option && check_grant(thd, DROP_ACL, view, 0, 1, 0)))) DBUG_RETURN(TRUE); for (sl= select_lex; sl; sl= sl->next_select()) { @@ -755,17 +755,17 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table) table->ancestor= view_tables; - /* next table should include SELECT_LEX under this table SELECT_LEX */ - table->ancestor->select_lex= table->select_lex; - /* Process upper level tables of view. As far as we do noy suport union here we can go through local tables of view most upper SELECT */ - for(tbl= (TABLE_LIST*)view_select->table_list.first; + for(tbl= view_tables; tbl; tbl= tbl->next_local) { + /* next table should include SELECT_LEX under this table SELECT_LEX */ + tbl->select_lex= table->select_lex; + /* move lock type (TODO: should we issue error in case of TMPTABLE algorithm and non-read locking)? diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 4924f78dc0a..9aa5d7fb4fc 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -47,13 +47,13 @@ const LEX_STRING null_lex_str={0,0}; #define yyoverflow(A,B,C,D,E,F) {ulong val= *(F); if(my_yyoverflow((B), (D), &val)) { yyerror((char*) (A)); return 2; } else { *(F)= (YYSIZE_T)val; }} -#define WARN_DEPRECATED(A,B) \ +#define WARN_DEPRECATED(A,B) \ push_warning_printf(((THD *)yythd), MYSQL_ERROR::WARN_LEVEL_WARN, \ - ER_WARN_DEPRECATED_SYNTAX, \ + ER_WARN_DEPRECATED_SYNTAX, \ ER(ER_WARN_DEPRECATED_SYNTAX), (A), (B)); -#define TEST_ASSERT(A) \ - if (!(A)) \ +#define TEST_ASSERT(A) \ + if (!(A)) \ { \ yyerror(ER(ER_SYNTAX_ERROR)); \ YYABORT; \ @@ -243,7 +243,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token DUPLICATE_SYM %token DYNAMIC_SYM %token EACH_SYM -%token EALLOCATE_SYM %token ELSEIF_SYM %token ELT_FUNC %token ENABLE_SYM @@ -702,7 +701,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); union_opt select_derived_init %type - ULONG_NUM raid_types merge_insert_types + ulong_num raid_types merge_insert_types %type ulonglong_num @@ -1039,16 +1038,16 @@ master_def: Lex->mi.password = $3.str; } | - MASTER_PORT_SYM EQ ULONG_NUM + MASTER_PORT_SYM EQ ulong_num { Lex->mi.port = $3; } | - MASTER_CONNECT_RETRY_SYM EQ ULONG_NUM + MASTER_CONNECT_RETRY_SYM EQ ulong_num { Lex->mi.connect_retry = $3; } - | MASTER_SSL_SYM EQ ULONG_NUM + | MASTER_SSL_SYM EQ ulong_num { Lex->mi.ssl= $3 ? LEX_MASTER_INFO::SSL_ENABLE : LEX_MASTER_INFO::SSL_DISABLE; @@ -1102,7 +1101,7 @@ master_file_def: { Lex->mi.relay_log_name = $3.str; } - | RELAY_LOG_POS_SYM EQ ULONG_NUM + | RELAY_LOG_POS_SYM EQ ulong_num { Lex->mi.relay_log_pos = $3; /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */ @@ -1329,12 +1328,12 @@ clear_privileges: ; sp_name: - IDENT_sys '.' IDENT_sys + ident '.' ident { $$= new sp_name($1, $3); $$->init_qname(YYTHD); } - | IDENT_sys + | ident { $$= sp_name_current_db_new(YYTHD, $1); } @@ -1682,7 +1681,6 @@ sp_decl: sp->add_instr(i); sp->push_backpatch(i, ctx->push_label((char *)"", 0)); - ctx->add_handler(); sp->m_in_handler= TRUE; } sp_hcond_list sp_proc_stmt @@ -1710,6 +1708,7 @@ sp_decl: sp->m_in_handler= FALSE; $$.vars= $$.conds= $$.curs= 0; $$.hndlrs= $6; + ctx->add_handlers($6); } | DECLARE_SYM ident CURSOR_SYM FOR_SYM sp_cursor_stmt { @@ -1775,24 +1774,48 @@ sp_hcond_list: { LEX *lex= Lex; sp_head *sp= lex->sphead; - sp_instr_hpush_jump *i= (sp_instr_hpush_jump *)sp->last_instruction(); + sp_pcontext *ctx= lex->spcont; - i->add_condition($1); - $$= 1; + if (ctx->find_handler($1)) + { + my_message(ER_SP_DUP_HANDLER, ER(ER_SP_DUP_HANDLER), MYF(0)); + YYABORT; + } + else + { + sp_instr_hpush_jump *i= + (sp_instr_hpush_jump *)sp->last_instruction(); + + i->add_condition($1); + ctx->push_handler($1); + $$= 1; + } } | sp_hcond_list ',' sp_hcond { LEX *lex= Lex; sp_head *sp= lex->sphead; - sp_instr_hpush_jump *i= (sp_instr_hpush_jump *)sp->last_instruction(); + sp_pcontext *ctx= lex->spcont; - i->add_condition($3); - $$= $1 + 1; + if (ctx->find_handler($3)) + { + my_message(ER_SP_DUP_HANDLER, ER(ER_SP_DUP_HANDLER), MYF(0)); + YYABORT; + } + else + { + sp_instr_hpush_jump *i= + (sp_instr_hpush_jump *)sp->last_instruction(); + + i->add_condition($3); + ctx->push_handler($3); + $$= $1 + 1; + } } ; sp_cond: - ULONG_NUM + ulong_num { /* mysql errno */ $$= (sp_cond_type_t *)YYTHD->alloc(sizeof(sp_cond_type_t)); $$->type= sp_cond_type_t::number; @@ -2578,18 +2601,18 @@ create_table_option: | TYPE_SYM opt_equal storage_engines { Lex->create_info.db_type= $3; WARN_DEPRECATED("TYPE=storage_engine","ENGINE=storage_engine"); Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE; } | MAX_ROWS opt_equal ulonglong_num { Lex->create_info.max_rows= $3; Lex->create_info.used_fields|= HA_CREATE_USED_MAX_ROWS;} | MIN_ROWS opt_equal ulonglong_num { Lex->create_info.min_rows= $3; Lex->create_info.used_fields|= HA_CREATE_USED_MIN_ROWS;} - | AVG_ROW_LENGTH opt_equal ULONG_NUM { Lex->create_info.avg_row_length=$3; Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;} + | AVG_ROW_LENGTH opt_equal ulong_num { Lex->create_info.avg_row_length=$3; Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;} | PASSWORD opt_equal TEXT_STRING_sys { Lex->create_info.password=$3.str; Lex->create_info.used_fields|= HA_CREATE_USED_PASSWORD; } | COMMENT_SYM opt_equal TEXT_STRING_sys { Lex->create_info.comment=$3.str; Lex->create_info.used_fields|= HA_CREATE_USED_COMMENT; } | AUTO_INC opt_equal ulonglong_num { Lex->create_info.auto_increment_value=$3; Lex->create_info.used_fields|= HA_CREATE_USED_AUTO;} - | PACK_KEYS_SYM opt_equal ULONG_NUM { Lex->create_info.table_options|= $3 ? HA_OPTION_PACK_KEYS : HA_OPTION_NO_PACK_KEYS; Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;} + | PACK_KEYS_SYM opt_equal ulong_num { Lex->create_info.table_options|= $3 ? HA_OPTION_PACK_KEYS : HA_OPTION_NO_PACK_KEYS; Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;} | PACK_KEYS_SYM opt_equal DEFAULT { Lex->create_info.table_options&= ~(HA_OPTION_PACK_KEYS | HA_OPTION_NO_PACK_KEYS); Lex->create_info.used_fields|= HA_CREATE_USED_PACK_KEYS;} - | CHECKSUM_SYM opt_equal ULONG_NUM { Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM; Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM; } - | DELAY_KEY_WRITE_SYM opt_equal ULONG_NUM { Lex->create_info.table_options|= $3 ? HA_OPTION_DELAY_KEY_WRITE : HA_OPTION_NO_DELAY_KEY_WRITE; Lex->create_info.used_fields|= HA_CREATE_USED_DELAY_KEY_WRITE; } + | CHECKSUM_SYM opt_equal ulong_num { Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM; Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM; } + | DELAY_KEY_WRITE_SYM opt_equal ulong_num { Lex->create_info.table_options|= $3 ? HA_OPTION_DELAY_KEY_WRITE : HA_OPTION_NO_DELAY_KEY_WRITE; Lex->create_info.used_fields|= HA_CREATE_USED_DELAY_KEY_WRITE; } | ROW_FORMAT_SYM opt_equal row_types { Lex->create_info.row_type= $3; Lex->create_info.used_fields|= HA_CREATE_USED_ROW_FORMAT; } | RAID_TYPE opt_equal raid_types { Lex->create_info.raid_type= $3; Lex->create_info.used_fields|= HA_CREATE_USED_RAID;} - | RAID_CHUNKS opt_equal ULONG_NUM { Lex->create_info.raid_chunks= $3; Lex->create_info.used_fields|= HA_CREATE_USED_RAID;} - | RAID_CHUNKSIZE opt_equal ULONG_NUM { Lex->create_info.raid_chunksize= $3*RAID_BLOCK_SIZE; Lex->create_info.used_fields|= HA_CREATE_USED_RAID;} + | RAID_CHUNKS opt_equal ulong_num { Lex->create_info.raid_chunks= $3; Lex->create_info.used_fields|= HA_CREATE_USED_RAID;} + | RAID_CHUNKSIZE opt_equal ulong_num { Lex->create_info.raid_chunksize= $3*RAID_BLOCK_SIZE; Lex->create_info.used_fields|= HA_CREATE_USED_RAID;} | UNION_SYM opt_equal '(' table_list ')' { /* Move the union list to the merge_list */ @@ -2666,7 +2689,7 @@ row_types: raid_types: RAID_STRIPED_SYM { $$= RAID_TYPE_0; } | RAID_0_SYM { $$= RAID_TYPE_0; } - | ULONG_NUM { $$=$1;}; + | ulong_num { $$=$1;}; merge_insert_types: NO_SYM { $$= MERGE_INSERT_DISABLED; } @@ -3909,7 +3932,6 @@ select_part2: { LEX *lex= Lex; SELECT_LEX *sel= lex->current_select; - lex->lock_option= TL_READ; if (sel->linkage != UNION_TYPE) mysql_init_select(lex); lex->current_select->parsing_place= SELECT_LIST; @@ -4575,14 +4597,16 @@ simple_expr: { $$= new Item_int((char*) "TRUE",1,1); } | ident '.' ident '(' udf_expr_list ')' { + LEX *lex= Lex; sp_name *name= new sp_name($1, $3); name->init_qname(YYTHD); - sp_add_to_hash(&Lex->spfuns, name); + sp_add_to_hash(&lex->spfuns, name); if ($5) $$= new Item_func_sp(name, *$5); else $$= new Item_func_sp(name); + lex->safe_to_cache_query=0; } | IDENT_sys '(' udf_expr_list ')' { @@ -4663,13 +4687,15 @@ simple_expr: else #endif /* HAVE_DLOPEN */ { + LEX *lex= Lex; sp_name *name= sp_name_current_db_new(YYTHD, $1); - sp_add_to_hash(&Lex->spfuns, name); + sp_add_to_hash(&lex->spfuns, name); if ($3) $$= new Item_func_sp(name, *$3); else $$= new Item_func_sp(name); + lex->safe_to_cache_query=0; } } | UNIQUE_USERS '(' text_literal ',' NUM ',' NUM ',' expr_list ')' @@ -4704,7 +4730,7 @@ simple_expr: { $$= new Item_func_yearweek($3,new Item_int((char*) "0",0,1)); } | YEARWEEK '(' expr ',' expr ')' { $$= new Item_func_yearweek($3, $5); } - | BENCHMARK_SYM '(' ULONG_NUM ',' expr ')' + | BENCHMARK_SYM '(' ulong_num ',' expr ')' { $$=new Item_func_benchmark($3,$5); Lex->uncacheable(UNCACHEABLE_SIDEEFFECT); @@ -4989,7 +5015,7 @@ table_ref: join_table_list: derived_table_list { TEST_ASSERT($$=$1); } ; - + /* Warning - may return NULL in case of incomplete SELECT */ derived_table_list: table_ref { $$=$1; } @@ -5033,7 +5059,7 @@ join_table: $$=$6; } | table_ref RIGHT opt_outer JOIN_SYM table_ref ON expr - { + { LEX *lex= Lex; TEST_ASSERT($1 && $5); if (!($$= lex->current_select->convert_right_join())) @@ -5047,7 +5073,7 @@ join_table: sel->save_names_for_using_list($1, $5); } USING '(' using_list ')' - { + { LEX *lex= Lex; if (!($$= lex->current_select->convert_right_join())) YYABORT; @@ -5063,7 +5089,7 @@ join_table: } | table_ref NATURAL JOIN_SYM table_factor { TEST_ASSERT($1 && ($$=$4)); add_join_natural($1,$4); }; - + normal_join: JOIN_SYM {} @@ -5109,9 +5135,9 @@ table_factor: sel->master_unit()->fake_select_lex; } if ($2->init_nested_join(lex->thd)) - YYABORT; + YYABORT; $$= 0; - /* incomplete derived tables return NULL, we must be + /* incomplete derived tables return NULL, we must be nested in select_derived rule to be here. */ } | '(' get_select_lex select_derived union_opt ')' opt_table_alias @@ -5119,7 +5145,7 @@ table_factor: /* Use $2 instead of Lex->current_select as derived table will alter value of Lex->current_select. */ - if (!($3 || $6) && $2->embedding && + if (!($3 || $6) && $2->embedding && !$2->embedding->nested_join->join_list.elements) { /* we have a derived table ($3 == NULL) but no alias, @@ -5144,7 +5170,7 @@ table_factor: (List *)0))) YYABORT; - sel->add_joined_table($$); + sel->add_joined_table($$); } else if ($4 || $6) @@ -5171,7 +5197,7 @@ select_derived: LEX *lex= Lex; /* for normal joins, $3 != NULL and end_nested_join() != NULL, for derived tables, both must equal NULL */ - + if (!($$= $1->end_nested_join(lex->thd)) && $3) YYABORT; if (!$3 && $$) @@ -5215,7 +5241,7 @@ select_derived_init: SELECT_SYM { LEX *lex= Lex; - SELECT_LEX *sel= lex->current_select; + SELECT_LEX *sel= lex->current_select; TABLE_LIST *embedding; if (!sel->embedding || sel->end_nested_join(lex->thd)) { @@ -5488,21 +5514,21 @@ limit_clause: ; limit_options: - ULONG_NUM + ulong_num { SELECT_LEX *sel= Select; sel->select_limit= $1; sel->offset_limit= 0L; sel->explicit_limit= 1; } - | ULONG_NUM ',' ULONG_NUM + | ulong_num ',' ulong_num { SELECT_LEX *sel= Select; sel->select_limit= $3; sel->offset_limit= $1; sel->explicit_limit= 1; } - | ULONG_NUM OFFSET_SYM ULONG_NUM + | ulong_num OFFSET_SYM ulong_num { SELECT_LEX *sel= Select; sel->select_limit= $1; @@ -5525,11 +5551,12 @@ delete_limit_clause: sel->explicit_limit= 1; }; -ULONG_NUM: - NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); } +ulong_num: + NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); } + | HEX_NUM { int error; $$= (ulong) strtol($1.str, (char**) 0, 16); } | LONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); } | ULONGLONG_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); } - | DECIMAL_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); } + | DECIMAL_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); } | FLOAT_NUM { int error; $$= (ulong) my_strtoll10($1.str, (char**) 0, &error); } ; @@ -6139,7 +6166,7 @@ show_param: | NEW_SYM MASTER_SYM FOR_SYM SLAVE WITH MASTER_LOG_FILE_SYM EQ TEXT_STRING_sys AND_SYM MASTER_LOG_POS_SYM EQ ulonglong_num AND_SYM MASTER_SERVER_ID_SYM EQ - ULONG_NUM + ulong_num { Lex->sql_command = SQLCOM_SHOW_NEW_MASTER; Lex->mi.log_file_name = $8.str; @@ -6688,7 +6715,7 @@ fields_or_vars: | field_or_var { Lex->field_list.push_back($1); } ; - + field_or_var: simple_ident_nospvar {$$= $1;} | '@' ident_or_text @@ -6836,9 +6863,9 @@ NUM_literal: } } ; - + /********************************************************************** -** Createing different items. +** Creating different items. **********************************************************************/ insert_ident: @@ -6854,8 +6881,8 @@ table_wild: | ident '.' ident '.' '*' { $$ = new Item_field((YYTHD->client_capabilities & - CLIENT_NO_SCHEMA ? NullS : $1.str), - $3.str,"*"); + CLIENT_NO_SCHEMA ? NullS : $1.str), + $3.str,"*"); Lex->current_select->with_wild++; } ; @@ -6898,53 +6925,53 @@ simple_ident_nospvar: (Item*) new Item_ref(NullS,NullS,$1.str); } | simple_ident_q { $$= $1; } - ; + ; simple_ident_q: ident '.' ident { THD *thd= YYTHD; LEX *lex= thd->lex; - + /* FIXME This will work ok in simple_ident_nospvar case because we can't meet simple_ident_nospvar in trigger now. But it should be changed in future. */ if (lex->sphead && lex->sphead->m_type == TYPE_ENUM_TRIGGER && - (!my_strcasecmp(system_charset_info, $1.str, "NEW") || + (!my_strcasecmp(system_charset_info, $1.str, "NEW") || !my_strcasecmp(system_charset_info, $1.str, "OLD"))) { Item_trigger_field *trg_fld; bool new_row= ($1.str[0]=='N' || $1.str[0]=='n'); - + if (lex->trg_chistics.event == TRG_EVENT_INSERT && !new_row) { my_error(ER_TRG_NO_SUCH_ROW_IN_TRG, MYF(0), "OLD", "on INSERT"); YYABORT; } - + if (lex->trg_chistics.event == TRG_EVENT_DELETE && new_row) { my_error(ER_TRG_NO_SUCH_ROW_IN_TRG, MYF(0), "NEW", "on DELETE"); YYABORT; } - + if (!(trg_fld= new Item_trigger_field(new_row ? Item_trigger_field::NEW_ROW: Item_trigger_field::OLD_ROW, $3.str))) YYABORT; - + /* Let us add this item to list of all Item_trigger_field objects in trigger. */ lex->trg_table_fields.link_in_list((byte *)trg_fld, (byte**)&trg_fld->next_trg_field); - + $$= (Item *)trg_fld; } else @@ -7020,9 +7047,10 @@ IDENT_sys: if (thd->charset_is_system_charset) { CHARSET_INFO *cs= system_charset_info; + int dummy_error; uint wlen= cs->cset->well_formed_len(cs, $1.str, $1.str+$1.length, - $1.length); + $1.length, &dummy_error); if (wlen < $1.length) { my_error(ER_INVALID_CHARACTER_STRING, MYF(0), @@ -7073,7 +7101,7 @@ ident: ; ident_or_text: - ident { $$=$1;} + ident { $$=$1;} | TEXT_STRING_sys { $$=$1;} | LEX_HOSTNAME { $$=$1;}; @@ -7250,7 +7278,7 @@ keyword: | MULTILINESTRING {} | MULTIPOINT {} | MULTIPOLYGON {} - | MUTEX_SYM {} + | MUTEX_SYM {} | NAME_SYM {} | NAMES_SYM {} | NATIONAL_SYM {} @@ -7342,8 +7370,8 @@ keyword: | TIMESTAMP_ADD {} | TIMESTAMP_DIFF {} | TIME_SYM {} - | TYPE_SYM {} | TYPES_SYM {} + | TYPE_SYM {} | UDF_RETURNS_SYM {} | FUNCTION_SYM {} | UNCOMMITTED_SYM {} @@ -8124,25 +8152,25 @@ grant_option_list: grant_option: GRANT OPTION { Lex->grant |= GRANT_ACL;} - | MAX_QUERIES_PER_HOUR ULONG_NUM + | MAX_QUERIES_PER_HOUR ulong_num { LEX *lex=Lex; lex->mqh.questions=$2; lex->mqh.specified_limits|= USER_RESOURCES::QUERIES_PER_HOUR; } - | MAX_UPDATES_PER_HOUR ULONG_NUM + | MAX_UPDATES_PER_HOUR ulong_num { LEX *lex=Lex; lex->mqh.updates=$2; lex->mqh.specified_limits|= USER_RESOURCES::UPDATES_PER_HOUR; } - | MAX_CONNECTIONS_PER_HOUR ULONG_NUM + | MAX_CONNECTIONS_PER_HOUR ulong_num { LEX *lex=Lex; lex->mqh.conn_per_hour= $2; lex->mqh.specified_limits|= USER_RESOURCES::CONNECTIONS_PER_HOUR; } - | MAX_USER_CONNECTIONS_SYM ULONG_NUM + | MAX_USER_CONNECTIONS_SYM ulong_num { LEX *lex=Lex; lex->mqh.user_conn= $2; @@ -8413,38 +8441,52 @@ check_option: xa: XA_SYM begin_or_start xid opt_join_or_resume { - LEX *lex= Lex; - lex->sql_command = SQLCOM_XA_START; + Lex->sql_command = SQLCOM_XA_START; } | XA_SYM END xid opt_suspend_or_migrate { - LEX *lex= Lex; - lex->sql_command = SQLCOM_XA_END; + Lex->sql_command = SQLCOM_XA_END; } | XA_SYM PREPARE_SYM xid { - LEX *lex= Lex; - lex->sql_command = SQLCOM_XA_PREPARE; + Lex->sql_command = SQLCOM_XA_PREPARE; } | XA_SYM COMMIT_SYM xid opt_one_phase { - LEX *lex= Lex; - lex->sql_command = SQLCOM_XA_COMMIT; + Lex->sql_command = SQLCOM_XA_COMMIT; } | XA_SYM ROLLBACK_SYM xid { - LEX *lex= Lex; - lex->sql_command = SQLCOM_XA_ROLLBACK; + Lex->sql_command = SQLCOM_XA_ROLLBACK; } | XA_SYM RECOVER_SYM { - LEX *lex= Lex; - lex->sql_command = SQLCOM_XA_RECOVER; + Lex->sql_command = SQLCOM_XA_RECOVER; } ; -xid: ident_or_text { Lex->ident=$1; } - ; +xid: text_string + { + TEST_ASSERT($1->length() <= MAXGTRIDSIZE); + if (!(Lex->xid=(XID *)YYTHD->alloc(sizeof(XID)))) + YYABORT; + Lex->xid->set(1L, $1->ptr(), $1->length(), 0, 0); + } + | text_string ',' text_string + { + TEST_ASSERT($1->length() <= MAXGTRIDSIZE && $3->length() <= MAXBQUALSIZE); + if (!(Lex->xid=(XID *)YYTHD->alloc(sizeof(XID)))) + YYABORT; + Lex->xid->set(1L, $1->ptr(), $1->length(), $3->ptr(), $3->length()); + } + | text_string ',' text_string ',' ulong_num + { + TEST_ASSERT($1->length() <= MAXGTRIDSIZE && $3->length() <= MAXBQUALSIZE); + if (!(Lex->xid=(XID *)YYTHD->alloc(sizeof(XID)))) + YYABORT; + Lex->xid->set($5, $1->ptr(), $1->length(), $3->ptr(), $3->length()); + } + ; begin_or_start: BEGIN_SYM {} | START_SYM {} diff --git a/sql/table.cc b/sql/table.cc index 9238d8aa68e..8e0f52e1910 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -568,7 +568,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, goto err; /* purecov: inspected */ } reg_field->comment=comment; - if (field_type == FIELD_TYPE_BIT) + if (field_type == FIELD_TYPE_BIT && !f_bit_as_char(pack_flag)) { if ((null_bit_pos+= field_length & 7) > 7) { @@ -1716,7 +1716,7 @@ void st_table_list::restore_want_privilege() check_opt_type - WHITH CHECK OPTION type (VIEW_CHECK_NONE, VIEW_CHECK_LOCAL, VIEW_CHECK_CASCADED) NOTES - ancestor is list of tables and views used by view + ancestor is list of tables and views used by view (underlying tables/views) DESCRIPTION It is: @@ -1750,6 +1750,9 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds, bool res= FALSE; DBUG_ENTER("st_table_list::setup_ancestor"); + if (check_stack_overrun(thd, (char *)&res)) + return TRUE; + for (tbl= ancestor; tbl; tbl= tbl->next_local) { if (tbl->ancestor && @@ -1986,6 +1989,34 @@ ok: } +/* + Find underlying base tables (TABLE_LIST) which represent given + table_to_find (TABLE) + + SYNOPSIS + st_table_list::find_underlying_table() + table_to_find table to find + + RETURN + 0 table is not found + found table reference +*/ + +st_table_list *st_table_list::find_underlying_table(TABLE *table_to_find) +{ + /* is this real table and table which we are looking for? */ + if (table == table_to_find && ancestor == 0) + return this; + + for (TABLE_LIST *tbl= ancestor; tbl; tbl= tbl->next_local) + { + TABLE_LIST *result; + if ((result= tbl->find_underlying_table(table_to_find))) + return result; + } + return 0; +} + /* cleunup items belonged to view fields translation table diff --git a/sql/table.h b/sql/table.h index fd299759678..270ec313240 100644 --- a/sql/table.h +++ b/sql/table.h @@ -376,7 +376,7 @@ typedef struct st_table_list st_select_lex *select_lex; st_lex *view; /* link on VIEW lex for merging */ Field_translator *field_translation; /* array of VIEW fields */ - /* ancestor of this table (VIEW merge algorithm) */ + /* list of ancestor(s) of this table (underlying table(s)/view(s) */ st_table_list *ancestor; /* most upper view this table belongs to */ st_table_list *belong_to_view; @@ -448,6 +448,7 @@ typedef struct st_table_list void restore_want_privilege(); bool check_single_table(st_table_list **table, table_map map); bool set_insert_values(MEM_ROOT *mem_root); + st_table_list *find_underlying_table(TABLE *table); } TABLE_LIST; class Item; diff --git a/sql/time.cc b/sql/time.cc index f1d21915c23..a3ec2283860 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -186,6 +186,7 @@ ulong convert_month_to_period(ulong month) NOTE See description of str_to_datetime() for more information. */ + timestamp_type str_to_datetime_with_warn(const char *str, uint length, TIME *l_time, uint flags) @@ -199,7 +200,7 @@ str_to_datetime_with_warn(const char *str, uint length, TIME *l_time, (MODE_INVALID_DATES | MODE_NO_ZERO_DATE))), &was_cut); - if (was_cut) + if (was_cut || ts_type <= MYSQL_TIMESTAMP_ERROR) make_truncated_value_warning(current_thd, str, length, ts_type, NullS); return ts_type; } @@ -712,9 +713,9 @@ void make_truncated_value_warning(THD *thd, const char *str_val, else cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff), ER(ER_TRUNCATED_WRONG_VALUE), - type_str, str.ptr()); - push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, - ER_TRUNCATED_WRONG_VALUE, warn_buff); + type_str, str.c_ptr()); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_TRUNCATED_WRONG_VALUE, warn_buff); } diff --git a/sql/unireg.cc b/sql/unireg.cc index 3e85767dc86..929ca5c672e 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -40,7 +40,7 @@ static bool pack_header(uchar *forminfo,enum db_type table_type, static uint get_interval_id(uint *int_count,List &create_fields, create_field *last_field); static bool pack_fields(File file, List &create_fields); -static bool make_empty_rec(int file, enum db_type table_type, +static bool make_empty_rec(THD *thd, int file, enum db_type table_type, uint table_options, List &create_fields, uint reclength,uint null_fields); @@ -134,7 +134,7 @@ bool mysql_create_frm(THD *thd, my_string file_name, VOID(my_seek(file, (ulong) uint2korr(fileinfo+6)+ (ulong) key_buff_length, MY_SEEK_SET,MYF(0))); - if (make_empty_rec(file,create_info->db_type,create_info->table_options, + if (make_empty_rec(thd,file,create_info->db_type,create_info->table_options, create_fields,reclength,null_fields)) goto err; @@ -640,7 +640,7 @@ static bool pack_fields(File file,List &create_fields) /* save an empty record on start of formfile */ -static bool make_empty_rec(File file,enum db_type table_type, +static bool make_empty_rec(THD *thd, File file,enum db_type table_type, uint table_options, List &create_fields, uint reclength, uint null_fields) @@ -652,6 +652,7 @@ static bool make_empty_rec(File file,enum db_type table_type, TABLE table; create_field *field; handler *handler; + enum_check_fields old_count_cuted_fields= thd->count_cuted_fields; DBUG_ENTER("make_empty_rec"); /* We need a table to generate columns for default values */ @@ -666,7 +667,7 @@ static bool make_empty_rec(File file,enum db_type table_type, DBUG_RETURN(1); } - table.in_use= current_thd; + table.in_use= thd; table.s->db_low_byte_first= handler->low_byte_first(); table.s->blob_ptr_size= portable_sizeof_char_ptr; @@ -678,14 +679,14 @@ static bool make_empty_rec(File file,enum db_type table_type, null_count++; } bfill(buff,(null_length=(null_fields+7)/8),255); - null_pos=buff; + null_pos= buff + null_count / 8; List_iterator it(create_fields); + thd->count_cuted_fields= CHECK_FIELD_WARN; // To find wrong default values while ((field=it++)) { Field *regfield=make_field((char*) buff+field->offset,field->length, - field->flags & NOT_NULL_FLAG ? 0: - null_pos+null_count/8, + null_pos, null_count & 7, field->pack_flag, field->sql_type, @@ -709,7 +710,14 @@ static bool make_empty_rec(File file,enum db_type table_type, if (field->def && (regfield->real_type() != FIELD_TYPE_YEAR || field->def->val_int() != 0)) - (void) field->def->save_in_field(regfield, 1); + { + if (field->def->save_in_field(regfield, 1)) + { + my_error(ER_INVALID_DEFAULT, MYF(0), regfield->field_name); + error= 1; + goto err; + } + } else if (regfield->real_type() == FIELD_TYPE_ENUM && (field->flags & NOT_NULL_FLAG)) { @@ -728,7 +736,10 @@ static bool make_empty_rec(File file,enum db_type table_type, /* Fill not used startpos */ bfill((byte*) buff+null_length,firstpos-null_length,255); error=(int) my_write(file,(byte*) buff,(uint) reclength,MYF_RW); + +err: my_free((gptr) buff,MYF(MY_FAE)); delete handler; + thd->count_cuted_fields= old_count_cuted_fields; DBUG_RETURN(error); } /* make_empty_rec */ diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 336b5f0e832..ab6691e68b0 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -6294,10 +6294,13 @@ my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)), */ static uint my_well_formed_len_big5(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e, uint pos) + const char *b, const char *e, + uint pos, int *error) { const char *b0= b; const char *emb= e - 1; /* Last possible end of an MB character */ + + *error= 0; while (pos && b < e) { if ((uchar) b[0] < 128) @@ -6313,6 +6316,7 @@ uint my_well_formed_len_big5(CHARSET_INFO *cs __attribute__((unused)), else { /* Wrong byte sequence */ + *error= 1; break; } } diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index c47f2c2d8ce..47bf1167c8c 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -5413,9 +5413,10 @@ uint my_numcells_cp932(CHARSET_INFO *cs __attribute__((unused)), */ static uint my_well_formed_len_cp932(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e, uint pos) + const char *b, const char *e, uint pos, int *error) { const char *b0= b; + *error= 0; while (pos && b < e) { /* @@ -5441,6 +5442,7 @@ uint my_well_formed_len_cp932(CHARSET_INFO *cs __attribute__((unused)), else { /* Wrong byte sequence */ + *error= 1; break; } } diff --git a/strings/ctype-eucjpms.c b/strings/ctype-eucjpms.c index 8c8d237cf48..ab12446754a 100644 --- a/strings/ctype-eucjpms.c +++ b/strings/ctype-eucjpms.c @@ -8380,17 +8380,18 @@ my_jisx0212_uni_onechar(int code){ /* EUC-JP encoding subcomponents: - [x00-x7F] # ASCII/JIS-Roman (one-byte/character) - [x8E][xA0-xDF] # half-width katakana (two bytes/char) - [x8F][xA1-xFE][xA1-xFE] # JIS X 0212-1990 (three bytes/char) + [x00-x7F] # ASCII/JIS-Roman (one-byte/character) + [x8E][xA0-xDF] # half-width katakana (two bytes/char) + [x8F][xA1-xFE][xA1-xFE] # JIS X 0212-1990 (three bytes/char) [xA1-xFE][xA1-xFE] # JIS X 0208:1997 (two bytes/char) */ static uint my_well_formed_len_eucjpms(CHARSET_INFO *cs __attribute__((unused)), - const char *beg, const char *end, uint pos) + const char *beg, const char *end, uint pos, int *error) { const uchar *b= (uchar *) beg; + *error=0; for ( ; pos && b < (uchar*) end; pos--, b++) { @@ -8408,6 +8409,7 @@ uint my_well_formed_len_eucjpms(CHARSET_INFO *cs __attribute__((unused)), { if (*b >= 0xA0 && *b <= 0xDF) continue; + *error=1; return chbeg - beg; /* invalid sequence */ } @@ -8415,12 +8417,16 @@ uint my_well_formed_len_eucjpms(CHARSET_INFO *cs __attribute__((unused)), { ch= *b++; if (b >= (uchar*) end) + { + *error= 1; return chbeg - beg; /* unexpected EOL */ + } } if (ch >= 0xA1 && ch <= 0xFE && *b >= 0xA1 && *b <= 0xFE) /* [xA1-xFE][xA1-xFE] */ continue; + *error=1; return chbeg - beg; /* invalid sequence */ } return b - (uchar *) beg; diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index a9edb35d8a4..b603a8ea0a8 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -264,18 +264,21 @@ uint my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)), } -uint my_well_formed_len_mb(CHARSET_INFO *cs, - const char *b, const char *e, uint pos) +uint my_well_formed_len_mb(CHARSET_INFO *cs, const char *b, const char *e, + uint pos, int *error) { const char *b_start= b; - + *error= 0; while (pos) { my_wc_t wc; int mblen; if ((mblen= cs->cset->mb_wc(cs, &wc, (uchar*) b, (uchar*) e)) <= 0) + { + *error= b < e ? 1 : 0; break; + } b+= mblen; pos--; } diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 91888771c80..5fa1a1b18a0 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -1122,11 +1122,11 @@ uint my_charpos_8bit(CHARSET_INFO *cs __attribute__((unused)), uint my_well_formed_len_8bit(CHARSET_INFO *cs __attribute__((unused)), - const char *start, - const char *end, - uint nchars) + const char *start, const char *end, + uint nchars, int *error) { uint nbytes= (uint) (end-start); + *error= 0; return min(nbytes, nchars); } diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index 9a54fe5595b..62cb5427dd9 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4586,9 +4586,11 @@ uint my_numcells_sjis(CHARSET_INFO *cs __attribute__((unused)), */ static uint my_well_formed_len_sjis(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e, uint pos) + const char *b, const char *e, + uint pos, int *error) { const char *b0= b; + *error= 0; while (pos && b < e) { if ((uchar) b[0] < 128) @@ -4609,6 +4611,7 @@ uint my_well_formed_len_sjis(CHARSET_INFO *cs __attribute__((unused)), else { /* Wrong byte sequence */ + *error= 1; break; } } diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 80fe0167cdd..3204bd2e1f6 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -6651,8 +6651,7 @@ static const char slovak[]= static const char spanish2[]= /* Also good for Asturian and Galician */ "&C < ch <<< Ch <<< CH" "&L < ll <<< Ll <<< LL" - "&N < \\u00F1 <<< \\u00D1" - "&R << rr <<< Rr <<< RR"; + "&N < \\u00F1 <<< \\u00D1"; static const char roman[]= /* i.e. Classical Latin */ "& I << j <<< J " diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 72483ce5c4c..73d15da8a4a 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1273,11 +1273,11 @@ uint my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)), static uint my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *b, - const char *e, - uint nchars) + const char *b, const char *e, + uint nchars, int *error) { uint nbytes= (e-b) & ~ (uint)1; + *error= 0; nchars*= 2; return min(nbytes, nchars); } diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index deaddcc76f6..7bcf1c83bab 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -8253,11 +8253,12 @@ my_jisx0212_uni_onechar(int code){ static uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)), - const char *beg, const char *end, uint pos) + const char *beg, const char *end, + uint pos, int *error) { const uchar *b= (uchar *) beg; - for ( ; pos && b < (uchar*) end; pos--, b++) + for ( *error= 0 ; pos && b < (uchar*) end; pos--, b++) { char *chbeg; uint ch= *b; @@ -8267,12 +8268,16 @@ uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)), chbeg= (char *) b++; if (b >= (uchar *) end) /* need more bytes */ + { + *error= 1; return chbeg - beg; /* unexpected EOL */ + } if (ch == 0x8E) /* [x8E][xA0-xDF] */ { if (*b >= 0xA0 && *b <= 0xDF) continue; + *error= 1; return chbeg - beg; /* invalid sequence */ } @@ -8280,12 +8285,16 @@ uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)), { ch= *b++; if (b >= (uchar*) end) + { + *error= 1; return chbeg - beg; /* unexpected EOL */ + } } if (ch >= 0xA1 && ch <= 0xFE && *b >= 0xA1 && *b <= 0xFE) /* [xA1-xFE][xA1-xFE] */ continue; + *error= 1; return chbeg - beg; /* invalid sequence */ } return b - (uchar *) beg; diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index e8b7a5e9e81..14b3934e815 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -2405,7 +2405,7 @@ CHARSET_INFO my_charset_utf8_bin= &my_collation_mb_bin_handler }; -#ifdef HAVE_CYBOZU_COLLATION +#ifdef HAVE_UTF8_GENERAL_CS /* * These functions bacically do the same as their original, except diff --git a/strings/decimal.c b/strings/decimal.c index 56dba61d887..9af95511f6d 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -806,7 +806,7 @@ internal_str2dec(const char *from, decimal_t *to, char **end, my_bool fixed) if (s < end_of_string && *s=='.') { endp= s+1; - while (s < end_of_string && my_isdigit(&my_charset_latin1, *endp)) + while (endp < end_of_string && my_isdigit(&my_charset_latin1, *endp)) endp++; frac= endp - s - 1; } diff --git a/support-files/MacOSX/Makefile.am b/support-files/MacOSX/Makefile.am index 6babcf97b7a..b521d357022 100644 --- a/support-files/MacOSX/Makefile.am +++ b/support-files/MacOSX/Makefile.am @@ -38,8 +38,7 @@ CLEANFILES = Info.plist \ Description.plist \ StartupParameters.plist \ postinstall \ - preinstall \ - ReadMe.txt + preinstall SUFFIXES = .sh diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index 2735ad91c6e..071b7696908 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -48,15 +48,21 @@ datadir= # Set some defaults pid_file= +server_pid_file= +use_mysqld_safe=1 +user=@MYSQLD_USER@ if test -z "$basedir" then basedir=@prefix@ bindir=@bindir@ datadir=@localstatedir@ sbindir=@sbindir@ + libexecdir=@libexecdir@ else bindir="$basedir/bin" - sbindir="$basedir/sbin" + datadir="$basedir/data" + sbindir="$basedir/bin" + libexecdir="$basedir/bin" fi # @@ -66,8 +72,14 @@ lsb_functions="/lib/lsb/init-functions" if test -f $lsb_functions ; then source $lsb_functions else - alias log_success_msg="echo \ SUCCESS! " - alias log_failure_msg="echo \ ERROR! " + log_success_msg() + { + echo " SUCCESS! $@" + } + log_failure_msg() + { + echo " ERROR! $@" + } fi PATH=/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin @@ -84,8 +96,17 @@ esac parse_server_arguments() { for arg do case "$arg" in - --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` + bindir="$basedir/bin" + datadir="$basedir/data" + sbindir="$basedir/bin" + libexecdir="$basedir/bin" + ;; --datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --pid-file=*) server_pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --use-mysqld_safe) use_mysqld_safe=1;; + --use-manager) use_mysqld_safe=0;; esac done } @@ -94,6 +115,7 @@ parse_manager_arguments() { for arg do case "$arg" in --pid-file=*) pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; esac done } @@ -165,17 +187,22 @@ else fi # -# Test if someone changed datadir; In this case we should also read the -# default arguments from this directory +# Read defaults file from 'basedir'. If there is no defaults file there +# check if it's in the old (depricated) place (datadir) and read it from there # extra_args="" -if test "$datadir" != "@localstatedir@" +if test -r "$basedir/my.cnf" then - extra_args="-e $datadir/my.cnf" + extra_args="-e $basedir/my.cnf" +else + if test -r "$datadir/my.cnf" + then + extra_args="-e $datadir/my.cnf" + fi fi -parse_server_arguments `$print_defaults $extra_args mysqld` +parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server` # Look for the pidfile parse_manager_arguments `$print_defaults $extra_args manager` @@ -192,9 +219,15 @@ else * ) pid_file="$datadir/$pid_file" ;; esac fi - -user=@MYSQLD_USER@ -USER_OPTION="--user=$user" +if test -z "$server_pid_file" +then + server_pid_file=$datadir/`@HOSTNAME@`.pid +else + case "$server_pid_file" in + /* ) ;; + * ) server_pid_file="$datadir/$server_pid_file" ;; + esac +fi # Safeguard (relative paths, core dumps..) cd $basedir @@ -203,12 +236,21 @@ case "$mode" in 'start') # Start daemon - if test -x $sbindir/mysqlmanager + manager=$bindir/mysqlmanager + if test -x $libexecdir/mysqlmanager + then + manager=$libexecdir/mysqlmanager + elif test -x $bindir/mysqlmanager + then + manager=$sbindir/mysqlmanager + fi + + echo $echo_n "Starting MySQL" + if test -x $manager -a "$use_mysqld_safe" = "0" then # Give extra arguments to mysqld with the my.cnf file. This script may # be overwritten at next upgrade. - echo $echo_n "Starting MySQL" - $sbindir/mysqlmanager $USER_OPTION --pid-file=$pid_file >/dev/null 2>&1 & + $manager --user=$user --pid-file=$pid_file >/dev/null 2>&1 & wait_for_pid created # Make lock for RedHat / SuSE @@ -216,14 +258,38 @@ case "$mode" in then touch /var/lock/subsys/mysqlmanager fi + elif test -x $bindir/mysqld_safe + then + # Give extra arguments to mysqld with the my.cnf file. This script + # may be overwritten at next upgrade. + pid_file=$server_pid_file + $bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file >/dev/null 2>&1 & + wait_for_pid created + + # Make lock for RedHat / SuSE + if test -w /var/lock/subsys + then + touch /var/lock/subsys/mysql + fi else - log_failure_msg "Can't execute $sbindir/mysqlmanager" + log_failure_msg "Couldn't find MySQL manager or server" fi ;; 'stop') # Stop daemon. We use a signal here to avoid having to know the # root password. + + # The RedHat / SuSE lock directory to remove + lock_dir=/var/lock/subsys/mysqlmanager + + # If the manager pid_file doesn't exist, try the server's + if test ! -s "$pid_file" + then + pid_file=$server_pid_file + lock_dir=/var/lock/subsys/mysql + fi + if test -s "$pid_file" then mysqlmanager_pid=`cat $pid_file` @@ -233,12 +299,12 @@ case "$mode" in wait_for_pid removed # delete lock for RedHat / SuSE - if test -f /var/lock/subsys/mysqlmanager + if test -f $lock_dir then - rm -f /var/lock/subsys/mysqlmanager + rm -f $lock_dir fi else - log_failure_msg "mysqlmanager PID file could not be found!" + log_failure_msg "MySQL manager or server PID file could not be found!" fi ;; @@ -249,9 +315,19 @@ case "$mode" in $0 start ;; + 'reload') + if test -s "$server_pid_file" ; then + mysqld_pid=`cat $server_pid_file` + kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL" + touch $server_pid_file + else + log_failure_msg "MySQL PID file could not be found!" + fi + ;; + *) # usage - echo "Usage: $0 start|stop|restart" + echo "Usage: $0 start|stop|restart|reload" exit 1 ;; esac diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index bad340e9de1..9568e4b291b 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -363,11 +363,6 @@ fi (cd libmysql/.libs; tar cf $RBR/shared-libs.tar *.so*) (cd libmysql_r/.libs; tar rf $RBR/shared-libs.tar *.so*) -# Save manual to avoid rebuilding -mv Docs/manual.ps Docs/manual.ps.save -make clean -mv Docs/manual.ps.save Docs/manual.ps - # # Only link statically on our i386 build host (which has a specially # patched static glibc installed) - ia64 and x86_64 run glibc-2.3 (unpatched) @@ -535,8 +530,6 @@ fi %defattr(-,root,root,0755) %doc COPYING README -%doc Docs/manual.{html,ps,texi,txt} -%doc Docs/manual_toc.html %doc support-files/my-*.cnf %doc support-files/ndb-*.ini @@ -675,9 +668,9 @@ fi %defattr(-, root, root, 0755) %attr(-, root, root) %{_datadir}/sql-bench %attr(-, root, root) %{_datadir}/mysql-test -%attr(755, root, root) %{_bindir}/mysqlmanager -%attr(755, root, root) %{_bindir}/mysqlmanager-pwgen -%attr(755, root, root) %{_bindir}/mysqlmanagerc +%attr(755, root, root) %{_bindir}/mysqltestmanager +%attr(755, root, root) %{_bindir}/mysqltestmanager-pwgen +%attr(755, root, root) %{_bindir}/mysqltestmanagerc %files Max %defattr(-, root, root, 0755) @@ -692,6 +685,16 @@ fi # itself - note that they must be ordered by date (important when # merging BK trees) %changelog +* Wed Apr 13 2005 Lenz Grimmer + +- removed the MySQL manual files (html/ps/texi) - they have been removed + from the MySQL sources and are now available seperately. + +* Mon Apr 4 2005 Petr Chardin + +- old mysqlmanager, mysqlmanagerc and mysqlmanager-pwger renamed into + mysqltestmanager, mysqltestmanager and mysqltestmanager-pwgen respectively + * Fri Mar 18 2005 Lenz Grimmer - Disabled RAID in the Max binaries once and for all (it has finally been diff --git a/tests/mail_to_db.pl b/tests/mail_to_db.pl index dc40fb3ede6..5ceda392313 100755 --- a/tests/mail_to_db.pl +++ b/tests/mail_to_db.pl @@ -17,7 +17,7 @@ use DBI; use Getopt::Long; $| = 1; -$VER = "2.6"; +$VER = "3.0"; $opt_help = 0; $opt_version = 0; @@ -26,7 +26,6 @@ $opt_host = undef(); $opt_port = undef(); $opt_socket = undef(); $opt_db = "mail"; -$opt_table = "mails"; $opt_user = undef(); $opt_password = undef(); $opt_max_mail_size = 65536; @@ -97,7 +96,7 @@ sub main print "the my.cnf file. This command is available from the latest MySQL\n"; print "distribution.\n"; } - GetOptions("help","version","host=s","port=i","socket=s","db=s","table=s", + GetOptions("help","version","host=s","port=i","socket=s","db=s", "user=s","password=s","max_mail_size=i","create","test", "no_path","debug","stop_on_error","stdin") || die "Wrong option! See $progname --help\n"; @@ -123,7 +122,6 @@ sub main || die "Couldn't connect: $DBI::errstr\n"; die "You must specify the database; use --db=" if (!defined($opt_db)); - die "You must specify the table; use --table=" if (!defined($opt_table)); create_table($dbh) if ($opt_create); @@ -218,9 +216,9 @@ sub main print "Total number of mails:\t\t\t\t"; print $mail_inserted + $ignored; print " (OK: "; - print sprintf("%.1f", (($mail_inserted / ($mail_inserted+$ignored)) * 100)); + print sprintf("%.1f", ($mail_inserted + $ignored) ? (($mail_inserted / ($mail_inserted+$ignored)) * 100) : 0.0); print "% Ignored: "; - print sprintf("%.1f", (($ignored / ($mail_inserted + $ignored)) * 100)); + print sprintf("%.1f", ($mail_inserted + $ignored) ? (($ignored / ($mail_inserted + $ignored)) * 100) : 0); print "%)\n"; print "################################ End Report ##################################\n"; exit(0); @@ -232,13 +230,15 @@ sub main sub create_table { - my ($dbh) = @_; + my ($dbh)= @_; my ($sth, $query); - $query = <)\s*/$1/; + $values{$type} = $1; + } + elsif (/^In-Reply-To:\s*(.*)/i) + { + $type = "in_reply_to"; + s/^\s*(<.*>)\s*/$1/; + $values{$type} = $1; + } elsif (/^Date: (.*)/i) { date_parser($1, \%values, $file_name); $type = "rubbish"; } - elsif (/^[\w\W-]+:\s/) + # Catch those fields that we don't or can't handle (yet) + elsif (/^[\w\W-]+:/) { - $type = "rubbish"; + $type = "rubbish"; } elsif ($_ eq "") { @@ -319,6 +334,10 @@ sub process_mail_file else { s/^\s*/ /; + if ($type eq 'message_id' || $type eq 'in_reply_to') + { + s/^\s*(<.*>)\s*/$1/; + } $values{$type} .= $_; } } @@ -421,8 +440,10 @@ sub update_table goto restart; # Some mails may have duplicated messages } - $q = "INSERT INTO $opt_table ("; + $q = "INSERT INTO my_mail ("; $q.= "mail_id,"; + $q.= "message_id,"; + $q.= "in_reply_to,"; $q.= "date,"; $q.= "time_zone,"; $q.= "mail_from,"; @@ -435,6 +456,12 @@ sub update_table $q.= "hash"; $q.= ") VALUES ("; $q.= "NULL,"; + $q.= (defined($values->{'message_id'}) ? + $dbh->quote($values->{'message_id'}) : "NULL"); + $q.= ","; + $q.= (defined($values->{'in_reply_to'}) ? + $dbh->quote($values->{'in_reply_to'}) : "NULL"); + $q.= ","; $q.= "'" . $values->{'date'} . "',"; $q.= (defined($values->{'time_zone'}) ? $dbh->quote($values->{'time_zone'}) : "NULL"); @@ -575,7 +602,6 @@ Options: --port=# TCP/IP port to be used with connection. --socket=... MySQL UNIX socket to be used with connection. --db=... Database to be used. ---table=... Table name for mails. --user=... Username for connecting. --password=... Password for the user. --stdin Read mails from stdin. diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 0f117b640c3..9b7c8281043 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -253,7 +253,12 @@ static void client_connect() mysql_autocommit(mysql, TRUE); if (!opt_silent) + { + fprintf(stdout, "\nConnected to MySQL server version: %s (%lu)\n", + mysql_get_server_info(mysql), + (ulong) mysql_get_server_version(mysql)); fprintf(stdout, "\n Creating a test database '%s' ...", current_db); + } strxmov(query, "CREATE DATABASE IF NOT EXISTS ", current_db, NullS); rc= mysql_query(mysql, query); @@ -3649,8 +3654,8 @@ static void test_bind_result_ext1() check_execute(stmt, rc); rc= mysql_stmt_fetch(stmt); - DIE_UNLESS(rc == MYSQL_DATA_TRUNCATED); - DIE_UNLESS(bind[4].error_value == 1); + printf("rc=%d\n", rc); + DIE_UNLESS(rc == 0); if (!opt_silent) { @@ -12457,7 +12462,6 @@ static void test_truncation() /* double -> longlong: fractional part is lost */ DIE_UNLESS(++bind < bind_array + bind_count); - DIE_UNLESS(*bind->error && * (longlong*) bind->buffer == 123); /* double -> ulonglong, negative fp number to unsigned integer */ DIE_UNLESS(++bind < bind_array + bind_count); @@ -12662,7 +12666,7 @@ static void test_view_sp_list_fields() int rc; MYSQL_RES *res; - myheader("test_view_insert_fields"); + myheader("test_view_sp_list_fields"); rc= mysql_query(mysql, "DROP FUNCTION IF EXISTS f1"); myquery(rc); diff --git a/tests/pmail.pl b/tests/pmail.pl index c7f8d4ee368..02d5d60ac0f 100755 --- a/tests/pmail.pl +++ b/tests/pmail.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/perl -w # # Prints mails to standard output # @@ -9,21 +9,25 @@ use DBI; use Getopt::Long; -$VER="1.5"; +$VER="2.0"; @fldnms= ("mail_from","mail_to","cc","date","time_zone","file","sbj","txt"); -$fields=8; -@mail= (@from,@to,@cc,@date,@time_zone,@file,@sbj,@txt); +my $fields= 0; +my $base_q= ""; +my $mail_count= 0; $opt_user= $opt_password= ""; $opt_socket= "/tmp/mysql.sock"; $opt_port= 3306; $opt_db="mail"; -$opt_table="mails"; +$opt_table="my_mail"; $opt_help=$opt_count=0; +$opt_thread= 0; +$opt_host= ""; +$opt_message_id= 0; GetOptions("help","count","port=i","db=s","table=s","host=s","password=s", - "user=s","socket=s") || usage(); + "user=s","socket=s", "thread","message_id") || usage(); if ($opt_host eq '') { @@ -39,81 +43,194 @@ if ($opt_help || !$ARGV[0]) #### Connect and parsing the query to MySQL #### -$dbh= DBI->connect("DBI:mysql:$opt_db:$opt_host:port=$opt_port:mysql_socket=$opt_mysql_socket", $opt_user,$opt_password, { PrintError => 0}) +$dbh= DBI->connect("DBI:mysql:$opt_db:$opt_host:port=$opt_port:mysql_socket=$opt_socket", $opt_user,$opt_password, { PrintError => 0}) || die $DBI::errstr; -if ($opt_count) +main(); + +#### +#### main +#### + +sub main { - count_mails(); + my ($row, $val, $q, $mail, $sth); + + if ($opt_count) + { + count_mails(); + } + + $base_q= "SELECT "; + foreach $val (@fldnms) + { + if (!$fields) + { + $base_q.= "$val"; + } + else + { + $base_q.= ",$val"; + } + $fields++; + } + $base_q.= ",message_id" if ($opt_thread || $opt_message_id); + $base_q.= " FROM $opt_table"; + $q= " WHERE $ARGV[0]"; + + $sth= $dbh->prepare($base_q . $q); + if (!$sth->execute) + { + print "$DBI::errstr\n"; + $sth->finish; + die; + } + for (; ($row= $sth->fetchrow_arrayref); $mail_count++) + { + for ($i= 0; $i < $fields; $i++) + { + if ($opt_message_id) + { + $mail[$fields][$mail_count]= $row->[$fields]; + $mail[$fields][$mail_count].= "\nNumber of Replies: " . get_nr_replies($row->[$fields]); + } + $mail[$i][$mail_count]= $row->[$i]; + } + if ($opt_thread) + { + get_mail_by_message_id($row->[$fields], $mail); + } + } + print_mails($mail); } -$fields=0; -$query = "select "; -foreach $val (@fldnms) +#### +#### Function, which fetches mail by searching in-reply-to with +#### a given message_id. Saves the value (mail) in mail variable. +#### Returns the message id of the mail found and searches again +#### and saves, until no more mails are found with that message_id. +#### + +sub get_mail_by_message_id { - if (!$fields) + my ($message_id, $mail)= @_; + my ($q, $query, $i, $row, $sth); + + $q= " WHERE in_reply_to = \"$message_id\""; + $query= $base_q . $q; + $sth= $dbh->prepare($query); + if (!$sth->execute) { - $query.= "$val"; + print "QUERY: $query\n$DBI::errstr\n"; + $sth->finish; + die; + } + while (($row= $sth->fetchrow_arrayref)) + { + $mail_count++; + for ($i= 0; $i < $fields; $i++) + { + if ($opt_message_id) + { + $mail[$fields][$mail_count]= $row->[$fields]; + $mail[$fields][$mail_count].= "\nNumber of Replies: " . get_nr_replies($row->[$fields]); + } + $mail[$i][$mail_count]= $row->[$i]; + } + $new_message_id= $row->[$fields]; + if (defined($new_message_id) && length($new_message_id)) + { + get_mail_by_message_id($new_message_id, $mail); + } + } + return; +} + +#### +#### Get number of replies for a given message_id +#### + +sub get_nr_replies +{ + my ($message_id)= @_; + my ($sth, $sth2, $q, $row, $row2, $nr_replies); + + $nr_replies= 0; + $q= "SELECT COUNT(*) FROM my_mail WHERE in_reply_to=\"$message_id\""; + $sth= $dbh->prepare($q); + if (!$sth->execute) + { + print "QUERY: $q\n$DBI::errstr\n"; + $sth->finish; + die; + } + while (($row= $sth->fetchrow_arrayref)) + { + if (($nr_replies= $row->[0])) + { + $q= "SELECT message_id FROM my_mail WHERE in_reply_to=\"$message_id\""; + $sth2= $dbh->prepare($q); + if (!$sth2->execute) + { + print "QUERY: $q\n$DBI::errstr\n"; + $sth->finish; + die; + } + while (($row2= $sth2->fetchrow_arrayref)) + { + # There may be several replies to the same mail. Also the + # replies to the 'parent' mail may contain several replies + # and so on. Thus we need to calculate it recursively. + $nr_replies+= get_nr_replies($row2->[0]); + } + } + return $nr_replies; + } +} + +#### +#### Print mails +#### + +sub print_mails +{ + my ($mail)= @_; + my ($i); + + for ($i=0; $mail[0][$i]; $i++) + { + print "#" x 33; + print " " . ($i+1) . ". Mail "; + print "#" x 33; + print "\n"; + if ($opt_message_id) + { + print "Msg ID: $mail[$fields][$i]\n"; + } + print "From: $mail[0][$i]\n"; + print "To: $mail[1][$i]\n"; + print "Cc:" . (defined($mail[2][$i]) ? $mail[2][$i] : "") . "\n"; + print "Date: $mail[3][$i]\n"; + print "Timezone: $mail[4][$i]\n"; + print "File: $mail[5][$i]\n"; + print "Subject: $mail[6][$i]\n"; + print "Message:\n$mail[7][$i]\n"; + } + print "#" x 20; + print " Summary: "; + if ($i == 1) + { + print "$i Mail "; + print "matches the query "; } else { - $query.= ",$val"; + print "$i Mails "; + print "match the query "; } - $fields++; -} -$query.= " from $opt_table where $ARGV[0] order by date desc"; - -#### -#### Send query and save result -#### - -$sth= $dbh->prepare($query); -if (!$sth->execute) -{ - print "$DBI::errstr\n"; - $sth->finish; - die; -} -for ($i=0; ($row= $sth->fetchrow_arrayref); $i++) -{ - for ($j=0; $j < $fields; $j++) - { - $mail[$j][$i]= $row->[$j]; - } -} - -#### -#### Print to stderr -#### - -for ($i=0; $mail[0][$i]; $i++) -{ - print "#" x 33; - print " " . ($i+1) . ". Mail "; - print "#" x 33; - print "\nFrom: $mail[0][$i]\n"; - print "To: $mail[1][$i]\n"; - print "Cc: $mail[2][$i]\n"; - print "Date: $mail[3][$i]\n"; - print "Timezone: $mail[4][$i]\n"; - print "File: $mail[5][$i]\n"; - print "Subject: $mail[6][$i]\n"; - print "Message:\n$mail[7][$i]\n"; -} -print "#" x 20; -print " Summary: "; -if ($i == 1) -{ - print "$i Mail "; - print "matches the query "; -} -else -{ - print "$i Mails "; - print "match the query "; -} -print "#" x 20; -print "\n"; + print "#" x 20; + print "\n"; +} #### #### Count mails that matches the query, but don't show them @@ -121,6 +238,8 @@ print "\n"; sub count_mails { + my ($sth); + $sth= $dbh->prepare("select count(*) from $opt_table where $ARGV[0]"); if (!$sth->execute) { @@ -154,15 +273,21 @@ sub usage Usage: pmail [options] "SQL where clause" Options: - --help show this help - --count Shows how many mails matches the query, but not the mails. - --db= database to use (Default: $opt_db) - --table= table to use (Default: $opt_table) - --host= Hostname which to connect (Default: $opt_host) - --socket= Unix socket to be used for connection (Default: $opt_socket) - --password= Password to use for mysql - --user= User to be used for mysql connection, if not current user - --port= mysql port to be used (Default: $opt_port) + --help show this help + --count Shows how many mails matches the query, but not the mails. + --db= database to use (Default: $opt_db) + --host= Hostname which to connect (Default: $opt_host) + --socket= Unix socket to be used for connection (Default: $opt_socket) + --password= Password to use for mysql + --user= User to be used for mysql connection, if not current user + --port= mysql port to be used (Default: $opt_port) + --thread Will search for possible replies to emails found by the search + criteria. Replies, if found, will be displayed right after the + original mail. + --message_id Display message_id on top of each mail. Useful when searching + email threads with --thread. On the second line is the number + of replies to the same thread, starting counting from that + mail (excluding possible parent mails). "SQL where clause" is the end of the select clause, where the condition is expressed. The result will be the mail(s) that matches the condition and @@ -176,18 +301,20 @@ sub usage - Subject - Message text The field names that can be used in the where clause are: - Field Type - - mail_from varchar(120) - - date datetime - - sbj varchar(200) - - txt mediumtext - - cc text - - mail_to text - - time_zone varchar(6) - - reply varchar(120) - - file varchar(32) - - hash int(11) - An example of the pmail: + Field Type + - message_id varchar(255) # Use with --thread and --message_id + - in_reply_to varchar(255) # Internally used by --thread + - mail_from varchar(120) + - date datetime + - sbj varchar(200) + - txt mediumtext + - cc text + - mail_to text + - time_zone varchar(6) + - reply varchar(120) + - file varchar(32) + - hash int(11) + An example of pmail: pmail "txt like '%libmysql.dll%' and sbj like '%delphi%'" NOTE: the txt field is NOT case sensitive! EOF diff --git a/tools/Makefile.am b/tools/Makefile.am index 8b8ada600f5..3b84aafeaa9 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -19,9 +19,9 @@ INCLUDES=-I$(top_srcdir)/include $(openssl_includes) \ -I$(top_builddir)/include LDADD= @CLIENT_EXTRA_LDFLAGS@ @openssl_libs@ \ $(top_builddir)/libmysql_r/libmysqlclient_r.la @ZLIB_LIBS@ -bin_PROGRAMS= mysqlmanager -mysqlmanager_SOURCES= mysqlmanager.c -mysqlmanager_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) +bin_PROGRAMS= mysqltestmanager +mysqltestmanager_SOURCES= mysqlmanager.c +mysqltestmanager_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) DEF= -DUNDEF_THREADS_HACK # Don't update the files from bitkeeper