1 Star 0 Fork 41

深圳比特萌信息技术有限公司/postgresql

forked from src-openEuler/postgresql 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
postgresql-14-check-db-dir 2.10 KB
一键复制 编辑 原始数据 按行查看 历史
Haowu Ge 提交于 2022-05-15 17:46 . update
#!/bin/sh
# This script verifies that the postgresql data directory has been correctly
# initialized. We do not want to automatically initdb it, because that has
# a risk of catastrophic failure (ie, overwriting a valuable database) in
# corner cases, such as a remotely mounted database on a volume that's a
# bit slow to mount. But we can at least emit a message advising newbies
# what to do.
PGDATA="$1"
if [ -z "$PGDATA" ]
then
echo "Usage: $0 database-path"
exit 1
fi
# PGVERSION is the full package version, e.g., 14.0
# Note: the specfile inserts the correct value during package build
PGVERSION=xxxx
# PGMAJORVERSION is major version, e.g., 14 (this should match PG_VERSION)
PGMAJORVERSION=`echo "$PGVERSION" | sed 's/^\([0-9]*\.[0-9]*\).*$/\1/'`
# PREVMAJORVERSION is the previous major version, e.g., 12 for upgrades
# Note: the specfile inserts the correct value during package build
PREVMAJORVERSION=xxxx
# PGDOCDIR is the directory containing the package's documentation
# Note: the specfile inserts the correct value during package build
PGDOCDIR=xxxx
# Check for the PGDATA structure
if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base" ]
then
# Check version of existing PGDATA
if [ x`cat "$PGDATA/PG_VERSION"` = x"$PGMAJORVERSION" ]
then
: A-OK
elif [ x`cat "$PGDATA/PG_VERSION"` = x"$PREVMAJORVERSION" ]
then
echo $"An old version of the database format was found."
echo $"Use \"postgresql-setup upgrade\" to upgrade to version $PGMAJORVERSION."
echo $"See $PGDOCDIR/README.rpm-dist for more information."
exit 1
else
echo $"An old version of the database format was found."
echo $"You need to dump and reload before using PostgreSQL $PGMAJORVERSION."
echo $"See $PGDOCDIR/README.rpm-dist for more information."
exit 1
fi
else
# No existing PGDATA! Warn the user to initdb it.
echo $"\"$PGDATA\" is missing or empty."
echo $"Use \"/usr/pgsql-14/bin/postgresql-14-setup initdb\" to initialize the database cluster."
echo $"See $PGDOCDIR/README.rpm-dist for more information."
exit 1
fi
exit 0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/BitMOE/postgresql.git
git@gitee.com:BitMOE/postgresql.git
BitMOE
postgresql
postgresql
master

搜索帮助