Subject | Why can't CHAR and VARCHAR store binary data (ASCII 0)? |
---|---|
Author | David Garamond |
Post date | 2003-11-26T10:01:41Z |
Why can't CHAR and VARCHAR store binary data (ASCII 0)?
Is it because internally the data are represented by null-terminated
strings? If yes, why? CHAR always has fixed length and VARCHAR has 2
extra bytes to store string length.
I currently need to store 128-bit MD5 hashes (sort of like UUID/GUID) as
primary keys. In MySQL, I can use "CHAR(16) BINARY NOT NULL" for this
data since the CHAR & VARCHAR are "binary safe", but in Firebird I have
to use "CHAR(18) NOT NULL" (I am encoding to base192, where the charset
are from ASCII 64 to ASCII 255).
I can also use CHAR(24) (storing as base64) or CHAR(32) (storing as
hexdigits), but they are longer.
--
dave
Is it because internally the data are represented by null-terminated
strings? If yes, why? CHAR always has fixed length and VARCHAR has 2
extra bytes to store string length.
I currently need to store 128-bit MD5 hashes (sort of like UUID/GUID) as
primary keys. In MySQL, I can use "CHAR(16) BINARY NOT NULL" for this
data since the CHAR & VARCHAR are "binary safe", but in Firebird I have
to use "CHAR(18) NOT NULL" (I am encoding to base192, where the charset
are from ASCII 64 to ASCII 255).
I can also use CHAR(24) (storing as base64) or CHAR(32) (storing as
hexdigits), but they are longer.
--
dave