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
9340fb80
Commit
9340fb80
authored
Sep 28, 2010
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
In pg_upgrade, properly handle oids > 2^31 by using strtoul() internally
rather than atol(). Per report from Brian Hirt
parent
a1bb570d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
21 deletions
+35
-21
contrib/pg_upgrade/controldata.c
contrib/pg_upgrade/controldata.c
+15
-15
contrib/pg_upgrade/info.c
contrib/pg_upgrade/info.c
+4
-4
contrib/pg_upgrade/pg_upgrade.h
contrib/pg_upgrade/pg_upgrade.h
+2
-0
contrib/pg_upgrade/relfilenode.c
contrib/pg_upgrade/relfilenode.c
+2
-2
contrib/pg_upgrade/util.c
contrib/pg_upgrade/util.c
+12
-0
No files found.
contrib/pg_upgrade/controldata.c
View file @
9340fb80
...
@@ -155,7 +155,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
...
@@ -155,7 +155,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
pg_log
(
ctx
,
PG_FATAL
,
"%d: pg_resetxlog problem
\n
"
,
__LINE__
);
pg_log
(
ctx
,
PG_FATAL
,
"%d: pg_resetxlog problem
\n
"
,
__LINE__
);
p
++
;
/* removing ':' char */
p
++
;
/* removing ':' char */
cluster
->
controldata
.
ctrl_ver
=
(
uint32
)
atol
(
p
);
cluster
->
controldata
.
ctrl_ver
=
str2uint
(
p
);
}
}
else
if
((
p
=
strstr
(
bufin
,
"Catalog version number:"
))
!=
NULL
)
else
if
((
p
=
strstr
(
bufin
,
"Catalog version number:"
))
!=
NULL
)
{
{
...
@@ -165,7 +165,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
...
@@ -165,7 +165,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
p
++
;
/* removing ':' char */
p
++
;
/* removing ':' char */
cluster
->
controldata
.
cat_ver
=
(
uint32
)
atol
(
p
);
cluster
->
controldata
.
cat_ver
=
str2uint
(
p
);
}
}
else
if
((
p
=
strstr
(
bufin
,
"First log file ID after reset:"
))
!=
NULL
)
else
if
((
p
=
strstr
(
bufin
,
"First log file ID after reset:"
))
!=
NULL
)
{
{
...
@@ -175,7 +175,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
...
@@ -175,7 +175,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
p
++
;
/* removing ':' char */
p
++
;
/* removing ':' char */
cluster
->
controldata
.
logid
=
(
uint32
)
atol
(
p
);
cluster
->
controldata
.
logid
=
str2uint
(
p
);
got_log_id
=
true
;
got_log_id
=
true
;
}
}
else
if
((
p
=
strstr
(
bufin
,
"First log file segment after reset:"
))
!=
NULL
)
else
if
((
p
=
strstr
(
bufin
,
"First log file segment after reset:"
))
!=
NULL
)
...
@@ -186,7 +186,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
...
@@ -186,7 +186,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
p
++
;
/* removing ':' char */
p
++
;
/* removing ':' char */
cluster
->
controldata
.
nxtlogseg
=
(
uint32
)
atol
(
p
);
cluster
->
controldata
.
nxtlogseg
=
str2uint
(
p
);
got_log_seg
=
true
;
got_log_seg
=
true
;
}
}
else
if
((
p
=
strstr
(
bufin
,
"Latest checkpoint's TimeLineID:"
))
!=
NULL
)
else
if
((
p
=
strstr
(
bufin
,
"Latest checkpoint's TimeLineID:"
))
!=
NULL
)
...
@@ -197,7 +197,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
...
@@ -197,7 +197,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
p
++
;
/* removing ':' char */
p
++
;
/* removing ':' char */
cluster
->
controldata
.
chkpnt_tli
=
(
uint32
)
atol
(
p
);
cluster
->
controldata
.
chkpnt_tli
=
str2uint
(
p
);
got_tli
=
true
;
got_tli
=
true
;
}
}
else
if
((
p
=
strstr
(
bufin
,
"Latest checkpoint's NextXID:"
))
!=
NULL
)
else
if
((
p
=
strstr
(
bufin
,
"Latest checkpoint's NextXID:"
))
!=
NULL
)
...
@@ -211,7 +211,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
...
@@ -211,7 +211,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
op
++
;
/* removing ':' char */
op
++
;
/* removing ':' char */
cluster
->
controldata
.
chkpnt_nxtxid
=
(
uint32
)
atol
(
op
);
cluster
->
controldata
.
chkpnt_nxtxid
=
str2uint
(
op
);
got_xid
=
true
;
got_xid
=
true
;
}
}
else
if
((
p
=
strstr
(
bufin
,
"Latest checkpoint's NextOID:"
))
!=
NULL
)
else
if
((
p
=
strstr
(
bufin
,
"Latest checkpoint's NextOID:"
))
!=
NULL
)
...
@@ -222,7 +222,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
...
@@ -222,7 +222,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
p
++
;
/* removing ':' char */
p
++
;
/* removing ':' char */
cluster
->
controldata
.
chkpnt_nxtoid
=
(
uint32
)
atol
(
p
);
cluster
->
controldata
.
chkpnt_nxtoid
=
str2uint
(
p
);
got_oid
=
true
;
got_oid
=
true
;
}
}
else
if
((
p
=
strstr
(
bufin
,
"Maximum data alignment:"
))
!=
NULL
)
else
if
((
p
=
strstr
(
bufin
,
"Maximum data alignment:"
))
!=
NULL
)
...
@@ -233,7 +233,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
...
@@ -233,7 +233,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
p
++
;
/* removing ':' char */
p
++
;
/* removing ':' char */
cluster
->
controldata
.
align
=
(
uint32
)
atol
(
p
);
cluster
->
controldata
.
align
=
str2uint
(
p
);
got_align
=
true
;
got_align
=
true
;
}
}
else
if
((
p
=
strstr
(
bufin
,
"Database block size:"
))
!=
NULL
)
else
if
((
p
=
strstr
(
bufin
,
"Database block size:"
))
!=
NULL
)
...
@@ -244,7 +244,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
...
@@ -244,7 +244,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
p
++
;
/* removing ':' char */
p
++
;
/* removing ':' char */
cluster
->
controldata
.
blocksz
=
(
uint32
)
atol
(
p
);
cluster
->
controldata
.
blocksz
=
str2uint
(
p
);
got_blocksz
=
true
;
got_blocksz
=
true
;
}
}
else
if
((
p
=
strstr
(
bufin
,
"Blocks per segment of large relation:"
))
!=
NULL
)
else
if
((
p
=
strstr
(
bufin
,
"Blocks per segment of large relation:"
))
!=
NULL
)
...
@@ -255,7 +255,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
...
@@ -255,7 +255,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
p
++
;
/* removing ':' char */
p
++
;
/* removing ':' char */
cluster
->
controldata
.
largesz
=
(
uint32
)
atol
(
p
);
cluster
->
controldata
.
largesz
=
str2uint
(
p
);
got_largesz
=
true
;
got_largesz
=
true
;
}
}
else
if
((
p
=
strstr
(
bufin
,
"WAL block size:"
))
!=
NULL
)
else
if
((
p
=
strstr
(
bufin
,
"WAL block size:"
))
!=
NULL
)
...
@@ -266,7 +266,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
...
@@ -266,7 +266,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
p
++
;
/* removing ':' char */
p
++
;
/* removing ':' char */
cluster
->
controldata
.
walsz
=
(
uint32
)
atol
(
p
);
cluster
->
controldata
.
walsz
=
str2uint
(
p
);
got_walsz
=
true
;
got_walsz
=
true
;
}
}
else
if
((
p
=
strstr
(
bufin
,
"Bytes per WAL segment:"
))
!=
NULL
)
else
if
((
p
=
strstr
(
bufin
,
"Bytes per WAL segment:"
))
!=
NULL
)
...
@@ -277,7 +277,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
...
@@ -277,7 +277,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
p
++
;
/* removing ':' char */
p
++
;
/* removing ':' char */
cluster
->
controldata
.
walseg
=
(
uint32
)
atol
(
p
);
cluster
->
controldata
.
walseg
=
str2uint
(
p
);
got_walseg
=
true
;
got_walseg
=
true
;
}
}
else
if
((
p
=
strstr
(
bufin
,
"Maximum length of identifiers:"
))
!=
NULL
)
else
if
((
p
=
strstr
(
bufin
,
"Maximum length of identifiers:"
))
!=
NULL
)
...
@@ -288,7 +288,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
...
@@ -288,7 +288,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
p
++
;
/* removing ':' char */
p
++
;
/* removing ':' char */
cluster
->
controldata
.
ident
=
(
uint32
)
atol
(
p
);
cluster
->
controldata
.
ident
=
str2uint
(
p
);
got_ident
=
true
;
got_ident
=
true
;
}
}
else
if
((
p
=
strstr
(
bufin
,
"Maximum columns in an index:"
))
!=
NULL
)
else
if
((
p
=
strstr
(
bufin
,
"Maximum columns in an index:"
))
!=
NULL
)
...
@@ -299,7 +299,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
...
@@ -299,7 +299,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
p
++
;
/* removing ':' char */
p
++
;
/* removing ':' char */
cluster
->
controldata
.
index
=
(
uint32
)
atol
(
p
);
cluster
->
controldata
.
index
=
str2uint
(
p
);
got_index
=
true
;
got_index
=
true
;
}
}
else
if
((
p
=
strstr
(
bufin
,
"Maximum size of a TOAST chunk:"
))
!=
NULL
)
else
if
((
p
=
strstr
(
bufin
,
"Maximum size of a TOAST chunk:"
))
!=
NULL
)
...
@@ -310,7 +310,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
...
@@ -310,7 +310,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
pg_log
(
ctx
,
PG_FATAL
,
"%d: controldata retrieval problem
\n
"
,
__LINE__
);
p
++
;
/* removing ':' char */
p
++
;
/* removing ':' char */
cluster
->
controldata
.
toast
=
(
uint32
)
atol
(
p
);
cluster
->
controldata
.
toast
=
str2uint
(
p
);
got_toast
=
true
;
got_toast
=
true
;
}
}
else
if
((
p
=
strstr
(
bufin
,
"Date/time type storage:"
))
!=
NULL
)
else
if
((
p
=
strstr
(
bufin
,
"Date/time type storage:"
))
!=
NULL
)
...
...
contrib/pg_upgrade/info.c
View file @
9340fb80
...
@@ -242,7 +242,7 @@ get_db_infos(migratorContext *ctx, DbInfoArr *dbinfs_arr, Cluster whichCluster)
...
@@ -242,7 +242,7 @@ get_db_infos(migratorContext *ctx, DbInfoArr *dbinfs_arr, Cluster whichCluster)
for
(
tupnum
=
0
;
tupnum
<
ntups
;
tupnum
++
)
for
(
tupnum
=
0
;
tupnum
<
ntups
;
tupnum
++
)
{
{
dbinfos
[
tupnum
].
db_oid
=
atol
(
PQgetvalue
(
res
,
tupnum
,
i_oid
));
dbinfos
[
tupnum
].
db_oid
=
str2uint
(
PQgetvalue
(
res
,
tupnum
,
i_oid
));
snprintf
(
dbinfos
[
tupnum
].
db_name
,
sizeof
(
dbinfos
[
tupnum
].
db_name
),
"%s"
,
snprintf
(
dbinfos
[
tupnum
].
db_name
,
sizeof
(
dbinfos
[
tupnum
].
db_name
),
"%s"
,
PQgetvalue
(
res
,
tupnum
,
i_datname
));
PQgetvalue
(
res
,
tupnum
,
i_datname
));
...
@@ -360,7 +360,7 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo,
...
@@ -360,7 +360,7 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo,
RelInfo
*
curr
=
&
relinfos
[
num_rels
++
];
RelInfo
*
curr
=
&
relinfos
[
num_rels
++
];
const
char
*
tblspace
;
const
char
*
tblspace
;
curr
->
reloid
=
atol
(
PQgetvalue
(
res
,
relnum
,
i_oid
));
curr
->
reloid
=
str2uint
(
PQgetvalue
(
res
,
relnum
,
i_oid
));
nspname
=
PQgetvalue
(
res
,
relnum
,
i_nspname
);
nspname
=
PQgetvalue
(
res
,
relnum
,
i_nspname
);
strlcpy
(
curr
->
nspname
,
nspname
,
sizeof
(
curr
->
nspname
));
strlcpy
(
curr
->
nspname
,
nspname
,
sizeof
(
curr
->
nspname
));
...
@@ -368,8 +368,8 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo,
...
@@ -368,8 +368,8 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo,
relname
=
PQgetvalue
(
res
,
relnum
,
i_relname
);
relname
=
PQgetvalue
(
res
,
relnum
,
i_relname
);
strlcpy
(
curr
->
relname
,
relname
,
sizeof
(
curr
->
relname
));
strlcpy
(
curr
->
relname
,
relname
,
sizeof
(
curr
->
relname
));
curr
->
relfilenode
=
atol
(
PQgetvalue
(
res
,
relnum
,
i_relfilenode
));
curr
->
relfilenode
=
str2uint
(
PQgetvalue
(
res
,
relnum
,
i_relfilenode
));
curr
->
toastrelid
=
atol
(
PQgetvalue
(
res
,
relnum
,
i_reltoastrelid
));
curr
->
toastrelid
=
str2uint
(
PQgetvalue
(
res
,
relnum
,
i_reltoastrelid
));
tblspace
=
PQgetvalue
(
res
,
relnum
,
i_spclocation
);
tblspace
=
PQgetvalue
(
res
,
relnum
,
i_spclocation
);
/* if no table tablespace, use the database tablespace */
/* if no table tablespace, use the database tablespace */
...
...
contrib/pg_upgrade/pg_upgrade.h
View file @
9340fb80
...
@@ -376,6 +376,8 @@ char *pg_strdup(migratorContext *ctx, const char *s);
...
@@ -376,6 +376,8 @@ char *pg_strdup(migratorContext *ctx, const char *s);
void
*
pg_malloc
(
migratorContext
*
ctx
,
int
size
);
void
*
pg_malloc
(
migratorContext
*
ctx
,
int
size
);
void
pg_free
(
void
*
ptr
);
void
pg_free
(
void
*
ptr
);
const
char
*
getErrorText
(
int
errNum
);
const
char
*
getErrorText
(
int
errNum
);
unsigned
int
str2uint
(
const
char
*
str
);
/* version.c */
/* version.c */
...
...
contrib/pg_upgrade/relfilenode.c
View file @
9340fb80
...
@@ -94,9 +94,9 @@ get_pg_database_relfilenode(migratorContext *ctx, Cluster whichCluster)
...
@@ -94,9 +94,9 @@ get_pg_database_relfilenode(migratorContext *ctx, Cluster whichCluster)
i_relfile
=
PQfnumber
(
res
,
"relfilenode"
);
i_relfile
=
PQfnumber
(
res
,
"relfilenode"
);
if
(
whichCluster
==
CLUSTER_OLD
)
if
(
whichCluster
==
CLUSTER_OLD
)
ctx
->
old
.
pg_database_oid
=
atol
(
PQgetvalue
(
res
,
0
,
i_relfile
));
ctx
->
old
.
pg_database_oid
=
str2uint
(
PQgetvalue
(
res
,
0
,
i_relfile
));
else
else
ctx
->
new
.
pg_database_oid
=
atol
(
PQgetvalue
(
res
,
0
,
i_relfile
));
ctx
->
new
.
pg_database_oid
=
str2uint
(
PQgetvalue
(
res
,
0
,
i_relfile
));
PQclear
(
res
);
PQclear
(
res
);
PQfinish
(
conn
);
PQfinish
(
conn
);
...
...
contrib/pg_upgrade/util.c
View file @
9340fb80
...
@@ -259,3 +259,15 @@ getErrorText(int errNum)
...
@@ -259,3 +259,15 @@ getErrorText(int errNum)
#endif
#endif
return
strdup
(
strerror
(
errNum
));
return
strdup
(
strerror
(
errNum
));
}
}
/*
* str2uint()
*
* convert string to oid
*/
unsigned
int
str2uint
(
const
char
*
str
)
{
return
strtol
(
str
,
NULL
,
10
);
}
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