Hi all, This is my first patch for PostgreSQL against the 7.5devel cvs (please advise if this is the wrong place to post patches). This patch simply enables the \xDD (or \XDD) hexadecimal import in the copy command (im starting with the simple stuff first). I did notice that there may be a need to issue an error if an invalid octal or hex character is found following a \ or \x. No errors are currently flagged by the octal (or this hex) import.
Rgds, Jason cvs server: Diffing . Index: copy.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/commands/copy.c,v retrieving revision 1.213 diff -u -r1.213 copy.c --- copy.c 6 Oct 2003 02:38:53 -0000 1.213 +++ copy.c 5 Nov 2003 11:19:33 -0000 @@ -48,9 +48,10 @@ #include "utils/lsyscache.h" #include "utils/syscache.h" - #define ISOCTAL(c) (((c) >= '0') && ((c) <= '7')) #define OCTVALUE(c) ((c) - '0') +#define ISHEX(c) ((((c)>='0') && ((c)<='9')) || (((c)>='A') && ((c)<='F')) || (((c)>='a') && ((c)<='f'))) +#define HEXVALUE(c) (((c)>='a') ? ((c)-87) : (((c)>='A') ? ((c)-55) : ((c)-'0'))) /* * Represents the different source/dest cases we need to worry about at @@ -1947,6 +1948,33 @@ c = line_buf.data[line_buf.cursor++]; switch (c) { + case 'x': + case 'X': + { + if (line_buf.cursor < line_buf.len) + { + int hexval = 0; + + c = line_buf.data[line_buf.cursor]; + if (ISHEX(c)) + { + line_buf.cursor++; + hexval = HEXVALUE(c); + if (line_buf.cursor < line_buf.len) + { + c = line_buf.data[line_buf.cursor]; + line_buf.cursor++; + if (ISHEX(c)) + { + line_buf.cursor++; + hexval = (hexval << 4) + HEXVALUE(c); + } + } + } + c = hexval; + } + } + break; case '0': case '1': case '2': ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly