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