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
ce495f8d
Commit
ce495f8d
authored
Mar 06, 2001
by
Philip Warner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Dump relevant parts of sequences only when doing schemaOnly & dataOnly
- Prevent double-dumping of sequences when dataOnly.
parent
aa28eebf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
47 deletions
+39
-47
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.c
+39
-47
No files found.
src/bin/pg_dump/pg_dump.c
View file @
ce495f8d
...
...
@@ -22,7 +22,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.19
3 2001/02/18 18:33:59 momjian
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.19
4 2001/03/06 04:53:28 pjw
Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
...
...
@@ -106,6 +106,8 @@
* - Fix help output: replace 'f' with 't' and change desc.
* - Add extra arg to formatStringLiteral to specify how to handle LF & TAB.
* I opted for encoding them except in procedure bodies.
* - Dump relevant parts of sequences only when doing schemaOnly & dataOnly
* - Prevent double-dumping of sequences when dataOnly.
*
*-------------------------------------------------------------------------
*/
...
...
@@ -156,7 +158,7 @@ typedef enum _formatLiteralOptions {
}
formatLiteralOptions
;
static
void
dumpComment
(
Archive
*
outfile
,
const
char
*
target
,
const
char
*
oid
);
static
void
dumpSequence
(
Archive
*
fout
,
TableInfo
tbinfo
);
static
void
dumpSequence
(
Archive
*
fout
,
TableInfo
tbinfo
,
const
bool
schemaOnly
,
const
bool
dataOnly
);
static
void
dumpACL
(
Archive
*
fout
,
TableInfo
tbinfo
);
static
void
dumpTriggers
(
Archive
*
fout
,
const
char
*
tablename
,
TableInfo
*
tblinfo
,
int
numTables
);
...
...
@@ -608,24 +610,6 @@ dumpClasses(const TableInfo *tblinfo, const int numTables, Archive *fout,
(
onlytable
==
NULL
||
(
strlen
(
onlytable
)
==
0
))
?
"s"
:
""
,
g_comment_end
);
/* Dump SEQUENCEs first (if dataOnly) */
if
(
dataOnly
)
{
for
(
i
=
0
;
i
<
numTables
;
i
++
)
{
if
(
!
(
tblinfo
[
i
].
sequence
))
continue
;
if
(
!
onlytable
||
(
strcmp
(
tblinfo
[
i
].
relname
,
onlytable
)
==
0
)
||
(
strlen
(
onlytable
)
==
0
)
)
{
if
(
g_verbose
)
fprintf
(
stderr
,
"%s dumping out schema of sequence '%s' %s
\n
"
,
g_comment_start
,
tblinfo
[
i
].
relname
,
g_comment_end
);
/* becomeUser(fout, tblinfo[i].usename); */
dumpSequence
(
fout
,
tblinfo
[
i
]);
}
}
}
for
(
i
=
0
;
i
<
numTables
;
i
++
)
{
const
char
*
classname
=
tblinfo
[
i
].
relname
;
...
...
@@ -3730,7 +3714,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
||
(
serialSeq
&&
!
strcmp
(
tblinfo
[
i
].
relname
,
serialSeq
)))
{
/* becomeUser(fout, tblinfo[i].usename); */
dumpSequence
(
fout
,
tblinfo
[
i
]);
dumpSequence
(
fout
,
tblinfo
[
i
]
,
schemaOnly
,
dataOnly
);
if
(
!
aclsSkip
)
dumpACL
(
fout
,
tblinfo
[
i
]);
}
...
...
@@ -4314,7 +4298,7 @@ findLastBuiltinOid(const char* dbname)
static
void
dumpSequence
(
Archive
*
fout
,
TableInfo
tbinfo
)
dumpSequence
(
Archive
*
fout
,
TableInfo
tbinfo
,
const
bool
schemaOnly
,
const
bool
dataOnly
)
{
PGresult
*
res
;
int4
last
,
...
...
@@ -4367,44 +4351,52 @@ dumpSequence(Archive *fout, TableInfo tbinfo)
t
=
PQgetvalue
(
res
,
0
,
7
);
called
=
*
t
;
PQclear
(
res
);
resetPQExpBuffer
(
delqry
);
appendPQExpBuffer
(
delqry
,
"DROP SEQUENCE %s;
\n
"
,
fmtId
(
tbinfo
.
relname
,
force_quotes
));
/*
* The logic we use for restoring sequences is as follows:
* - Add a basic CREATE SEQUENCE statement
* (use last_val for start if called == 'f', else use min_val for start_val).
* - Add a 'SETVAL(seq, last_val, iscalled)' at restore-time iff we load data
*/
resetPQExpBuffer
(
query
);
appendPQExpBuffer
(
query
,
"CREATE SEQUENCE %s start %d increment %d maxvalue %d "
"minvalue %d cache %d %s;
\n
"
,
fmtId
(
tbinfo
.
relname
,
force_quotes
),
(
called
==
't'
)
?
minv
:
last
,
incby
,
maxv
,
minv
,
cache
,
(
cycled
==
't'
)
?
"cycle"
:
""
);
ArchiveEntry
(
fout
,
tbinfo
.
oid
,
fmtId
(
tbinfo
.
relname
,
force_quotes
),
"SEQUENCE"
,
NULL
,
query
->
data
,
delqry
->
data
,
""
,
tbinfo
.
usename
,
NULL
,
NULL
);
if
(
!
dataOnly
)
{
PQclear
(
res
);
resetPQExpBuffer
(
delqry
);
appendPQExpBuffer
(
delqry
,
"DROP SEQUENCE %s;
\n
"
,
fmtId
(
tbinfo
.
relname
,
force_quotes
));
resetPQExpBuffer
(
query
);
appendPQExpBuffer
(
query
,
"SELECT setval ("
);
formatStringLiteral
(
query
,
fmtId
(
tbinfo
.
relname
,
force_quotes
),
CONV_ALL
);
appendPQExpBuffer
(
query
,
", %d, '%c');
\n
"
,
last
,
called
);
resetPQExpBuffer
(
query
);
appendPQExpBuffer
(
query
,
"CREATE SEQUENCE %s start %d increment %d maxvalue %d "
"minvalue %d cache %d %s;
\n
"
,
fmtId
(
tbinfo
.
relname
,
force_quotes
),
(
called
==
't'
)
?
minv
:
last
,
incby
,
maxv
,
minv
,
cache
,
(
cycled
==
't'
)
?
"cycle"
:
""
);
ArchiveEntry
(
fout
,
tbinfo
.
oid
,
fmtId
(
tbinfo
.
relname
,
force_quotes
),
"SEQUENCE"
,
NULL
,
query
->
data
,
delqry
->
data
,
""
,
tbinfo
.
usename
,
NULL
,
NULL
);
}
ArchiveEntry
(
fout
,
tbinfo
.
oid
,
fmtId
(
tbinfo
.
relname
,
force_quotes
),
"SEQUENCE SET"
,
NULL
,
query
->
data
,
""
/* Del */
,
""
,
""
,
NULL
,
NULL
);
if
(
!
schemaOnly
)
{
resetPQExpBuffer
(
query
);
appendPQExpBuffer
(
query
,
"SELECT setval ("
);
formatStringLiteral
(
query
,
fmtId
(
tbinfo
.
relname
,
force_quotes
),
CONV_ALL
);
appendPQExpBuffer
(
query
,
", %d, '%c');
\n
"
,
last
,
called
);
/* Dump Sequence Comments */
ArchiveEntry
(
fout
,
tbinfo
.
oid
,
fmtId
(
tbinfo
.
relname
,
force_quotes
),
"SEQUENCE SET"
,
NULL
,
query
->
data
,
""
/* Del */
,
""
,
""
,
NULL
,
NULL
);
}
resetPQExpBuffer
(
query
);
appendPQExpBuffer
(
query
,
"SEQUENCE %s"
,
fmtId
(
tbinfo
.
relname
,
force_quotes
));
dumpComment
(
fout
,
query
->
data
,
tbinfo
.
oid
);
if
(
!
dataOnly
)
{
/* Dump Sequence Comments */
resetPQExpBuffer
(
query
);
appendPQExpBuffer
(
query
,
"SEQUENCE %s"
,
fmtId
(
tbinfo
.
relname
,
force_quotes
));
dumpComment
(
fout
,
query
->
data
,
tbinfo
.
oid
);
}
}
...
...
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