バージョンごとのドキュメント一覧

18.1. Visual C++またはMicrosoft Windows SDKを使用した構築 #

<title>Building with <productname>Visual C++</productname> or the <productname>Microsoft Windows SDK</productname></title>

PostgreSQL can be built using the Visual C++ compiler suite from Microsoft. These compilers can be either from <productname>Visual Studio</productname>, <productname>Visual Studio Express</productname> or some versions of the <productname>Microsoft Windows SDK</productname>. If you do not already have a <productname>Visual Studio</productname> environment set up, the easiest ways are to use the compilers from <productname>Visual Studio 2022</productname> or those in the <productname>Windows SDK 10</productname>, which are both free downloads from Microsoft. Microsoftが提供するVisual C++コンパイラスイートを使用してPostgreSQLを構築することができます。 これらのコンパイラはVisual StudioVisual Studio Express、いくつかのバージョンのMicrosoft Windows SDKにあります。 すでにVisual Studio環境が設定されているのでなければ、Microsoftから無料でダウンロードできるVisual Studio 2022のコンパイラやWindows SDK 10のものを使用することが最も簡単な方法です。

Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite. 32-bit PostgreSQL builds are possible with <productname>Visual Studio 2015</productname> to <productname>Visual Studio 2022</productname>, as well as standalone Windows SDK releases 10 and above. 64-bit PostgreSQL builds are supported with <productname>Microsoft Windows SDK</productname> version 10 and above or <productname>Visual Studio 2015</productname> and above. 32ビットも64ビットもマイクロソフトのコンパイラ一式で構築が可能です。 32ビットPostgreSQLの構築はVisual Studio 2015からVisual Studio 2022までに付属のコンパイラをサポートします。単体のWindows SDKの10以上についても同様です。 64ビットPostgreSQLの構築はMicrosoft Windows SDKのバージョン10以上、もしくはVisual Studio 2015かそれ以上のバージョンでサポートしています。 For 2015 requirements: https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2015-sysrequirements-vs For 2017 requirements: https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2017-system-requirements-vs For 2019 requirements: https://docs.microsoft.com/en-us/visualstudio/releases/2019/system-requirements For 2022 requirements: https://docs.microsoft.com/en-us/visualstudio/releases/2022/system-requirements

The tools for building using <productname>Visual C++</productname> or <productname>Platform SDK</productname> are in the <filename>src\tools\msvc</filename> directory. When building, make sure there are no tools from <productname>MinGW</productname> or <productname>Cygwin</productname> present in your system PATH. Also, make sure you have all the required Visual C++ tools available in the PATH. In <productname>Visual Studio</productname>, start the <application>Visual Studio Command Prompt</application>. If you wish to build a 64-bit version, you must use the 64-bit version of the command, and vice versa. Starting with <productname>Visual Studio 2017</productname> this can be done from the command line using <command>VsDevCmd.bat</command>, see <command>-help</command> for the available options and their default values. <command>vsvars32.bat</command> is available in <productname>Visual Studio 2015</productname> and earlier versions for the same purpose. From the <application>Visual Studio Command Prompt</application>, you can change the targeted CPU architecture, build type, and target OS by using the <command>vcvarsall.bat</command> command, e.g., <command>vcvarsall.bat x64 10.0.10240.0</command> to target Windows 10 with a 64-bit release build. See <command>-help</command> for the other options of <command>vcvarsall.bat</command>. All commands should be run from the <filename>src\tools\msvc</filename> directory. Visual C++またはPlatform SDKを使用して構築するためのツールがsrc\tools\msvcディレクトリに存在します。 構築する際に、MinGWCygwinに付属するツールがシステムPATHに存在しないことを確認してください。 また、PATH上で必要なVisual C++ツールがすべて利用可能になっていることを確認してください。 Visual Studioでは、Visual Studio コマンドプロンプトを起動してください。 64ビット版を構築したい場合には、それぞれ64ビット版のコマンドを使用する必要がありますし、逆の場合も同様です。 Visual Studio 2017からは、これはコマンドラインからVsDevCmd.batを使ってできます。利用可能なオプションとそのデフォルト値については-helpを参照してください。 Visual Studio 2015とそれ以前のバージョンでは、同じ目的のためにvsvars32.batが利用可能です。 Visual Studioコマンドプロンプトから、vcvarsall.batコマンドを使うことで対象のCPUアーキテクチャ、構築種類、対象OSを変更できます。 例えば、vcvarsall.bat x64 10.0.10240.0は対象をWindows 10の64ビットリリース版として構築します。 その他のvcvarsall.batのオプションについては-helpを参照してください。 すべてのコマンドはsrc\tools\msvcディレクトリから実行しなければなりません。

Before you build, you can create the file <filename>config.pl</filename> to reflect any configuration options you want to change, or the paths to any third party libraries to use. The complete configuration is determined by first reading and parsing the file <filename>config_default.pl</filename>, and then apply any changes from <filename>config.pl</filename>. For example, to specify the location of your <productname>Python</productname> installation, put the following in <filename>config.pl</filename>: 構築する前に、config.plファイルを作成して、変更する設定オプションや使用する何らかのサードパーティ製のライブラリのパスを反映させることができます。 まずconfig_default.plファイルを読み取り、解析することから始まり、そしてconfig.pl内の何らかの変更が適用されて、すべての設定が決定されます。 例えば、Pythonインストレーションの場所を指定する場合、以下をconfig.plに記載します。

$config->{python} = 'c:\python310';

You only need to specify those parameters that are different from what's in <filename>config_default.pl</filename>. config_default.pl内の指定と異なるパラメータのみを指定する必要があります。

If you need to set any other environment variables, create a file called <filename>buildenv.pl</filename> and put the required commands there. For example, to add the path for bison when it's not in the PATH, create a file containing: 何か他に環境変数を設定する必要があれば、buildenv.plという名前のファイルを作成し、そこに必要なコマンドを記載してください。 たとえば、PATHにbison用のパスを追加したいのであれば、以下を含むファイルを作成してください。

$ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';

To pass additional command line arguments to the Visual Studio build command (msbuild or vcbuild): Visual Studioビルドコマンド(msbuildまたはvcbuild)に追加のコマンドライン引数を渡すには次のようにします。

$ENV{MSBFLAGS}="/m";

18.1.1. 必要条件 #

<title>Requirements</title>

The following additional products are required to build <productname>PostgreSQL</productname>. Use the <filename>config.pl</filename> file to specify which directories the libraries are available in. PostgreSQLを構築するには以下の追加製品が必要です。 config.plファイルを使用してライブラリを利用できるディレクトリを指定してください。

Microsoft Windows SDK

If your build environment doesn't ship with a supported version of the <productname>Microsoft Windows SDK</productname> it is recommended that you upgrade to the latest version (currently version 10), available for download from <ulink url="https://www.microsoft.com/download"></ulink>. もしあなたの構築環境がサポートされているMicrosoft Windows SDKのバージョンを搭載していないのであれば、入手可能な最新版(現在はバージョン10)までアップグレードすることを推奨します。 https://www.microsoft.com/downloadからダウンロードできます。

You must always include the <application>Windows Headers and Libraries</application> part of the SDK. If you install a <productname>Windows SDK</productname> including the <application>Visual C++ Compilers</application>, you don't need <productname>Visual Studio</productname> to build. Note that as of Version 8.0a the Windows SDK no longer ships with a complete command-line build environment. SDKのWindows Headers and Librariesを常にインクルードしなければなりません。 Visual C++ Compilersに含まれるWindows SDKをインストールしている場合、構築のためにVisual Studioは必要ありません。 バージョン8.0aでは、Windows SDKは完全なコマンドライン構築環境を提供していないことに注意してください。

ActiveState Perl

ActiveState Perl is required to run the build generation scripts. MinGW or Cygwin Perl will not work. It must also be present in the PATH. Binaries can be downloaded from <ulink url="https://www.activestate.com"></ulink> (Note: version 5.14 or later is required, the free Standard Distribution is sufficient). ActiveState Perlが構築生成スクリプトを実行するために必要です。 MinGWまたはCygwinのPerlでは動作しません。 また、PATH内に含められていなければなりません。 https://www.activestate.comからバイナリをダウンロードできます (注意:バージョン5.14以降が必要です。フリー版の標準配布で十分です)。

The following additional products are not required to get started, but are required to build the complete package. Use the <filename>config.pl</filename> file to specify which directories the libraries are available in. 使用できるようになることが目的であれば以下の追加製品は必要ありませんが、完全なパッケージを構築する場合には必要です。 config.plを使用してライブラリが利用できるディレクトリを指定してください。

ActiveState TCL

Required for building <application>PL/Tcl</application> (Note: version 8.4 is required, the free Standard Distribution is sufficient). PL/Tclを構築する時に必要です (注意:バージョン8.4が必要です。フリー版の標準配布で十分です)。

BisonおよびFlex

<productname>Bison</productname> and <productname>Flex</productname> are required to build from Git, but not required when building from a release file. Only <productname>Bison</productname> versions 2.3 and later will work. <productname>Flex</productname> must be version 2.5.35 or later. Gitから構築する場合はBisonおよびFlexが必要です。 しかしリリースファイルから構築する場合は不要です。 Bison バージョン2.3以降のみで動作します。 Flexはバージョン2.5.35以降でなければなりません。

Both <productname>Bison</productname> and <productname>Flex</productname> are included in the <productname>msys</productname> tool suite, available from <ulink url="http://www.mingw.org/wiki/MSYS"></ulink> as part of the <productname>MinGW</productname> compiler suite. BisonおよびFlexの両方が、MinGWコンパイラ一式の一部としてhttp://www.mingw.org/wiki/MSYSから入手できる、msysツール一式に含まれています。

You will need to add the directory containing <filename>flex.exe</filename> and <filename>bison.exe</filename> to the PATH environment variable in <filename>buildenv.pl</filename> unless they are already in PATH. In the case of MinGW, the directory is the <filename>\msys\1.0\bin</filename> subdirectory of your MinGW installation directory. すでにPATHが通っていない場合は、buildenv.plの中でflex.exeおよびbison.exeがあるディレクトリをPATH環境変数に追加する必要があります。 MinGWの場合、このディレクトリはMinGWのインストールディレクトリの\msys\1.0\binサブディレクトリです。

注記

The Bison distribution from GnuWin32 appears to have a bug that causes Bison to malfunction when installed in a directory with spaces in the name, such as the default location on English installations <filename>C:\Program Files\GnuWin32</filename>. Consider installing into <filename>C:\GnuWin32</filename> or use the NTFS short name path to GnuWin32 in your PATH environment setting (e.g., <filename>C:\PROGRA~1\GnuWin32</filename>). GnuWin32からのBisonディストリビューションでは、C:\Program Files\GnuWin32のように名前に空白を持つディレクトリにインストールされると正常に機能しないというバグがあります。 代わりにC:\GnuWin32へのインストール、または、PATH環境設定におけるGnuWin32へのNTFSショートネームパスの使用(例えばC:\PROGRA~1\GnuWin32)を検討してください。

Diff

Diff is required to run the regression tests, and can be downloaded from <ulink url="http://gnuwin32.sourceforge.net"></ulink>. リグレッションテストを実行するにはdiffが必要です。 http://gnuwin32.sourceforge.netからダウンロードできます。

Gettext

Gettext is required to build with NLS support, and can be downloaded from <ulink url="http://gnuwin32.sourceforge.net"></ulink>. Note that binaries, dependencies and developer files are all needed. NLSサポート付きで構築する場合はgettextが必要です。 http://gnuwin32.sourceforge.netからダウンロードできます。 バイナリ、依存物、開発用ファイルすべてが必要であることに注意してください。

MIT Kerberos

Required for GSSAPI authentication support. MIT Kerberos can be downloaded from <ulink url="https://web.mit.edu/Kerberos/dist/index.html"></ulink>. GSSAPI認証をサポートする場合に必要です。 MIT Kerberosはhttps://web.mit.edu/Kerberos/dist/index.htmlからダウンロードできます。

libxml2およびlibxslt

Required for XML support. Binaries can be downloaded from <ulink url="https://zlatkovic.com/pub/libxml"></ulink> or source from <ulink url="http://xmlsoft.org"></ulink>. Note that libxml2 requires iconv, which is available from the same download location. XMLサポートのために必要です。 バイナリはhttps://zlatkovic.com/pub/libxmlから、ソースはhttp://xmlsoft.orgからダウンロードできます。 libxml2はiconvを必要とすることに注意してください。 同じ場所からダウンロードできます。

LZ4

Required for supporting <productname>LZ4</productname> compression. Binaries and source can be downloaded from <ulink url="https://github.com/lz4/lz4/releases"></ulink>. LZ4圧縮方式のサポートのために必要です。 バイナリとソースはhttps://github.com/lz4/lz4/releasesからダウンロードできます。

Zstandard

Required for supporting <productname>Zstandard</productname> compression. Binaries and source can be downloaded from <ulink url="https://github.com/facebook/zstd/releases"></ulink>. Zstandard圧縮方式のサポートのために必要です。 バイナリとソースはhttps://github.com/facebook/zstd/releasesからダウンロードできます。

OpenSSL

Required for SSL support. Binaries can be downloaded from <ulink url="https://slproweb.com/products/Win32OpenSSL.html"></ulink> or source from <ulink url="https://www.openssl.org"></ulink>. SSLサポートのために必要です。 バイナリはhttps://slproweb.com/products/Win32OpenSSL.htmlから、ソースはhttps://www.openssl.orgからダウンロードできます。

ossp-uuid

Required for UUID-OSSP support (contrib only). Source can be downloaded from <ulink url="http://www.ossp.org/pkg/lib/uuid/"></ulink>. UUID-OSSPサポート(contribのみ)で必要です。 ソースはhttp://www.ossp.org/pkg/lib/uuid/にあります。

Python

Required for building <application>PL/Python</application>. Binaries can be downloaded from <ulink url="https://www.python.org"></ulink>. PL/Pythonを構築する場合に必要です。 バイナリはhttps://www.python.orgからダウンロードできます。

zlib

Required for compression support in <application>pg_dump</application> and <application>pg_restore</application>. Binaries can be downloaded from <ulink url="https://www.zlib.net"></ulink>. pg_dumpおよびpg_restoreにおける圧縮をサポートするために必要です。 バイナリはhttps://www.zlib.netからダウンロードできます。

18.1.2. 64ビット版のWindowsにおける特別な考慮事項 #

<title>Special Considerations for 64-Bit Windows</title>

PostgreSQL will only build for the x64 architecture on 64-bit Windows. 64ビット版Windowsにおいてx64アーキテクチャのみでPostgreSQLを構築できます。

Mixing 32- and 64-bit versions in the same build tree is not supported. The build system will automatically detect if it's running in a 32- or 64-bit environment, and build PostgreSQL accordingly. For this reason, it is important to start the correct command prompt before building. 同じ構築用ツリーで32ビット版と64ビット版を混在させることはサポートされません。 構築システムは32ビット環境で動作しているか64ビット環境で動作しているかを自動的に検出し、それにしたがってPostgreSQLを構築します。 このため構築作業を始める前に正しいコマンドプロンプトを開始することが重要です。

To use a server-side third party library such as <productname>Python</productname> or <productname>OpenSSL</productname>, this library <emphasis>must</emphasis> also be 64-bit. There is no support for loading a 32-bit library in a 64-bit server. Several of the third party libraries that PostgreSQL supports may only be available in 32-bit versions, in which case they cannot be used with 64-bit PostgreSQL. PythonOpenSSLなどのサーバサイドのサードパーティ製ライブラリを使用するためには、ライブラリも64ビット版である必要があります。 64ビット版のサーバで32ビット版のライブラリをロードすることはサポートされていません。 PostgreSQLがサポートするサードパーティ製のライブラリで32ビット版しか利用できないものが複数あります。 こうした場合、64ビット版のPostgreSQLで使用することはできません。

18.1.3. 構築 #

<title>Building</title>

To build all of PostgreSQL in release configuration (the default), run the command: リリース条件(デフォルト)でPostgreSQLをすべて構築するためには、以下のコマンドを実行してください。

build

To build all of PostgreSQL in debug configuration, run the command: デバッグ条件でPostgreSQLをすべて構築するためには、以下のコマンドを実行してください。

build DEBUG

To build just a single project, for example psql, run the commands: 単一のプロジェクトのみを構築するためには、たとえばpsqlであれば、以下のコマンドを実行してください。

build psql
build DEBUG psql

To change the default build configuration to debug, put the following in the <filename>buildenv.pl</filename> file: デバッグのためにデフォルトの構築条件を変更するためには、以下をbuildenv.plファイルに記載してください。

$ENV{CONFIG}="Debug";

It is also possible to build from inside the Visual Studio GUI. In this case, you need to run: また、Visual Studio GUI内から構築することも可能です。 この場合はコマンドプロンプトから以下を実行しなければなりません。

perl mkvcbuild.pl

from the command prompt, and then open the generated <filename>pgsql.sln</filename> (in the root directory of the source tree) in Visual Studio. その後に、生成されたpgsql.sln(ソースツリーのトップディレクトリに存在します)をVisual Studioで開いてください。

18.1.4. 整理およびインストール #

<title>Cleaning and Installing</title>

Most of the time, the automatic dependency tracking in Visual Studio will handle changed files. But if there have been large changes, you may need to clean the installation. To do this, simply run the <filename>clean.bat</filename> command, which will automatically clean out all generated files. You can also run it with the <parameter>dist</parameter> parameter, in which case it will behave like <userinput>make distclean</userinput> and remove the flex/bison output files as well. ほとんどの場合、Visual Studioの持つ自動依存関係追跡により変更されたファイルが扱われます。 しかし、大規模な変更が行われた場合、インストレーションを整理する必要があるかもしれません。 このためには、clean.batコマンドを実行してください。 これにより、生成されたファイルがすべて自動的に消去されます。 また、distパラメータを使用して実行することも可能です。 この場合、make distcleanのように振舞い、flex/bisonの出力ファイルも削除します。

By default, all files are written into a subdirectory of the <filename>debug</filename> or <filename>release</filename> directories. To install these files using the standard layout, and also generate the files required to initialize and use the database, run the command: デフォルトで、すべてのファイルがdebugまたはreleaseディレクトリ以下のサブディレクトリに書き出されます。 これらのファイルを標準レイアウトでインストールし、データベースの初期化や使用に必要なファイルを生成するためには、以下のコマンドを実行してください。

install c:\destination\directory

If you want to install only the client applications and interface libraries, then you can use these commands: クライアントアプリケーションとインタフェースライブラリだけをインストールしたいのであれば、以下のコマンドが使えます。

install c:\destination\directory client

18.1.5. リグレッションテストの実行 #

<title>Running the Regression Tests</title>

To run the regression tests, make sure you have completed the build of all required parts first. Also, make sure that the DLLs required to load all parts of the system (such as the Perl and Python DLLs for the procedural languages) are present in the system path. If they are not, set it through the <filename>buildenv.pl</filename> file. To run the tests, run one of the following commands from the <filename>src\tools\msvc</filename> directory: リグレッションテストを実行するためには、まず必要なすべての部品の構築が完了していることを確認してください。 また、システムのすべての部品で必要とするDLL(手続き言語用のPerlのDLLやPythonのDLLなど)がシステムパスに含まれていることを確認してください。 もし含まれていなければ、buildenv.plファイルを介して設定してください。 試験を実行するためには、以下のコマンドのいずれかをsrc\tools\msvcディレクトリから実行してください。

vcregress check
vcregress installcheck
vcregress plcheck
vcregress contribcheck
vcregress modulescheck
vcregress ecpgcheck
vcregress isolationcheck
vcregress bincheck
vcregress recoverycheck

To change the schedule used (default is parallel), append it to the command line like: 使用するスケジュール(デフォルトはparallelです)を変更するためには、コマンドラインに以下のように追加してください。

vcregress check serial

For more information about the regression tests, see <xref linkend="regress"/>. リグレッションテストの詳細については第33章を参照してください。

Running the regression tests on client programs, with <command>vcregress bincheck</command>, or on recovery tests, with <command>vcregress recoverycheck</command>, requires an additional Perl module to be installed: クライアントプログラムでvcregress bincheckによりリグレッションテストを実行したり、vcregress recoverycheckによりリカバリテストを実行したりするには、追加のPerlモジュールをインストールしておかなければなりません。

IPC::Run

As of this writing, <literal>IPC::Run</literal> is not included in the ActiveState Perl installation, nor in the ActiveState Perl Package Manager (PPM) library. To install, download the <filename>IPC-Run-&lt;version&gt;.tar.gz</filename> source archive from <acronym>CPAN</acronym>, at <ulink url="https://metacpan.org/dist/IPC-Run"></ulink>, and uncompress. Edit the <filename>buildenv.pl</filename> file, and add a PERL5LIB variable to point to the <filename>lib</filename> subdirectory from the extracted archive. For example: これを書いている時点では、IPC::RunはActiveState PerlインストレーションにもActiveState Perl Package Manager(PPM)ライブラリにも含まれていません。 インストールするためには、https://metacpan.org/dist/IPC-RunCPANからIPC-Run-<version>.tar.gzソースアーカイブをダウンロードして、展開してください。 buildenv.plを編集して、取り出されたアーカイブからlibサブディレクトリを指すように変数PERL5LIBを追加してください。 例えば以下のとおりです。

$ENV{PERL5LIB}=$ENV{PERL5LIB} . ';c:\IPC-Run-0.94\lib';

The TAP tests run with <command>vcregress</command> support the environment variables <varname>PROVE_TESTS</varname>, that is expanded automatically using the name patterns given, and <varname>PROVE_FLAGS</varname>. These can be set on a Windows terminal, before running <command>vcregress</command>: vcregressでのTAPテストの実行では、環境変数PROVE_TESTSPROVE_FLAGSをサポートします。PROVE_TESTSは与えられた名前のパターンを使って自動的に展開されます。 これは、vcregressを実行する前に、Windowsターミナルで設定できます。

set PROVE_FLAGS=--timer --jobs 2
set PROVE_TESTS=t/020*.pl t/010*.pl

It is also possible to set up those parameters in <filename>buildenv.pl</filename>: buildenv.plで、このパラメータを設定することもできます。

$ENV{PROVE_FLAGS}='--timer --jobs 2'
$ENV{PROVE_TESTS}='t/020*.pl t/010*.pl'

Additionally, the behavior of TAP tests can be controlled by a set of environment variables, see <xref linkend="regress-tap-vars" />. さらに、TAPテストの動作は一連の環境変数で制御できます。33.4.1を参照してください。

Some of the TAP tests depend on a set of external commands that would optionally trigger tests related to them. Each one of those variables can be set or unset in <filename>buildenv.pl</filename>: TAPテストの中には、オプションで関連するテストを起動する外部コマンドに依存しているものがあります。 これらの変数のそれぞれは、buildenv.plで設定または解除できます。

GZIP_PROGRAM

Path to a <application>gzip</application> command. The default is <literal>gzip</literal>, which will search for a command by that name in the configured <envar>PATH</envar>. gzipコマンドへのパス。 デフォルトはgzipで、設定されたPATH内からその名前でコマンドを検索します。

LZ4

Path to a <application>lz4</application> command. The default is <literal>lz4</literal>, which will search for a command by that name in the configured <envar>PATH</envar>. lz4コマンドへのパス。 デフォルトはlz4で、設定されたPATH内からその名前でコマンドを検索します。

OPENSSL

Path to an <application>openssl</application> command. The default is <literal>openssl</literal>, which will search for a command by that name in the configured <envar>PATH</envar>. opensslコマンドへのパス。 デフォルトはopensslで、設定されたPATH内からその名前でコマンドを検索します。

TAR

Path to a <application>tar</application> command. The default is <literal>tar</literal>, which will search for a command by that name in the configured <envar>PATH</envar>. tarコマンドへのパス。 デフォルトはtarで、設定されたPATH内からその名前でコマンドを検索します。

ZSTD

Path to a <application>zstd</application> command. The default is <literal>zstd</literal>, which will search for a command by that name in the configured <envar>PATH</envar>. zstdコマンドへのパス。 デフォルトはzstdで、設定されたPATH内からその名前でコマンドを検索します。