summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2006-02-24 18:34:15 +0200
committerunknown <monty@mysql.com>2006-02-24 18:34:15 +0200
commit0afb6ff66082f64c7c0aea62662e4c03e7c987c5 (patch)
tree603ae9081a58d9f7bb204327f65d4a8af4425b28 /sql
parentef1316fadda7b7d8c1b00de6d82576ebc21607cc (diff)
downloadmariadb-git-0afb6ff66082f64c7c0aea62662e4c03e7c987c5.tar.gz
Fixes to embedded server to be able to run tests with it
(Needed for "list of pushes" web page and autopush) include/mysql.h: Fix to embedded server to be able to run tests on it libmysql/libmysql.c: Fix to embedded server to be able to run tests on it libmysqld/emb_qcache.cc: Fix to embedded server to be able to run tests on it libmysqld/embedded_priv.h: Fix to embedded server to be able to run tests on it libmysqld/lib_sql.cc: Fix to embedded server to be able to run tests on it libmysqld/libmysqld.c: Fix to embedded server to be able to run tests on it mysql-test/mysql-test-run.sh: Fix to embedded server to be able to run tests on it mysql-test/r/binlog.result: Updated test for embedded server mysql-test/r/ctype_cp932.result: Updated test for embedded server mysql-test/r/innodb.result: Updated test for embedded server mysql-test/r/mysqltest.result: Updated test for embedded server mysql-test/r/query_cache.result: Updated test for embedded server mysql-test/r/query_cache_notembedded.result: Updated test for embedded server mysql-test/r/sp-error.result: Updated test for embedded server mysql-test/r/sp.result: Updated test for embedded server mysql-test/r/subselect.result: Updated test for embedded server mysql-test/r/view.result: Updated test for embedded server mysql-test/r/view_grant.result: Updated test for embedded server mysql-test/t/backup.test: Updated test for embedded server mysql-test/t/binlog.test: Updated test for embedded server mysql-test/t/blackhole.test: Updated test for embedded server mysql-test/t/compress.test: Updated test for embedded server mysql-test/t/ctype_cp932.test: Updated test for embedded server mysql-test/t/delayed.test: Updated test for embedded server mysql-test/t/handler.test: Updated test for embedded server mysql-test/t/innodb.test: Updated test for embedded server mysql-test/t/mysql.test: Updated test for embedded server mysql-test/t/mysql_client_test.test: Updated test for embedded server mysql-test/t/mysqltest.test: Updated test for embedded server mysql-test/t/query_cache.test: Updated test for embedded server mysql-test/t/query_cache_notembedded.test: Updated test for embedded server mysql-test/t/read_only.test: Updated test for embedded server mysql-test/t/skip_grants.test: Updated test for embedded server mysql-test/t/sp-destruct.test: Updated test for embedded server mysql-test/t/sp-error.test: Updated test for embedded server mysql-test/t/sp-threads.test: Updated test for embedded server mysql-test/t/sp.test: Updated test for embedded server mysql-test/t/subselect.test: Updated test for embedded server mysql-test/t/temp_table.test: Updated test for embedded server mysql-test/t/view.test: Updated test for embedded server mysql-test/t/view_grant.test: Updated test for embedded server mysql-test/t/wait_timeout.test: Updated test for embedded server mysys/mf_dirname.c: Review fix: Don't access data outside of array mysys/my_bitmap.c: Remove compiler warnings scripts/mysql_fix_privilege_tables.sql: Add flush privileges to .sql script so that one doesn't have to reboot mysqld when one runs the mysql_fix_privilege_script sql-common/client.c: Updated test for embedded server sql/item.cc: Remove DBUG_PRINT statement that can cause crashes when running with --debug sql/mysqld.cc: Fix to embedded server to be able to run tests on it sql/protocol.cc: Fix to embedded server to be able to run tests on it (Trivial reconstruction of code) sql/protocol.h: Fix to embedded server to be able to run tests on it sql/sql_base.cc: Better comment sql/sql_class.cc: Fix to embedded server to be able to run tests on it sql/sql_class.h: Fix to embedded server to be able to run tests on it sql/sql_cursor.cc: Fix to embedded server to be able to run tests on it sql/sql_parse.cc: Fix to embedded server to be able to run tests on it Don't crash for disabled commands when using embedded server sql/sql_prepare.cc: Fix to embedded server to be able to run tests on it mysql-test/r/ctype_cp932_notembedded.result: New BitKeeper file ``mysql-test/r/ctype_cp932_notembedded.result'' mysql-test/r/innodb_notembedded.result: New BitKeeper file ``mysql-test/r/innodb_notembedded.result'' mysql-test/r/sp.result.orig: New BitKeeper file ``mysql-test/r/sp.result.orig'' mysql-test/r/sp_notembedded.result: New BitKeeper file ``mysql-test/r/sp_notembedded.result'' mysql-test/r/subselect_notembedded.result: New BitKeeper file ``mysql-test/r/subselect_notembedded.result'' mysql-test/t/ctype_cp932_notembedded.test: New BitKeeper file ``mysql-test/t/ctype_cp932_notembedded.test'' mysql-test/t/innodb_notembedded.test: New BitKeeper file ``mysql-test/t/innodb_notembedded.test'' mysql-test/t/sp.test.orig: New BitKeeper file ``mysql-test/t/sp.test.orig'' mysql-test/t/sp_notembedded.test: New BitKeeper file ``mysql-test/t/sp_notembedded.test'' mysql-test/t/subselect_notembedded.test: New BitKeeper file ``mysql-test/t/subselect_notembedded.test''
Diffstat (limited to 'sql')
-rw-r--r--sql/item.cc3
-rw-r--r--sql/mysqld.cc2
-rw-r--r--sql/protocol.cc82
-rw-r--r--sql/protocol.h9
-rw-r--r--sql/sql_base.cc9
-rw-r--r--sql/sql_class.cc3
-rw-r--r--sql/sql_class.h12
-rw-r--r--sql/sql_cursor.cc1
-rw-r--r--sql/sql_parse.cc33
-rw-r--r--sql/sql_prepare.cc11
10 files changed, 84 insertions, 81 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 367452444d2..3d454969c1d 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -375,9 +375,6 @@ void Item::print_item_w_name(String *str)
void Item::cleanup()
{
DBUG_ENTER("Item::cleanup");
- DBUG_PRINT("info", ("Item: 0x%lx, Type: %d, name %s, original name %s",
- this, (int)type(), name ? name : "(null)",
- orig_name ? orig_name : "null"));
fixed=0;
marker= 0;
if (orig_name)
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 00ddde46127..37a135fa063 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2387,9 +2387,7 @@ static int my_message_sql(uint error, const char *str, myf MyFlags)
{
NET *net= &thd->net;
net->report_error= 1;
-#ifndef EMBEDDED_LIBRARY /* TODO query cache in embedded library*/
query_cache_abort(net);
-#endif
if (!net->last_error[0]) // Return only first message
{
strmake(net->last_error, str, sizeof(net->last_error)-1);
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 15f7049ec2f..650bd8fc58f 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -29,6 +29,7 @@
static const unsigned int PACKET_BUFFER_EXTRA_ALLOC= 1024;
static void write_eof_packet(THD *thd, NET *net);
+void net_send_error_packet(THD *thd, uint sql_errno, const char *err);
#ifndef EMBEDDED_LIBRARY
bool Protocol::net_store_data(const char *from, uint length)
@@ -56,10 +57,6 @@ bool Protocol_prep::net_store_data(const char *from, uint length)
void net_send_error(THD *thd, uint sql_errno, const char *err)
{
-#ifndef EMBEDDED_LIBRARY
- uint length;
- char buff[MYSQL_ERRMSG_SIZE+2], *pos;
-#endif
NET *net= &thd->net;
bool generate_warning= thd->killed != THD::KILL_CONNECTION;
DBUG_ENTER("net_send_error");
@@ -106,42 +103,8 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, sql_errno, err);
}
-#ifdef EMBEDDED_LIBRARY
- net->last_errno= sql_errno;
- strmake(net->last_error, err, sizeof(net->last_error)-1);
- strmov(net->sqlstate, mysql_errno_to_sqlstate(sql_errno));
-#else
-
- if (net->vio == 0)
- {
- if (thd->bootstrap)
- {
- /* In bootstrap it's ok to print on stderr */
- fprintf(stderr,"ERROR: %d %s\n",sql_errno,err);
- }
- DBUG_VOID_RETURN;
- }
+ net_send_error_packet(thd, sql_errno, err);
- if (net->return_errno)
- { // new client code; Add errno before message
- int2store(buff,sql_errno);
- pos= buff+2;
- if (thd->client_capabilities & CLIENT_PROTOCOL_41)
- {
- /* The first # is to make the protocol backward compatible */
- buff[2]= '#';
- pos= strmov(buff+3, mysql_errno_to_sqlstate(sql_errno));
- }
- length= (uint) (strmake(pos, err, MYSQL_ERRMSG_SIZE-1) - buff);
- err=buff;
- }
- else
- {
- length=(uint) strlen(err);
- set_if_smaller(length,MYSQL_ERRMSG_SIZE-1);
- }
- VOID(net_write_command(net,(uchar) 255, "", 0, (char*) err,length));
-#endif /* EMBEDDED_LIBRARY*/
thd->is_fatal_error=0; // Error message is given
thd->net.report_error= 0;
@@ -430,6 +393,47 @@ bool send_old_password_request(THD *thd)
return my_net_write(net, eof_buff, 1) || net_flush(net);
}
+
+void net_send_error_packet(THD *thd, uint sql_errno, const char *err)
+{
+ NET *net= &thd->net;
+ uint length;
+ char buff[MYSQL_ERRMSG_SIZE+2], *pos;
+
+ DBUG_ENTER("send_error_packet");
+
+ if (net->vio == 0)
+ {
+ if (thd->bootstrap)
+ {
+ /* In bootstrap it's ok to print on stderr */
+ fprintf(stderr,"ERROR: %d %s\n",sql_errno,err);
+ }
+ DBUG_VOID_RETURN;
+ }
+
+ if (net->return_errno)
+ { // new client code; Add errno before message
+ int2store(buff,sql_errno);
+ pos= buff+2;
+ if (thd->client_capabilities & CLIENT_PROTOCOL_41)
+ {
+ /* The first # is to make the protocol backward compatible */
+ buff[2]= '#';
+ pos= strmov(buff+3, mysql_errno_to_sqlstate(sql_errno));
+ }
+ length= (uint) (strmake(pos, err, MYSQL_ERRMSG_SIZE-1) - buff);
+ err=buff;
+ }
+ else
+ {
+ length=(uint) strlen(err);
+ set_if_smaller(length,MYSQL_ERRMSG_SIZE-1);
+ }
+ VOID(net_write_command(net,(uchar) 255, "", 0, (char*) err,length));
+ DBUG_VOID_RETURN;
+}
+
#endif /* EMBEDDED_LIBRARY */
/*
diff --git a/sql/protocol.h b/sql/protocol.h
index 8d9da5774b2..85c22724b74 100644
--- a/sql/protocol.h
+++ b/sql/protocol.h
@@ -91,6 +91,12 @@ public:
virtual bool store_date(TIME *time)=0;
virtual bool store_time(TIME *time)=0;
virtual bool store(Field *field)=0;
+#ifdef EMBEDDED_LIBRARY
+ int begin_dataset();
+ virtual void remove_last_row() {}
+#else
+ void remove_last_row() {}
+#endif
};
@@ -117,6 +123,9 @@ public:
virtual bool store(float nr, uint32 decimals, String *buffer);
virtual bool store(double from, uint32 decimals, String *buffer);
virtual bool store(Field *field);
+#ifdef EMBEDDED_LIBRARY
+ void remove_last_row();
+#endif
};
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 37d4c80a0d0..2614a7cd5be 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -368,6 +368,15 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh,
DESCRIPTION
Marks all tables in the list which were used by current substatement
(they are marked by its query_id) as free for reuse.
+
+ NOTE
+ The reason we reset query_id is that it's not enough to just test
+ if table->query_id != thd->query_id to know if a table is in use.
+
+ For example
+ SELECT f1_that_uses_t1() FROM t1;
+ In f1_that_uses_t1() we will see one instance of t1 where query_id is
+ set to query_id of original query.
*/
static void mark_used_tables_as_free_for_reuse(THD *thd, TABLE *table)
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 2125201026a..59391a333c3 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -950,6 +950,7 @@ bool select_send::send_data(List<Item> &items)
DBUG_RETURN(0);
if (!thd->net.report_error)
DBUG_RETURN(protocol->write());
+ protocol->remove_last_row();
DBUG_RETURN(1);
}
@@ -1981,10 +1982,8 @@ void THD::reset_sub_statement_state(Sub_statement_state *backup,
cuted_fields= 0;
transaction.savepoints= 0;
-#ifndef EMBEDDED_LIBRARY
/* Surpress OK packets in case if we will execute statements */
net.no_send_ok= TRUE;
-#endif
}
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 1672a5ea811..65e6ebea33e 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1102,13 +1102,16 @@ public:
#ifdef EMBEDDED_LIBRARY
struct st_mysql *mysql;
- struct st_mysql_data *data;
unsigned long client_stmt_id;
unsigned long client_param_count;
struct st_mysql_bind *client_params;
char *extra_data;
ulong extra_length;
- String query_rest;
+ struct st_mysql_data *cur_data;
+ struct st_mysql_data *first_data;
+ struct st_mysql_data **data_tail;
+ void clear_data_list();
+ struct st_mysql_data *alloc_new_dataset();
#endif
NET net; // client connection descriptor
MEM_ROOT warn_root; // For warnings and errors
@@ -1659,6 +1662,11 @@ public:
*/
virtual void cleanup();
void set_thd(THD *thd_arg) { thd= thd_arg; }
+#ifdef EMBEDDED_LIBRARY
+ virtual void begin_dataset() {}
+#else
+ void begin_dataset() {}
+#endif
};
diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc
index 89c160cd70a..33ad27b9d14 100644
--- a/sql/sql_cursor.cc
+++ b/sql/sql_cursor.cc
@@ -603,6 +603,7 @@ void Materialized_cursor::fetch(ulong num_rows)
THD *thd= table->in_use;
int res= 0;
+ result->begin_dataset();
for (fetch_limit+= num_rows; fetch_count < fetch_limit; fetch_count++)
{
if ((res= table->file->rnd_next(table->record[0])))
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 978cab704c0..8b87c59cc64 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1724,13 +1724,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
net->no_send_error= 0;
/*
Multiple queries exits, execute them individually
- in embedded server - just store them to be executed later
*/
-#ifndef EMBEDDED_LIBRARY
if (thd->lock || thd->open_tables || thd->derived_tables ||
thd->prelocked_mode)
close_thread_tables(thd);
-#endif
ulong length= (ulong)(packet_end-packet);
log_slow_statement(thd);
@@ -1748,25 +1745,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd->set_time(); /* Reset the query start time. */
/* TODO: set thd->lex->sql_command to SQLCOM_END here */
VOID(pthread_mutex_unlock(&LOCK_thread_count));
-#ifndef EMBEDDED_LIBRARY
mysql_parse(thd, packet, length);
-#else
- /*
- 'packet' can point inside the query_rest's buffer
- so we have to do memmove here
- */
- if (thd->query_rest.length() > length)
- {
- memmove(thd->query_rest.c_ptr(), packet, length);
- thd->query_rest.length(length);
- }
- else
- thd->query_rest.copy(packet, length, thd->query_rest.charset());
-
- thd->server_status&= ~ (SERVER_QUERY_NO_INDEX_USED |
- SERVER_QUERY_NO_GOOD_INDEX_USED);
- break;
-#endif /*EMBEDDED_LIBRARY*/
}
if (!(specialflag & SPECIAL_NO_PRIOR))
@@ -4273,10 +4252,8 @@ end_with_restore_list:
goto error;
}
-#ifndef EMBEDDED_LIBRARY
my_bool nsok= thd->net.no_send_ok;
thd->net.no_send_ok= TRUE;
-#endif
if (sp->m_flags & sp_head::MULTI_RESULTS)
{
if (! (thd->client_capabilities & CLIENT_MULTI_RESULTS))
@@ -4286,9 +4263,7 @@ end_with_restore_list:
back
*/
my_error(ER_SP_BADSELECT, MYF(0), sp->m_qname.str);
-#ifndef EMBEDDED_LIBRARY
thd->net.no_send_ok= nsok;
-#endif
goto error;
}
/*
@@ -4305,18 +4280,14 @@ end_with_restore_list:
sp->m_db.str, sp->m_name.str, TRUE, 0) ||
sp_change_security_context(thd, sp, &save_ctx))
{
-#ifndef EMBEDDED_LIBRARY
thd->net.no_send_ok= nsok;
-#endif
goto error;
}
if (save_ctx &&
check_routine_access(thd, EXECUTE_ACL,
sp->m_db.str, sp->m_name.str, TRUE, 0))
{
-#ifndef EMBEDDED_LIBRARY
thd->net.no_send_ok= nsok;
-#endif
sp_restore_security_context(thd, save_ctx);
goto error;
}
@@ -4348,9 +4319,7 @@ end_with_restore_list:
sp_restore_security_context(thd, save_ctx);
#endif
-#ifndef EMBEDDED_LIBRARY
thd->net.no_send_ok= nsok;
-#endif
thd->server_status&= ~bits_to_be_cleared;
if (!res)
@@ -4846,7 +4815,9 @@ end_with_restore_list:
res= mysql_xa_recover(thd);
break;
default:
+#ifndef EMBEDDED_LIBRARY
DBUG_ASSERT(0); /* Impossible */
+#endif
send_ok(thd);
break;
}
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 5746e2a6f1a..332f699200e 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -92,6 +92,12 @@ public:
virtual bool send_fields(List<Item> &list, uint flags);
virtual bool send_data(List<Item> &items);
virtual bool send_eof();
+#ifdef EMBEDDED_LIBRARY
+ void begin_dataset()
+ {
+ protocol.begin_dataset();
+ }
+#endif
};
/******************************************************************************
@@ -524,9 +530,10 @@ void set_param_time(Item_param *param, uchar **pos, ulong len)
void set_param_datetime(Item_param *param, uchar **pos, ulong len)
{
- MYSQL_TIME *to= (MYSQL_TIME*)*pos;
+ MYSQL_TIME tm= *((MYSQL_TIME*)*pos);
+ tm.neg= 0;
- param->set_time(to, MYSQL_TIMESTAMP_DATETIME,
+ param->set_time(&tm, MYSQL_TIMESTAMP_DATETIME,
MAX_DATETIME_WIDTH * MY_CHARSET_BIN_MB_MAXLEN);
}