summaryrefslogtreecommitdiff
path: root/sql/item_sum.h
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2020-06-04 10:00:56 +0400
committerAlexey Botchkov <holyfoot@askmonty.org>2020-06-04 10:00:56 +0400
commitbb47050e1fdc49aa56fb55c8c55ff81ba24d355b (patch)
tree4b0e592a38460d12b4baf61f4203abe366e9cc27 /sql/item_sum.h
parente7bab059b764bc58ee14e182b51f90c47a6c8e17 (diff)
downloadmariadb-git-bb47050e1fdc49aa56fb55c8c55ff81ba24d355b.tar.gz
MDEV-22640, MDEV-22449, MDEV-21528 JSON_ARRAYAGG crashes with NULL values.
We have to include NULL in the result which the GOUP_CONCAT doesn't always do. Also converting should be done into another String instance as these can be same.
Diffstat (limited to 'sql/item_sum.h')
-rw-r--r--sql/item_sum.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/sql/item_sum.h b/sql/item_sum.h
index 7ff71c84209..7c69dea4a9a 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -1918,6 +1918,12 @@ protected:
bool repack_tree(THD *thd);
+ /*
+ Says whether the function should skip NULL arguments
+ or add them to the result.
+ Redefined in JSON_ARRAYAGG.
+ */
+ virtual bool skip_nulls() const { return true; }
public:
// Methods used by ColumnStore
bool get_distinct() const { return distinct; }
@@ -1947,7 +1953,7 @@ public:
void clear();
bool add()
{
- return add(true);
+ return add(skip_nulls());
}
void reset_field() { DBUG_ASSERT(0); } // not used
void update_field() { DBUG_ASSERT(0); } // not used