30 #include "sql_class.h"
34 #include "item_inetfunc.h"
184 bool use_explicit_name,
List<Item> *item_list);
297 static Create_func_area s_singleton;
300 Create_func_area() {}
301 virtual ~Create_func_area() {}
312 static Create_func_as_wkb s_singleton;
315 Create_func_as_wkb() {}
316 virtual ~Create_func_as_wkb() {}
327 static Create_func_as_wkt s_singleton;
330 Create_func_as_wkt() {}
331 virtual ~Create_func_as_wkt() {}
433 static Create_func_centroid s_singleton;
436 Create_func_centroid() {}
437 virtual ~Create_func_centroid() {}
526 static Create_func_mbr_contains s_singleton;
529 Create_func_mbr_contains() {}
530 virtual ~Create_func_mbr_contains() {}
539 static Create_func_contains s_singleton;
542 Create_func_contains() {}
543 virtual ~Create_func_contains() {}
619 static Create_func_crosses s_singleton;
622 Create_func_crosses() {}
623 virtual ~Create_func_crosses() {}
764 static Create_func_dimension s_singleton;
767 Create_func_dimension() {}
768 virtual ~Create_func_dimension() {}
779 static Create_func_mbr_disjoint s_singleton;
782 Create_func_mbr_disjoint() {}
783 virtual ~Create_func_mbr_disjoint() {}
792 static Create_func_disjoint s_singleton;
795 Create_func_disjoint() {}
796 virtual ~Create_func_disjoint() {}
805 static Create_func_distance s_singleton;
808 Create_func_distance() {}
809 virtual ~Create_func_distance() {}
859 static Create_func_endpoint s_singleton;
862 Create_func_endpoint() {}
863 virtual ~Create_func_endpoint() {}
874 static Create_func_envelope s_singleton;
877 Create_func_envelope() {}
878 virtual ~Create_func_envelope() {}
889 static Create_func_mbr_equals s_singleton;
892 Create_func_mbr_equals() {}
893 virtual ~Create_func_mbr_equals() {}
902 static Create_func_equals s_singleton;
905 Create_func_equals() {}
906 virtual ~Create_func_equals() {}
943 static Create_func_exteriorring s_singleton;
946 Create_func_exteriorring() {}
947 virtual ~Create_func_exteriorring() {}
1049 static Create_func_geometry_from_text s_singleton;
1052 Create_func_geometry_from_text() {}
1053 virtual ~Create_func_geometry_from_text() {}
1064 static Create_func_geometry_from_wkb s_singleton;
1067 Create_func_geometry_from_wkb() {}
1068 virtual ~Create_func_geometry_from_wkb() {}
1079 static Create_func_geometry_type s_singleton;
1082 Create_func_geometry_type() {}
1083 virtual ~Create_func_geometry_type() {}
1094 static Create_func_geometryn s_singleton;
1097 Create_func_geometryn() {}
1098 virtual ~Create_func_geometryn() {}
1116 #if defined(HAVE_SPATIAL) && !defined(DBUG_OFF)
1122 static Create_func_gis_debug s_singleton;
1125 Create_func_gis_debug() {}
1126 virtual ~Create_func_gis_debug() {}
1137 static Create_func_glength s_singleton;
1140 Create_func_glength() {}
1141 virtual ~Create_func_glength() {}
1334 static Create_func_interiorringn s_singleton;
1337 Create_func_interiorringn() {}
1338 virtual ~Create_func_interiorringn() {}
1349 static Create_func_mbr_intersects s_singleton;
1352 Create_func_mbr_intersects() {}
1353 virtual ~Create_func_mbr_intersects() {}
1362 static Create_func_intersects s_singleton;
1365 Create_func_intersects() {}
1366 virtual ~Create_func_intersects() {}
1375 static Create_func_intersection s_singleton;
1378 Create_func_intersection() {}
1379 virtual ~Create_func_intersection() {}
1388 static Create_func_difference s_singleton;
1391 Create_func_difference() {}
1392 virtual ~Create_func_difference() {}
1401 static Create_func_union s_singleton;
1404 Create_func_union() {}
1405 virtual ~Create_func_union() {}
1414 static Create_func_symdifference s_singleton;
1417 Create_func_symdifference() {}
1418 virtual ~Create_func_symdifference() {}
1427 static Create_func_buffer s_singleton;
1430 Create_func_buffer() {}
1431 virtual ~Create_func_buffer() {}
1468 static Create_func_isclosed s_singleton;
1471 Create_func_isclosed() {}
1472 virtual ~Create_func_isclosed() {}
1483 static Create_func_isempty s_singleton;
1486 Create_func_isempty() {}
1487 virtual ~Create_func_isempty() {}
1511 static Create_func_issimple s_singleton;
1514 Create_func_issimple() {}
1515 virtual ~Create_func_issimple() {}
1838 static Create_func_numgeometries s_singleton;
1841 Create_func_numgeometries() {}
1842 virtual ~Create_func_numgeometries() {}
1853 static Create_func_numinteriorring s_singleton;
1856 Create_func_numinteriorring() {}
1857 virtual ~Create_func_numinteriorring() {}
1868 static Create_func_numpoints s_singleton;
1871 Create_func_numpoints() {}
1872 virtual ~Create_func_numpoints() {}
1909 static Create_func_mbr_overlaps s_singleton;
1912 Create_func_mbr_overlaps() {}
1913 virtual ~Create_func_mbr_overlaps() {}
1922 static Create_func_overlaps s_singleton;
1925 Create_func_overlaps() {}
1926 virtual ~Create_func_overlaps() {}
1976 static Create_func_pointn s_singleton;
1979 Create_func_pointn() {}
1980 virtual ~Create_func_pointn() {}
2225 static Create_func_srid s_singleton;
2228 Create_func_srid() {}
2229 virtual ~Create_func_srid() {}
2240 static Create_func_startpoint s_singleton;
2243 Create_func_startpoint() {}
2244 virtual ~Create_func_startpoint() {}
2397 static Create_func_touches s_singleton;
2400 Create_func_touches() {}
2401 virtual ~Create_func_touches() {}
2555 static Create_func_mbr_within s_singleton;
2558 Create_func_mbr_within() {}
2559 virtual ~Create_func_mbr_within() {}
2568 static Create_func_within s_singleton;
2571 Create_func_within() {}
2572 virtual ~Create_func_within() {}
2583 static Create_func_x s_singleton;
2587 virtual ~Create_func_x() {}
2624 static Create_func_y s_singleton;
2628 virtual ~Create_func_y() {}
2659 static bool has_named_parameters(
List<Item> *params)
2665 while ((param= it++))
2675 #ifndef HAVE_SPATIAL
2684 my_error(ER_FEATURE_DISABLED, MYF(0),
2685 sym_group_geom.name, sym_group_geom.needed_define);
2696 if (! thd->db && ! thd->lex->sphead)
2709 my_error(ER_SP_DOES_NOT_EXIST, MYF(0),
2710 "FUNCTION", name.str);
2714 if (thd->lex->copy_db_to(&db.str, &db.length))
2717 return create(thd, db, name,
false, item_list);
2722 Create_udf_func Create_udf_func::s_singleton;
2727 udf_func *udf= find_udf(name.str, name.length);
2729 return create(thd, udf, item_list);
2739 DBUG_ENTER(
"Create_udf_func::create");
2740 if (item_list != NULL)
2741 arg_count= item_list->elements;
2743 thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_UDF);
2745 DBUG_ASSERT( (udf->type == UDFTYPE_FUNCTION)
2746 || (udf->type == UDFTYPE_AGGREGATE));
2748 switch(udf->returns) {
2751 if (udf->type == UDFTYPE_FUNCTION)
2769 if (udf->type == UDFTYPE_FUNCTION)
2787 if (udf->type == UDFTYPE_FUNCTION)
2803 case DECIMAL_RESULT:
2805 if (udf->type == UDFTYPE_FUNCTION)
2823 my_error(ER_NOT_SUPPORTED_YET, MYF(0),
"UDF return type");
2826 thd->lex->safe_to_cache_query= 0;
2836 bool use_explicit_name,
List<Item> *item_list)
2843 if (has_named_parameters(item_list))
2854 my_error(ER_WRONG_PARAMETERS_TO_STORED_FCT, MYF(0), name.str);
2858 if (item_list != NULL)
2859 arg_count= item_list->elements;
2861 qname=
new (thd->mem_root)
sp_name(db, name, use_explicit_name);
2863 sp_add_used_routine(lex, thd, qname, SP_TYPE_FUNCTION);
2866 func=
new (thd->mem_root)
Item_func_sp(lex->current_context(), qname,
2869 func=
new (thd->mem_root)
Item_func_sp(lex->current_context(), qname);
2871 lex->safe_to_cache_query= 0;
2879 if (has_named_parameters(item_list))
2881 my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
2894 if (item_list != NULL)
2895 arg_count= item_list->elements;
2899 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2913 arg_count= item_list->elements;
2917 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2921 Item *param_1= item_list->pop();
2925 my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
2929 return create(thd, param_1);
2939 arg_count= item_list->elements;
2943 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2947 Item *param_1= item_list->pop();
2948 Item *param_2= item_list->pop();
2953 my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
2957 return create(thd, param_1, param_2);
2967 arg_count= item_list->elements;
2971 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
2975 Item *param_1= item_list->pop();
2976 Item *param_2= item_list->pop();
2977 Item *param_3= item_list->pop();
2983 my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
2987 return create(thd, param_1, param_2, param_3);
3037 Create_func_area Create_func_area::s_singleton;
3042 return new (thd->mem_root) Item_func_area(arg1);
3048 Create_func_as_wkb Create_func_as_wkb::s_singleton;
3053 return new (thd->mem_root) Item_func_as_wkb(arg1);
3059 Create_func_as_wkt Create_func_as_wkt::s_singleton;
3064 return new (thd->mem_root) Item_func_as_wkt(arg1);
3087 if (item_list != NULL)
3088 arg_count= item_list->elements;
3090 switch (arg_count) {
3093 Item *param_1= item_list->pop();
3099 Item *param_1= item_list->pop();
3100 Item *param_2= item_list->pop();
3106 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3120 thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
3164 Create_func_centroid Create_func_centroid::s_singleton;
3169 return new (thd->mem_root) Item_func_centroid(arg1);
3200 if (item_list != NULL)
3201 arg_count= item_list->elements;
3205 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3221 if (item_list != NULL)
3222 arg_count= item_list->elements;
3227 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3249 thd->lex->safe_to_cache_query= 0;
3255 Create_func_mbr_contains Create_func_mbr_contains::s_singleton;
3260 return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
3261 Item_func::SP_CONTAINS_FUNC);
3265 Create_func_contains Create_func_contains::s_singleton;
3270 return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
3271 Item_func::SP_CONTAINS_FUNC);
3322 Create_func_crosses Create_func_crosses::s_singleton;
3327 return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
3328 Item_func::SP_CROSSES_FUNC);
3418 if (item_list != NULL)
3419 arg_count= item_list->elements;
3421 switch (arg_count) {
3424 Item *param_1= item_list->pop();
3430 Item *param_1= item_list->pop();
3431 Item *param_2= item_list->pop();
3437 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3455 if (item_list != NULL)
3456 arg_count= item_list->elements;
3458 switch (arg_count) {
3461 Item *param_1= item_list->pop();
3467 Item *param_1= item_list->pop();
3468 Item *param_2= item_list->pop();
3474 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3484 Create_func_dimension Create_func_dimension::s_singleton;
3489 return new (thd->mem_root) Item_func_dimension(arg1);
3495 Create_func_mbr_disjoint Create_func_mbr_disjoint::s_singleton;
3500 return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
3501 Item_func::SP_DISJOINT_FUNC);
3505 Create_func_disjoint Create_func_disjoint::s_singleton;
3510 return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
3511 Item_func::SP_DISJOINT_FUNC);
3515 Create_func_distance Create_func_distance::s_singleton;
3520 return new (thd->mem_root) Item_func_distance(arg1, arg2);
3533 if (item_list != NULL)
3534 arg_count= item_list->elements;
3538 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3564 if (item_list != NULL)
3565 arg_count= item_list->elements;
3567 switch (arg_count) {
3570 Item *param_1= item_list->pop();
3572 thd->lex->uncacheable(UNCACHEABLE_RAND);
3577 Item *param_1= item_list->pop();
3578 Item *param_2= item_list->pop();
3584 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3594 Create_func_endpoint Create_func_endpoint::s_singleton;
3599 return new (thd->mem_root) Item_func_spatial_decomp(arg1,
3600 Item_func::SP_ENDPOINT);
3606 Create_func_envelope Create_func_envelope::s_singleton;
3611 return new (thd->mem_root) Item_func_envelope(arg1);
3617 Create_func_mbr_equals Create_func_mbr_equals::s_singleton;
3622 return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
3623 Item_func::SP_EQUALS_FUNC);
3627 Create_func_equals Create_func_equals::s_singleton;
3632 return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
3633 Item_func::SP_EQUALS_FUNC);
3656 if (item_list != NULL)
3657 arg_count= item_list->elements;
3659 switch (arg_count) {
3662 Item *param_1= item_list->pop();
3663 Item *param_2= item_list->pop();
3664 Item *param_3= item_list->pop();
3670 Item *param_1= item_list->pop();
3671 Item *param_2= item_list->pop();
3672 Item *param_3= item_list->pop();
3673 Item *param_4= item_list->pop();
3680 Item *param_1= item_list->pop();
3681 Item *param_2= item_list->pop();
3682 Item *param_3= item_list->pop();
3683 Item *param_4= item_list->pop();
3684 Item *param_5= item_list->pop();
3691 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3701 Create_func_exteriorring Create_func_exteriorring::s_singleton;
3706 return new (thd->mem_root) Item_func_spatial_decomp(arg1,
3707 Item_func::SP_EXTERIORRING);
3720 if (item_list != NULL)
3721 arg_count= item_list->elements;
3725 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3756 DBUG_ENTER(
"Create_func_found_rows::create");
3757 thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
3758 thd->lex->safe_to_cache_query= 0;
3790 if (item_list != NULL)
3791 arg_count= item_list->elements;
3793 switch (arg_count) {
3796 Item *param_1= item_list->pop();
3802 Item *param_1= item_list->pop();
3803 Item *param_2= item_list->pop();
3810 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3820 Create_func_geometry_from_text Create_func_geometry_from_text::s_singleton;
3829 if (item_list != NULL)
3830 arg_count= item_list->elements;
3832 switch (arg_count) {
3835 Item *param_1= item_list->pop();
3836 func=
new (thd->mem_root) Item_func_geometry_from_text(param_1);
3837 thd->lex->uncacheable(UNCACHEABLE_RAND);
3842 Item *param_1= item_list->pop();
3843 Item *param_2= item_list->pop();
3844 func=
new (thd->mem_root) Item_func_geometry_from_text(param_1, param_2);
3849 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3860 Create_func_geometry_from_wkb Create_func_geometry_from_wkb::s_singleton;
3869 if (item_list != NULL)
3870 arg_count= item_list->elements;
3872 switch (arg_count) {
3875 Item *param_1= item_list->pop();
3876 func=
new (thd->mem_root) Item_func_geometry_from_wkb(param_1);
3877 thd->lex->uncacheable(UNCACHEABLE_RAND);
3882 Item *param_1= item_list->pop();
3883 Item *param_2= item_list->pop();
3884 func=
new (thd->mem_root) Item_func_geometry_from_wkb(param_1, param_2);
3889 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
3900 Create_func_geometry_type Create_func_geometry_type::s_singleton;
3905 return new (thd->mem_root) Item_func_geometry_type(arg1);
3911 Create_func_geometryn Create_func_geometryn::s_singleton;
3916 return new (thd->mem_root) Item_func_spatial_decomp_n(arg1, arg2,
3917 Item_func::SP_GEOMETRYN);
3927 thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
3928 thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
3933 #if defined(HAVE_SPATIAL) && !defined(DBUG_OFF)
3934 Create_func_gis_debug Create_func_gis_debug::s_singleton;
3939 return new (thd->mem_root) Item_func_gis_debug(arg1);
3945 Create_func_glength Create_func_glength::s_singleton;
3950 return new (thd->mem_root) Item_func_glength(arg1);
3963 if (item_list != NULL)
3964 arg_count= item_list->elements;
3968 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4094 Create_func_interiorringn Create_func_interiorringn::s_singleton;
4099 return new (thd->mem_root) Item_func_spatial_decomp_n(arg1, arg2,
4100 Item_func::SP_INTERIORRINGN);
4106 Create_func_mbr_intersects Create_func_mbr_intersects::s_singleton;
4111 return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
4112 Item_func::SP_INTERSECTS_FUNC);
4116 Create_func_intersects Create_func_intersects::s_singleton;
4121 return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
4122 Item_func::SP_INTERSECTS_FUNC);
4126 Create_func_intersection Create_func_intersection::s_singleton;
4131 return new (thd->mem_root) Item_func_spatial_operation(arg1, arg2,
4132 Gcalc_function::op_intersection);
4136 Create_func_difference Create_func_difference::s_singleton;
4141 return new (thd->mem_root) Item_func_spatial_operation(arg1, arg2,
4142 Gcalc_function::op_difference);
4146 Create_func_union Create_func_union::s_singleton;
4151 return new (thd->mem_root) Item_func_spatial_operation(arg1, arg2,
4152 Gcalc_function::op_union);
4156 Create_func_symdifference Create_func_symdifference::s_singleton;
4161 return new (thd->mem_root) Item_func_spatial_operation(arg1, arg2,
4162 Gcalc_function::op_symdifference);
4166 Create_func_buffer Create_func_buffer::s_singleton;
4171 return new (thd->mem_root) Item_func_buffer(arg1, arg2);
4181 thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
4182 thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
4192 thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
4193 thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
4199 Create_func_isclosed Create_func_isclosed::s_singleton;
4204 return new (thd->mem_root) Item_func_isclosed(arg1);
4210 Create_func_isempty Create_func_isempty::s_singleton;
4215 return new (thd->mem_root) Item_func_isempty(arg1);
4230 Create_func_issimple Create_func_issimple::s_singleton;
4235 return new (thd->mem_root) Item_func_issimple(arg1);
4258 if (item_list != NULL)
4259 arg_count= item_list->elements;
4261 switch (arg_count) {
4265 thd->lex->safe_to_cache_query= 0;
4270 Item *param_1= item_list->pop();
4272 thd->lex->safe_to_cache_query= 0;
4277 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4303 if (item_list != NULL)
4304 arg_count= item_list->elements;
4308 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4359 DBUG_ENTER(
"Create_func_load_file::create");
4360 thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
4361 thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
4375 if (item_list != NULL)
4376 arg_count= item_list->elements;
4378 switch (arg_count) {
4381 Item *param_1= item_list->pop();
4382 Item *param_2= item_list->pop();
4389 Item *param_1= item_list->pop();
4390 Item *param_2= item_list->pop();
4391 Item *param_3= item_list->pop();
4398 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4416 if (item_list != NULL)
4417 arg_count= item_list->elements;
4419 switch (arg_count) {
4422 Item *param_1= item_list->pop();
4428 Item *param_1= item_list->pop();
4429 Item *param_2= item_list->pop();
4435 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4506 if (item_list != NULL)
4507 arg_count= item_list->elements;
4511 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4515 Item *param_1= item_list->pop();
4530 thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
4532 if (item_list != NULL)
4533 arg_count= item_list->elements;
4535 switch (arg_count) {
4538 Item *param_1= item_list->pop();
4539 Item *param_2= item_list->pop();
4541 thd->lex->safe_to_cache_query= 0;
4546 Item *param_1= item_list->pop();
4547 Item *param_2= item_list->pop();
4548 Item *param_3= item_list->pop();
4550 thd->lex->safe_to_cache_query= 0;
4555 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4573 thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
4575 if (item_list != NULL)
4576 arg_count= item_list->elements;
4578 switch (arg_count) {
4581 Item *param_1= item_list->pop();
4583 thd->lex->safe_to_cache_query= 0;
4588 Item *param_1= item_list->pop();
4589 Item *param_2= item_list->pop();
4591 thd->lex->safe_to_cache_query= 0;
4596 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4641 Create_func_numgeometries Create_func_numgeometries::s_singleton;
4646 return new (thd->mem_root) Item_func_numgeometries(arg1);
4652 Create_func_numinteriorring Create_func_numinteriorring::s_singleton;
4657 return new (thd->mem_root) Item_func_numinteriorring(arg1);
4663 Create_func_numpoints Create_func_numpoints::s_singleton;
4668 return new (thd->mem_root) Item_func_numpoints(arg1);
4694 Create_func_mbr_overlaps Create_func_mbr_overlaps::s_singleton;
4699 return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
4700 Item_func::SP_OVERLAPS_FUNC);
4704 Create_func_overlaps Create_func_overlaps::s_singleton;
4709 return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
4710 Item_func::SP_OVERLAPS_FUNC);
4744 Create_func_pointn Create_func_pointn::s_singleton;
4749 return new (thd->mem_root) Item_func_spatial_decomp_n(arg1, arg2,
4750 Item_func::SP_POINTN);
4792 if (item_list != NULL)
4793 arg_count= item_list->elements;
4803 thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
4805 switch (arg_count) {
4809 thd->lex->uncacheable(UNCACHEABLE_RAND);
4814 Item *param_1= item_list->pop();
4816 thd->lex->uncacheable(UNCACHEABLE_RAND);
4821 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4835 thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
4836 thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
4859 if (item_list != NULL)
4860 arg_count= item_list->elements;
4862 switch (arg_count) {
4865 Item *param_1= item_list->pop();
4872 Item *param_1= item_list->pop();
4873 Item *param_2= item_list->pop();
4879 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
4956 thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
4957 thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
4990 Create_func_srid Create_func_srid::s_singleton;
4995 return new (thd->mem_root) Item_func_srid(arg1);
5001 Create_func_startpoint Create_func_startpoint::s_singleton;
5006 return new (thd->mem_root) Item_func_spatial_decomp(arg1,
5007 Item_func::SP_STARTPOINT);
5112 Create_func_touches Create_func_touches::s_singleton;
5117 return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
5118 Item_func::SP_TOUCHES_FUNC);
5168 if (item_list != NULL)
5169 arg_count= item_list->elements;
5171 switch (arg_count) {
5175 thd->lex->safe_to_cache_query= 0;
5180 Item *param_1= item_list->pop();
5186 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
5200 DBUG_ENTER(
"Create_func_uuid::create");
5201 thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
5202 thd->lex->safe_to_cache_query= 0;
5212 DBUG_ENTER(
"Create_func_uuid_short::create");
5213 thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
5214 thd->lex->safe_to_cache_query= 0;
5220 Create_func_validate_password_strength::s_singleton;
5234 thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
5237 (uint) strlen(server_version),
5238 system_charset_info,
5239 DERIVATION_SYSCONST);
5257 Item *i1=
new (thd->mem_root)
Item_int(NAME_STRING(
"0"), 3, 1);
5263 Create_func_mbr_within Create_func_mbr_within::s_singleton;
5268 return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2,
5269 Item_func::SP_WITHIN_FUNC);
5273 Create_func_within Create_func_within::s_singleton;
5278 return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
5279 Item_func::SP_WITHIN_FUNC);
5285 Create_func_x Create_func_x::s_singleton;
5290 return new (thd->mem_root) Item_func_x(arg1);
5314 Create_func_y Create_func_y::s_singleton;
5319 return new (thd->mem_root) Item_func_y(arg1);
5333 if (item_list != NULL)
5334 arg_count= item_list->elements;
5336 switch (arg_count) {
5339 Item *param_1= item_list->pop();
5346 Item *param_1= item_list->pop();
5347 Item *param_2= item_list->pop();
5353 my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
5368 #define BUILDER(F) & F::s_singleton
5371 #define GEOM_BUILDER(F) & F::s_singleton
5373 #define GEOM_BUILDER(F) & Create_func_no_geom::s_singleton
5394 { { C_STRING_WITH_LEN(
"AREA") }, GEOM_BUILDER(Create_func_area)},
5395 { { C_STRING_WITH_LEN(
"ASBINARY") }, GEOM_BUILDER(Create_func_as_wkb)},
5397 { { C_STRING_WITH_LEN(
"ASTEXT") }, GEOM_BUILDER(Create_func_as_wkt)},
5398 { { C_STRING_WITH_LEN(
"ASWKB") }, GEOM_BUILDER(Create_func_as_wkb)},
5399 { { C_STRING_WITH_LEN(
"ASWKT") }, GEOM_BUILDER(Create_func_as_wkt)},
5405 { { C_STRING_WITH_LEN(
"BUFFER") }, GEOM_BUILDER(Create_func_buffer)},
5409 { { C_STRING_WITH_LEN(
"CENTROID") }, GEOM_BUILDER(Create_func_centroid)},
5422 { { C_STRING_WITH_LEN(
"CROSSES") }, GEOM_BUILDER(Create_func_crosses)},
5433 { { C_STRING_WITH_LEN(
"DIMENSION") }, GEOM_BUILDER(Create_func_dimension)},
5434 { { C_STRING_WITH_LEN(
"DISJOINT") }, GEOM_BUILDER(Create_func_mbr_disjoint)},
5438 { { C_STRING_WITH_LEN(
"ENDPOINT") }, GEOM_BUILDER(Create_func_endpoint)},
5439 { { C_STRING_WITH_LEN(
"ENVELOPE") }, GEOM_BUILDER(Create_func_envelope)},
5440 { { C_STRING_WITH_LEN(
"EQUALS") }, GEOM_BUILDER(Create_func_mbr_equals)},
5443 { { C_STRING_WITH_LEN(
"EXTERIORRING") }, GEOM_BUILDER(Create_func_exteriorring)},
5452 { { C_STRING_WITH_LEN(
"GEOMCOLLFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5453 { { C_STRING_WITH_LEN(
"GEOMCOLLFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5454 { { C_STRING_WITH_LEN(
"GEOMETRYCOLLECTIONFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5455 { { C_STRING_WITH_LEN(
"GEOMETRYCOLLECTIONFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5456 { { C_STRING_WITH_LEN(
"GEOMETRYFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5457 { { C_STRING_WITH_LEN(
"GEOMETRYFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5458 { { C_STRING_WITH_LEN(
"GEOMETRYN") }, GEOM_BUILDER(Create_func_geometryn)},
5459 { { C_STRING_WITH_LEN(
"GEOMETRYTYPE") }, GEOM_BUILDER(Create_func_geometry_type)},
5460 { { C_STRING_WITH_LEN(
"GEOMFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5461 { { C_STRING_WITH_LEN(
"GEOMFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5463 { { C_STRING_WITH_LEN(
"GLENGTH") }, GEOM_BUILDER(Create_func_glength)},
5478 { { C_STRING_WITH_LEN(
"INTERIORRINGN") }, GEOM_BUILDER(Create_func_interiorringn)},
5479 { { C_STRING_WITH_LEN(
"INTERSECTS") }, GEOM_BUILDER(Create_func_mbr_intersects)},
5480 { { C_STRING_WITH_LEN(
"ISCLOSED") }, GEOM_BUILDER(Create_func_isclosed)},
5481 { { C_STRING_WITH_LEN(
"ISEMPTY") }, GEOM_BUILDER(Create_func_isempty)},
5483 { { C_STRING_WITH_LEN(
"ISSIMPLE") }, GEOM_BUILDER(Create_func_issimple)},
5495 { { C_STRING_WITH_LEN(
"LINEFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5496 { { C_STRING_WITH_LEN(
"LINEFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5497 { { C_STRING_WITH_LEN(
"LINESTRINGFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5498 { { C_STRING_WITH_LEN(
"LINESTRINGFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5512 { { C_STRING_WITH_LEN(
"MBRCONTAINS") }, GEOM_BUILDER(Create_func_mbr_contains)},
5513 { { C_STRING_WITH_LEN(
"MBRDISJOINT") }, GEOM_BUILDER(Create_func_mbr_disjoint)},
5514 { { C_STRING_WITH_LEN(
"MBREQUAL") }, GEOM_BUILDER(Create_func_mbr_equals)},
5515 { { C_STRING_WITH_LEN(
"MBRINTERSECTS") }, GEOM_BUILDER(Create_func_mbr_intersects)},
5516 { { C_STRING_WITH_LEN(
"MBROVERLAPS") }, GEOM_BUILDER(Create_func_mbr_overlaps)},
5517 { { C_STRING_WITH_LEN(
"MBRTOUCHES") }, GEOM_BUILDER(Create_func_touches)},
5518 { { C_STRING_WITH_LEN(
"MBRWITHIN") }, GEOM_BUILDER(Create_func_mbr_within)},
5520 { { C_STRING_WITH_LEN(
"MLINEFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5521 { { C_STRING_WITH_LEN(
"MLINEFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5523 { { C_STRING_WITH_LEN(
"MPOINTFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5524 { { C_STRING_WITH_LEN(
"MPOINTFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5525 { { C_STRING_WITH_LEN(
"MPOLYFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5526 { { C_STRING_WITH_LEN(
"MPOLYFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5527 { { C_STRING_WITH_LEN(
"MULTILINESTRINGFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5528 { { C_STRING_WITH_LEN(
"MULTILINESTRINGFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5529 { { C_STRING_WITH_LEN(
"MULTIPOINTFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5530 { { C_STRING_WITH_LEN(
"MULTIPOINTFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5531 { { C_STRING_WITH_LEN(
"MULTIPOLYGONFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5532 { { C_STRING_WITH_LEN(
"MULTIPOLYGONFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5535 { { C_STRING_WITH_LEN(
"NUMGEOMETRIES") }, GEOM_BUILDER(Create_func_numgeometries)},
5536 { { C_STRING_WITH_LEN(
"NUMINTERIORRINGS") }, GEOM_BUILDER(Create_func_numinteriorring)},
5537 { { C_STRING_WITH_LEN(
"NUMPOINTS") }, GEOM_BUILDER(Create_func_numpoints)},
5541 { { C_STRING_WITH_LEN(
"OVERLAPS") }, GEOM_BUILDER(Create_func_mbr_overlaps)},
5545 { { C_STRING_WITH_LEN(
"POINTFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5546 { { C_STRING_WITH_LEN(
"POINTFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5547 { { C_STRING_WITH_LEN(
"POINTN") }, GEOM_BUILDER(Create_func_pointn)},
5548 { { C_STRING_WITH_LEN(
"POLYFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5549 { { C_STRING_WITH_LEN(
"POLYFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5550 { { C_STRING_WITH_LEN(
"POLYGONFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5551 { { C_STRING_WITH_LEN(
"POLYGONFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5573 { { C_STRING_WITH_LEN(
"SRID") }, GEOM_BUILDER(Create_func_srid)},
5574 { { C_STRING_WITH_LEN(
"STARTPOINT") }, GEOM_BUILDER(Create_func_startpoint)},
5577 { { C_STRING_WITH_LEN(
"ST_AREA") }, GEOM_BUILDER(Create_func_area)},
5578 { { C_STRING_WITH_LEN(
"ST_ASBINARY") }, GEOM_BUILDER(Create_func_as_wkb)},
5579 { { C_STRING_WITH_LEN(
"ST_ASTEXT") }, GEOM_BUILDER(Create_func_as_wkt)},
5580 { { C_STRING_WITH_LEN(
"ST_ASWKB") }, GEOM_BUILDER(Create_func_as_wkb)},
5581 { { C_STRING_WITH_LEN(
"ST_ASWKT") }, GEOM_BUILDER(Create_func_as_wkt)},
5582 { { C_STRING_WITH_LEN(
"ST_BUFFER") }, GEOM_BUILDER(Create_func_buffer)},
5583 { { C_STRING_WITH_LEN(
"ST_CENTROID") }, GEOM_BUILDER(Create_func_centroid)},
5584 { { C_STRING_WITH_LEN(
"ST_CONTAINS") }, GEOM_BUILDER(Create_func_contains)},
5585 { { C_STRING_WITH_LEN(
"ST_CROSSES") }, GEOM_BUILDER(Create_func_crosses)},
5586 { { C_STRING_WITH_LEN(
"ST_DIFFERENCE") }, GEOM_BUILDER(Create_func_difference)},
5587 { { C_STRING_WITH_LEN(
"ST_DIMENSION") }, GEOM_BUILDER(Create_func_dimension)},
5588 { { C_STRING_WITH_LEN(
"ST_DISJOINT") }, GEOM_BUILDER(Create_func_disjoint)},
5589 { { C_STRING_WITH_LEN(
"ST_DISTANCE") }, GEOM_BUILDER(Create_func_distance)},
5590 { { C_STRING_WITH_LEN(
"ST_ENDPOINT") }, GEOM_BUILDER(Create_func_endpoint)},
5591 { { C_STRING_WITH_LEN(
"ST_ENVELOPE") }, GEOM_BUILDER(Create_func_envelope)},
5592 { { C_STRING_WITH_LEN(
"ST_EQUALS") }, GEOM_BUILDER(Create_func_mbr_equals)},
5593 { { C_STRING_WITH_LEN(
"ST_EXTERIORRING") }, GEOM_BUILDER(Create_func_exteriorring)},
5594 { { C_STRING_WITH_LEN(
"ST_GEOMCOLLFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5595 { { C_STRING_WITH_LEN(
"ST_GEOMCOLLFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5596 { { C_STRING_WITH_LEN(
"ST_GEOMETRYCOLLECTIONFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5597 { { C_STRING_WITH_LEN(
"ST_GEOMETRYCOLLECTIONFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5598 { { C_STRING_WITH_LEN(
"ST_GEOMETRYFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5599 { { C_STRING_WITH_LEN(
"ST_GEOMETRYFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5600 { { C_STRING_WITH_LEN(
"ST_GEOMETRYN") }, GEOM_BUILDER(Create_func_geometryn)},
5601 { { C_STRING_WITH_LEN(
"ST_GEOMETRYTYPE") }, GEOM_BUILDER(Create_func_geometry_type)},
5602 { { C_STRING_WITH_LEN(
"ST_GEOMFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5603 { { C_STRING_WITH_LEN(
"ST_GEOMFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5605 { { C_STRING_WITH_LEN(
"ST_GIS_DEBUG") }, GEOM_BUILDER(Create_func_gis_debug)},
5607 { { C_STRING_WITH_LEN(
"ST_EQUALS") }, GEOM_BUILDER(Create_func_equals)},
5608 { { C_STRING_WITH_LEN(
"ST_INTERIORRINGN") }, GEOM_BUILDER(Create_func_interiorringn)},
5609 { { C_STRING_WITH_LEN(
"ST_INTERSECTS") }, GEOM_BUILDER(Create_func_intersects)},
5610 { { C_STRING_WITH_LEN(
"ST_INTERSECTION") }, GEOM_BUILDER(Create_func_intersection)},
5611 { { C_STRING_WITH_LEN(
"ST_ISCLOSED") }, GEOM_BUILDER(Create_func_isclosed)},
5612 { { C_STRING_WITH_LEN(
"ST_ISEMPTY") }, GEOM_BUILDER(Create_func_isempty)},
5613 { { C_STRING_WITH_LEN(
"ST_ISSIMPLE") }, GEOM_BUILDER(Create_func_issimple)},
5614 { { C_STRING_WITH_LEN(
"ST_LENGTH") }, GEOM_BUILDER(Create_func_glength)},
5615 { { C_STRING_WITH_LEN(
"ST_LINEFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5616 { { C_STRING_WITH_LEN(
"ST_LINEFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5617 { { C_STRING_WITH_LEN(
"ST_LINESTRINGFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5618 { { C_STRING_WITH_LEN(
"ST_LINESTRINGFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5619 { { C_STRING_WITH_LEN(
"ST_NUMGEOMETRIES") }, GEOM_BUILDER(Create_func_numgeometries)},
5620 { { C_STRING_WITH_LEN(
"ST_NUMINTERIORRINGS") }, GEOM_BUILDER(Create_func_numinteriorring)},
5621 { { C_STRING_WITH_LEN(
"ST_NUMPOINTS") }, GEOM_BUILDER(Create_func_numpoints)},
5622 { { C_STRING_WITH_LEN(
"ST_OVERLAPS") }, GEOM_BUILDER(Create_func_overlaps)},
5623 { { C_STRING_WITH_LEN(
"ST_POINTFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5624 { { C_STRING_WITH_LEN(
"ST_POINTFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5625 { { C_STRING_WITH_LEN(
"ST_POINTN") }, GEOM_BUILDER(Create_func_pointn)},
5626 { { C_STRING_WITH_LEN(
"ST_POLYFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5627 { { C_STRING_WITH_LEN(
"ST_POLYFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5628 { { C_STRING_WITH_LEN(
"ST_POLYGONFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)},
5629 { { C_STRING_WITH_LEN(
"ST_POLYGONFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)},
5630 { { C_STRING_WITH_LEN(
"ST_SRID") }, GEOM_BUILDER(Create_func_srid)},
5631 { { C_STRING_WITH_LEN(
"ST_STARTPOINT") }, GEOM_BUILDER(Create_func_startpoint)},
5632 { { C_STRING_WITH_LEN(
"ST_SYMDIFFERENCE") }, GEOM_BUILDER(Create_func_symdifference)},
5633 { { C_STRING_WITH_LEN(
"ST_TOUCHES") }, GEOM_BUILDER(Create_func_touches)},
5634 { { C_STRING_WITH_LEN(
"ST_UNION") }, GEOM_BUILDER(Create_func_union)},
5635 { { C_STRING_WITH_LEN(
"ST_WITHIN") }, GEOM_BUILDER(Create_func_within)},
5636 { { C_STRING_WITH_LEN(
"ST_X") }, GEOM_BUILDER(Create_func_x)},
5637 { { C_STRING_WITH_LEN(
"ST_Y") }, GEOM_BUILDER(Create_func_y)},
5644 { { C_STRING_WITH_LEN(
"TOUCHES") }, GEOM_BUILDER(Create_func_touches)},
5661 { { C_STRING_WITH_LEN(
"WITHIN") }, GEOM_BUILDER(Create_func_mbr_within)},
5662 { { C_STRING_WITH_LEN(
"X") }, GEOM_BUILDER(Create_func_x)},
5663 { { C_STRING_WITH_LEN(
"Y") }, GEOM_BUILDER(Create_func_y)},
5669 static HASH native_functions_hash;
5672 get_native_fct_hash_key(
const uchar *buff,
size_t *length,
5676 *length= func->name.length;
5677 return (uchar*) func->name.str;
5686 int item_create_init()
5690 DBUG_ENTER(
"item_create_init");
5692 if (my_hash_init(& native_functions_hash,
5693 system_charset_info,
5694 array_elements(func_array),
5697 (my_hash_get_key) get_native_fct_hash_key,
5702 for (func= func_array; func->builder != NULL; func++)
5704 if (my_hash_insert(& native_functions_hash, (uchar*) func))
5709 for (uint
i=0 ;
i < native_functions_hash.records ;
i++)
5712 DBUG_PRINT(
"info", (
"native function: %s length: %u",
5713 func->name.str, (uint) func->name.length));
5726 void item_create_cleanup()
5728 DBUG_ENTER(
"item_create_cleanup");
5729 my_hash_free(& native_functions_hash);
5746 builder= func->builder;
5755 return & Create_sp_func::s_singleton;
5761 const char *c_len,
const char *c_dec,
5764 Item *UNINIT_VAR(res);
5766 switch (cast_type) {
5767 case ITEM_CAST_BINARY:
5770 case ITEM_CAST_SIGNED_INT:
5773 case ITEM_CAST_UNSIGNED_INT:
5776 case ITEM_CAST_DATE:
5779 case ITEM_CAST_TIME:
5780 case ITEM_CAST_DATETIME:
5782 uint dec= c_dec ? strtoul(c_dec, NULL, 10) : 0;
5783 if (dec > DATETIME_MAX_DECIMALS)
5785 my_error(ER_TOO_BIG_PRECISION, MYF(0),
5786 (
int) dec,
"CAST", DATETIME_MAX_DECIMALS);
5789 res= (cast_type == ITEM_CAST_TIME) ?
5794 case ITEM_CAST_DECIMAL:
5803 decoded_size= strtoul(c_len, NULL, 10);
5806 my_error(ER_TOO_BIG_PRECISION, MYF(0), INT_MAX, a->item_name.
ptr(),
5817 decoded_size= strtoul(c_dec, NULL, 10);
5818 if ((errno != 0) || (decoded_size > UINT_MAX))
5820 my_error(ER_TOO_BIG_SCALE, MYF(0), INT_MAX, a->item_name.
ptr(),
5821 static_cast<ulong
>(DECIMAL_MAX_SCALE));
5826 my_decimal_trim(&len, &dec);
5829 my_error(ER_M_BIGGER_THAN_D, MYF(0),
"");
5834 my_error(ER_TOO_BIG_PRECISION, MYF(0), static_cast<int>(len), a->item_name.
ptr(),
5838 if (dec > DECIMAL_MAX_SCALE)
5840 my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->item_name.
ptr(),
5841 static_cast<ulong
>(DECIMAL_MAX_SCALE));
5847 case ITEM_CAST_CHAR:
5851 (cs ? cs : thd->variables.collation_connection);
5856 decoded_size= strtoul(c_len, NULL, 10);
5857 if ((errno != 0) || (decoded_size > MAX_FIELD_BLOBLENGTH))
5859 my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0),
"cast as char", MAX_FIELD_BLOBLENGTH);
5862 len= (int) decoded_size;
5889 const char *str, uint length,
5891 enum_field_types
type,
bool send_error)
5896 ulonglong
flags= TIME_FUZZY_DATE | thd->datetime_flags();
5900 case MYSQL_TYPE_DATE:
5901 case MYSQL_TYPE_NEWDATE:
5902 if (!str_to_datetime(cs, str, length, <ime, flags, &status) &&
5903 ltime.time_type == MYSQL_TIMESTAMP_DATE && !status.warnings)
5906 case MYSQL_TYPE_DATETIME:
5907 if (!str_to_datetime(cs, str, length, <ime, flags, &status) &&
5908 ltime.time_type == MYSQL_TIMESTAMP_DATETIME && !status.warnings)
5910 status.fractional_digits);
5912 case MYSQL_TYPE_TIME:
5913 if (!str_to_time(cs, str, length, <ime, 0, &status) &&
5914 ltime.time_type == MYSQL_TIMESTAMP_TIME && !status.warnings)
5916 status.fractional_digits);
5927 const char *typestr=
5928 (type == MYSQL_TYPE_DATE) ?
"DATE" :
5929 (type == MYSQL_TYPE_TIME) ?
"TIME" :
"DATETIME";
5930 ErrConvString err(str, length, thd->variables.character_set_client);
5931 my_error(ER_WRONG_VALUE, MYF(0), typestr, err.ptr());