Skip to content

Commit 0195baf

Browse files
author
Alexey Botchkov
committed
MDEV-31766 SIGSEGV in maria_rtree_split_page | maria_rtree_add_key.
Raise an error when UPDATE with the bad spatial object.
1 parent b1ff40d commit 0195baf

File tree

6 files changed

+52
-5
lines changed

6 files changed

+52
-5
lines changed

mysql-test/main/gis-rtree.result

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,3 +1629,8 @@ DROP TABLE t1;
16291629
#
16301630
# End of 10.1 tests
16311631
#
1632+
CREATE TABLE t1 (c POINT NOT NULL,SPATIAL (c));
1633+
INSERT INTO t1 VALUES (ST_GEOMFROMTEXT ('POINT(1 0)'));
1634+
UPDATE t1 SET c='';
1635+
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
1636+
DROP TABLE t1;

mysql-test/main/gis-rtree.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,3 +1010,15 @@ DROP TABLE t1;
10101010
--echo #
10111011
--echo # End of 10.1 tests
10121012
--echo #
1013+
1014+
#
1015+
# Bug #31766 SIGSEGV in maria_rtree_split_page | maria_rtree_add_key
1016+
#
1017+
1018+
CREATE TABLE t1 (c POINT NOT NULL,SPATIAL (c));
1019+
INSERT INTO t1 VALUES (ST_GEOMFROMTEXT ('POINT(1 0)'));
1020+
--error ER_CANT_CREATE_GEOMETRY_OBJECT
1021+
UPDATE t1 SET c='';
1022+
DROP TABLE t1;
1023+
1024+

mysql-test/suite/innodb_gis/r/innodb_gis_rtree.result

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,3 +1629,8 @@ DROP TABLE t1;
16291629
#
16301630
# End of 10.1 tests
16311631
#
1632+
CREATE TABLE t1 (c POINT NOT NULL,SPATIAL (c));
1633+
INSERT INTO t1 VALUES (ST_GEOMFROMTEXT ('POINT(1 0)'));
1634+
UPDATE t1 SET c='';
1635+
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
1636+
DROP TABLE t1;

mysql-test/suite/maria/maria-gis-rtree.result

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,3 +1484,8 @@ COUNT(*)
14841484
2
14851485
DROP TABLE t1;
14861486
End of 5.0 tests.
1487+
CREATE TABLE t1 (c POINT NOT NULL,SPATIAL (c));
1488+
INSERT INTO t1 VALUES (ST_GEOMFROMTEXT ('POINT(1 0)'));
1489+
UPDATE t1 SET c='';
1490+
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
1491+
DROP TABLE t1;

mysql-test/suite/maria/maria-gis-rtree.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,3 +886,13 @@ SELECT COUNT(*) FROM t1 IGNORE INDEX (b) WHERE
886886
DROP TABLE t1;
887887

888888
--echo End of 5.0 tests.
889+
890+
#
891+
# Bug #31766 SIGSEGV in maria_rtree_split_page | maria_rtree_add_key
892+
#
893+
894+
CREATE TABLE t1 (c POINT NOT NULL,SPATIAL (c));
895+
INSERT INTO t1 VALUES (ST_GEOMFROMTEXT ('POINT(1 0)'));
896+
--error ER_CANT_CREATE_GEOMETRY_OBJECT
897+
UPDATE t1 SET c='';
898+
DROP TABLE t1;

storage/maria/ma_update.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "ma_fulltext.h"
1717
#include "ma_rt_index.h"
1818
#include "trnman.h"
19+
#include <mysqld_error.h>
1920

2021
/**
2122
Update an old row in a MARIA table
@@ -113,10 +114,19 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec,
113114
{
114115
MARIA_KEY new_key, old_key;
115116

116-
(*keyinfo->make_key)(info,&new_key, i, new_key_buff, newrec,
117-
pos, info->trn->trid);
118-
(*keyinfo->make_key)(info,&old_key, i, old_key_buff,
119-
oldrec, pos, info->cur_row.trid);
117+
if (!(*keyinfo->make_key)(info,&new_key, i, new_key_buff, newrec,
118+
pos, info->trn->trid))
119+
goto err;
120+
121+
if (!(*keyinfo->make_key)(info,&old_key, i, old_key_buff,
122+
oldrec, pos, info->cur_row.trid))
123+
{
124+
/*
125+
Can't make a key from the record from the table already.
126+
Sholdn't happen normally. Table is corrupted.
127+
*/
128+
goto err;
129+
}
120130

121131
/* The above changed info->lastkey2. Inform maria_rnext_same(). */
122132
info->update&= ~HA_STATE_RNEXT_SAME;
@@ -204,7 +214,7 @@ int maria_update(register MARIA_HA *info, const uchar *oldrec,
204214
save_errno= HA_ERR_INTERNAL_ERROR; /* Should never happen */
205215

206216
if (my_errno == HA_ERR_FOUND_DUPP_KEY || my_errno == HA_ERR_OUT_OF_MEM ||
207-
my_errno == HA_ERR_RECORD_FILE_FULL)
217+
my_errno == HA_ERR_RECORD_FILE_FULL || my_errno == HA_ERR_NULL_IN_SPATIAL)
208218
{
209219
info->errkey= (int) i;
210220
flag=0;

0 commit comments

Comments
 (0)