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
3325c9bd
Commit
3325c9bd
authored
Oct 20, 2010
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Further speed up pg_upgrade lookups.
parent
c33bfb8b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
19 deletions
+21
-19
contrib/pg_upgrade/info.c
contrib/pg_upgrade/info.c
+20
-19
contrib/pg_upgrade/pg_upgrade.h
contrib/pg_upgrade/pg_upgrade.h
+1
-0
No files found.
contrib/pg_upgrade/info.c
View file @
3325c9bd
...
...
@@ -66,7 +66,7 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db,
if
(
strcmp
(
newrel
->
nspname
,
"pg_toast"
)
==
0
)
continue
;
oldrel
=
relarr_lookup_rel
(
&
(
old_db
->
rel_arr
)
,
newrel
->
nspname
,
oldrel
=
relarr_lookup_rel
(
&
old_db
->
rel_arr
,
newrel
->
nspname
,
newrel
->
relname
,
CLUSTER_OLD
);
map_rel
(
oldrel
,
newrel
,
old_db
,
new_db
,
old_pgdata
,
new_pgdata
,
...
...
@@ -275,7 +275,7 @@ get_db_and_rel_infos(DbInfoArr *db_arr, Cluster whichCluster)
for
(
dbnum
=
0
;
dbnum
<
db_arr
->
ndbs
;
dbnum
++
)
get_rel_infos
(
&
db_arr
->
dbs
[
dbnum
],
&
(
db_arr
->
dbs
[
dbnum
].
rel_arr
)
,
whichCluster
);
&
db_arr
->
dbs
[
dbnum
].
rel_arr
,
whichCluster
);
if
(
log
.
debug
)
dbarr_print
(
db_arr
,
whichCluster
);
...
...
@@ -292,8 +292,7 @@ get_db_and_rel_infos(DbInfoArr *db_arr, Cluster whichCluster)
* FirstNormalObjectId belongs to the user
*/
static
void
get_rel_infos
(
const
DbInfo
*
dbinfo
,
RelInfoArr
*
relarr
,
Cluster
whichCluster
)
get_rel_infos
(
const
DbInfo
*
dbinfo
,
RelInfoArr
*
relarr
,
Cluster
whichCluster
)
{
PGconn
*
conn
=
connectToServer
(
dbinfo
->
db_name
,
whichCluster
);
PGresult
*
res
;
...
...
@@ -386,6 +385,7 @@ get_rel_infos(const DbInfo *dbinfo,
relarr
->
rels
=
relinfos
;
relarr
->
nrels
=
num_rels
;
relarr
->
cache_name_rel
=
0
;
}
...
...
@@ -419,31 +419,31 @@ dbarr_lookup_db(DbInfoArr *db_arr, const char *db_name)
* RelInfo structure.
*/
static
RelInfo
*
relarr_lookup_rel
(
RelInfoArr
*
rel_arr
,
const
char
*
nspname
,
const
char
*
relname
,
Cluster
whichCluster
)
relarr_lookup_rel
(
RelInfoArr
*
rel_arr
,
const
char
*
nspname
,
const
char
*
relname
,
Cluster
whichCluster
)
{
static
int
relnum
=
0
;
int
relnum
;
if
(
!
rel_arr
||
!
relname
)
return
NULL
;
/* Test most recent lookup first, for speed */
if
(
relnum
<
rel_arr
->
nrels
&&
strcmp
(
rel_arr
->
rels
[
relnum
].
nspname
,
nspname
)
==
0
&&
strcmp
(
rel_arr
->
rels
[
relnum
].
relname
,
relname
)
==
0
)
return
&
rel_arr
->
rels
[
relnum
];
if
(
relnum
+
1
<
rel_arr
->
nrels
&&
strcmp
(
rel_arr
->
rels
[
relnum
+
1
].
nspname
,
nspname
)
==
0
&&
strcmp
(
rel_arr
->
rels
[
relnum
+
1
].
relname
,
relname
)
==
0
)
return
&
rel_arr
->
rels
[
relnum
+
1
];
/* Test next lookup first, for speed */
if
(
rel_arr
->
cache_name_rel
+
1
<
rel_arr
->
nrels
&&
strcmp
(
rel_arr
->
rels
[
rel_arr
->
cache_name_rel
+
1
].
nspname
,
nspname
)
==
0
&&
strcmp
(
rel_arr
->
rels
[
rel_arr
->
cache_name_rel
+
1
].
relname
,
relname
)
==
0
)
{
rel_arr
->
cache_name_rel
++
;
return
&
rel_arr
->
rels
[
rel_arr
->
cache_name_rel
];
}
for
(
relnum
=
0
;
relnum
<
rel_arr
->
nrels
;
relnum
++
)
{
if
(
strcmp
(
rel_arr
->
rels
[
relnum
].
nspname
,
nspname
)
==
0
&&
strcmp
(
rel_arr
->
rels
[
relnum
].
relname
,
relname
)
==
0
)
{
rel_arr
->
cache_name_rel
=
relnum
;
return
&
rel_arr
->
rels
[
relnum
];
}
}
pg_log
(
PG_FATAL
,
"Could not find %s.%s in %s cluster
\n
"
,
nspname
,
relname
,
CLUSTERNAME
(
whichCluster
));
...
...
@@ -483,6 +483,7 @@ relarr_free(RelInfoArr *rel_arr)
{
pg_free
(
rel_arr
->
rels
);
rel_arr
->
nrels
=
0
;
rel_arr
->
cache_name_rel
=
0
;
}
...
...
contrib/pg_upgrade/pg_upgrade.h
View file @
3325c9bd
...
...
@@ -78,6 +78,7 @@ typedef struct
{
RelInfo
*
rels
;
int
nrels
;
int
cache_name_rel
;
/* cache of last lookup location */
}
RelInfoArr
;
/*
...
...
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