diff options
author | unknown <ram@mysql.r18.ru> | 2003-04-03 15:13:14 +0500 |
---|---|---|
committer | unknown <ram@mysql.r18.ru> | 2003-04-03 15:13:14 +0500 |
commit | 7835ff508331e46f9983912c2d1ddffde42c2685 (patch) | |
tree | 3e563294225fa9f9c646d386809ffd3e66999c9f /sql | |
parent | 1e8cc909de55b33b7a73ebfa7186598c1a7dbba3 (diff) | |
download | mariadb-git-7835ff508331e46f9983912c2d1ddffde42c2685.tar.gz |
AsWKB() function has been added.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_create.cc | 5 | ||||
-rw-r--r-- | sql/item_create.h | 1 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 21 | ||||
-rw-r--r-- | sql/item_strfunc.h | 9 | ||||
-rw-r--r-- | sql/lex.h | 1 |
5 files changed, 37 insertions, 0 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc index 3bc6fa47e83..b9179a84c12 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -491,6 +491,11 @@ Item *create_func_as_text(Item *a) return new Item_func_as_text(a); } +Item *create_func_as_wkb(Item *a) +{ + return new Item_func_as_wkb(a); +} + Item *create_func_srid(Item *a) { return new Item_func_srid(a); diff --git a/sql/item_create.h b/sql/item_create.h index 0e2295b6d4f..f1f9c4673d8 100644 --- a/sql/item_create.h +++ b/sql/item_create.h @@ -105,6 +105,7 @@ Item *create_func_quote(Item* a); Item *create_func_geometry_from_text(Item *a); Item *create_func_as_text(Item *a); +Item *create_func_as_wkb(Item *a); Item *create_func_srid(Item *a); Item *create_func_startpoint(Item *a); Item *create_func_endpoint(Item *a); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 5b2706e3eef..31ae5a3d437 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2585,6 +2585,27 @@ void Item_func_as_text::fix_length_and_dec() max_length=MAX_BLOB_WIDTH; } +String *Item_func_as_wkb::val_str(String *str) +{ + String arg_val; + String *swkb= args[0]->val_str(&arg_val); + Geometry geom; + + if ((null_value= (args[0]->null_value || + geom.create_from_wkb(swkb->ptr() + SRID_SIZE, + swkb->length() - SRID_SIZE)))) + return 0; + + str->copy(swkb->ptr() + SRID_SIZE, swkb->length() - SRID_SIZE, + &my_charset_bin); + return str; +} + +void Item_func_as_wkb::fix_length_and_dec() +{ + max_length= MAX_BLOB_WIDTH; +} + String *Item_func_geometry_type::val_str(String *str) { String *swkb= args[0]->val_str(str); diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index e403b970fe1..6c5dbe49915 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -665,6 +665,15 @@ public: void fix_length_and_dec(); }; +class Item_func_as_wkb :public Item_str_func +{ +public: + Item_func_as_wkb(Item *a) :Item_str_func(a) {} + const char *func_name() const { return "aswkb"; } + String *val_str(String *); + void fix_length_and_dec(); +}; + class Item_func_geometry_type :public Item_str_func { public: diff --git a/sql/lex.h b/sql/lex.h index aab530251b8..98a802f5c4a 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -429,6 +429,7 @@ static SYMBOL sql_functions[] = { { "AREA", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_area)}, { "ASIN", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_asin)}, { "ASTEXT", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_as_text)}, + { "ASWKB", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_as_wkb)}, { "ATAN", SYM(ATAN),0,0}, { "ATAN2", SYM(ATAN),0,0}, { "BENCHMARK", SYM(BENCHMARK_SYM),0,0}, |