\xDD patch for 7.5devel
От | Jason Godden |
---|---|
Тема | \xDD patch for 7.5devel |
Дата | |
Msg-id | 200311052229.54012.jasongodden@optushome.com.au обсуждение исходный текст |
Ответы |
Re: \xDD patch for 7.5devel
(Peter Eisentraut <peter_e@gmx.net>)
Re: \xDD patch for 7.5devel (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-hackers |
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 simplestuff first). I did notice that there may be a need to issue an error if an invalid octal or hex character is foundfollowing 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':
В списке pgsql-hackers по дате отправления: