Commit 3f2210c0 authored by serg@serg.mylan's avatar serg@serg.mylan

after merge fixes

parent e1237cbc
...@@ -907,3 +907,4 @@ ndb/test/tools/hugoScanUpdate ...@@ -907,3 +907,4 @@ ndb/test/tools/hugoScanUpdate
ndb/test/tools/ndb_cpcc ndb/test/tools/ndb_cpcc
ndb/test/tools/restart ndb/test/tools/restart
ndb/test/tools/verify_index ndb/test/tools/verify_index
EXCEPTIONS-CLIENT
...@@ -613,7 +613,6 @@ show_failed_diff () ...@@ -613,7 +613,6 @@ show_failed_diff ()
echo "http://www.mysql.com/doc/en/Reporting_mysqltest_bugs.html" echo "http://www.mysql.com/doc/en/Reporting_mysqltest_bugs.html"
echo "to find the reason to this problem and how to report this." echo "to find the reason to this problem and how to report this."
echo "" echo ""
echo "Test $1 failed!"
fi fi
} }
......
...@@ -478,7 +478,7 @@ alter table t1 drop key a; ...@@ -478,7 +478,7 @@ alter table t1 drop key a;
drop table t1; drop table t1;
create table t1 (a int); create table t1 (a int);
alter table t1 rename to `t1\\`; alter table t1 rename to `t1\\`;
Incorrect table name 't1\\' ERROR 42000: Incorrect table name 't1\\'
rename table t1 to `t1\\`; rename table t1 to `t1\\`;
Incorrect table name 't1\\' ERROR 42000: Incorrect table name 't1\\'
drop table t1; drop table t1;
...@@ -43,7 +43,7 @@ Warnings: ...@@ -43,7 +43,7 @@ Warnings:
Note 1003 select abs(-(10)) AS `abs(-10)`,sign(-(5)) AS `sign(-5)`,sign(5) AS `sign(5)`,sign(0) AS `sign(0)` Note 1003 select abs(-(10)) AS `abs(-10)`,sign(-(5)) AS `sign(-5)`,sign(5) AS `sign(5)`,sign(0) AS `sign(0)`
select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2); select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
log(exp(10)) exp(log(sqrt(10))*2) log(-1) log(NULL) log(1,1) log(3,9) log(-1,2) log(NULL,2) log(exp(10)) exp(log(sqrt(10))*2) log(-1) log(NULL) log(1,1) log(3,9) log(-1,2) log(NULL,2)
10.000000 10.000000 NULL NULL NULL 2.000000 NULL NULL 10 10 NULL NULL NULL 2 NULL NULL
explain extended select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2); explain extended select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
id select_type table type possible_keys key key_len ref rows Extra 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 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
...@@ -51,7 +51,7 @@ Warnings: ...@@ -51,7 +51,7 @@ Warnings:
Note 1003 select log(exp(10)) AS `log(exp(10))`,exp((log(sqrt(10)) * 2)) AS `exp(log(sqrt(10))*2)`,log(-(1)) AS `log(-1)`,log(NULL) AS `log(NULL)`,log(1,1) AS `log(1,1)`,log(3,9) AS `log(3,9)`,log(-(1),2) AS `log(-1,2)`,log(NULL,2) AS `log(NULL,2)` Note 1003 select log(exp(10)) AS `log(exp(10))`,exp((log(sqrt(10)) * 2)) AS `exp(log(sqrt(10))*2)`,log(-(1)) AS `log(-1)`,log(NULL) AS `log(NULL)`,log(1,1) AS `log(1,1)`,log(3,9) AS `log(3,9)`,log(-(1),2) AS `log(-1,2)`,log(NULL,2) AS `log(NULL,2)`
select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL); select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
ln(exp(10)) exp(ln(sqrt(10))*2) ln(-1) ln(0) ln(NULL) ln(exp(10)) exp(ln(sqrt(10))*2) ln(-1) ln(0) ln(NULL)
10.000000 10.000000 NULL NULL NULL 10 10 NULL NULL NULL
explain extended select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL); explain extended select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
id select_type table type possible_keys key key_len ref rows Extra 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 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
...@@ -59,7 +59,7 @@ Warnings: ...@@ -59,7 +59,7 @@ Warnings:
Note 1003 select ln(exp(10)) AS `ln(exp(10))`,exp((ln(sqrt(10)) * 2)) AS `exp(ln(sqrt(10))*2)`,ln(-(1)) AS `ln(-1)`,ln(0) AS `ln(0)`,ln(NULL) AS `ln(NULL)` Note 1003 select ln(exp(10)) AS `ln(exp(10))`,exp((ln(sqrt(10)) * 2)) AS `exp(ln(sqrt(10))*2)`,ln(-(1)) AS `ln(-1)`,ln(0) AS `ln(0)`,ln(NULL) AS `ln(NULL)`
select log2(8),log2(15),log2(-2),log2(0),log2(NULL); select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
log2(8) log2(15) log2(-2) log2(0) log2(NULL) log2(8) log2(15) log2(-2) log2(0) log2(NULL)
3.000000 3.906891 NULL NULL NULL 3 3.9068905956085 NULL NULL NULL
explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL); explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
id select_type table type possible_keys key key_len ref rows Extra 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 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
...@@ -67,7 +67,7 @@ Warnings: ...@@ -67,7 +67,7 @@ Warnings:
Note 1003 select log2(8) AS `log2(8)`,log2(15) AS `log2(15)`,log2(-(2)) AS `log2(-2)`,log2(0) AS `log2(0)`,log2(NULL) AS `log2(NULL)` Note 1003 select log2(8) AS `log2(8)`,log2(15) AS `log2(15)`,log2(-(2)) AS `log2(-2)`,log2(0) AS `log2(0)`,log2(NULL) AS `log2(NULL)`
select log10(100),log10(18),log10(-4),log10(0),log10(NULL); select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
log10(100) log10(18) log10(-4) log10(0) log10(NULL) log10(100) log10(18) log10(-4) log10(0) log10(NULL)
2.000000 1.255273 NULL NULL NULL 2 1.2552725051033 NULL NULL NULL
explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL); explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
id select_type table type possible_keys key key_len ref rows Extra 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 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
...@@ -75,7 +75,7 @@ Warnings: ...@@ -75,7 +75,7 @@ Warnings:
Note 1003 select log10(100) AS `log10(100)`,log10(18) AS `log10(18)`,log10(-(4)) AS `log10(-4)`,log10(0) AS `log10(0)`,log10(NULL) AS `log10(NULL)` Note 1003 select log10(100) AS `log10(100)`,log10(18) AS `log10(18)`,log10(-(4)) AS `log10(-4)`,log10(0) AS `log10(0)`,log10(NULL) AS `log10(NULL)`
select pow(10,log10(10)),power(2,4); select pow(10,log10(10)),power(2,4);
pow(10,log10(10)) power(2,4) pow(10,log10(10)) power(2,4)
10.000000 16.000000 10 16
explain extended select pow(10,log10(10)),power(2,4); explain extended select pow(10,log10(10)),power(2,4);
id select_type table type possible_keys key key_len ref rows Extra 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 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
...@@ -90,35 +90,35 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -90,35 +90,35 @@ 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 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select sql_no_cache rand(999999) AS `rand(999999)`,rand() AS `rand()` Note 1003 select sql_no_cache rand(999999) AS `rand(999999)`,rand() AS `rand()`
select pi(),sin(pi()/2),cos(pi()/2),abs(tan(pi())),cot(1),asin(1),acos(0),atan(1); select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6),format(cot(1),6),format(asin(1),6),format(acos(0),6),format(atan(1),6);
pi() sin(pi()/2) cos(pi()/2) abs(tan(pi())) cot(1) asin(1) acos(0) atan(1) pi() format(sin(pi()/2),6) format(cos(pi()/2),6) format(abs(tan(pi())),6) format(cot(1),6) format(asin(1),6) format(acos(0),6) format(atan(1),6)
3.141593 1.000000 0.000000 0.000000 0.64209262 1.570796 1.570796 0.785398 3.141593 1.000000 0.000000 0.000000 0.642093 1.570796 1.570796 0.785398
explain extended select pi(),sin(pi()/2),cos(pi()/2),abs(tan(pi())),cot(1),asin(1),acos(0),atan(1); explain extended select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6),format(cot(1),6),format(asin(1),6),format(acos(0),6),format(atan(1),6);
id select_type table type possible_keys key key_len ref rows Extra 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 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings: Warnings:
Note 1003 select pi() AS `pi()`,sin((pi() / 2)) AS `sin(pi()/2)`,cos((pi() / 2)) AS `cos(pi()/2)`,abs(tan(pi())) AS `abs(tan(pi()))`,(1 / tan(1)) AS `cot(1)`,asin(1) AS `asin(1)`,acos(0) AS `acos(0)`,atan(1) AS `atan(1)` Note 1003 select pi() AS `pi()`,format(sin((pi() / 2)),6) AS `format(sin(pi()/2),6)`,format(cos((pi() / 2)),6) AS `format(cos(pi()/2),6)`,format(abs(tan(pi())),6) AS `format(abs(tan(pi())),6)`,format((1 / tan(1)),6) AS `format(cot(1),6)`,format(asin(1),6) AS `format(asin(1),6)`,format(acos(0),6) AS `format(acos(0),6)`,format(atan(1),6) AS `format(atan(1),6)`
select degrees(pi()),radians(360); select degrees(pi()),radians(360);
degrees(pi()) radians(360) degrees(pi()) radians(360)
180 6.2831853071796 180 6.2831853071796
SELECT ACOS(1.0); SELECT ACOS(1.0);
ACOS(1.0) ACOS(1.0)
0.000000 0
SELECT ASIN(1.0); SELECT ASIN(1.0);
ASIN(1.0) ASIN(1.0)
1.570796 1.5707963267949
SELECT ACOS(0.2*5.0); SELECT ACOS(0.2*5.0);
ACOS(0.2*5.0) ACOS(0.2*5.0)
0.000000 0
SELECT ACOS(0.5*2.0); SELECT ACOS(0.5*2.0);
ACOS(0.5*2.0) ACOS(0.5*2.0)
0.000000 0
SELECT ASIN(0.8+0.2); SELECT ASIN(0.8+0.2);
ASIN(0.8+0.2) ASIN(0.8+0.2)
1.570796 1.5707963267949
SELECT ASIN(1.2-0.2); SELECT ASIN(1.2-0.2);
ASIN(1.2-0.2) ASIN(1.2-0.2)
1.570796 1.5707963267949
explain extended select degrees(pi()),radians(360); explain extended select degrees(pi()),radians(360);
id select_type table type possible_keys key key_len ref rows Extra 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 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
......
...@@ -229,3 +229,22 @@ GRANT SELECT ( ...@@ -229,3 +229,22 @@ GRANT SELECT (
REVOKE SELECT () ON . FROM @localhost; REVOKE SELECT () ON . FROM @localhost;
DROP DATABASE ; DROP DATABASE ;
SET NAMES latin1; SET NAMES latin1;
insert into mysql.user (host, user) values ('localhost', 'test11');
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;
flush privileges;
show grants for test11@localhost;
Grants for test11@localhost
GRANT USAGE ON *.* TO 'test11'@'localhost'
GRANT SELECT ON `ab%`.* TO 'test11'@'localhost'
GRANT SELECT ON `a%`.* TO 'test11'@'localhost'
alter table mysql.db order by db desc;
flush privileges;
show grants for test11@localhost;
Grants for test11@localhost
GRANT USAGE ON *.* TO 'test11'@'localhost'
GRANT SELECT ON `ab%`.* TO 'test11'@'localhost'
GRANT SELECT ON `a%`.* TO 'test11'@'localhost'
delete from mysql.user where user='test11';
delete from mysql.db where user='test11';
...@@ -90,17 +90,17 @@ drop table t1; ...@@ -90,17 +90,17 @@ drop table t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
`id` bigint(20) NOT NULL default '0', `id` bigint(20) NOT NULL default '0',
`description` text `description` text
) TYPE=MyISAM; ) ENGINE=MyISAM;
CREATE TABLE t2 ( CREATE TABLE t2 (
`id` bigint(20) NOT NULL default '0', `id` bigint(20) NOT NULL default '0',
`description` varchar(20) `description` varchar(20)
) TYPE=MyISAM; ) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1, 'test'); INSERT INTO t1 VALUES (1, 'test');
INSERT INTO t2 VALUES (1, 'test'); INSERT INTO t2 VALUES (1, 'test');
CREATE TABLE t3 ( CREATE TABLE t3 (
`id` bigint(20) NOT NULL default '0', `id` bigint(20) NOT NULL default '0',
`order_id` bigint(20) NOT NULL default '0' `order_id` bigint(20) NOT NULL default '0'
) TYPE=MyISAM; ) ENGINE=MyISAM;
select select
a.id, a.description, a.id, a.description,
count(b.id) as c count(b.id) as c
......
...@@ -222,7 +222,7 @@ CREATE TABLE `job_titles` ( ...@@ -222,7 +222,7 @@ CREATE TABLE `job_titles` (
`job_title` char(18) NOT NULL default '', `job_title` char(18) NOT NULL default '',
PRIMARY KEY (`job_title_id`), PRIMARY KEY (`job_title_id`),
UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`) UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`)
) TYPE=HEAP; ) ENGINE=HEAP;
SELECT MAX(job_title_id) FROM job_titles; SELECT MAX(job_title_id) FROM job_titles;
MAX(job_title_id) MAX(job_title_id)
NULL NULL
......
...@@ -529,3 +529,12 @@ show keys from t1; ...@@ -529,3 +529,12 @@ show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 a 1 a NULL NULL NULL NULL YES HASH t1 1 a 1 a NULL NULL NULL NULL YES HASH
drop table t1,t2; drop table t1,t2;
create table t1 ( a tinytext, b char(1), index idx (a(1),b) );
insert into t1 values (null,''), (null,'');
explain select count(*) from t1 where a is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref idx idx 4 const 1 Using where
select count(*) from t1 where a is null;
count(*)
2
drop table t1;
...@@ -5,8 +5,12 @@ insert into t1 values (1); ...@@ -5,8 +5,12 @@ insert into t1 values (1);
insert into t1 values (-1); insert into t1 values (-1);
Warnings: Warnings:
Warning 1264 Data truncated; out of range for column 'this' at row 1 Warning 1264 Data truncated; out of range for column 'this' at row 1
insert into t1 values ('5000000000');
Warnings:
Warning 1265 Data truncated for column 'this' at row 1
select * from t1; select * from t1;
this this
1 1
0 0
4294967295
drop table t1; drop table t1;
...@@ -84,12 +84,12 @@ drop table t1; ...@@ -84,12 +84,12 @@ drop table t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
`id` bigint(20) NOT NULL default '0', `id` bigint(20) NOT NULL default '0',
`description` text `description` text
) TYPE=MyISAM; ) ENGINE=MyISAM;
CREATE TABLE t2 ( CREATE TABLE t2 (
`id` bigint(20) NOT NULL default '0', `id` bigint(20) NOT NULL default '0',
`description` varchar(20) `description` varchar(20)
) TYPE=MyISAM; ) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1, 'test'); INSERT INTO t1 VALUES (1, 'test');
INSERT INTO t2 VALUES (1, 'test'); INSERT INTO t2 VALUES (1, 'test');
...@@ -97,7 +97,7 @@ INSERT INTO t2 VALUES (1, 'test'); ...@@ -97,7 +97,7 @@ INSERT INTO t2 VALUES (1, 'test');
CREATE TABLE t3 ( CREATE TABLE t3 (
`id` bigint(20) NOT NULL default '0', `id` bigint(20) NOT NULL default '0',
`order_id` bigint(20) NOT NULL default '0' `order_id` bigint(20) NOT NULL default '0'
) TYPE=MyISAM; ) ENGINE=MyISAM;
select select
a.id, a.description, a.id, a.description,
......
...@@ -159,7 +159,7 @@ CREATE TABLE `job_titles` ( ...@@ -159,7 +159,7 @@ CREATE TABLE `job_titles` (
`job_title` char(18) NOT NULL default '', `job_title` char(18) NOT NULL default '',
PRIMARY KEY (`job_title_id`), PRIMARY KEY (`job_title_id`),
UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`) UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`)
) TYPE=HEAP; ) ENGINE=HEAP;
SELECT MAX(job_title_id) FROM job_titles; SELECT MAX(job_title_id) FROM job_titles;
......
...@@ -234,14 +234,3 @@ alter table t1 add i int default 10; ...@@ -234,14 +234,3 @@ alter table t1 add i int default 10;
select * from t1; select * from t1;
drop table t1; drop table t1;
#
# Test for bug #4491, TIMESTAMP(19) should be possible to create and not
# only read in 4.0
#
create table t1 (ts timestamp(19));
show create table t1;
set TIMESTAMP=1000000000;
insert into t1 values ();
select * from t1;
drop table t1;
...@@ -1037,7 +1037,7 @@ void mysql_read_default_options(struct st_mysql_options *options, ...@@ -1037,7 +1037,7 @@ void mysql_read_default_options(struct st_mysql_options *options,
options->client_flag&= ~CLIENT_LOCAL_FILES; options->client_flag&= ~CLIENT_LOCAL_FILES;
break; break;
case 22: case 22:
options->client_flag&= CLIENT_LOCAL_FILES; options->client_flag&= ~CLIENT_LOCAL_FILES;
break; break;
case 23: /* replication probe */ case 23: /* replication probe */
#ifndef TO_BE_DELETED #ifndef TO_BE_DELETED
......
...@@ -4268,24 +4268,21 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) ...@@ -4268,24 +4268,21 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
Store double value in Field_string or Field_varstring. Store double value in Field_string or Field_varstring.
SYNOPSIS SYNOPSIS
store_double_in_string_field() store(double nr)
field field to store value in
field_length number of characters in the field
nr number nr number
DESCRIPTION DESCRIPTION
Pretty prints double number into field_length characters buffer. Pretty prints double number into field_length characters buffer.
*/ */
static int store_double_in_string_field(Field_str *field, uint32 field_length, int Field_str::store(double nr)
double nr)
{ {
bool use_scientific_notation=TRUE; bool use_scientific_notation=TRUE;
char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE]; char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
int length; int length;
if (field_length < 32 && nr > 1) if (field_length < 32 && nr > 1) // TODO: negative numbers
{ {
if (field->ceiling == 0) if (ceiling == 0)
{ {
static double e[]= {1e1, 1e2, 1e4, 1e8, 1e16 }; static double e[]= {1e1, 1e2, 1e4, 1e8, 1e16 };
double p= 1; double p= 1;
...@@ -4294,23 +4291,17 @@ static int store_double_in_string_field(Field_str *field, uint32 field_length, ...@@ -4294,23 +4291,17 @@ static int store_double_in_string_field(Field_str *field, uint32 field_length,
if (field_length & j) if (field_length & j)
p*= e[i]; p*= e[i];
} }
field->ceiling= p-1; ceiling= p-1;
} }
use_scientific_notation= (field->ceiling < nr); use_scientific_notation= (ceiling < nr);
} }
length= sprintf(buff, "%-.*g", length= sprintf(buff, "%-.*g",
use_scientific_notation ? max(0,field_length-5) : field_length, use_scientific_notation ? max(0,field_length-5) : field_length,
nr); nr);
DBUG_ASSERT(length <= field_length); DBUG_ASSERT(length <= field_length);
return field->store(buff, (uint) length); return store((const char *)buff, (uint) length, charset());
} }
int Field_string::store(double nr)
{
return store_double_in_string_field(this, field_length, nr);
}
int Field_string::store(longlong nr) int Field_string::store(longlong nr)
{ {
char buff[64]; char buff[64];
...@@ -4479,12 +4470,6 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs) ...@@ -4479,12 +4470,6 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
} }
int Field_varstring::store(double nr)
{
return store_double_in_string_field(this, field_length, nr);
}
int Field_varstring::store(longlong nr) int Field_varstring::store(longlong nr)
{ {
char buff[64]; char buff[64];
......
...@@ -336,21 +336,23 @@ class Field_num :public Field { ...@@ -336,21 +336,23 @@ class Field_num :public Field {
class Field_str :public Field { class Field_str :public Field {
protected: protected:
CHARSET_INFO *field_charset; CHARSET_INFO *field_charset;
public:
double ceiling; // for ::store(double nr) double ceiling; // for ::store(double nr)
public:
Field_str(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, Field_str(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg, uchar null_bit_arg, utype unireg_check_arg,
const char *field_name_arg, const char *field_name_arg,
struct st_table *table_arg,CHARSET_INFO *charset) struct st_table *table_arg,CHARSET_INFO *charset)
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, table_arg), ceiling(0.0) unireg_check_arg, field_name_arg, table_arg), ceiling(0.0)
{ {
field_charset=charset; field_charset=charset;
if (charset->state & MY_CS_BINSORT) if (charset->state & MY_CS_BINSORT)
flags|=BINARY_FLAG; flags|=BINARY_FLAG;
} }
Item_result result_type () const { return STRING_RESULT; } Item_result result_type () const { return STRING_RESULT; }
uint decimals() const { return NOT_FIXED_DEC; } uint decimals() const { return NOT_FIXED_DEC; }
int store(double nr);
int store(const char *to,uint length,CHARSET_INFO *cs)=0;
void make_field(Send_field *); void make_field(Send_field *);
uint size_of() const { return sizeof(*this); } uint size_of() const { return sizeof(*this); }
CHARSET_INFO *charset(void) const { return field_charset; } CHARSET_INFO *charset(void) const { return field_charset; }
...@@ -905,7 +907,6 @@ class Field_string :public Field_str { ...@@ -905,7 +907,6 @@ class Field_string :public Field_str {
bool zero_pack() const { return 0; } bool zero_pack() const { return 0; }
void reset(void) { charset()->cset->fill(charset(),ptr,field_length,' '); } void reset(void) { charset()->cset->fill(charset(),ptr,field_length,' '); }
int store(const char *to,uint length,CHARSET_INFO *charset); int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr); int store(longlong nr);
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
...@@ -951,7 +952,6 @@ class Field_varstring :public Field_str { ...@@ -951,7 +952,6 @@ class Field_varstring :public Field_str {
uint32 pack_length() const { return (uint32) field_length+2; } uint32 pack_length() const { return (uint32) field_length+2; }
uint32 key_length() const { return (uint32) field_length; } uint32 key_length() const { return (uint32) field_length; }
int store(const char *to,uint length,CHARSET_INFO *charset); int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr); int store(longlong nr);
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
......
...@@ -200,13 +200,13 @@ net_printf(THD *thd, uint errcode, ...) ...@@ -200,13 +200,13 @@ net_printf(THD *thd, uint errcode, ...)
2+SQLSTATE_LENGTH+1 : 2) : 0); 2+SQLSTATE_LENGTH+1 : 2) : 0);
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
text_pos=(char*) net->buff + head_length + offset + 1; text_pos=(char*) net->buff + head_length + offset + 1;
length=(char*)net->buff_end-text_pos;
#else
length=sizeof(text_pos)-1;
#endif #endif
(void) my_vsnprintf(my_const_cast(char*) (text_pos), length=my_vsnprintf(my_const_cast(char*) (text_pos),
(char*)net->buff_end-text_pos, min(length, sizeof(net->last_error)),
format,args); format,args);
length=(uint) strlen((char*) text_pos);
if (length >= sizeof(net->last_error))
length=sizeof(net->last_error)-1; /* purecov: inspected */
va_end(args); va_end(args);
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
......
...@@ -95,6 +95,14 @@ class String ...@@ -95,6 +95,14 @@ class String
Ptr[str_length]=0; Ptr[str_length]=0;
return Ptr; return Ptr;
} }
inline char *c_ptr_safe()
{
if (Ptr && str_length < Alloced_length)
Ptr[str_length]=0;
else
(void) realloc(str_length);
return Ptr;
}
void set(String &str,uint32 offset,uint32 arg_length) void set(String &str,uint32 offset,uint32 arg_length)
{ {
......
...@@ -1936,7 +1936,7 @@ alter_list_item: ...@@ -1936,7 +1936,7 @@ alter_list_item:
if (check_table_name($3->table.str,$3->table.length) || if (check_table_name($3->table.str,$3->table.length) ||
$3->db.str && check_db_name($3->db.str)) $3->db.str && check_db_name($3->db.str))
{ {
net_printf(&lex->thd->net,ER_WRONG_TABLE_NAME,$3->table.str); net_printf(lex->thd,ER_WRONG_TABLE_NAME,$3->table.str);
YYABORT; YYABORT;
} }
lex->alter_info.flags|= ALTER_RENAME; lex->alter_info.flags|= ALTER_RENAME;
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
%#[l]d %#[l]d
%#[l]u %#[l]u
%#[l]x %#[l]x
%#.#s Note #.# is skiped %#.#s Note first # is ignored
RETURN RETURN
length of result string length of result string
...@@ -47,7 +47,7 @@ int my_snprintf(char* to, size_t n, const char* fmt, ...) ...@@ -47,7 +47,7 @@ int my_snprintf(char* to, size_t n, const char* fmt, ...)
int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
{ {
char *start=to, *end=to+n-1; char *start=to, *end=to+n-1;
uint length, num_state, pre_zero, have_long; uint length, width, pre_zero, have_long;
for (; *fmt ; fmt++) for (; *fmt ; fmt++)
{ {
...@@ -62,23 +62,18 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) ...@@ -62,23 +62,18 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
/* Read max fill size (only used with %d and %u) */ /* Read max fill size (only used with %d and %u) */
if (*fmt == '-') if (*fmt == '-')
fmt++; fmt++;
length= num_state= pre_zero= have_long= 0; length= width= pre_zero= have_long= 0;
for (;; fmt++) for (;my_isdigit(&my_charset_latin1,*fmt); fmt++)
{ {
if (my_isdigit(&my_charset_latin1,*fmt)) length=length*10+ (uint) (*fmt-'0');
{ if (!length)
if (!num_state) pre_zero= 1; /* first digit was 0 */
{
length=length*10+ (uint) (*fmt-'0');
if (!length)
pre_zero= 1; /* first digit was 0 */
}
continue;
}
if (*fmt != '.' || num_state)
break;
num_state= 1;
} }
if (*fmt == '.')
for (fmt++;my_isdigit(&my_charset_latin1,*fmt); fmt++)
width=width*10+ (uint) (*fmt-'0');
else
width= ~0;
if (*fmt == 'l') if (*fmt == 'l')
{ {
fmt++; fmt++;
...@@ -90,6 +85,7 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) ...@@ -90,6 +85,7 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
uint plen,left_len = (uint)(end-to)+1; uint plen,left_len = (uint)(end-to)+1;
if (!par) par = (char*)"(null)"; if (!par) par = (char*)"(null)";
plen = (uint) strlen(par); plen = (uint) strlen(par);
set_if_smaller(plen,width);
if (left_len <= plen) if (left_len <= plen)
plen = left_len - 1; plen = left_len - 1;
to=strnmov(to,par,plen); to=strnmov(to,par,plen);
......
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