Working With VisualStudio
Pre-requisites
Visual Studio 2017
PostgreSQL can be built using the Visual C++ compiler suite from Microsoft. These compilers are present in Visual Studio.
After installing Visual Studio, open Visual Studio application and click on ‘Tools’ option and select ‘Get Tools and Features’.
The following workloads need to be installed. Workloads required are .NET desktop development and Desktop development with C++.
Apart from these workloads individual components like VC++ development toolkit and Windows Universal CRT SDK also need to be installed. (Switch to Individual Components tab to install)
It is advised to install both Windows 10 SDK and Windows 8.1 SDK as the build fails with Windows 10 SDK in some machines.
Bison and Flex
Bison and Flex are aging unix utilities that help you write very fast parsers for almost arbitrary file formats
Bison and Flex are required to build from Git. Bison must be version 2.2 or later. Flex must be version 2.5.31 or later.
Both Bison and Flex are included in the msys tool suite, as part of the MinGW compiler suite.
The MinGW installer can be downloaded from https://osdn.net/projects/mingw/downloads/68260/mingw-get-setup.exe
After the installer is up and running, the following packages need to be selected.
Once it is done, include the path of bison and flex in Windows PATH variable. By default, they are under C:\MinGW\msys\1.0\bin
Perl
ActiveState Perl is required to run the build generation scripts.
MinGW or Cygwin Perl will not work.
Binaries can be downloaded from https://www.activestate.com
This also must be present in the Windows PATH variable.
Build and Installation
Create a local repository to store source code for PostgreSQL.
Clone/download the source code from GitHub to the local repository using following command: git clone “https://github.com/postgres/postgres.git”
Under the local repository move to tools section:
Postgres/src/tools/msvc .
Open the ‘Developer Command Prompt for VS 2017’(Using Windows Search) and change the directory path to msvc.
We use the following command to intiate the build. perl mkvcbuild.pl
If there are no errors in the console, solution file corresponding to the PostgreSQL code is generated.
Open solution file in Visual Studio, right click on the Solution ‘pgsql’ and select Build Solution to build.
Post successful build, run the install command to complete the installation for PostgreSQL, create local directory where the installed files should be placed and pass it to INSTALL command
After installation, all the binaries would be available under bin folder.
These binaries can be run through the command prompt.
Running regression tests
Redirect to path postgres/src/tools/msvc using command prompt
Run the vcregress check command to run all the SQL regression tests.
To run a new perl test use the command
vcregress taptest src\bin\<Test_Folder_name>