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 <plugin/session_dictionary/dictionary.h>
00024 #include <drizzled/user_var_entry.h>
00025
00026 #define LARGEST_USER_VARIABLE_NAME 128
00027
00028 namespace session_dictionary {
00029
00030 Variables::Variables() :
00031 drizzled::plugin::TableFunction("DATA_DICTIONARY", "USER_DEFINED_VARIABLES")
00032 {
00033 add_field("VARIABLE_NAME", drizzled::plugin::TableFunction::STRING, LARGEST_USER_VARIABLE_NAME, false);
00034 add_field("VARIABLE_VALUE", drizzled::plugin::TableFunction::STRING, LARGEST_USER_VARIABLE_NAME, true);
00035 }
00036
00037 Variables::Generator::Generator(drizzled::Field **arg) :
00038 drizzled::plugin::TableFunction::Generator(arg),
00039 user_vars(getSession().getUserVariables()),
00040 iter(user_vars.begin())
00041 {
00042 }
00043
00044 Variables::Generator::~Generator()
00045 {
00046 }
00047
00048 bool Variables::Generator::populate()
00049 {
00050 while (iter != user_vars.end())
00051 {
00052 char buff[LARGEST_USER_VARIABLE_NAME];
00053 drizzled::String tmp(buff, sizeof(buff), drizzled::system_charset_info);
00054
00055 bool null_value;
00056 uint32_t decimals= 4;
00057 iter->second->val_str(&null_value, &tmp, decimals);
00058
00059
00060
00061 push(iter->first);
00062
00063
00064 if (null_value)
00065 push();
00066 else
00067 push(tmp.c_str());
00068
00069 iter++;
00070
00071 return true;
00072 }
00073
00074 return false;
00075 }
00076
00077 }