2021-05-07 16:56:14 +02:00
|
|
|
|
2023-01-02 21:00:37 +01:00
|
|
|
# Copyright (c) 2021-2023, PostgreSQL Global Development Group
|
2021-05-07 16:56:14 +02:00
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
package Mkvcbuild;
|
2007-03-23 10:53:33 +01:00
|
|
|
|
2007-03-17 15:01:01 +01:00
|
|
|
#
|
|
|
|
# Package that generates build files for msvc build
|
|
|
|
#
|
2010-09-20 22:08:53 +02:00
|
|
|
# src/tools/msvc/Mkvcbuild.pm
|
2007-03-17 15:01:01 +01:00
|
|
|
#
|
2007-03-17 14:50:42 +01:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
2020-02-21 22:03:05 +01:00
|
|
|
|
|
|
|
use Carp;
|
|
|
|
use if ($^O eq "MSWin32"), 'Win32';
|
2007-03-17 14:50:42 +01:00
|
|
|
use Project;
|
|
|
|
use Solution;
|
2010-01-09 15:45:47 +01:00
|
|
|
use Cwd;
|
|
|
|
use File::Copy;
|
2011-11-26 21:22:32 +01:00
|
|
|
use Config;
|
2012-01-03 14:44:26 +01:00
|
|
|
use VSObjectFactory;
|
2011-11-26 21:22:32 +01:00
|
|
|
use List::Util qw(first);
|
2007-03-17 14:50:42 +01:00
|
|
|
|
|
|
|
use Exporter;
|
|
|
|
our (@ISA, @EXPORT_OK);
|
2012-07-05 03:47:49 +02:00
|
|
|
@ISA = qw(Exporter);
|
2007-03-17 14:50:42 +01:00
|
|
|
@EXPORT_OK = qw(Mkvcbuild);
|
|
|
|
|
|
|
|
my $solution;
|
|
|
|
my $libpgport;
|
Create libpgcommon, and move pg_malloc et al to it
libpgcommon is a new static library to allow sharing code among the
various frontend programs and backend; this lets us eliminate duplicate
implementations of common routines. We avoid libpgport, because that's
intended as a place for porting issues; per discussion, it seems better
to keep them separate.
The first use case, and the only implemented by this patch, is pg_malloc
and friends, which many frontend programs were already using.
At the same time, we can use this to provide palloc emulation functions
for the frontend; this way, some palloc-using files in the backend can
also be used by the frontend cleanly. To do this, we change palloc() in
the backend to be a function instead of a macro on top of
MemoryContextAlloc(). This was previously believed to cause loss of
performance, but this implementation has been tweaked by Tom and Andres
so that on modern compilers it provides a slight improvement over the
previous one.
This lets us clean up some places that were already with
localized hacks.
Most of the pg_malloc/palloc changes in this patch were authored by
Andres Freund. Zoltán Böszörményi also independently provided a form of
that. libpgcommon infrastructure was authored by Álvaro.
2013-02-12 14:33:40 +01:00
|
|
|
my $libpgcommon;
|
2016-03-24 20:55:44 +01:00
|
|
|
my $libpgfeutils;
|
2007-03-17 14:50:42 +01:00
|
|
|
my $postgres;
|
|
|
|
my $libpq;
|
2017-12-09 03:06:05 +01:00
|
|
|
my @unlink_on_exit;
|
2007-03-17 14:50:42 +01:00
|
|
|
|
2015-04-16 20:17:26 +02:00
|
|
|
# Set of variables for modules in contrib/ and src/test/modules/
|
2022-10-06 22:03:31 +02:00
|
|
|
my $contrib_defines = {};
|
2021-08-09 09:45:26 +02:00
|
|
|
my @contrib_uselibpq = ();
|
|
|
|
my @contrib_uselibpgport = ();
|
|
|
|
my @contrib_uselibpgcommon = ();
|
2021-03-15 22:13:42 +01:00
|
|
|
my $contrib_extralibs = { 'libpq_pipeline' => ['ws2_32.lib'] };
|
2021-08-09 09:45:26 +02:00
|
|
|
my $contrib_extraincludes = {};
|
|
|
|
my $contrib_extrasource = {};
|
2015-04-28 17:47:08 +02:00
|
|
|
my @contrib_excludes = (
|
2016-04-09 00:18:10 +02:00
|
|
|
'bool_plperl', 'commit_ts',
|
|
|
|
'hstore_plperl', 'hstore_plpython',
|
2018-04-03 16:43:16 +02:00
|
|
|
'intagg', 'jsonb_plperl',
|
|
|
|
'jsonb_plpython', 'ltree_plpython',
|
2021-11-06 23:02:27 +01:00
|
|
|
'sepgsql', 'brin',
|
2019-09-08 01:03:11 +02:00
|
|
|
'test_extensions', 'test_misc',
|
|
|
|
'test_pg_dump', 'snapshot_too_old',
|
|
|
|
'unsafe_tests');
|
2007-03-17 14:50:42 +01:00
|
|
|
|
2015-03-11 14:21:01 +01:00
|
|
|
# Set of variables for frontend modules
|
2022-10-06 22:03:31 +02:00
|
|
|
my $frontend_defines = { 'pgbench' => 'FD_SETSIZE=1024' };
|
2021-03-12 19:00:01 +01:00
|
|
|
my @frontend_uselibpq =
|
|
|
|
('pg_amcheck', 'pg_ctl', 'pg_upgrade', 'pgbench', 'psql', 'initdb');
|
2015-03-11 03:33:24 +01:00
|
|
|
my @frontend_uselibpgport = (
|
2021-03-12 19:00:01 +01:00
|
|
|
'pg_amcheck', 'pg_archivecleanup',
|
2015-03-11 03:33:24 +01:00
|
|
|
'pg_test_fsync', 'pg_test_timing',
|
2017-02-09 22:23:46 +01:00
|
|
|
'pg_upgrade', 'pg_waldump',
|
|
|
|
'pgbench');
|
2015-03-11 03:33:24 +01:00
|
|
|
my @frontend_uselibpgcommon = (
|
2021-03-12 19:00:01 +01:00
|
|
|
'pg_amcheck', 'pg_archivecleanup',
|
2015-03-11 03:33:24 +01:00
|
|
|
'pg_test_fsync', 'pg_test_timing',
|
2017-02-09 22:23:46 +01:00
|
|
|
'pg_upgrade', 'pg_waldump',
|
|
|
|
'pgbench');
|
2015-03-11 14:21:01 +01:00
|
|
|
my $frontend_extralibs = {
|
|
|
|
'initdb' => ['ws2_32.lib'],
|
2021-03-12 19:00:01 +01:00
|
|
|
'pg_amcheck' => ['ws2_32.lib'],
|
2015-03-11 14:21:01 +01:00
|
|
|
'pg_restore' => ['ws2_32.lib'],
|
2015-03-11 03:33:24 +01:00
|
|
|
'pgbench' => ['ws2_32.lib'],
|
2018-05-09 16:14:46 +02:00
|
|
|
'psql' => ['ws2_32.lib']
|
|
|
|
};
|
2015-03-11 14:21:01 +01:00
|
|
|
my $frontend_extraincludes = {
|
2015-04-25 14:52:03 +02:00
|
|
|
'initdb' => ['src/timezone'],
|
2018-05-09 16:14:46 +02:00
|
|
|
'psql' => ['src/backend']
|
|
|
|
};
|
2015-03-11 03:33:24 +01:00
|
|
|
my $frontend_extrasource = {
|
2016-03-25 01:28:47 +01:00
|
|
|
'psql' => ['src/bin/psql/psqlscanslash.l'],
|
2015-03-11 03:33:24 +01:00
|
|
|
'pgbench' =>
|
2018-05-09 16:14:46 +02:00
|
|
|
[ 'src/bin/pgbench/exprscan.l', 'src/bin/pgbench/exprparse.y' ]
|
|
|
|
};
|
2015-03-23 18:47:52 +01:00
|
|
|
my @frontend_excludes = (
|
2015-03-11 03:33:24 +01:00
|
|
|
'pgevent', 'pg_basebackup', 'pg_rewind', 'pg_dump',
|
2017-02-09 22:23:46 +01:00
|
|
|
'pg_waldump', 'scripts');
|
2015-03-11 14:21:01 +01:00
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
sub mkvcbuild
|
|
|
|
{
|
|
|
|
our $config = shift;
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2015-04-25 14:52:03 +02:00
|
|
|
chdir('../../..') if (-d '../msvc' && -d '../../../src');
|
2012-07-05 03:47:49 +02:00
|
|
|
die 'Must run from root or msvc directory'
|
2015-04-25 14:52:03 +02:00
|
|
|
unless (-d 'src/tools/msvc' && -d 'src');
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-01-03 14:44:26 +01:00
|
|
|
my $vsVersion = DetermineVisualStudioVersion();
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-01-03 14:44:26 +01:00
|
|
|
$solution = CreateSolution($vsVersion, $config);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
our @pgportfiles = qw(
|
2022-08-05 06:10:05 +02:00
|
|
|
chklocale.c explicit_bzero.c
|
2022-08-13 13:35:24 +02:00
|
|
|
getpeereid.c inet_aton.c
|
2022-08-13 23:53:28 +02:00
|
|
|
inet_net_ntop.c kill.c open.c
|
Replace random(), pg_erand48(), etc with a better PRNG API and algorithm.
Standardize on xoroshiro128** as our basic PRNG algorithm, eliminating
a bunch of platform dependencies as well as fundamentally-obsolete PRNG
code. In addition, this API replacement will ease replacing the
algorithm again in future, should that become necessary.
xoroshiro128** is a few percent slower than the drand48 family,
but it can produce full-width 64-bit random values not only 48-bit,
and it should be much more trustworthy. It's likely to be noticeably
faster than the platform's random(), depending on which platform you
are thinking about; and we can have non-global state vectors easily,
unlike with random(). It is not cryptographically strong, but neither
are the functions it replaces.
Fabien Coelho, reviewed by Dean Rasheed, Aleksander Alekseev, and myself
Discussion: https://postgr.es/m/alpine.DEB.2.22.394.2105241211230.165418@pseudo
2021-11-29 03:32:36 +01:00
|
|
|
snprintf.c strlcat.c strlcpy.c dirmod.c noblock.c path.c
|
2022-08-04 23:36:50 +02:00
|
|
|
dirent.c getopt.c getopt_long.c
|
2023-11-29 04:44:19 +01:00
|
|
|
pg_bitutils.c
|
Replace PostmasterRandom() with a stronger source, second attempt.
This adds a new routine, pg_strong_random() for generating random bytes,
for use in both frontend and backend. At the moment, it's only used in
the backend, but the upcoming SCRAM authentication patches need strong
random numbers in libpq as well.
pg_strong_random() is based on, and replaces, the existing implementation
in pgcrypto. It can acquire strong random numbers from a number of sources,
depending on what's available:
- OpenSSL RAND_bytes(), if built with OpenSSL
- On Windows, the native cryptographic functions are used
- /dev/urandom
Unlike the current pgcrypto function, the source is chosen by configure.
That makes it easier to test different implementations, and ensures that
we don't accidentally fall back to a less secure implementation, if the
primary source fails. All of those methods are quite reliable, it would be
pretty surprising for them to fail, so we'd rather find out by failing
hard.
If no strong random source is available, we fall back to using erand48(),
seeded from current timestamp, like PostmasterRandom() was. That isn't
cryptographically secure, but allows us to still work on platforms that
don't have any of the above stronger sources. Because it's not very secure,
the built-in implementation is only used if explicitly requested with
--disable-strong-random.
This replaces the more complicated Fortuna algorithm we used to have in
pgcrypto, which is unfortunate, but all modern platforms have /dev/urandom,
so it doesn't seem worth the maintenance effort to keep that. pgcrypto
functions that require strong random numbers will be disabled with
--disable-strong-random.
Original patch by Magnus Hagander, tons of further work by Michael Paquier
and me.
Discussion: https://www.postgresql.org/message-id/CAB7nPqRy3krN8quR9XujMVVHYtXJ0_60nqgVc6oUk8ygyVkZsA@mail.gmail.com
Discussion: https://www.postgresql.org/message-id/CAB7nPqRWkNYRRPJA7-cF+LfroYV10pvjdz6GNvxk-Eee9FypKA@mail.gmail.com
2016-12-05 12:42:59 +01:00
|
|
|
pg_strong_random.c pgcheckdir.c pgmkdirp.c pgsleep.c pgstrcasecmp.c
|
2021-03-23 00:11:20 +01:00
|
|
|
pqsignal.c mkdtemp.c qsort.c qsort_arg.c bsearch_arg.c quotes.c system.c
|
2022-01-11 19:46:12 +01:00
|
|
|
strerror.c tar.c
|
Fix detection of unseekable files for fseek() and ftello() with MSVC
Calling fseek() or ftello() on a handle to a non-seeking device such as
a pipe or a communications device is not supported. Unfortunately,
MSVC's flavor of these routines, _fseeki64() and _ftelli64(), do not
return an error when given a pipe as handle. Some of the logic of
pg_dump and restore relies on these routines to check if a handle is
seekable, causing failures when passing the contents of pg_dump to
pg_restore through a pipe, for example.
This commit introduces wrappers for fseeko() and ftello() on MSVC so as
any callers are able to properly detect the cases of non-seekable
handles. This relies mainly on GetFileType(), sharing a bit of code
with the MSVC port for fstat(). The code in charge of getting a file
type is refactored into a new file called win32common.c, shared by
win32stat.c and the new win32fseek.c. It includes the MSVC ports for
fseeko() and ftello().
Like 765f5df, this is backpatched down to 14, where the fstat()
implementation for MSVC is able to understand about files larger than
4GB in size. Using a TAP test for that is proving to be tricky as
IPC::Run handles the pipes by itself, still I have been able to check
the fix manually.
Reported-by: Daniel Watzinger
Author: Juan José Santamaría Flecha, Michael Paquier
Discussion: https://postgr.es/m/CAC+AXB26a4EmxM2suXxPpJaGrqAdxracd7hskLg-zxtPB50h7A@mail.gmail.com
Backpatch-through: 14
2023-04-12 02:09:38 +02:00
|
|
|
win32common.c
|
2022-08-04 23:12:45 +02:00
|
|
|
win32dlopen.c
|
2022-08-04 23:36:50 +02:00
|
|
|
win32env.c win32error.c
|
2022-08-05 06:10:05 +02:00
|
|
|
win32fdatasync.c
|
Fix detection of unseekable files for fseek() and ftello() with MSVC
Calling fseek() or ftello() on a handle to a non-seeking device such as
a pipe or a communications device is not supported. Unfortunately,
MSVC's flavor of these routines, _fseeki64() and _ftelli64(), do not
return an error when given a pipe as handle. Some of the logic of
pg_dump and restore relies on these routines to check if a handle is
seekable, causing failures when passing the contents of pg_dump to
pg_restore through a pipe, for example.
This commit introduces wrappers for fseeko() and ftello() on MSVC so as
any callers are able to properly detect the cases of non-seekable
handles. This relies mainly on GetFileType(), sharing a bit of code
with the MSVC port for fstat(). The code in charge of getting a file
type is refactored into a new file called win32common.c, shared by
win32stat.c and the new win32fseek.c. It includes the MSVC ports for
fseeko() and ftello().
Like 765f5df, this is backpatched down to 14, where the fstat()
implementation for MSVC is able to understand about files larger than
4GB in size. Using a TAP test for that is proving to be tricky as
IPC::Run handles the pipes by itself, still I have been able to check
the fix manually.
Reported-by: Daniel Watzinger
Author: Juan José Santamaría Flecha, Michael Paquier
Discussion: https://postgr.es/m/CAC+AXB26a4EmxM2suXxPpJaGrqAdxracd7hskLg-zxtPB50h7A@mail.gmail.com
Backpatch-through: 14
2023-04-12 02:09:38 +02:00
|
|
|
win32fseek.c
|
2022-08-13 13:35:24 +02:00
|
|
|
win32getrusage.c
|
2022-08-06 17:34:56 +02:00
|
|
|
win32gettimeofday.c
|
2022-08-04 23:36:50 +02:00
|
|
|
win32link.c
|
2022-08-04 23:42:31 +02:00
|
|
|
win32pread.c
|
|
|
|
win32pwrite.c
|
2022-08-04 23:36:50 +02:00
|
|
|
win32ntdll.c
|
2021-12-10 04:13:14 +01:00
|
|
|
win32security.c win32setlocale.c win32stat.c);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2019-02-13 16:19:44 +01:00
|
|
|
push(@pgportfiles, 'strtof.c') if ($vsVersion < '14.00');
|
|
|
|
|
Use Intel SSE 4.2 CRC instructions where available.
Modern x86 and x86-64 processors with SSE 4.2 support have special
instructions, crc32b and crc32q, for calculating CRC-32C. They greatly
speed up CRC calculation.
Whether the instructions can be used or not depends on the compiler and the
target architecture. If generation of SSE 4.2 instructions is allowed for
the target (-msse4.2 flag on gcc and clang), use them. If they are not
allowed by default, but the compiler supports the -msse4.2 flag to enable
them, compile just the CRC-32C function with -msse4.2 flag, and check at
runtime whether the processor we're running on supports it. If it doesn't,
fall back to the slicing-by-8 algorithm. (With the common defaults on
current operating systems, the runtime-check variant is what you get in
practice.)
Abhijit Menon-Sen, heavily modified by me, reviewed by Andres Freund.
2015-04-14 16:05:03 +02:00
|
|
|
if ($vsVersion >= '9.00')
|
|
|
|
{
|
Use ARMv8 CRC instructions where available.
ARMv8 introduced special CPU instructions for calculating CRC-32C. Use
them, when available, for speed.
Like with the similar Intel CRC instructions, several factors affect
whether the instructions can be used. The compiler intrinsics for them must
be supported by the compiler, and the instructions must be supported by the
target architecture. If the compilation target architecture does not
support the instructions, but adding "-march=armv8-a+crc" makes them
available, then we compile the code with a runtime check to determine if
the host we're running on supports them or not.
For the runtime check, use glibc getauxval() function. Unfortunately,
that's not very portable, but I couldn't find any more portable way to do
it. If getauxval() is not available, the CRC instructions will still be
used if the target architecture supports them without any additional
compiler flags, but the runtime check will not be available.
Original patch by Yuqi Gu, heavily modified by me. Reviewed by Andres
Freund, Thomas Munro.
Discussion: https://www.postgresql.org/message-id/HE1PR0801MB1323D171938EABC04FFE7FA9E3110%40HE1PR0801MB1323.eurprd08.prod.outlook.com
2018-04-04 11:22:45 +02:00
|
|
|
push(@pgportfiles, 'pg_crc32c_sse42_choose.c');
|
Use Intel SSE 4.2 CRC instructions where available.
Modern x86 and x86-64 processors with SSE 4.2 support have special
instructions, crc32b and crc32q, for calculating CRC-32C. They greatly
speed up CRC calculation.
Whether the instructions can be used or not depends on the compiler and the
target architecture. If generation of SSE 4.2 instructions is allowed for
the target (-msse4.2 flag on gcc and clang), use them. If they are not
allowed by default, but the compiler supports the -msse4.2 flag to enable
them, compile just the CRC-32C function with -msse4.2 flag, and check at
runtime whether the processor we're running on supports it. If it doesn't,
fall back to the slicing-by-8 algorithm. (With the common defaults on
current operating systems, the runtime-check variant is what you get in
practice.)
Abhijit Menon-Sen, heavily modified by me, reviewed by Andres Freund.
2015-04-14 16:05:03 +02:00
|
|
|
push(@pgportfiles, 'pg_crc32c_sse42.c');
|
|
|
|
push(@pgportfiles, 'pg_crc32c_sb8.c');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
push(@pgportfiles, 'pg_crc32c_sb8.c');
|
|
|
|
}
|
|
|
|
|
2013-02-22 02:46:17 +01:00
|
|
|
our @pgcommonallfiles = qw(
|
2023-09-18 21:46:57 +02:00
|
|
|
archive.c base64.c binaryheap.c checksum_helper.c compression.c
|
2020-04-03 17:50:38 +02:00
|
|
|
config_info.c controldata_utils.c d2s.c encnames.c exec.c
|
2021-08-19 02:20:13 +02:00
|
|
|
f2s.c file_perm.c file_utils.c hashfn.c ip.c jsonapi.c
|
2023-01-11 14:41:52 +01:00
|
|
|
keywords.c kwlookup.c link-canary.c md5_common.c percentrepl.c
|
Replace random(), pg_erand48(), etc with a better PRNG API and algorithm.
Standardize on xoroshiro128** as our basic PRNG algorithm, eliminating
a bunch of platform dependencies as well as fundamentally-obsolete PRNG
code. In addition, this API replacement will ease replacing the
algorithm again in future, should that become necessary.
xoroshiro128** is a few percent slower than the drand48 family,
but it can produce full-width 64-bit random values not only 48-bit,
and it should be much more trustworthy. It's likely to be noticeably
faster than the platform's random(), depending on which platform you
are thinking about; and we can have non-global state vectors easily,
unlike with random(). It is not cryptographically strong, but neither
are the functions it replaces.
Fabien Coelho, reviewed by Dean Rasheed, Aleksander Alekseev, and myself
Discussion: https://postgr.es/m/alpine.DEB.2.22.394.2105241211230.165418@pseudo
2021-11-29 03:32:36 +01:00
|
|
|
pg_get_line.c pg_lzcompress.c pg_prng.c pgfnames.c psprintf.c relpath.c
|
2023-11-04 03:41:16 +01:00
|
|
|
rmtree.c saslprep.c scram-common.c string.c stringinfo.c
|
|
|
|
unicode_category.c unicode_norm.c username.c wait_error.c wchar.c);
|
Create libpgcommon, and move pg_malloc et al to it
libpgcommon is a new static library to allow sharing code among the
various frontend programs and backend; this lets us eliminate duplicate
implementations of common routines. We avoid libpgport, because that's
intended as a place for porting issues; per discussion, it seems better
to keep them separate.
The first use case, and the only implemented by this patch, is pg_malloc
and friends, which many frontend programs were already using.
At the same time, we can use this to provide palloc emulation functions
for the frontend; this way, some palloc-using files in the backend can
also be used by the frontend cleanly. To do this, we change palloc() in
the backend to be a function instead of a macro on top of
MemoryContextAlloc(). This was previously believed to cause loss of
performance, but this implementation has been tweaked by Tom and Andres
so that on modern compilers it provides a slight improvement over the
previous one.
This lets us clean up some places that were already with
localized hacks.
Most of the pg_malloc/palloc changes in this patch were authored by
Andres Freund. Zoltán Böszörményi also independently provided a form of
that. libpgcommon infrastructure was authored by Álvaro.
2013-02-12 14:33:40 +01:00
|
|
|
|
2017-03-07 13:23:49 +01:00
|
|
|
if ($solution->{options}->{openssl})
|
|
|
|
{
|
Move SHA2 routines to a new generic API layer for crypto hashes
Two new routines to allocate a hash context and to free it are created,
as these become necessary for the goal behind this refactoring: switch
the all cryptohash implementations for OpenSSL to use EVP (for FIPS and
also because upstream does not recommend the use of low-level cryptohash
functions for 20 years). Note that OpenSSL hides the internals of
cryptohash contexts since 1.1.0, so it is necessary to leave the
allocation to OpenSSL itself, explaining the need for those two new
routines. This part is going to require more work to properly track
hash contexts with resource owners, but this not introduced here.
Still, this refactoring makes the move possible.
This reduces the number of routines for all SHA2 implementations from
twelve (SHA{224,256,386,512} with init, update and final calls) to five
(create, free, init, update and final calls) by incorporating the hash
type directly into the hash context data.
The new cryptohash routines are moved to a new file, called cryptohash.c
for the fallback implementations, with SHA2 specifics becoming a part
internal to src/common/. OpenSSL specifics are part of
cryptohash_openssl.c. This infrastructure is usable for more hash
types, like MD5 or HMAC.
Any code paths using the internal SHA2 routines are adapted to report
correctly errors, which are most of the changes of this commit. The
zones mostly impacted are checksum manifests, libpq and SCRAM.
Note that e21cbb4 was a first attempt to switch SHA2 to EVP, but it
lacked the refactoring needed for libpq, as done here.
This patch has been tested on Linux and Windows, with and without
OpenSSL, and down to 1.0.1, the oldest version supported on HEAD.
Author: Michael Paquier
Reviewed-by: Daniel Gustafsson
Discussion: https://postgr.es/m/20200924025314.GE7405@paquier.xyz
2020-12-02 02:37:20 +01:00
|
|
|
push(@pgcommonallfiles, 'cryptohash_openssl.c');
|
Refactor HMAC implementations
Similarly to the cryptohash implementations, this refactors the existing
HMAC code into a single set of APIs that can be plugged with any crypto
libraries PostgreSQL is built with (only OpenSSL currently). If there
is no such libraries, a fallback implementation is available. Those new
APIs are designed similarly to the existing cryptohash layer, so there
is no real new design here, with the same logic around buffer bound
checks and memory handling.
HMAC has a dependency on cryptohashes, so all the cryptohash types
supported by cryptohash{_openssl}.c can be used with HMAC. This
refactoring is an advantage mainly for SCRAM, that included its own
implementation of HMAC with SHA256 without relying on the existing
crypto libraries even if PostgreSQL was built with their support.
This code has been tested on Windows and Linux, with and without
OpenSSL, across all the versions supported on HEAD from 1.1.1 down to
1.0.1. I have also checked that the implementations are working fine
using some sample results, a custom extension of my own, and doing
cross-checks across different major versions with SCRAM with the client
and the backend.
Author: Michael Paquier
Reviewed-by: Bruce Momjian
Discussion: https://postgr.es/m/X9m0nkEJEzIPXjeZ@paquier.xyz
2021-04-03 10:30:49 +02:00
|
|
|
push(@pgcommonallfiles, 'hmac_openssl.c');
|
2020-01-17 02:06:17 +01:00
|
|
|
push(@pgcommonallfiles, 'protocol_openssl.c');
|
2017-03-07 13:23:49 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
Move SHA2 routines to a new generic API layer for crypto hashes
Two new routines to allocate a hash context and to free it are created,
as these become necessary for the goal behind this refactoring: switch
the all cryptohash implementations for OpenSSL to use EVP (for FIPS and
also because upstream does not recommend the use of low-level cryptohash
functions for 20 years). Note that OpenSSL hides the internals of
cryptohash contexts since 1.1.0, so it is necessary to leave the
allocation to OpenSSL itself, explaining the need for those two new
routines. This part is going to require more work to properly track
hash contexts with resource owners, but this not introduced here.
Still, this refactoring makes the move possible.
This reduces the number of routines for all SHA2 implementations from
twelve (SHA{224,256,386,512} with init, update and final calls) to five
(create, free, init, update and final calls) by incorporating the hash
type directly into the hash context data.
The new cryptohash routines are moved to a new file, called cryptohash.c
for the fallback implementations, with SHA2 specifics becoming a part
internal to src/common/. OpenSSL specifics are part of
cryptohash_openssl.c. This infrastructure is usable for more hash
types, like MD5 or HMAC.
Any code paths using the internal SHA2 routines are adapted to report
correctly errors, which are most of the changes of this commit. The
zones mostly impacted are checksum manifests, libpq and SCRAM.
Note that e21cbb4 was a first attempt to switch SHA2 to EVP, but it
lacked the refactoring needed for libpq, as done here.
This patch has been tested on Linux and Windows, with and without
OpenSSL, and down to 1.0.1, the oldest version supported on HEAD.
Author: Michael Paquier
Reviewed-by: Daniel Gustafsson
Discussion: https://postgr.es/m/20200924025314.GE7405@paquier.xyz
2020-12-02 02:37:20 +01:00
|
|
|
push(@pgcommonallfiles, 'cryptohash.c');
|
Refactor HMAC implementations
Similarly to the cryptohash implementations, this refactors the existing
HMAC code into a single set of APIs that can be plugged with any crypto
libraries PostgreSQL is built with (only OpenSSL currently). If there
is no such libraries, a fallback implementation is available. Those new
APIs are designed similarly to the existing cryptohash layer, so there
is no real new design here, with the same logic around buffer bound
checks and memory handling.
HMAC has a dependency on cryptohashes, so all the cryptohash types
supported by cryptohash{_openssl}.c can be used with HMAC. This
refactoring is an advantage mainly for SCRAM, that included its own
implementation of HMAC with SHA256 without relying on the existing
crypto libraries even if PostgreSQL was built with their support.
This code has been tested on Windows and Linux, with and without
OpenSSL, across all the versions supported on HEAD from 1.1.1 down to
1.0.1. I have also checked that the implementations are working fine
using some sample results, a custom extension of my own, and doing
cross-checks across different major versions with SCRAM with the client
and the backend.
Author: Michael Paquier
Reviewed-by: Bruce Momjian
Discussion: https://postgr.es/m/X9m0nkEJEzIPXjeZ@paquier.xyz
2021-04-03 10:30:49 +02:00
|
|
|
push(@pgcommonallfiles, 'hmac.c');
|
Refactor MD5 implementations according to new cryptohash infrastructure
This commit heavily reorganizes the MD5 implementations that exist in
the tree in various aspects.
First, MD5 is added to the list of options available in cryptohash.c and
cryptohash_openssl.c. This means that if building with OpenSSL, EVP is
used for MD5 instead of the fallback implementation that Postgres had
for ages. With the recent refactoring work for cryptohash functions,
this change is straight-forward. If not building with OpenSSL, a
fallback implementation internal to src/common/ is used.
Second, this reduces the number of MD5 implementations present in the
tree from two to one, by moving the KAME implementation from pgcrypto to
src/common/, and by removing the implementation that existed in
src/common/. KAME was already structured with an init/update/final set
of routines by pgcrypto (see original pgcrypto/md5.h) for compatibility
with OpenSSL, so moving it to src/common/ has proved to be a
straight-forward move, requiring no actual manipulation of the internals
of each routine. Some benchmarking has not shown any performance gap
between both implementations.
Similarly to the fallback implementation used for SHA2, the fallback
implementation of MD5 is moved to src/common/md5.c with an internal
header called md5_int.h for the init, update and final routines. This
gets then consumed by cryptohash.c.
The original routines used for MD5-hashed passwords are moved to a
separate file called md5_common.c, also in src/common/, aimed at being
shared between all MD5 implementations as utility routines to keep
compatibility with any code relying on them.
Like the SHA2 changes, this commit had its round of tests on both Linux
and Windows, across all versions of OpenSSL supported on HEAD, with and
even without OpenSSL.
Author: Michael Paquier
Reviewed-by: Daniel Gustafsson
Discussion: https://postgr.es/m/20201106073434.GA4961@paquier.xyz
2020-12-10 03:59:10 +01:00
|
|
|
push(@pgcommonallfiles, 'md5.c');
|
2021-01-23 03:33:04 +01:00
|
|
|
push(@pgcommonallfiles, 'sha1.c');
|
2017-03-07 13:23:49 +01:00
|
|
|
push(@pgcommonallfiles, 'sha2.c');
|
|
|
|
}
|
|
|
|
|
2015-03-30 23:07:52 +02:00
|
|
|
our @pgcommonfrontendfiles = (
|
2020-09-07 08:11:46 +02:00
|
|
|
@pgcommonallfiles, qw(fe_memutils.c
|
Remove arbitrary restrictions on password length.
This patch started out with the goal of harmonizing various arbitrary
limits on password length, but after awhile a better idea emerged:
let's just get rid of those fixed limits.
recv_password_packet() has an arbitrary limit on the packet size,
which we don't really need, so just drop it. (Note that this doesn't
really affect anything for MD5 or SCRAM password verification, since
those will hash the user's password to something shorter anyway.
It does matter for auth methods that require a cleartext password.)
Likewise remove the arbitrary error condition in pg_saslprep().
The remaining limits are mostly in client-side code that prompts
for passwords. To improve those, refactor simple_prompt() so that
it allocates its own result buffer that can be made as big as
necessary. Actually, it proves best to make a separate routine
pg_get_line() that has essentially the semantics of fgets(), except
that it allocates a suitable result buffer and hence will never
return a truncated line. (pg_get_line has a lot of potential
applications to replace randomly-sized fgets buffers elsewhere,
but I'll leave that for another patch.)
I built pg_get_line() atop stringinfo.c, which requires moving
that code to src/common/; but that seems fine since it was a poor
fit for src/port/ anyway.
This patch is mostly mine, but it owes a good deal to Nathan Bossart
who pressed for a solution to the password length problem and
created a predecessor patch. Also thanks to Peter Eisentraut and
Stephen Frost for ideas and discussion.
Discussion: https://postgr.es/m/09512C4F-8CB9-4021-B455-EF4C4F0D55A0@amazon.com
2020-09-04 02:09:18 +02:00
|
|
|
logging.c restricted_token.c sprompt.c));
|
2013-02-22 02:46:17 +01:00
|
|
|
|
|
|
|
our @pgcommonbkndfiles = @pgcommonallfiles;
|
Create libpgcommon, and move pg_malloc et al to it
libpgcommon is a new static library to allow sharing code among the
various frontend programs and backend; this lets us eliminate duplicate
implementations of common routines. We avoid libpgport, because that's
intended as a place for porting issues; per discussion, it seems better
to keep them separate.
The first use case, and the only implemented by this patch, is pg_malloc
and friends, which many frontend programs were already using.
At the same time, we can use this to provide palloc emulation functions
for the frontend; this way, some palloc-using files in the backend can
also be used by the frontend cleanly. To do this, we change palloc() in
the backend to be a function instead of a macro on top of
MemoryContextAlloc(). This was previously believed to cause loss of
performance, but this implementation has been tweaked by Tom and Andres
so that on modern compilers it provides a slight improvement over the
previous one.
This lets us clean up some places that were already with
localized hacks.
Most of the pg_malloc/palloc changes in this patch were authored by
Andres Freund. Zoltán Böszörményi also independently provided a form of
that. libpgcommon infrastructure was authored by Álvaro.
2013-02-12 14:33:40 +01:00
|
|
|
|
2016-03-24 20:55:44 +01:00
|
|
|
our @pgfeutilsfiles = qw(
|
Move some code from src/bin/scripts to src/fe_utils to permit reuse.
The parallel slots infrastructure (which implements client-side
multiplexing of server connections doing similar things, not
threading or multiple processes or anything like that) are moved from
src/bin/scripts/scripts_parallel.c to src/fe_utils/parallel_slot.c.
The functions consumeQueryResult() and processQueryResult() which were
previously part of src/bin/scripts/common.c are now moved into that
file as well, becoming static helper functions. This might need to be
changed in the future, but currently they're not used for anything
else.
Some other functions from src/bin/scripts/common.c are moved to to
src/fe_utils and are split up among several files. connectDatabase(),
connectMaintenanceDatabase(), and disconnectDatabase() are moved to
connect_utils.c. executeQuery(), executeCommand(), and
executeMaintenanceCommand() are move to query_utils.c.
handle_help_version_opts() is moved to option_utils.c.
Mark Dilger, reviewed by me. The larger patch series of which this is
a part has also had review from Peter Geoghegan, Andres Freund, Álvaro
Herrera, Michael Paquier, and Amul Sul, but I don't know whether any
of them have reviewed this bit specifically.
Discussion: http://postgr.es/m/12ED3DA8-25F0-4B68-937D-D907CFBF08E7@enterprisedb.com
Discussion: http://postgr.es/m/5F743835-3399-419C-8324-2D424237E999@enterprisedb.com
Discussion: http://postgr.es/m/70655DF3-33CE-4527-9A4D-DDEB582B6BA0@enterprisedb.com
2021-02-05 19:33:38 +01:00
|
|
|
archive.c cancel.c conditional.c connect_utils.c mbprint.c option_utils.c
|
|
|
|
parallel_slot.c print.c psqlscan.l psqlscan.c query_utils.c simple_list.c
|
|
|
|
string_utils.c recovery_gen.c);
|
2016-03-24 20:55:44 +01:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
$libpgport = $solution->AddProject('libpgport', 'lib', 'misc');
|
2007-03-17 14:50:42 +01:00
|
|
|
$libpgport->AddDefine('FRONTEND');
|
2015-04-25 14:52:03 +02:00
|
|
|
$libpgport->AddFiles('src/port', @pgportfiles);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
Create libpgcommon, and move pg_malloc et al to it
libpgcommon is a new static library to allow sharing code among the
various frontend programs and backend; this lets us eliminate duplicate
implementations of common routines. We avoid libpgport, because that's
intended as a place for porting issues; per discussion, it seems better
to keep them separate.
The first use case, and the only implemented by this patch, is pg_malloc
and friends, which many frontend programs were already using.
At the same time, we can use this to provide palloc emulation functions
for the frontend; this way, some palloc-using files in the backend can
also be used by the frontend cleanly. To do this, we change palloc() in
the backend to be a function instead of a macro on top of
MemoryContextAlloc(). This was previously believed to cause loss of
performance, but this implementation has been tweaked by Tom and Andres
so that on modern compilers it provides a slight improvement over the
previous one.
This lets us clean up some places that were already with
localized hacks.
Most of the pg_malloc/palloc changes in this patch were authored by
Andres Freund. Zoltán Böszörményi also independently provided a form of
that. libpgcommon infrastructure was authored by Álvaro.
2013-02-12 14:33:40 +01:00
|
|
|
$libpgcommon = $solution->AddProject('libpgcommon', 'lib', 'misc');
|
|
|
|
$libpgcommon->AddDefine('FRONTEND');
|
2015-04-25 14:52:03 +02:00
|
|
|
$libpgcommon->AddFiles('src/common', @pgcommonfrontendfiles);
|
Create libpgcommon, and move pg_malloc et al to it
libpgcommon is a new static library to allow sharing code among the
various frontend programs and backend; this lets us eliminate duplicate
implementations of common routines. We avoid libpgport, because that's
intended as a place for porting issues; per discussion, it seems better
to keep them separate.
The first use case, and the only implemented by this patch, is pg_malloc
and friends, which many frontend programs were already using.
At the same time, we can use this to provide palloc emulation functions
for the frontend; this way, some palloc-using files in the backend can
also be used by the frontend cleanly. To do this, we change palloc() in
the backend to be a function instead of a macro on top of
MemoryContextAlloc(). This was previously believed to cause loss of
performance, but this implementation has been tweaked by Tom and Andres
so that on modern compilers it provides a slight improvement over the
previous one.
This lets us clean up some places that were already with
localized hacks.
Most of the pg_malloc/palloc changes in this patch were authored by
Andres Freund. Zoltán Böszörményi also independently provided a form of
that. libpgcommon infrastructure was authored by Álvaro.
2013-02-12 14:33:40 +01:00
|
|
|
|
2016-03-24 20:55:44 +01:00
|
|
|
$libpgfeutils = $solution->AddProject('libpgfeutils', 'lib', 'misc');
|
|
|
|
$libpgfeutils->AddDefine('FRONTEND');
|
2022-10-06 22:03:31 +02:00
|
|
|
$libpgfeutils->AddDefine('FD_SETSIZE=1024');
|
2016-03-24 22:12:40 +01:00
|
|
|
$libpgfeutils->AddIncludeDir('src/interfaces/libpq');
|
2016-03-24 20:55:44 +01:00
|
|
|
$libpgfeutils->AddFiles('src/fe_utils', @pgfeutilsfiles);
|
|
|
|
|
2015-04-25 14:52:03 +02:00
|
|
|
$postgres = $solution->AddProject('postgres', 'exe', '', 'src/backend');
|
|
|
|
$postgres->AddIncludeDir('src/backend');
|
|
|
|
$postgres->AddDir('src/backend/port/win32');
|
|
|
|
$postgres->AddFile('src/backend/utils/fmgrtab.c');
|
|
|
|
$postgres->ReplaceFile('src/backend/port/pg_sema.c',
|
|
|
|
'src/backend/port/win32_sema.c');
|
|
|
|
$postgres->ReplaceFile('src/backend/port/pg_shmem.c',
|
|
|
|
'src/backend/port/win32_shmem.c');
|
|
|
|
$postgres->AddFiles('src/port', @pgportfiles);
|
|
|
|
$postgres->AddFiles('src/common', @pgcommonbkndfiles);
|
|
|
|
$postgres->AddDir('src/timezone');
|
|
|
|
|
|
|
|
# We need source files from src/timezone, but that directory's resource
|
2014-08-19 04:59:53 +02:00
|
|
|
# file pertains to "zic", not to the backend.
|
2015-04-25 14:52:03 +02:00
|
|
|
$postgres->RemoveFile('src/timezone/win32ver.rc');
|
|
|
|
$postgres->AddFiles('src/backend/parser', 'scan.l', 'gram.y');
|
|
|
|
$postgres->AddFiles('src/backend/bootstrap', 'bootscanner.l',
|
2012-07-05 03:47:49 +02:00
|
|
|
'bootparse.y');
|
2015-04-25 14:52:03 +02:00
|
|
|
$postgres->AddFiles('src/backend/utils/misc', 'guc-file.l');
|
|
|
|
$postgres->AddFiles(
|
|
|
|
'src/backend/replication', 'repl_scanner.l',
|
Support multiple synchronous standby servers.
Previously synchronous replication offered only the ability to confirm
that all changes made by a transaction had been transferred to at most
one synchronous standby server.
This commit extends synchronous replication so that it supports multiple
synchronous standby servers. It enables users to consider one or more
standby servers as synchronous, and increase the level of transaction
durability by ensuring that transaction commits wait for replies from
all of those synchronous standbys.
Multiple synchronous standby servers are configured in
synchronous_standby_names which is extended to support new syntax of
'num_sync ( standby_name [ , ... ] )', where num_sync specifies
the number of synchronous standbys that transaction commits need to
wait for replies from and standby_name is the name of a standby
server.
The syntax of 'standby_name [ , ... ]' which was used in 9.5 or before
is also still supported. It's the same as new syntax with num_sync=1.
This commit doesn't include "quorum commit" feature which was discussed
in pgsql-hackers. Synchronous standbys are chosen based on their priorities.
synchronous_standby_names determines the priority of each standby for
being chosen as a synchronous standby. The standbys whose names appear
earlier in the list are given higher priority and will be considered as
synchronous. Other standby servers appearing later in this list
represent potential synchronous standbys.
The regression test for multiple synchronous standbys is not included
in this commit. It should come later.
Authors: Sawada Masahiko, Beena Emerson, Michael Paquier, Fujii Masao
Reviewed-By: Kyotaro Horiguchi, Amit Kapila, Robert Haas, Simon Riggs,
Amit Langote, Thomas Munro, Sameer Thakur, Suraj Kharage, Abhijit Menon-Sen,
Rajeev Rastogi
Many thanks to the various individuals who were involved in
discussing and developing this feature.
2016-04-06 10:18:25 +02:00
|
|
|
'repl_gram.y', 'syncrep_scanner.l',
|
|
|
|
'syncrep_gram.y');
|
Partial implementation of SQL/JSON path language
SQL 2016 standards among other things contains set of SQL/JSON features for
JSON processing inside of relational database. The core of SQL/JSON is JSON
path language, allowing access parts of JSON documents and make computations
over them. This commit implements partial support JSON path language as
separate datatype called "jsonpath". The implementation is partial because
it's lacking datetime support and suppression of numeric errors. Missing
features will be added later by separate commits.
Support of SQL/JSON features requires implementation of separate nodes, and it
will be considered in subsequent patches. This commit includes following
set of plain functions, allowing to execute jsonpath over jsonb values:
* jsonb_path_exists(jsonb, jsonpath[, jsonb, bool]),
* jsonb_path_match(jsonb, jsonpath[, jsonb, bool]),
* jsonb_path_query(jsonb, jsonpath[, jsonb, bool]),
* jsonb_path_query_array(jsonb, jsonpath[, jsonb, bool]).
* jsonb_path_query_first(jsonb, jsonpath[, jsonb, bool]).
This commit also implements "jsonb @? jsonpath" and "jsonb @@ jsonpath", which
are wrappers over jsonpath_exists(jsonb, jsonpath) and jsonpath_predicate(jsonb,
jsonpath) correspondingly. These operators will have an index support
(implemented in subsequent patches).
Catversion bumped, to add new functions and operators.
Code was written by Nikita Glukhov and Teodor Sigaev, revised by me.
Documentation was written by Oleg Bartunov and Liudmila Mantrova. The work
was inspired by Oleg Bartunov.
Discussion: https://postgr.es/m/fcc6fc6a-b497-f39a-923d-aa34d0c588e8%402ndQuadrant.com
Author: Nikita Glukhov, Teodor Sigaev, Alexander Korotkov, Oleg Bartunov, Liudmila Mantrova
Reviewed-by: Tomas Vondra, Andrew Dunstan, Pavel Stehule, Alexander Korotkov
2019-03-16 10:15:37 +01:00
|
|
|
$postgres->AddFiles('src/backend/utils/adt', 'jsonpath_scan.l',
|
|
|
|
'jsonpath_gram.y');
|
2007-03-17 14:50:42 +01:00
|
|
|
$postgres->AddDefine('BUILDING_DLL');
|
2008-02-05 15:17:23 +01:00
|
|
|
$postgres->AddLibrary('secur32.lib');
|
2014-07-15 14:18:39 +02:00
|
|
|
$postgres->AddLibrary('ws2_32.lib');
|
2007-03-17 14:50:42 +01:00
|
|
|
$postgres->AddLibrary('wldap32.lib') if ($solution->{options}->{ldap});
|
|
|
|
$postgres->FullExportDLL('postgres.lib');
|
2015-03-11 14:21:01 +01:00
|
|
|
|
2018-09-28 21:17:07 +02:00
|
|
|
# The OBJS scraper doesn't know about ifdefs, so remove appropriate files
|
|
|
|
# if building without OpenSSL.
|
Break out OpenSSL-specific code to separate files.
This refactoring is in preparation for adding support for other SSL
implementations, with no user-visible effects. There are now two #defines,
USE_OPENSSL which is defined when building with OpenSSL, and USE_SSL which
is defined when building with any SSL implementation. Currently, OpenSSL is
the only implementation so the two #defines go together, but USE_SSL is
supposed to be used for implementation-independent code.
The libpq SSL code is changed to use a custom BIO, which does all the raw
I/O, like we've been doing in the backend for a long time. That makes it
possible to use MSG_NOSIGNAL to block SIGPIPE when using SSL, which avoids
a couple of syscall for each send(). Probably doesn't make much performance
difference in practice - the SSL encryption is expensive enough to mask the
effect - but it was a natural result of this refactoring.
Based on a patch by Martijn van Oosterhout from 2006. Briefly reviewed by
Alvaro Herrera, Andreas Karlsson, Jeff Janes.
2014-08-11 10:54:19 +02:00
|
|
|
if (!$solution->{options}->{openssl})
|
|
|
|
{
|
2018-02-26 19:28:38 +01:00
|
|
|
$postgres->RemoveFile('src/backend/libpq/be-secure-common.c');
|
2015-04-25 14:52:03 +02:00
|
|
|
$postgres->RemoveFile('src/backend/libpq/be-secure-openssl.c');
|
Break out OpenSSL-specific code to separate files.
This refactoring is in preparation for adding support for other SSL
implementations, with no user-visible effects. There are now two #defines,
USE_OPENSSL which is defined when building with OpenSSL, and USE_SSL which
is defined when building with any SSL implementation. Currently, OpenSSL is
the only implementation so the two #defines go together, but USE_SSL is
supposed to be used for implementation-independent code.
The libpq SSL code is changed to use a custom BIO, which does all the raw
I/O, like we've been doing in the backend for a long time. That makes it
possible to use MSG_NOSIGNAL to block SIGPIPE when using SSL, which avoids
a couple of syscall for each send(). Probably doesn't make much performance
difference in practice - the SSL encryption is expensive enough to mask the
effect - but it was a natural result of this refactoring.
Based on a patch by Martijn van Oosterhout from 2006. Briefly reviewed by
Alvaro Herrera, Andreas Karlsson, Jeff Janes.
2014-08-11 10:54:19 +02:00
|
|
|
}
|
GSSAPI encryption support
On both the frontend and backend, prepare for GSSAPI encryption
support by moving common code for error handling into a separate file.
Fix a TODO for handling multiple status messages in the process.
Eliminate the OIDs, which have not been needed for some time.
Add frontend and backend encryption support functions. Keep the
context initiation for authentication-only separate on both the
frontend and backend in order to avoid concerns about changing the
requested flags to include encryption support.
In postmaster, pull GSSAPI authorization checking into a shared
function. Also share the initiator name between the encryption and
non-encryption codepaths.
For HBA, add "hostgssenc" and "hostnogssenc" entries that behave
similarly to their SSL counterparts. "hostgssenc" requires either
"gss", "trust", or "reject" for its authentication.
Similarly, add a "gssencmode" parameter to libpq. Supported values are
"disable", "require", and "prefer". Notably, negotiation will only be
attempted if credentials can be acquired. Move credential acquisition
into its own function to support this behavior.
Add a simple pg_stat_gssapi view similar to pg_stat_ssl, for monitoring
if GSSAPI authentication was used, what principal was used, and if
encryption is being used on the connection.
Finally, add documentation for everything new, and update existing
documentation on connection security.
Thanks to Michael Paquier for the Windows fixes.
Author: Robbie Harwood, with changes to the read/write functions by me.
Reviewed in various forms and at different times by: Michael Paquier,
Andres Freund, David Steele.
Discussion: https://www.postgresql.org/message-id/flat/jlg1tgq1ktm.fsf@thriss.redhat.com
2019-04-03 21:02:33 +02:00
|
|
|
if (!$solution->{options}->{gss})
|
|
|
|
{
|
|
|
|
$postgres->RemoveFile('src/backend/libpq/be-gssapi-common.c');
|
|
|
|
$postgres->RemoveFile('src/backend/libpq/be-secure-gssapi.c');
|
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $snowball = $solution->AddProject('dict_snowball', 'dll', '',
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/backend/snowball');
|
2015-03-11 14:21:01 +01:00
|
|
|
|
2014-08-19 04:59:53 +02:00
|
|
|
# This Makefile uses VPATH to find most source files in a subdirectory.
|
2010-04-09 15:05:58 +02:00
|
|
|
$snowball->RelocateFiles(
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/backend/snowball/libstemmer',
|
2010-04-09 15:05:58 +02:00
|
|
|
sub {
|
2014-08-19 04:59:53 +02:00
|
|
|
return shift !~ /(dict_snowball.c|win32ver.rc)$/;
|
2012-07-05 03:47:49 +02:00
|
|
|
});
|
2015-04-25 14:52:03 +02:00
|
|
|
$snowball->AddIncludeDir('src/include/snowball');
|
2007-08-21 17:10:41 +02:00
|
|
|
$snowball->AddReference($postgres);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $plpgsql =
|
2015-04-25 14:52:03 +02:00
|
|
|
$solution->AddProject('plpgsql', 'dll', 'PLs', 'src/pl/plpgsql/src');
|
|
|
|
$plpgsql->AddFiles('src/pl/plpgsql/src', 'pl_gram.y');
|
2007-03-17 14:50:42 +01:00
|
|
|
$plpgsql->AddReference($postgres);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
if ($solution->{options}->{tcl})
|
|
|
|
{
|
2017-05-05 17:05:34 +02:00
|
|
|
my $found = 0;
|
2012-07-05 03:47:49 +02:00
|
|
|
my $pltcl =
|
2015-04-25 14:52:03 +02:00
|
|
|
$solution->AddProject('pltcl', 'dll', 'PLs', 'src/pl/tcl');
|
|
|
|
$pltcl->AddIncludeDir($solution->{options}->{tcl} . '/include');
|
2007-03-17 14:50:42 +01:00
|
|
|
$pltcl->AddReference($postgres);
|
2017-05-05 17:05:34 +02:00
|
|
|
|
2017-07-24 08:53:27 +02:00
|
|
|
for my $tclver (qw(86t 86 85 84))
|
2009-04-07 21:35:57 +02:00
|
|
|
{
|
2017-05-05 17:05:34 +02:00
|
|
|
my $tcllib = $solution->{options}->{tcl} . "/lib/tcl$tclver.lib";
|
|
|
|
if (-e $tcllib)
|
|
|
|
{
|
|
|
|
$pltcl->AddLibrary($tcllib);
|
|
|
|
$found = 1;
|
|
|
|
last;
|
|
|
|
}
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
2017-05-05 17:05:34 +02:00
|
|
|
die "Unable to find $solution->{options}->{tcl}/lib/tcl<version>.lib"
|
|
|
|
unless $found;
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
$libpq = $solution->AddProject('libpq', 'dll', 'interfaces',
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/interfaces/libpq');
|
|
|
|
$libpq->AddIncludeDir('src/port');
|
2007-07-23 12:16:54 +02:00
|
|
|
$libpq->AddLibrary('secur32.lib');
|
2009-10-01 03:58:58 +02:00
|
|
|
$libpq->AddLibrary('ws2_32.lib');
|
2007-03-17 14:50:42 +01:00
|
|
|
$libpq->AddLibrary('wldap32.lib') if ($solution->{options}->{ldap});
|
2015-04-25 14:52:03 +02:00
|
|
|
$libpq->UseDef('src/interfaces/libpq/libpqdll.def');
|
2018-09-28 21:49:05 +02:00
|
|
|
$libpq->AddReference($libpgcommon, $libpgport);
|
2015-03-11 14:21:01 +01:00
|
|
|
|
2018-09-28 21:17:07 +02:00
|
|
|
# The OBJS scraper doesn't know about ifdefs, so remove appropriate files
|
|
|
|
# if building without OpenSSL.
|
Break out OpenSSL-specific code to separate files.
This refactoring is in preparation for adding support for other SSL
implementations, with no user-visible effects. There are now two #defines,
USE_OPENSSL which is defined when building with OpenSSL, and USE_SSL which
is defined when building with any SSL implementation. Currently, OpenSSL is
the only implementation so the two #defines go together, but USE_SSL is
supposed to be used for implementation-independent code.
The libpq SSL code is changed to use a custom BIO, which does all the raw
I/O, like we've been doing in the backend for a long time. That makes it
possible to use MSG_NOSIGNAL to block SIGPIPE when using SSL, which avoids
a couple of syscall for each send(). Probably doesn't make much performance
difference in practice - the SSL encryption is expensive enough to mask the
effect - but it was a natural result of this refactoring.
Based on a patch by Martijn van Oosterhout from 2006. Briefly reviewed by
Alvaro Herrera, Andreas Karlsson, Jeff Janes.
2014-08-11 10:54:19 +02:00
|
|
|
if (!$solution->{options}->{openssl})
|
|
|
|
{
|
2018-01-27 19:47:52 +01:00
|
|
|
$libpq->RemoveFile('src/interfaces/libpq/fe-secure-common.c');
|
2015-04-25 14:52:03 +02:00
|
|
|
$libpq->RemoveFile('src/interfaces/libpq/fe-secure-openssl.c');
|
Break out OpenSSL-specific code to separate files.
This refactoring is in preparation for adding support for other SSL
implementations, with no user-visible effects. There are now two #defines,
USE_OPENSSL which is defined when building with OpenSSL, and USE_SSL which
is defined when building with any SSL implementation. Currently, OpenSSL is
the only implementation so the two #defines go together, but USE_SSL is
supposed to be used for implementation-independent code.
The libpq SSL code is changed to use a custom BIO, which does all the raw
I/O, like we've been doing in the backend for a long time. That makes it
possible to use MSG_NOSIGNAL to block SIGPIPE when using SSL, which avoids
a couple of syscall for each send(). Probably doesn't make much performance
difference in practice - the SSL encryption is expensive enough to mask the
effect - but it was a natural result of this refactoring.
Based on a patch by Martijn van Oosterhout from 2006. Briefly reviewed by
Alvaro Herrera, Andreas Karlsson, Jeff Janes.
2014-08-11 10:54:19 +02:00
|
|
|
}
|
GSSAPI encryption support
On both the frontend and backend, prepare for GSSAPI encryption
support by moving common code for error handling into a separate file.
Fix a TODO for handling multiple status messages in the process.
Eliminate the OIDs, which have not been needed for some time.
Add frontend and backend encryption support functions. Keep the
context initiation for authentication-only separate on both the
frontend and backend in order to avoid concerns about changing the
requested flags to include encryption support.
In postmaster, pull GSSAPI authorization checking into a shared
function. Also share the initiator name between the encryption and
non-encryption codepaths.
For HBA, add "hostgssenc" and "hostnogssenc" entries that behave
similarly to their SSL counterparts. "hostgssenc" requires either
"gss", "trust", or "reject" for its authentication.
Similarly, add a "gssencmode" parameter to libpq. Supported values are
"disable", "require", and "prefer". Notably, negotiation will only be
attempted if credentials can be acquired. Move credential acquisition
into its own function to support this behavior.
Add a simple pg_stat_gssapi view similar to pg_stat_ssl, for monitoring
if GSSAPI authentication was used, what principal was used, and if
encryption is being used on the connection.
Finally, add documentation for everything new, and update existing
documentation on connection security.
Thanks to Michael Paquier for the Windows fixes.
Author: Robbie Harwood, with changes to the read/write functions by me.
Reviewed in various forms and at different times by: Michael Paquier,
Andres Freund, David Steele.
Discussion: https://www.postgresql.org/message-id/flat/jlg1tgq1ktm.fsf@thriss.redhat.com
2019-04-03 21:02:33 +02:00
|
|
|
if (!$solution->{options}->{gss})
|
|
|
|
{
|
|
|
|
$libpq->RemoveFile('src/interfaces/libpq/fe-gssapi-common.c');
|
|
|
|
$libpq->RemoveFile('src/interfaces/libpq/fe-secure-gssapi.c');
|
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $libpqwalreceiver =
|
|
|
|
$solution->AddProject('libpqwalreceiver', 'dll', '',
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/backend/replication/libpqwalreceiver');
|
|
|
|
$libpqwalreceiver->AddIncludeDir('src/interfaces/libpq');
|
2012-07-05 03:47:49 +02:00
|
|
|
$libpqwalreceiver->AddReference($postgres, $libpq);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2022-04-16 15:35:15 +02:00
|
|
|
my $libpq_testclient =
|
2022-05-04 14:15:25 +02:00
|
|
|
$solution->AddProject('libpq_testclient', 'exe', 'misc',
|
2022-04-16 15:35:15 +02:00
|
|
|
'src/interfaces/libpq/test');
|
2022-05-04 14:15:25 +02:00
|
|
|
$libpq_testclient->AddFile(
|
|
|
|
'src/interfaces/libpq/test/libpq_testclient.c');
|
2022-04-16 15:35:15 +02:00
|
|
|
$libpq_testclient->AddIncludeDir('src/interfaces/libpq');
|
|
|
|
$libpq_testclient->AddReference($libpgport, $libpq);
|
|
|
|
$libpq_testclient->AddLibrary('ws2_32.lib');
|
|
|
|
|
|
|
|
my $libpq_uri_regress =
|
2022-05-04 14:15:25 +02:00
|
|
|
$solution->AddProject('libpq_uri_regress', 'exe', 'misc',
|
2022-04-16 15:35:15 +02:00
|
|
|
'src/interfaces/libpq/test');
|
2022-05-04 14:15:25 +02:00
|
|
|
$libpq_uri_regress->AddFile(
|
|
|
|
'src/interfaces/libpq/test/libpq_uri_regress.c');
|
2022-04-16 15:35:15 +02:00
|
|
|
$libpq_uri_regress->AddIncludeDir('src/interfaces/libpq');
|
|
|
|
$libpq_uri_regress->AddReference($libpgport, $libpq);
|
|
|
|
$libpq_uri_regress->AddLibrary('ws2_32.lib');
|
|
|
|
|
2017-05-05 12:08:48 +02:00
|
|
|
my $pgoutput = $solution->AddProject('pgoutput', 'dll', '',
|
|
|
|
'src/backend/replication/pgoutput');
|
|
|
|
$pgoutput->AddReference($postgres);
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $pgtypes = $solution->AddProject(
|
|
|
|
'libpgtypes', 'dll',
|
2015-04-25 14:52:03 +02:00
|
|
|
'interfaces', 'src/interfaces/ecpg/pgtypeslib');
|
2018-09-28 21:49:05 +02:00
|
|
|
$pgtypes->AddReference($libpgcommon, $libpgport);
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgtypes->UseDef('src/interfaces/ecpg/pgtypeslib/pgtypeslib.def');
|
|
|
|
$pgtypes->AddIncludeDir('src/interfaces/ecpg/include');
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $libecpg = $solution->AddProject('libecpg', 'dll', 'interfaces',
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/interfaces/ecpg/ecpglib');
|
|
|
|
$libecpg->AddIncludeDir('src/interfaces/ecpg/include');
|
|
|
|
$libecpg->AddIncludeDir('src/interfaces/libpq');
|
|
|
|
$libecpg->AddIncludeDir('src/port');
|
|
|
|
$libecpg->UseDef('src/interfaces/ecpg/ecpglib/ecpglib.def');
|
2014-07-15 14:18:39 +02:00
|
|
|
$libecpg->AddLibrary('ws2_32.lib');
|
2012-07-05 03:47:49 +02:00
|
|
|
$libecpg->AddReference($libpq, $pgtypes, $libpgport);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $libecpgcompat = $solution->AddProject(
|
|
|
|
'libecpg_compat', 'dll',
|
2015-04-25 14:52:03 +02:00
|
|
|
'interfaces', 'src/interfaces/ecpg/compatlib');
|
|
|
|
$libecpgcompat->AddIncludeDir('src/interfaces/ecpg/include');
|
|
|
|
$libecpgcompat->AddIncludeDir('src/interfaces/libpq');
|
|
|
|
$libecpgcompat->UseDef('src/interfaces/ecpg/compatlib/compatlib.def');
|
2019-12-05 00:15:11 +01:00
|
|
|
$libecpgcompat->AddReference($pgtypes, $libecpg, $libpgport,
|
|
|
|
$libpgcommon);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $ecpg = $solution->AddProject('ecpg', 'exe', 'interfaces',
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/interfaces/ecpg/preproc');
|
|
|
|
$ecpg->AddIncludeDir('src/interfaces/ecpg/include');
|
2018-12-01 23:19:51 +01:00
|
|
|
$ecpg->AddIncludeDir('src/interfaces/ecpg/ecpglib');
|
2015-04-25 14:52:03 +02:00
|
|
|
$ecpg->AddIncludeDir('src/interfaces/libpq');
|
|
|
|
$ecpg->AddPrefixInclude('src/interfaces/ecpg/preproc');
|
|
|
|
$ecpg->AddFiles('src/interfaces/ecpg/preproc', 'pgc.l', 'preproc.y');
|
2013-10-18 14:15:20 +02:00
|
|
|
$ecpg->AddReference($libpgcommon, $libpgport);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $pgregress_ecpg =
|
|
|
|
$solution->AddProject('pg_regress_ecpg', 'exe', 'misc');
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgregress_ecpg->AddFile('src/interfaces/ecpg/test/pg_regress_ecpg.c');
|
|
|
|
$pgregress_ecpg->AddFile('src/test/regress/pg_regress.c');
|
|
|
|
$pgregress_ecpg->AddIncludeDir('src/port');
|
|
|
|
$pgregress_ecpg->AddIncludeDir('src/test/regress');
|
2023-10-25 04:37:37 +02:00
|
|
|
$pgregress_ecpg->AddIncludeDir('src/interfaces/libpq');
|
2007-06-12 13:07:34 +02:00
|
|
|
$pgregress_ecpg->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
|
2014-12-25 19:52:03 +01:00
|
|
|
$pgregress_ecpg->AddLibrary('ws2_32.lib');
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgregress_ecpg->AddDirResourceFile('src/interfaces/ecpg/test');
|
2023-10-25 04:37:37 +02:00
|
|
|
$pgregress_ecpg->AddReference($libpq, $libpgcommon, $libpgport);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $isolation_tester =
|
|
|
|
$solution->AddProject('isolationtester', 'exe', 'misc');
|
2015-04-25 14:52:03 +02:00
|
|
|
$isolation_tester->AddFile('src/test/isolation/isolationtester.c');
|
|
|
|
$isolation_tester->AddFile('src/test/isolation/specparse.y');
|
|
|
|
$isolation_tester->AddFile('src/test/isolation/specscanner.l');
|
|
|
|
$isolation_tester->AddFile('src/test/isolation/specparse.c');
|
2022-09-04 11:49:00 +02:00
|
|
|
$isolation_tester->AddFile('src/test/isolation/specscanner.c');
|
2015-04-25 14:52:03 +02:00
|
|
|
$isolation_tester->AddIncludeDir('src/test/isolation');
|
|
|
|
$isolation_tester->AddIncludeDir('src/port');
|
|
|
|
$isolation_tester->AddIncludeDir('src/test/regress');
|
|
|
|
$isolation_tester->AddIncludeDir('src/interfaces/libpq');
|
2011-05-15 23:55:05 +02:00
|
|
|
$isolation_tester->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
|
2014-07-15 14:18:39 +02:00
|
|
|
$isolation_tester->AddLibrary('ws2_32.lib');
|
2015-04-25 14:52:03 +02:00
|
|
|
$isolation_tester->AddDirResourceFile('src/test/isolation');
|
2013-10-18 15:54:41 +02:00
|
|
|
$isolation_tester->AddReference($libpq, $libpgcommon, $libpgport);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $pgregress_isolation =
|
|
|
|
$solution->AddProject('pg_isolation_regress', 'exe', 'misc');
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgregress_isolation->AddFile('src/test/isolation/isolation_main.c');
|
|
|
|
$pgregress_isolation->AddFile('src/test/regress/pg_regress.c');
|
|
|
|
$pgregress_isolation->AddIncludeDir('src/port');
|
|
|
|
$pgregress_isolation->AddIncludeDir('src/test/regress');
|
2023-10-25 04:37:37 +02:00
|
|
|
$pgregress_isolation->AddIncludeDir('src/interfaces/libpq');
|
2011-05-15 23:55:05 +02:00
|
|
|
$pgregress_isolation->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
|
2014-12-25 19:52:03 +01:00
|
|
|
$pgregress_isolation->AddLibrary('ws2_32.lib');
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgregress_isolation->AddDirResourceFile('src/test/isolation');
|
2023-10-25 04:37:37 +02:00
|
|
|
$pgregress_isolation->AddReference($libpq, $libpgcommon, $libpgport);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
# src/bin
|
2015-03-11 14:21:01 +01:00
|
|
|
my $D;
|
|
|
|
opendir($D, 'src/bin') || croak "Could not opendir on src/bin!\n";
|
|
|
|
while (my $d = readdir($D))
|
|
|
|
{
|
|
|
|
next if ($d =~ /^\./);
|
|
|
|
next unless (-f "src/bin/$d/Makefile");
|
|
|
|
next if (grep { /^$d$/ } @frontend_excludes);
|
|
|
|
AddSimpleFrontend($d);
|
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2011-01-23 12:21:23 +01:00
|
|
|
my $pgbasebackup = AddSimpleFrontend('pg_basebackup', 1);
|
2021-11-06 17:12:32 +01:00
|
|
|
# This list of files has to match BBOBJS in pg_basebackup's Makefile.
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgbasebackup->AddFile('src/bin/pg_basebackup/pg_basebackup.c');
|
2021-11-06 17:12:32 +01:00
|
|
|
$pgbasebackup->AddFile('src/bin/pg_basebackup/bbstreamer_file.c');
|
2022-01-28 22:15:58 +01:00
|
|
|
$pgbasebackup->AddFile('src/bin/pg_basebackup/bbstreamer_gzip.c');
|
2021-11-06 17:12:32 +01:00
|
|
|
$pgbasebackup->AddFile('src/bin/pg_basebackup/bbstreamer_inject.c');
|
2022-02-11 15:41:42 +01:00
|
|
|
$pgbasebackup->AddFile('src/bin/pg_basebackup/bbstreamer_lz4.c');
|
2021-11-06 17:12:32 +01:00
|
|
|
$pgbasebackup->AddFile('src/bin/pg_basebackup/bbstreamer_tar.c');
|
2022-12-28 14:20:53 +01:00
|
|
|
$pgbasebackup->AddFile('src/bin/pg_basebackup/bbstreamer_zstd.c');
|
2011-10-26 20:13:33 +02:00
|
|
|
$pgbasebackup->AddLibrary('ws2_32.lib');
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2017-02-09 22:23:46 +01:00
|
|
|
my $pgreceivewal = AddSimpleFrontend('pg_basebackup', 1);
|
|
|
|
$pgreceivewal->{name} = 'pg_receivewal';
|
|
|
|
$pgreceivewal->AddFile('src/bin/pg_basebackup/pg_receivewal.c');
|
|
|
|
$pgreceivewal->AddLibrary('ws2_32.lib');
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2014-04-24 09:30:44 +02:00
|
|
|
my $pgrecvlogical = AddSimpleFrontend('pg_basebackup', 1);
|
|
|
|
$pgrecvlogical->{name} = 'pg_recvlogical';
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgrecvlogical->AddFile('src/bin/pg_basebackup/pg_recvlogical.c');
|
2014-04-24 09:30:44 +02:00
|
|
|
$pgrecvlogical->AddLibrary('ws2_32.lib');
|
|
|
|
|
2015-03-23 18:47:52 +01:00
|
|
|
my $pgrewind = AddSimpleFrontend('pg_rewind', 1);
|
|
|
|
$pgrewind->{name} = 'pg_rewind';
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgrewind->AddFile('src/backend/access/transam/xlogreader.c');
|
2015-03-23 18:47:52 +01:00
|
|
|
$pgrewind->AddLibrary('ws2_32.lib');
|
2015-03-23 19:25:35 +01:00
|
|
|
$pgrewind->AddDefine('FRONTEND');
|
2015-03-23 18:47:52 +01:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $pgevent = $solution->AddProject('pgevent', 'dll', 'bin');
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgevent->AddFiles('src/bin/pgevent', 'pgevent.c', 'pgmsgevent.rc');
|
|
|
|
$pgevent->AddResourceFile('src/bin/pgevent', 'Eventlog message formatter',
|
2014-07-14 20:07:41 +02:00
|
|
|
'win32');
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgevent->UseDef('src/bin/pgevent/pgevent.def');
|
2007-03-17 14:50:42 +01:00
|
|
|
$pgevent->DisableLinkerWarnings('4104');
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
my $pgdump = AddSimpleFrontend('pg_dump', 1);
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgdump->AddIncludeDir('src/backend');
|
|
|
|
$pgdump->AddFile('src/bin/pg_dump/pg_dump.c');
|
|
|
|
$pgdump->AddFile('src/bin/pg_dump/common.c');
|
|
|
|
$pgdump->AddFile('src/bin/pg_dump/pg_dump_sort.c');
|
2013-03-24 16:27:20 +01:00
|
|
|
$pgdump->AddLibrary('ws2_32.lib');
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
my $pgdumpall = AddSimpleFrontend('pg_dump', 1);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-01-03 14:44:26 +01:00
|
|
|
# pg_dumpall doesn't use the files in the Makefile's $(OBJS), unlike
|
|
|
|
# pg_dump and pg_restore.
|
|
|
|
# So remove their sources from the object, keeping the other setup that
|
|
|
|
# AddSimpleFrontend() has done.
|
2015-04-25 14:52:03 +02:00
|
|
|
my @nodumpall = grep { m!src/bin/pg_dump/.*\.c$! }
|
2012-07-05 03:47:49 +02:00
|
|
|
keys %{ $pgdumpall->{files} };
|
|
|
|
delete @{ $pgdumpall->{files} }{@nodumpall};
|
2007-03-17 14:50:42 +01:00
|
|
|
$pgdumpall->{name} = 'pg_dumpall';
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgdumpall->AddIncludeDir('src/backend');
|
|
|
|
$pgdumpall->AddFile('src/bin/pg_dump/pg_dumpall.c');
|
|
|
|
$pgdumpall->AddFile('src/bin/pg_dump/dumputils.c');
|
Read include/exclude commands for dump/restore from file
When there is a need to filter multiple tables with include and/or exclude
options it's quite possible to run into the limitations of the commandline.
This adds a --filter=FILENAME feature to pg_dump, pg_dumpall and pg_restore
which is used to supply a file containing object exclude/include commands
which work just like their commandline counterparts. The format of the file
is one command per row like:
<command> <object> <objectpattern>
<command> can be "include" or "exclude", <object> can be table_data, index
table_data_and_children, database, extension, foreign_data, function, table
schema, table_and_children or trigger.
This patch has gone through many revisions and design changes over a long
period of time, the list of reviewers reflect reviewers of some version of
the patch, not necessarily the final version.
Patch by Pavel Stehule with some additional hacking by me.
Author: Pavel Stehule <pavel.stehule@gmail.com>
Reviewed-by: Justin Pryzby <pryzby@telsasoft.com>
Reviewed-by: vignesh C <vignesh21@gmail.com>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Reviewed-by: Tomas Vondra <tomas.vondra@enterprisedb.com>
Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>
Reviewed-by: Erik Rijkers <er@xs4all.nl>
Discussion: https://postgr.es/m/CAFj8pRB10wvW0CC9Xq=1XDs=zCQxer3cbLcNZa+qiX4cUH-G_A@mail.gmail.com
2023-11-29 14:56:24 +01:00
|
|
|
$pgdumpall->AddFile('src/bin/pg_dump/filter.c');
|
2013-03-24 16:27:20 +01:00
|
|
|
$pgdumpall->AddLibrary('ws2_32.lib');
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
my $pgrestore = AddSimpleFrontend('pg_dump', 1);
|
|
|
|
$pgrestore->{name} = 'pg_restore';
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgrestore->AddIncludeDir('src/backend');
|
|
|
|
$pgrestore->AddFile('src/bin/pg_dump/pg_restore.c');
|
2013-03-24 16:27:20 +01:00
|
|
|
$pgrestore->AddLibrary('ws2_32.lib');
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $zic = $solution->AddProject('zic', 'exe', 'utils');
|
2016-03-28 22:02:07 +02:00
|
|
|
$zic->AddFiles('src/timezone', 'zic.c');
|
2015-04-25 14:52:03 +02:00
|
|
|
$zic->AddDirResourceFile('src/timezone');
|
2013-10-18 14:15:20 +02:00
|
|
|
$zic->AddReference($libpgcommon, $libpgport);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2016-09-11 18:46:55 +02:00
|
|
|
if (!$solution->{options}->{xml})
|
2007-03-17 14:50:42 +01:00
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
push @contrib_excludes, 'xml2';
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
if (!$solution->{options}->{openssl})
|
|
|
|
{
|
2021-11-05 13:59:42 +01:00
|
|
|
push @contrib_excludes, 'sslinfo', 'ssl_passphrase_callback',
|
|
|
|
'pgcrypto';
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2023-03-15 23:30:22 +01:00
|
|
|
if (!$solution->{options}->{ldap})
|
|
|
|
{
|
|
|
|
push @contrib_excludes, 'ldap_password_func';
|
|
|
|
}
|
|
|
|
|
2016-09-11 18:46:55 +02:00
|
|
|
if (!$solution->{options}->{uuid})
|
2008-02-28 13:17:59 +01:00
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
push @contrib_excludes, 'uuid-ossp';
|
2008-02-28 13:17:59 +01:00
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2015-04-16 20:17:26 +02:00
|
|
|
foreach my $subdir ('contrib', 'src/test/modules')
|
2007-03-17 14:50:42 +01:00
|
|
|
{
|
2015-04-16 20:17:26 +02:00
|
|
|
opendir($D, $subdir) || croak "Could not opendir on $subdir!\n";
|
|
|
|
while (my $d = readdir($D))
|
|
|
|
{
|
|
|
|
next if ($d =~ /^\./);
|
|
|
|
next unless (-f "$subdir/$d/Makefile");
|
|
|
|
next if (grep { /^$d$/ } @contrib_excludes);
|
|
|
|
AddContrib($subdir, $d);
|
|
|
|
}
|
|
|
|
closedir($D);
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2015-04-28 17:47:08 +02:00
|
|
|
# Build Perl and Python modules after contrib/ modules to satisfy some
|
|
|
|
# dependencies with transform contrib modules, like hstore_plpython
|
|
|
|
# ltree_plpython and hstore_plperl.
|
|
|
|
if ($solution->{options}->{python})
|
|
|
|
{
|
2015-05-24 03:35:49 +02:00
|
|
|
|
2015-04-28 17:47:08 +02:00
|
|
|
# Attempt to get python version and location.
|
|
|
|
# Assume python.exe in specified dir.
|
|
|
|
my $pythonprog = "import sys;print(sys.prefix);"
|
|
|
|
. "print(str(sys.version_info[0])+str(sys.version_info[1]))";
|
|
|
|
my $prefixcmd =
|
2020-05-06 14:08:15 +02:00
|
|
|
qq("$solution->{options}->{python}\\python" -c "$pythonprog");
|
2015-04-28 17:47:08 +02:00
|
|
|
my $pyout = `$prefixcmd`;
|
|
|
|
die "Could not query for python version!\n" if $?;
|
|
|
|
my ($pyprefix, $pyver) = split(/\r?\n/, $pyout);
|
|
|
|
|
|
|
|
# Sometimes (always?) if python is not present, the execution
|
|
|
|
# appears to work, but gives no data...
|
|
|
|
die "Failed to query python for version information\n"
|
|
|
|
if (!(defined($pyprefix) && defined($pyver)));
|
|
|
|
|
|
|
|
my $pymajorver = substr($pyver, 0, 1);
|
2022-02-17 07:47:35 +01:00
|
|
|
|
|
|
|
die
|
|
|
|
"Python version $pyver is too old (version 3 or later is required)"
|
|
|
|
if int($pymajorver) < 3;
|
|
|
|
|
2015-04-28 17:47:08 +02:00
|
|
|
my $plpython = $solution->AddProject('plpython' . $pymajorver,
|
|
|
|
'dll', 'PLs', 'src/pl/plpython');
|
|
|
|
$plpython->AddIncludeDir($pyprefix . '/include');
|
|
|
|
$plpython->AddLibrary($pyprefix . "/Libs/python$pyver.lib");
|
|
|
|
$plpython->AddReference($postgres);
|
|
|
|
|
|
|
|
# Add transform modules dependent on plpython
|
Convert contrib/hstore_plpython to not use direct linking to other modules.
Previously, on most platforms, we allowed hstore_plpython's references
to hstore and plpython to be unresolved symbols at link time, trusting
the dynamic linker to resolve them when the module is loaded. This
has a number of problems, the worst being that the dynamic linker
does not know where the references come from and can do nothing but
fail if those other modules haven't been loaded. We've more or less
gotten away with that for the limited use-case of datatype transform
modules, but even there, it requires some awkward hacks, most recently
commit 83c249200.
Instead, let's not treat these references as linker-resolvable at all,
but use function pointers that are manually filled in by the module's
_PG_init function. There are few enough contact points that this
doesn't seem unmaintainable, at least for these use-cases. (Note that
the same technique wouldn't work at all for decoupling from libpython
itself, but fortunately that's just a standard shared library and can
be linked to normally.)
This is an initial patch that just converts hstore_plpython. If the
buildfarm doesn't find any fatal problems, I'll work on the other
transform modules soon.
Tom Lane, per an idea of Andres Freund's.
Discussion: <2652.1475512158@sss.pgh.pa.us>
2016-10-04 04:27:11 +02:00
|
|
|
my $hstore_plpython = AddTransformModule(
|
2015-04-28 17:47:08 +02:00
|
|
|
'hstore_plpython' . $pymajorver, 'contrib/hstore_plpython',
|
|
|
|
'plpython' . $pymajorver, 'src/pl/plpython',
|
2018-09-16 19:46:45 +02:00
|
|
|
'hstore', 'contrib');
|
Convert contrib/hstore_plpython to not use direct linking to other modules.
Previously, on most platforms, we allowed hstore_plpython's references
to hstore and plpython to be unresolved symbols at link time, trusting
the dynamic linker to resolve them when the module is loaded. This
has a number of problems, the worst being that the dynamic linker
does not know where the references come from and can do nothing but
fail if those other modules haven't been loaded. We've more or less
gotten away with that for the limited use-case of datatype transform
modules, but even there, it requires some awkward hacks, most recently
commit 83c249200.
Instead, let's not treat these references as linker-resolvable at all,
but use function pointers that are manually filled in by the module's
_PG_init function. There are few enough contact points that this
doesn't seem unmaintainable, at least for these use-cases. (Note that
the same technique wouldn't work at all for decoupling from libpython
itself, but fortunately that's just a standard shared library and can
be linked to normally.)
This is an initial patch that just converts hstore_plpython. If the
buildfarm doesn't find any fatal problems, I'll work on the other
transform modules soon.
Tom Lane, per an idea of Andres Freund's.
Discussion: <2652.1475512158@sss.pgh.pa.us>
2016-10-04 04:27:11 +02:00
|
|
|
$hstore_plpython->AddDefine(
|
|
|
|
'PLPYTHON_LIBNAME="plpython' . $pymajorver . '"');
|
2018-03-28 17:49:23 +02:00
|
|
|
my $jsonb_plpython = AddTransformModule(
|
|
|
|
'jsonb_plpython' . $pymajorver, 'contrib/jsonb_plpython',
|
|
|
|
'plpython' . $pymajorver, 'src/pl/plpython');
|
|
|
|
$jsonb_plpython->AddDefine(
|
|
|
|
'PLPYTHON_LIBNAME="plpython' . $pymajorver . '"');
|
2016-10-04 23:49:07 +02:00
|
|
|
my $ltree_plpython = AddTransformModule(
|
2015-04-28 17:47:08 +02:00
|
|
|
'ltree_plpython' . $pymajorver, 'contrib/ltree_plpython',
|
|
|
|
'plpython' . $pymajorver, 'src/pl/plpython',
|
2018-09-16 19:46:45 +02:00
|
|
|
'ltree', 'contrib');
|
2016-10-04 23:49:07 +02:00
|
|
|
$ltree_plpython->AddDefine(
|
|
|
|
'PLPYTHON_LIBNAME="plpython' . $pymajorver . '"');
|
2015-04-28 17:47:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($solution->{options}->{perl})
|
|
|
|
{
|
|
|
|
my $plperlsrc = "src/pl/plperl/";
|
|
|
|
my $plperl =
|
|
|
|
$solution->AddProject('plperl', 'dll', 'PLs', 'src/pl/plperl');
|
|
|
|
$plperl->AddIncludeDir($solution->{options}->{perl} . '/lib/CORE');
|
2017-12-09 03:06:05 +01:00
|
|
|
$plperl->AddReference($postgres);
|
|
|
|
|
|
|
|
my $perl_path = $solution->{options}->{perl} . '\lib\CORE\*perl*';
|
|
|
|
|
2018-04-26 20:13:46 +02:00
|
|
|
# ActivePerl 5.16 provided perl516.lib; 5.18 provided libperl518.a
|
|
|
|
# Starting with ActivePerl 5.24, both perlnn.lib and libperlnn.a are provided.
|
|
|
|
# In this case, prefer .lib.
|
2017-12-09 03:06:05 +01:00
|
|
|
my @perl_libs =
|
2018-03-04 18:00:16 +01:00
|
|
|
reverse sort grep { /perl\d+\.lib$|libperl\d+\.a$/ }
|
|
|
|
glob($perl_path);
|
2018-03-02 12:40:49 +01:00
|
|
|
if (@perl_libs > 0)
|
2017-12-09 03:06:05 +01:00
|
|
|
{
|
|
|
|
$plperl->AddLibrary($perl_libs[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
die
|
2018-04-26 17:52:52 +02:00
|
|
|
"could not identify perl library version matching pattern $perl_path\n";
|
2017-12-09 03:06:05 +01:00
|
|
|
}
|
PL/Perl portability fix: absorb relevant -D switches from Perl.
The Perl documentation is very clear that stuff calling libperl should
be built with the compiler switches shown by Perl's $Config{ccflags}.
We'd been ignoring that up to now, and mostly getting away with it,
but recent Perl versions contain ABI compatibility cross-checks that
fail on some builds because of this omission. In particular the
sizeof(PerlInterpreter) can come out different due to some fields being
added or removed; which means we have a live ABI hazard that we'd better
fix rather than continuing to sweep it under the rug.
However, it still seems like a bad idea to just absorb $Config{ccflags}
verbatim. In some environments Perl was built with a different compiler
that doesn't even use the same switch syntax. -D switch syntax is pretty
universal though, and absorbing Perl's -D switches really ought to be
enough to fix the problem.
Furthermore, Perl likes to inject stuff like -D_LARGEFILE_SOURCE and
-D_FILE_OFFSET_BITS=64 into $Config{ccflags}, which affect libc ABIs on
platforms where they're relevant. Adopting those seems dangerous too.
It's unclear whether a build wherein Perl and Postgres have different ideas
of sizeof(off_t) etc would work, or whether anyone would care about making
it work. But it's dead certain that having different stdio ABIs in
core Postgres and PL/Perl will not work; we've seen that movie before.
Therefore, let's also ignore -D switches for symbols beginning with
underscore. The symbols that we actually need to import should be the ones
mentioned in perl.h's PL_bincompat_options stanza, and none of those start
with underscore, so this seems likely to work. (If it turns out not to
work everywhere, we could consider intersecting the symbols mentioned in
PL_bincompat_options with the -D switches. But that will be much more
complicated, so let's try this way first.)
This will need to be back-patched, but first let's see what the
buildfarm makes of it.
Ashutosh Sharma, some adjustments by me
Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com
2017-07-28 20:25:28 +02:00
|
|
|
|
|
|
|
# Add defines from Perl's ccflags; see PGAC_CHECK_PERL_EMBED_CCFLAGS
|
|
|
|
my @perl_embed_ccflags;
|
|
|
|
foreach my $f (split(" ", $Config{ccflags}))
|
|
|
|
{
|
2017-12-09 03:06:05 +01:00
|
|
|
if ($f =~ /^-D[^_]/)
|
PL/Perl portability fix: absorb relevant -D switches from Perl.
The Perl documentation is very clear that stuff calling libperl should
be built with the compiler switches shown by Perl's $Config{ccflags}.
We'd been ignoring that up to now, and mostly getting away with it,
but recent Perl versions contain ABI compatibility cross-checks that
fail on some builds because of this omission. In particular the
sizeof(PerlInterpreter) can come out different due to some fields being
added or removed; which means we have a live ABI hazard that we'd better
fix rather than continuing to sweep it under the rug.
However, it still seems like a bad idea to just absorb $Config{ccflags}
verbatim. In some environments Perl was built with a different compiler
that doesn't even use the same switch syntax. -D switch syntax is pretty
universal though, and absorbing Perl's -D switches really ought to be
enough to fix the problem.
Furthermore, Perl likes to inject stuff like -D_LARGEFILE_SOURCE and
-D_FILE_OFFSET_BITS=64 into $Config{ccflags}, which affect libc ABIs on
platforms where they're relevant. Adopting those seems dangerous too.
It's unclear whether a build wherein Perl and Postgres have different ideas
of sizeof(off_t) etc would work, or whether anyone would care about making
it work. But it's dead certain that having different stdio ABIs in
core Postgres and PL/Perl will not work; we've seen that movie before.
Therefore, let's also ignore -D switches for symbols beginning with
underscore. The symbols that we actually need to import should be the ones
mentioned in perl.h's PL_bincompat_options stanza, and none of those start
with underscore, so this seems likely to work. (If it turns out not to
work everywhere, we could consider intersecting the symbols mentioned in
PL_bincompat_options with the -D switches. But that will be much more
complicated, so let's try this way first.)
This will need to be back-patched, but first let's see what the
buildfarm makes of it.
Ashutosh Sharma, some adjustments by me
Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com
2017-07-28 20:25:28 +02:00
|
|
|
{
|
|
|
|
$f =~ s/\-D//;
|
|
|
|
push(@perl_embed_ccflags, $f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-09 03:06:05 +01:00
|
|
|
# hack to prevent duplicate definitions of uid_t/gid_t
|
PL/Perl portability fix: absorb relevant -D switches from Perl.
The Perl documentation is very clear that stuff calling libperl should
be built with the compiler switches shown by Perl's $Config{ccflags}.
We'd been ignoring that up to now, and mostly getting away with it,
but recent Perl versions contain ABI compatibility cross-checks that
fail on some builds because of this omission. In particular the
sizeof(PerlInterpreter) can come out different due to some fields being
added or removed; which means we have a live ABI hazard that we'd better
fix rather than continuing to sweep it under the rug.
However, it still seems like a bad idea to just absorb $Config{ccflags}
verbatim. In some environments Perl was built with a different compiler
that doesn't even use the same switch syntax. -D switch syntax is pretty
universal though, and absorbing Perl's -D switches really ought to be
enough to fix the problem.
Furthermore, Perl likes to inject stuff like -D_LARGEFILE_SOURCE and
-D_FILE_OFFSET_BITS=64 into $Config{ccflags}, which affect libc ABIs on
platforms where they're relevant. Adopting those seems dangerous too.
It's unclear whether a build wherein Perl and Postgres have different ideas
of sizeof(off_t) etc would work, or whether anyone would care about making
it work. But it's dead certain that having different stdio ABIs in
core Postgres and PL/Perl will not work; we've seen that movie before.
Therefore, let's also ignore -D switches for symbols beginning with
underscore. The symbols that we actually need to import should be the ones
mentioned in perl.h's PL_bincompat_options stanza, and none of those start
with underscore, so this seems likely to work. (If it turns out not to
work everywhere, we could consider intersecting the symbols mentioned in
PL_bincompat_options with the -D switches. But that will be much more
complicated, so let's try this way first.)
This will need to be back-patched, but first let's see what the
buildfarm makes of it.
Ashutosh Sharma, some adjustments by me
Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com
2017-07-28 20:25:28 +02:00
|
|
|
push(@perl_embed_ccflags, 'PLPERL_HAVE_UID_GID');
|
2022-11-27 15:03:22 +01:00
|
|
|
# prevent binary mismatch between MSVC built plperl and
|
|
|
|
# Strawberry or msys ucrt perl libraries
|
|
|
|
push(@perl_embed_ccflags, 'NO_THREAD_SAFE_LOCALE');
|
PL/Perl portability fix: absorb relevant -D switches from Perl.
The Perl documentation is very clear that stuff calling libperl should
be built with the compiler switches shown by Perl's $Config{ccflags}.
We'd been ignoring that up to now, and mostly getting away with it,
but recent Perl versions contain ABI compatibility cross-checks that
fail on some builds because of this omission. In particular the
sizeof(PerlInterpreter) can come out different due to some fields being
added or removed; which means we have a live ABI hazard that we'd better
fix rather than continuing to sweep it under the rug.
However, it still seems like a bad idea to just absorb $Config{ccflags}
verbatim. In some environments Perl was built with a different compiler
that doesn't even use the same switch syntax. -D switch syntax is pretty
universal though, and absorbing Perl's -D switches really ought to be
enough to fix the problem.
Furthermore, Perl likes to inject stuff like -D_LARGEFILE_SOURCE and
-D_FILE_OFFSET_BITS=64 into $Config{ccflags}, which affect libc ABIs on
platforms where they're relevant. Adopting those seems dangerous too.
It's unclear whether a build wherein Perl and Postgres have different ideas
of sizeof(off_t) etc would work, or whether anyone would care about making
it work. But it's dead certain that having different stdio ABIs in
core Postgres and PL/Perl will not work; we've seen that movie before.
Therefore, let's also ignore -D switches for symbols beginning with
underscore. The symbols that we actually need to import should be the ones
mentioned in perl.h's PL_bincompat_options stanza, and none of those start
with underscore, so this seems likely to work. (If it turns out not to
work everywhere, we could consider intersecting the symbols mentioned in
PL_bincompat_options with the -D switches. But that will be much more
complicated, so let's try this way first.)
This will need to be back-patched, but first let's see what the
buildfarm makes of it.
Ashutosh Sharma, some adjustments by me
Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com
2017-07-28 20:25:28 +02:00
|
|
|
|
2017-12-09 03:06:05 +01:00
|
|
|
# Windows offers several 32-bit ABIs. Perl is sensitive to
|
|
|
|
# sizeof(time_t), one of the ABI dimensions. To get 32-bit time_t,
|
|
|
|
# use "cl -D_USE_32BIT_TIME_T" or plain "gcc". For 64-bit time_t, use
|
|
|
|
# "gcc -D__MINGW_USE_VC2005_COMPAT" or plain "cl". Before MSVC 2005,
|
|
|
|
# plain "cl" chose 32-bit time_t. PostgreSQL doesn't support building
|
|
|
|
# with pre-MSVC-2005 compilers, but it does support linking to Perl
|
|
|
|
# built with such a compiler. MSVC-built Perl 5.13.4 and later report
|
|
|
|
# -D_USE_32BIT_TIME_T in $Config{ccflags} if applicable, but
|
|
|
|
# MinGW-built Perl never reports -D_USE_32BIT_TIME_T despite typically
|
|
|
|
# needing it. Ignore the $Config{ccflags} opinion about
|
|
|
|
# -D_USE_32BIT_TIME_T, and use a runtime test to deduce the ABI Perl
|
|
|
|
# expects. Specifically, test use of PL_modglobal, which maps to a
|
|
|
|
# PerlInterpreter field whose position depends on sizeof(time_t).
|
|
|
|
if ($solution->{platform} eq 'Win32')
|
|
|
|
{
|
|
|
|
my $source_file = 'conftest.c';
|
|
|
|
my $obj = 'conftest.obj';
|
|
|
|
my $exe = 'conftest.exe';
|
|
|
|
my @conftest = ($source_file, $obj, $exe);
|
|
|
|
push @unlink_on_exit, @conftest;
|
|
|
|
unlink $source_file;
|
|
|
|
open my $o, '>', $source_file
|
|
|
|
|| croak "Could not write to $source_file";
|
|
|
|
print $o '
|
|
|
|
/* compare to plperl.h */
|
|
|
|
#define __inline__ __inline
|
|
|
|
#define PERL_NO_GET_CONTEXT
|
|
|
|
#include <EXTERN.h>
|
|
|
|
#include <perl.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int dummy_argc = 1;
|
|
|
|
char *dummy_argv[1] = {""};
|
|
|
|
char *dummy_env[1] = {NULL};
|
|
|
|
static PerlInterpreter *interp;
|
|
|
|
|
|
|
|
PERL_SYS_INIT3(&dummy_argc, (char ***) &dummy_argv,
|
|
|
|
(char ***) &dummy_env);
|
|
|
|
interp = perl_alloc();
|
|
|
|
perl_construct(interp);
|
|
|
|
{
|
|
|
|
dTHX;
|
|
|
|
const char key[] = "dummy";
|
|
|
|
|
|
|
|
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
|
|
|
|
hv_store(PL_modglobal, key, sizeof(key) - 1, newSViv(1), 0);
|
|
|
|
return hv_fetch(PL_modglobal, key, sizeof(key) - 1, 0) == NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
';
|
|
|
|
close $o;
|
|
|
|
|
|
|
|
# Build $source_file with a given #define, and return a true value
|
|
|
|
# if a run of the resulting binary exits successfully.
|
|
|
|
my $try_define = sub {
|
|
|
|
my $define = shift;
|
|
|
|
|
|
|
|
unlink $obj, $exe;
|
|
|
|
my @cmd = (
|
|
|
|
'cl',
|
|
|
|
'-I' . $solution->{options}->{perl} . '/lib/CORE',
|
|
|
|
(map { "-D$_" } @perl_embed_ccflags, $define || ()),
|
|
|
|
$source_file,
|
|
|
|
'/link',
|
|
|
|
$perl_libs[0]);
|
|
|
|
my $compile_output = `@cmd 2>&1`;
|
|
|
|
-f $exe || die "Failed to build Perl test:\n$compile_output";
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
# Some builds exhibit runtime failure through Perl warning
|
2018-11-02 13:56:16 +01:00
|
|
|
# 'Can't spawn "conftest.exe"'; suppress that.
|
2017-12-09 03:06:05 +01:00
|
|
|
no warnings;
|
|
|
|
|
2020-02-21 22:03:05 +01:00
|
|
|
no strict 'subs'; ## no critic (ProhibitNoStrict)
|
2020-02-21 20:50:56 +01:00
|
|
|
|
2017-12-09 03:06:05 +01:00
|
|
|
# Disable error dialog boxes like we do in the postmaster.
|
|
|
|
# Here, we run code that triggers relevant errors.
|
2020-02-21 20:50:56 +01:00
|
|
|
use
|
|
|
|
if ($^O eq "MSWin32"), 'Win32API::File',
|
|
|
|
qw(SetErrorMode :SEM_);
|
2017-12-09 03:06:05 +01:00
|
|
|
my $oldmode = SetErrorMode(
|
|
|
|
SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
|
|
|
|
system(".\\$exe");
|
|
|
|
SetErrorMode($oldmode);
|
|
|
|
}
|
|
|
|
|
|
|
|
return !($? >> 8);
|
|
|
|
};
|
|
|
|
|
|
|
|
my $define_32bit_time = '_USE_32BIT_TIME_T';
|
|
|
|
my $ok_now = $try_define->(undef);
|
|
|
|
my $ok_32bit = $try_define->($define_32bit_time);
|
|
|
|
unlink @conftest;
|
|
|
|
if (!$ok_now && !$ok_32bit)
|
|
|
|
{
|
|
|
|
|
|
|
|
# Unsupported configuration. Since we used %Config from the
|
|
|
|
# Perl running the build scripts, this is expected if
|
|
|
|
# attempting to link with some other Perl.
|
|
|
|
die "Perl test fails with or without -D$define_32bit_time";
|
|
|
|
}
|
|
|
|
elsif ($ok_now && $ok_32bit)
|
|
|
|
{
|
|
|
|
|
|
|
|
# Resulting build may work, but it's especially important to
|
|
|
|
# verify with "vcregress plcheck". A refined test may avoid
|
|
|
|
# this outcome.
|
|
|
|
warn "Perl test passes with or without -D$define_32bit_time";
|
|
|
|
}
|
|
|
|
elsif ($ok_32bit)
|
|
|
|
{
|
|
|
|
push(@perl_embed_ccflags, $define_32bit_time);
|
|
|
|
} # else $ok_now, hence no flag required
|
|
|
|
}
|
|
|
|
|
|
|
|
print "CFLAGS recommended by Perl: $Config{ccflags}\n";
|
|
|
|
print "CFLAGS to compile embedded Perl: ",
|
|
|
|
(join ' ', map { "-D$_" } @perl_embed_ccflags), "\n";
|
PL/Perl portability fix: absorb relevant -D switches from Perl.
The Perl documentation is very clear that stuff calling libperl should
be built with the compiler switches shown by Perl's $Config{ccflags}.
We'd been ignoring that up to now, and mostly getting away with it,
but recent Perl versions contain ABI compatibility cross-checks that
fail on some builds because of this omission. In particular the
sizeof(PerlInterpreter) can come out different due to some fields being
added or removed; which means we have a live ABI hazard that we'd better
fix rather than continuing to sweep it under the rug.
However, it still seems like a bad idea to just absorb $Config{ccflags}
verbatim. In some environments Perl was built with a different compiler
that doesn't even use the same switch syntax. -D switch syntax is pretty
universal though, and absorbing Perl's -D switches really ought to be
enough to fix the problem.
Furthermore, Perl likes to inject stuff like -D_LARGEFILE_SOURCE and
-D_FILE_OFFSET_BITS=64 into $Config{ccflags}, which affect libc ABIs on
platforms where they're relevant. Adopting those seems dangerous too.
It's unclear whether a build wherein Perl and Postgres have different ideas
of sizeof(off_t) etc would work, or whether anyone would care about making
it work. But it's dead certain that having different stdio ABIs in
core Postgres and PL/Perl will not work; we've seen that movie before.
Therefore, let's also ignore -D switches for symbols beginning with
underscore. The symbols that we actually need to import should be the ones
mentioned in perl.h's PL_bincompat_options stanza, and none of those start
with underscore, so this seems likely to work. (If it turns out not to
work everywhere, we could consider intersecting the symbols mentioned in
PL_bincompat_options with the -D switches. But that will be much more
complicated, so let's try this way first.)
This will need to be back-patched, but first let's see what the
buildfarm makes of it.
Ashutosh Sharma, some adjustments by me
Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com
2017-07-28 20:25:28 +02:00
|
|
|
foreach my $f (@perl_embed_ccflags)
|
|
|
|
{
|
|
|
|
$plperl->AddDefine($f);
|
|
|
|
}
|
|
|
|
|
2015-04-28 17:47:08 +02:00
|
|
|
foreach my $xs ('SPI.xs', 'Util.xs')
|
|
|
|
{
|
|
|
|
(my $xsc = $xs) =~ s/\.xs/.c/;
|
|
|
|
if (Solution::IsNewer("$plperlsrc$xsc", "$plperlsrc$xs"))
|
|
|
|
{
|
2018-05-18 16:46:38 +02:00
|
|
|
my $xsubppdir = first { -e "$_/ExtUtils/xsubpp" } (@INC);
|
2015-04-28 17:47:08 +02:00
|
|
|
print "Building $plperlsrc$xsc...\n";
|
|
|
|
system( $solution->{options}->{perl}
|
|
|
|
. '/bin/perl '
|
|
|
|
. "$xsubppdir/ExtUtils/xsubpp -typemap "
|
|
|
|
. $solution->{options}->{perl}
|
|
|
|
. '/lib/ExtUtils/typemap '
|
|
|
|
. "$plperlsrc$xs "
|
|
|
|
. ">$plperlsrc$xsc");
|
|
|
|
if ((!(-f "$plperlsrc$xsc")) || -z "$plperlsrc$xsc")
|
|
|
|
{
|
|
|
|
unlink("$plperlsrc$xsc"); # if zero size
|
|
|
|
die "Failed to create $xsc.\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Solution::IsNewer(
|
|
|
|
'src/pl/plperl/perlchunks.h',
|
|
|
|
'src/pl/plperl/plc_perlboot.pl')
|
|
|
|
|| Solution::IsNewer(
|
|
|
|
'src/pl/plperl/perlchunks.h',
|
|
|
|
'src/pl/plperl/plc_trusted.pl'))
|
|
|
|
{
|
|
|
|
print 'Building src/pl/plperl/perlchunks.h ...' . "\n";
|
|
|
|
my $basedir = getcwd;
|
|
|
|
chdir 'src/pl/plperl';
|
|
|
|
system( $solution->{options}->{perl}
|
|
|
|
. '/bin/perl '
|
|
|
|
. 'text2macro.pl '
|
|
|
|
. '--strip="^(\#.*|\s*)$$" '
|
|
|
|
. 'plc_perlboot.pl plc_trusted.pl '
|
|
|
|
. '>perlchunks.h');
|
|
|
|
chdir $basedir;
|
|
|
|
if ((!(-f 'src/pl/plperl/perlchunks.h'))
|
|
|
|
|| -z 'src/pl/plperl/perlchunks.h')
|
|
|
|
{
|
|
|
|
unlink('src/pl/plperl/perlchunks.h'); # if zero size
|
|
|
|
die 'Failed to create perlchunks.h' . "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Solution::IsNewer(
|
|
|
|
'src/pl/plperl/plperl_opmask.h',
|
|
|
|
'src/pl/plperl/plperl_opmask.pl'))
|
|
|
|
{
|
|
|
|
print 'Building src/pl/plperl/plperl_opmask.h ...' . "\n";
|
|
|
|
my $basedir = getcwd;
|
|
|
|
chdir 'src/pl/plperl';
|
|
|
|
system( $solution->{options}->{perl}
|
|
|
|
. '/bin/perl '
|
|
|
|
. 'plperl_opmask.pl '
|
|
|
|
. 'plperl_opmask.h');
|
|
|
|
chdir $basedir;
|
|
|
|
if ((!(-f 'src/pl/plperl/plperl_opmask.h'))
|
|
|
|
|| -z 'src/pl/plperl/plperl_opmask.h')
|
|
|
|
{
|
|
|
|
unlink('src/pl/plperl/plperl_opmask.h'); # if zero size
|
|
|
|
die 'Failed to create plperl_opmask.h' . "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-03 16:43:16 +02:00
|
|
|
# Add transform modules dependent on plperl
|
2020-03-06 23:11:23 +01:00
|
|
|
my $bool_plperl = AddTransformModule(
|
|
|
|
'bool_plperl', 'contrib/bool_plperl',
|
|
|
|
'plperl', 'src/pl/plperl');
|
2015-04-28 17:47:08 +02:00
|
|
|
my $hstore_plperl = AddTransformModule(
|
|
|
|
'hstore_plperl', 'contrib/hstore_plperl',
|
|
|
|
'plperl', 'src/pl/plperl',
|
2018-09-16 19:46:45 +02:00
|
|
|
'hstore', 'contrib');
|
2018-04-03 16:43:16 +02:00
|
|
|
my $jsonb_plperl = AddTransformModule(
|
|
|
|
'jsonb_plperl', 'contrib/jsonb_plperl',
|
|
|
|
'plperl', 'src/pl/plperl');
|
PL/Perl portability fix: absorb relevant -D switches from Perl.
The Perl documentation is very clear that stuff calling libperl should
be built with the compiler switches shown by Perl's $Config{ccflags}.
We'd been ignoring that up to now, and mostly getting away with it,
but recent Perl versions contain ABI compatibility cross-checks that
fail on some builds because of this omission. In particular the
sizeof(PerlInterpreter) can come out different due to some fields being
added or removed; which means we have a live ABI hazard that we'd better
fix rather than continuing to sweep it under the rug.
However, it still seems like a bad idea to just absorb $Config{ccflags}
verbatim. In some environments Perl was built with a different compiler
that doesn't even use the same switch syntax. -D switch syntax is pretty
universal though, and absorbing Perl's -D switches really ought to be
enough to fix the problem.
Furthermore, Perl likes to inject stuff like -D_LARGEFILE_SOURCE and
-D_FILE_OFFSET_BITS=64 into $Config{ccflags}, which affect libc ABIs on
platforms where they're relevant. Adopting those seems dangerous too.
It's unclear whether a build wherein Perl and Postgres have different ideas
of sizeof(off_t) etc would work, or whether anyone would care about making
it work. But it's dead certain that having different stdio ABIs in
core Postgres and PL/Perl will not work; we've seen that movie before.
Therefore, let's also ignore -D switches for symbols beginning with
underscore. The symbols that we actually need to import should be the ones
mentioned in perl.h's PL_bincompat_options stanza, and none of those start
with underscore, so this seems likely to work. (If it turns out not to
work everywhere, we could consider intersecting the symbols mentioned in
PL_bincompat_options with the -D switches. But that will be much more
complicated, so let's try this way first.)
This will need to be back-patched, but first let's see what the
buildfarm makes of it.
Ashutosh Sharma, some adjustments by me
Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com
2017-07-28 20:25:28 +02:00
|
|
|
|
|
|
|
foreach my $f (@perl_embed_ccflags)
|
|
|
|
{
|
2020-03-06 23:11:23 +01:00
|
|
|
$bool_plperl->AddDefine($f);
|
PL/Perl portability fix: absorb relevant -D switches from Perl.
The Perl documentation is very clear that stuff calling libperl should
be built with the compiler switches shown by Perl's $Config{ccflags}.
We'd been ignoring that up to now, and mostly getting away with it,
but recent Perl versions contain ABI compatibility cross-checks that
fail on some builds because of this omission. In particular the
sizeof(PerlInterpreter) can come out different due to some fields being
added or removed; which means we have a live ABI hazard that we'd better
fix rather than continuing to sweep it under the rug.
However, it still seems like a bad idea to just absorb $Config{ccflags}
verbatim. In some environments Perl was built with a different compiler
that doesn't even use the same switch syntax. -D switch syntax is pretty
universal though, and absorbing Perl's -D switches really ought to be
enough to fix the problem.
Furthermore, Perl likes to inject stuff like -D_LARGEFILE_SOURCE and
-D_FILE_OFFSET_BITS=64 into $Config{ccflags}, which affect libc ABIs on
platforms where they're relevant. Adopting those seems dangerous too.
It's unclear whether a build wherein Perl and Postgres have different ideas
of sizeof(off_t) etc would work, or whether anyone would care about making
it work. But it's dead certain that having different stdio ABIs in
core Postgres and PL/Perl will not work; we've seen that movie before.
Therefore, let's also ignore -D switches for symbols beginning with
underscore. The symbols that we actually need to import should be the ones
mentioned in perl.h's PL_bincompat_options stanza, and none of those start
with underscore, so this seems likely to work. (If it turns out not to
work everywhere, we could consider intersecting the symbols mentioned in
PL_bincompat_options with the -D switches. But that will be much more
complicated, so let's try this way first.)
This will need to be back-patched, but first let's see what the
buildfarm makes of it.
Ashutosh Sharma, some adjustments by me
Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com
2017-07-28 20:25:28 +02:00
|
|
|
$hstore_plperl->AddDefine($f);
|
2018-04-03 16:43:16 +02:00
|
|
|
$jsonb_plperl->AddDefine($f);
|
PL/Perl portability fix: absorb relevant -D switches from Perl.
The Perl documentation is very clear that stuff calling libperl should
be built with the compiler switches shown by Perl's $Config{ccflags}.
We'd been ignoring that up to now, and mostly getting away with it,
but recent Perl versions contain ABI compatibility cross-checks that
fail on some builds because of this omission. In particular the
sizeof(PerlInterpreter) can come out different due to some fields being
added or removed; which means we have a live ABI hazard that we'd better
fix rather than continuing to sweep it under the rug.
However, it still seems like a bad idea to just absorb $Config{ccflags}
verbatim. In some environments Perl was built with a different compiler
that doesn't even use the same switch syntax. -D switch syntax is pretty
universal though, and absorbing Perl's -D switches really ought to be
enough to fix the problem.
Furthermore, Perl likes to inject stuff like -D_LARGEFILE_SOURCE and
-D_FILE_OFFSET_BITS=64 into $Config{ccflags}, which affect libc ABIs on
platforms where they're relevant. Adopting those seems dangerous too.
It's unclear whether a build wherein Perl and Postgres have different ideas
of sizeof(off_t) etc would work, or whether anyone would care about making
it work. But it's dead certain that having different stdio ABIs in
core Postgres and PL/Perl will not work; we've seen that movie before.
Therefore, let's also ignore -D switches for symbols beginning with
underscore. The symbols that we actually need to import should be the ones
mentioned in perl.h's PL_bincompat_options stanza, and none of those start
with underscore, so this seems likely to work. (If it turns out not to
work everywhere, we could consider intersecting the symbols mentioned in
PL_bincompat_options with the -D switches. But that will be much more
complicated, so let's try this way first.)
This will need to be back-patched, but first let's see what the
buildfarm makes of it.
Ashutosh Sharma, some adjustments by me
Discussion: https://postgr.es/m/CANFyU97OVQ3+Mzfmt3MhuUm5NwPU=-FtbNH5Eb7nZL9ua8=rcA@mail.gmail.com
2017-07-28 20:25:28 +02:00
|
|
|
}
|
2015-04-28 17:47:08 +02:00
|
|
|
}
|
|
|
|
|
2021-11-05 13:59:42 +01:00
|
|
|
my $mf =
|
2015-04-25 14:52:03 +02:00
|
|
|
Project::read_file('src/backend/utils/mb/conversion_procs/Makefile');
|
2014-07-14 20:07:27 +02:00
|
|
|
$mf =~ s{\\\r?\n}{}g;
|
2012-07-05 03:47:49 +02:00
|
|
|
$mf =~ m{SUBDIRS\s*=\s*(.*)$}m
|
|
|
|
|| die 'Could not match in conversion makefile' . "\n";
|
|
|
|
foreach my $sub (split /\s+/, $1)
|
2007-03-17 14:50:42 +01:00
|
|
|
{
|
2015-04-25 14:52:03 +02:00
|
|
|
my $dir = 'src/backend/utils/mb/conversion_procs/' . $sub;
|
2014-07-14 20:07:21 +02:00
|
|
|
my $p = $solution->AddProject($sub, 'dll', 'conversion procs', $dir);
|
2015-04-25 14:52:03 +02:00
|
|
|
$p->AddFile("$dir/$sub.c"); # implicit source file
|
2007-03-17 14:50:42 +01:00
|
|
|
$p->AddReference($postgres);
|
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2015-04-25 14:52:03 +02:00
|
|
|
$mf = Project::read_file('src/bin/scripts/Makefile');
|
2014-07-14 20:07:27 +02:00
|
|
|
$mf =~ s{\\\r?\n}{}g;
|
2012-07-05 03:47:49 +02:00
|
|
|
$mf =~ m{PROGRAMS\s*=\s*(.*)$}m
|
2015-04-25 14:52:03 +02:00
|
|
|
|| die 'Could not match in bin/scripts/Makefile' . "\n";
|
2012-07-05 03:47:49 +02:00
|
|
|
foreach my $prg (split /\s+/, $1)
|
2007-03-17 14:50:42 +01:00
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
my $proj = $solution->AddProject($prg, 'exe', 'bin');
|
|
|
|
$mf =~ m{$prg\s*:\s*(.*)$}m
|
|
|
|
|| die 'Could not find script define for $prg' . "\n";
|
|
|
|
my @files = split /\s+/, $1;
|
2007-03-17 14:50:42 +01:00
|
|
|
foreach my $f (@files)
|
|
|
|
{
|
2009-03-08 20:13:38 +01:00
|
|
|
$f =~ s/\.o$/\.c/;
|
2016-03-24 23:27:28 +01:00
|
|
|
if ($f =~ /\.c$/)
|
2007-03-17 14:50:42 +01:00
|
|
|
{
|
2015-04-25 14:52:03 +02:00
|
|
|
$proj->AddFile('src/bin/scripts/' . $f);
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
2015-04-25 14:52:03 +02:00
|
|
|
$proj->AddIncludeDir('src/interfaces/libpq');
|
2016-03-24 20:55:44 +01:00
|
|
|
$proj->AddReference($libpq, $libpgfeutils, $libpgcommon, $libpgport);
|
2015-04-25 14:52:03 +02:00
|
|
|
$proj->AddDirResourceFile('src/bin/scripts');
|
2013-03-24 16:27:20 +01:00
|
|
|
$proj->AddLibrary('ws2_32.lib');
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
# Regression DLL and EXE
|
2012-07-05 03:47:49 +02:00
|
|
|
my $regress = $solution->AddProject('regress', 'dll', 'misc');
|
2015-04-25 14:52:03 +02:00
|
|
|
$regress->AddFile('src/test/regress/regress.c');
|
|
|
|
$regress->AddDirResourceFile('src/test/regress');
|
2007-03-17 14:50:42 +01:00
|
|
|
$regress->AddReference($postgres);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $pgregress = $solution->AddProject('pg_regress', 'exe', 'misc');
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgregress->AddFile('src/test/regress/pg_regress.c');
|
|
|
|
$pgregress->AddFile('src/test/regress/pg_regress_main.c');
|
|
|
|
$pgregress->AddIncludeDir('src/port');
|
2023-10-25 04:37:37 +02:00
|
|
|
$pgregress->AddIncludeDir('src/interfaces/libpq');
|
2007-03-17 14:50:42 +01:00
|
|
|
$pgregress->AddDefine('HOST_TUPLE="i686-pc-win32vc"');
|
2014-12-25 19:52:03 +01:00
|
|
|
$pgregress->AddLibrary('ws2_32.lib');
|
2015-04-25 14:52:03 +02:00
|
|
|
$pgregress->AddDirResourceFile('src/test/regress');
|
2023-10-25 04:37:37 +02:00
|
|
|
$pgregress->AddReference($libpq, $libpgcommon, $libpgport);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2017-02-09 22:23:46 +01:00
|
|
|
# fix up pg_waldump once it's been set up
|
2013-02-25 18:00:53 +01:00
|
|
|
# files symlinked on Unix are copied on windows
|
2017-02-09 22:23:46 +01:00
|
|
|
my $pg_waldump = AddSimpleFrontend('pg_waldump');
|
|
|
|
$pg_waldump->AddDefine('FRONTEND');
|
2023-04-08 17:19:18 +02:00
|
|
|
foreach my $xf (glob('src/backend/access/rmgrdesc/*desc*.c'))
|
2013-02-25 18:00:53 +01:00
|
|
|
{
|
2017-02-09 22:23:46 +01:00
|
|
|
$pg_waldump->AddFile($xf);
|
2013-02-25 18:00:53 +01:00
|
|
|
}
|
2017-02-09 22:23:46 +01:00
|
|
|
$pg_waldump->AddFile('src/backend/access/transam/xlogreader.c');
|
2013-02-25 02:28:42 +01:00
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
$solution->Save();
|
2012-01-03 14:44:26 +01:00
|
|
|
return $solution->{vcver};
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#####################
|
|
|
|
# Utility functions #
|
|
|
|
#####################
|
|
|
|
|
|
|
|
# Add a simple frontend project (exe)
|
|
|
|
sub AddSimpleFrontend
|
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
my $n = shift;
|
|
|
|
my $uselibpq = shift;
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $p = $solution->AddProject($n, 'exe', 'bin');
|
2015-04-25 14:52:03 +02:00
|
|
|
$p->AddDir('src/bin/' . $n);
|
2016-03-24 20:55:44 +01:00
|
|
|
$p->AddReference($libpgfeutils, $libpgcommon, $libpgport);
|
2007-03-17 14:50:42 +01:00
|
|
|
if ($uselibpq)
|
|
|
|
{
|
2015-04-25 14:52:03 +02:00
|
|
|
$p->AddIncludeDir('src/interfaces/libpq');
|
2007-03-17 14:50:42 +01:00
|
|
|
$p->AddReference($libpq);
|
|
|
|
}
|
2015-03-11 14:21:01 +01:00
|
|
|
|
2015-04-09 14:15:39 +02:00
|
|
|
# Adjust module definition using frontend variables
|
2015-03-11 14:21:01 +01:00
|
|
|
AdjustFrontendProj($p);
|
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
return $p;
|
|
|
|
}
|
|
|
|
|
2015-04-28 17:47:08 +02:00
|
|
|
# Add a simple transform module
|
|
|
|
sub AddTransformModule
|
|
|
|
{
|
|
|
|
my $n = shift;
|
|
|
|
my $n_src = shift;
|
|
|
|
my $pl_proj_name = shift;
|
|
|
|
my $pl_src = shift;
|
2018-03-28 17:49:23 +02:00
|
|
|
my $type_name = shift;
|
|
|
|
my $type_src = shift;
|
2015-04-28 17:47:08 +02:00
|
|
|
|
2018-03-28 17:49:23 +02:00
|
|
|
my $type_proj = undef;
|
|
|
|
if ($type_name)
|
2015-04-28 17:47:08 +02:00
|
|
|
{
|
2018-03-28 17:49:23 +02:00
|
|
|
foreach my $proj (@{ $solution->{projects}->{'contrib'} })
|
2015-04-28 17:47:08 +02:00
|
|
|
{
|
2018-03-28 17:49:23 +02:00
|
|
|
if ($proj->{name} eq $type_name)
|
|
|
|
{
|
|
|
|
$type_proj = $proj;
|
|
|
|
last;
|
|
|
|
}
|
2015-04-28 17:47:08 +02:00
|
|
|
}
|
2018-03-28 17:49:23 +02:00
|
|
|
die "could not find base module $type_name for transform module $n"
|
|
|
|
if (!defined($type_proj));
|
2015-04-28 17:47:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
my $pl_proj = undef;
|
|
|
|
foreach my $proj (@{ $solution->{projects}->{'PLs'} })
|
|
|
|
{
|
|
|
|
if ($proj->{name} eq $pl_proj_name)
|
|
|
|
{
|
|
|
|
$pl_proj = $proj;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
die "could not find PL $pl_proj_name for transform module $n"
|
|
|
|
if (!defined($pl_proj));
|
|
|
|
|
|
|
|
my $p = $solution->AddProject($n, 'dll', 'contrib', $n_src);
|
|
|
|
for my $file (glob("$n_src/*.c"))
|
|
|
|
{
|
|
|
|
$p->AddFile($file);
|
|
|
|
}
|
|
|
|
$p->AddReference($postgres);
|
|
|
|
|
|
|
|
# Add PL dependencies
|
|
|
|
$p->AddIncludeDir($pl_src);
|
|
|
|
$p->AddReference($pl_proj);
|
2021-07-29 00:14:25 +02:00
|
|
|
$p->AddIncludeDir($_) for @{ $pl_proj->{includes} };
|
2015-04-28 17:47:08 +02:00
|
|
|
foreach my $pl_lib (@{ $pl_proj->{libraries} })
|
|
|
|
{
|
|
|
|
$p->AddLibrary($pl_lib);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Add base module dependencies
|
2018-03-28 17:49:23 +02:00
|
|
|
if ($type_proj)
|
2015-04-28 17:47:08 +02:00
|
|
|
{
|
2018-03-28 17:49:23 +02:00
|
|
|
$p->AddIncludeDir($type_src);
|
2021-07-29 00:14:25 +02:00
|
|
|
$p->AddIncludeDir($_) for @{ $type_proj->{includes} };
|
2018-03-28 17:49:23 +02:00
|
|
|
foreach my $type_lib (@{ $type_proj->{libraries} })
|
|
|
|
{
|
|
|
|
$p->AddLibrary($type_lib);
|
|
|
|
}
|
|
|
|
$p->AddReference($type_proj);
|
2015-04-28 17:47:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $p;
|
|
|
|
}
|
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
# Add a simple contrib project
|
|
|
|
sub AddContrib
|
|
|
|
{
|
2015-04-16 20:17:26 +02:00
|
|
|
my $subdir = shift;
|
2012-07-05 03:47:49 +02:00
|
|
|
my $n = shift;
|
2015-04-16 20:17:26 +02:00
|
|
|
my $mf = Project::read_file("$subdir/$n/Makefile");
|
2021-07-29 02:01:23 +02:00
|
|
|
my @projects = ();
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2007-03-24 15:13:27 +01:00
|
|
|
if ($mf =~ /^MODULE_big\s*=\s*(.*)$/mg)
|
2007-03-17 14:50:42 +01:00
|
|
|
{
|
2007-03-24 15:13:27 +01:00
|
|
|
my $dn = $1;
|
2015-04-16 20:17:26 +02:00
|
|
|
my $proj = $solution->AddProject($dn, 'dll', 'contrib', "$subdir/$n");
|
2007-03-17 14:50:42 +01:00
|
|
|
$proj->AddReference($postgres);
|
|
|
|
AdjustContribProj($proj);
|
2021-07-29 02:01:23 +02:00
|
|
|
push @projects, $proj;
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
|
|
|
elsif ($mf =~ /^MODULES\s*=\s*(.*)$/mg)
|
|
|
|
{
|
|
|
|
foreach my $mod (split /\s+/, $1)
|
|
|
|
{
|
2014-07-14 20:07:21 +02:00
|
|
|
my $proj =
|
2015-04-16 20:17:26 +02:00
|
|
|
$solution->AddProject($mod, 'dll', 'contrib', "$subdir/$n");
|
|
|
|
my $filename = $mod . '.c';
|
2015-04-25 14:52:03 +02:00
|
|
|
$proj->AddFile("$subdir/$n/$filename");
|
2007-03-17 14:50:42 +01:00
|
|
|
$proj->AddReference($postgres);
|
|
|
|
AdjustContribProj($proj);
|
2021-07-29 02:01:23 +02:00
|
|
|
push @projects, $proj;
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
2007-03-17 14:50:42 +01:00
|
|
|
elsif ($mf =~ /^PROGRAM\s*=\s*(.*)$/mg)
|
|
|
|
{
|
2015-04-16 20:17:26 +02:00
|
|
|
my $proj = $solution->AddProject($1, 'exe', 'contrib', "$subdir/$n");
|
2007-03-17 14:50:42 +01:00
|
|
|
AdjustContribProj($proj);
|
2021-07-29 02:01:23 +02:00
|
|
|
push @projects, $proj;
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
croak "Could not determine contrib module type for $n\n";
|
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2021-07-29 02:01:23 +02:00
|
|
|
# Process custom compiler flags
|
|
|
|
if ( $mf =~ /^PG_CPPFLAGS\s*=\s*(.*)$/mg
|
|
|
|
|| $mf =~ /^override\s*CPPFLAGS\s*[+:]?=\s*(.*)$/mg)
|
|
|
|
{
|
|
|
|
foreach my $flag (split /\s+/, $1)
|
|
|
|
{
|
|
|
|
if ($flag =~ /^-D(.*)$/)
|
|
|
|
{
|
|
|
|
foreach my $proj (@projects)
|
|
|
|
{
|
|
|
|
$proj->AddDefine($1);
|
|
|
|
}
|
|
|
|
}
|
2021-08-09 09:45:26 +02:00
|
|
|
elsif ($flag =~ /^-I(.*)$/)
|
|
|
|
{
|
|
|
|
if ($1 eq '$(libpq_srcdir)')
|
|
|
|
{
|
|
|
|
foreach my $proj (@projects)
|
|
|
|
{
|
|
|
|
$proj->AddIncludeDir('src/interfaces/libpq');
|
|
|
|
$proj->AddReference($libpq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($mf =~ /^SHLIB_LINK_INTERNAL\s*[+:]?=\s*(.*)$/mg)
|
|
|
|
{
|
|
|
|
foreach my $lib (split /\s+/, $1)
|
|
|
|
{
|
|
|
|
if ($lib eq '$(libpq)')
|
|
|
|
{
|
|
|
|
foreach my $proj (@projects)
|
|
|
|
{
|
|
|
|
$proj->AddIncludeDir('src/interfaces/libpq');
|
|
|
|
$proj->AddReference($libpq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($mf =~ /^PG_LIBS_INTERNAL\s*[+:]?=\s*(.*)$/mg)
|
|
|
|
{
|
|
|
|
foreach my $lib (split /\s+/, $1)
|
|
|
|
{
|
|
|
|
if ($lib eq '$(libpq_pgport)')
|
|
|
|
{
|
|
|
|
foreach my $proj (@projects)
|
|
|
|
{
|
|
|
|
$proj->AddReference($libpgport);
|
|
|
|
$proj->AddReference($libpgcommon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $line (split /\n/, $mf)
|
|
|
|
{
|
|
|
|
if ($line =~ /^[A-Za-z0-9_]*\.o:\s(.*)/)
|
|
|
|
{
|
|
|
|
foreach my $file (split /\s+/, $1)
|
|
|
|
{
|
|
|
|
foreach my $proj (@projects)
|
|
|
|
{
|
|
|
|
$proj->AddDependantFiles("$subdir/$n/$file");
|
|
|
|
}
|
|
|
|
}
|
2021-07-29 02:01:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-23 10:53:33 +01:00
|
|
|
# Are there any output data files to build?
|
|
|
|
GenerateContribSqlFiles($n, $mf);
|
2018-05-27 15:08:42 +02:00
|
|
|
return;
|
2007-03-23 10:53:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub GenerateContribSqlFiles
|
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
my $n = shift;
|
2007-03-23 10:53:33 +01:00
|
|
|
my $mf = shift;
|
2014-07-14 20:07:27 +02:00
|
|
|
$mf =~ s{\\\r?\n}{}g;
|
2007-03-23 10:53:33 +01:00
|
|
|
if ($mf =~ /^DATA_built\s*=\s*(.*)$/mg)
|
|
|
|
{
|
|
|
|
my $l = $1;
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2007-03-23 10:53:33 +01:00
|
|
|
# Strip out $(addsuffix) rules
|
|
|
|
if (index($l, '$(addsuffix ') >= 0)
|
|
|
|
{
|
|
|
|
my $pcount = 0;
|
|
|
|
my $i;
|
|
|
|
for ($i = index($l, '$(addsuffix ') + 12; $i < length($l); $i++)
|
|
|
|
{
|
|
|
|
$pcount++ if (substr($l, $i, 1) eq '(');
|
|
|
|
$pcount-- if (substr($l, $i, 1) eq ')');
|
2012-07-05 03:47:49 +02:00
|
|
|
last if ($pcount < 0);
|
2007-03-23 10:53:33 +01:00
|
|
|
}
|
2012-07-05 03:47:49 +02:00
|
|
|
$l =
|
|
|
|
substr($l, 0, index($l, '$(addsuffix ')) . substr($l, $i + 1);
|
2007-03-23 10:53:33 +01:00
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2007-03-23 10:53:33 +01:00
|
|
|
foreach my $d (split /\s+/, $l)
|
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
my $in = "$d.in";
|
2007-03-23 10:53:33 +01:00
|
|
|
my $out = "$d";
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2007-03-23 10:53:33 +01:00
|
|
|
if (Solution::IsNewer("contrib/$n/$out", "contrib/$n/$in"))
|
|
|
|
{
|
|
|
|
print "Building $out from $in (contrib/$n)...\n";
|
|
|
|
my $cont = Project::read_file("contrib/$n/$in");
|
2012-07-05 03:47:49 +02:00
|
|
|
my $dn = $out;
|
2015-03-11 14:21:01 +01:00
|
|
|
$dn =~ s/\.sql$//;
|
2007-03-24 15:13:27 +01:00
|
|
|
$cont =~ s/MODULE_PATHNAME/\$libdir\/$dn/g;
|
2007-03-23 10:53:33 +01:00
|
|
|
my $o;
|
2017-03-27 04:24:13 +02:00
|
|
|
open($o, '>', "contrib/$n/$out")
|
2007-03-23 10:53:33 +01:00
|
|
|
|| croak "Could not write to contrib/$n/$d";
|
|
|
|
print $o $cont;
|
|
|
|
close($o);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-05-27 15:08:42 +02:00
|
|
|
return;
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub AdjustContribProj
|
|
|
|
{
|
|
|
|
my $proj = shift;
|
2015-03-11 14:21:01 +01:00
|
|
|
AdjustModule(
|
2022-10-06 22:03:31 +02:00
|
|
|
$proj, $contrib_defines,
|
|
|
|
\@contrib_uselibpq, \@contrib_uselibpgport,
|
|
|
|
\@contrib_uselibpgcommon, $contrib_extralibs,
|
|
|
|
$contrib_extrasource, $contrib_extraincludes);
|
2018-05-27 15:08:42 +02:00
|
|
|
return;
|
2015-03-11 14:21:01 +01:00
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2015-03-11 14:21:01 +01:00
|
|
|
sub AdjustFrontendProj
|
|
|
|
{
|
|
|
|
my $proj = shift;
|
2015-03-11 03:33:23 +01:00
|
|
|
AdjustModule(
|
2022-10-06 22:03:31 +02:00
|
|
|
$proj, $frontend_defines,
|
|
|
|
\@frontend_uselibpq, \@frontend_uselibpgport,
|
|
|
|
\@frontend_uselibpgcommon, $frontend_extralibs,
|
|
|
|
$frontend_extrasource, $frontend_extraincludes);
|
2018-05-27 15:08:42 +02:00
|
|
|
return;
|
2015-03-11 14:21:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub AdjustModule
|
|
|
|
{
|
|
|
|
my $proj = shift;
|
2022-10-06 22:03:31 +02:00
|
|
|
my $module_defines = shift;
|
2015-03-11 14:21:01 +01:00
|
|
|
my $module_uselibpq = shift;
|
|
|
|
my $module_uselibpgport = shift;
|
|
|
|
my $module_uselibpgcommon = shift;
|
|
|
|
my $module_extralibs = shift;
|
|
|
|
my $module_extrasource = shift;
|
|
|
|
my $module_extraincludes = shift;
|
|
|
|
my $n = $proj->{name};
|
|
|
|
|
2022-10-06 22:03:31 +02:00
|
|
|
if ($module_defines->{$n})
|
|
|
|
{
|
|
|
|
foreach my $d ($module_defines->{$n})
|
|
|
|
{
|
|
|
|
$proj->AddDefine($d);
|
|
|
|
}
|
|
|
|
}
|
2015-03-11 14:21:01 +01:00
|
|
|
if (grep { /^$n$/ } @{$module_uselibpq})
|
2007-03-17 14:50:42 +01:00
|
|
|
{
|
|
|
|
$proj->AddIncludeDir('src\interfaces\libpq');
|
|
|
|
$proj->AddReference($libpq);
|
|
|
|
}
|
2015-03-11 14:21:01 +01:00
|
|
|
if (grep { /^$n$/ } @{$module_uselibpgport})
|
2007-03-17 14:50:42 +01:00
|
|
|
{
|
|
|
|
$proj->AddReference($libpgport);
|
|
|
|
}
|
2015-03-11 14:21:01 +01:00
|
|
|
if (grep { /^$n$/ } @{$module_uselibpgcommon})
|
Create libpgcommon, and move pg_malloc et al to it
libpgcommon is a new static library to allow sharing code among the
various frontend programs and backend; this lets us eliminate duplicate
implementations of common routines. We avoid libpgport, because that's
intended as a place for porting issues; per discussion, it seems better
to keep them separate.
The first use case, and the only implemented by this patch, is pg_malloc
and friends, which many frontend programs were already using.
At the same time, we can use this to provide palloc emulation functions
for the frontend; this way, some palloc-using files in the backend can
also be used by the frontend cleanly. To do this, we change palloc() in
the backend to be a function instead of a macro on top of
MemoryContextAlloc(). This was previously believed to cause loss of
performance, but this implementation has been tweaked by Tom and Andres
so that on modern compilers it provides a slight improvement over the
previous one.
This lets us clean up some places that were already with
localized hacks.
Most of the pg_malloc/palloc changes in this patch were authored by
Andres Freund. Zoltán Böszörményi also independently provided a form of
that. libpgcommon infrastructure was authored by Álvaro.
2013-02-12 14:33:40 +01:00
|
|
|
{
|
|
|
|
$proj->AddReference($libpgcommon);
|
|
|
|
}
|
2015-03-11 14:21:01 +01:00
|
|
|
if ($module_extralibs->{$n})
|
2007-03-17 14:50:42 +01:00
|
|
|
{
|
2015-03-11 14:21:01 +01:00
|
|
|
foreach my $l (@{ $module_extralibs->{$n} })
|
2007-03-17 14:50:42 +01:00
|
|
|
{
|
|
|
|
$proj->AddLibrary($l);
|
|
|
|
}
|
|
|
|
}
|
2015-03-11 14:21:01 +01:00
|
|
|
if ($module_extraincludes->{$n})
|
2007-03-17 14:50:42 +01:00
|
|
|
{
|
2015-03-11 14:21:01 +01:00
|
|
|
foreach my $i (@{ $module_extraincludes->{$n} })
|
2007-03-17 14:50:42 +01:00
|
|
|
{
|
|
|
|
$proj->AddIncludeDir($i);
|
|
|
|
}
|
|
|
|
}
|
2015-03-11 14:21:01 +01:00
|
|
|
if ($module_extrasource->{$n})
|
2007-03-17 14:50:42 +01:00
|
|
|
{
|
2015-03-11 14:21:01 +01:00
|
|
|
foreach my $i (@{ $module_extrasource->{$n} })
|
|
|
|
{
|
|
|
|
print "Files $i\n";
|
|
|
|
$proj->AddFile($i);
|
|
|
|
}
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
2018-05-27 15:08:42 +02:00
|
|
|
return;
|
2007-03-17 14:50:42 +01:00
|
|
|
}
|
|
|
|
|
2017-12-09 03:06:05 +01:00
|
|
|
END
|
|
|
|
{
|
|
|
|
unlink @unlink_on_exit;
|
|
|
|
}
|
|
|
|
|
2007-03-17 14:50:42 +01:00
|
|
|
1;
|