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
3f633335
Commit
3f633335
authored
Feb 14, 2003
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make pg_dump/restore safer for autocommit=off in postgresql.conf.
parent
37664ee4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
5 deletions
+32
-5
src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_backup_archiver.c
+5
-3
src/bin/pg_dump/pg_backup_db.c
src/bin/pg_dump/pg_backup_db.c
+16
-1
src/bin/pg_dump/pg_dumpall.c
src/bin/pg_dump/pg_dumpall.c
+11
-1
No files found.
src/bin/pg_dump/pg_backup_archiver.c
View file @
3f633335
...
...
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.6
7 2003/02/01 22:06:59 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.6
8 2003/02/14 19:40:42 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -206,7 +206,8 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
sav
=
SetOutput
(
AH
,
ropt
->
filename
,
ropt
->
compression
);
ahprintf
(
AH
,
"--
\n
-- PostgreSQL database dump
\n
--
\n\n
"
);
ahprintf
(
AH
,
"SET autocommit TO 'on';
\n\n
"
);
/*
* Drop the items at the start, in reverse order
*/
...
...
@@ -2109,7 +2110,8 @@ _reconnectAsUser(ArchiveHandle *AH, const char *dbname, const char *user)
dbname
?
fmtId
(
dbname
)
:
"-"
);
appendPQExpBuffer
(
qry
,
" %s
\n\n
"
,
fmtId
(
user
));
appendPQExpBuffer
(
qry
,
"SET autocommit TO 'on';
\n\n
"
);
ahprintf
(
AH
,
qry
->
data
);
destroyPQExpBuffer
(
qry
);
...
...
src/bin/pg_dump/pg_backup_db.c
View file @
3f633335
...
...
@@ -5,7 +5,7 @@
* Implements the basic DB functions used by the archiver.
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.4
5 2003/02/13 04:54:15
momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.4
6 2003/02/14 19:40:42
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -213,6 +213,21 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser)
if
(
password
)
free
(
password
);
/* check for version mismatch */
_check_database_version
(
AH
,
true
);
/* Turn autocommit on */
if
(
AH
->
public
.
remoteVersion
>=
70300
)
{
PGresult
*
res
;
res
=
PQexec
(
AH
->
connection
,
"SET autocommit TO 'on'"
);
if
(
!
res
||
PQresultStatus
(
res
)
!=
PGRES_COMMAND_OK
)
die_horribly
(
AH
,
NULL
,
"SET autocommit TO 'on' failed: %s"
,
PQerrorMessage
(
AH
->
connection
));
PQclear
(
res
);
}
PQsetNoticeProcessor
(
newConn
,
notice_processor
,
NULL
);
return
newConn
;
...
...
src/bin/pg_dump/pg_dumpall.c
View file @
3f633335
...
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.1
3 2003/01/16 15:27:59 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.1
4 2003/02/14 19:40:42 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -190,6 +190,7 @@ main(int argc, char *argv[])
printf
(
"-- PostgreSQL database cluster dump
\n
"
);
printf
(
"--
\n\n
"
);
printf
(
"
\\
connect
\"
template1
\"\n\n
"
);
printf
(
"SET autocommit TO 'on';
\n\n
"
);
dumpUsers
(
conn
);
dumpGroups
(
conn
);
...
...
@@ -552,6 +553,7 @@ dumpDatabases(PGconn *conn)
fprintf
(
stderr
,
_
(
"%s: dumping database
\"
%s
\"
...
\n
"
),
progname
,
dbname
);
printf
(
"
\\
connect %s
\n
"
,
fmtId
(
dbname
));
printf
(
"SET autocommit TO 'on';
\n\n
"
);
ret
=
runPgDump
(
dbname
);
if
(
ret
!=
0
)
{
...
...
@@ -677,6 +679,14 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport,
}
PQclear
(
res
);
if
(
server_version
>=
70300
)
{
PGresult
*
res
;
res
=
executeQuery
(
conn
,
"SET autocommit TO 'on';SELECT 1;"
);
PQclear
(
res
);
}
return
conn
;
}
...
...
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