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
6f11e6df
Commit
6f11e6df
authored
Nov 27, 2000
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
This patch allow pg_dump save name of primary key constraint (if primary
key exist). awn@bcs.zp.ua
parent
579f8f09
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
3 deletions
+52
-3
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.c
+50
-2
src/bin/pg_dump/pg_dump.h
src/bin/pg_dump/pg_dump.h
+2
-1
No files found.
src/bin/pg_dump/pg_dump.c
View file @
6f11e6df
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.18
1 2000/11/24 22:32:26 petere
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.18
2 2000/11/27 20:51:40 momjian
Exp $
*
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
*
...
@@ -1544,6 +1544,8 @@ clearTableInfo(TableInfo *tblinfo, int numTables)
...
@@ -1544,6 +1544,8 @@ clearTableInfo(TableInfo *tblinfo, int numTables)
free
(
tblinfo
[
i
].
notnull
);
free
(
tblinfo
[
i
].
notnull
);
if
(
tblinfo
[
i
].
primary_key
)
if
(
tblinfo
[
i
].
primary_key
)
free
(
tblinfo
[
i
].
primary_key
);
free
(
tblinfo
[
i
].
primary_key
);
if
(
tblinfo
[
i
].
primary_key_name
)
free
(
tblinfo
[
i
].
primary_key_name
);
}
}
free
(
tblinfo
);
free
(
tblinfo
);
}
}
...
@@ -2144,6 +2146,49 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
...
@@ -2144,6 +2146,49 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
else
else
tblinfo
[
i
].
primary_key
=
NULL
;
tblinfo
[
i
].
primary_key
=
NULL
;
/* Get primary key name (if primary key exist) */
if
(
tblinfo
[
i
].
primary_key
)
{
PGresult
*
res2
;
int
n
;
resetPQExpBuffer
(
query
);
appendPQExpBuffer
(
query
,
"SELECT c.relname "
"FROM pg_index i, pg_class c "
"WHERE i.indrelid = %s"
"AND i.indisprimary "
"AND c.oid = i.indexrelid "
,
tblinfo
[
i
].
oid
);
res2
=
PQexec
(
g_conn
,
query
->
data
);
if
(
!
res2
||
PQresultStatus
(
res2
)
!=
PGRES_TUPLES_OK
)
{
fprintf
(
stderr
,
"getTables(): SELECT (for PRIMARY KEY NAME) failed. Explanation from backend: %s"
,
PQerrorMessage
(
g_conn
));
exit_nicely
(
g_conn
);
}
n
=
PQntuples
(
res2
);
if
(
n
!=
1
)
{
fprintf
(
stderr
,
"getTables(): SELECT (for PRIMARY KEY NAME) failed. This is impossible but object with OID == %s have %d primary keys.
\n
"
,
tblinfo
[
i
].
oid
,
n
);
exit_nicely
(
g_conn
);
}
tblinfo
[
i
].
primary_key_name
=
strdup
(
fmtId
(
PQgetvalue
(
res2
,
0
,
0
),
force_quotes
));
if
(
tblinfo
[
i
].
primary_key_name
==
NULL
)
{
perror
(
"strdup"
);
exit
(
1
);
}
}
else
tblinfo
[
i
].
primary_key_name
=
NULL
;
/* Get Triggers */
/* Get Triggers */
if
(
tblinfo
[
i
].
ntrig
>
0
)
if
(
tblinfo
[
i
].
ntrig
>
0
)
{
{
...
@@ -3558,7 +3603,10 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
...
@@ -3558,7 +3603,10 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
{
{
if
(
actual_atts
+
tblinfo
[
i
].
ncheck
>
0
)
if
(
actual_atts
+
tblinfo
[
i
].
ncheck
>
0
)
appendPQExpBuffer
(
q
,
",
\n\t
"
);
appendPQExpBuffer
(
q
,
",
\n\t
"
);
appendPQExpBuffer
(
q
,
"PRIMARY KEY (%s)"
,
tblinfo
[
i
].
primary_key
);
appendPQExpBuffer
(
q
,
"CONSTRAINT %s PRIMARY KEY (%s)"
,
tblinfo
[
i
].
primary_key_name
,
tblinfo
[
i
].
primary_key
);
}
}
appendPQExpBuffer
(
q
,
"
\n
)"
);
appendPQExpBuffer
(
q
,
"
\n
)"
);
...
...
src/bin/pg_dump/pg_dump.h
View file @
6f11e6df
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: pg_dump.h,v 1.5
4 2000/11/14 18:37:46 tgl
Exp $
* $Id: pg_dump.h,v 1.5
5 2000/11/27 20:51:40 momjian
Exp $
*
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
*
...
@@ -117,6 +117,7 @@ typedef struct _tableInfo
...
@@ -117,6 +117,7 @@ typedef struct _tableInfo
int
ntrig
;
/* # of triggers */
int
ntrig
;
/* # of triggers */
TrigInfo
*
triggers
;
/* Triggers on the table */
TrigInfo
*
triggers
;
/* Triggers on the table */
char
*
primary_key
;
/* PRIMARY KEY of the table, if any */
char
*
primary_key
;
/* PRIMARY KEY of the table, if any */
char
*
primary_key_name
;
/* PRIMARY KEY name, if any */
}
TableInfo
;
}
TableInfo
;
typedef
struct
_inhInfo
typedef
struct
_inhInfo
...
...
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