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
3e896ebe
Commit
3e896ebe
authored
Jan 28, 2001
by
Philip Warner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Used LEFT OUTER JOIN for various queries
parent
2f9bdffc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
14 deletions
+38
-14
src/bin/pg_dump/common.c
src/bin/pg_dump/common.c
+1
-1
src/bin/pg_dump/pg_backup_archiver.h
src/bin/pg_dump/pg_backup_archiver.h
+1
-1
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.c
+36
-12
No files found.
src/bin/pg_dump/common.c
View file @
3e896ebe
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.5
1 2001/01/28 02:57:06
pjw Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.5
2 2001/01/28 03:47:49
pjw 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
*
*
...
...
src/bin/pg_dump/pg_backup_archiver.h
View file @
3e896ebe
...
@@ -62,7 +62,7 @@ typedef z_stream *z_streamp;
...
@@ -62,7 +62,7 @@ typedef z_stream *z_streamp;
#define K_VERS_MAJOR 1
#define K_VERS_MAJOR 1
#define K_VERS_MINOR 4
#define K_VERS_MINOR 4
#define K_VERS_REV 2
5
#define K_VERS_REV 2
7
/* Data block types */
/* Data block types */
#define BLK_DATA 1
#define BLK_DATA 1
...
...
src/bin/pg_dump/pg_dump.c
View file @
3e896ebe
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.1
89 2001/01/28 02:57:06
pjw Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.1
90 2001/01/28 03:47:49
pjw Exp $
*
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
*
...
@@ -2037,6 +2037,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
...
@@ -2037,6 +2037,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
tblinfo
[
i
].
relname
,
tblinfo
[
i
].
relname
,
g_comment_end
);
g_comment_end
);
/* XXXX: Use LOJ maybe - need to compare with subsequent query for non-inherited */
resetPQExpBuffer
(
query
);
resetPQExpBuffer
(
query
);
appendPQExpBuffer
(
query
,
"SELECT rcname from pg_relcheck, pg_inherits as i "
appendPQExpBuffer
(
query
,
"SELECT rcname from pg_relcheck, pg_inherits as i "
"where rcrelid = '%s'::oid "
"where rcrelid = '%s'::oid "
...
@@ -2141,13 +2142,14 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
...
@@ -2141,13 +2142,14 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
res2
=
PQexec
(
g_conn
,
query
->
data
);
res2
=
PQexec
(
g_conn
,
query
->
data
);
if
(
!
res2
||
PQresultStatus
(
res2
)
!=
PGRES_TUPLES_OK
)
if
(
!
res2
||
PQresultStatus
(
res2
)
!=
PGRES_TUPLES_OK
)
{
{
fprintf
(
stderr
,
"getTables(): SELECT (for PRIMARY KEY) failed. Explanation from backend: %s
\n
"
,
fprintf
(
stderr
,
"getTables(): SELECT (for PRIMARY KEY) failed
on table %s
. Explanation from backend: %s
\n
"
,
PQerrorMessage
(
g_conn
));
tblinfo
[
i
].
relname
,
PQerrorMessage
(
g_conn
));
exit_nicely
(
g_conn
);
exit_nicely
(
g_conn
);
}
}
if
(
PQntuples
(
res2
)
>
1
)
{
if
(
PQntuples
(
res2
)
>
1
)
{
fprintf
(
stderr
,
"getTables(): SELECT (for PRIMARY KEY) produced more than one row.
\n
"
);
fprintf
(
stderr
,
"getTables(): SELECT (for PRIMARY KEY) produced more than one row on table %s.
\n
"
,
tblinfo
[
i
].
relname
);
exit_nicely
(
g_conn
);
exit_nicely
(
g_conn
);
}
}
...
@@ -2170,16 +2172,15 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
...
@@ -2170,16 +2172,15 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
resetPQExpBuffer
(
query
);
resetPQExpBuffer
(
query
);
appendPQExpBuffer
(
query
,
appendPQExpBuffer
(
query
,
"SELECT c.relname "
"SELECT c.relname "
"FROM pg_index i
, pg_class c
"
"FROM pg_index i
LEFT OUTER JOIN pg_class c ON c.oid = i.indexrelid
"
"WHERE i.indrelid = %s"
"WHERE i.indrelid = %s"
"AND i.indisprimary "
"AND i.indisprimary "
,
"AND c.oid = i.indexrelid "
,
tblinfo
[
i
].
oid
);
tblinfo
[
i
].
oid
);
res2
=
PQexec
(
g_conn
,
query
->
data
);
res2
=
PQexec
(
g_conn
,
query
->
data
);
if
(
!
res2
||
PQresultStatus
(
res2
)
!=
PGRES_TUPLES_OK
)
if
(
!
res2
||
PQresultStatus
(
res2
)
!=
PGRES_TUPLES_OK
)
{
{
fprintf
(
stderr
,
"getTables(): SELECT (for PRIMARY KEY NAME) failed. Explanation from backend: %s"
,
fprintf
(
stderr
,
"getTables(): SELECT (for PRIMARY KEY NAME) failed
for table %s
. Explanation from backend: %s"
,
PQerrorMessage
(
g_conn
));
tblinfo
[
i
].
relname
,
PQerrorMessage
(
g_conn
));
exit_nicely
(
g_conn
);
exit_nicely
(
g_conn
);
}
}
...
@@ -2187,12 +2188,22 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
...
@@ -2187,12 +2188,22 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
if
(
n
!=
1
)
if
(
n
!=
1
)
{
{
fprintf
(
stderr
,
fprintf
(
stderr
,
"getTables(): SELECT (for PRIMARY KEY NAME) failed. This is impossible but object with OID == %s have %d primary keys.
\n
"
,
"getTables(): SELECT (for PRIMARY KEY NAME) failed for table %s. "
"This is impossible but object with OID == %s have %d primary keys.
\n
"
,
tblinfo
[
i
].
relname
,
tblinfo
[
i
].
oid
,
tblinfo
[
i
].
oid
,
n
);
n
);
exit_nicely
(
g_conn
);
exit_nicely
(
g_conn
);
}
}
/* Sanity check on LOJ */
if
(
PQgetisnull
(
res2
,
0
,
0
))
{
fprintf
(
stderr
,
"getTables(): SELECT (for PRIMARY KEY NAME) on table %s returned NULL value.
\n
"
,
tblinfo
[
i
].
relname
);
exit_nicely
(
g_conn
);
}
tblinfo
[
i
].
primary_key_name
=
tblinfo
[
i
].
primary_key_name
=
strdup
(
fmtId
(
PQgetvalue
(
res2
,
0
,
0
),
force_quotes
));
strdup
(
fmtId
(
PQgetvalue
(
res2
,
0
,
0
),
force_quotes
));
if
(
tblinfo
[
i
].
primary_key_name
==
NULL
)
if
(
tblinfo
[
i
].
primary_key_name
==
NULL
)
...
@@ -2569,8 +2580,8 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
...
@@ -2569,8 +2580,8 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
resetPQExpBuffer
(
q
);
resetPQExpBuffer
(
q
);
appendPQExpBuffer
(
q
,
"SELECT a.oid as attoid, a.attnum, a.attname, t.typname, a.atttypmod, "
appendPQExpBuffer
(
q
,
"SELECT a.oid as attoid, a.attnum, a.attname, t.typname, a.atttypmod, "
"a.attnotnull, a.atthasdef, format_type(a.atttypid, a.atttypmod) as atttypedefn "
"a.attnotnull, a.atthasdef, format_type(a.atttypid, a.atttypmod) as atttypedefn "
"from pg_attribute a
, pg_type t
"
"from pg_attribute a
LEFT OUTER JOIN pg_type t ON a.atttypid = t.oid
"
"where a.attrelid = '%s'::oid
and a.atttypid = t.oid
"
"where a.attrelid = '%s'::oid "
"and a.attnum > 0 order by attnum"
,
"and a.attnum > 0 order by attnum"
,
tblinfo
[
i
].
oid
);
tblinfo
[
i
].
oid
);
res
=
PQexec
(
g_conn
,
q
->
data
);
res
=
PQexec
(
g_conn
,
q
->
data
);
...
@@ -2605,6 +2616,15 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
...
@@ -2605,6 +2616,15 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
tblinfo
[
i
].
numParents
=
0
;
tblinfo
[
i
].
numParents
=
0
;
for
(
j
=
0
;
j
<
ntups
;
j
++
)
for
(
j
=
0
;
j
<
ntups
;
j
++
)
{
{
/* Sanity check on LOJ */
if
(
PQgetisnull
(
res
,
j
,
i_typname
))
{
fprintf
(
stderr
,
"getTableAttrs(): SELECT produced NULL attribute type name for attr %d on table %s.
\n
"
,
j
,
tblinfo
[
i
].
relname
);
exit_nicely
(
g_conn
);
}
tblinfo
[
i
].
attoids
[
j
]
=
strdup
(
PQgetvalue
(
res
,
j
,
i_attoid
));
tblinfo
[
i
].
attoids
[
j
]
=
strdup
(
PQgetvalue
(
res
,
j
,
i_attoid
));
tblinfo
[
i
].
attnames
[
j
]
=
strdup
(
PQgetvalue
(
res
,
j
,
i_attname
));
tblinfo
[
i
].
attnames
[
j
]
=
strdup
(
PQgetvalue
(
res
,
j
,
i_attname
));
tblinfo
[
i
].
atttypedefns
[
j
]
=
strdup
(
PQgetvalue
(
res
,
j
,
i_atttypedefn
));
tblinfo
[
i
].
atttypedefns
[
j
]
=
strdup
(
PQgetvalue
(
res
,
j
,
i_atttypedefn
));
...
@@ -2692,6 +2712,8 @@ getIndices(int *numIndices)
...
@@ -2692,6 +2712,8 @@ getIndices(int *numIndices)
* Notice we skip indices on system classes
* Notice we skip indices on system classes
*
*
* this is a 4-way join !!
* this is a 4-way join !!
*
* XXXX: Use LOJ
*/
*/
appendPQExpBuffer
(
query
,
appendPQExpBuffer
(
query
,
...
@@ -4423,6 +4445,8 @@ dumpRules(Archive *fout, const char *tablename,
...
@@ -4423,6 +4445,8 @@ dumpRules(Archive *fout, const char *tablename,
* Get all rules defined for this table
* Get all rules defined for this table
* We include pg_rules in the cross since it filters out
* We include pg_rules in the cross since it filters out
* all view rules (pjw 15-Sep-2000).
* all view rules (pjw 15-Sep-2000).
*
* XXXX: Use LOJ here
*/
*/
resetPQExpBuffer
(
query
);
resetPQExpBuffer
(
query
);
appendPQExpBuffer
(
query
,
"SELECT definition,"
appendPQExpBuffer
(
query
,
"SELECT definition,"
...
...
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