00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021 #include <drizzled/function/math/int.h>
00022 #include <drizzled/plugin/function.h>
00023 #include <drizzled/session.h>
00024
00025 using namespace std;
00026 using namespace drizzled;
00027
00028 class ConnectionIdFunction :public Item_int_func
00029 {
00030 int64_t value;
00031 public:
00032 ConnectionIdFunction() :Item_int_func() {}
00033
00034 int64_t val_int()
00035 {
00036 assert(fixed == true);
00037 return value;
00038 }
00039
00040 const char *func_name() const
00041 {
00042 return "connection_id";
00043 }
00044
00045 void fix_length_and_dec()
00046 {
00047 Item_int_func::fix_length_and_dec();
00048 max_length= 10;
00049 }
00050
00051 bool fix_fields(Session *session, Item **ref)
00052 {
00053 if (Item_int_func::fix_fields(session, ref))
00054 {
00055 return true;
00056 }
00057
00058 value= session->variables.pseudo_thread_id;
00059 return false;
00060 }
00061
00062 bool check_argument_count(int n)
00063 {
00064 return (n == 0);
00065 }
00066 };
00067
00068
00069 plugin::Create_function<ConnectionIdFunction> *connection_idudf= NULL;
00070
00071 static int initialize(module::Context &context)
00072 {
00073 connection_idudf=
00074 new plugin::Create_function<ConnectionIdFunction>("connection_id");
00075 context.add(connection_idudf);
00076 return 0;
00077 }
00078
00079 DRIZZLE_DECLARE_PLUGIN
00080 {
00081 DRIZZLE_VERSION_ID,
00082 "connection_id",
00083 "1.0",
00084 "Devananda van der Veen",
00085 "Return the current connection_id",
00086 PLUGIN_LICENSE_GPL,
00087 initialize,
00088 NULL,
00089 NULL
00090 }
00091 DRIZZLE_DECLARE_PLUGIN_END;