Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDEV-35102 CREATE TABLE AS SELECT ST_collect ... does not work #3715

Open
wants to merge 1 commit into
base: bb-11.7-mdev-34120-gis-functions
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions mysql-test/main/spatial_utility_function_collect.result
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,16 @@ GEOMETRYCOLLECTION(MULTIPOINT(5 0),MULTIPOINT(6 0))
GEOMETRYCOLLECTION(MULTIPOINT(6 0),GEOMETRYCOLLECTION EMPTY)
GEOMETRYCOLLECTION(GEOMETRYCOLLECTION EMPTY,GEOMETRYCOLLECTION EMPTY)
DROP TABLE simple_table;
#
# MDEV-35102 CREATE TABLE AS SELECT ST_collect ... does not work
#
SELECT ST_astext(ST_collect(( POINTFROMTEXT(' POINT( 4 1 ) ') )));
ST_astext(ST_collect(( POINTFROMTEXT(' POINT( 4 1 ) ') )))
MULTIPOINT(4 1)
CREATE TABLE tb1 AS SELECT (ST_collect(( POINTFROMTEXT(' POINT( 4 1 ) ') )) );
SHOW CREATE TABLE tb1;
Table Create Table
tb1 CREATE TABLE `tb1` (
`(ST_collect(( POINTFROMTEXT(' POINT( 4 1 ) ') )) )` geometry DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
DROP TABLE tb1;
8 changes: 8 additions & 0 deletions mysql-test/main/spatial_utility_function_collect.test
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,11 @@ PRECEDING AND CURRENT ROW)) AS geocollect FROM simple_table;
# SELECT CAST(ST_COLLECT(geo) AS DECIMAL ) FROM simple_table;

DROP TABLE simple_table;

--echo #
--echo # MDEV-35102 CREATE TABLE AS SELECT ST_collect ... does not work
--echo #
SELECT ST_astext(ST_collect(( POINTFROMTEXT(' POINT( 4 1 ) ') )));
CREATE TABLE tb1 AS SELECT (ST_collect(( POINTFROMTEXT(' POINT( 4 1 ) ') )) );
SHOW CREATE TABLE tb1;
DROP TABLE tb1;
17 changes: 16 additions & 1 deletion sql/item_sum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "sql_parse.h"
#include "sp_head.h"
#include "item_sum.h"
#include "sql_type_geom.h"

/**
Calculate the affordable RAM limit for structures like TREE or Unique
Expand Down Expand Up @@ -4803,6 +4804,20 @@ String *Item_func_collect::val_str(String *str)
}


Item *Item_func_collect::copy_or_same(THD *thd) {
Item *Item_func_collect::copy_or_same(THD *thd)
{
return new (thd->mem_root) Item_func_collect(thd, is_distinct, this);
}


const Type_handler *Item_func_collect::type_handler() const
{
return &type_handler_geometry;
}


bool Item_func_collect::fix_fields_impl(THD *thd,Item **)
{
max_length= UINT_MAX32;
return FALSE;
}
8 changes: 2 additions & 6 deletions sql/item_sum.h
Original file line number Diff line number Diff line change
Expand Up @@ -2169,8 +2169,7 @@ class Item_func_collect : public Item_sum_str
{
return GEOMETRY_COLLECT_FUNC;
}
const Type_handler *type_handler() const override
{ return &type_handler_string; }
const Type_handler *type_handler() const override;
String *val_str(String*str) override;
LEX_CSTRING func_name_cstring() const override
{
Expand All @@ -2185,10 +2184,7 @@ class Item_func_collect : public Item_sum_str
return true;
}

bool fix_fields_impl(THD *,Item **) override
{
return FALSE;
}
bool fix_fields_impl(THD *thd,Item **) override;

public:
Item_func_collect(THD *thd, bool is_distinct, Item *item_par);
Expand Down