aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/encode.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-08-04 16:08:37 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-08-04 16:08:37 +0000
commita2a8c7a662ec96537b6d1faba0770c516b921911 (patch)
tree3226541cb0deaba08693e1d7063c4e49fa74e570 /src/backend/utils/adt/encode.c
parentf192e4a5d0a041a5353d43fa10b6fe675a1c01fa (diff)
downloadpostgresql-a2a8c7a662ec96537b6d1faba0770c516b921911.tar.gz
postgresql-a2a8c7a662ec96537b6d1faba0770c516b921911.zip
Support hex-string input and output for type BYTEA.
Both hex format and the traditional "escape" format are automatically handled on input. The output format is selected by the new GUC variable bytea_output. As committed, bytea_output defaults to HEX, which is an *incompatible change*. We will keep it this way for awhile for testing purposes, but should consider whether to switch to the more backwards-compatible default of ESCAPE before 8.5 is released. Peter Eisentraut
Diffstat (limited to 'src/backend/utils/adt/encode.c')
-rw-r--r--src/backend/utils/adt/encode.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c
index 480b85cefcb..e581e3bc42d 100644
--- a/src/backend/utils/adt/encode.c
+++ b/src/backend/utils/adt/encode.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/encode.c,v 1.23 2009/01/01 17:23:49 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/encode.c,v 1.24 2009/08/04 16:08:36 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -109,7 +109,7 @@ binary_decode(PG_FUNCTION_ARGS)
* HEX
*/
-static const char *hextbl = "0123456789abcdef";
+static const char hextbl[] = "0123456789abcdef";
static const int8 hexlookup[128] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
@@ -122,7 +122,7 @@ static const int8 hexlookup[128] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
};
-static unsigned
+unsigned
hex_encode(const char *src, unsigned len, char *dst)
{
const char *end = src + len;
@@ -136,7 +136,7 @@ hex_encode(const char *src, unsigned len, char *dst)
return len * 2;
}
-static char
+static inline char
get_hex(char c)
{
int res = -1;
@@ -152,7 +152,7 @@ get_hex(char c)
return (char) res;
}
-static unsigned
+unsigned
hex_decode(const char *src, unsigned len, char *dst)
{
const char *s,