summaryrefslogtreecommitdiff
path: root/sql/sql_test.cc
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2010-01-17 17:51:10 +0300
committerSergey Petrunya <psergey@askmonty.org>2010-01-17 17:51:10 +0300
commitb83cb52e9e78a0d07c05f6515aa7811deabe434c (patch)
treeaa289e64cb57964bd08fc79d326136cb801e1da7 /sql/sql_test.cc
parent1a490f2da492f2e5698b244341696c6dd9d8db4c (diff)
downloadmariadb-git-b83cb52e9e78a0d07c05f6515aa7811deabe434c.tar.gz
Backport of subquery optimizations to 5.3.
There are still test failures because of: - Wrong query results in outer join + semi join - EXPLAIN output differences
Diffstat (limited to 'sql/sql_test.cc')
-rw-r--r--sql/sql_test.cc59
1 files changed, 59 insertions, 0 deletions
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index eeb9a21b6f5..89cea0caced 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -213,6 +213,44 @@ TEST_join(JOIN *join)
}
+#define FT_KEYPART (MAX_REF_PARTS+10)
+
+void print_keyuse(KEYUSE *keyuse)
+{
+ char buff[256];
+ char buf2[64];
+ const char *fieldname;
+ String str(buff,(uint32) sizeof(buff), system_charset_info);
+ str.length(0);
+ keyuse->val->print(&str, QT_ORDINARY);
+ str.append('\0');
+ if (keyuse->keypart == FT_KEYPART)
+ fieldname= "FT_KEYPART";
+ else
+ fieldname= keyuse->table->key_info[keyuse->key].key_part[keyuse->keypart].field->field_name;
+ longlong2str(keyuse->used_tables, buf2, 16);
+ DBUG_LOCK_FILE;
+ fprintf(DBUG_FILE, "KEYUSE: %s.%s=%s optimize= %d used_tables=%s "
+ "ref_table_rows= %lu keypart_map= %0lx\n",
+ keyuse->table->alias, fieldname, str.ptr(),
+ keyuse->optimize, buf2, (ulong)keyuse->ref_table_rows,
+ keyuse->keypart_map);
+ DBUG_UNLOCK_FILE;
+ //key_part_map keypart_map; --?? there can be several?
+}
+
+
+/* purecov: begin inspected */
+void print_keyuse_array(DYNAMIC_ARRAY *keyuse_array)
+{
+ DBUG_LOCK_FILE;
+ fprintf(DBUG_FILE, "KEYUSE array (%d elements)\n", keyuse_array->elements);
+ DBUG_UNLOCK_FILE;
+ for(uint i=0; i < keyuse_array->elements; i++)
+ print_keyuse((KEYUSE*)dynamic_array_ptr(keyuse_array, i));
+}
+
+
/*
Print the current state during query optimization.
@@ -313,6 +351,27 @@ print_plan(JOIN* join, uint idx, double record_count, double read_time,
DBUG_UNLOCK_FILE;
}
+
+void print_sjm(SJ_MATERIALIZATION_INFO *sjm)
+{
+ DBUG_LOCK_FILE;
+ fprintf(DBUG_FILE, "\nsemi-join nest{\n");
+ fprintf(DBUG_FILE, " tables { \n");
+ for (uint i= 0;i < sjm->tables; i++)
+ {
+ fprintf(DBUG_FILE, " %s%s\n",
+ sjm->positions[i].table->table->alias,
+ (i == sjm->tables -1)? "": ",");
+ }
+ fprintf(DBUG_FILE, " }\n");
+ fprintf(DBUG_FILE, " materialize_cost= %g\n",
+ sjm->materialization_cost.total_cost());
+ fprintf(DBUG_FILE, " rows= %g\n", sjm->rows);
+ fprintf(DBUG_FILE, "}\n");
+ DBUG_UNLOCK_FILE;
+}
+/* purecov: end */
+
#endif
typedef struct st_debug_lock