Commit b68519f7 authored by unknown's avatar unknown

Merge tsmith@bk-internal.mysql.com:/home/bk/mysql-4.1

into  quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/mrg0306/41

parents 2e669d8e 49110f3e
...@@ -1067,3 +1067,4 @@ vio/viotest-ssl ...@@ -1067,3 +1067,4 @@ vio/viotest-ssl
include/check_abi include/check_abi
include/mysql_h.ic include/mysql_h.ic
mysql-test/r/blackhole.log mysql-test/r/blackhole.log
mysql-test/lib/init_db.sql
/* 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 */
/*
echo is a replacement for the "echo" command builtin to cmd.exe
on Windows, to get a Unix eqvivalent behaviour when running commands
like:
$> echo "hello" | mysql
The windows "echo" would have sent "hello" to mysql while
Unix echo will send hello without the enclosing hyphens
This is a very advanced high tech program so take care when
you change it and remember to valgrind it before production
use.
*/
#include <stdio.h>
int main(int argc, char **argv)
{
int i;
for (i= 1; i < argc; i++)
{
fprintf(stdout, "%s", argv[i]);
if (i < argc - 1)
fprintf(stdout, " ");
}
fprintf(stdout, "\n");
return 0;
}
This diff is collapsed.
...@@ -35,7 +35,7 @@ testdir = $(benchdir_root)/mysql-test ...@@ -35,7 +35,7 @@ testdir = $(benchdir_root)/mysql-test
EXTRA_SCRIPTS = mysql-test-run-shell.sh install_test_db.sh \ EXTRA_SCRIPTS = mysql-test-run-shell.sh install_test_db.sh \
valgrind.supp $(PRESCRIPTS) valgrind.supp $(PRESCRIPTS)
EXTRA_DIST = $(EXTRA_SCRIPTS) EXTRA_DIST = $(EXTRA_SCRIPTS)
GENSCRIPTS = mysql-test-run-shell mysql-test-run install_test_db mtr GENSCRIPTS = mysql-test-run-shell mysql-test-run install_test_db mtr lib/init_db.sql
PRESCRIPTS = mysql-test-run.pl PRESCRIPTS = mysql-test-run.pl
test_SCRIPTS = $(GENSCRIPTS) $(PRESCRIPTS) test_SCRIPTS = $(GENSCRIPTS) $(PRESCRIPTS)
test_DATA = std_data/client-key.pem \ test_DATA = std_data/client-key.pem \
...@@ -119,6 +119,11 @@ mysql-test-run: ...@@ -119,6 +119,11 @@ mysql-test-run:
$(RM) -f mysql-test-run $(RM) -f mysql-test-run
$(LN_S) mysql-test-run.pl mysql-test-run $(LN_S) mysql-test-run.pl mysql-test-run
# Build init_db.sql by executing mysql_create_system_tables
lib/init_db.sql:
$(top_builddir)/scripts/mysql_create_system_tables \
test . \@HOSTNAME\@ > lib/init_db.sql
SUFFIXES = .sh SUFFIXES = .sh
.sh: .sh:
......
This diff is collapsed.
This diff is collapsed.
...@@ -8,6 +8,7 @@ use strict; ...@@ -8,6 +8,7 @@ use strict;
sub mtr_full_hostname (); sub mtr_full_hostname ();
sub mtr_short_hostname (); sub mtr_short_hostname ();
sub mtr_native_path($);
sub mtr_init_args ($); sub mtr_init_args ($);
sub mtr_add_arg ($$@); sub mtr_add_arg ($$@);
sub mtr_path_exists(@); sub mtr_path_exists(@);
...@@ -49,6 +50,22 @@ sub mtr_short_hostname () { ...@@ -49,6 +50,22 @@ sub mtr_short_hostname () {
return $hostname; return $hostname;
} }
# Convert path to OS native format
sub mtr_native_path($)
{
my $path= shift;
# MySQL version before 5.0 still use cygwin, no need
# to convert path
return $path
if ($::mysql_version_id < 50000);
$path=~ s/\//\\/g
if ($::glob_win32);
return $path;
}
# FIXME move to own lib # FIXME move to own lib
sub mtr_init_args ($) { sub mtr_init_args ($) {
......
...@@ -8,7 +8,7 @@ use Socket; ...@@ -8,7 +8,7 @@ use Socket;
use Errno; use Errno;
use strict; use strict;
use POSIX 'WNOHANG'; use POSIX qw(WNOHANG SIGHUP);
sub mtr_run ($$$$$$;$); sub mtr_run ($$$$$$;$);
sub mtr_spawn ($$$$$$;$); sub mtr_spawn ($$$$$$;$);
...@@ -125,19 +125,18 @@ sub spawn_impl ($$$$$$$$) { ...@@ -125,19 +125,18 @@ sub spawn_impl ($$$$$$$$) {
{ {
if ( $! == $!{EAGAIN} ) # See "perldoc Errno" if ( $! == $!{EAGAIN} ) # See "perldoc Errno"
{ {
mtr_debug("Got EAGAIN from fork(), sleep 1 second and redo"); mtr_warning("Got EAGAIN from fork(), sleep 1 second and redo");
sleep(1); sleep(1);
redo FORK; redo FORK;
} }
else
{ mtr_error("$path ($pid) can't be forked, error: $!");
mtr_error("$path ($pid) can't be forked");
}
} }
if ( $pid ) if ( $pid )
{ {
spawn_parent_impl($pid,$mode,$path); return spawn_parent_impl($pid,$mode,$path);
} }
else else
{ {
...@@ -202,8 +201,11 @@ sub spawn_impl ($$$$$$$$) { ...@@ -202,8 +201,11 @@ sub spawn_impl ($$$$$$$$) {
{ {
mtr_child_error("failed to execute \"$path\": $!"); mtr_child_error("failed to execute \"$path\": $!");
} }
mtr_error("Should never come here 1!");
} }
mtr_error("Should never come here 2!");
} }
mtr_error("Should never come here 3!");
} }
...@@ -216,12 +218,21 @@ sub spawn_parent_impl { ...@@ -216,12 +218,21 @@ sub spawn_parent_impl {
{ {
if ( $mode eq 'run' ) if ( $mode eq 'run' )
{ {
# Simple run of command, we wait for it to return # Simple run of command, wait blocking for it to return
my $ret_pid= waitpid($pid,0); my $ret_pid= waitpid($pid,0);
if ( $ret_pid != $pid ) if ( $ret_pid != $pid )
{ {
mtr_error("waitpid($pid, 0) returned $ret_pid " . # The "simple" waitpid has failed, print debug info
"when waiting for '$path'"); # and try to handle the error
mtr_warning("waitpid($pid, 0) returned $ret_pid " .
"when waiting for '$path', error: '$!'");
if ( $ret_pid == -1 )
{
# waitpid returned -1, that would indicate the process
# no longer exist and waitpid couldn't wait for it.
return 1;
}
mtr_error("Error handling failed");
} }
return mtr_process_exit_status($?); return mtr_process_exit_status($?);
...@@ -1089,12 +1100,6 @@ sub mtr_kill_processes ($) { ...@@ -1089,12 +1100,6 @@ sub mtr_kill_processes ($) {
# #
############################################################################## ##############################################################################
# FIXME something is wrong, we sometimes terminate with "Hangup" written
# to tty, and no STDERR output telling us why.
# FIXME for some reason, setting HUP to 'IGNORE' will cause exit() to
# write out "Hangup", and maybe loose some output. We insert a sleep...
sub mtr_exit ($) { sub mtr_exit ($) {
my $code= shift; my $code= shift;
mtr_timer_stop_all($::glob_timers); mtr_timer_stop_all($::glob_timers);
...@@ -1106,7 +1111,7 @@ sub mtr_exit ($) { ...@@ -1106,7 +1111,7 @@ sub mtr_exit ($) {
# set ourselves as the group leader at startup (with # set ourselves as the group leader at startup (with
# POSIX::setpgrp(0,0)), but then care must be needed to always do # POSIX::setpgrp(0,0)), but then care must be needed to always do
# proper child process cleanup. # proper child process cleanup.
kill('HUP', -$$) if !$::glob_win32_perl and $$ == getpgrp(); POSIX::kill(SIGHUP, -$$) if !$::glob_win32_perl and $$ == getpgrp();
exit($code); exit($code);
} }
......
...@@ -347,6 +347,7 @@ sub stop_all_servers (); ...@@ -347,6 +347,7 @@ sub stop_all_servers ();
sub run_mysqltest ($); sub run_mysqltest ($);
sub usage ($); sub usage ($);
###################################################################### ######################################################################
# #
# Main program # Main program
...@@ -1518,7 +1519,8 @@ sub executable_setup () { ...@@ -1518,7 +1519,8 @@ sub executable_setup () {
sub generate_cmdline_mysqldump ($) { sub generate_cmdline_mysqldump ($) {
my($mysqld) = @_; my($mysqld) = @_;
return return
"$exe_mysqldump --no-defaults -uroot " . mtr_native_path($exe_mysqldump) .
" --no-defaults -uroot " .
"--port=$mysqld->{'port'} " . "--port=$mysqld->{'port'} " .
"--socket=$mysqld->{'path_sock'} --password="; "--socket=$mysqld->{'path_sock'} --password=";
} }
...@@ -1624,7 +1626,7 @@ sub environment_setup () { ...@@ -1624,7 +1626,7 @@ sub environment_setup () {
my $deb_version; my $deb_version;
if ( $opt_valgrind and -d $debug_libraries_path and if ( $opt_valgrind and -d $debug_libraries_path and
(! -e '/etc/debian_version' or (! -e '/etc/debian_version' or
($deb_version= mtr_grab_file('/etc/debian_version')) == 0 or ($deb_version= mtr_grab_file('/etc/debian_version')) !~ /^[0-9]+\.[0-9]$/ or
$deb_version > 3.1 ) ) $deb_version > 3.1 ) )
{ {
push(@ld_library_paths, $debug_libraries_path); push(@ld_library_paths, $debug_libraries_path);
...@@ -1721,9 +1723,10 @@ sub environment_setup () { ...@@ -1721,9 +1723,10 @@ sub environment_setup () {
# Setup env so childs can execute mysqlcheck # Setup env so childs can execute mysqlcheck
# ---------------------------------------------------- # ----------------------------------------------------
my $cmdline_mysqlcheck= my $cmdline_mysqlcheck=
"$exe_mysqlcheck --no-defaults -uroot " . mtr_native_path($exe_mysqlcheck) .
"--port=$master->[0]->{'port'} " . " --no-defaults -uroot " .
"--socket=$master->[0]->{'path_sock'} --password="; "--port=$master->[0]->{'port'} " .
"--socket=$master->[0]->{'path_sock'} --password=";
if ( $opt_debug ) if ( $opt_debug )
{ {
...@@ -1755,7 +1758,8 @@ sub environment_setup () { ...@@ -1755,7 +1758,8 @@ sub environment_setup () {
if ( $exe_mysqlslap ) if ( $exe_mysqlslap )
{ {
my $cmdline_mysqlslap= my $cmdline_mysqlslap=
"$exe_mysqlslap -uroot " . mtr_native_path($exe_mysqlslap) .
" -uroot " .
"--port=$master->[0]->{'port'} " . "--port=$master->[0]->{'port'} " .
"--socket=$master->[0]->{'path_sock'} --password= " . "--socket=$master->[0]->{'path_sock'} --password= " .
"--lock-directory=$opt_tmpdir"; "--lock-directory=$opt_tmpdir";
...@@ -1772,7 +1776,8 @@ sub environment_setup () { ...@@ -1772,7 +1776,8 @@ sub environment_setup () {
# Setup env so childs can execute mysqlimport # Setup env so childs can execute mysqlimport
# ---------------------------------------------------- # ----------------------------------------------------
my $cmdline_mysqlimport= my $cmdline_mysqlimport=
"$exe_mysqlimport -uroot " . mtr_native_path($exe_mysqlimport) .
" -uroot " .
"--port=$master->[0]->{'port'} " . "--port=$master->[0]->{'port'} " .
"--socket=$master->[0]->{'path_sock'} --password="; "--socket=$master->[0]->{'path_sock'} --password=";
...@@ -1788,7 +1793,8 @@ sub environment_setup () { ...@@ -1788,7 +1793,8 @@ sub environment_setup () {
# Setup env so childs can execute mysqlshow # Setup env so childs can execute mysqlshow
# ---------------------------------------------------- # ----------------------------------------------------
my $cmdline_mysqlshow= my $cmdline_mysqlshow=
"$exe_mysqlshow -uroot " . mtr_native_path($exe_mysqlshow) .
" -uroot " .
"--port=$master->[0]->{'port'} " . "--port=$master->[0]->{'port'} " .
"--socket=$master->[0]->{'path_sock'} --password="; "--socket=$master->[0]->{'path_sock'} --password=";
...@@ -1803,7 +1809,7 @@ sub environment_setup () { ...@@ -1803,7 +1809,7 @@ sub environment_setup () {
# Setup env so childs can execute mysqlbinlog # Setup env so childs can execute mysqlbinlog
# ---------------------------------------------------- # ----------------------------------------------------
my $cmdline_mysqlbinlog= my $cmdline_mysqlbinlog=
"$exe_mysqlbinlog" . mtr_native_path($exe_mysqlbinlog) .
" --no-defaults --local-load=$opt_tmpdir"; " --no-defaults --local-load=$opt_tmpdir";
if ( $mysql_version_id >= 50000 ) if ( $mysql_version_id >= 50000 )
{ {
...@@ -1821,7 +1827,8 @@ sub environment_setup () { ...@@ -1821,7 +1827,8 @@ sub environment_setup () {
# Setup env so childs can execute mysql # Setup env so childs can execute mysql
# ---------------------------------------------------- # ----------------------------------------------------
my $cmdline_mysql= my $cmdline_mysql=
"$exe_mysql --no-defaults --host=localhost --user=root --password= " . mtr_native_path($exe_mysql) .
" --no-defaults --host=localhost --user=root --password= " .
"--port=$master->[0]->{'port'} " . "--port=$master->[0]->{'port'} " .
"--socket=$master->[0]->{'path_sock'} ". "--socket=$master->[0]->{'path_sock'} ".
"--character-sets-dir=$path_charsetsdir"; "--character-sets-dir=$path_charsetsdir";
...@@ -1850,17 +1857,17 @@ sub environment_setup () { ...@@ -1850,17 +1857,17 @@ sub environment_setup () {
# ---------------------------------------------------- # ----------------------------------------------------
# Setup env so childs can execute my_print_defaults # Setup env so childs can execute my_print_defaults
# ---------------------------------------------------- # ----------------------------------------------------
$ENV{'MYSQL_MY_PRINT_DEFAULTS'}= $exe_my_print_defaults; $ENV{'MYSQL_MY_PRINT_DEFAULTS'}= mtr_native_path($exe_my_print_defaults);
# ---------------------------------------------------- # ----------------------------------------------------
# Setup env so childs can execute mysqladmin # Setup env so childs can execute mysqladmin
# ---------------------------------------------------- # ----------------------------------------------------
$ENV{'MYSQLADMIN'}= $exe_mysqladmin; $ENV{'MYSQLADMIN'}= mtr_native_path($exe_mysqladmin);
# ---------------------------------------------------- # ----------------------------------------------------
# Setup env so childs can execute perror # Setup env so childs can execute perror
# ---------------------------------------------------- # ----------------------------------------------------
$ENV{'MY_PERROR'}= $exe_perror; $ENV{'MY_PERROR'}= mtr_native_path($exe_perror);
# ---------------------------------------------------- # ----------------------------------------------------
# Add the path where mysqld will find udf_example.so # Add the path where mysqld will find udf_example.so
...@@ -2018,6 +2025,16 @@ sub remove_stale_vardir () { ...@@ -2018,6 +2025,16 @@ sub remove_stale_vardir () {
mtr_verbose("Removing $opt_vardir/"); mtr_verbose("Removing $opt_vardir/");
rmtree("$opt_vardir/"); rmtree("$opt_vardir/");
} }
if ( $opt_mem )
{
# A symlink from var/ to $opt_mem will be set up
# remove the $opt_mem dir to assure the symlink
# won't point at an old directory
mtr_verbose("Removing $opt_mem");
rmtree($opt_mem);
}
} }
else else
{ {
...@@ -3634,7 +3651,7 @@ sub mysqld_arguments ($$$$$) { ...@@ -3634,7 +3651,7 @@ sub mysqld_arguments ($$$$$) {
if ( $mysql_version_id <= 50106 ) if ( $mysql_version_id <= 50106 )
{ {
# Force mysqld to use log files up until 5.1.6 # Force mysqld to use log files up until 5.1.6
mtr_add_arg($args, "%s--log=%s", $prefix, $master->[0]->{'path_mylog'}); mtr_add_arg($args, "%s--log=%s", $prefix, $slave->[0]->{'path_mylog'});
} }
else else
{ {
...@@ -4516,7 +4533,8 @@ sub run_mysqltest ($) { ...@@ -4516,7 +4533,8 @@ sub run_mysqltest ($) {
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# export MYSQL_TEST variable containing <path>/mysqltest <args> # export MYSQL_TEST variable containing <path>/mysqltest <args>
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
$ENV{'MYSQL_TEST'}= "$exe_mysqltest " . join(" ", @$args); $ENV{'MYSQL_TEST'}=
mtr_native_path($exe_mysqltest) . " " . join(" ", @$args);
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Add arguments that should not go into the MYSQL_TEST env var # Add arguments that should not go into the MYSQL_TEST env var
......
...@@ -229,9 +229,7 @@ a ...@@ -229,9 +229,7 @@ a
10000 10000
select microsecond(19971231235959.01) as a; select microsecond(19971231235959.01) as a;
a a
0 10000
Warnings:
Warning 1292 Truncated incorrect time value: '19971231235959.01'
select date_add("1997-12-31",INTERVAL "10.09" SECOND_MICROSECOND) as a; select date_add("1997-12-31",INTERVAL "10.09" SECOND_MICROSECOND) as a;
a a
1997-12-31 00:00:10.090000 1997-12-31 00:00:10.090000
......
...@@ -854,4 +854,8 @@ H ...@@ -854,4 +854,8 @@ H
select last_day('0000-00-00'); select last_day('0000-00-00');
last_day('0000-00-00') last_day('0000-00-00')
NULL NULL
select isnull(week(now() + 0)), isnull(week(now() + 0.2)),
week(20061108), week(20061108.01), week(20061108085411.000002);
isnull(week(now() + 0)) isnull(week(now() + 0.2)) week(20061108) week(20061108.01) week(20061108085411.000002)
0 0 45 45 45
End of 4.1 tests End of 4.1 tests
...@@ -578,7 +578,7 @@ create table t1 select POINT(1,3); ...@@ -578,7 +578,7 @@ create table t1 select POINT(1,3);
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`POINT(1,3)` longblob NOT NULL `POINT(1,3)` longblob
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
CREATE TABLE `t1` (`object_id` bigint(20) unsigned NOT NULL default '0', `geo` CREATE TABLE `t1` (`object_id` bigint(20) unsigned NOT NULL default '0', `geo`
...@@ -677,3 +677,45 @@ load data infile '../../std_data/bad_gis_data.dat' into table t1; ...@@ -677,3 +677,45 @@ load data infile '../../std_data/bad_gis_data.dat' into table t1;
ERROR 01000: Data truncated; NULL supplied to NOT NULL column 'b' at row 1 ERROR 01000: Data truncated; NULL supplied to NOT NULL column 'b' at row 1
alter table t1 enable keys; alter table t1 enable keys;
drop table t1; drop table t1;
create table t1 (a int, b blob);
insert into t1 values (1, ''), (2, NULL), (3, '1');
select * from t1;
a b
1
2 NULL
3 1
select
geometryfromtext(b) IS NULL, geometryfromwkb(b) IS NULL, astext(b) IS NULL,
aswkb(b) IS NULL, geometrytype(b) IS NULL, centroid(b) IS NULL,
envelope(b) IS NULL, startpoint(b) IS NULL, endpoint(b) IS NULL,
exteriorring(b) IS NULL, pointn(b, 1) IS NULL, geometryn(b, 1) IS NULL,
interiorringn(b, 1) IS NULL, multipoint(b) IS NULL, isempty(b) IS NULL,
issimple(b) IS NULL, isclosed(b) IS NULL, dimension(b) IS NULL,
numgeometries(b) IS NULL, numinteriorrings(b) IS NULL, numpoints(b) IS NULL,
area(b) IS NULL, glength(b) IS NULL, srid(b) IS NULL, x(b) IS NULL,
y(b) IS NULL
from t1;
geometryfromtext(b) IS NULL geometryfromwkb(b) IS NULL astext(b) IS NULL aswkb(b) IS NULL geometrytype(b) IS NULL centroid(b) IS NULL envelope(b) IS NULL startpoint(b) IS NULL endpoint(b) IS NULL exteriorring(b) IS NULL pointn(b, 1) IS NULL geometryn(b, 1) IS NULL interiorringn(b, 1) IS NULL multipoint(b) IS NULL isempty(b) IS NULL issimple(b) IS NULL isclosed(b) IS NULL dimension(b) IS NULL numgeometries(b) IS NULL numinteriorrings(b) IS NULL numpoints(b) IS NULL area(b) IS NULL glength(b) IS NULL srid(b) IS NULL x(b) IS NULL y(b) IS NULL
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
select
within(b, b) IS NULL, contains(b, b) IS NULL, overlaps(b, b) IS NULL,
equals(b, b) IS NULL, disjoint(b, b) IS NULL, touches(b, b) IS NULL,
intersects(b, b) IS NULL, crosses(b, b) IS NULL
from t1;
within(b, b) IS NULL contains(b, b) IS NULL overlaps(b, b) IS NULL equals(b, b) IS NULL disjoint(b, b) IS NULL touches(b, b) IS NULL intersects(b, b) IS NULL crosses(b, b) IS NULL
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
select
point(b, b) IS NULL, linestring(b) IS NULL, polygon(b) IS NULL, multipoint(b) IS NULL,
multilinestring(b) IS NULL, multipolygon(b) IS NULL,
geometrycollection(b) IS NULL
from t1;
point(b, b) IS NULL linestring(b) IS NULL polygon(b) IS NULL multipoint(b) IS NULL multilinestring(b) IS NULL multipolygon(b) IS NULL geometrycollection(b) IS NULL
0 1 1 1 1 1 1
1 1 1 1 1 1 1
0 1 1 1 1 1 1
drop table t1;
End of 4.1 tests
...@@ -210,7 +210,6 @@ source database ...@@ -210,7 +210,6 @@ source database
"MySQL: The world's most popular ;open source database" "MySQL: The world's most popular ;open source database"
echo message echo message echo message echo message
mysqltest: At line 1: Empty variable
mysqltest: At line 1: command "false" failed mysqltest: At line 1: command "false" failed
mysqltest: At line 1: Missing argument in exec mysqltest: At line 1: Missing argument in exec
MySQL MySQL
...@@ -507,8 +506,10 @@ drop table t1; ...@@ -507,8 +506,10 @@ drop table t1;
mysqltest: At line 1: Missing required argument 'filename' to command 'remove_file' mysqltest: At line 1: Missing required argument 'filename' to command 'remove_file'
mysqltest: At line 1: Missing required argument 'filename' to command 'write_file' mysqltest: At line 1: Missing required argument 'filename' to command 'write_file'
mysqltest: At line 1: End of file encountered before 'EOF' delimiter was found mysqltest: At line 1: End of file encountered before 'EOF' delimiter was found
mysqltest: At line 1: End of line junk detected: "write_file filename "; Some data
" for cat_file command
of mysqltest
mysqltest: At line 1: Failed to open file non_existing_file
mysqltest: At line 1: Missing required argument 'filename' to command 'file_exists' mysqltest: At line 1: Missing required argument 'filename' to command 'file_exists'
mysqltest: At line 1: Missing required argument 'from_file' to command 'copy_file' mysqltest: At line 1: Missing required argument 'from_file' to command 'copy_file'
mysqltest: At line 1: Missing required argument 'to_file' to command 'copy_file' mysqltest: At line 1: Missing required argument 'to_file' to command 'copy_file'
......
...@@ -847,6 +847,30 @@ num (select num + 2 FROM t1 LIMIT 1) ...@@ -847,6 +847,30 @@ num (select num + 2 FROM t1 LIMIT 1)
SELECT a.a + 1 AS num FROM t1 a JOIN t1 b ON num = b.a; SELECT a.a + 1 AS num FROM t1 a JOIN t1 b ON num = b.a;
ERROR 42S22: Unknown column 'num' in 'on clause' ERROR 42S22: Unknown column 'num' in 'on clause'
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE bug25126 (
val int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY
);
UPDATE bug25126 SET MissingCol = MissingCol;
ERROR 42S22: Unknown column 'MissingCol' in 'field list'
UPDATE bug25126 SET val = val ORDER BY MissingCol;
ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
UPDATE bug25126 SET val = val ORDER BY val;
UPDATE bug25126 SET val = 1 ORDER BY val;
UPDATE bug25126 SET val = 1 ORDER BY MissingCol;
ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
UPDATE bug25126 SET val = 1 ORDER BY val, MissingCol;
ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
UPDATE bug25126 SET val = MissingCol ORDER BY MissingCol;
ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
UPDATE bug25126 SET MissingCol = 1 ORDER BY val, MissingCol;
ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
UPDATE bug25126 SET MissingCol = 1 ORDER BY MissingCol;
ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
UPDATE bug25126 SET MissingCol = val ORDER BY MissingCol;
ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
UPDATE bug25126 SET MissingCol = MissingCol ORDER BY MissingCol;
ERROR 42S22: Unknown column 'MissingCol' in 'order clause'
DROP TABLE bug25126;
CREATE TABLE t1 (a int); CREATE TABLE t1 (a int);
SELECT p.a AS val, q.a AS val1 FROM t1 p, t1 q ORDER BY val > 1; SELECT p.a AS val, q.a AS val1 FROM t1 p, t1 q ORDER BY val > 1;
val val1 val val1
......
...@@ -492,4 +492,11 @@ union ...@@ -492,4 +492,11 @@ union
select last_day('0000-00-00'); select last_day('0000-00-00');
#
# Bug 23616: datetime functions with double argumets
#
select isnull(week(now() + 0)), isnull(week(now() + 0.2)),
week(20061108), week(20061108.01), week(20061108085411.000002);
--echo End of 4.1 tests --echo End of 4.1 tests
...@@ -377,4 +377,38 @@ load data infile '../../std_data/bad_gis_data.dat' into table t1; ...@@ -377,4 +377,38 @@ load data infile '../../std_data/bad_gis_data.dat' into table t1;
alter table t1 enable keys; alter table t1 enable keys;
drop table t1; drop table t1;
# End of 4.1 tests #
# Bug #26038: is null and bad data
#
create table t1 (a int, b blob);
insert into t1 values (1, ''), (2, NULL), (3, '1');
select * from t1;
select
geometryfromtext(b) IS NULL, geometryfromwkb(b) IS NULL, astext(b) IS NULL,
aswkb(b) IS NULL, geometrytype(b) IS NULL, centroid(b) IS NULL,
envelope(b) IS NULL, startpoint(b) IS NULL, endpoint(b) IS NULL,
exteriorring(b) IS NULL, pointn(b, 1) IS NULL, geometryn(b, 1) IS NULL,
interiorringn(b, 1) IS NULL, multipoint(b) IS NULL, isempty(b) IS NULL,
issimple(b) IS NULL, isclosed(b) IS NULL, dimension(b) IS NULL,
numgeometries(b) IS NULL, numinteriorrings(b) IS NULL, numpoints(b) IS NULL,
area(b) IS NULL, glength(b) IS NULL, srid(b) IS NULL, x(b) IS NULL,
y(b) IS NULL
from t1;
select
within(b, b) IS NULL, contains(b, b) IS NULL, overlaps(b, b) IS NULL,
equals(b, b) IS NULL, disjoint(b, b) IS NULL, touches(b, b) IS NULL,
intersects(b, b) IS NULL, crosses(b, b) IS NULL
from t1;
select
point(b, b) IS NULL, linestring(b) IS NULL, polygon(b) IS NULL, multipoint(b) IS NULL,
multilinestring(b) IS NULL, multipolygon(b) IS NULL,
geometrycollection(b) IS NULL
from t1;
drop table t1;
--echo End of 4.1 tests
...@@ -552,8 +552,8 @@ echo ; ...@@ -552,8 +552,8 @@ echo ;
# Illegal use of echo # Illegal use of echo
--error 1 #--error 1
--exec echo "echo \$;" | $MYSQL_TEST 2>&1 #--exec echo "echo \$;" | $MYSQL_TEST 2>&1
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
...@@ -1469,8 +1469,8 @@ remove_file non_existing_file; ...@@ -1469,8 +1469,8 @@ remove_file non_existing_file;
--error 1 --error 1
--exec echo "write_file filename ;" | $MYSQL_TEST 2>&1 --exec echo "write_file filename ;" | $MYSQL_TEST 2>&1
--error 1 #--error 1
--exec echo "write_file filename \";" | $MYSQL_TEST 2>&1 #--exec echo "write_file filename \";" | $MYSQL_TEST 2>&1
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
Content for test_file1 Content for test_file1
...@@ -1484,6 +1484,74 @@ END_DELIMITER ...@@ -1484,6 +1484,74 @@ END_DELIMITER
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp; file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
# ----------------------------------------------------------------------------
# test for append_file
# ----------------------------------------------------------------------------
write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
Content for test_file1
EOF
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
append_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
Appended text
EOF
file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
append_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
Appended text on nonexisting file
EOF
# ----------------------------------------------------------------------------
# test for cat_file
# ----------------------------------------------------------------------------
--write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp
Some data
for cat_file command
of mysqltest
EOF
cat_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
--error 1
--exec echo "cat_file non_existing_file;" | $MYSQL_TEST 2>&1
# ----------------------------------------------------------------------------
# test for diff_files
# ----------------------------------------------------------------------------
--write_file $MYSQLTEST_VARDIR/tmp/diff1.tmp
Some data
for diff_file command
of mysqltest
EOF
--write_file $MYSQLTEST_VARDIR/tmp/diff2.tmp
Some data
for diff_file command
of mysqltest
EOF
--write_file $MYSQLTEST_VARDIR/tmp/diff3.tmp
Some other data
for diff_file command
of mysqltest
EOF
# Compare equal files
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff2.tmp
--diff_files $MYSQLTEST_VARDIR/tmp/diff2.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp
# Compare files that differ
--error 1
--diff_files $MYSQLTEST_VARDIR/tmp/diff3.tmp $MYSQLTEST_VARDIR/tmp/diff2.tmp
--error 1
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff3.tmp
# Compare equal files, again...
--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff2.tmp
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# test for file_exist # test for file_exist
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
......
...@@ -575,6 +575,35 @@ SELECT a + 1 AS num, (select num + 2 FROM t1 LIMIT 1) FROM t1; ...@@ -575,6 +575,35 @@ SELECT a + 1 AS num, (select num + 2 FROM t1 LIMIT 1) FROM t1;
SELECT a.a + 1 AS num FROM t1 a JOIN t1 b ON num = b.a; SELECT a.a + 1 AS num FROM t1 a JOIN t1 b ON num = b.a;
DROP TABLE t1; DROP TABLE t1;
#
# Bug#25126: Reference to non-existant column in UPDATE...ORDER BY...
# crashes server
#
CREATE TABLE bug25126 (
val int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY
);
--error 1054
UPDATE bug25126 SET MissingCol = MissingCol;
--error 1054
UPDATE bug25126 SET val = val ORDER BY MissingCol;
UPDATE bug25126 SET val = val ORDER BY val;
UPDATE bug25126 SET val = 1 ORDER BY val;
--error 1054
UPDATE bug25126 SET val = 1 ORDER BY MissingCol;
--error 1054
UPDATE bug25126 SET val = 1 ORDER BY val, MissingCol;
--error 1054
UPDATE bug25126 SET val = MissingCol ORDER BY MissingCol;
--error 1054
UPDATE bug25126 SET MissingCol = 1 ORDER BY val, MissingCol;
--error 1054
UPDATE bug25126 SET MissingCol = 1 ORDER BY MissingCol;
--error 1054
UPDATE bug25126 SET MissingCol = val ORDER BY MissingCol;
--error 1054
UPDATE bug25126 SET MissingCol = MissingCol ORDER BY MissingCol;
DROP TABLE bug25126;
# #
# Bug #25427: crash when order by expression contains a name # Bug #25427: crash when order by expression contains a name
# that cannot be resolved unambiguously # that cannot be resolved unambiguously
......
...@@ -145,7 +145,7 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, ...@@ -145,7 +145,7 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
digits= (uint) (pos-str); digits= (uint) (pos-str);
start_loop= 0; /* Start of scan loop */ start_loop= 0; /* Start of scan loop */
date_len[format_position[0]]= 0; /* Length of year field */ date_len[format_position[0]]= 0; /* Length of year field */
if (pos == end) if (pos == end || *pos == '.')
{ {
/* Found date in internal format (only numbers like YYYYMMDD) */ /* Found date in internal format (only numbers like YYYYMMDD) */
year_length= (digits == 4 || digits == 8 || digits >= 14) ? 4 : 2; year_length= (digits == 4 || digits == 8 || digits >= 14) ? 4 : 2;
......
...@@ -142,7 +142,8 @@ sql_yacc.o: sql_yacc.cc sql_yacc.h $(HEADERS) ...@@ -142,7 +142,8 @@ sql_yacc.o: sql_yacc.cc sql_yacc.h $(HEADERS)
# this avoid the rebuild of the built files in a source dist # this avoid the rebuild of the built files in a source dist
lex_hash.h: gen_lex_hash.cc lex.h lex_hash.h: gen_lex_hash.cc lex.h
$(MAKE) $(AM_MAKEFLAGS) gen_lex_hash$(EXEEXT) $(MAKE) $(AM_MAKEFLAGS) gen_lex_hash$(EXEEXT)
./gen_lex_hash$(EXEEXT) > $@ ./gen_lex_hash$(EXEEXT) > $@-t
$(MV) $@-t $@
# For testing of udf_example.so; Works on platforms with gcc # For testing of udf_example.so; Works on platforms with gcc
# (This is not part of our build process but only provided as an example) # (This is not part of our build process but only provided as an example)
......
...@@ -1774,7 +1774,18 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -1774,7 +1774,18 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
use the field from the Item_field in the select list and leave use the field from the Item_field in the select list and leave
the Item_field instance in place. the Item_field instance in place.
*/ */
set_field((*((Item_field**)res))->field);
Field *field= (*((Item_field**)res))->field;
if (field == NULL)
{
/* The column to which we link isn't valid. */
my_error(ER_BAD_FIELD_ERROR, MYF(0), (*res)->name,
current_thd->where);
return(1);
}
set_field(field);
return 0; return 0;
} }
else else
......
...@@ -30,6 +30,7 @@ void Item_geometry_func::fix_length_and_dec() ...@@ -30,6 +30,7 @@ void Item_geometry_func::fix_length_and_dec()
collation.set(&my_charset_bin); collation.set(&my_charset_bin);
decimals=0; decimals=0;
max_length=MAX_BLOB_WIDTH; max_length=MAX_BLOB_WIDTH;
maybe_null= 1;
} }
...@@ -109,6 +110,7 @@ String *Item_func_as_wkt::val_str(String *str) ...@@ -109,6 +110,7 @@ String *Item_func_as_wkt::val_str(String *str)
void Item_func_as_wkt::fix_length_and_dec() void Item_func_as_wkt::fix_length_and_dec()
{ {
max_length=MAX_BLOB_WIDTH; max_length=MAX_BLOB_WIDTH;
maybe_null= 1;
} }
...@@ -356,7 +358,8 @@ String *Item_func_spatial_collection::val_str(String *str) ...@@ -356,7 +358,8 @@ String *Item_func_spatial_collection::val_str(String *str)
for (i= 0; i < arg_count; ++i) for (i= 0; i < arg_count; ++i)
{ {
String *res= args[i]->val_str(&arg_value); String *res= args[i]->val_str(&arg_value);
if (args[i]->null_value) uint32 len;
if (args[i]->null_value || ((len= res->length()) < WKB_HEADER_SIZE))
goto err; goto err;
if (coll_type == Geometry::wkb_geometrycollection) if (coll_type == Geometry::wkb_geometrycollection)
...@@ -365,13 +368,12 @@ String *Item_func_spatial_collection::val_str(String *str) ...@@ -365,13 +368,12 @@ String *Item_func_spatial_collection::val_str(String *str)
In the case of GeometryCollection we don't need any checkings In the case of GeometryCollection we don't need any checkings
for item types, so just copy them into target collection for item types, so just copy them into target collection
*/ */
if (str->append(res->ptr(), res->length(), (uint32) 512)) if (str->append(res->ptr(), len, (uint32) 512))
goto err; goto err;
} }
else else
{ {
enum Geometry::wkbType wkb_type; enum Geometry::wkbType wkb_type;
uint32 len=res->length();
const char *data= res->ptr() + 1; const char *data= res->ptr() + 1;
/* /*
...@@ -379,8 +381,6 @@ String *Item_func_spatial_collection::val_str(String *str) ...@@ -379,8 +381,6 @@ String *Item_func_spatial_collection::val_str(String *str)
are of specific type, let's do this checking now are of specific type, let's do this checking now
*/ */
if (len < 5)
goto err;
wkb_type= (Geometry::wkbType) uint4korr(data); wkb_type= (Geometry::wkbType) uint4korr(data);
data+= 4; data+= 4;
len-= 5; len-= 5;
...@@ -502,9 +502,13 @@ longlong Item_func_spatial_rel::val_int() ...@@ -502,9 +502,13 @@ longlong Item_func_spatial_rel::val_int()
longlong Item_func_isempty::val_int() longlong Item_func_isempty::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
String tmp; String tmp;
null_value=0; String *swkb= args[0]->val_str(&tmp);
return args[0]->null_value ? 1 : 0; Geometry_buffer buffer;
null_value= args[0]->null_value ||
!(Geometry::construct(&buffer, swkb->ptr(), swkb->length()));
return null_value ? 1 : 0;
} }
...@@ -512,10 +516,11 @@ longlong Item_func_issimple::val_int() ...@@ -512,10 +516,11 @@ longlong Item_func_issimple::val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
String tmp; String tmp;
String *wkb=args[0]->val_str(&tmp); String *swkb= args[0]->val_str(&tmp);
Geometry_buffer buffer;
if ((null_value= (!wkb || args[0]->null_value)))
return 0; null_value= args[0]->null_value ||
!(Geometry::construct(&buffer, swkb->ptr(), swkb->length()));
/* TODO: Ramil or Holyfoot, add real IsSimple calculation */ /* TODO: Ramil or Holyfoot, add real IsSimple calculation */
return 0; return 0;
} }
......
...@@ -33,6 +33,7 @@ public: ...@@ -33,6 +33,7 @@ public:
Item_geometry_func(List<Item> &list) :Item_str_func(list) {} Item_geometry_func(List<Item> &list) :Item_str_func(list) {}
void fix_length_and_dec(); void fix_length_and_dec();
enum_field_types field_type() const { return MYSQL_TYPE_GEOMETRY; } enum_field_types field_type() const { return MYSQL_TYPE_GEOMETRY; }
bool is_null() { (void) val_int(); return null_value; }
}; };
class Item_func_geometry_from_text: public Item_geometry_func class Item_func_geometry_from_text: public Item_geometry_func
...@@ -80,6 +81,7 @@ public: ...@@ -80,6 +81,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
max_length=20; // "GeometryCollection" is the most long max_length=20; // "GeometryCollection" is the most long
maybe_null= 1;
}; };
}; };
...@@ -221,6 +223,8 @@ public: ...@@ -221,6 +223,8 @@ public:
} }
} }
void print(String *str) { Item_func::print(str); } void print(String *str) { Item_func::print(str); }
void fix_length_and_dec() { maybe_null= 1; }
bool is_null() { (void) val_int(); return null_value; }
}; };
class Item_func_isempty: public Item_bool_func class Item_func_isempty: public Item_bool_func
...@@ -230,6 +234,7 @@ public: ...@@ -230,6 +234,7 @@ public:
longlong val_int(); longlong val_int();
optimize_type select_optimize() const { return OPTIMIZE_NONE; } optimize_type select_optimize() const { return OPTIMIZE_NONE; }
const char *func_name() const { return "isempty"; } const char *func_name() const { return "isempty"; }
void fix_length_and_dec() { maybe_null= 1; }
}; };
class Item_func_issimple: public Item_bool_func class Item_func_issimple: public Item_bool_func
...@@ -239,6 +244,7 @@ public: ...@@ -239,6 +244,7 @@ public:
longlong val_int(); longlong val_int();
optimize_type select_optimize() const { return OPTIMIZE_NONE; } optimize_type select_optimize() const { return OPTIMIZE_NONE; }
const char *func_name() const { return "issimple"; } const char *func_name() const { return "issimple"; }
void fix_length_and_dec() { maybe_null= 1; }
}; };
class Item_func_isclosed: public Item_bool_func class Item_func_isclosed: public Item_bool_func
...@@ -248,6 +254,7 @@ public: ...@@ -248,6 +254,7 @@ public:
longlong val_int(); longlong val_int();
optimize_type select_optimize() const { return OPTIMIZE_NONE; } optimize_type select_optimize() const { return OPTIMIZE_NONE; }
const char *func_name() const { return "isclosed"; } const char *func_name() const { return "isclosed"; }
void fix_length_and_dec() { maybe_null= 1; }
}; };
class Item_func_dimension: public Item_int_func class Item_func_dimension: public Item_int_func
...@@ -257,7 +264,7 @@ public: ...@@ -257,7 +264,7 @@ public:
Item_func_dimension(Item *a): Item_int_func(a) {} Item_func_dimension(Item *a): Item_int_func(a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "dimension"; } const char *func_name() const { return "dimension"; }
void fix_length_and_dec() { max_length=10; } void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
}; };
class Item_func_x: public Item_real_func class Item_func_x: public Item_real_func
...@@ -267,6 +274,11 @@ public: ...@@ -267,6 +274,11 @@ public:
Item_func_x(Item *a): Item_real_func(a) {} Item_func_x(Item *a): Item_real_func(a) {}
double val(); double val();
const char *func_name() const { return "x"; } const char *func_name() const { return "x"; }
void fix_length_and_dec()
{
Item_real_func::fix_length_and_dec();
maybe_null= 1;
}
}; };
...@@ -277,6 +289,11 @@ public: ...@@ -277,6 +289,11 @@ public:
Item_func_y(Item *a): Item_real_func(a) {} Item_func_y(Item *a): Item_real_func(a) {}
double val(); double val();
const char *func_name() const { return "y"; } const char *func_name() const { return "y"; }
void fix_length_and_dec()
{
Item_real_func::fix_length_and_dec();
maybe_null= 1;
}
}; };
...@@ -287,7 +304,7 @@ public: ...@@ -287,7 +304,7 @@ public:
Item_func_numgeometries(Item *a): Item_int_func(a) {} Item_func_numgeometries(Item *a): Item_int_func(a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "numgeometries"; } const char *func_name() const { return "numgeometries"; }
void fix_length_and_dec() { max_length=10; } void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
}; };
...@@ -298,7 +315,7 @@ public: ...@@ -298,7 +315,7 @@ public:
Item_func_numinteriorring(Item *a): Item_int_func(a) {} Item_func_numinteriorring(Item *a): Item_int_func(a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "numinteriorrings"; } const char *func_name() const { return "numinteriorrings"; }
void fix_length_and_dec() { max_length=10; } void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
}; };
...@@ -309,7 +326,7 @@ public: ...@@ -309,7 +326,7 @@ public:
Item_func_numpoints(Item *a): Item_int_func(a) {} Item_func_numpoints(Item *a): Item_int_func(a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "numpoints"; } const char *func_name() const { return "numpoints"; }
void fix_length_and_dec() { max_length=10; } void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
}; };
...@@ -320,6 +337,11 @@ public: ...@@ -320,6 +337,11 @@ public:
Item_func_area(Item *a): Item_real_func(a) {} Item_func_area(Item *a): Item_real_func(a) {}
double val(); double val();
const char *func_name() const { return "area"; } const char *func_name() const { return "area"; }
void fix_length_and_dec()
{
Item_real_func::fix_length_and_dec();
maybe_null= 1;
}
}; };
...@@ -330,6 +352,11 @@ public: ...@@ -330,6 +352,11 @@ public:
Item_func_glength(Item *a): Item_real_func(a) {} Item_func_glength(Item *a): Item_real_func(a) {}
double val(); double val();
const char *func_name() const { return "glength"; } const char *func_name() const { return "glength"; }
void fix_length_and_dec()
{
Item_real_func::fix_length_and_dec();
maybe_null= 1;
}
}; };
...@@ -340,7 +367,7 @@ public: ...@@ -340,7 +367,7 @@ public:
Item_func_srid(Item *a): Item_int_func(a) {} Item_func_srid(Item *a): Item_int_func(a) {}
longlong val_int(); longlong val_int();
const char *func_name() const { return "srid"; } const char *func_name() const { return "srid"; }
void fix_length_and_dec() { max_length= 10; } void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
}; };
#define GEOM_NEW(obj_constructor) new obj_constructor #define GEOM_NEW(obj_constructor) new obj_constructor
......
...@@ -1933,7 +1933,10 @@ static void check_data_home(const char *path) ...@@ -1933,7 +1933,10 @@ static void check_data_home(const char *path)
extern "C" sig_handler handle_segfault(int sig) extern "C" sig_handler handle_segfault(int sig)
{ {
time_t curr_time;
struct tm tm;
THD *thd=current_thd; THD *thd=current_thd;
/* /*
Strictly speaking, one needs a mutex here Strictly speaking, one needs a mutex here
but since we have got SIGSEGV already, things are a mess but since we have got SIGSEGV already, things are a mess
...@@ -1947,11 +1950,17 @@ extern "C" sig_handler handle_segfault(int sig) ...@@ -1947,11 +1950,17 @@ extern "C" sig_handler handle_segfault(int sig)
} }
segfaulted = 1; segfaulted = 1;
curr_time= time(NULL);
localtime_r(&curr_time, &tm);
fprintf(stderr,"\ fprintf(stderr,"\
mysqld got signal %d;\n\ %02d%02d%02d %2d:%02d:%02d - mysqld got signal %d;\n\
This could be because you hit a bug. It is also possible that this binary\n\ This could be because you hit a bug. It is also possible that this binary\n\
or one of the libraries it was linked against is corrupt, improperly built,\n\ or one of the libraries it was linked against is corrupt, improperly built,\n\
or misconfigured. This error can also be caused by malfunctioning hardware.\n", or misconfigured. This error can also be caused by malfunctioning hardware.\n",
tm.tm_year % 100, tm.tm_mon+1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec,
sig); sig);
fprintf(stderr, "\ fprintf(stderr, "\
We will try our best to scrape up some info that will hopefully help diagnose\n\ We will try our best to scrape up some info that will hopefully help diagnose\n\
......
...@@ -210,23 +210,24 @@ static uint32 wkb_get_uint(const char *ptr, Geometry::wkbByteOrder bo) ...@@ -210,23 +210,24 @@ static uint32 wkb_get_uint(const char *ptr, Geometry::wkbByteOrder bo)
} }
int Geometry::create_from_wkb(Geometry_buffer *buffer, Geometry *Geometry::create_from_wkb(Geometry_buffer *buffer,
const char *wkb, uint32 len, String *res) const char *wkb, uint32 len, String *res)
{ {
uint32 geom_type; uint32 geom_type;
Geometry *geom; Geometry *geom;
if (len < WKB_HEADER_SIZE) if (len < WKB_HEADER_SIZE)
return 1; return NULL;
geom_type= wkb_get_uint(wkb+1, (wkbByteOrder)wkb[0]); geom_type= wkb_get_uint(wkb+1, (wkbByteOrder)wkb[0]);
if (!(geom= create_by_typeid(buffer, (int) geom_type)) || if (!(geom= create_by_typeid(buffer, (int) geom_type)) ||
res->reserve(WKB_HEADER_SIZE, 512)) res->reserve(WKB_HEADER_SIZE, 512))
return 1; return NULL;
res->q_append((char) wkb_ndr); res->q_append((char) wkb_ndr);
res->q_append(geom_type); res->q_append(geom_type);
return geom->init_from_wkb(wkb+WKB_HEADER_SIZE, len - WKB_HEADER_SIZE,
(wkbByteOrder) wkb[0], res); return geom->init_from_wkb(wkb + WKB_HEADER_SIZE, len - WKB_HEADER_SIZE,
(wkbByteOrder) wkb[0], res) ? geom : NULL;
} }
......
...@@ -244,8 +244,8 @@ public: ...@@ -244,8 +244,8 @@ public:
static Geometry *create_from_wkt(Geometry_buffer *buffer, static Geometry *create_from_wkt(Geometry_buffer *buffer,
Gis_read_stream *trs, String *wkt, Gis_read_stream *trs, String *wkt,
bool init_stream=1); bool init_stream=1);
static int create_from_wkb(Geometry_buffer *buffer, static Geometry *create_from_wkb(Geometry_buffer *buffer, const char *wkb,
const char *wkb, uint32 len, String *res); uint32 len, String *res);
int as_wkt(String *wkt, const char **end) int as_wkt(String *wkt, const char **end)
{ {
uint32 len= get_class_info()->m_name.length; uint32 len= get_class_info()->m_name.length;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment