Commit da64397b authored by jani@ua141d10.elisa.omakaista.fi's avatar jani@ua141d10.elisa.omakaista.fi

Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.0

into  ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-5.0-tmp
parents 531b847f 44aea416
...@@ -518,6 +518,13 @@ int main(int argc, char **argv) ...@@ -518,6 +518,13 @@ int main(int argc, char **argv)
free_defaults(argv_to_free); free_defaults(argv_to_free);
return(1); /* purecov: deadcode */ return(1); /* purecov: deadcode */
} }
if (mysql_query(sock, "set @@character_set_database=binary;"))
{
db_error(sock); /* We shall countinue here, if --force was given */
return(1);
}
if (lock_tables) if (lock_tables)
lock_table(sock, argc, argv); lock_table(sock, argc, argv);
for (; *argv != NULL; argv++) for (; *argv != NULL; argv++)
......
...@@ -173,6 +173,7 @@ our $exe_mysql_client_test; ...@@ -173,6 +173,7 @@ our $exe_mysql_client_test;
our $exe_mysqld; our $exe_mysqld;
our $exe_mysqlcheck; # Called from test case our $exe_mysqlcheck; # Called from test case
our $exe_mysqldump; # Called from test case our $exe_mysqldump; # Called from test case
our $exe_mysqlimport; # Called from test case
our $exe_mysqlshow; # Called from test case our $exe_mysqlshow; # Called from test case
our $exe_mysql_fix_system_tables; our $exe_mysql_fix_system_tables;
our $exe_mysqltest; our $exe_mysqltest;
...@@ -926,6 +927,7 @@ sub executable_setup () { ...@@ -926,6 +927,7 @@ sub executable_setup () {
} }
$exe_mysqlcheck= mtr_exe_exists("$path_client_bindir/mysqlcheck"); $exe_mysqlcheck= mtr_exe_exists("$path_client_bindir/mysqlcheck");
$exe_mysqldump= mtr_exe_exists("$path_client_bindir/mysqldump"); $exe_mysqldump= mtr_exe_exists("$path_client_bindir/mysqldump");
$exe_mysqlimport= mtr_exe_exists("$path_client_bindir/mysqlimport");
$exe_mysqlshow= mtr_exe_exists("$path_client_bindir/mysqlshow"); $exe_mysqlshow= mtr_exe_exists("$path_client_bindir/mysqlshow");
$exe_mysqlbinlog= mtr_exe_exists("$path_client_bindir/mysqlbinlog"); $exe_mysqlbinlog= mtr_exe_exists("$path_client_bindir/mysqlbinlog");
$exe_mysqladmin= mtr_exe_exists("$path_client_bindir/mysqladmin"); $exe_mysqladmin= mtr_exe_exists("$path_client_bindir/mysqladmin");
...@@ -2450,6 +2452,14 @@ sub run_mysqltest ($) { ...@@ -2450,6 +2452,14 @@ sub run_mysqltest ($) {
$cmdline_mysqldump .= $cmdline_mysqldump .=
" --debug=d:t:A,$opt_vardir/log/mysqldump.trace"; " --debug=d:t:A,$opt_vardir/log/mysqldump.trace";
} }
my $cmdline_mysqlimport= "$exe_mysqlimport -uroot " .
"--port=$master->[0]->{'path_myport'} " .
"--socket=$master->[0]->{'path_mysock'} --password=";
if ( $opt_debug )
{
$cmdline_mysqlimport .=
" --debug=d:t:A,$opt_vardir/log/mysqlimport.trace";
}
my $cmdline_mysqlshow= "$exe_mysqlshow -uroot " . my $cmdline_mysqlshow= "$exe_mysqlshow -uroot " .
"--port=$master->[0]->{'path_myport'} " . "--port=$master->[0]->{'path_myport'} " .
...@@ -2503,6 +2513,7 @@ sub run_mysqltest ($) { ...@@ -2503,6 +2513,7 @@ sub run_mysqltest ($) {
$ENV{'MYSQL'}= $cmdline_mysql; $ENV{'MYSQL'}= $cmdline_mysql;
$ENV{'MYSQL_CHECK'}= $cmdline_mysqlcheck; $ENV{'MYSQL_CHECK'}= $cmdline_mysqlcheck;
$ENV{'MYSQL_DUMP'}= $cmdline_mysqldump; $ENV{'MYSQL_DUMP'}= $cmdline_mysqldump;
$ENV{'MYSQL_IMPORT'}= $cmdline_mysqlimport;
$ENV{'MYSQL_SHOW'}= $cmdline_mysqlshow; $ENV{'MYSQL_SHOW'}= $cmdline_mysqlshow;
$ENV{'MYSQL_BINLOG'}= $cmdline_mysqlbinlog; $ENV{'MYSQL_BINLOG'}= $cmdline_mysqlbinlog;
$ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables; $ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables;
......
...@@ -629,6 +629,11 @@ if [ x$SOURCE_DIST = x1 ] ; then ...@@ -629,6 +629,11 @@ if [ x$SOURCE_DIST = x1 ] ; then
else else
MYSQL_DUMP="$BASEDIR/client/mysqldump" MYSQL_DUMP="$BASEDIR/client/mysqldump"
fi fi
if [ -f "$BASEDIR/client/.libs/mysqlimport" ] ; then
MYSQL_IMPORT="$BASEDIR/client/.libs/mysqlimport"
else
MYSQL_IMPORT="$BASEDIR/client/mysqlimport"
fi
if [ -f "$BASEDIR/client/.libs/mysqlshow" ] ; then if [ -f "$BASEDIR/client/.libs/mysqlshow" ] ; then
MYSQL_SHOW="$BASEDIR/client/.libs/mysqlshow" MYSQL_SHOW="$BASEDIR/client/.libs/mysqlshow"
else else
...@@ -705,6 +710,7 @@ else ...@@ -705,6 +710,7 @@ else
MYSQL_CHECK="$CLIENT_BINDIR/mysqlcheck" MYSQL_CHECK="$CLIENT_BINDIR/mysqlcheck"
MYSQL_DUMP="$CLIENT_BINDIR/mysqldump" MYSQL_DUMP="$CLIENT_BINDIR/mysqldump"
MYSQL_SHOW="$CLIENT_BINDIR/mysqlshow" MYSQL_SHOW="$CLIENT_BINDIR/mysqlshow"
MYSQL_IMPORT="$CLIENT_BINDIR/mysqlimport"
MYSQL_BINLOG="$CLIENT_BINDIR/mysqlbinlog" MYSQL_BINLOG="$CLIENT_BINDIR/mysqlbinlog"
MYSQLADMIN="$CLIENT_BINDIR/mysqladmin" MYSQLADMIN="$CLIENT_BINDIR/mysqladmin"
WAIT_PID="$CLIENT_BINDIR/mysql_waitpid" WAIT_PID="$CLIENT_BINDIR/mysql_waitpid"
...@@ -792,9 +798,10 @@ MYSQL_CHECK="$MYSQL_CHECK --no-defaults -uroot --socket=$MASTER_MYSOCK --passwor ...@@ -792,9 +798,10 @@ MYSQL_CHECK="$MYSQL_CHECK --no-defaults -uroot --socket=$MASTER_MYSOCK --passwor
MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT" MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT"
MYSQL_SHOW="$MYSQL_SHOW -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLSHOW_OPT" MYSQL_SHOW="$MYSQL_SHOW -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLSHOW_OPT"
MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR --character-sets-dir=$CHARSETSDIR $EXTRA_MYSQLBINLOG_OPT" MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR --character-sets-dir=$CHARSETSDIR $EXTRA_MYSQLBINLOG_OPT"
MYSQL_IMPORT="$MYSQL_IMPORT -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT"
MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose" MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose"
MYSQL="$MYSQL --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD" MYSQL="$MYSQL --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD"
export MYSQL MYSQL_CHECK MYSQL_DUMP MYSQL_SHOW MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES export MYSQL MYSQL_CHECK MYSQL_DUMP MYSQL_SHOW MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES MYSQL_IMPORT
export CLIENT_BINDIR MYSQL_CLIENT_TEST CHARSETSDIR MYSQL_MY_PRINT_DEFAULTS export CLIENT_BINDIR MYSQL_CLIENT_TEST CHARSETSDIR MYSQL_MY_PRINT_DEFAULTS
export NDB_TOOLS_DIR export NDB_TOOLS_DIR
export NDB_MGM export NDB_MGM
......
...@@ -688,3 +688,9 @@ alter table t1 add primary key pti(pt); ...@@ -688,3 +688,9 @@ alter table t1 add primary key pti(pt);
ERROR 42000: BLOB/TEXT column 'pt' used in key specification without a key length ERROR 42000: BLOB/TEXT column 'pt' used in key specification without a key length
alter table t1 add primary key pti(pt(20)); alter table t1 add primary key pti(pt(20));
drop table t1; drop table t1;
select (asWKT(geomfromwkb((0x000000000140240000000000004024000000000000))));
(asWKT(geomfromwkb((0x000000000140240000000000004024000000000000))))
POINT(10 10)
select (asWKT(geomfromwkb((0x010100000000000000000024400000000000002440))));
(asWKT(geomfromwkb((0x010100000000000000000024400000000000002440))))
POINT(10 10)
...@@ -1677,6 +1677,16 @@ insert into t2 (a, b) values (NULL, NULL),(10, NULL),(NULL, "twenty"),(30, "thir ...@@ -1677,6 +1677,16 @@ insert into t2 (a, b) values (NULL, NULL),(10, NULL),(NULL, "twenty"),(30, "thir
</database> </database>
</mysqldump> </mysqldump>
drop table t1, t2; drop table t1, t2;
create table t1 (a text character set utf8, b text character set latin1);
insert t1 values (0x4F736E616272C3BC636B, 0x4BF66C6E);
select * from t1;
a b
Osnabrck Kln
test.t1: Records: 1 Deleted: 0 Skipped: 0 Warnings: 0
select * from t1;
a b
Osnabrck Kln
drop table t1;
create table t1(a int); create table t1(a int);
create view v1 as select * from t1; create view v1 as select * from t1;
......
...@@ -372,6 +372,9 @@ insert into t1 values (pointfromtext('point(1,1)')); ...@@ -372,6 +372,9 @@ insert into t1 values (pointfromtext('point(1,1)'));
drop table t1; drop table t1;
select (asWKT(geomfromwkb((0x000000000140240000000000004024000000000000))));
select (asWKT(geomfromwkb((0x010100000000000000000024400000000000002440))));
# End of 4.1 tests # End of 4.1 tests
# #
......
...@@ -697,6 +697,18 @@ insert into t2 (a, b) values (NULL, NULL),(10, NULL),(NULL, "twenty"),(30, "thir ...@@ -697,6 +697,18 @@ insert into t2 (a, b) values (NULL, NULL),(10, NULL),(NULL, "twenty"),(30, "thir
--exec $MYSQL_DUMP --skip-comments --xml --no-create-info test --exec $MYSQL_DUMP --skip-comments --xml --no-create-info test
drop table t1, t2; drop table t1, t2;
#
# BUG #12123
#
create table t1 (a text character set utf8, b text character set latin1);
insert t1 values (0x4F736E616272C3BC636B, 0x4BF66C6E);
select * from t1;
--exec $MYSQL_DUMP --tab=$MYSQL_TEST_DIR/var/tmp/ test
--exec $MYSQL test < $MYSQL_TEST_DIR/var/tmp/t1.sql
--exec $MYSQL_IMPORT test $MYSQL_TEST_DIR/var/tmp/t1.txt
select * from t1;
drop table t1;
# End of 4.1 tests # End of 4.1 tests
# #
......
...@@ -7041,8 +7041,7 @@ void Field_blob::get_key_image(char *buff, uint length, imagetype type) ...@@ -7041,8 +7041,7 @@ void Field_blob::get_key_image(char *buff, uint length, imagetype type)
return; return;
} }
get_ptr(&blob); get_ptr(&blob);
gobj= Geometry::create_from_wkb(&buffer, gobj= Geometry::construct(&buffer, blob, blob_length);
blob + SRID_SIZE, blob_length - SRID_SIZE);
if (gobj->get_mbr(&mbr, &dummy)) if (gobj->get_mbr(&mbr, &dummy))
bzero(buff, SIZEOF_STORED_DOUBLE*4); bzero(buff, SIZEOF_STORED_DOUBLE*4);
else else
...@@ -7371,8 +7370,7 @@ void Field_geom::get_key_image(char *buff, uint length, imagetype type) ...@@ -7371,8 +7370,7 @@ void Field_geom::get_key_image(char *buff, uint length, imagetype type)
return; return;
} }
get_ptr(&blob); get_ptr(&blob);
gobj= Geometry::create_from_wkb(&buffer, gobj= Geometry::construct(&buffer, blob, blob_length);
blob + SRID_SIZE, blob_length - SRID_SIZE);
if (gobj->get_mbr(&mbr, &dummy)) if (gobj->get_mbr(&mbr, &dummy))
bzero(buff, SIZEOF_STORED_DOUBLE*4); bzero(buff, SIZEOF_STORED_DOUBLE*4);
else else
...@@ -7453,7 +7451,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs) ...@@ -7453,7 +7451,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs)
uint32 wkb_type; uint32 wkb_type;
if (length < SRID_SIZE + WKB_HEADER_SIZE + SIZEOF_STORED_DOUBLE*2) if (length < SRID_SIZE + WKB_HEADER_SIZE + SIZEOF_STORED_DOUBLE*2)
goto err; goto err;
wkb_type= uint4korr(from + WKB_HEADER_SIZE); wkb_type= uint4korr(from + SRID_SIZE + 1);
if (wkb_type < (uint32) Geometry::wkb_point || if (wkb_type < (uint32) Geometry::wkb_point ||
wkb_type > (uint32) Geometry::wkb_end) wkb_type > (uint32) Geometry::wkb_end)
goto err; goto err;
......
...@@ -81,8 +81,7 @@ String *Item_func_geometry_from_wkb::val_str(String *str) ...@@ -81,8 +81,7 @@ String *Item_func_geometry_from_wkb::val_str(String *str)
str->q_append(srid); str->q_append(srid);
if ((null_value= if ((null_value=
(args[0]->null_value || (args[0]->null_value ||
!Geometry::create_from_wkb(&buffer, wkb->ptr(), wkb->length()) || !Geometry::create_from_wkb(&buffer, wkb->ptr(), wkb->length(), str))))
str->append(*wkb))))
return 0; return 0;
return str; return str;
} }
...@@ -99,8 +98,7 @@ String *Item_func_as_wkt::val_str(String *str) ...@@ -99,8 +98,7 @@ String *Item_func_as_wkt::val_str(String *str)
if ((null_value= if ((null_value=
(args[0]->null_value || (args[0]->null_value ||
!(geom= Geometry::create_from_wkb(&buffer, swkb->ptr() + SRID_SIZE, !(geom= Geometry::construct(&buffer, swkb->ptr(), swkb->length())))))
swkb->length() - SRID_SIZE)))))
return 0; return 0;
str->length(0); str->length(0);
...@@ -126,8 +124,7 @@ String *Item_func_as_wkb::val_str(String *str) ...@@ -126,8 +124,7 @@ String *Item_func_as_wkb::val_str(String *str)
if ((null_value= if ((null_value=
(args[0]->null_value || (args[0]->null_value ||
!(Geometry::create_from_wkb(&buffer, swkb->ptr() + SRID_SIZE, !(Geometry::construct(&buffer, swkb->ptr(), swkb->length())))))
swkb->length() - SRID_SIZE)))))
return 0; return 0;
str->copy(swkb->ptr() + SRID_SIZE, swkb->length() - SRID_SIZE, str->copy(swkb->ptr() + SRID_SIZE, swkb->length() - SRID_SIZE,
...@@ -145,8 +142,7 @@ String *Item_func_geometry_type::val_str(String *str) ...@@ -145,8 +142,7 @@ String *Item_func_geometry_type::val_str(String *str)
if ((null_value= if ((null_value=
(args[0]->null_value || (args[0]->null_value ||
!(geom= Geometry::create_from_wkb(&buffer, swkb->ptr() + SRID_SIZE, !(geom= Geometry::construct(&buffer, swkb->ptr(), swkb->length())))))
swkb->length() - SRID_SIZE)))))
return 0; return 0;
/* String will not move */ /* String will not move */
str->copy(geom->get_class_info()->m_name.str, str->copy(geom->get_class_info()->m_name.str,
...@@ -167,8 +163,7 @@ String *Item_func_envelope::val_str(String *str) ...@@ -167,8 +163,7 @@ String *Item_func_envelope::val_str(String *str)
if ((null_value= if ((null_value=
args[0]->null_value || args[0]->null_value ||
!(geom= Geometry::create_from_wkb(&buffer, swkb->ptr() + SRID_SIZE, !(geom= Geometry::construct(&buffer, swkb->ptr(), swkb->length()))))
swkb->length() - SRID_SIZE))))
return 0; return 0;
srid= uint4korr(swkb->ptr()); srid= uint4korr(swkb->ptr());
...@@ -191,8 +186,7 @@ String *Item_func_centroid::val_str(String *str) ...@@ -191,8 +186,7 @@ String *Item_func_centroid::val_str(String *str)
uint32 srid; uint32 srid;
if ((null_value= args[0]->null_value || if ((null_value= args[0]->null_value ||
!(geom= Geometry::create_from_wkb(&buffer, swkb->ptr() + SRID_SIZE, !(geom= Geometry::construct(&buffer, swkb->ptr(), swkb->length()))))
swkb->length() - SRID_SIZE))))
return 0; return 0;
str->set_charset(&my_charset_bin); str->set_charset(&my_charset_bin);
...@@ -221,8 +215,7 @@ String *Item_func_spatial_decomp::val_str(String *str) ...@@ -221,8 +215,7 @@ String *Item_func_spatial_decomp::val_str(String *str)
if ((null_value= if ((null_value=
(args[0]->null_value || (args[0]->null_value ||
!(geom= Geometry::create_from_wkb(&buffer, swkb->ptr() + SRID_SIZE, !(geom= Geometry::construct(&buffer, swkb->ptr(), swkb->length())))))
swkb->length() - SRID_SIZE)))))
return 0; return 0;
srid= uint4korr(swkb->ptr()); srid= uint4korr(swkb->ptr());
...@@ -270,8 +263,7 @@ String *Item_func_spatial_decomp_n::val_str(String *str) ...@@ -270,8 +263,7 @@ String *Item_func_spatial_decomp_n::val_str(String *str)
if ((null_value= if ((null_value=
(args[0]->null_value || args[1]->null_value || (args[0]->null_value || args[1]->null_value ||
!(geom= Geometry::create_from_wkb(&buffer, swkb->ptr() + SRID_SIZE, !(geom= Geometry::construct(&buffer, swkb->ptr(), swkb->length())))))
swkb->length() - SRID_SIZE)))))
return 0; return 0;
str->set_charset(&my_charset_bin); str->set_charset(&my_charset_bin);
...@@ -478,10 +470,8 @@ longlong Item_func_spatial_rel::val_int() ...@@ -478,10 +470,8 @@ longlong Item_func_spatial_rel::val_int()
if ((null_value= if ((null_value=
(args[0]->null_value || (args[0]->null_value ||
args[1]->null_value || args[1]->null_value ||
!(g1= Geometry::create_from_wkb(&buffer1, res1->ptr() + SRID_SIZE, !(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) ||
res1->length() - SRID_SIZE)) || !(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())) ||
!(g2= Geometry::create_from_wkb(&buffer2, res2->ptr() + SRID_SIZE,
res2->length() - SRID_SIZE)) ||
g1->get_mbr(&mbr1, &dummy) || g1->get_mbr(&mbr1, &dummy) ||
g2->get_mbr(&mbr2, &dummy)))) g2->get_mbr(&mbr2, &dummy))))
return 0; return 0;
...@@ -546,8 +536,7 @@ longlong Item_func_isclosed::val_int() ...@@ -546,8 +536,7 @@ longlong Item_func_isclosed::val_int()
null_value= (!swkb || null_value= (!swkb ||
args[0]->null_value || args[0]->null_value ||
!(geom= !(geom=
Geometry::create_from_wkb(&buffer, swkb->ptr() + SRID_SIZE, Geometry::construct(&buffer, swkb->ptr(), swkb->length())) ||
swkb->length() - SRID_SIZE)) ||
geom->is_closed(&isclosed)); geom->is_closed(&isclosed));
return (longlong) isclosed; return (longlong) isclosed;
...@@ -569,9 +558,7 @@ longlong Item_func_dimension::val_int() ...@@ -569,9 +558,7 @@ longlong Item_func_dimension::val_int()
null_value= (!swkb || null_value= (!swkb ||
args[0]->null_value || args[0]->null_value ||
!(geom= Geometry::create_from_wkb(&buffer, !(geom= Geometry::construct(&buffer, swkb->ptr(), swkb->length())) ||
swkb->ptr() + SRID_SIZE,
swkb->length() - SRID_SIZE)) ||
geom->dimension(&dim, &dummy)); geom->dimension(&dim, &dummy));
return (longlong) dim; return (longlong) dim;
} }
...@@ -586,9 +573,8 @@ longlong Item_func_numinteriorring::val_int() ...@@ -586,9 +573,8 @@ longlong Item_func_numinteriorring::val_int()
Geometry *geom; Geometry *geom;
null_value= (!swkb || null_value= (!swkb ||
!(geom= Geometry::create_from_wkb(&buffer, !(geom= Geometry::construct(&buffer,
swkb->ptr() + SRID_SIZE, swkb->ptr(), swkb->length())) ||
swkb->length() - SRID_SIZE)) ||
geom->num_interior_ring(&num)); geom->num_interior_ring(&num));
return (longlong) num; return (longlong) num;
} }
...@@ -603,9 +589,8 @@ longlong Item_func_numgeometries::val_int() ...@@ -603,9 +589,8 @@ longlong Item_func_numgeometries::val_int()
Geometry *geom; Geometry *geom;
null_value= (!swkb || null_value= (!swkb ||
!(geom= Geometry::create_from_wkb(&buffer, !(geom= Geometry::construct(&buffer,
swkb->ptr() + SRID_SIZE, swkb->ptr(), swkb->length())) ||
swkb->length() - SRID_SIZE)) ||
geom->num_geometries(&num)); geom->num_geometries(&num));
return (longlong) num; return (longlong) num;
} }
...@@ -621,9 +606,8 @@ longlong Item_func_numpoints::val_int() ...@@ -621,9 +606,8 @@ longlong Item_func_numpoints::val_int()
null_value= (!swkb || null_value= (!swkb ||
args[0]->null_value || args[0]->null_value ||
!(geom= Geometry::create_from_wkb(&buffer, !(geom= Geometry::construct(&buffer,
swkb->ptr() + SRID_SIZE, swkb->ptr(), swkb->length())) ||
swkb->length() - SRID_SIZE)) ||
geom->num_points(&num)); geom->num_points(&num));
return (longlong) num; return (longlong) num;
} }
...@@ -638,9 +622,8 @@ double Item_func_x::val_real() ...@@ -638,9 +622,8 @@ double Item_func_x::val_real()
Geometry *geom; Geometry *geom;
null_value= (!swkb || null_value= (!swkb ||
!(geom= Geometry::create_from_wkb(&buffer, !(geom= Geometry::construct(&buffer,
swkb->ptr() + SRID_SIZE, swkb->ptr(), swkb->length())) ||
swkb->length() - SRID_SIZE)) ||
geom->get_x(&res)); geom->get_x(&res));
return res; return res;
} }
...@@ -655,9 +638,8 @@ double Item_func_y::val_real() ...@@ -655,9 +638,8 @@ double Item_func_y::val_real()
Geometry *geom; Geometry *geom;
null_value= (!swkb || null_value= (!swkb ||
!(geom= Geometry::create_from_wkb(&buffer, !(geom= Geometry::construct(&buffer,
swkb->ptr() + SRID_SIZE, swkb->ptr(), swkb->length())) ||
swkb->length() - SRID_SIZE)) ||
geom->get_y(&res)); geom->get_y(&res));
return res; return res;
} }
...@@ -673,9 +655,8 @@ double Item_func_area::val_real() ...@@ -673,9 +655,8 @@ double Item_func_area::val_real()
const char *dummy; const char *dummy;
null_value= (!swkb || null_value= (!swkb ||
!(geom= Geometry::create_from_wkb(&buffer, !(geom= Geometry::construct(&buffer,
swkb->ptr() + SRID_SIZE, swkb->ptr(), swkb->length())) ||
swkb->length() - SRID_SIZE)) ||
geom->area(&res, &dummy)); geom->area(&res, &dummy));
return res; return res;
} }
...@@ -689,9 +670,8 @@ double Item_func_glength::val_real() ...@@ -689,9 +670,8 @@ double Item_func_glength::val_real()
Geometry *geom; Geometry *geom;
null_value= (!swkb || null_value= (!swkb ||
!(geom= Geometry::create_from_wkb(&buffer, !(geom= Geometry::construct(&buffer,
swkb->ptr() + SRID_SIZE, swkb->ptr(), swkb->length())) ||
swkb->length() - SRID_SIZE)) ||
geom->length(&res)); geom->length(&res));
return res; return res;
} }
...@@ -703,9 +683,8 @@ longlong Item_func_srid::val_int() ...@@ -703,9 +683,8 @@ longlong Item_func_srid::val_int()
Geometry_buffer buffer; Geometry_buffer buffer;
null_value= (!swkb || null_value= (!swkb ||
!Geometry::create_from_wkb(&buffer, !Geometry::construct(&buffer,
swkb->ptr() + SRID_SIZE, swkb->ptr(), swkb->length()));
swkb->length() - SRID_SIZE));
if (null_value) if (null_value)
return 0; return 0;
......
...@@ -121,25 +121,23 @@ Geometry::Class_info *Geometry::find_class(const char *name, uint32 len) ...@@ -121,25 +121,23 @@ Geometry::Class_info *Geometry::find_class(const char *name, uint32 len)
return 0; return 0;
} }
Geometry *Geometry::create_from_wkb(Geometry_buffer *buffer,
Geometry *Geometry::construct(Geometry_buffer *buffer,
const char *data, uint32 data_len) const char *data, uint32 data_len)
{ {
uint32 geom_type; uint32 geom_type;
Geometry *result; Geometry *result;
char byte_order;
if (data_len < 1 + 4) if (data_len < SRID_SIZE + 1 + 4)
return NULL; return NULL;
data++; byte_order= data[SRID_SIZE];
/* geom_type= uint4korr(data + SRID_SIZE + 1);
FIXME: check byte ordering data+= SRID_SIZE + WKB_HEADER_SIZE;
Also check if we could replace this with one byte
*/
geom_type= uint4korr(data);
data+= 4;
if (!(result= create_by_typeid(buffer, (int) geom_type))) if (!(result= create_by_typeid(buffer, (int) geom_type)))
return NULL; return NULL;
result->m_data= data; result->m_data= data;
result->m_data_end= data + data_len; result->m_data_end= data + (data_len - (SRID_SIZE + WKB_HEADER_SIZE));
return result; return result;
} }
...@@ -170,13 +168,71 @@ Geometry *Geometry::create_from_wkt(Geometry_buffer *buffer, ...@@ -170,13 +168,71 @@ Geometry *Geometry::create_from_wkt(Geometry_buffer *buffer,
return NULL; return NULL;
if (init_stream) if (init_stream)
{ {
result->init_from_wkb(wkt->ptr(), wkt->length()); result->set_data_ptr(wkt->ptr(), wkt->length());
result->shift_wkb_header(); result->shift_wkb_header();
} }
return result; return result;
} }
static double wkb_get_double(const char *ptr, Geometry::wkbByteOrder bo)
{
double res;
if (bo != Geometry::wkb_xdr)
float8get(res, ptr);
else
{
char inv_array[8];
inv_array[0]= ptr[7];
inv_array[1]= ptr[6];
inv_array[2]= ptr[5];
inv_array[3]= ptr[4];
inv_array[4]= ptr[3];
inv_array[5]= ptr[2];
inv_array[6]= ptr[1];
inv_array[7]= ptr[0];
float8get(res, inv_array);
}
return res;
}
static uint32 wkb_get_uint(const char *ptr, Geometry::wkbByteOrder bo)
{
if (bo != Geometry::wkb_xdr)
return uint4korr(ptr);
/* else */
{
char inv_array[4];
inv_array[0]= ptr[3];
inv_array[1]= ptr[2];
inv_array[2]= ptr[1];
inv_array[3]= ptr[0];
return uint4korr(inv_array);
}
}
int Geometry::create_from_wkb(Geometry_buffer *buffer,
const char *wkb, uint32 len, String *res)
{
uint32 geom_type;
Geometry *geom;
if (len < WKB_HEADER_SIZE)
return 1;
geom_type= wkb_get_uint(wkb+1, (wkbByteOrder)wkb[0]);
if (!(geom= create_by_typeid(buffer, (int) geom_type)) ||
res->reserve(WKB_HEADER_SIZE, 512))
return 1;
res->q_append((char) wkb_ndr);
res->q_append(geom_type);
return geom->init_from_wkb(wkb+WKB_HEADER_SIZE, len - WKB_HEADER_SIZE,
(wkbByteOrder) wkb[0], res);
}
bool Geometry::envelope(String *result) const bool Geometry::envelope(String *result) const
{ {
MBR mbr; MBR mbr;
...@@ -346,6 +402,20 @@ bool Gis_point::init_from_wkt(Gis_read_stream *trs, String *wkb) ...@@ -346,6 +402,20 @@ bool Gis_point::init_from_wkt(Gis_read_stream *trs, String *wkb)
} }
uint Gis_point::init_from_wkb(const char *wkb, uint len,
wkbByteOrder bo, String *res)
{
double x, y;
if (len < POINT_DATA_SIZE || res->reserve(POINT_DATA_SIZE))
return 0;
x= wkb_get_double(wkb, bo);
y= wkb_get_double(wkb + SIZEOF_STORED_DOUBLE, bo);
res->q_append(x);
res->q_append(y);
return POINT_DATA_SIZE;
}
bool Gis_point::get_data_as_wkt(String *txt, const char **end) const bool Gis_point::get_data_as_wkt(String *txt, const char **end) const
{ {
double x, y; double x, y;
...@@ -415,6 +485,33 @@ bool Gis_line_string::init_from_wkt(Gis_read_stream *trs, String *wkb) ...@@ -415,6 +485,33 @@ bool Gis_line_string::init_from_wkt(Gis_read_stream *trs, String *wkb)
} }
uint Gis_line_string::init_from_wkb(const char *wkb, uint len,
wkbByteOrder bo, String *res)
{
uint32 n_points, proper_length;
const char *wkb_end;
Gis_point p;
if (len < 4)
return 0;
n_points= wkb_get_uint(wkb, bo);
proper_length= 4 + n_points * POINT_DATA_SIZE;
if (len < proper_length || res->reserve(proper_length))
return 0;
res->q_append(n_points);
wkb_end= wkb + proper_length;
for (wkb+= 4; wkb<wkb_end; wkb+= POINT_DATA_SIZE)
{
if (!p.init_from_wkb(wkb, POINT_DATA_SIZE, bo, res))
return 0;
}
return proper_length;
}
bool Gis_line_string::get_data_as_wkt(String *txt, const char **end) const bool Gis_line_string::get_data_as_wkt(String *txt, const char **end) const
{ {
uint32 n_points; uint32 n_points;
...@@ -594,7 +691,7 @@ bool Gis_polygon::init_from_wkt(Gis_read_stream *trs, String *wkb) ...@@ -594,7 +691,7 @@ bool Gis_polygon::init_from_wkt(Gis_read_stream *trs, String *wkb)
trs->check_next_symbol(')')) trs->check_next_symbol(')'))
return 1; return 1;
ls.init_from_wkb(wkb->ptr()+ls_pos, wkb->length()-ls_pos); ls.set_data_ptr(wkb->ptr() + ls_pos, wkb->length() - ls_pos);
if (ls.is_closed(&closed) || !closed) if (ls.is_closed(&closed) || !closed)
{ {
trs->set_error_msg("POLYGON's linear ring isn't closed"); trs->set_error_msg("POLYGON's linear ring isn't closed");
...@@ -609,6 +706,43 @@ bool Gis_polygon::init_from_wkt(Gis_read_stream *trs, String *wkb) ...@@ -609,6 +706,43 @@ bool Gis_polygon::init_from_wkt(Gis_read_stream *trs, String *wkb)
} }
uint Gis_polygon::init_from_wkb(const char *wkb, uint len, wkbByteOrder bo,
String *res)
{
uint32 n_linear_rings;
const char *wkb_orig= wkb;
if (len < 4)
return 0;
n_linear_rings= wkb_get_uint(wkb, bo);
if (res->reserve(4, 512))
return 0;
wkb+= 4;
len-= 4;
res->q_append(n_linear_rings);
while (n_linear_rings--)
{
Gis_line_string ls;
uint32 ls_pos= res->length();
int ls_len;
int closed;
if (!(ls_len= ls.init_from_wkb(wkb, len, bo, res)))
return 0;
ls.set_data_ptr(res->ptr() + ls_pos, res->length() - ls_pos);
if (ls.is_closed(&closed) || !closed)
return 0;
wkb+= ls_len;
}
return wkb - wkb_orig;
}
bool Gis_polygon::get_data_as_wkt(String *txt, const char **end) const bool Gis_polygon::get_data_as_wkt(String *txt, const char **end) const
{ {
uint32 n_linear_rings; uint32 n_linear_rings;
...@@ -897,6 +1031,36 @@ bool Gis_multi_point::init_from_wkt(Gis_read_stream *trs, String *wkb) ...@@ -897,6 +1031,36 @@ bool Gis_multi_point::init_from_wkt(Gis_read_stream *trs, String *wkb)
} }
uint Gis_multi_point::init_from_wkb(const char *wkb, uint len, wkbByteOrder bo,
String *res)
{
uint32 n_points;
uint proper_size;
Gis_point p;
const char *wkb_end;
if (len < 4)
return 0;
n_points= wkb_get_uint(wkb, bo);
proper_size= 4 + n_points * (WKB_HEADER_SIZE + POINT_DATA_SIZE);
if (len < proper_size || res->reserve(proper_size))
return 0;
res->q_append(n_points);
wkb_end= wkb + proper_size;
for (wkb+=4; wkb < wkb_end; wkb+= (WKB_HEADER_SIZE + POINT_DATA_SIZE))
{
res->q_append((char)wkb_ndr);
res->q_append((uint32)wkb_point);
if (!p.init_from_wkb(wkb + WKB_HEADER_SIZE,
POINT_DATA_SIZE, (wkbByteOrder) wkb[0], res))
return 0;
}
return proper_size;
}
bool Gis_multi_point::get_data_as_wkt(String *txt, const char **end) const bool Gis_multi_point::get_data_as_wkt(String *txt, const char **end) const
{ {
uint32 n_points; uint32 n_points;
...@@ -1006,6 +1170,42 @@ bool Gis_multi_line_string::init_from_wkt(Gis_read_stream *trs, String *wkb) ...@@ -1006,6 +1170,42 @@ bool Gis_multi_line_string::init_from_wkt(Gis_read_stream *trs, String *wkb)
} }
uint Gis_multi_line_string::init_from_wkb(const char *wkb, uint len,
wkbByteOrder bo, String *res)
{
uint32 n_line_strings;
const char *wkb_orig= wkb;
if (len < 4)
return 0;
n_line_strings= wkb_get_uint(wkb, bo);
if (res->reserve(4, 512))
return 0;
res->q_append(n_line_strings);
for (wkb+=4; n_line_strings; n_line_strings--)
{
Gis_line_string ls;
int ls_len;
if ((len < WKB_HEADER_SIZE) ||
res->reserve(WKB_HEADER_SIZE, 512))
return 0;
res->q_append((char) wkb_ndr);
res->q_append((uint32) wkb_linestring);
if (!(ls_len= ls.init_from_wkb(wkb + WKB_HEADER_SIZE, len,
(wkbByteOrder) wkb[0], res)))
return 0;
wkb+= (ls_len + WKB_HEADER_SIZE);
len-= (ls_len + WKB_HEADER_SIZE);
}
return wkb-wkb_orig;
}
bool Gis_multi_line_string::get_data_as_wkt(String *txt, bool Gis_multi_line_string::get_data_as_wkt(String *txt,
const char **end) const const char **end) const
{ {
...@@ -1111,7 +1311,7 @@ int Gis_multi_line_string::length(double *len) const ...@@ -1111,7 +1311,7 @@ int Gis_multi_line_string::length(double *len) const
double ls_len; double ls_len;
Gis_line_string ls; Gis_line_string ls;
data+= WKB_HEADER_SIZE; data+= WKB_HEADER_SIZE;
ls.init_from_wkb(data, (uint32) (m_data_end - data)); ls.set_data_ptr(data, (uint32) (m_data_end - data));
if (ls.length(&ls_len)) if (ls.length(&ls_len))
return 1; return 1;
*len+= ls_len; *len+= ls_len;
...@@ -1140,7 +1340,7 @@ int Gis_multi_line_string::is_closed(int *closed) const ...@@ -1140,7 +1340,7 @@ int Gis_multi_line_string::is_closed(int *closed) const
Gis_line_string ls; Gis_line_string ls;
if (no_data(data, 0)) if (no_data(data, 0))
return 1; return 1;
ls.init_from_wkb(data, (uint32) (m_data_end - data)); ls.set_data_ptr(data, (uint32) (m_data_end - data));
if (ls.is_closed(closed)) if (ls.is_closed(closed))
return 1; return 1;
if (!*closed) if (!*closed)
...@@ -1222,6 +1422,41 @@ bool Gis_multi_polygon::init_from_wkt(Gis_read_stream *trs, String *wkb) ...@@ -1222,6 +1422,41 @@ bool Gis_multi_polygon::init_from_wkt(Gis_read_stream *trs, String *wkb)
} }
uint Gis_multi_polygon::init_from_wkb(const char *wkb, uint len,
wkbByteOrder bo, String *res)
{
uint32 n_poly;
const char *wkb_orig= wkb;
if (len < 4)
return 0;
n_poly= wkb_get_uint(wkb, bo);
if (res->reserve(4, 512))
return 0;
res->q_append(n_poly);
for (wkb+=4; n_poly; n_poly--)
{
Gis_polygon p;
int p_len;
if (len < WKB_HEADER_SIZE ||
res->reserve(WKB_HEADER_SIZE, 512))
return 0;
res->q_append((char) wkb_ndr);
res->q_append((uint32) wkb_polygon);
if (!(p_len= p.init_from_wkb(wkb + WKB_HEADER_SIZE, len,
(wkbByteOrder) wkb[0], res)))
return 0;
wkb+= (p_len + WKB_HEADER_SIZE);
len-= (p_len + WKB_HEADER_SIZE);
}
return wkb-wkb_orig;
}
bool Gis_multi_polygon::get_data_as_wkt(String *txt, const char **end) const bool Gis_multi_polygon::get_data_as_wkt(String *txt, const char **end) const
{ {
uint32 n_polygons; uint32 n_polygons;
...@@ -1358,7 +1593,7 @@ int Gis_multi_polygon::area(double *ar, const char **end_of_data) const ...@@ -1358,7 +1593,7 @@ int Gis_multi_polygon::area(double *ar, const char **end_of_data) const
Gis_polygon p; Gis_polygon p;
data+= WKB_HEADER_SIZE; data+= WKB_HEADER_SIZE;
p.init_from_wkb(data, (uint32) (m_data_end - data)); p.set_data_ptr(data, (uint32) (m_data_end - data));
if (p.area(&p_area, &data)) if (p.area(&p_area, &data))
return 1; return 1;
result+= p_area; result+= p_area;
...@@ -1390,7 +1625,7 @@ int Gis_multi_polygon::centroid(String *result) const ...@@ -1390,7 +1625,7 @@ int Gis_multi_polygon::centroid(String *result) const
while (n_polygons--) while (n_polygons--)
{ {
data+= WKB_HEADER_SIZE; data+= WKB_HEADER_SIZE;
p.init_from_wkb(data, (uint32) (m_data_end - data)); p.set_data_ptr(data, (uint32) (m_data_end - data));
if (p.area(&cur_area, &data) || if (p.area(&cur_area, &data) ||
p.centroid_xy(&cur_cx, &cur_cy)) p.centroid_xy(&cur_cx, &cur_cy))
return 1; return 1;
...@@ -1444,7 +1679,7 @@ uint32 Gis_geometry_collection::get_data_size() const ...@@ -1444,7 +1679,7 @@ uint32 Gis_geometry_collection::get_data_size() const
if (!(geom= create_by_typeid(&buffer, wkb_type))) if (!(geom= create_by_typeid(&buffer, wkb_type)))
return GET_SIZE_ERROR; return GET_SIZE_ERROR;
geom->init_from_wkb(data, (uint) (m_data_end - data)); geom->set_data_ptr(data, (uint) (m_data_end - data));
if ((object_size= geom->get_data_size()) == GET_SIZE_ERROR) if ((object_size= geom->get_data_size()) == GET_SIZE_ERROR)
return GET_SIZE_ERROR; return GET_SIZE_ERROR;
data+= object_size; data+= object_size;
...@@ -1484,6 +1719,46 @@ bool Gis_geometry_collection::init_from_wkt(Gis_read_stream *trs, String *wkb) ...@@ -1484,6 +1719,46 @@ bool Gis_geometry_collection::init_from_wkt(Gis_read_stream *trs, String *wkb)
} }
uint Gis_geometry_collection::init_from_wkb(const char *wkb, uint len,
wkbByteOrder bo, String *res)
{
uint32 n_geom;
const char *wkb_orig= wkb;
if (len < 4)
return 0;
n_geom= wkb_get_uint(wkb, bo);
if (res->reserve(4, 512))
return 0;
res->q_append(n_geom);
for (wkb+=4; n_geom; n_geom--)
{
Geometry_buffer buffer;
Geometry *geom;
int g_len;
uint32 wkb_type;
if (len < WKB_HEADER_SIZE ||
res->reserve(WKB_HEADER_SIZE, 512))
return 0;
res->q_append((char) wkb_ndr);
wkb_type= wkb_get_uint(wkb+1, (wkbByteOrder) wkb[0]);
res->q_append(wkb_type);
if (!(geom= create_by_typeid(&buffer, wkb_type)) ||
!(g_len= geom->init_from_wkb(wkb + WKB_HEADER_SIZE, len,
(wkbByteOrder) wkb[0], res)))
return 0;
wkb+= (g_len + WKB_HEADER_SIZE);
len-= (g_len + WKB_HEADER_SIZE);
}
return wkb-wkb_orig;
}
bool Gis_geometry_collection::get_data_as_wkt(String *txt, bool Gis_geometry_collection::get_data_as_wkt(String *txt,
const char **end) const const char **end) const
{ {
...@@ -1508,7 +1783,7 @@ bool Gis_geometry_collection::get_data_as_wkt(String *txt, ...@@ -1508,7 +1783,7 @@ bool Gis_geometry_collection::get_data_as_wkt(String *txt,
if (!(geom= create_by_typeid(&buffer, wkb_type))) if (!(geom= create_by_typeid(&buffer, wkb_type)))
return 1; return 1;
geom->init_from_wkb(data, (uint) (m_data_end - data)); geom->set_data_ptr(data, (uint) (m_data_end - data));
if (geom->as_wkt(txt, &data)) if (geom->as_wkt(txt, &data))
return 1; return 1;
if (txt->append(",", 1, 512)) if (txt->append(",", 1, 512))
...@@ -1543,7 +1818,7 @@ bool Gis_geometry_collection::get_mbr(MBR *mbr, const char **end) const ...@@ -1543,7 +1818,7 @@ bool Gis_geometry_collection::get_mbr(MBR *mbr, const char **end) const
if (!(geom= create_by_typeid(&buffer, wkb_type))) if (!(geom= create_by_typeid(&buffer, wkb_type)))
return 1; return 1;
geom->init_from_wkb(data, (uint32) (m_data_end - data)); geom->set_data_ptr(data, (uint32) (m_data_end - data));
if (geom->get_mbr(mbr, &data)) if (geom->get_mbr(mbr, &data))
return 1; return 1;
} }
...@@ -1584,7 +1859,7 @@ int Gis_geometry_collection::geometry_n(uint32 num, String *result) const ...@@ -1584,7 +1859,7 @@ int Gis_geometry_collection::geometry_n(uint32 num, String *result) const
if (!(geom= create_by_typeid(&buffer, wkb_type))) if (!(geom= create_by_typeid(&buffer, wkb_type)))
return 1; return 1;
geom->init_from_wkb(data, (uint) (m_data_end - data)); geom->set_data_ptr(data, (uint) (m_data_end - data));
if ((length= geom->get_data_size()) == GET_SIZE_ERROR) if ((length= geom->get_data_size()) == GET_SIZE_ERROR)
return 1; return 1;
data+= length; data+= length;
...@@ -1637,7 +1912,7 @@ bool Gis_geometry_collection::dimension(uint32 *res_dim, const char **end) const ...@@ -1637,7 +1912,7 @@ bool Gis_geometry_collection::dimension(uint32 *res_dim, const char **end) const
data+= WKB_HEADER_SIZE; data+= WKB_HEADER_SIZE;
if (!(geom= create_by_typeid(&buffer, wkb_type))) if (!(geom= create_by_typeid(&buffer, wkb_type)))
return 1; return 1;
geom->init_from_wkb(data, (uint32) (m_data_end - data)); geom->set_data_ptr(data, (uint32) (m_data_end - data));
if (geom->dimension(&dim, &end_data)) if (geom->dimension(&dim, &end_data))
return 1; return 1;
set_if_bigger(*res_dim, dim); set_if_bigger(*res_dim, dim);
......
...@@ -207,6 +207,10 @@ public: ...@@ -207,6 +207,10 @@ public:
virtual const Class_info *get_class_info() const=0; virtual const Class_info *get_class_info() const=0;
virtual uint32 get_data_size() const=0; virtual uint32 get_data_size() const=0;
virtual bool init_from_wkt(Gis_read_stream *trs, String *wkb)=0; virtual bool init_from_wkt(Gis_read_stream *trs, String *wkb)=0;
/* returns the length of the wkb that was read */
virtual uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo,
String *res)=0;
virtual bool get_data_as_wkt(String *txt, const char **end) const=0; virtual bool get_data_as_wkt(String *txt, const char **end) const=0;
virtual bool get_mbr(MBR *mbr, const char **end) const=0; virtual bool get_mbr(MBR *mbr, const char **end) const=0;
virtual bool dimension(uint32 *dim, const char **end) const=0; virtual bool dimension(uint32 *dim, const char **end) const=0;
...@@ -236,11 +240,13 @@ public: ...@@ -236,11 +240,13 @@ public:
return my_reinterpret_cast(Geometry *)(buffer); return my_reinterpret_cast(Geometry *)(buffer);
} }
static Geometry *create_from_wkb(Geometry_buffer *buffer, static Geometry *construct(Geometry_buffer *buffer,
const char *data, uint32 data_len); const char *data, uint32 data_len);
static Geometry *create_from_wkt(Geometry_buffer *buffer, static Geometry *create_from_wkt(Geometry_buffer *buffer,
Gis_read_stream *trs, String *wkt, Gis_read_stream *trs, String *wkt,
bool init_stream=1); bool init_stream=1);
static int Geometry::create_from_wkb(Geometry_buffer *buffer,
const char *wkb, uint32 len, String *res);
int as_wkt(String *wkt, const char **end) int as_wkt(String *wkt, const char **end)
{ {
uint32 len= get_class_info()->m_name.length; uint32 len= get_class_info()->m_name.length;
...@@ -254,7 +260,7 @@ public: ...@@ -254,7 +260,7 @@ public:
return 0; return 0;
} }
inline void init_from_wkb(const char *data, uint32 data_len) inline void set_data_ptr(const char *data, uint32 data_len)
{ {
m_data= data; m_data= data;
m_data_end= data + data_len; m_data_end= data + data_len;
...@@ -298,6 +304,7 @@ class Gis_point: public Geometry ...@@ -298,6 +304,7 @@ class Gis_point: public Geometry
public: public:
uint32 get_data_size() const; uint32 get_data_size() const;
bool init_from_wkt(Gis_read_stream *trs, String *wkb); bool init_from_wkt(Gis_read_stream *trs, String *wkb);
uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res);
bool get_data_as_wkt(String *txt, const char **end) const; bool get_data_as_wkt(String *txt, const char **end) const;
bool get_mbr(MBR *mbr, const char **end) const; bool get_mbr(MBR *mbr, const char **end) const;
...@@ -344,6 +351,7 @@ class Gis_line_string: public Geometry ...@@ -344,6 +351,7 @@ class Gis_line_string: public Geometry
public: public:
uint32 get_data_size() const; uint32 get_data_size() const;
bool init_from_wkt(Gis_read_stream *trs, String *wkb); bool init_from_wkt(Gis_read_stream *trs, String *wkb);
uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res);
bool get_data_as_wkt(String *txt, const char **end) const; bool get_data_as_wkt(String *txt, const char **end) const;
bool get_mbr(MBR *mbr, const char **end) const; bool get_mbr(MBR *mbr, const char **end) const;
int length(double *len) const; int length(double *len) const;
...@@ -369,6 +377,7 @@ class Gis_polygon: public Geometry ...@@ -369,6 +377,7 @@ class Gis_polygon: public Geometry
public: public:
uint32 get_data_size() const; uint32 get_data_size() const;
bool init_from_wkt(Gis_read_stream *trs, String *wkb); bool init_from_wkt(Gis_read_stream *trs, String *wkb);
uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res);
bool get_data_as_wkt(String *txt, const char **end) const; bool get_data_as_wkt(String *txt, const char **end) const;
bool get_mbr(MBR *mbr, const char **end) const; bool get_mbr(MBR *mbr, const char **end) const;
int area(double *ar, const char **end) const; int area(double *ar, const char **end) const;
...@@ -394,6 +403,7 @@ class Gis_multi_point: public Geometry ...@@ -394,6 +403,7 @@ class Gis_multi_point: public Geometry
public: public:
uint32 get_data_size() const; uint32 get_data_size() const;
bool init_from_wkt(Gis_read_stream *trs, String *wkb); bool init_from_wkt(Gis_read_stream *trs, String *wkb);
uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res);
bool get_data_as_wkt(String *txt, const char **end) const; bool get_data_as_wkt(String *txt, const char **end) const;
bool get_mbr(MBR *mbr, const char **end) const; bool get_mbr(MBR *mbr, const char **end) const;
int num_geometries(uint32 *num) const; int num_geometries(uint32 *num) const;
...@@ -415,6 +425,7 @@ class Gis_multi_line_string: public Geometry ...@@ -415,6 +425,7 @@ class Gis_multi_line_string: public Geometry
public: public:
uint32 get_data_size() const; uint32 get_data_size() const;
bool init_from_wkt(Gis_read_stream *trs, String *wkb); bool init_from_wkt(Gis_read_stream *trs, String *wkb);
uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res);
bool get_data_as_wkt(String *txt, const char **end) const; bool get_data_as_wkt(String *txt, const char **end) const;
bool get_mbr(MBR *mbr, const char **end) const; bool get_mbr(MBR *mbr, const char **end) const;
int num_geometries(uint32 *num) const; int num_geometries(uint32 *num) const;
...@@ -438,6 +449,7 @@ class Gis_multi_polygon: public Geometry ...@@ -438,6 +449,7 @@ class Gis_multi_polygon: public Geometry
public: public:
uint32 get_data_size() const; uint32 get_data_size() const;
bool init_from_wkt(Gis_read_stream *trs, String *wkb); bool init_from_wkt(Gis_read_stream *trs, String *wkb);
uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res);
bool get_data_as_wkt(String *txt, const char **end) const; bool get_data_as_wkt(String *txt, const char **end) const;
bool get_mbr(MBR *mbr, const char **end) const; bool get_mbr(MBR *mbr, const char **end) const;
int num_geometries(uint32 *num) const; int num_geometries(uint32 *num) const;
...@@ -461,6 +473,7 @@ class Gis_geometry_collection: public Geometry ...@@ -461,6 +473,7 @@ class Gis_geometry_collection: public Geometry
public: public:
uint32 get_data_size() const; uint32 get_data_size() const;
bool init_from_wkt(Gis_read_stream *trs, String *wkb); bool init_from_wkt(Gis_read_stream *trs, String *wkb);
uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res);
bool get_data_as_wkt(String *txt, const char **end) const; bool get_data_as_wkt(String *txt, const char **end) const;
bool get_mbr(MBR *mbr, const char **end) const; bool get_mbr(MBR *mbr, const char **end) const;
int num_geometries(uint32 *num) const; int num_geometries(uint32 *num) const;
......
...@@ -33,7 +33,7 @@ sort_buffer_size = 2M ...@@ -33,7 +33,7 @@ sort_buffer_size = 2M
read_buffer_size = 2M read_buffer_size = 2M
read_rnd_buffer_size = 8M read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M myisam_sort_buffer_size = 64M
thread_cache = 8 thread_cache_size = 8
query_cache_size = 32M query_cache_size = 32M
# Try number of CPU's*2 for thread_concurrency # Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8 thread_concurrency = 8
......
...@@ -128,7 +128,7 @@ join_buffer_size = 8M ...@@ -128,7 +128,7 @@ join_buffer_size = 8M
# the amount of thread creations needed if you have a lot of new # the amount of thread creations needed if you have a lot of new
# connections. (Normally this doesn't give a notable performance # connections. (Normally this doesn't give a notable performance
# improvement if you have a good thread implementation.) # improvement if you have a good thread implementation.)
thread_cache = 8 thread_cache_size = 8
# This permits the application to give the threads system a hint for the # This permits the application to give the threads system a hint for the
# desired number of threads that should be run at the same time. This # desired number of threads that should be run at the same time. This
......
...@@ -33,7 +33,7 @@ sort_buffer_size = 1M ...@@ -33,7 +33,7 @@ sort_buffer_size = 1M
read_buffer_size = 1M read_buffer_size = 1M
read_rnd_buffer_size = 4M read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M myisam_sort_buffer_size = 64M
thread_cache = 8 thread_cache_size = 8
query_cache_size= 16M query_cache_size= 16M
# Try number of CPU's*2 for thread_concurrency # Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8 thread_concurrency = 8
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment