Commit 1ba3a170 authored by unknown's avatar unknown

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

into poseidon.(none):/home/tomas/mysql-4.1

parents 2cd71180 1460e454
...@@ -2947,7 +2947,12 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate) ...@@ -2947,7 +2947,12 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate)
(void) fflush(file); (void) fflush(file);
fprintf(file,"ERROR"); fprintf(file,"ERROR");
if (error) if (error)
{
if (sqlstate)
(void) fprintf(file," %d (%s)",error, sqlstate);
else
(void) fprintf(file," %d",error); (void) fprintf(file," %d",error);
}
if (status.query_start_line && line_numbers) if (status.query_start_line && line_numbers)
{ {
(void) fprintf(file," at line %lu",status.query_start_line); (void) fprintf(file," at line %lu",status.query_start_line);
......
...@@ -42,7 +42,7 @@ const char *client_errors[]= ...@@ -42,7 +42,7 @@ const char *client_errors[]=
"Error in server handshake", "Error in server handshake",
"Lost connection to MySQL server during query", "Lost connection to MySQL server during query",
"Commands out of sync; you can't run this command now", "Commands out of sync; you can't run this command now",
"Verbindung ueber Named Pipe; Host: %-.100s", "Verbindung ueber Named Pipe: %-.32s",
"Kann nicht auf Named Pipe warten. Host: %-.64s pipe: %-.32s (%lu)", "Kann nicht auf Named Pipe warten. Host: %-.64s pipe: %-.32s (%lu)",
"Kann Named Pipe nicht oeffnen. Host: %-.64s pipe: %-.32s (%lu)", "Kann Named Pipe nicht oeffnen. Host: %-.64s pipe: %-.32s (%lu)",
"Kann den Status der Named Pipe nicht setzen. Host: %-.64s pipe: %-.32s (%lu)", "Kann den Status der Named Pipe nicht setzen. Host: %-.64s pipe: %-.32s (%lu)",
...@@ -64,7 +64,7 @@ const char *client_errors[]= ...@@ -64,7 +64,7 @@ const char *client_errors[]=
"Invalid parameter number", "Invalid parameter number",
"Can't send long data for non-string/non-binary data types (parameter: %d)", "Can't send long data for non-string/non-binary data types (parameter: %d)",
"Using unsupported buffer type: %d (parameter: %d)", "Using unsupported buffer type: %d (parameter: %d)",
"Shared memory (%lu)", "Shared memory: %-.100s",
"Can't open shared memory; client could not create request event (%lu)", "Can't open shared memory; client could not create request event (%lu)",
"Can't open shared memory; no answer event received from server (%lu)", "Can't open shared memory; no answer event received from server (%lu)",
"Can't open shared memory; server could not allocate file mapping (%lu)", "Can't open shared memory; server could not allocate file mapping (%lu)",
...@@ -101,7 +101,7 @@ const char *client_errors[]= ...@@ -101,7 +101,7 @@ const char *client_errors[]=
"Erro na negociao de acesso ao servidor", "Erro na negociao de acesso ao servidor",
"Conexo perdida com servidor MySQL durante 'query'", "Conexo perdida com servidor MySQL durante 'query'",
"Comandos fora de sincronismo; voc no pode executar este comando agora", "Comandos fora de sincronismo; voc no pode executar este comando agora",
"%-.100s via 'named pipe'", "Named pipe: %-.32s",
"No pode esperar pelo 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", "No pode esperar pelo 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)",
"No pode abrir 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", "No pode abrir 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)",
"No pode estabelecer o estado do 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", "No pode estabelecer o estado do 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)",
...@@ -123,7 +123,7 @@ const char *client_errors[]= ...@@ -123,7 +123,7 @@ const char *client_errors[]=
"Invalid parameter number", "Invalid parameter number",
"Can't send long data for non-string/non-binary data types (parameter: %d)", "Can't send long data for non-string/non-binary data types (parameter: %d)",
"Using unsupported buffer type: %d (parameter: %d)", "Using unsupported buffer type: %d (parameter: %d)",
"Shared memory (%lu)", "Shared memory: %-.100s",
"Can't open shared memory; client could not create request event (%lu)", "Can't open shared memory; client could not create request event (%lu)",
"Can't open shared memory; no answer event received from server (%lu)", "Can't open shared memory; no answer event received from server (%lu)",
"Can't open shared memory; server could not allocate file mapping (%lu)", "Can't open shared memory; server could not allocate file mapping (%lu)",
...@@ -158,7 +158,7 @@ const char *client_errors[]= ...@@ -158,7 +158,7 @@ const char *client_errors[]=
"Error in server handshake", "Error in server handshake",
"Lost connection to MySQL server during query", "Lost connection to MySQL server during query",
"Commands out of sync; you can't run this command now", "Commands out of sync; you can't run this command now",
"%-.100s via named pipe", "Named pipe: %-.32s",
"Can't wait for named pipe to host: %-.64s pipe: %-.32s (%lu)", "Can't wait for named pipe to host: %-.64s pipe: %-.32s (%lu)",
"Can't open named pipe to host: %-.64s pipe: %-.32s (%lu)", "Can't open named pipe to host: %-.64s pipe: %-.32s (%lu)",
"Can't set state of named pipe to host: %-.64s pipe: %-.32s (%lu)", "Can't set state of named pipe to host: %-.64s pipe: %-.32s (%lu)",
...@@ -180,7 +180,7 @@ const char *client_errors[]= ...@@ -180,7 +180,7 @@ const char *client_errors[]=
"Invalid parameter number", "Invalid parameter number",
"Can't send long data for non-string/non-binary data types (parameter: %d)", "Can't send long data for non-string/non-binary data types (parameter: %d)",
"Using unsupported buffer type: %d (parameter: %d)", "Using unsupported buffer type: %d (parameter: %d)",
"Shared memory (%lu)", "Shared memory: %-.100s",
"Can't open shared memory; client could not create request event (%lu)", "Can't open shared memory; client could not create request event (%lu)",
"Can't open shared memory; no answer event received from server (%lu)", "Can't open shared memory; no answer event received from server (%lu)",
"Can't open shared memory; server could not allocate file mapping (%lu)", "Can't open shared memory; server could not allocate file mapping (%lu)",
......
...@@ -1703,16 +1703,18 @@ static void stmt_update_metadata(MYSQL_STMT *stmt, MYSQL_ROWS *data); ...@@ -1703,16 +1703,18 @@ static void stmt_update_metadata(MYSQL_STMT *stmt, MYSQL_ROWS *data);
/**************** Misc utility functions ****************************/ /**************** Misc utility functions ****************************/
/* /*
Reallocate the NET package to be at least of 'length' bytes Reallocate the NET package to have at least length bytes available.
SYNPOSIS SYNPOSIS
my_realloc_str() my_realloc_str()
net The NET structure to modify net The NET structure to modify.
length Ensure that net->buff is at least this big length Ensure that net->buff has space for at least
this number of bytes.
RETURN VALUES RETURN VALUES
0 ok 0 Success.
1 Error 1 Error, i.e. out of memory or requested packet size is bigger
than max_allowed_packet. The error code is stored in net->last_errno.
*/ */
static my_bool my_realloc_str(NET *net, ulong length) static my_bool my_realloc_str(NET *net, ulong length)
...@@ -2365,7 +2367,7 @@ static my_bool store_param(MYSQL_STMT *stmt, MYSQL_BIND *param) ...@@ -2365,7 +2367,7 @@ static my_bool store_param(MYSQL_STMT *stmt, MYSQL_BIND *param)
*/ */
if ((my_realloc_str(net, *param->length))) if ((my_realloc_str(net, *param->length)))
{ {
set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate); set_stmt_error(stmt, net->last_errno, unknown_sqlstate);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
(*param->store_param_func)(net, param); (*param->store_param_func)(net, param);
...@@ -2427,6 +2429,11 @@ int cli_stmt_execute(MYSQL_STMT *stmt) ...@@ -2427,6 +2429,11 @@ int cli_stmt_execute(MYSQL_STMT *stmt)
net_clear(net); /* Sets net->write_pos */ net_clear(net); /* Sets net->write_pos */
/* Reserve place for null-marker bytes */ /* Reserve place for null-marker bytes */
null_count= (stmt->param_count+7) /8; null_count= (stmt->param_count+7) /8;
if (my_realloc_str(net, null_count + 1))
{
set_stmt_error(stmt, net->last_errno, unknown_sqlstate);
DBUG_RETURN(1);
}
bzero((char*) net->write_pos, null_count); bzero((char*) net->write_pos, null_count);
net->write_pos+= null_count; net->write_pos+= null_count;
param_end= stmt->params + stmt->param_count; param_end= stmt->params + stmt->param_count;
...@@ -2435,6 +2442,11 @@ int cli_stmt_execute(MYSQL_STMT *stmt) ...@@ -2435,6 +2442,11 @@ int cli_stmt_execute(MYSQL_STMT *stmt)
*(net->write_pos)++= (uchar) stmt->send_types_to_server; *(net->write_pos)++= (uchar) stmt->send_types_to_server;
if (stmt->send_types_to_server) if (stmt->send_types_to_server)
{ {
if (my_realloc_str(net, 2 * stmt->param_count))
{
set_stmt_error(stmt, net->last_errno, unknown_sqlstate);
DBUG_RETURN(1);
}
/* /*
Store types of parameters in first in first package Store types of parameters in first in first package
that is sent to the server. that is sent to the server.
......
...@@ -629,3 +629,12 @@ explain SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL; ...@@ -629,3 +629,12 @@ explain SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY 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 t1 ALL NULL NULL NULL NULL 6 Using filesort 1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
DROP TABLE t1; DROP TABLE t1;
create table t1 ( col1 int, col2 int );
insert into t1 values (1,1),(1,2),(1,3),(2,1),(2,2);
select group_concat( distinct col1 ) as alias from t1
group by col2 having alias like '%';
alias
1,2
1,2
1
drop table t1;
...@@ -106,3 +106,11 @@ a b ...@@ -106,3 +106,11 @@ a b
2 12 2 12
4 105 4 105
drop table t1, t2; drop table t1, t2;
CREATE TABLE `t1` ( `unit` varchar(50) NOT NULL default '', `ingredient` varchar(50) NOT NULL default '') ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `t2` ( `ingredient` varchar(50) NOT NULL default '', `unit` varchar(50) NOT NULL default '', PRIMARY KEY (ingredient, unit)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `t1` VALUES ('xx','yy');
INSERT INTO `t2` VALUES ('yy','xx');
SELECT R.unit, R.ingredient FROM t1 R WHERE R.ingredient IN (SELECT N.ingredient FROM t2 N WHERE N.unit = R.unit);
unit ingredient
xx yy
drop table t1, t2;
...@@ -456,3 +456,12 @@ INSERT INTO t1 VALUES (1,2),(2,3),(4,5),(3,5),(1,5),(23,5); ...@@ -456,3 +456,12 @@ INSERT INTO t1 VALUES (1,2),(2,3),(4,5),(3,5),(1,5),(23,5);
SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL; SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL;
explain SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL; explain SELECT i, COUNT(DISTINCT(i)) FROM t1 GROUP BY j ORDER BY NULL;
DROP TABLE t1; DROP TABLE t1;
# Test for BUG#5400: GROUP_CONCAT returns everything twice.
create table t1 ( col1 int, col2 int );
insert into t1 values (1,1),(1,2),(1,3),(2,1),(2,2);
select group_concat( distinct col1 ) as alias from t1
group by col2 having alias like '%';
drop table t1;
...@@ -111,3 +111,17 @@ create table t2 (a int) engine=innodb; ...@@ -111,3 +111,17 @@ create table t2 (a int) engine=innodb;
insert into t2 values (1),(2),(3),(4); insert into t2 values (1),(2),(3),(4);
select a, sum(b) as b from t1 group by a having b > (select max(a) from t2); select a, sum(b) as b from t1 group by a having b > (select max(a) from t2);
drop table t1, t2; drop table t1, t2;
#
# bug #5220 test suite
#
CREATE TABLE `t1` ( `unit` varchar(50) NOT NULL default '', `ingredient` varchar(50) NOT NULL default '') ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `t2` ( `ingredient` varchar(50) NOT NULL default '', `unit` varchar(50) NOT NULL default '', PRIMARY KEY (ingredient, unit)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `t1` VALUES ('xx','yy');
INSERT INTO `t2` VALUES ('yy','xx');
SELECT R.unit, R.ingredient FROM t1 R WHERE R.ingredient IN (SELECT N.ingredient FROM t2 N WHERE N.unit = R.unit);
drop table t1, t2;
...@@ -1615,7 +1615,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, ...@@ -1615,7 +1615,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
sock=0; sock=0;
unix_socket = 0; unix_socket = 0;
host=mysql->options.shared_memory_base_name; host=mysql->options.shared_memory_base_name;
host_info=(char*) ER(CR_SHARED_MEMORY_CONNECTION); sprintf(host_info=buff, ER(CR_SHARED_MEMORY_CONNECTION), host);
} }
} }
#endif /* HAVE_SMEM */ #endif /* HAVE_SMEM */
...@@ -1679,8 +1679,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, ...@@ -1679,8 +1679,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
else else
{ {
net->vio=vio_new_win32pipe(hPipe); net->vio=vio_new_win32pipe(hPipe);
sprintf(host_info=buff, ER(CR_NAMEDPIPE_CONNECTION), host, sprintf(host_info=buff, ER(CR_NAMEDPIPE_CONNECTION), unix_socket);
unix_socket);
} }
} }
#endif #endif
......
...@@ -2121,6 +2121,8 @@ String* Item_func_group_concat::val_str(String* str) ...@@ -2121,6 +2121,8 @@ String* Item_func_group_concat::val_str(String* str)
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
if (null_value) if (null_value)
return 0; return 0;
if (result.length())
return &result;
if (tree_mode) if (tree_mode)
{ {
tree_walk(tree, (tree_walk_action)&dump_leaf_key, (void*)this, tree_walk(tree, (tree_walk_action)&dump_leaf_key, (void*)this,
......
...@@ -1994,7 +1994,7 @@ void print_buffer_to_file(enum loglevel level, const char *buffer) ...@@ -1994,7 +1994,7 @@ void print_buffer_to_file(enum loglevel level, const char *buffer)
start->tm_min, start->tm_min,
start->tm_sec, start->tm_sec,
(level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ? (level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ?
"WARNING" : "INFORMATION"), "WARNING" : "NOTE"),
buffer); buffer);
fflush(stderr); fflush(stderr);
......
...@@ -193,9 +193,7 @@ my_bool net_realloc(NET *net, ulong length) ...@@ -193,9 +193,7 @@ my_bool net_realloc(NET *net, ulong length)
{ {
net->error= 1; net->error= 1;
net->report_error= 1; net->report_error= 1;
#ifdef MYSQL_SERVER
net->last_errno= ER_OUT_OF_RESOURCES; net->last_errno= ER_OUT_OF_RESOURCES;
#endif
DBUG_RETURN(1); DBUG_RETURN(1);
} }
net->buff=net->write_pos=buff; net->buff=net->write_pos=buff;
......
...@@ -1475,8 +1475,16 @@ error: ...@@ -1475,8 +1475,16 @@ error:
static bool init_param_array(Prepared_statement *stmt) static bool init_param_array(Prepared_statement *stmt)
{ {
LEX *lex= stmt->lex; LEX *lex= stmt->lex;
THD *thd= stmt->thd;
if ((stmt->param_count= lex->param_list.elements)) if ((stmt->param_count= lex->param_list.elements))
{ {
if (stmt->param_count > (uint) UINT_MAX16)
{
/* Error code to be defined in 5.0 */
send_error(thd, ER_UNKNOWN_ERROR,
"Prepared statement contains too many placeholders.");
return 1;
}
Item_param **to; Item_param **to;
List_iterator<Item_param> param_iterator(lex->param_list); List_iterator<Item_param> param_iterator(lex->param_list);
/* Use thd->mem_root as it points at statement mem_root */ /* Use thd->mem_root as it points at statement mem_root */
...@@ -1485,7 +1493,7 @@ static bool init_param_array(Prepared_statement *stmt) ...@@ -1485,7 +1493,7 @@ static bool init_param_array(Prepared_statement *stmt)
sizeof(Item_param*) * stmt->param_count); sizeof(Item_param*) * stmt->param_count);
if (!stmt->param_array) if (!stmt->param_array)
{ {
send_error(stmt->thd, ER_OUT_OF_RESOURCES); send_error(thd, ER_OUT_OF_RESOURCES);
return 1; return 1;
} }
for (to= stmt->param_array; for (to= stmt->param_array;
......
This diff is collapsed.
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