Commit c19d2c1e authored by igor@rurik.mysql.com's avatar igor@rurik.mysql.com

Merge rurik.mysql.com:/home/igor/mysql-5.0

into rurik.mysql.com:/home/igor/dev/mysql-5.0-0
parents f93e7cc7 093789aa
......@@ -1045,8 +1045,12 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
/* We don't need to lock the key tree here as we don't allow
concurrent threads when running myisamchk
*/
if (_mi_search(info,keyinfo,info->lastkey,key_length,
SEARCH_SAME, info->s->state.key_root[key]))
int search_result= (keyinfo->flag & HA_SPATIAL) ?
rtree_find_first(info, key, info->lastkey, key_length,
SEARCH_SAME) :
_mi_search(info,keyinfo,info->lastkey,key_length,
SEARCH_SAME, info->s->state.key_root[key]);
if (search_result)
{
mi_check_print_error(param,"Record at: %10s Can't find key for index: %2d",
llstr(start_recpos,llbuff),key+1);
......
......@@ -803,3 +803,16 @@ CREATE TABLE t2 (geom GEOMETRY NOT NULL, SPATIAL KEY gk(geom));
INSERT INTO t2 SELECT GeomFromText(st) FROM t1;
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1, t2;
CREATE TABLE t1 (`geometry` geometry NOT NULL default '',SPATIAL KEY `gndx` (`geometry`(32))) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO t1 (geometry) VALUES
(PolygonFromText('POLYGON((-18.6086111000 -66.9327777000, -18.6055555000
-66.8158332999, -18.7186111000 -66.8102777000, -18.7211111000 -66.9269443999,
-18.6086111000 -66.9327777000))'));
INSERT INTO t1 (geometry) VALUES
(PolygonFromText('POLYGON((-65.7402776999 -96.6686111000, -65.7372222000
-96.5516666000, -65.8502777000 -96.5461111000, -65.8527777000 -96.6627777000,
-65.7402776999 -96.6686111000))'));
check table t1 extended;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
......@@ -670,3 +670,13 @@ create trigger t1_bu before update on t1 for each row set new.s1 = null;
insert into t1 values (null,null);
ERROR 23000: Column 's1' cannot be null
drop table t1;
drop procedure if exists fn3;
create function fn3 () returns point return GeomFromText("point(1 1)");
show create function fn3;
Function sql_mode Create Function
fn3 CREATE FUNCTION `fn3`() RETURNS point
return GeomFromText("point(1 1)")
select astext(fn3());
astext(fn3())
POINT(1 1)
drop function fn3;
......@@ -308,7 +308,7 @@ Function sql_mode Create Function
sub1
show create function sub2;
Function sql_mode Create Function
sub2 CREATE FUNCTION `test`.`sub2`(i int) RETURNS int(11)
sub2 CREATE FUNCTION `sub2`(i int) RETURNS int(11)
return i+1
show function status like "sub2";
Db Name Type Definer Modified Created Security_type Comment
......@@ -316,7 +316,7 @@ test sub2 FUNCTION mysqltest_1@localhost # # DEFINER
drop function sub2;
show create procedure sel2;
Procedure sql_mode Create Procedure
sel2 CREATE PROCEDURE `test`.`sel2`()
sel2 CREATE PROCEDURE `sel2`()
begin
select * from t1;
select * from t2;
......
......@@ -788,7 +788,7 @@ comment 'Characteristics procedure test'
insert into t1 values ("chistics", 1)|
show create procedure chistics|
Procedure sql_mode Create Procedure
chistics CREATE PROCEDURE `test`.`chistics`()
chistics CREATE PROCEDURE `chistics`()
MODIFIES SQL DATA
COMMENT 'Characteristics procedure test'
insert into t1 values ("chistics", 1)
......@@ -800,7 +800,7 @@ delete from t1|
alter procedure chistics sql security invoker|
show create procedure chistics|
Procedure sql_mode Create Procedure
chistics CREATE PROCEDURE `test`.`chistics`()
chistics CREATE PROCEDURE `chistics`()
MODIFIES SQL DATA
SQL SECURITY INVOKER
COMMENT 'Characteristics procedure test'
......@@ -815,7 +815,7 @@ comment 'Characteristics procedure test'
return 42|
show create function chistics|
Function sql_mode Create Function
chistics CREATE FUNCTION `test`.`chistics`() RETURNS int(11)
chistics CREATE FUNCTION `chistics`() RETURNS int(11)
DETERMINISTIC
SQL SECURITY INVOKER
COMMENT 'Characteristics procedure test'
......@@ -828,7 +828,7 @@ no sql
comment 'Characteristics function test'|
show create function chistics|
Function sql_mode Create Function
chistics CREATE FUNCTION `test`.`chistics`() RETURNS int(11)
chistics CREATE FUNCTION `chistics`() RETURNS int(11)
NO SQL
DETERMINISTIC
SQL SECURITY INVOKER
......@@ -1210,7 +1210,7 @@ end while;
end|
show create procedure opp|
Procedure sql_mode Create Procedure
opp CREATE PROCEDURE `test`.`opp`(n bigint unsigned, out pp bool)
opp CREATE PROCEDURE `opp`(n bigint unsigned, out pp bool)
begin
declare r double;
declare b, s bigint unsigned default 0;
......@@ -1263,7 +1263,7 @@ alter procedure bar comment "3333333333"|
alter procedure bar|
show create procedure bar|
Procedure sql_mode Create Procedure
bar CREATE PROCEDURE `test`.`bar`(x char(16), y int)
bar CREATE PROCEDURE `bar`(x char(16), y int)
COMMENT '3333333333'
insert into test.t1 values (x, y)
show procedure status like 'bar'|
......@@ -1821,20 +1821,20 @@ return x || y$
set @@sql_mode = ''|
show create procedure bug2564_1|
Procedure sql_mode Create Procedure
bug2564_1 CREATE PROCEDURE `test`.`bug2564_1`()
bug2564_1 CREATE PROCEDURE `bug2564_1`()
COMMENT 'Joe''s procedure'
insert into `t1` values ("foo", 1)
show create procedure bug2564_2|
Procedure sql_mode Create Procedure
bug2564_2 ANSI_QUOTES CREATE PROCEDURE "test"."bug2564_2"()
bug2564_2 ANSI_QUOTES CREATE PROCEDURE "bug2564_2"()
insert into "t1" values ('foo', 1)
show create function bug2564_3|
Function sql_mode Create Function
bug2564_3 CREATE FUNCTION `test`.`bug2564_3`(x int, y int) RETURNS int(11)
bug2564_3 CREATE FUNCTION `bug2564_3`(x int, y int) RETURNS int(11)
return x || y
show create function bug2564_4|
Function sql_mode Create Function
bug2564_4 REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI CREATE FUNCTION "test"."bug2564_4"(x int, y int) RETURNS int(11)
bug2564_4 REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI CREATE FUNCTION "bug2564_4"(x int, y int) RETURNS int(11)
return x || y
drop procedure bug2564_1|
drop procedure bug2564_2|
......@@ -3186,4 +3186,11 @@ end|
call bug11333(10)|
drop procedure bug11333|
drop table t3|
drop function if exists bug9048|
create function bug9048(f1 char binary) returns char binary
begin
set f1= concat( 'hello', f1 );
return f1;
end|
drop function bug9048|
drop table t1,t2;
......@@ -424,23 +424,23 @@ SET @@SQL_MODE='';
create function `foo` () returns int return 5;
show create function `foo`;
Function sql_mode Create Function
foo CREATE FUNCTION `test`.`foo`() RETURNS int(11)
foo CREATE FUNCTION `foo`() RETURNS int(11)
return 5
SET @@SQL_MODE='ANSI_QUOTES';
show create function `foo`;
Function sql_mode Create Function
foo CREATE FUNCTION `test`.`foo`() RETURNS int(11)
foo CREATE FUNCTION `foo`() RETURNS int(11)
return 5
drop function `foo`;
create function `foo` () returns int return 5;
show create function `foo`;
Function sql_mode Create Function
foo ANSI_QUOTES CREATE FUNCTION "test"."foo"() RETURNS int(11)
foo ANSI_QUOTES CREATE FUNCTION "foo"() RETURNS int(11)
return 5
SET @@SQL_MODE='';
show create function `foo`;
Function sql_mode Create Function
foo ANSI_QUOTES CREATE FUNCTION "test"."foo"() RETURNS int(11)
foo ANSI_QUOTES CREATE FUNCTION "foo"() RETURNS int(11)
return 5
drop function `foo`;
SET @@SQL_MODE='';
......
......@@ -172,4 +172,19 @@ CREATE TABLE t2 (geom GEOMETRY NOT NULL, SPATIAL KEY gk(geom));
INSERT INTO t2 SELECT GeomFromText(st) FROM t1;
drop table t1, t2;
CREATE TABLE t1 (`geometry` geometry NOT NULL default '',SPATIAL KEY `gndx` (`geometry`(32))) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO t1 (geometry) VALUES
(PolygonFromText('POLYGON((-18.6086111000 -66.9327777000, -18.6055555000
-66.8158332999, -18.7186111000 -66.8102777000, -18.7211111000 -66.9269443999,
-18.6086111000 -66.9327777000))'));
INSERT INTO t1 (geometry) VALUES
(PolygonFromText('POLYGON((-65.7402776999 -96.6686111000, -65.7372222000
-96.5516666000, -65.8502777000 -96.5461111000, -65.8527777000 -96.6627777000,
-65.7402776999 -96.6686111000))'));
check table t1 extended;
drop table t1;
# End of 4.1 tests
......@@ -383,3 +383,15 @@ create trigger t1_bu before update on t1 for each row set new.s1 = null;
--error 1048
insert into t1 values (null,null);
drop table t1;
#
# Bug #10499 (function creation with GEOMETRY datatype)
#
--disable_warnings
drop procedure if exists fn3;
--enable_warnings
create function fn3 () returns point return GeomFromText("point(1 1)");
show create function fn3;
select astext(fn3());
drop function fn3;
......@@ -4030,6 +4030,19 @@ call bug11333(10)|
drop procedure bug11333|
drop table t3|
#
# BUG#9048: Creating a function with char binary IN parameter fails
#
--disable_warnings
drop function if exists bug9048|
--enable_warnings
create function bug9048(f1 char binary) returns char binary
begin
set f1= concat( 'hello', f1 );
return f1;
end|
drop function bug9048|
#
# BUG#NNNN: New bug synopsis
#
......
......@@ -1532,8 +1532,6 @@ create_string(THD *thd, String *buf,
buf->append("FUNCTION ", 9);
else
buf->append("PROCEDURE ", 10);
append_identifier(thd, buf, name->m_db.str, name->m_db.length);
buf->append('.');
append_identifier(thd, buf, name->m_name.str, name->m_name.length);
buf->append('(');
buf->append(params, paramslen);
......
......@@ -597,7 +597,7 @@ sp_head::make_field(uint max_length, const char *name, TABLE *dummy)
field= ::make_field((char *)0,
!m_returns_len ? max_length : m_returns_len,
(uchar *)"", 0, m_returns_pack, m_returns, m_returns_cs,
(enum Field::geometry_type)0, Field::NONE,
m_geom_returns, Field::NONE,
m_returns_typelib,
name ? name : (const char *)m_name.str, dummy);
DBUG_RETURN(field);
......
......@@ -110,6 +110,7 @@ class sp_head :private Query_arena
int m_type; // TYPE_ENUM_FUNCTION or TYPE_ENUM_PROCEDURE
enum enum_field_types m_returns; // For FUNCTIONs only
Field::geometry_type m_geom_returns;
CHARSET_INFO *m_returns_cs; // For FUNCTIONs only
TYPELIB *m_returns_typelib; // For FUNCTIONs only
uint m_returns_len; // For FUNCTIONs only
......
......@@ -10256,6 +10256,7 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
bool end_of_records)
{
int idx= -1;
enum_nested_loop_state ok_code= NESTED_LOOP_OK;
DBUG_ENTER("end_send_group");
if (!join->first_record || end_of_records ||
......@@ -10320,7 +10321,11 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
There is a server side cursor and all rows
for this fetch request are sent.
*/
DBUG_RETURN(NESTED_LOOP_CURSOR_LIMIT);
/*
Preventing code duplication. When finished with the group reset
the group functions and copy_fields. We fall through. bug #11904
*/
ok_code= NESTED_LOOP_CURSOR_LIMIT;
}
}
}
......@@ -10333,12 +10338,16 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
}
if (idx < (int) join->send_group_parts)
{
/*
This branch is executed also for cursors which have finished their
fetch limit - the reason for ok_code.
*/
copy_fields(&join->tmp_table_param);
if (init_sum_functions(join->sum_funcs, join->sum_funcs_end[idx+1]))
DBUG_RETURN(NESTED_LOOP_ERROR);
if (join->procedure)
join->procedure->add();
DBUG_RETURN(NESTED_LOOP_OK);
DBUG_RETURN(ok_code);
}
}
if (update_sum_func(join->sum_funcs))
......
......@@ -88,6 +88,7 @@ inline Item *is_truth_value(Item *A, bool v1, bool v2)
udf_func *udf;
LEX_USER *lex_user;
struct sys_var_with_base variable;
enum enum_var_type var_type;
Key::Keytype key_type;
enum ha_key_alg key_alg;
enum db_type db_type;
......@@ -697,11 +698,11 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <num>
type int_type real_type order_dir lock_option
udf_type if_exists opt_local opt_table_options table_options
table_option opt_if_not_exists opt_no_write_to_binlog opt_var_type
opt_var_ident_type delete_option opt_temporary all_or_any opt_distinct
table_option opt_if_not_exists opt_no_write_to_binlog
delete_option opt_temporary all_or_any opt_distinct
opt_ignore_leaves fulltext_options spatial_type union_option
start_transaction_opts opt_chain opt_release
union_opt select_derived_init option_type option_type2
union_opt select_derived_init option_type2
%type <ulong_num>
ulong_num raid_types merge_insert_types
......@@ -733,6 +734,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
expr_list udf_expr_list udf_expr_list2 when_list
ident_list ident_list_arg
%type <var_type>
option_type opt_var_type opt_var_ident_type
%type <key_type>
key_type opt_unique_or_fulltext constraint_key_type
......@@ -1444,7 +1448,7 @@ create_function_tail:
sp_prepare_create_field(YYTHD, new_field);
if (prepare_create_field(new_field, &unused1, &unused2, &unused2,
0))
HA_CAN_GEOMETRY))
YYABORT;
sp->m_returns= new_field->sql_type;
......@@ -1452,6 +1456,7 @@ create_function_tail:
sp->m_returns_len= new_field->length;
sp->m_returns_pack= new_field->pack_flag;
sp->m_returns_typelib= new_field->interval;
sp->m_geom_returns= new_field->geom_type;
new_field->interval= NULL;
bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics));
......@@ -2874,10 +2879,10 @@ type:
$$=FIELD_TYPE_STRING; }
| char opt_binary { Lex->length=(char*) "1";
$$=FIELD_TYPE_STRING; }
| nchar '(' NUM ')' { Lex->length=$3.str;
| nchar '(' NUM ')' opt_bin_mod { Lex->length=$3.str;
$$=FIELD_TYPE_STRING;
Lex->charset=national_charset_info; }
| nchar { Lex->length=(char*) "1";
| nchar opt_bin_mod { Lex->length=(char*) "1";
$$=FIELD_TYPE_STRING;
Lex->charset=national_charset_info; }
| BINARY '(' NUM ')' { Lex->length=$3.str;
......@@ -2888,7 +2893,7 @@ type:
$$=FIELD_TYPE_STRING; }
| varchar '(' NUM ')' opt_binary { Lex->length=$3.str;
$$= MYSQL_TYPE_VARCHAR; }
| nvarchar '(' NUM ')' { Lex->length=$3.str;
| nvarchar '(' NUM ')' opt_bin_mod { Lex->length=$3.str;
$$= MYSQL_TYPE_VARCHAR;
Lex->charset=national_charset_info; }
| VARBINARY '(' NUM ')' { Lex->length=$3.str;
......@@ -3077,7 +3082,6 @@ attribute:
lex->alter_info.flags|= ALTER_ADD_INDEX;
}
| COMMENT_SYM TEXT_STRING_sys { Lex->comment= $2; }
| BINARY { Lex->type|= BINCMP_FLAG; }
| COLLATE_SYM collation_name
{
if (Lex->charset && !my_charset_same(Lex->charset,$2))
......@@ -3162,8 +3166,27 @@ opt_default:
opt_binary:
/* empty */ { Lex->charset=NULL; }
| ASCII_SYM { Lex->charset=&my_charset_latin1; }
| ASCII_SYM opt_bin_mod { Lex->charset=&my_charset_latin1; }
| BYTE_SYM { Lex->charset=&my_charset_bin; }
| UNICODE_SYM opt_bin_mod
{
if (!(Lex->charset=get_charset_by_csname("ucs2",
MY_CS_PRIMARY,MYF(0))))
{
my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), "ucs2");
YYABORT;
}
}
| charset charset_name opt_bin_mod { Lex->charset=$2; }
| BINARY opt_bin_charset { Lex->type|= BINCMP_FLAG; };
opt_bin_mod:
/* empty */ { }
| BINARY { Lex->type|= BINCMP_FLAG; };
opt_bin_charset:
/* empty */ { }
| ASCII_SYM { Lex->charset=&my_charset_latin1; }
| UNICODE_SYM
{
if (!(Lex->charset=get_charset_by_csname("ucs2",
......@@ -4362,7 +4385,7 @@ simple_expr:
yyerror(ER(ER_SYNTAX_ERROR));
YYABORT;
}
if (!($$= get_system_var(YYTHD, (enum_var_type) $3, $4, $5)))
if (!($$= get_system_var(YYTHD, $3, $4, $5)))
YYABORT;
Lex->variables_used= 1;
}
......@@ -6455,7 +6478,7 @@ show_param:
LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT;
lex->orig_sql_command= SQLCOM_SHOW_STATUS;
lex->option_type= (enum_var_type) $1;
lex->option_type= $1;
if (prepare_schema_table(YYTHD, lex, 0, SCH_STATUS))
YYABORT;
}
......@@ -6470,7 +6493,7 @@ show_param:
LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT;
lex->orig_sql_command= SQLCOM_SHOW_VARIABLES;
lex->option_type= (enum_var_type) $1;
lex->option_type= $1;
if (prepare_schema_table(YYTHD, lex, 0, SCH_VARIABLES))
YYABORT;
}
......@@ -7852,7 +7875,7 @@ sys_option_value:
else if ($2.var)
{ /* System variable */
if ($1)
lex->option_type= (enum_var_type)$1;
lex->option_type= $1;
lex->var_list.push_back(new set_var(lex->option_type, $2.var,
&$2.base_name, $4));
}
......@@ -7886,8 +7909,8 @@ sys_option_value:
| option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types
{
LEX *lex=Lex;
if (!$1)
lex->option_type= (enum_var_type)$1;
if ($1)
lex->option_type= $1;
lex->var_list.push_back(new set_var(lex->option_type,
find_sys_var("tx_isolation"),
&null_lex_str,
......@@ -7903,8 +7926,7 @@ option_value:
| '@' '@' opt_var_ident_type internal_variable_name equal set_expr_or_default
{
LEX *lex=Lex;
lex->var_list.push_back(new set_var((enum_var_type) $3, $4.var,
&$4.base_name, $6));
lex->var_list.push_back(new set_var($3, $4.var, &$4.base_name, $6));
}
| charset old_or_new_charset_name_or_default
{
......
......@@ -14179,6 +14179,81 @@ static void test_bug11901()
myquery(rc);
}
/* Bug#11904: mysql_stmt_attr_set CURSOR_TYPE_READ_ONLY grouping wrong result */
static void test_bug11904()
{
MYSQL_STMT *stmt1;
int rc;
const char *stmt_text;
const ulong type= (ulong)CURSOR_TYPE_READ_ONLY;
MYSQL_BIND bind[2];
int country_id=0;
char row_data[11]= {0};
myheader("test_bug11904");
/* create tables */
rc= mysql_query(mysql, "DROP TABLE IF EXISTS bug11904b");
myquery(rc);
rc= mysql_query(mysql, "CREATE TABLE bug11904b (id int, name char(10), primary key(id, name))");
myquery(rc);
rc= mysql_query(mysql, "INSERT INTO bug11904b VALUES (1, 'sofia'), (1,'plovdiv'),"
" (1,'varna'), (2,'LA'), (2,'new york'), (3,'heidelberg'),"
" (3,'berlin'), (3, 'frankfurt')");
myquery(rc);
mysql_commit(mysql);
/* create statement */
stmt1= mysql_stmt_init(mysql);
mysql_stmt_attr_set(stmt1, STMT_ATTR_CURSOR_TYPE, (const void*) &type);
stmt_text= "SELECT id, MIN(name) FROM bug11904b GROUP BY id";
rc= mysql_stmt_prepare(stmt1, stmt_text, strlen(stmt_text));
check_execute(stmt1, rc);
memset(bind, 0, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_LONG;
bind[0].buffer=& country_id;
bind[0].buffer_length= 0;
bind[0].length= 0;
bind[1].buffer_type= MYSQL_TYPE_STRING;
bind[1].buffer=& row_data;
bind[1].buffer_length= sizeof(row_data) - 1;
bind[1].length= 0;
rc= mysql_stmt_bind_result(stmt1, bind);
check_execute(stmt1, rc);
rc= mysql_stmt_execute(stmt1);
check_execute(stmt1, rc);
rc= mysql_stmt_fetch(stmt1);
check_execute(stmt1, rc);
DIE_UNLESS(country_id == 1);
DIE_UNLESS(memcmp(row_data, "plovdiv", 7) == 0);
rc= mysql_stmt_fetch(stmt1);
check_execute(stmt1, rc);
DIE_UNLESS(country_id == 2);
DIE_UNLESS(memcmp(row_data, "LA", 2) == 0);
rc= mysql_stmt_fetch(stmt1);
check_execute(stmt1, rc);
DIE_UNLESS(country_id == 3);
DIE_UNLESS(memcmp(row_data, "berlin", 6) == 0);
rc= mysql_stmt_close(stmt1);
check_execute(stmt1, rc);
rc= mysql_query(mysql, "drop table bug11904b");
myquery(rc);
}
/* Bug#12243: multiple cursors, crash in a fetch after commit. */
static void test_bug12243()
......@@ -14522,6 +14597,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug11718", test_bug11718 },
{ "test_bug11909", test_bug11909 },
{ "test_bug11901", test_bug11901 },
{ "test_bug11904", test_bug11904 },
{ "test_bug12243", test_bug12243 },
{ 0, 0 }
};
......
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