Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
3553f6ea
Commit
3553f6ea
authored
Oct 23, 2007
by
gkodinov/kgeorge@magare.gmz
Browse files
Options
Browse Files
Download
Plain Diff
Merge magare.gmz:/home/kgeorge/mysql/autopush/B30825-new-5.0-opt
into magare.gmz:/home/kgeorge/mysql/work/B30825-5.1-opt
parents
ffea2073
d066e217
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
140 additions
and
39 deletions
+140
-39
mysql-test/include/gis_keys.inc
mysql-test/include/gis_keys.inc
+46
-0
mysql-test/r/gis-rtree.result
mysql-test/r/gis-rtree.result
+2
-2
mysql-test/r/gis.result
mysql-test/r/gis.result
+39
-0
mysql-test/r/innodb_gis.result
mysql-test/r/innodb_gis.result
+38
-0
mysql-test/t/gis.test
mysql-test/t/gis.test
+2
-0
mysql-test/t/innodb_gis.test
mysql-test/t/innodb_gis.test
+1
-0
sql/field.cc
sql/field.cc
+0
-30
sql/field.h
sql/field.h
+0
-1
sql/sql_select.h
sql/sql_select.h
+6
-2
sql/sql_table.cc
sql/sql_table.cc
+1
-1
sql/sql_yacc.yy
sql/sql_yacc.yy
+1
-1
sql/table.cc
sql/table.cc
+4
-2
No files found.
mysql-test/include/gis_keys.inc
0 → 100644
View file @
3553f6ea
--
source
include
/
have_geometry
.
inc
#
# Spatial objects with keys
#
#
# Bug #30825: Problems when putting a non-spatial index on a GIS column
#
CREATE
TABLE
t1
(
p
POINT
);
CREATE
TABLE
t2
(
p
POINT
,
INDEX
(
p
));
INSERT
INTO
t1
VALUES
(
POINTFROMTEXT
(
'POINT(1 2)'
));
INSERT
INTO
t2
VALUES
(
POINTFROMTEXT
(
'POINT(1 2)'
));
--
no
index
,
returns
1
as
expected
SELECT
COUNT
(
*
)
FROM
t1
WHERE
p
=
POINTFROMTEXT
(
'POINT(1 2)'
);
--
with
index
,
returns
1
as
expected
--
EXPLAIN
shows
that
the
index
is
not
used
though
--
due
to
the
"most rows covered anyway, so a scan is more effective"
rule
EXPLAIN
SELECT
COUNT
(
*
)
FROM
t2
WHERE
p
=
POINTFROMTEXT
(
'POINT(1 2)'
);
SELECT
COUNT
(
*
)
FROM
t2
WHERE
p
=
POINTFROMTEXT
(
'POINT(1 2)'
);
--
adding
another
row
to
the
table
so
that
--
the
"most rows covered"
rule
doesn
't kick in anymore
-- now EXPLAIN shows the index used on the table
-- and we'
re
getting
the
wrong
result
again
INSERT
INTO
t1
VALUES
(
POINTFROMTEXT
(
'POINT(1 2)'
));
INSERT
INTO
t2
VALUES
(
POINTFROMTEXT
(
'POINT(1 2)'
));
EXPLAIN
SELECT
COUNT
(
*
)
FROM
t1
WHERE
p
=
POINTFROMTEXT
(
'POINT(1 2)'
);
SELECT
COUNT
(
*
)
FROM
t1
WHERE
p
=
POINTFROMTEXT
(
'POINT(1 2)'
);
EXPLAIN
SELECT
COUNT
(
*
)
FROM
t2
WHERE
p
=
POINTFROMTEXT
(
'POINT(1 2)'
);
SELECT
COUNT
(
*
)
FROM
t2
WHERE
p
=
POINTFROMTEXT
(
'POINT(1 2)'
);
EXPLAIN
SELECT
COUNT
(
*
)
FROM
t2
IGNORE
INDEX
(
p
)
WHERE
p
=
POINTFROMTEXT
(
'POINT(1 2)'
);
SELECT
COUNT
(
*
)
FROM
t2
IGNORE
INDEX
(
p
)
WHERE
p
=
POINTFROMTEXT
(
'POINT(1 2)'
);
DROP
TABLE
t1
,
t2
;
--
echo
End
of
5.0
tests
mysql-test/r/gis-rtree.result
View file @
3553f6ea
...
...
@@ -167,7 +167,7 @@ count(*)
150
EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range g g 3
2
NULL 8 Using where
1 SIMPLE t1 range g g 3
4
NULL 8 Using where
SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
fid AsText(g)
1 LINESTRING(150 150,150 150)
...
...
@@ -301,7 +301,7 @@ count(*)
EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range g g 3
2
NULL 4 Using where
1 SIMPLE t2 range g g 3
4
NULL 4 Using where
SELECT fid, AsText(g) FROM t2 WHERE Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
fid AsText(g)
...
...
mysql-test/r/gis.result
View file @
3553f6ea
...
...
@@ -895,6 +895,45 @@ drop table t1, t2;
SELECT 1;
1
1
CREATE TABLE t1 (p POINT);
CREATE TABLE t2 (p POINT, INDEX(p));
INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)'));
INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)'));
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
1
EXPLAIN
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 system p NULL NULL NULL 1
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
1
INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)'));
INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)'));
EXPLAIN
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
2
EXPLAIN
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref p p 28 const 1 Using where
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
2
EXPLAIN
SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
2
DROP TABLE t1, t2;
End of 5.0 tests
End of 5.0 tests
create table t1 (f1 tinyint(1), f2 char(1), f3 varchar(1), f4 geometry, f5 datetime);
create view v1 as select * from t1;
...
...
mysql-test/r/innodb_gis.result
View file @
3553f6ea
...
...
@@ -545,6 +545,44 @@ SELECT Overlaps(@horiz1, @point2) FROM DUAL;
Overlaps(@horiz1, @point2)
0
DROP TABLE t1;
CREATE TABLE t1 (p POINT);
CREATE TABLE t2 (p POINT, INDEX(p));
INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)'));
INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)'));
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
1
EXPLAIN
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref p p 28 const 1 Using where
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
1
INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)'));
INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)'));
EXPLAIN
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
2
EXPLAIN
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref p p 28 const 1 Using where
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
2
EXPLAIN
SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
COUNT(*)
2
DROP TABLE t1, t2;
End of 5.0 tests
create table t1 (g geometry not null, spatial gk(g)) engine=innodb;
ERROR HY000: The used table type doesn't support SPATIAL indexes
mysql-test/t/gis.test
View file @
3553f6ea
...
...
@@ -599,6 +599,8 @@ SELECT AsText(GeometryFromText(CONCAT(
--
enable_query_log
SELECT
1
;
--
source
include
/
gis_keys
.
inc
--
echo
End
of
5.0
tests
...
...
mysql-test/t/innodb_gis.test
View file @
3553f6ea
--
source
include
/
have_innodb
.
inc
SET
storage_engine
=
innodb
;
--
source
include
/
gis_generic
.
inc
--
source
include
/
gis_keys
.
inc
#
# Bug #15680 (SPATIAL key in innodb)
...
...
sql/field.cc
View file @
3553f6ea
...
...
@@ -8031,36 +8031,6 @@ uint Field_blob::is_equal(Create_field *new_field)
#ifdef HAVE_SPATIAL
uint
Field_geom
::
get_key_image
(
uchar
*
buff
,
uint
length
,
imagetype
type
)
{
uchar
*
blob
;
const
char
*
dummy
;
MBR
mbr
;
ulong
blob_length
=
get_length
(
ptr
);
Geometry_buffer
buffer
;
Geometry
*
gobj
;
const
uint
image_length
=
SIZEOF_STORED_DOUBLE
*
4
;
if
(
blob_length
<
SRID_SIZE
)
{
bzero
(
buff
,
image_length
);
return
image_length
;
}
get_ptr
(
&
blob
);
gobj
=
Geometry
::
construct
(
&
buffer
,
(
char
*
)
blob
,
blob_length
);
if
(
!
gobj
||
gobj
->
get_mbr
(
&
mbr
,
&
dummy
))
bzero
(
buff
,
image_length
);
else
{
float8store
(
buff
,
mbr
.
xmin
);
float8store
(
buff
+
8
,
mbr
.
xmax
);
float8store
(
buff
+
16
,
mbr
.
ymin
);
float8store
(
buff
+
24
,
mbr
.
ymax
);
}
return
image_length
;
}
void
Field_geom
::
sql_type
(
String
&
res
)
const
{
CHARSET_INFO
*
cs
=
&
my_charset_latin1
;
...
...
sql/field.h
View file @
3553f6ea
...
...
@@ -1522,7 +1522,6 @@ class Field_geom :public Field_blob {
int
store
(
double
nr
);
int
store
(
longlong
nr
,
bool
unsigned_val
);
int
store_decimal
(
const
my_decimal
*
);
uint
get_key_image
(
uchar
*
buff
,
uint
length
,
imagetype
type
);
uint
size_of
()
const
{
return
sizeof
(
*
this
);
}
int
reset
(
void
)
{
return
!
maybe_null
()
||
Field_blob
::
reset
();
}
geometry_type
get_geometry_type
()
{
return
geom_type
;
};
...
...
sql/sql_select.h
View file @
3553f6ea
...
...
@@ -566,9 +566,13 @@ class store_key :public Sql_alloc
store_key
(
THD
*
thd
,
Field
*
field_arg
,
uchar
*
ptr
,
uchar
*
null
,
uint
length
)
:
null_key
(
0
),
null_ptr
(
null
),
err
(
0
)
{
if
(
field_arg
->
type
()
==
MYSQL_TYPE_BLOB
)
if
(
field_arg
->
type
()
==
MYSQL_TYPE_BLOB
||
field_arg
->
type
()
==
MYSQL_TYPE_GEOMETRY
)
{
/* Key segments are always packed with a 2 byte length prefix */
/*
Key segments are always packed with a 2 byte length prefix.
See mi_rkey for details.
*/
to_field
=
new
Field_varstring
(
ptr
,
length
,
2
,
null
,
1
,
Field
::
NONE
,
field_arg
->
field_name
,
field_arg
->
table
->
s
,
field_arg
->
charset
());
...
...
sql/sql_table.cc
View file @
3553f6ea
...
...
@@ -2740,7 +2740,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
}
if
(
f_is_geom
(
sql_field
->
pack_flag
)
&&
sql_field
->
geom_type
==
Field
::
GEOM_POINT
)
column
->
length
=
2
1
;
column
->
length
=
2
5
;
if
(
!
column
->
length
)
{
my_error
(
ER_BLOB_KEY_WITHOUT_LENGTH
,
MYF
(
0
),
column
->
field_name
);
...
...
sql/sql_yacc.yy
View file @
3553f6ea
...
...
@@ -4896,7 +4896,7 @@ spatial_type:
| GEOMETRYCOLLECTION { $$= Field::GEOM_GEOMETRYCOLLECTION; }
| POINT_SYM
{
Lex->length= (char*)"2
1
";
Lex->length= (char*)"2
5
";
$$= Field::GEOM_POINT;
}
| MULTIPOINT { $$= Field::GEOM_MULTIPOINT; }
...
...
sql/table.cc
View file @
3553f6ea
...
...
@@ -1351,9 +1351,11 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
keyinfo
->
key_length
+=
HA_KEY_NULL_LENGTH
;
}
if
(
field
->
type
()
==
MYSQL_TYPE_BLOB
||
field
->
real_type
()
==
MYSQL_TYPE_VARCHAR
)
field
->
real_type
()
==
MYSQL_TYPE_VARCHAR
||
field
->
type
()
==
MYSQL_TYPE_GEOMETRY
)
{
if
(
field
->
type
()
==
MYSQL_TYPE_BLOB
)
if
(
field
->
type
()
==
MYSQL_TYPE_BLOB
||
field
->
type
()
==
MYSQL_TYPE_GEOMETRY
)
key_part
->
key_part_flag
|=
HA_BLOB_PART
;
else
key_part
->
key_part_flag
|=
HA_VAR_LENGTH_PART
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment