00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022
00023 #include <drizzled/plugin/function.h>
00024 #include <drizzled/function/math/int.h>
00025
00026 using namespace drizzled;
00027
00028 class CoercibilityFunction :public Item_int_func
00029 {
00030 public:
00031 CoercibilityFunction() :Item_int_func()
00032 {
00033 unsigned_flag= true;
00034 }
00035
00036 int64_t val_int();
00037
00038 const char *func_name() const
00039 {
00040 return "coercibility";
00041 }
00042
00043 void fix_length_and_dec()
00044 {
00045 max_length=10; maybe_null= 0;
00046 }
00047
00048 table_map not_null_tables() const
00049 {
00050 return 0;
00051 }
00052
00053 bool check_argument_count(int n)
00054 {
00055 return (n == 1);
00056 }
00057 };
00058
00059 int64_t CoercibilityFunction::val_int()
00060 {
00061 assert(fixed == 1);
00062 null_value= 0;
00063 return (int64_t) args[0]->collation.derivation;
00064 }
00065
00066 plugin::Create_function<CoercibilityFunction> *coercibility_function= NULL;
00067
00068 static int initialize(drizzled::module::Context &context)
00069 {
00070 coercibility_function= new plugin::Create_function<CoercibilityFunction>("coercibility");
00071 context.add(coercibility_function);
00072 return 0;
00073 }
00074
00075 DRIZZLE_DECLARE_PLUGIN
00076 {
00077 DRIZZLE_VERSION_ID,
00078 "coercibility_function",
00079 "1.0",
00080 "Andrew Hutchings",
00081 "COERCIBILITY()",
00082 PLUGIN_LICENSE_GPL,
00083 initialize,
00084 NULL,
00085 NULL
00086 }
00087 DRIZZLE_DECLARE_PLUGIN_END;