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
539bc9fc
Commit
539bc9fc
authored
Jul 01, 2005
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add code to pg_dump to use E'' strings when backslashes are used in dump
files.
parent
975368e2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
11 deletions
+41
-11
src/bin/pg_dump/dumputils.c
src/bin/pg_dump/dumputils.c
+25
-4
src/bin/pg_dump/pg_backup_db.c
src/bin/pg_dump/pg_backup_db.c
+1
-2
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.c
+15
-5
No files found.
src/bin/pg_dump/dumputils.c
View file @
539bc9fc
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.1
7 2005/04/30 08:08:51 neilc
Exp $
* $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.1
8 2005/07/01 21:03:25 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -111,6 +111,27 @@ fmtId(const char *rawid)
...
@@ -111,6 +111,27 @@ fmtId(const char *rawid)
void
void
appendStringLiteral
(
PQExpBuffer
buf
,
const
char
*
str
,
bool
escapeAll
)
appendStringLiteral
(
PQExpBuffer
buf
,
const
char
*
str
,
bool
escapeAll
)
{
{
bool
has_escapes
=
false
;
const
char
*
str2
=
str
;
while
(
*
str2
)
{
char
ch
=
*
str2
++
;
if
(
ch
==
'\\'
||
((
unsigned
char
)
ch
<
(
unsigned
char
)
' '
&&
(
escapeAll
||
(
ch
!=
'\t'
&&
ch
!=
'\n'
&&
ch
!=
'\v'
&&
ch
!=
'\f'
&&
ch
!=
'\r'
))))
{
has_escapes
=
true
;
break
;
}
}
if
(
has_escapes
)
appendPQExpBufferChar
(
buf
,
'E'
);
appendPQExpBufferChar
(
buf
,
'\''
);
appendPQExpBufferChar
(
buf
,
'\''
);
while
(
*
str
)
while
(
*
str
)
{
{
...
@@ -122,9 +143,9 @@ appendStringLiteral(PQExpBuffer buf, const char *str, bool escapeAll)
...
@@ -122,9 +143,9 @@ appendStringLiteral(PQExpBuffer buf, const char *str, bool escapeAll)
appendPQExpBufferChar
(
buf
,
ch
);
appendPQExpBufferChar
(
buf
,
ch
);
}
}
else
if
((
unsigned
char
)
ch
<
(
unsigned
char
)
' '
&&
else
if
((
unsigned
char
)
ch
<
(
unsigned
char
)
' '
&&
(
escapeAll
(
escapeAll
||
||
(
ch
!=
'\t'
&&
ch
!=
'\n'
&&
ch
!=
'\v'
&&
ch
!=
'\f'
&&
ch
!=
'\r'
)
(
ch
!=
'\t'
&&
ch
!=
'\n'
&&
ch
!=
'\v'
&&
))
ch
!=
'\f'
&&
ch
!=
'\r'
)
))
{
{
/*
/*
* generate octal escape for control chars other than
* generate octal escape for control chars other than
...
...
src/bin/pg_dump/pg_backup_db.c
View file @
539bc9fc
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
* Implements the basic DB functions used by the archiver.
* Implements the basic DB functions used by the archiver.
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.6
2 2005/06/21 20:45:44 tgl
Exp $
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.6
3 2005/07/01 21:03:25 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -597,7 +597,6 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
...
@@ -597,7 +597,6 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
}
}
else
else
{
{
if
(
qry
[
pos
]
==
'\\'
)
if
(
qry
[
pos
]
==
'\\'
)
{
{
if
(
AH
->
sqlparse
.
lastChar
==
'\\'
)
if
(
AH
->
sqlparse
.
lastChar
==
'\\'
)
...
...
src/bin/pg_dump/pg_dump.c
View file @
539bc9fc
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
* by PostgreSQL
* by PostgreSQL
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.41
1 2005/06/30 03:02:56 tgl
Exp $
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.41
2 2005/07/01 21:03:25 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -7767,8 +7767,9 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
...
@@ -7767,8 +7767,9 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
p
=
tginfo
->
tgargs
;
p
=
tginfo
->
tgargs
;
for
(
findx
=
0
;
findx
<
tginfo
->
tgnargs
;
findx
++
)
for
(
findx
=
0
;
findx
<
tginfo
->
tgnargs
;
findx
++
)
{
{
const
char
*
s
=
p
;
const
char
*
s
=
p
,
*
s2
=
p
;
/* Set 'p' to end of arg string. marked by '\000' */
for
(;;)
for
(;;)
{
{
p
=
strchr
(
p
,
'\\'
);
p
=
strchr
(
p
,
'\\'
);
...
@@ -7781,20 +7782,29 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
...
@@ -7781,20 +7782,29 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
exit_nicely
();
exit_nicely
();
}
}
p
++
;
p
++
;
if
(
*
p
==
'\\'
)
if
(
*
p
==
'\\'
)
/* is it '\\'? */
{
{
p
++
;
p
++
;
continue
;
continue
;
}
}
if
(
p
[
0
]
==
'0'
&&
p
[
1
]
==
'0'
&&
p
[
2
]
==
'0'
)
if
(
p
[
0
]
==
'0'
&&
p
[
1
]
==
'0'
&&
p
[
2
]
==
'0'
)
/* is it '\000'? */
break
;
break
;
}
}
p
--
;
p
--
;
/* do we need E''? */
while
(
s2
<
p
)
if
(
*
s2
++
==
'\\'
)
{
appendPQExpBufferChar
(
query
,
'E'
);
break
;
}
appendPQExpBufferChar
(
query
,
'\''
);
appendPQExpBufferChar
(
query
,
'\''
);
while
(
s
<
p
)
while
(
s
<
p
)
{
{
if
(
*
s
==
'\''
)
if
(
*
s
==
'\''
)
appendPQExpBufferChar
(
query
,
'\
\
'
);
appendPQExpBufferChar
(
query
,
'\
'
'
);
appendPQExpBufferChar
(
query
,
*
s
++
);
appendPQExpBufferChar
(
query
,
*
s
++
);
}
}
appendPQExpBufferChar
(
query
,
'\''
);
appendPQExpBufferChar
(
query
,
'\''
);
...
...
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