summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2003-10-31 22:14:49 +0200
committerunknown <bell@sanja.is.com.ua>2003-10-31 22:14:49 +0200
commit5337ffde112ebc041f4048fcc3b152ca6b4d5cec (patch)
tree2c6fd809f0c5f377f0c9be63a16c38f0853a56cf /sql/item.cc
parentab9fb4ea752731bb04cfbd844902ae34c63123ab (diff)
parented49917e8c9ea60797772ca8db638a3ae8580c3e (diff)
downloadmariadb-git-5337ffde112ebc041f4048fcc3b152ca6b4d5cec.tar.gz
merge
mysql-test/r/fulltext.result: Auto merged mysql-test/r/func_group.result: Auto merged mysql-test/t/fulltext.test: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_timefunc.cc: Auto merged sql/mysql_priv.h: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_yacc.yy: Auto merged
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc141
1 files changed, 123 insertions, 18 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 7c7cad7c290..0fbf3ae587b 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -87,6 +87,19 @@ Item::Item(THD *c_thd, Item &item):
thd->free_list= this;
}
+
+void Item::print_item_w_name(String *str)
+{
+ print(str);
+ if (name)
+ {
+ str->append(" AS `", 5);
+ str->append(name);
+ str->append('`');
+ }
+}
+
+
// Constructor used by Item_field & Item_ref (see Item comment)
Item_ident::Item_ident(THD *thd, Item_ident &item):
Item(thd, item),
@@ -422,6 +435,7 @@ bool Item_field::eq(const Item *item, bool binary_cmp) const
db_name))))));
}
+
table_map Item_field::used_tables() const
{
if (field->table->const_table)
@@ -429,6 +443,7 @@ table_map Item_field::used_tables() const
return (depended_from ? OUTER_REF_TABLE_BIT : field->table->map);
}
+
Item *Item_field::get_tmp_table_item(THD *thd)
{
Item_field *new_item= new Item_field(thd, *this);
@@ -437,6 +452,7 @@ Item *Item_field::get_tmp_table_item(THD *thd)
return new_item;
}
+
String *Item_int::val_str(String *str)
{
str->set(value, default_charset());
@@ -445,28 +461,24 @@ String *Item_int::val_str(String *str)
void Item_int::print(String *str)
{
- if (!name)
- {
- str_value.set(value, default_charset());
- name=str_value.c_ptr();
- }
- str->append(name);
+ // latin1 is good enough for numbers
+ str_value.set(value, &my_charset_latin1);
+ str->append(str_value);
}
+
String *Item_uint::val_str(String *str)
{
str->set((ulonglong) value, default_charset());
return str;
}
+
void Item_uint::print(String *str)
{
- if (!name)
- {
- str_value.set((ulonglong) value, default_charset());
- name=str_value.c_ptr();
- }
- str->append(name);
+ // latin1 is good enough for numbers
+ str_value.set((ulonglong) value, default_charset());
+ str->append(str_value);
}
@@ -476,10 +488,46 @@ String *Item_real::val_str(String *str)
return str;
}
+
void Item_string::print(String *str)
{
+ str->append('_');
+ str->append(collation.collation->csname);
str->append('\'');
- str->append(full_name());
+ char *st= (char*)str_value.ptr(), *end= st+str_value.length();
+ for(; st < end; st++)
+ {
+ uchar c= *st;
+ switch (c)
+ {
+ case '\\':
+ str->append("\\\\", 2);
+ break;
+ case '\0':
+ str->append("\\0", 2);
+ break;
+ case '\'':
+ str->append("\\'", 2);
+ break;
+ case '\n':
+ str->append("\\n", 2);
+ break;
+ case '\r':
+ str->append("\\r", 2);
+ break;
+ case '\t':
+ str->append("\\t", 2);
+ break;
+ case '\b':
+ str->append("\\b", 2);
+ break;
+ case 26: //Ctrl-Z
+ str->append("\\z", 2);
+ break;
+ default:
+ str->append(c);
+ }
+ }
str->append('\'');
}
@@ -700,7 +748,7 @@ String *Item_param::query_val_str(String* str)
make_datetime(str, &ltime, is_time_only, 0,
tmp_format->format, tmp_format->format_length, 0);
}
- str->append("'");
+ str->append('\'');
}
return str;
}
@@ -777,7 +825,7 @@ static void mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current,
// store pointer on SELECT_LEX from wich item is dependent
item->depended_from= last;
current->mark_as_dependent(last);
- if (thd->lex.describe)
+ if (thd->lex.describe & DESCRIBE_EXTENDED)
{
char warn_buff[MYSQL_ERRMSG_SIZE];
sprintf(warn_buff, ER(ER_WARN_FIELD_RESOLVED),
@@ -1533,6 +1581,34 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
}
+void Item_ref::print(String *str)
+{
+ if (ref && *ref)
+ (*ref)->print(str);
+ else
+ Item_ident::print(str);
+}
+
+
+void Item_ref_null_helper::print(String *str)
+{
+ str->append("<ref_null_helper>(", 18);
+ if (ref && *ref)
+ (*ref)->print(str);
+ else
+ str->append('?');
+ str->append(')');
+}
+
+
+void Item_null_helper::print(String *str)
+{
+ str->append("<null_helper>(", 14);
+ store->print(str);
+ str->append(')');
+}
+
+
bool Item_default_value::eq(const Item *item, bool binary_cmp) const
{
return item->type() == DEFAULT_VALUE_ITEM &&
@@ -1574,10 +1650,10 @@ void Item_default_value::print(String *str)
{
if (!arg)
{
- str->append("DEFAULT");
+ str->append("default", 7);
return;
}
- str->append("DEFAULT(");
+ str->append("default(", 8);
arg->print(str);
str->append(')');
}
@@ -1630,7 +1706,7 @@ bool Item_insert_value::fix_fields(THD *thd, struct st_table_list *table_list, I
void Item_insert_value::print(String *str)
{
- str->append("VALUE(");
+ str->append("values(", 7);
arg->print(str);
str->append(')');
}
@@ -1754,6 +1830,34 @@ Item_cache* Item_cache::get_cache(Item_result type)
}
}
+
+void Item_cache::print(String *str)
+{
+ str->append("<cache>(", 8);
+ if (example)
+ example->print(str);
+ else
+ Item::print(str);
+ str->append(')');
+}
+
+
+void Item_cache_int::store(Item *item)
+{
+ value= item->val_int_result();
+ null_value= item->null_value;
+ collation.set(item->collation);
+}
+
+
+void Item_cache_real::store(Item *item)
+{
+ value= item->val_result();
+ null_value= item->null_value;
+ collation.set(item->collation);
+}
+
+
void Item_cache_str::store(Item *item)
{
value_buff.set(buffer, sizeof(buffer), item->collation.collation);
@@ -1804,6 +1908,7 @@ bool Item_cache_row::allocate(uint num)
bool Item_cache_row::setup(Item * item)
{
+ example= item;
if (!values && allocate(item->cols()))
return 1;
for (uint i= 0; i < item_count; i++)