summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2014-11-20 21:09:57 +0300
committerSergei Petrunia <psergey@askmonty.org>2014-11-20 21:09:57 +0300
commit1f3724a5831cd6529f4917b0a977d456465c68fe (patch)
tree6bd9f013a21ae3e0eb8a56090702fb4f973856d3 /sql
parentbe1c17669cb90e18315d7675c8b4d3c906cd64a7 (diff)
downloadmariadb-git-1f3724a5831cd6529f4917b0a977d456465c68fe.tar.gz
Better comments
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_select.cc18
-rw-r--r--sql/table.h6
2 files changed, 24 insertions, 0 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 7c1a9810db0..468f9fb41e3 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -20736,6 +20736,24 @@ static void free_blobs(Field **ptr)
}
+/*
+ @brief
+ Remove duplicates from a temporary table.
+
+ @detail
+ Remove duplicate rows from a temporary table. This is used for e.g. queries
+ like
+
+ select distinct count(*) as CNT from tbl group by col
+
+ Here, we get a group table with count(*) values. It is not possible to
+ prevent duplicates from appearing in the table (as we don't know the values
+ before we've done the grouping). Because of that, we have this function to
+ scan the temptable (maybe, multiple times) and remove the duplicate rows
+
+ Rows that do not satisfy 'having' condition are also removed.
+*/
+
static int
remove_duplicates(JOIN *join, TABLE *table, List<Item> &fields, Item *having)
{
diff --git a/sql/table.h b/sql/table.h
index eca35d6c52c..a4b3abdd803 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -1072,6 +1072,12 @@ public:
TABLE_LIST *pos_in_table_list;/* Element referring to this table */
/* Position in thd->locked_table_list under LOCK TABLES */
TABLE_LIST *pos_in_locked_tables;
+
+ /*
+ Not-null for temporary tables only. Non-null values means this table is
+ used to compute GROUP BY, it has a unique of GROUP BY columns.
+ (set by create_tmp_table)
+ */
ORDER *group;
String alias; /* alias or table name */
uchar *null_flags;