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
69f909ba
Commit
69f909ba
authored
Jan 18, 2002
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
You might want to run pg_indent on pg_backup_db.c however ...
tom lane
parent
83b5ae65
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
65 deletions
+69
-65
src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_backup_archiver.c
+7
-7
src/bin/pg_dump/pg_backup_db.c
src/bin/pg_dump/pg_backup_db.c
+40
-38
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.c
+18
-16
src/bin/pg_dump/pg_restore.c
src/bin/pg_dump/pg_restore.c
+4
-4
No files found.
src/bin/pg_dump/pg_backup_archiver.c
View file @
69f909ba
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.
39 2002/01/18 17:13:50 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.
40 2002/01/18 19:17:04 momjian
Exp $
*
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
*
*
...
@@ -1922,12 +1922,12 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt)
...
@@ -1922,12 +1922,12 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt)
res
=
res
&
~
REQ_DATA
;
res
=
res
&
~
REQ_DATA
;
}
}
/* Special case: <Init> type with <Max OID> name; this is part of
/*
* a DATA restore even though it has SQL.
* Special case: <Init> type with <Max OID> name; this is part of a
* DATA restore even though it has SQL.
*/
*/
if
(
(
strcmp
(
te
->
desc
,
"<Init>"
)
==
0
)
&&
(
strcmp
(
te
->
name
,
"Max OID"
)
==
0
)
)
{
if
(
(
strcmp
(
te
->
desc
,
"<Init>"
)
==
0
)
&&
(
strcmp
(
te
->
name
,
"Max OID"
)
==
0
))
res
=
REQ_DATA
;
res
=
REQ_DATA
;
}
/* Mask it if we only want schema */
/* Mask it if we only want schema */
if
(
ropt
->
schemaOnly
)
if
(
ropt
->
schemaOnly
)
...
...
src/bin/pg_dump/pg_backup_db.c
View file @
69f909ba
...
@@ -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
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.3
0 2002/01/18 17:13:51 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.3
1 2002/01/18 19:17:05 momjian
Exp $
*
*
* NOTES
* NOTES
*
*
...
@@ -51,8 +51,8 @@ static void _check_database_version(ArchiveHandle *AH, bool ignoreVersion);
...
@@ -51,8 +51,8 @@ static void _check_database_version(ArchiveHandle *AH, bool ignoreVersion);
static
PGconn
*
_connectDB
(
ArchiveHandle
*
AH
,
const
char
*
newdbname
,
const
char
*
newUser
);
static
PGconn
*
_connectDB
(
ArchiveHandle
*
AH
,
const
char
*
newdbname
,
const
char
*
newUser
);
static
int
_executeSqlCommand
(
ArchiveHandle
*
AH
,
PGconn
*
conn
,
PQExpBuffer
qry
,
char
*
desc
);
static
int
_executeSqlCommand
(
ArchiveHandle
*
AH
,
PGconn
*
conn
,
PQExpBuffer
qry
,
char
*
desc
);
static
void
notice_processor
(
void
*
arg
,
const
char
*
message
);
static
void
notice_processor
(
void
*
arg
,
const
char
*
message
);
static
char
*
_sendSQLLine
(
ArchiveHandle
*
AH
,
char
*
qry
,
char
*
eos
);
static
char
*
_sendSQLLine
(
ArchiveHandle
*
AH
,
char
*
qry
,
char
*
eos
);
static
char
*
_sendCopyLine
(
ArchiveHandle
*
AH
,
char
*
qry
,
char
*
eos
);
static
char
*
_sendCopyLine
(
ArchiveHandle
*
AH
,
char
*
qry
,
char
*
eos
);
/*
/*
...
@@ -547,8 +547,8 @@ _executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc)
...
@@ -547,8 +547,8 @@ _executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc)
/*
/*
* Used by ExecuteSqlCommandBuf to send one buffered line when running a COPY command.
* Used by ExecuteSqlCommandBuf to send one buffered line when running a COPY command.
*/
*/
static
char
*
static
char
*
_sendCopyLine
(
ArchiveHandle
*
AH
,
char
*
qry
,
char
*
eos
)
_sendCopyLine
(
ArchiveHandle
*
AH
,
char
*
qry
,
char
*
eos
)
{
{
int
loc
;
/* Location of next newline */
int
loc
;
/* Location of next newline */
int
pos
=
0
;
/* Current position */
int
pos
=
0
;
/* Current position */
...
@@ -556,7 +556,8 @@ _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
...
@@ -556,7 +556,8 @@ _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
int
isEnd
=
0
;
int
isEnd
=
0
;
/* loop to find unquoted newline ending the line of COPY data */
/* loop to find unquoted newline ending the line of COPY data */
for
(;;)
{
for
(;;)
{
loc
=
strcspn
(
&
qry
[
pos
],
"
\n
"
)
+
pos
;
loc
=
strcspn
(
&
qry
[
pos
],
"
\n
"
)
+
pos
;
/* If no match, then wait */
/* If no match, then wait */
...
@@ -579,8 +580,8 @@ _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
...
@@ -579,8 +580,8 @@ _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
sPos
=
loc
-
sPos
;
sPos
=
loc
-
sPos
;
/*
/*
* If an odd number of preceding slashes, then \n was escaped
* If an odd number of preceding slashes, then \n was escaped
so
* s
o s
et the next search pos, and loop (if any left).
* set the next search pos, and loop (if any left).
*/
*/
if
((
sPos
&
1
)
==
1
)
if
((
sPos
&
1
)
==
1
)
{
{
...
@@ -591,9 +592,9 @@ _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
...
@@ -591,9 +592,9 @@ _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
appendBinaryPQExpBuffer
(
AH
->
pgCopyBuf
,
qry
,
(
eos
-
qry
));
appendBinaryPQExpBuffer
(
AH
->
pgCopyBuf
,
qry
,
(
eos
-
qry
));
return
eos
;
return
eos
;
}
}
}
else
{
break
;
}
}
else
break
;
}
}
/* We found an unquoted newline */
/* We found an unquoted newline */
...
@@ -613,8 +614,7 @@ _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
...
@@ -613,8 +614,7 @@ _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
resetPQExpBuffer
(
AH
->
pgCopyBuf
);
resetPQExpBuffer
(
AH
->
pgCopyBuf
);
/*
/*
* fprintf(stderr, "Buffer is '%s'\n",
* fprintf(stderr, "Buffer is '%s'\n", AH->pgCopyBuf->data);
* AH->pgCopyBuf->data);
*/
*/
if
(
isEnd
)
if
(
isEnd
)
...
@@ -631,21 +631,20 @@ _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
...
@@ -631,21 +631,20 @@ _sendCopyLine( ArchiveHandle *AH, char *qry, char *eos)
/*
/*
* Used by ExecuteSqlCommandBuf to send one buffered line of SQL (not data for the copy command).
* Used by ExecuteSqlCommandBuf to send one buffered line of SQL (not data for the copy command).
*/
*/
static
char
*
static
char
*
_sendSQLLine
(
ArchiveHandle
*
AH
,
char
*
qry
,
char
*
eos
)
_sendSQLLine
(
ArchiveHandle
*
AH
,
char
*
qry
,
char
*
eos
)
{
{
int
pos
=
0
;
/* Current position */
int
pos
=
0
;
/* Current position */
/*
/*
* The following is a mini state machine to assess the end of an
* The following is a mini state machine to assess the end of an
SQL
*
SQL statement. It really only needs to parse good SQL, or a
t
*
statement. It really only needs to parse good SQL, or at leas
t
*
least that's the theory... End-of-statement is assumed to be an
*
that's the theory... End-of-statement is assumed to be an unquoted,
* un
quoted, un
commented semi-colon.
* un commented semi-colon.
*/
*/
/*
/*
* fprintf(stderr, "Buffer at start is: '%s'\n\n",
* fprintf(stderr, "Buffer at start is: '%s'\n\n", AH->sqlBuf->data);
* AH->sqlBuf->data);
*/
*/
for
(
pos
=
0
;
pos
<
(
eos
-
qry
);
pos
++
)
for
(
pos
=
0
;
pos
<
(
eos
-
qry
);
pos
++
)
...
@@ -670,11 +669,12 @@ _sendSQLLine( ArchiveHandle *AH, char *qry, char *eos)
...
@@ -670,11 +669,12 @@ _sendSQLLine( ArchiveHandle *AH, char *qry, char *eos)
resetPQExpBuffer
(
AH
->
sqlBuf
);
resetPQExpBuffer
(
AH
->
sqlBuf
);
AH
->
sqlparse
.
lastChar
=
'\0'
;
AH
->
sqlparse
.
lastChar
=
'\0'
;
/* Remove any following newlines - so that embedded COPY commands don't get a
/*
* starting newline.
* Remove any following newlines - so that embedded
* COPY commands don't get a starting newline.
*/
*/
pos
++
;
pos
++
;
for
(
;
pos
<
(
eos
-
qry
)
&&
qry
[
pos
]
==
'\n'
;
pos
++
)
;
for
(
;
pos
<
(
eos
-
qry
)
&&
qry
[
pos
]
==
'\n'
;
pos
++
)
;
/* We've got our line, so exit */
/* We've got our line, so exit */
return
qry
+
pos
;
return
qry
+
pos
;
...
@@ -741,7 +741,10 @@ _sendSQLLine( ArchiveHandle *AH, char *qry, char *eos)
...
@@ -741,7 +741,10 @@ _sendSQLLine( ArchiveHandle *AH, char *qry, char *eos)
/* fprintf(stderr, "\n"); */
/* fprintf(stderr, "\n"); */
}
}
/* If we get here, we've processed entire string with no complete SQL stmt */
/*
* If we get here, we've processed entire string with no complete SQL
* stmt
*/
return
eos
;
return
eos
;
}
}
...
@@ -762,12 +765,11 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen)
...
@@ -762,12 +765,11 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen)
/* Could switch between command and COPY IN mode at each line */
/* Could switch between command and COPY IN mode at each line */
while
(
qry
<
eos
)
while
(
qry
<
eos
)
{
{
if
(
AH
->
pgCopyIn
)
{
if
(
AH
->
pgCopyIn
)
qry
=
_sendCopyLine
(
AH
,
qry
,
eos
);
qry
=
_sendCopyLine
(
AH
,
qry
,
eos
);
}
else
{
else
qry
=
_sendSQLLine
(
AH
,
qry
,
eos
);
qry
=
_sendSQLLine
(
AH
,
qry
,
eos
);
}
}
}
return
1
;
return
1
;
}
}
...
...
src/bin/pg_dump/pg_dump.c
View file @
69f909ba
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.23
7 2002/01/11 23:21:55 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.23
8 2002/01/18 19:17:05 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -2035,7 +2035,7 @@ getFuncs(int *numFuncs)
...
@@ -2035,7 +2035,7 @@ getFuncs(int *numFuncs)
* numTables is set to the number of tables read in
* numTables is set to the number of tables read in
*/
*/
TableInfo
*
TableInfo
*
getTables
(
int
*
numTables
,
FuncInfo
*
finfo
,
int
numFuncs
,
const
char
*
tablename
)
getTables
(
int
*
numTables
,
FuncInfo
*
finfo
,
int
numFuncs
,
const
char
*
tablename
)
{
{
PGresult
*
res
;
PGresult
*
res
;
int
ntups
;
int
ntups
;
...
@@ -2127,14 +2127,15 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char* tablename)
...
@@ -2127,14 +2127,15 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char* tablename)
/*
/*
* First pass: extract data from result and lock tables. We do the
* First pass: extract data from result and lock tables. We do the
* locking before anything else, to minimize the window wherein a
table
* locking before anything else, to minimize the window wherein a
* could disappear under us.
*
table
could disappear under us.
*
*
* Note that we have to collect info about all tables here, even when
* Note that we have to collect info about all tables here, even when
* dumping only one, because we don't know which tables might be
* dumping only one, because we don't know which tables might be
* inheritance ancestors of the target table. Possible future
* inheritance ancestors of the target table. Possible future
* improvement: suppress later collection of schema info about tables
* improvement: suppress later collection of schema info about tables
* that are determined not to be either targets or ancestors of targets.
* that are determined not to be either targets or ancestors of
* targets.
*/
*/
tblinfo
=
(
TableInfo
*
)
malloc
(
ntups
*
sizeof
(
TableInfo
));
tblinfo
=
(
TableInfo
*
)
malloc
(
ntups
*
sizeof
(
TableInfo
));
...
@@ -2167,12 +2168,13 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char* tablename)
...
@@ -2167,12 +2168,13 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char* tablename)
*
*
* If no target tablename was specified, lock all tables we see,
* If no target tablename was specified, lock all tables we see,
* otherwise lock only the specified table. (This is incomplete
* otherwise lock only the specified table. (This is incomplete
* because we'll still try to collect schema info about all tables,
* because we'll still try to collect schema info about all
* and could possibly lose during that phase. But for the typical
* tables, and could possibly lose during that phase. But for the
* use where we're dumping all tables anyway, it matters not.)
* typical use where we're dumping all tables anyway, it matters
* not.)
*
*
* NOTE: it'd be kinda nice to lock views and sequences too, not
* NOTE: it'd be kinda nice to lock views and sequences too, not
only
*
only
plain tables, but the backend doesn't presently allow that.
* plain tables, but the backend doesn't presently allow that.
*/
*/
if
((
tblinfo
[
i
].
relkind
==
RELKIND_RELATION
)
&&
if
((
tblinfo
[
i
].
relkind
==
RELKIND_RELATION
)
&&
(
tablename
==
NULL
||
strcmp
(
tblinfo
[
i
].
relname
,
tablename
)
==
0
))
(
tablename
==
NULL
||
strcmp
(
tblinfo
[
i
].
relname
,
tablename
)
==
0
))
...
@@ -2183,7 +2185,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char* tablename)
...
@@ -2183,7 +2185,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char* tablename)
appendPQExpBuffer
(
lockquery
,
appendPQExpBuffer
(
lockquery
,
"LOCK TABLE %s IN ACCESS SHARE MODE"
,
"LOCK TABLE %s IN ACCESS SHARE MODE"
,
fmtId
(
tblinfo
[
i
].
relname
,
force_quotes
));
fmtId
(
tblinfo
[
i
].
relname
,
force_quotes
));
lres
=
PQexec
(
g_conn
,
lockquery
->
data
);
lres
=
PQexec
(
g_conn
,
lockquery
->
data
);
if
(
!
lres
||
PQresultStatus
(
lres
)
!=
PGRES_COMMAND_OK
)
if
(
!
lres
||
PQresultStatus
(
lres
)
!=
PGRES_COMMAND_OK
)
{
{
write_msg
(
NULL
,
"Attempt to lock table
\"
%s
\"
failed. %s"
,
write_msg
(
NULL
,
"Attempt to lock table
\"
%s
\"
failed. %s"
,
...
@@ -2198,8 +2200,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char* tablename)
...
@@ -2198,8 +2200,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char* tablename)
res
=
NULL
;
res
=
NULL
;
/*
/*
* Second pass: pick up additional information about each table,
* Second pass: pick up additional information about each table,
as
*
as
required.
* required.
*/
*/
for
(
i
=
0
;
i
<
*
numTables
;
i
++
)
for
(
i
=
0
;
i
<
*
numTables
;
i
++
)
{
{
...
...
src/bin/pg_dump/pg_restore.c
View file @
69f909ba
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.3
2 2002/01/10 01:11:45 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.3
3 2002/01/18 19:17:05 momjian
Exp $
*
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
*
*
...
...
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