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
a51d560d
Commit
a51d560d
authored
Apr 04, 2001
by
Philip Warner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't dump CHECK constraints with same source and names both
starting with '$'.
parent
1d9819d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
61 deletions
+30
-61
src/bin/pg_dump/pg_backup_archiver.h
src/bin/pg_dump/pg_backup_archiver.h
+2
-2
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.c
+28
-59
No files found.
src/bin/pg_dump/pg_backup_archiver.h
View file @
a51d560d
...
...
@@ -17,7 +17,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.
29 2001/04/03 08:52:59
pjw Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.
30 2001/04/04 06:47:30
pjw Exp $
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* - Initial version.
...
...
@@ -68,7 +68,7 @@ typedef z_stream *z_streamp;
#define K_VERS_MAJOR 1
#define K_VERS_MINOR 5
#define K_VERS_REV
1
#define K_VERS_REV
2
/* Data block types */
#define BLK_DATA 1
...
...
src/bin/pg_dump/pg_dump.c
View file @
a51d560d
...
...
@@ -22,7 +22,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.
199 2001/04/03 08:52:59
pjw Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.
200 2001/04/04 06:47:30
pjw Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
...
...
@@ -122,6 +122,11 @@
* OID of the type functions, but type must be created after
* the functions.
*
* Modifications - 4-Apr-2001 - pjw@rhyme.com.au
*
* - Don't dump CHECK constraints with same source and names both
* starting with '$'.
*
*-------------------------------------------------------------------------
*/
...
...
@@ -2068,59 +2073,15 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
else
tblinfo
[
i
].
viewdef
=
NULL
;
/*
/*
* Get non-inherited CHECK constraints, if any.
*
* Exclude inherited CHECKs from CHECK constraints total. If a
* constraint matches by name and condition with a constraint
* belonging to a parent class, we assume it was inherited.
* belonging to a parent class (OR conditions match and both
* names start with '$', we assume it was inherited.
*/
if
(
tblinfo
[
i
].
ncheck
>
0
)
{
PGresult
*
res2
;
int
ntups2
;
if
(
g_verbose
)
fprintf
(
stderr
,
"%s excluding inherited CHECK constraints "
"for relation: '%s' %s
\n
"
,
g_comment_start
,
tblinfo
[
i
].
relname
,
g_comment_end
);
/*
* XXXX: Use LOJ maybe - need to compare with subsequent query
* for non-inherited
*/
resetPQExpBuffer
(
query
);
appendPQExpBuffer
(
query
,
"SELECT rcname from pg_relcheck, pg_inherits as i "
"where rcrelid = '%s'::oid "
" and rcrelid = i.inhrelid"
" and exists "
" (select * from pg_relcheck as c "
" where c.rcname = pg_relcheck.rcname "
" and c.rcsrc = pg_relcheck.rcsrc "
" and c.rcrelid = i.inhparent) "
,
tblinfo
[
i
].
oid
);
res2
=
PQexec
(
g_conn
,
query
->
data
);
if
(
!
res2
||
PQresultStatus
(
res2
)
!=
PGRES_TUPLES_OK
)
{
fprintf
(
stderr
,
"getTables(): SELECT (for inherited CHECK) failed. "
"Explanation from backend: '%s'.
\n
"
,
PQerrorMessage
(
g_conn
));
exit_nicely
(
g_conn
);
}
ntups2
=
PQntuples
(
res2
);
tblinfo
[
i
].
ncheck
-=
ntups2
;
if
(
tblinfo
[
i
].
ncheck
<
0
)
{
fprintf
(
stderr
,
"getTables(): found more inherited CHECKs than total for "
"relation %s
\n
"
,
tblinfo
[
i
].
relname
);
exit_nicely
(
g_conn
);
}
PQclear
(
res2
);
}
/* Get non-inherited CHECK constraints, if any */
if
(
tblinfo
[
i
].
ncheck
>
0
)
{
PGresult
*
res2
;
int
i_rcname
,
...
...
@@ -2136,13 +2097,16 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
resetPQExpBuffer
(
query
);
appendPQExpBuffer
(
query
,
"SELECT rcname, rcsrc from pg_relcheck "
"where rcrelid = '%s'::oid "
"
where rcrelid = '%s'::oid "
" and not exists "
" (select * from pg_relcheck as c, pg_inherits as i "
" where i.inhrelid = pg_relcheck.rcrelid "
" and c.rcname = pg_relcheck.rcname "
" and c.rcsrc = pg_relcheck.rcsrc "
" and c.rcrelid = i.inhparent) "
" (select * from pg_relcheck as c, pg_inherits as i "
" where i.inhrelid = pg_relcheck.rcrelid "
" and (c.rcname = pg_relcheck.rcname "
" or ( c.rcname[0] = '$' "
" and pg_relcheck.rcname[0] = '$')"
" )"
" and c.rcsrc = pg_relcheck.rcsrc "
" and c.rcrelid = i.inhparent) "
" Order By oid "
,
tblinfo
[
i
].
oid
);
res2
=
PQexec
(
g_conn
,
query
->
data
);
...
...
@@ -2154,12 +2118,17 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
exit_nicely
(
g_conn
);
}
ntups2
=
PQntuples
(
res2
);
if
(
ntups2
!=
tblinfo
[
i
].
ncheck
)
if
(
ntups2
>
tblinfo
[
i
].
ncheck
)
{
fprintf
(
stderr
,
"getTables(): relation '%s': %d CHECKs were expected, but got %d
\n
"
,
fprintf
(
stderr
,
"getTables(): relation '%s': a maximum of %d CHECKs "
"were expected, but got %d
\n
"
,
tblinfo
[
i
].
relname
,
tblinfo
[
i
].
ncheck
,
ntups2
);
exit_nicely
(
g_conn
);
}
/* Set ncheck to the number of *non-inherited* CHECK constraints */
tblinfo
[
i
].
ncheck
=
ntups2
;
i_rcname
=
PQfnumber
(
res2
,
"rcname"
);
i_rcsrc
=
PQfnumber
(
res2
,
"rcsrc"
);
tblinfo
[
i
].
check_expr
=
(
char
**
)
malloc
(
ntups2
*
sizeof
(
char
*
));
...
...
@@ -3897,7 +3866,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
if
(
numParents
>
0
)
{
appendPQExpBuffer
(
q
,
"
\n
inherits
("
);
appendPQExpBuffer
(
q
,
"
\n
INHERITS
("
);
for
(
k
=
0
;
k
<
numParents
;
k
++
)
{
appendPQExpBuffer
(
q
,
"%s%s"
,
...
...
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