summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <serg@serg.mysql.com>2002-12-05 21:38:27 +0100
committerunknown <serg@serg.mysql.com>2002-12-05 21:38:27 +0100
commita29ee10048e9bbe0f5251a36981b274ab72b8a25 (patch)
tree4301080c345c415ce2704ef85b2b693ebdafbfb5 /sql
parent9d14d104e6b30d66e9a849fd32e43480d201dac2 (diff)
downloadmariadb-git-a29ee10048e9bbe0f5251a36981b274ab72b8a25.tar.gz
current_user() to return priv_user
Diffstat (limited to 'sql')
-rw-r--r--sql/item.h4
-rw-r--r--sql/item_create.cc11
-rw-r--r--sql/item_create.h1
-rw-r--r--sql/lex.h2
4 files changed, 15 insertions, 3 deletions
diff --git a/sql/item.h b/sql/item.h
index ad68287a92c..05b906a66a6 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -267,6 +267,8 @@ public:
}
Item_string(const char *name_par,const char *str,uint length)
{
+ if (!length)
+ length=strlen(str);
str_value.set(str,length);
max_length=length;
name=(char*) name_par;
@@ -286,7 +288,7 @@ public:
String *const_string() { return &str_value; }
inline void append(char *str,uint length) { str_value.append(str,length); }
void print(String *str);
- unsigned int size_of() { return sizeof(*this);}
+ unsigned int size_of() { return sizeof(*this);}
};
diff --git a/sql/item_create.cc b/sql/item_create.cc
index c5f53f0d040..1f0bad8eda3 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -291,6 +291,15 @@ Item *create_func_pow(Item* a, Item *b)
return new Item_func_pow(a,b);
}
+Item *create_func_current_user()
+{
+ THD *thd=current_thd;
+ Item_string *res=new Item_string("CURRENT_USER()", thd->priv_user, 0);
+ res->append("@", 1);
+ res->append((char *)thd->host_or_ip, 0);
+ return res;
+}
+
Item *create_func_quarter(Item* a)
{
return new Item_func_quarter(a);
@@ -394,7 +403,7 @@ Item *create_func_ucase(Item* a)
Item *create_func_version(void)
{
- return new Item_string(NullS,server_version, (uint) strlen(server_version));
+ return new Item_string("VERSION()",server_version, 0);
}
Item *create_func_weekday(Item* a)
diff --git a/sql/item_create.h b/sql/item_create.h
index 28fbd61df8f..80ef57e436a 100644
--- a/sql/item_create.h
+++ b/sql/item_create.h
@@ -68,6 +68,7 @@ Item *create_func_period_add(Item* a, Item *b);
Item *create_func_period_diff(Item* a, Item *b);
Item *create_func_pi(void);
Item *create_func_pow(Item* a, Item *b);
+Item *create_func_current_user(void);
Item *create_func_quarter(Item* a);
Item *create_func_radians(Item *a);
Item *create_func_release_lock(Item* a);
diff --git a/sql/lex.h b/sql/lex.h
index 717e8a355ca..bf0abc323e1 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -398,7 +398,7 @@ static SYMBOL sql_functions[] = {
{ "CAST", SYM(CAST_SYM),0,0},
{ "CEIL", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ceiling)},
{ "CEILING", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ceiling)},
- { "CURRENT_USER", SYM(USER),0,0},
+ { "CURRENT_USER", SYM(FUNC_ARG0),0,CREATE_FUNC(create_func_current_user)},
{ "BIT_LENGTH", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_bit_length)},
{ "CHAR_LENGTH", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_char_length)},
{ "CHARACTER_LENGTH", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_char_length)},