diff options
author | unknown <monty@mysql.com> | 2004-10-20 16:24:28 +0300 |
---|---|---|
committer | unknown <monty@mysql.com> | 2004-10-20 16:24:28 +0300 |
commit | 560d7bcdd0c80551b7844b3669be503113c91ddf (patch) | |
tree | f3f6e81dac72352598beb9c21f116d2ef7f9c3ef /libmysql | |
parent | 7bdb93aa7e8b2c4d003f68635af8e1cbe757f6e6 (diff) | |
parent | ec8779e95a46b3dfff492196ad004cb2716df3c3 (diff) | |
download | mariadb-git-560d7bcdd0c80551b7844b3669be503113c91ddf.tar.gz |
Merge with 4.0
BitKeeper/etc/logging_ok:
auto-union
Docs/Support/texi2html:
Auto merged
innobase/trx/trx0rec.c:
Auto merged
libmysql/libmysql.c:
Auto merged
myisam/myisampack.c:
Auto merged
mysql-test/t/innodb-lock.test:
Auto merged
mysys/thr_lock.c:
Auto merged
sql/ha_innodb.cc:
Auto merged
sql/lock.cc:
Auto merged
sql/sql_acl.cc:
Keep old code
Diffstat (limited to 'libmysql')
-rw-r--r-- | libmysql/libmysql.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index deb09c856ec..fb405a7b868 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1544,6 +1544,40 @@ void my_net_local_init(NET *net) } /* + This function is used to create HEX string that you + can use in a SQL statement in of the either ways: + INSERT INTO blob_column VALUES (0xAABBCC); (any MySQL version) + INSERT INTO blob_column VALUES (X'AABBCC'); (4.1 and higher) + + The string in "from" is encoded to a HEX string. + The result is placed in "to" and a terminating null byte is appended. + + The string pointed to by "from" must be "length" bytes long. + You must allocate the "to" buffer to be at least length*2+1 bytes long. + Each character needs two bytes, and you need room for the terminating + null byte. When mysql_hex_string() returns, the contents of "to" will + be a null-terminated string. The return value is the length of the + encoded string, not including the terminating null character. + + The return value does not contain any leading 0x or a leading X' and + trailing '. The caller must supply whichever of those is desired. +*/ + +ulong mysql_hex_string(char *to, const char *from, ulong length) +{ + char *to0= to; + const char *end; + + for (end= from + length; from < end; from++) + { + *to++= _dig_vec[((unsigned char) *from) >> 4]; + *to++= _dig_vec[((unsigned char) *from) & 0x0F]; + } + *to= '\0'; + return (ulong) (to-to0); +} + +/* Add escape characters to a string (blob?) to make it suitable for a insert to should at least have place for length*2+1 chars Returns the length of the to string |