Commit 082f7c9b authored by venu@myvenu.com's avatar venu@myvenu.com

Merge work.mysql.com:/home/bk/mysql-4.1

into myvenu.com:/home/venu/bk/src-4.1
parents 46ec0c5d a39da98d
......@@ -502,10 +502,12 @@ my_bool STDCALL mysql_send_long_data(MYSQL_STMT *stmt,
my_bool last_data);
int STDCALL mysql_multi_query(MYSQL *mysql,const char *query,
unsigned long len);
MYSQL_RES *STDCALL mysql_next_result(MYSQL *mysql);
MYSQL_RES *STDCALL mysql_prepare_result(MYSQL_STMT *stmt);
my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt);
int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt);
my_bool STDCALL mysql_more_results(MYSQL *mysql);
my_bool STDCALL mysql_next_result(MYSQL *mysql);
/* new status messages */
......
......@@ -106,10 +106,12 @@ enum enum_server_command
#define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */
#define CLIENT_PROTOCOL_41 16384 /* New 4.1 protocol */
#define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */
#define CLIENT_MULTI_QUERIES 65536 /* Enable/disable multi query support */
#define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */
#define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */
#define SERVER_STATUS_MORE_RESULTS 4 /* More results on server */
#define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */
#define MYSQL_ERRMSG_SIZE 200
#define NET_READ_TIMEOUT 30 /* Timeout on read */
......
......@@ -3858,7 +3858,7 @@ static my_bool read_prepare_result(MYSQL_STMT *stmt)
}
if (!(stmt->params= (MYSQL_BIND *) alloc_root(&stmt->mem_root,
sizeof(MYSQL_BIND)*
(stmt->param_count +
(param_count +
field_count))))
{
set_stmt_error(stmt, CR_OUT_OF_MEMORY);
......@@ -5164,3 +5164,36 @@ my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode)
DBUG_RETURN((my_bool) mysql_real_query(mysql, "set autocommit=1", 16));
DBUG_RETURN((my_bool) mysql_real_query(mysql, "set autocommit=0", 16));
}
/********************************************************************
Multi query execution related implementations
*********************************************************************/
/*
Returns if there are any more query results exists to be read using
mysql_next_result()
*/
my_bool STDCALL mysql_more_results(MYSQL *mysql)
{
if (mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS)
return 1;
return 0;
}
/*
Reads and returns the next query results
*/
my_bool STDCALL mysql_next_result(MYSQL *mysql)
{
mysql->net.last_error[0]=0;
mysql->net.last_errno=0;
mysql->affected_rows= ~(my_ulonglong) 0;
if (mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS)
return mysql_read_query_result(mysql);
return 0;
}
......@@ -906,6 +906,14 @@ int yylex(void *arg, void *yythd)
case STATE_COLON: // optional line terminator
if (yyPeek())
{
if (((THD *)yythd)->client_capabilities & CLIENT_MULTI_QUERIES)
{
lex->found_colon=(char*)lex->ptr;
((THD *)yythd)->server_status |= SERVER_MORE_RESULTS_EXISTS;
lex->next_state=STATE_END;
return(END_OF_INPUT);
}
else
state=STATE_CHAR; // Return ';'
break;
}
......
......@@ -414,6 +414,7 @@ typedef struct st_lex
char *backup_dir; /* For RESTORE/BACKUP */
char* to_log; /* For PURGE MASTER LOGS TO */
char* x509_subject,*x509_issuer,*ssl_cipher;
char* found_colon; /* For multi queries - next query */
enum SSL_type ssl_type; /* defined in violite.h */
String *wild;
sql_exchange *exchange;
......
......@@ -1427,6 +1427,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query);
}
}
if (command == COM_QUERY && thd->lex.found_colon)
{
/*
Multiple queries exits, execute them individually
*/
uint length= thd->query_length-(uint)(thd->lex.found_colon-thd->query)+1;
dispatch_command(command, thd, thd->lex.found_colon, length);
}
thd->proc_info="cleaning up";
VOID(pthread_mutex_lock(&LOCK_thread_count)); // For process list
thd->proc_info=0;
......@@ -3083,6 +3091,7 @@ mysql_init_query(THD *thd)
lex->olap=lex->describe=0;
lex->derived_tables= false;
lex->lock_option=TL_READ;
lex->found_colon=0;
thd->check_loops_counter= thd->select_number=
lex->select_lex.select_number= 1;
thd->free_list= 0;
......@@ -3091,6 +3100,7 @@ mysql_init_query(THD *thd)
thd->sent_row_count= thd->examined_row_count= 0;
thd->fatal_error= thd->rand_used= 0;
thd->possible_loops= 0;
thd->server_status &= ~SERVER_MORE_RESULTS_EXISTS;
DBUG_VOID_RETURN;
}
......
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