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
a52aa6c6
Commit
a52aa6c6
authored
Oct 20, 2010
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up pg_upgrade cache lookup code; remove useless NULL pointer tests.
parent
18e752f2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
20 deletions
+12
-20
contrib/pg_upgrade/info.c
contrib/pg_upgrade/info.c
+11
-19
contrib/pg_upgrade/pg_upgrade.h
contrib/pg_upgrade/pg_upgrade.h
+1
-1
No files found.
contrib/pg_upgrade/info.c
View file @
a52aa6c6
...
...
@@ -74,8 +74,8 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db,
num_maps
++
;
/*
*
so much for the mapping of this relation. Now we need a mapping for
*
its corresponding toast relation
if any.
*
So much for mapping this relation; now we need a mapping
*
for its corresponding toast relation,
if any.
*/
if
(
oldrel
->
toastrelid
>
0
)
{
...
...
@@ -117,6 +117,7 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db,
newrel
->
reloid
);
/* look them up in their respective arrays */
/* we lose our cache location here */
old_toast
=
relarr_lookup_rel
(
&
old_db
->
rel_arr
,
"pg_toast"
,
old_name
,
CLUSTER_OLD
);
new_toast
=
relarr_lookup_rel
(
&
new_db
->
rel_arr
,
...
...
@@ -385,7 +386,7 @@ get_rel_infos(const DbInfo *dbinfo, RelInfoArr *relarr, Cluster whichCluster)
relarr
->
rels
=
relinfos
;
relarr
->
nrels
=
num_rels
;
relarr
->
cache_name_rel
=
0
;
relarr
->
last_relname_lookup
=
0
;
}
...
...
@@ -399,9 +400,6 @@ dbarr_lookup_db(DbInfoArr *db_arr, const char *db_name)
{
int
dbnum
;
if
(
!
db_arr
||
!
db_name
)
return
NULL
;
for
(
dbnum
=
0
;
dbnum
<
db_arr
->
ndbs
;
dbnum
++
)
{
if
(
strcmp
(
db_arr
->
dbs
[
dbnum
].
db_name
,
db_name
)
==
0
)
...
...
@@ -424,16 +422,13 @@ relarr_lookup_rel(RelInfoArr *rel_arr, const char *nspname,
{
int
relnum
;
if
(
!
rel_arr
||
!
relname
)
return
NULL
;
/* 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
)
if
(
rel_arr
->
last_relname_lookup
+
1
<
rel_arr
->
nrels
&&
strcmp
(
rel_arr
->
rels
[
rel_arr
->
last_relname_lookup
+
1
].
nspname
,
nspname
)
==
0
&&
strcmp
(
rel_arr
->
rels
[
rel_arr
->
last_relname_lookup
+
1
].
relname
,
relname
)
==
0
)
{
rel_arr
->
cache_name_rel
++
;
return
&
rel_arr
->
rels
[
rel_arr
->
cache_name_rel
];
rel_arr
->
last_relname_lookup
++
;
return
&
rel_arr
->
rels
[
rel_arr
->
last_relname_lookup
];
}
for
(
relnum
=
0
;
relnum
<
rel_arr
->
nrels
;
relnum
++
)
...
...
@@ -441,7 +436,7 @@ relarr_lookup_rel(RelInfoArr *rel_arr, const char *nspname,
if
(
strcmp
(
rel_arr
->
rels
[
relnum
].
nspname
,
nspname
)
==
0
&&
strcmp
(
rel_arr
->
rels
[
relnum
].
relname
,
relname
)
==
0
)
{
rel_arr
->
cache_name_rel
=
relnum
;
rel_arr
->
last_relname_lookup
=
relnum
;
return
&
rel_arr
->
rels
[
relnum
];
}
}
...
...
@@ -464,9 +459,6 @@ relarr_lookup_reloid(RelInfoArr *rel_arr, Oid oid,
{
int
relnum
;
if
(
!
rel_arr
||
!
oid
)
return
NULL
;
for
(
relnum
=
0
;
relnum
<
rel_arr
->
nrels
;
relnum
++
)
{
if
(
rel_arr
->
rels
[
relnum
].
reloid
==
oid
)
...
...
@@ -483,7 +475,7 @@ relarr_free(RelInfoArr *rel_arr)
{
pg_free
(
rel_arr
->
rels
);
rel_arr
->
nrels
=
0
;
rel_arr
->
cache_name_rel
=
0
;
rel_arr
->
last_relname_lookup
=
0
;
}
...
...
contrib/pg_upgrade/pg_upgrade.h
View file @
a52aa6c6
...
...
@@ -78,7 +78,7 @@ typedef struct
{
RelInfo
*
rels
;
int
nrels
;
int
cache_name_rel
;
/* cache of last lookup location */
int
last_relname_lookup
;
/* 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