Build on Ubuntu 18.04
参考:Installation from Source Code
需要安装的软件:
- gcc
sudo apt install gcc g++
- make
sudo apt install make
- bison/flex
sudo apt install bison flex
- zlib
sudo apt install zlib1g-dev
- libedit-dev (readline的BSD license替代)
sudo apt install libedit-dev
检出PostgreSQL 11.3代码:
git clone https://github.com/davidli2010/postgresql-11.3.git
编译DEBUG版本:
cd postgresql-11.3
chmod +x ./configure
./configure --with-libedit-preferred --enable-debug --enable-cassert --enable-depend --prefix=/home/david/pginstall CFLAGS=-O0
make install -j 4
创建测试数据库:
cd /home/david/pginstall/bin
./initdb -D ../data
./postgres -D ../data >logfile 2>&1 &
./createdb test
./psql test
Build on Windows
Windows编译借鉴了https://www.cnblogs.com/baisha/p/7829028.html。
参考:Building with Visual C++ or the Microsoft Windows SDK
PostgreSQL可以使用Visual C++编译器编译。Visual C++编译器可以是Visual Studio或者Microsoft Windows SDK自带的。
需要安装的软件:
- Visual Studio 2019 Community: https://visualstudio.microsoft.com/zh-hans/vs/
- ActivePerl: https://www.activestate.com/products/activeperl/downloads/
- diff: http://gnuwin32.sourceforge.net/packages/diffutils.htm/
- flex/bsion(Git代码必需,官方源码包可选): http://www.mingw.org/wiki/MSYS/
检出PostgreSQL 11.3代码:
git clone https://github.com/davidli2010/postgresql-11.3.git
上面代码库中的PostgreSQL 11.3代码针对Visual Studio 2019对编译脚本做了修改。
编译需要在Visual Studio 2019提供的x64 Native Tools Command Prompt for VS 2019
命令行环境下执行,并且保证安装的其它软件已添加到环境变量PATH上。
编译DEBUG版本:
cd postgresql-11.3\src\tools\msvc
build DEBUG
vcregress check
install D:\pginstall
创建测试数据库:
cd D:\pginstall\bin
initdb -D ../data
pg_ctl -D ../data -l logfile start
createdb test
psql test