diff options
author | unknown <Sinisa@sinisa.nasamreza.org> | 2003-04-17 13:47:37 +0300 |
---|---|---|
committer | unknown <Sinisa@sinisa.nasamreza.org> | 2003-04-17 13:47:37 +0300 |
commit | fa741bbc0316e9bdaeb1c3af416ed3dcf41b021f (patch) | |
tree | b92a81772aa5e2d58017601c1b3f16f2ab6ddfb1 /sql/item.cc | |
parent | 781133546cfcb4d237ec8d31aa33109fd4f57d84 (diff) | |
parent | 430a3291efed1c85626f41506bf978f0d8d34cbb (diff) | |
download | mariadb-git-fa741bbc0316e9bdaeb1c3af416ed3dcf41b021f.tar.gz |
Merge sinisa@bk-internal.mysql.com:/home/bk/mysql-4.1
into sinisa.nasamreza.org:/mnt/work/mysql-4.1
sql/item.cc:
Auto merged
sql/item_strfunc.cc:
Auto merged
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/sql/item.cc b/sql/item.cc index a029219c366..60d52e776fd 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -542,6 +542,77 @@ String *Item_param::val_str(String* str) return (String*) &str_value; } } + +/* + Return Param item values in string format, for generating the dynamic + query used in update/binary logs +*/ + +String *Item_param::query_val_str(String* str) +{ + switch (item_result_type) { + case INT_RESULT: + case REAL_RESULT: + return val_str(str); + break; + default: + str->set("'", 1, default_charset()); + + if (!item_is_time) + { + str->append(str_value); + const char *from= str->ptr(); + uint32 length= 1; + + // Escape misc cases + char *to= (char *)from, *end= (char *)to+str->length(); + for (to++; to != end ; length++, to++) + { + switch(*to) { + case '\'': + case '"': + case '\r': + case '\n': + case '\\': // TODO: Add remaining .. + str->replace(length,0,"\\",1); + to++; end++; length++; + break; + default: + break; + } + } + } + else + { + char buff[25]; + + switch (ltime.time_type) { + case TIMESTAMP_NONE: + break; + case TIMESTAMP_DATE: + sprintf(buff, "%04d-%02d-%02d", + ltime.year,ltime.month,ltime.day); + str->append(buff, 10); + break; + case TIMESTAMP_FULL: + sprintf(buff, "%04d-%02d-%02d %02d:%02d:%02d", + ltime.year,ltime.month,ltime.day, + ltime.hour,ltime.minute,ltime.second); + str->append(buff, 19); + break; + case TIMESTAMP_TIME: + { + sprintf(buff, "%02d:%02d:%02d", + ltime.hour,ltime.minute,ltime.second); + str->append(buff, 8); + break; + } + } + } + str->append("'"); + } + return str; +} /* End of Item_param related */ |