Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
202e6e73
Commit
202e6e73
authored
Jun 02, 2005
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for \x hex escapes in COPY.
Sergey Ten
parent
b6e5c4ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
5 deletions
+47
-5
doc/src/sgml/ref/copy.sgml
doc/src/sgml/ref/copy.sgml
+9
-4
src/backend/commands/copy.c
src/backend/commands/copy.c
+38
-1
No files found.
doc/src/sgml/ref/copy.sgml
View file @
202e6e73
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/copy.sgml,v 1.6
5 2005/05/07 02:22:45
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/copy.sgml,v 1.6
6 2005/06/02 01:21:21
momjian Exp $
PostgreSQL documentation
-->
...
...
@@ -424,13 +424,18 @@ COPY <replaceable class="parameter">tablename</replaceable> [ ( <replaceable cla
<entry>Backslash followed by one to three octal digits specifies
the character with that numeric code</entry>
</row>
<row>
<entry><literal>\x</><replaceable>digits</></entry>
<entry>Backslash <literal>x</> followed by one or two hex digits specifies
the character with that numeric code</entry>
</row>
</tbody>
</tgroup>
</informaltable>
Presently, <command>COPY TO</command> will never emit an octal
-digits
backslash sequence, but it does use the other sequences listed above
for those control characters.
Presently, <command>COPY TO</command> will never emit an octal
or
hex-digits backslash sequence, but it does use the other sequences
listed above
for those control characters.
</para>
<para>
...
...
src/backend/commands/copy.c
View file @
202e6e73
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.24
4 2005/05/07 02:22:46
momjian Exp $
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.24
5 2005/06/02 01:21:22
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -2274,6 +2274,18 @@ CopyReadLine(char * quote, char * escape)
return
result
;
}
/*
* Return decimal value for a hexadecimal digit
*/
static
int
GetDecimalFromHex
(
char
hex
)
{
if
(
isdigit
(
hex
))
return
hex
-
'0'
;
else
return
tolower
(
hex
)
-
'a'
+
10
;
}
/*----------
* Read the value of a single attribute, performing de-escaping as needed.
*
...
...
@@ -2335,6 +2347,7 @@ CopyReadAttribute(const char *delim, const char *null_print,
case
'5'
:
case
'6'
:
case
'7'
:
/* handle \013 */
{
int
val
;
...
...
@@ -2360,6 +2373,30 @@ CopyReadAttribute(const char *delim, const char *null_print,
c
=
val
&
0377
;
}
break
;
case
'x'
:
/* Handle \x3F */
if
(
line_buf
.
cursor
<
line_buf
.
len
)
{
char
hexchar
=
line_buf
.
data
[
line_buf
.
cursor
];
if
(
isxdigit
(
hexchar
))
{
int
val
=
GetDecimalFromHex
(
hexchar
);
line_buf
.
cursor
++
;
if
(
line_buf
.
cursor
<
line_buf
.
len
)
{
hexchar
=
line_buf
.
data
[
line_buf
.
cursor
];
if
(
isxdigit
(
hexchar
))
{
line_buf
.
cursor
++
;
val
=
(
val
<<
4
)
+
GetDecimalFromHex
(
hexchar
);
}
}
c
=
val
&
0xff
;
}
}
break
;
case
'b'
:
c
=
'\b'
;
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment