Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
13312a00
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
13312a00
编写于
11月 19, 1996
作者:
B
Bryan Henderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
The routines in magic.c have moved to the more accessible version.c.
上级
b8eb6400
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
0 addition
and
167 deletion
+0
-167
src/backend/utils/init/magic.c
src/backend/utils/init/magic.c
+0
-167
未找到文件。
src/backend/utils/init/magic.c
已删除
100644 → 0
浏览文件 @
b8eb6400
/*-------------------------------------------------------------------------
*
* magic.c--
* magic number management routines
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/magic.c,v 1.3 1996/11/06 10:31:56 scrappy Exp $
*
* NOTES
* XXX eventually, should be able to handle version identifiers
* of length != 4.
*
* STANDALONE CODE - do not use error routines as this code is linked with
* stuff that does not cinterface.a
*-------------------------------------------------------------------------
*/
#include <sys/file.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include "postgres.h"
#include "miscadmin.h"
/* for global decls */
#include "storage/fd.h"
/* for O_ */
static
char
Pg_verfile
[]
=
PG_VERFILE
;
/*
* private function prototypes
*/
static
void
PathSetVersionFilePath
(
const
char
*
path
,
char
*
filepathbuf
);
/*
* DatabaseMetaGunkIsConsistent
*
* Returns 1 iff all version numbers and ownerships are consistent.
*
* Note that we have to go through the whole rigmarole of generating the path
* and checking the existence of the database whether Noversion is set or not.
*/
int
DatabaseMetaGunkIsConsistent
(
const
char
*
database
,
char
*
path
)
{
int
isValid
;
#ifndef WIN32
struct
stat
statbuf
;
#else
struct
_stat
statbuf
;
#endif
/* XXX We haven't changed PG_VERSION since 1.1! */
#ifndef WIN32
isValid
=
ValidPgVersion
(
DataDir
);
sprintf
(
path
,
"%s/base/%s"
,
DataDir
,
database
);
isValid
=
ValidPgVersion
(
path
)
||
isValid
;
#endif
/* WIN32 */
if
(
stat
(
path
,
&
statbuf
)
<
0
)
elog
(
FATAL
,
"database %s does not exist, bailing out..."
,
database
);
return
(
isValid
);
}
/*
* ValidPgVersion - verifies the consistency of the database
*
* Returns 1 iff the catalog version number (from the version number file
* in the directory specified in "path") is consistent with the backend
* version number.
*/
int
ValidPgVersion
(
const
char
*
path
)
{
int
fd
;
char
version
[
4
],
buf
[
MAXPGPATH
+
1
];
#ifndef WIN32
struct
stat
statbuf
;
#else
struct
_stat
statbuf
;
#endif
u_short
my_euid
=
geteuid
();
PathSetVersionFilePath
(
path
,
buf
);
if
(
stat
(
buf
,
&
statbuf
)
>=
0
)
{
if
(
statbuf
.
st_uid
!=
my_euid
&&
my_euid
!=
0
)
elog
(
FATAL
,
"process userid (%d) != database owner (%d)"
,
my_euid
,
statbuf
.
st_uid
);
}
else
return
(
0
);
if
((
fd
=
open
(
buf
,
O_RDONLY
,
0
))
<
0
)
{
if
(
!
Noversion
)
elog
(
DEBUG
,
"ValidPgVersion: %s: %m"
,
buf
);
return
(
0
);
}
if
(
read
(
fd
,
version
,
4
)
<
4
||
!
isascii
(
version
[
0
])
||
!
isdigit
(
version
[
0
])
||
version
[
1
]
!=
'.'
||
!
isascii
(
version
[
2
])
||
!
isdigit
(
version
[
2
])
||
version
[
3
]
!=
'\n'
)
elog
(
FATAL
,
"ValidPgVersion: %s: bad format"
,
buf
);
if
(
version
[
2
]
!=
'0'
+
PG_VERSION
||
version
[
0
]
!=
'0'
+
PG_RELEASE
)
{
if
(
!
Noversion
)
elog
(
DEBUG
,
"ValidPgVersion: should be %d.%d not %c.%c"
,
PG_RELEASE
,
PG_VERSION
,
version
[
0
],
version
[
2
]);
close
(
fd
);
return
(
0
);
}
close
(
fd
);
return
(
1
);
}
/*
* SetPgVersion - writes the version to a database directory
*/
void
SetPgVersion
(
const
char
*
path
)
{
int
fd
;
char
version
[
4
],
buf
[
MAXPGPATH
+
1
];
PathSetVersionFilePath
(
path
,
buf
);
if
((
fd
=
open
(
buf
,
O_WRONLY
|
O_CREAT
|
O_EXCL
,
0666
))
<
0
)
elog
(
FATAL
,
"SetPgVersion: %s: %m"
,
buf
);
version
[
0
]
=
'0'
+
PG_RELEASE
;
version
[
1
]
=
'.'
;
version
[
2
]
=
'0'
+
PG_VERSION
;
version
[
3
]
=
'\n'
;
if
(
write
(
fd
,
version
,
4
)
!=
4
)
elog
(
WARN
,
"SetPgVersion: %s: %m"
,
buf
);
close
(
fd
);
}
/*
* PathSetVersionFilePath
*
* Destructively change "filepathbuf" to contain the concatenation of "path"
* and the name of the version file name.
*/
static
void
PathSetVersionFilePath
(
const
char
*
path
,
char
*
filepathbuf
)
{
if
(
strlen
(
path
)
>
(
MAXPGPATH
-
sizeof
(
Pg_verfile
)
-
1
))
elog
(
FATAL
,
"PathSetVersionFilePath: %s: path too long"
);
sprintf
(
filepathbuf
,
"%s%c%s"
,
path
,
SEP_CHAR
,
Pg_verfile
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录