summaryrefslogtreecommitdiff
path: root/sql/protocol.h
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2014-06-24 19:41:43 +0400
committerSergei Petrunia <psergey@askmonty.org>2014-06-24 19:41:43 +0400
commitc08de06246f776c557b7795d53e2a956e156f533 (patch)
tree6c9ed33855eeb6c418fe390deef7f62db91d6d36 /sql/protocol.h
parent581b889771447f7a9f33d467f0b5ef2aa96e072b (diff)
downloadmariadb-git-c08de06246f776c557b7795d53e2a956e156f533.tar.gz
MDEV-406: ANALYZE $stmt: get ANALYZE work for subqueries
- "ANALYZE $stmt" should discard select's output, but it should still evaluate the output columns (otherwise, subqueries in select list are not executed) - SHOW EXPLAIN's code practice of calling JOIN::save_explain_data() after JOIN::exec() is disastrous for ANALYZE, because it resets all counters after the first execution. It is stopped = "Late" test_if_skip_sort_order() calls explicitly update their part of the query plan. = Also, I had to rewrite I_S optimization to actually have optimization and execution stages.
Diffstat (limited to 'sql/protocol.h')
-rw-r--r--sql/protocol.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/sql/protocol.h b/sql/protocol.h
index c58de68289f..5129f68d706 100644
--- a/sql/protocol.h
+++ b/sql/protocol.h
@@ -210,6 +210,42 @@ public:
virtual enum enum_protocol_type type() { return PROTOCOL_BINARY; };
};
+
+/*
+ A helper for "ANALYZE $stmt" which looks a real network procotol but doesn't
+ write results to the network.
+
+ At first glance, class select_send looks like a more appropriate place to
+ implement the "write nothing" hook. This is not true, because
+ - we need to evaluate the value of every item, and do it the way
+ select_send does it (i.e. call item->val_int() or val_real() or...)
+ - select_send::send_data() has some other code, like telling the storage
+ engine that the row can be unlocked. We want to keep that also.
+ as a result, "ANALYZE $stmt" uses a select_send_analyze which still uses
+ select_send::send_data() & co., and also uses Protocol_discard object.
+*/
+
+class Protocol_discard : public Protocol_text
+{
+public:
+ Protocol_discard(THD *thd_arg) : Protocol_text(thd_arg) {}
+ /* The real writing is done only in write() */
+ virtual bool write() { return 0; }
+ virtual bool send_result_set_metadata(List<Item> *list, uint flags)
+ {
+ // Don't pas Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF flags
+ return Protocol_text::send_result_set_metadata(list, 0);
+ }
+
+ // send_error is intentionally not overloaded.
+ virtual bool send_eof(uint server_status, uint statement_warn_count)
+ {
+ return 0;
+ }
+
+};
+
+
void send_warning(THD *thd, uint sql_errno, const char *err=0);
bool net_send_error(THD *thd, uint sql_errno, const char *err,
const char* sqlstate);