2006-09-04 23:30:40 +02:00
|
|
|
package Solution;
|
2007-03-29 17:30:52 +02:00
|
|
|
|
2007-03-17 15:01:01 +01:00
|
|
|
#
|
|
|
|
# Package that encapsulates a Visual C++ solution file generation
|
2007-03-29 17:30:52 +02:00
|
|
|
#
|
2010-09-20 22:08:53 +02:00
|
|
|
# src/tools/msvc/Solution.pm
|
2007-03-17 15:01:01 +01:00
|
|
|
#
|
2006-09-04 23:30:40 +02:00
|
|
|
use Carp;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
2012-01-03 14:44:26 +01:00
|
|
|
use VSObjectFactory;
|
2006-09-04 23:30:40 +02:00
|
|
|
|
2018-06-30 18:28:55 +02:00
|
|
|
no warnings qw(redefine); ## no critic
|
2018-05-31 14:13:02 +02:00
|
|
|
|
2012-01-03 14:44:26 +01:00
|
|
|
sub _new
|
2007-03-12 20:10:50 +01:00
|
|
|
{
|
2012-06-10 21:20:04 +02:00
|
|
|
my $classname = shift;
|
2012-07-05 03:47:49 +02:00
|
|
|
my $options = shift;
|
|
|
|
my $self = {
|
2014-05-06 18:12:18 +02:00
|
|
|
projects => {},
|
|
|
|
options => $options,
|
|
|
|
numver => '',
|
|
|
|
strver => '',
|
|
|
|
VisualStudioVersion => undef,
|
2014-01-26 15:49:10 +01:00
|
|
|
MinimumVisualStudioVersion => undef,
|
2014-05-06 18:12:18 +02:00
|
|
|
vcver => undef,
|
2018-05-09 16:14:46 +02:00
|
|
|
platform => undef,
|
|
|
|
};
|
2012-06-10 21:20:04 +02:00
|
|
|
bless($self, $classname);
|
|
|
|
|
2015-04-05 17:49:49 +02:00
|
|
|
$self->DeterminePlatform();
|
|
|
|
my $bits = $self->{platform} eq 'Win32' ? 32 : 64;
|
|
|
|
|
2012-06-10 21:20:04 +02:00
|
|
|
$options->{float4byval} = 1
|
|
|
|
unless exists $options->{float4byval};
|
2015-04-05 17:49:49 +02:00
|
|
|
$options->{float8byval} = ($bits == 64)
|
|
|
|
unless exists $options->{float8byval};
|
|
|
|
die "float8byval not permitted on 32 bit platforms"
|
2015-05-24 03:35:49 +02:00
|
|
|
if $options->{float8byval} && $bits == 32;
|
2016-09-11 18:46:55 +02:00
|
|
|
if ($options->{xslt} && !$options->{xml})
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2016-09-11 18:46:55 +02:00
|
|
|
die "XSLT requires XML\n";
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
$options->{blocksize} = 8
|
2012-07-05 03:47:49 +02:00
|
|
|
unless $options->{blocksize}; # undef or 0 means default
|
2012-06-10 21:20:04 +02:00
|
|
|
die "Bad blocksize $options->{blocksize}"
|
2012-07-05 03:47:49 +02:00
|
|
|
unless grep { $_ == $options->{blocksize} } (1, 2, 4, 8, 16, 32);
|
2012-06-10 21:20:04 +02:00
|
|
|
$options->{segsize} = 1
|
2012-07-05 03:47:49 +02:00
|
|
|
unless $options->{segsize}; # undef or 0 means default
|
|
|
|
# only allow segsize 1 for now, as we can't do large files yet in windows
|
2012-06-10 21:20:04 +02:00
|
|
|
die "Bad segsize $options->{segsize}"
|
|
|
|
unless $options->{segsize} == 1;
|
|
|
|
$options->{wal_blocksize} = 8
|
2012-07-05 03:47:49 +02:00
|
|
|
unless $options->{wal_blocksize}; # undef or 0 means default
|
2012-06-10 21:20:04 +02:00
|
|
|
die "Bad wal_blocksize $options->{wal_blocksize}"
|
2012-07-05 03:47:49 +02:00
|
|
|
unless grep { $_ == $options->{wal_blocksize} }
|
2018-04-25 20:00:19 +02:00
|
|
|
(1, 2, 4, 8, 16, 32, 64);
|
2012-06-10 21:20:04 +02:00
|
|
|
|
|
|
|
return $self;
|
2006-09-04 23:30:40 +02:00
|
|
|
}
|
|
|
|
|
2014-01-26 15:49:10 +01:00
|
|
|
sub GetAdditionalHeaders
|
|
|
|
{
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2012-01-03 14:44:26 +01:00
|
|
|
sub DeterminePlatform
|
2009-12-23 14:27:04 +01:00
|
|
|
{
|
2012-06-10 21:20:04 +02:00
|
|
|
my $self = shift;
|
|
|
|
|
2013-02-06 20:52:29 +01:00
|
|
|
# Examine CL help output to determine if we are in 32 or 64-bit mode.
|
2015-02-19 02:24:30 +01:00
|
|
|
my $output = `cl /? 2>&1`;
|
|
|
|
$? >> 8 == 0 or die "cl command not found";
|
|
|
|
$self->{platform} = ($output =~ /^\/favor:<.+AMD64/m) ? 'x64' : 'Win32';
|
2012-06-10 21:20:04 +02:00
|
|
|
print "Detected hardware platform: $self->{platform}\n";
|
2018-05-27 15:08:42 +02:00
|
|
|
return;
|
2009-12-23 14:27:04 +01:00
|
|
|
}
|
|
|
|
|
2006-09-04 23:30:40 +02:00
|
|
|
# Return 1 if $oldfile is newer than $newfile, or if $newfile doesn't exist.
|
|
|
|
# Special case - if config.pl has changed, always return 1
|
2007-03-12 20:10:50 +01:00
|
|
|
sub IsNewer
|
|
|
|
{
|
2012-06-10 21:20:04 +02:00
|
|
|
my ($newfile, $oldfile) = @_;
|
2017-11-13 03:43:32 +01:00
|
|
|
-e $oldfile or warn "source file \"$oldfile\" does not exist";
|
2015-04-25 14:52:03 +02:00
|
|
|
if ( $oldfile ne 'src/tools/msvc/config.pl'
|
|
|
|
&& $oldfile ne 'src/tools/msvc/config_default.pl')
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
return 1
|
2015-04-25 14:52:03 +02:00
|
|
|
if (-f 'src/tools/msvc/config.pl')
|
|
|
|
&& IsNewer($newfile, 'src/tools/msvc/config.pl');
|
2012-06-10 21:20:04 +02:00
|
|
|
return 1
|
2015-04-25 14:52:03 +02:00
|
|
|
if (-f 'src/tools/msvc/config_default.pl')
|
|
|
|
&& IsNewer($newfile, 'src/tools/msvc/config_default.pl');
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
return 1 if (!(-e $newfile));
|
|
|
|
my @nstat = stat($newfile);
|
|
|
|
my @ostat = stat($oldfile);
|
|
|
|
return 1 if ($nstat[9] < $ostat[9]);
|
|
|
|
return 0;
|
2006-09-04 23:30:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Copy a file, *not* preserving date. Only works for text files.
|
2007-03-12 20:10:50 +01:00
|
|
|
sub copyFile
|
|
|
|
{
|
2012-06-10 21:20:04 +02:00
|
|
|
my ($src, $dest) = @_;
|
2017-03-27 04:24:13 +02:00
|
|
|
open(my $i, '<', $src) || croak "Could not open $src";
|
|
|
|
open(my $o, '>', $dest) || croak "Could not open $dest";
|
|
|
|
while (<$i>)
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o $_;
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
2017-03-27 04:24:13 +02:00
|
|
|
close($i);
|
|
|
|
close($o);
|
2018-05-27 15:08:42 +02:00
|
|
|
return;
|
2006-09-04 23:30:40 +02:00
|
|
|
}
|
|
|
|
|
2007-03-12 20:10:50 +01:00
|
|
|
sub GenerateFiles
|
|
|
|
{
|
2012-06-10 21:20:04 +02:00
|
|
|
my $self = shift;
|
|
|
|
my $bits = $self->{platform} eq 'Win32' ? 32 : 64;
|
|
|
|
|
|
|
|
# Parse configure.in to get version numbers
|
2017-03-27 04:24:13 +02:00
|
|
|
open(my $c, '<', "configure.in")
|
2012-07-05 03:47:49 +02:00
|
|
|
|| confess("Could not open configure.in for reading\n");
|
2017-03-27 04:24:13 +02:00
|
|
|
while (<$c>)
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
if (/^AC_INIT\(\[PostgreSQL\], \[([^\]]+)\]/)
|
|
|
|
{
|
|
|
|
$self->{strver} = $1;
|
2016-08-15 19:49:49 +02:00
|
|
|
if ($self->{strver} !~ /^(\d+)(?:\.(\d+))?/)
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
confess "Bad format of version: $self->{strver}\n";
|
|
|
|
}
|
2016-08-15 19:49:49 +02:00
|
|
|
$self->{numver} = sprintf("%d%04d", $1, $2 ? $2 : 0);
|
|
|
|
$self->{majorver} = sprintf("%d", $1);
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
}
|
2017-03-27 04:24:13 +02:00
|
|
|
close($c);
|
2012-06-10 21:20:04 +02:00
|
|
|
confess "Unable to parse configure.in for all variables!"
|
|
|
|
if ($self->{strver} eq '' || $self->{numver} eq '');
|
|
|
|
|
2015-05-24 03:35:49 +02:00
|
|
|
if (IsNewer("src/include/pg_config_os.h", "src/include/port/win32.h"))
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
print "Copying pg_config_os.h...\n";
|
2015-05-24 03:35:49 +02:00
|
|
|
copyFile("src/include/port/win32.h", "src/include/pg_config_os.h");
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
|
2015-05-24 03:35:49 +02:00
|
|
|
if (IsNewer("src/include/pg_config.h", "src/include/pg_config.h.win32"))
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
print "Generating pg_config.h...\n";
|
2017-03-27 04:24:13 +02:00
|
|
|
open(my $i, '<', "src/include/pg_config.h.win32")
|
2012-06-10 21:20:04 +02:00
|
|
|
|| confess "Could not open pg_config.h.win32\n";
|
2017-03-27 04:24:13 +02:00
|
|
|
open(my $o, '>', "src/include/pg_config.h")
|
2012-07-05 03:47:49 +02:00
|
|
|
|| confess "Could not write to pg_config.h\n";
|
2014-07-14 20:07:12 +02:00
|
|
|
my $extraver = $self->{options}->{extraver};
|
|
|
|
$extraver = '' unless defined $extraver;
|
2017-03-27 04:24:13 +02:00
|
|
|
while (<$i>)
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2014-07-14 20:07:12 +02:00
|
|
|
s{PG_VERSION "[^"]+"}{PG_VERSION "$self->{strver}$extraver"};
|
2012-06-10 21:20:04 +02:00
|
|
|
s{PG_VERSION_NUM \d+}{PG_VERSION_NUM $self->{numver}};
|
2018-04-26 17:52:52 +02:00
|
|
|
s{PG_VERSION_STR "[^"]+"}{PG_VERSION_STR "PostgreSQL $self->{strver}$extraver, compiled by Visual C++ build " CppAsString2(_MSC_VER) ", $bits-bit"};
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o $_;
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o "#define PG_MAJORVERSION \"$self->{majorver}\"\n";
|
|
|
|
print $o "#define LOCALEDIR \"/share/locale\"\n"
|
2012-07-05 03:47:49 +02:00
|
|
|
if ($self->{options}->{nls});
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o "/* defines added by config steps */\n";
|
|
|
|
print $o "#ifndef IGNORE_CONFIGURED_SETTINGS\n";
|
|
|
|
print $o "#define USE_ASSERT_CHECKING 1\n"
|
2012-07-05 03:47:49 +02:00
|
|
|
if ($self->{options}->{asserts});
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o "#define USE_LDAP 1\n" if ($self->{options}->{ldap});
|
|
|
|
print $o "#define HAVE_LIBZ 1\n" if ($self->{options}->{zlib});
|
|
|
|
print $o "#define USE_OPENSSL 1\n" if ($self->{options}->{openssl});
|
|
|
|
print $o "#define ENABLE_NLS 1\n" if ($self->{options}->{nls});
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2017-05-18 01:01:23 +02:00
|
|
|
print $o "#define BLCKSZ ", 1024 * $self->{options}->{blocksize},
|
|
|
|
"\n";
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o "#define RELSEG_SIZE ",
|
2012-07-05 03:47:49 +02:00
|
|
|
(1024 / $self->{options}->{blocksize}) *
|
2018-04-25 20:00:19 +02:00
|
|
|
$self->{options}->{segsize} * 1024, "\n";
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o "#define XLOG_BLCKSZ ",
|
2012-07-05 03:47:49 +02:00
|
|
|
1024 * $self->{options}->{wal_blocksize}, "\n";
|
2012-06-10 21:20:04 +02:00
|
|
|
|
|
|
|
if ($self->{options}->{float4byval})
|
|
|
|
{
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o "#define USE_FLOAT4_BYVAL 1\n";
|
|
|
|
print $o "#define FLOAT4PASSBYVAL true\n";
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o "#define FLOAT4PASSBYVAL false\n";
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
if ($self->{options}->{float8byval})
|
|
|
|
{
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o "#define USE_FLOAT8_BYVAL 1\n";
|
|
|
|
print $o "#define FLOAT8PASSBYVAL true\n";
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o "#define FLOAT8PASSBYVAL false\n";
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($self->{options}->{uuid})
|
|
|
|
{
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o "#define HAVE_UUID_OSSP\n";
|
|
|
|
print $o "#define HAVE_UUID_H\n";
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
if ($self->{options}->{xml})
|
|
|
|
{
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o "#define HAVE_LIBXML2\n";
|
|
|
|
print $o "#define USE_LIBXML\n";
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
if ($self->{options}->{xslt})
|
|
|
|
{
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o "#define HAVE_LIBXSLT\n";
|
|
|
|
print $o "#define USE_LIBXSLT\n";
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
2014-01-19 17:07:15 +01:00
|
|
|
if ($self->{options}->{gss})
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o "#define ENABLE_GSS 1\n";
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
2017-06-12 17:05:20 +02:00
|
|
|
if ($self->{options}->{icu})
|
|
|
|
{
|
|
|
|
print $o "#define USE_ICU 1\n";
|
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
if (my $port = $self->{options}->{"--with-pgport"})
|
|
|
|
{
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o "#undef DEF_PGPORT\n";
|
|
|
|
print $o "#undef DEF_PGPORT_STR\n";
|
|
|
|
print $o "#define DEF_PGPORT $port\n";
|
|
|
|
print $o "#define DEF_PGPORT_STR \"$port\"\n";
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o "#define VAL_CONFIGURE \""
|
2012-07-05 03:47:49 +02:00
|
|
|
. $self->GetFakeConfigure() . "\"\n";
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o "#endif /* IGNORE_CONFIGURED_SETTINGS */\n";
|
|
|
|
close($o);
|
|
|
|
close($i);
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
|
2012-10-08 03:52:07 +02:00
|
|
|
if (IsNewer(
|
2015-04-25 14:52:03 +02:00
|
|
|
"src/include/pg_config_ext.h",
|
|
|
|
"src/include/pg_config_ext.h.win32"))
|
2012-10-08 03:52:07 +02:00
|
|
|
{
|
|
|
|
print "Copying pg_config_ext.h...\n";
|
2013-05-29 22:58:43 +02:00
|
|
|
copyFile(
|
2015-04-25 14:52:03 +02:00
|
|
|
"src/include/pg_config_ext.h.win32",
|
|
|
|
"src/include/pg_config_ext.h");
|
2012-10-08 03:52:07 +02:00
|
|
|
}
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
$self->GenerateDefFile(
|
2015-04-25 14:52:03 +02:00
|
|
|
"src/interfaces/libpq/libpqdll.def",
|
|
|
|
"src/interfaces/libpq/exports.txt",
|
2012-07-05 03:47:49 +02:00
|
|
|
"LIBPQ");
|
2012-06-10 21:20:04 +02:00
|
|
|
$self->GenerateDefFile(
|
2015-04-25 14:52:03 +02:00
|
|
|
"src/interfaces/ecpg/ecpglib/ecpglib.def",
|
|
|
|
"src/interfaces/ecpg/ecpglib/exports.txt",
|
2012-07-05 03:47:49 +02:00
|
|
|
"LIBECPG");
|
2012-06-10 21:20:04 +02:00
|
|
|
$self->GenerateDefFile(
|
2015-04-25 14:52:03 +02:00
|
|
|
"src/interfaces/ecpg/compatlib/compatlib.def",
|
|
|
|
"src/interfaces/ecpg/compatlib/exports.txt",
|
2012-07-05 03:47:49 +02:00
|
|
|
"LIBECPG_COMPAT");
|
2012-06-10 21:20:04 +02:00
|
|
|
$self->GenerateDefFile(
|
2015-04-25 14:52:03 +02:00
|
|
|
"src/interfaces/ecpg/pgtypeslib/pgtypeslib.def",
|
|
|
|
"src/interfaces/ecpg/pgtypeslib/exports.txt",
|
2012-07-05 03:47:49 +02:00
|
|
|
"LIBPGTYPES");
|
2012-06-10 21:20:04 +02:00
|
|
|
|
Replace our traditional initial-catalog-data format with a better design.
Historically, the initial catalog data to be installed during bootstrap
has been written in DATA() lines in the catalog header files. This had
lots of disadvantages: the format was badly underdocumented, it was
very difficult to edit the data in any mechanized way, and due to the
lack of any abstraction the data was verbose, hard to read/understand,
and easy to get wrong.
Hence, move this data into separate ".dat" files and represent it in a way
that can easily be read and rewritten by Perl scripts. The new format is
essentially "key => value" for each column; while it's a bit repetitive,
explicit labeling of each value makes the data far more readable and less
error-prone. Provide a way to abbreviate entries by omitting field values
that match a specified default value for their column. This allows removal
of a large amount of repetitive boilerplate and also lowers the barrier to
adding new columns.
Also teach genbki.pl how to translate symbolic OID references into
numeric OIDs for more cases than just "regproc"-like pg_proc references.
It can now do that for regprocedure-like references (thus solving the
problem that regproc is ambiguous for overloaded functions), operators,
types, opfamilies, opclasses, and access methods. Use this to turn
nearly all OID cross-references in the initial data into symbolic form.
This represents a very large step forward in readability and error
resistance of the initial catalog data. It should also reduce the
difficulty of renumbering OID assignments in uncommitted patches.
Also, solve the longstanding problem that frontend code that would like to
use OID macros and other information from the catalog headers often had
difficulty with backend-only code in the headers. To do this, arrange for
all generated macros, plus such other declarations as we deem fit, to be
placed in "derived" header files that are safe for frontend inclusion.
(Once clients migrate to using these pg_*_d.h headers, it will be possible
to get rid of the pg_*_fn.h headers, which only exist to quarantine code
away from clients. That is left for follow-on patches, however.)
The now-automatically-generated macros include the Anum_xxx and Natts_xxx
constants that we used to have to update by hand when adding or removing
catalog columns.
Replace the former manual method of generating OID macros for pg_type
entries with an automatic method, ensuring that all built-in types have
OID macros. (But note that this patch does not change the way that
OID macros for pg_proc entries are built and used. It's not clear that
making that match the other catalogs would be worth extra code churn.)
Add SGML documentation explaining what the new data format is and how to
work with it.
Despite being a very large change in the catalog headers, there is no
catversion bump here, because postgres.bki and related output files
haven't changed at all.
John Naylor, based on ideas from various people; review and minor
additional coding by me; previous review by Alvaro Herrera
Discussion: https://postgr.es/m/CAJVSVGWO48JbbwXkJz_yBFyGYW-M9YWxnPdxJBUosDC9ou_F0Q@mail.gmail.com
2018-04-08 19:16:50 +02:00
|
|
|
chdir('src/backend/utils');
|
2019-05-22 19:36:19 +02:00
|
|
|
my $pg_proc_dat = '../../../src/include/catalog/pg_proc.dat';
|
2018-05-04 00:47:41 +02:00
|
|
|
if ( IsNewer('fmgr-stamp', 'Gen_fmgrtab.pl')
|
|
|
|
|| IsNewer('fmgr-stamp', '../catalog/Catalog.pm')
|
|
|
|
|| IsNewer('fmgr-stamp', $pg_proc_dat)
|
|
|
|
|| IsNewer('fmgr-stamp', '../../../src/include/access/transam.h'))
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
system(
|
2019-02-12 22:29:26 +01:00
|
|
|
"perl -I ../catalog Gen_fmgrtab.pl --include-path ../../../src/include/ $pg_proc_dat"
|
2018-04-25 20:00:19 +02:00
|
|
|
);
|
2018-05-04 00:47:41 +02:00
|
|
|
open(my $f, '>', 'fmgr-stamp')
|
|
|
|
|| confess "Could not touch fmgr-stamp";
|
|
|
|
close($f);
|
2012-12-16 14:56:51 +01:00
|
|
|
}
|
Replace our traditional initial-catalog-data format with a better design.
Historically, the initial catalog data to be installed during bootstrap
has been written in DATA() lines in the catalog header files. This had
lots of disadvantages: the format was badly underdocumented, it was
very difficult to edit the data in any mechanized way, and due to the
lack of any abstraction the data was verbose, hard to read/understand,
and easy to get wrong.
Hence, move this data into separate ".dat" files and represent it in a way
that can easily be read and rewritten by Perl scripts. The new format is
essentially "key => value" for each column; while it's a bit repetitive,
explicit labeling of each value makes the data far more readable and less
error-prone. Provide a way to abbreviate entries by omitting field values
that match a specified default value for their column. This allows removal
of a large amount of repetitive boilerplate and also lowers the barrier to
adding new columns.
Also teach genbki.pl how to translate symbolic OID references into
numeric OIDs for more cases than just "regproc"-like pg_proc references.
It can now do that for regprocedure-like references (thus solving the
problem that regproc is ambiguous for overloaded functions), operators,
types, opfamilies, opclasses, and access methods. Use this to turn
nearly all OID cross-references in the initial data into symbolic form.
This represents a very large step forward in readability and error
resistance of the initial catalog data. It should also reduce the
difficulty of renumbering OID assignments in uncommitted patches.
Also, solve the longstanding problem that frontend code that would like to
use OID macros and other information from the catalog headers often had
difficulty with backend-only code in the headers. To do this, arrange for
all generated macros, plus such other declarations as we deem fit, to be
placed in "derived" header files that are safe for frontend inclusion.
(Once clients migrate to using these pg_*_d.h headers, it will be possible
to get rid of the pg_*_fn.h headers, which only exist to quarantine code
away from clients. That is left for follow-on patches, however.)
The now-automatically-generated macros include the Anum_xxx and Natts_xxx
constants that we used to have to update by hand when adding or removing
catalog columns.
Replace the former manual method of generating OID macros for pg_type
entries with an automatic method, ensuring that all built-in types have
OID macros. (But note that this patch does not change the way that
OID macros for pg_proc entries are built and used. It's not clear that
making that match the other catalogs would be worth extra code churn.)
Add SGML documentation explaining what the new data format is and how to
work with it.
Despite being a very large change in the catalog headers, there is no
catversion bump here, because postgres.bki and related output files
haven't changed at all.
John Naylor, based on ideas from various people; review and minor
additional coding by me; previous review by Alvaro Herrera
Discussion: https://postgr.es/m/CAJVSVGWO48JbbwXkJz_yBFyGYW-M9YWxnPdxJBUosDC9ou_F0Q@mail.gmail.com
2018-04-08 19:16:50 +02:00
|
|
|
chdir('../../..');
|
|
|
|
|
2013-05-29 22:58:43 +02:00
|
|
|
if (IsNewer(
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/include/utils/fmgroids.h',
|
|
|
|
'src/backend/utils/fmgroids.h'))
|
2012-12-16 14:56:51 +01:00
|
|
|
{
|
2015-04-25 14:52:03 +02:00
|
|
|
copyFile('src/backend/utils/fmgroids.h',
|
|
|
|
'src/include/utils/fmgroids.h');
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
|
2016-12-28 18:00:00 +01:00
|
|
|
if (IsNewer(
|
|
|
|
'src/include/utils/fmgrprotos.h',
|
|
|
|
'src/backend/utils/fmgrprotos.h'))
|
|
|
|
{
|
2017-05-18 01:01:23 +02:00
|
|
|
copyFile(
|
|
|
|
'src/backend/utils/fmgrprotos.h',
|
2016-12-28 18:00:00 +01:00
|
|
|
'src/include/utils/fmgrprotos.h');
|
|
|
|
}
|
|
|
|
|
2015-09-11 19:58:28 +02:00
|
|
|
if (IsNewer(
|
2016-06-12 10:19:56 +02:00
|
|
|
'src/include/storage/lwlocknames.h',
|
|
|
|
'src/backend/storage/lmgr/lwlocknames.txt'))
|
2015-09-11 19:58:28 +02:00
|
|
|
{
|
|
|
|
print "Generating lwlocknames.c and lwlocknames.h...\n";
|
|
|
|
chdir('src/backend/storage/lmgr');
|
|
|
|
system('perl generate-lwlocknames.pl lwlocknames.txt');
|
|
|
|
chdir('../../../..');
|
|
|
|
}
|
|
|
|
if (IsNewer(
|
|
|
|
'src/include/storage/lwlocknames.h',
|
|
|
|
'src/backend/storage/lmgr/lwlocknames.h'))
|
|
|
|
{
|
2016-06-12 10:19:56 +02:00
|
|
|
copyFile(
|
|
|
|
'src/backend/storage/lmgr/lwlocknames.h',
|
2015-09-11 19:58:28 +02:00
|
|
|
'src/include/storage/lwlocknames.h');
|
|
|
|
}
|
|
|
|
|
2015-04-25 14:52:03 +02:00
|
|
|
if (IsNewer('src/include/utils/probes.h', 'src/backend/utils/probes.d'))
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
print "Generating probes.h...\n";
|
|
|
|
system(
|
2018-04-26 17:52:52 +02:00
|
|
|
'perl src/backend/utils/Gen_dummy_probes.pl src/backend/utils/probes.d > src/include/utils/probes.h'
|
2012-06-10 21:20:04 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($self->{options}->{python}
|
2012-07-05 03:47:49 +02:00
|
|
|
&& IsNewer(
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/pl/plpython/spiexceptions.h',
|
2017-11-13 03:43:32 +01:00
|
|
|
'src/backend/utils/errcodes.txt'))
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
print "Generating spiexceptions.h...\n";
|
|
|
|
system(
|
2018-04-26 17:52:52 +02:00
|
|
|
'perl src/pl/plpython/generate-spiexceptions.pl src/backend/utils/errcodes.txt > src/pl/plpython/spiexceptions.h'
|
2012-06-10 21:20:04 +02:00
|
|
|
);
|
|
|
|
}
|
2011-02-28 17:41:10 +01:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
if (IsNewer(
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/include/utils/errcodes.h',
|
|
|
|
'src/backend/utils/errcodes.txt'))
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
print "Generating errcodes.h...\n";
|
|
|
|
system(
|
2018-04-26 17:52:52 +02:00
|
|
|
'perl src/backend/utils/generate-errcodes.pl src/backend/utils/errcodes.txt > src/backend/utils/errcodes.h'
|
2012-06-10 21:20:04 +02:00
|
|
|
);
|
2015-04-25 14:52:03 +02:00
|
|
|
copyFile('src/backend/utils/errcodes.h',
|
|
|
|
'src/include/utils/errcodes.h');
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
if (IsNewer(
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/pl/plpgsql/src/plerrcodes.h',
|
|
|
|
'src/backend/utils/errcodes.txt'))
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
print "Generating plerrcodes.h...\n";
|
|
|
|
system(
|
2018-04-26 17:52:52 +02:00
|
|
|
'perl src/pl/plpgsql/src/generate-plerrcodes.pl src/backend/utils/errcodes.txt > src/pl/plpgsql/src/plerrcodes.h'
|
2012-06-10 21:20:04 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-03-25 21:54:52 +01:00
|
|
|
if ($self->{options}->{tcl}
|
|
|
|
&& IsNewer(
|
2016-06-12 10:19:56 +02:00
|
|
|
'src/pl/tcl/pltclerrcodes.h', 'src/backend/utils/errcodes.txt'))
|
2016-03-25 21:54:52 +01:00
|
|
|
{
|
|
|
|
print "Generating pltclerrcodes.h...\n";
|
|
|
|
system(
|
2018-04-26 17:52:52 +02:00
|
|
|
'perl src/pl/tcl/generate-pltclerrcodes.pl src/backend/utils/errcodes.txt > src/pl/tcl/pltclerrcodes.h'
|
2016-03-25 21:54:52 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
if (IsNewer(
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/backend/utils/sort/qsort_tuple.c',
|
|
|
|
'src/backend/utils/sort/gen_qsort_tuple.pl'))
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
print "Generating qsort_tuple.c...\n";
|
|
|
|
system(
|
2018-04-26 17:52:52 +02:00
|
|
|
'perl src/backend/utils/sort/gen_qsort_tuple.pl > src/backend/utils/sort/qsort_tuple.c'
|
2012-06-10 21:20:04 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
if (IsNewer(
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/interfaces/libpq/libpq.rc',
|
|
|
|
'src/interfaces/libpq/libpq.rc.in'))
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
print "Generating libpq.rc...\n";
|
2012-07-05 03:47:49 +02:00
|
|
|
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
|
|
|
|
localtime(time);
|
2012-06-10 21:20:04 +02:00
|
|
|
my $d = ($year - 100) . "$yday";
|
2017-03-27 04:24:13 +02:00
|
|
|
open(my $i, '<', 'src/interfaces/libpq/libpq.rc.in')
|
2012-06-10 21:20:04 +02:00
|
|
|
|| confess "Could not open libpq.rc.in";
|
2017-03-27 04:24:13 +02:00
|
|
|
open(my $o, '>', 'src/interfaces/libpq/libpq.rc')
|
2012-07-05 03:47:49 +02:00
|
|
|
|| confess "Could not open libpq.rc";
|
2017-03-27 04:24:13 +02:00
|
|
|
while (<$i>)
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
s/(VERSION.*),0/$1,$d/;
|
2017-07-09 09:43:17 +02:00
|
|
|
print $o $_;
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
2017-03-27 04:24:13 +02:00
|
|
|
close($i);
|
|
|
|
close($o);
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
|
2015-04-25 14:52:03 +02:00
|
|
|
if (IsNewer('src/bin/psql/sql_help.h', 'src/bin/psql/create_help.pl'))
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
print "Generating sql_help.h...\n";
|
2015-04-25 14:52:03 +02:00
|
|
|
chdir('src/bin/psql');
|
2012-06-10 21:20:04 +02:00
|
|
|
system("perl create_help.pl ../../../doc/src/sgml/ref sql_help");
|
2015-04-25 14:52:03 +02:00
|
|
|
chdir('../../..');
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
|
2019-05-22 19:36:19 +02:00
|
|
|
if (IsNewer('src/common/kwlist_d.h', 'src/include/parser/kwlist.h'))
|
Replace the data structure used for keyword lookup.
Previously, ScanKeywordLookup was passed an array of string pointers.
This had some performance deficiencies: the strings themselves might
be scattered all over the place depending on the compiler (and some
quick checking shows that at least with gcc-on-Linux, they indeed
weren't reliably close together). That led to very cache-unfriendly
behavior as the binary search touched strings in many different pages.
Also, depending on the platform, the string pointers might need to
be adjusted at program start, so that they couldn't be simple constant
data. And the ScanKeyword struct had been designed with an eye to
32-bit machines originally; on 64-bit it requires 16 bytes per
keyword, making it even more cache-unfriendly.
Redesign so that the keyword strings themselves are allocated
consecutively (as part of one big char-string constant), thereby
eliminating the touch-lots-of-unrelated-pages syndrome. And get
rid of the ScanKeyword array in favor of three separate arrays:
uint16 offsets into the keyword array, uint16 token codes, and
uint8 keyword categories. That reduces the overhead per keyword
to 5 bytes instead of 16 (even less in programs that only need
one of the token codes and categories); moreover, the binary search
only touches the offsets array, further reducing its cache footprint.
This also lets us put the token codes somewhere else than the
keyword strings are, which avoids some unpleasant build dependencies.
While we're at it, wrap the data used by ScanKeywordLookup into
a struct that can be treated as an opaque type by most callers.
That doesn't change things much right now, but it will make it
less painful to switch to a hash-based lookup method, as is being
discussed in the mailing list thread.
Most of the change here is associated with adding a generator
script that can build the new data structure from the same
list-of-PG_KEYWORD header representation we used before.
The PG_KEYWORD lists that plpgsql and ecpg used to embed in
their scanner .c files have to be moved into headers, and the
Makefiles have to be taught to invoke the generator script.
This work is also necessary if we're to consider hash-based lookup,
since the generator script is what would be responsible for
constructing a hash table.
Aside from saving a few kilobytes in each program that includes
the keyword table, this seems to speed up raw parsing (flex+bison)
by a few percent. So it's worth doing even as it stands, though
we think we can gain even more with a follow-on patch to switch
to hash-based lookup.
John Naylor, with further hacking by me
Discussion: https://postgr.es/m/CAJVSVGXdFVU2sgym89XPL=Lv1zOS5=EHHQ8XWNzFL=mTXkKMLw@mail.gmail.com
2019-01-06 23:02:57 +01:00
|
|
|
{
|
|
|
|
print "Generating kwlist_d.h...\n";
|
2019-05-22 19:36:19 +02:00
|
|
|
system(
|
|
|
|
'perl -I src/tools src/tools/gen_keywordlist.pl --extern -o src/common src/include/parser/kwlist.h'
|
|
|
|
);
|
Replace the data structure used for keyword lookup.
Previously, ScanKeywordLookup was passed an array of string pointers.
This had some performance deficiencies: the strings themselves might
be scattered all over the place depending on the compiler (and some
quick checking shows that at least with gcc-on-Linux, they indeed
weren't reliably close together). That led to very cache-unfriendly
behavior as the binary search touched strings in many different pages.
Also, depending on the platform, the string pointers might need to
be adjusted at program start, so that they couldn't be simple constant
data. And the ScanKeyword struct had been designed with an eye to
32-bit machines originally; on 64-bit it requires 16 bytes per
keyword, making it even more cache-unfriendly.
Redesign so that the keyword strings themselves are allocated
consecutively (as part of one big char-string constant), thereby
eliminating the touch-lots-of-unrelated-pages syndrome. And get
rid of the ScanKeyword array in favor of three separate arrays:
uint16 offsets into the keyword array, uint16 token codes, and
uint8 keyword categories. That reduces the overhead per keyword
to 5 bytes instead of 16 (even less in programs that only need
one of the token codes and categories); moreover, the binary search
only touches the offsets array, further reducing its cache footprint.
This also lets us put the token codes somewhere else than the
keyword strings are, which avoids some unpleasant build dependencies.
While we're at it, wrap the data used by ScanKeywordLookup into
a struct that can be treated as an opaque type by most callers.
That doesn't change things much right now, but it will make it
less painful to switch to a hash-based lookup method, as is being
discussed in the mailing list thread.
Most of the change here is associated with adding a generator
script that can build the new data structure from the same
list-of-PG_KEYWORD header representation we used before.
The PG_KEYWORD lists that plpgsql and ecpg used to embed in
their scanner .c files have to be moved into headers, and the
Makefiles have to be taught to invoke the generator script.
This work is also necessary if we're to consider hash-based lookup,
since the generator script is what would be responsible for
constructing a hash table.
Aside from saving a few kilobytes in each program that includes
the keyword table, this seems to speed up raw parsing (flex+bison)
by a few percent. So it's worth doing even as it stands, though
we think we can gain even more with a follow-on patch to switch
to hash-based lookup.
John Naylor, with further hacking by me
Discussion: https://postgr.es/m/CAJVSVGXdFVU2sgym89XPL=Lv1zOS5=EHHQ8XWNzFL=mTXkKMLw@mail.gmail.com
2019-01-06 23:02:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (IsNewer(
|
|
|
|
'src/pl/plpgsql/src/pl_reserved_kwlist_d.h',
|
|
|
|
'src/pl/plpgsql/src/pl_reserved_kwlist.h')
|
|
|
|
|| IsNewer(
|
|
|
|
'src/pl/plpgsql/src/pl_unreserved_kwlist_d.h',
|
|
|
|
'src/pl/plpgsql/src/pl_unreserved_kwlist.h'))
|
|
|
|
{
|
2019-05-22 19:36:19 +02:00
|
|
|
print
|
|
|
|
"Generating pl_reserved_kwlist_d.h and pl_unreserved_kwlist_d.h...\n";
|
Replace the data structure used for keyword lookup.
Previously, ScanKeywordLookup was passed an array of string pointers.
This had some performance deficiencies: the strings themselves might
be scattered all over the place depending on the compiler (and some
quick checking shows that at least with gcc-on-Linux, they indeed
weren't reliably close together). That led to very cache-unfriendly
behavior as the binary search touched strings in many different pages.
Also, depending on the platform, the string pointers might need to
be adjusted at program start, so that they couldn't be simple constant
data. And the ScanKeyword struct had been designed with an eye to
32-bit machines originally; on 64-bit it requires 16 bytes per
keyword, making it even more cache-unfriendly.
Redesign so that the keyword strings themselves are allocated
consecutively (as part of one big char-string constant), thereby
eliminating the touch-lots-of-unrelated-pages syndrome. And get
rid of the ScanKeyword array in favor of three separate arrays:
uint16 offsets into the keyword array, uint16 token codes, and
uint8 keyword categories. That reduces the overhead per keyword
to 5 bytes instead of 16 (even less in programs that only need
one of the token codes and categories); moreover, the binary search
only touches the offsets array, further reducing its cache footprint.
This also lets us put the token codes somewhere else than the
keyword strings are, which avoids some unpleasant build dependencies.
While we're at it, wrap the data used by ScanKeywordLookup into
a struct that can be treated as an opaque type by most callers.
That doesn't change things much right now, but it will make it
less painful to switch to a hash-based lookup method, as is being
discussed in the mailing list thread.
Most of the change here is associated with adding a generator
script that can build the new data structure from the same
list-of-PG_KEYWORD header representation we used before.
The PG_KEYWORD lists that plpgsql and ecpg used to embed in
their scanner .c files have to be moved into headers, and the
Makefiles have to be taught to invoke the generator script.
This work is also necessary if we're to consider hash-based lookup,
since the generator script is what would be responsible for
constructing a hash table.
Aside from saving a few kilobytes in each program that includes
the keyword table, this seems to speed up raw parsing (flex+bison)
by a few percent. So it's worth doing even as it stands, though
we think we can gain even more with a follow-on patch to switch
to hash-based lookup.
John Naylor, with further hacking by me
Discussion: https://postgr.es/m/CAJVSVGXdFVU2sgym89XPL=Lv1zOS5=EHHQ8XWNzFL=mTXkKMLw@mail.gmail.com
2019-01-06 23:02:57 +01:00
|
|
|
chdir('src/pl/plpgsql/src');
|
2019-05-22 19:36:19 +02:00
|
|
|
system(
|
|
|
|
'perl -I ../../../tools ../../../tools/gen_keywordlist.pl --varname ReservedPLKeywords pl_reserved_kwlist.h'
|
|
|
|
);
|
|
|
|
system(
|
|
|
|
'perl -I ../../../tools ../../../tools/gen_keywordlist.pl --varname UnreservedPLKeywords pl_unreserved_kwlist.h'
|
|
|
|
);
|
Replace the data structure used for keyword lookup.
Previously, ScanKeywordLookup was passed an array of string pointers.
This had some performance deficiencies: the strings themselves might
be scattered all over the place depending on the compiler (and some
quick checking shows that at least with gcc-on-Linux, they indeed
weren't reliably close together). That led to very cache-unfriendly
behavior as the binary search touched strings in many different pages.
Also, depending on the platform, the string pointers might need to
be adjusted at program start, so that they couldn't be simple constant
data. And the ScanKeyword struct had been designed with an eye to
32-bit machines originally; on 64-bit it requires 16 bytes per
keyword, making it even more cache-unfriendly.
Redesign so that the keyword strings themselves are allocated
consecutively (as part of one big char-string constant), thereby
eliminating the touch-lots-of-unrelated-pages syndrome. And get
rid of the ScanKeyword array in favor of three separate arrays:
uint16 offsets into the keyword array, uint16 token codes, and
uint8 keyword categories. That reduces the overhead per keyword
to 5 bytes instead of 16 (even less in programs that only need
one of the token codes and categories); moreover, the binary search
only touches the offsets array, further reducing its cache footprint.
This also lets us put the token codes somewhere else than the
keyword strings are, which avoids some unpleasant build dependencies.
While we're at it, wrap the data used by ScanKeywordLookup into
a struct that can be treated as an opaque type by most callers.
That doesn't change things much right now, but it will make it
less painful to switch to a hash-based lookup method, as is being
discussed in the mailing list thread.
Most of the change here is associated with adding a generator
script that can build the new data structure from the same
list-of-PG_KEYWORD header representation we used before.
The PG_KEYWORD lists that plpgsql and ecpg used to embed in
their scanner .c files have to be moved into headers, and the
Makefiles have to be taught to invoke the generator script.
This work is also necessary if we're to consider hash-based lookup,
since the generator script is what would be responsible for
constructing a hash table.
Aside from saving a few kilobytes in each program that includes
the keyword table, this seems to speed up raw parsing (flex+bison)
by a few percent. So it's worth doing even as it stands, though
we think we can gain even more with a follow-on patch to switch
to hash-based lookup.
John Naylor, with further hacking by me
Discussion: https://postgr.es/m/CAJVSVGXdFVU2sgym89XPL=Lv1zOS5=EHHQ8XWNzFL=mTXkKMLw@mail.gmail.com
2019-01-06 23:02:57 +01:00
|
|
|
chdir('../../../..');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsNewer(
|
|
|
|
'src/interfaces/ecpg/preproc/c_kwlist_d.h',
|
|
|
|
'src/interfaces/ecpg/preproc/c_kwlist.h')
|
|
|
|
|| IsNewer(
|
|
|
|
'src/interfaces/ecpg/preproc/ecpg_kwlist_d.h',
|
|
|
|
'src/interfaces/ecpg/preproc/ecpg_kwlist.h'))
|
|
|
|
{
|
|
|
|
print "Generating c_kwlist_d.h and ecpg_kwlist_d.h...\n";
|
|
|
|
chdir('src/interfaces/ecpg/preproc');
|
2019-05-22 19:36:19 +02:00
|
|
|
system(
|
|
|
|
'perl -I ../../../tools ../../../tools/gen_keywordlist.pl --varname ScanCKeywords --no-case-fold c_kwlist.h'
|
|
|
|
);
|
|
|
|
system(
|
|
|
|
'perl -I ../../../tools ../../../tools/gen_keywordlist.pl --varname ScanECPGKeywords ecpg_kwlist.h'
|
|
|
|
);
|
Replace the data structure used for keyword lookup.
Previously, ScanKeywordLookup was passed an array of string pointers.
This had some performance deficiencies: the strings themselves might
be scattered all over the place depending on the compiler (and some
quick checking shows that at least with gcc-on-Linux, they indeed
weren't reliably close together). That led to very cache-unfriendly
behavior as the binary search touched strings in many different pages.
Also, depending on the platform, the string pointers might need to
be adjusted at program start, so that they couldn't be simple constant
data. And the ScanKeyword struct had been designed with an eye to
32-bit machines originally; on 64-bit it requires 16 bytes per
keyword, making it even more cache-unfriendly.
Redesign so that the keyword strings themselves are allocated
consecutively (as part of one big char-string constant), thereby
eliminating the touch-lots-of-unrelated-pages syndrome. And get
rid of the ScanKeyword array in favor of three separate arrays:
uint16 offsets into the keyword array, uint16 token codes, and
uint8 keyword categories. That reduces the overhead per keyword
to 5 bytes instead of 16 (even less in programs that only need
one of the token codes and categories); moreover, the binary search
only touches the offsets array, further reducing its cache footprint.
This also lets us put the token codes somewhere else than the
keyword strings are, which avoids some unpleasant build dependencies.
While we're at it, wrap the data used by ScanKeywordLookup into
a struct that can be treated as an opaque type by most callers.
That doesn't change things much right now, but it will make it
less painful to switch to a hash-based lookup method, as is being
discussed in the mailing list thread.
Most of the change here is associated with adding a generator
script that can build the new data structure from the same
list-of-PG_KEYWORD header representation we used before.
The PG_KEYWORD lists that plpgsql and ecpg used to embed in
their scanner .c files have to be moved into headers, and the
Makefiles have to be taught to invoke the generator script.
This work is also necessary if we're to consider hash-based lookup,
since the generator script is what would be responsible for
constructing a hash table.
Aside from saving a few kilobytes in each program that includes
the keyword table, this seems to speed up raw parsing (flex+bison)
by a few percent. So it's worth doing even as it stands, though
we think we can gain even more with a follow-on patch to switch
to hash-based lookup.
John Naylor, with further hacking by me
Discussion: https://postgr.es/m/CAJVSVGXdFVU2sgym89XPL=Lv1zOS5=EHHQ8XWNzFL=mTXkKMLw@mail.gmail.com
2019-01-06 23:02:57 +01:00
|
|
|
chdir('../../../..');
|
|
|
|
}
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
if (IsNewer(
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/interfaces/ecpg/preproc/preproc.y',
|
|
|
|
'src/backend/parser/gram.y'))
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
print "Generating preproc.y...\n";
|
2015-04-25 14:52:03 +02:00
|
|
|
chdir('src/interfaces/ecpg/preproc');
|
|
|
|
system('perl parse.pl < ../../../backend/parser/gram.y > preproc.y');
|
|
|
|
chdir('../../../..');
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
if (IsNewer(
|
2015-04-25 14:52:03 +02:00
|
|
|
'src/interfaces/ecpg/include/ecpg_config.h',
|
|
|
|
'src/interfaces/ecpg/include/ecpg_config.h.in'))
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
print "Generating ecpg_config.h...\n";
|
2017-03-27 04:24:13 +02:00
|
|
|
open(my $o, '>', 'src/interfaces/ecpg/include/ecpg_config.h')
|
2012-06-10 21:20:04 +02:00
|
|
|
|| confess "Could not open ecpg_config.h";
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o <<EOF;
|
2006-09-15 23:42:02 +02:00
|
|
|
#if (_MSC_VER > 1200)
|
2018-02-27 22:46:52 +01:00
|
|
|
#define HAVE_LONG_LONG_INT 1
|
2017-09-03 17:01:08 +02:00
|
|
|
#define HAVE_LONG_LONG_INT_64 1
|
2018-02-27 22:46:52 +01:00
|
|
|
#endif
|
2007-03-29 17:30:52 +02:00
|
|
|
#define ENABLE_THREAD_SAFETY 1
|
2006-09-15 23:42:02 +02:00
|
|
|
EOF
|
2017-03-27 04:24:13 +02:00
|
|
|
close($o);
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
|
2015-04-25 14:52:03 +02:00
|
|
|
unless (-f "src/port/pg_config_paths.h")
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
print "Generating pg_config_paths.h...\n";
|
2017-03-27 04:24:13 +02:00
|
|
|
open(my $o, '>', 'src/port/pg_config_paths.h')
|
2012-06-10 21:20:04 +02:00
|
|
|
|| confess "Could not open pg_config_paths.h";
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o <<EOF;
|
2007-02-08 16:28:58 +01:00
|
|
|
#define PGBINDIR "/bin"
|
|
|
|
#define PGSHAREDIR "/share"
|
|
|
|
#define SYSCONFDIR "/etc"
|
|
|
|
#define INCLUDEDIR "/include"
|
|
|
|
#define PKGINCLUDEDIR "/include"
|
|
|
|
#define INCLUDEDIRSERVER "/include/server"
|
|
|
|
#define LIBDIR "/lib"
|
|
|
|
#define PKGLIBDIR "/lib"
|
|
|
|
#define LOCALEDIR "/share/locale"
|
|
|
|
#define DOCDIR "/doc"
|
2008-02-19 13:00:03 +01:00
|
|
|
#define HTMLDIR "/doc"
|
2007-02-08 16:28:58 +01:00
|
|
|
#define MANDIR "/man"
|
2006-09-04 23:30:40 +02:00
|
|
|
EOF
|
2017-03-27 04:24:13 +02:00
|
|
|
close($o);
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
|
2015-04-25 14:52:03 +02:00
|
|
|
my $mf = Project::read_file('src/backend/catalog/Makefile');
|
2014-07-14 20:07:27 +02:00
|
|
|
$mf =~ s{\\\r?\n}{}g;
|
Replace our traditional initial-catalog-data format with a better design.
Historically, the initial catalog data to be installed during bootstrap
has been written in DATA() lines in the catalog header files. This had
lots of disadvantages: the format was badly underdocumented, it was
very difficult to edit the data in any mechanized way, and due to the
lack of any abstraction the data was verbose, hard to read/understand,
and easy to get wrong.
Hence, move this data into separate ".dat" files and represent it in a way
that can easily be read and rewritten by Perl scripts. The new format is
essentially "key => value" for each column; while it's a bit repetitive,
explicit labeling of each value makes the data far more readable and less
error-prone. Provide a way to abbreviate entries by omitting field values
that match a specified default value for their column. This allows removal
of a large amount of repetitive boilerplate and also lowers the barrier to
adding new columns.
Also teach genbki.pl how to translate symbolic OID references into
numeric OIDs for more cases than just "regproc"-like pg_proc references.
It can now do that for regprocedure-like references (thus solving the
problem that regproc is ambiguous for overloaded functions), operators,
types, opfamilies, opclasses, and access methods. Use this to turn
nearly all OID cross-references in the initial data into symbolic form.
This represents a very large step forward in readability and error
resistance of the initial catalog data. It should also reduce the
difficulty of renumbering OID assignments in uncommitted patches.
Also, solve the longstanding problem that frontend code that would like to
use OID macros and other information from the catalog headers often had
difficulty with backend-only code in the headers. To do this, arrange for
all generated macros, plus such other declarations as we deem fit, to be
placed in "derived" header files that are safe for frontend inclusion.
(Once clients migrate to using these pg_*_d.h headers, it will be possible
to get rid of the pg_*_fn.h headers, which only exist to quarantine code
away from clients. That is left for follow-on patches, however.)
The now-automatically-generated macros include the Anum_xxx and Natts_xxx
constants that we used to have to update by hand when adding or removing
catalog columns.
Replace the former manual method of generating OID macros for pg_type
entries with an automatic method, ensuring that all built-in types have
OID macros. (But note that this patch does not change the way that
OID macros for pg_proc entries are built and used. It's not clear that
making that match the other catalogs would be worth extra code churn.)
Add SGML documentation explaining what the new data format is and how to
work with it.
Despite being a very large change in the catalog headers, there is no
catversion bump here, because postgres.bki and related output files
haven't changed at all.
John Naylor, based on ideas from various people; review and minor
additional coding by me; previous review by Alvaro Herrera
Discussion: https://postgr.es/m/CAJVSVGWO48JbbwXkJz_yBFyGYW-M9YWxnPdxJBUosDC9ou_F0Q@mail.gmail.com
2018-04-08 19:16:50 +02:00
|
|
|
$mf =~ /^CATALOG_HEADERS\s*:?=(.*)$/gm
|
|
|
|
|| croak "Could not find CATALOG_HEADERS in Makefile\n";
|
|
|
|
my @bki_srcs = split /\s+/, $1;
|
|
|
|
push @bki_srcs, 'toasting.h';
|
|
|
|
push @bki_srcs, 'indexing.h';
|
|
|
|
$mf =~ /^POSTGRES_BKI_DATA\s*:?=[^,]+,(.*)\)$/gm
|
|
|
|
|| croak "Could not find POSTGRES_BKI_DATA in Makefile\n";
|
|
|
|
my @bki_data = split /\s+/, $1;
|
2018-04-25 20:00:19 +02:00
|
|
|
|
2018-05-04 00:47:41 +02:00
|
|
|
my $need_genbki = 0;
|
Replace our traditional initial-catalog-data format with a better design.
Historically, the initial catalog data to be installed during bootstrap
has been written in DATA() lines in the catalog header files. This had
lots of disadvantages: the format was badly underdocumented, it was
very difficult to edit the data in any mechanized way, and due to the
lack of any abstraction the data was verbose, hard to read/understand,
and easy to get wrong.
Hence, move this data into separate ".dat" files and represent it in a way
that can easily be read and rewritten by Perl scripts. The new format is
essentially "key => value" for each column; while it's a bit repetitive,
explicit labeling of each value makes the data far more readable and less
error-prone. Provide a way to abbreviate entries by omitting field values
that match a specified default value for their column. This allows removal
of a large amount of repetitive boilerplate and also lowers the barrier to
adding new columns.
Also teach genbki.pl how to translate symbolic OID references into
numeric OIDs for more cases than just "regproc"-like pg_proc references.
It can now do that for regprocedure-like references (thus solving the
problem that regproc is ambiguous for overloaded functions), operators,
types, opfamilies, opclasses, and access methods. Use this to turn
nearly all OID cross-references in the initial data into symbolic form.
This represents a very large step forward in readability and error
resistance of the initial catalog data. It should also reduce the
difficulty of renumbering OID assignments in uncommitted patches.
Also, solve the longstanding problem that frontend code that would like to
use OID macros and other information from the catalog headers often had
difficulty with backend-only code in the headers. To do this, arrange for
all generated macros, plus such other declarations as we deem fit, to be
placed in "derived" header files that are safe for frontend inclusion.
(Once clients migrate to using these pg_*_d.h headers, it will be possible
to get rid of the pg_*_fn.h headers, which only exist to quarantine code
away from clients. That is left for follow-on patches, however.)
The now-automatically-generated macros include the Anum_xxx and Natts_xxx
constants that we used to have to update by hand when adding or removing
catalog columns.
Replace the former manual method of generating OID macros for pg_type
entries with an automatic method, ensuring that all built-in types have
OID macros. (But note that this patch does not change the way that
OID macros for pg_proc entries are built and used. It's not clear that
making that match the other catalogs would be worth extra code churn.)
Add SGML documentation explaining what the new data format is and how to
work with it.
Despite being a very large change in the catalog headers, there is no
catversion bump here, because postgres.bki and related output files
haven't changed at all.
John Naylor, based on ideas from various people; review and minor
additional coding by me; previous review by Alvaro Herrera
Discussion: https://postgr.es/m/CAJVSVGWO48JbbwXkJz_yBFyGYW-M9YWxnPdxJBUosDC9ou_F0Q@mail.gmail.com
2018-04-08 19:16:50 +02:00
|
|
|
foreach my $bki (@bki_srcs, @bki_data)
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
next if $bki eq "";
|
2012-07-05 03:47:49 +02:00
|
|
|
if (IsNewer(
|
2018-05-04 00:47:41 +02:00
|
|
|
'src/backend/catalog/bki-stamp',
|
2012-07-05 03:47:49 +02:00
|
|
|
"src/include/catalog/$bki"))
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2018-05-04 00:47:41 +02:00
|
|
|
$need_genbki = 1;
|
2012-06-10 21:20:04 +02:00
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
2018-05-04 00:47:41 +02:00
|
|
|
$need_genbki = 1
|
|
|
|
if IsNewer('src/backend/catalog/bki-stamp',
|
|
|
|
'src/backend/catalog/genbki.pl');
|
|
|
|
$need_genbki = 1
|
|
|
|
if IsNewer('src/backend/catalog/bki-stamp',
|
|
|
|
'src/backend/catalog/Catalog.pm');
|
|
|
|
if ($need_genbki)
|
|
|
|
{
|
|
|
|
chdir('src/backend/catalog');
|
|
|
|
my $bki_srcs = join(' ../../../src/include/catalog/', @bki_srcs);
|
2019-05-22 19:36:19 +02:00
|
|
|
system(
|
|
|
|
"perl genbki.pl --include-path ../../../src/include/ --set-version=$self->{majorver} $bki_srcs"
|
|
|
|
);
|
2018-05-04 00:47:41 +02:00
|
|
|
open(my $f, '>', 'bki-stamp')
|
|
|
|
|| confess "Could not touch bki-stamp";
|
|
|
|
close($f);
|
|
|
|
chdir('../../..');
|
2018-05-18 17:53:18 +02:00
|
|
|
}
|
2018-05-04 00:47:41 +02:00
|
|
|
|
2018-05-18 17:53:18 +02:00
|
|
|
if (IsNewer(
|
|
|
|
'src/include/catalog/header-stamp',
|
|
|
|
'src/backend/catalog/bki-stamp'))
|
|
|
|
{
|
2018-05-04 00:47:41 +02:00
|
|
|
# Copy generated headers to include directory.
|
|
|
|
opendir(my $dh, 'src/backend/catalog/')
|
|
|
|
|| die "Can't opendir src/backend/catalog/ $!";
|
|
|
|
my @def_headers = grep { /pg_\w+_d\.h$/ } readdir($dh);
|
|
|
|
closedir $dh;
|
|
|
|
foreach my $def_header (@def_headers)
|
|
|
|
{
|
|
|
|
copyFile(
|
|
|
|
"src/backend/catalog/$def_header",
|
|
|
|
"src/include/catalog/$def_header");
|
|
|
|
}
|
|
|
|
copyFile(
|
|
|
|
'src/backend/catalog/schemapg.h',
|
|
|
|
'src/include/catalog/schemapg.h');
|
2018-05-18 17:53:18 +02:00
|
|
|
open(my $chs, '>', 'src/include/catalog/header-stamp')
|
|
|
|
|| confess "Could not touch header-stamp";
|
|
|
|
close($chs);
|
2018-05-04 00:47:41 +02:00
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2017-03-27 04:24:13 +02:00
|
|
|
open(my $o, '>', "doc/src/sgml/version.sgml")
|
2012-07-05 03:47:49 +02:00
|
|
|
|| croak "Could not write to version.sgml\n";
|
2017-03-27 04:24:13 +02:00
|
|
|
print $o <<EOF;
|
2011-04-04 22:42:42 +02:00
|
|
|
<!ENTITY version "$self->{strver}">
|
|
|
|
<!ENTITY majorversion "$self->{majorver}">
|
2007-03-06 15:16:55 +01:00
|
|
|
EOF
|
2017-03-27 04:24:13 +02:00
|
|
|
close($o);
|
2018-05-27 15:08:42 +02:00
|
|
|
return;
|
2006-09-04 23:30:40 +02:00
|
|
|
}
|
|
|
|
|
2007-10-03 14:11:00 +02:00
|
|
|
sub GenerateDefFile
|
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
my ($self, $deffile, $txtfile, $libname) = @_;
|
2012-06-10 21:20:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
if (IsNewer($deffile, $txtfile))
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
print "Generating $deffile...\n";
|
2017-03-27 04:24:13 +02:00
|
|
|
open(my $if, '<', $txtfile) || confess("Could not open $txtfile\n");
|
|
|
|
open(my $of, '>', $deffile) || confess("Could not open $deffile\n");
|
|
|
|
print $of "LIBRARY $libname\nEXPORTS\n";
|
|
|
|
while (<$if>)
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
next if (/^#/);
|
|
|
|
next if (/^\s*$/);
|
|
|
|
my ($f, $o) = split;
|
2017-03-27 04:24:13 +02:00
|
|
|
print $of " $f @ $o\n";
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
2017-03-27 04:24:13 +02:00
|
|
|
close($of);
|
|
|
|
close($if);
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
2018-05-27 15:08:42 +02:00
|
|
|
return;
|
2007-10-03 14:11:00 +02:00
|
|
|
}
|
|
|
|
|
2007-03-12 20:10:50 +01:00
|
|
|
sub AddProject
|
|
|
|
{
|
2012-06-10 21:20:04 +02:00
|
|
|
my ($self, $name, $type, $folder, $initialdir) = @_;
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
my $proj =
|
|
|
|
VSObjectFactory::CreateProject($self->{vcver}, $name, $type, $self);
|
|
|
|
push @{ $self->{projects}->{$folder} }, $proj;
|
2012-06-10 21:20:04 +02:00
|
|
|
$proj->AddDir($initialdir) if ($initialdir);
|
|
|
|
if ($self->{options}->{zlib})
|
|
|
|
{
|
|
|
|
$proj->AddIncludeDir($self->{options}->{zlib} . '\include');
|
|
|
|
$proj->AddLibrary($self->{options}->{zlib} . '\lib\zdll.lib');
|
|
|
|
}
|
|
|
|
if ($self->{options}->{openssl})
|
|
|
|
{
|
|
|
|
$proj->AddIncludeDir($self->{options}->{openssl} . '\include');
|
2017-06-06 02:38:46 +02:00
|
|
|
if (-e "$self->{options}->{openssl}/lib/VC/ssleay32MD.lib")
|
2017-06-05 20:24:42 +02:00
|
|
|
{
|
|
|
|
$proj->AddLibrary(
|
|
|
|
$self->{options}->{openssl} . '\lib\VC\ssleay32.lib', 1);
|
|
|
|
$proj->AddLibrary(
|
|
|
|
$self->{options}->{openssl} . '\lib\VC\libeay32.lib', 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-01-03 21:26:39 +01:00
|
|
|
# We don't expect the config-specific library to be here,
|
|
|
|
# so don't ask for it in last parameter
|
2017-06-05 20:24:42 +02:00
|
|
|
$proj->AddLibrary(
|
2018-01-03 21:26:39 +01:00
|
|
|
$self->{options}->{openssl} . '\lib\ssleay32.lib', 0);
|
2017-06-05 20:24:42 +02:00
|
|
|
$proj->AddLibrary(
|
2018-01-03 21:26:39 +01:00
|
|
|
$self->{options}->{openssl} . '\lib\libeay32.lib', 0);
|
2017-06-05 20:24:42 +02:00
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
if ($self->{options}->{nls})
|
|
|
|
{
|
|
|
|
$proj->AddIncludeDir($self->{options}->{nls} . '\include');
|
|
|
|
$proj->AddLibrary($self->{options}->{nls} . '\lib\libintl.lib');
|
|
|
|
}
|
2014-01-19 17:07:15 +01:00
|
|
|
if ($self->{options}->{gss})
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2014-01-19 17:07:15 +01:00
|
|
|
$proj->AddIncludeDir($self->{options}->{gss} . '\inc\krb5');
|
|
|
|
$proj->AddLibrary($self->{options}->{gss} . '\lib\i386\krb5_32.lib');
|
2014-05-06 18:12:18 +02:00
|
|
|
$proj->AddLibrary($self->{options}->{gss} . '\lib\i386\comerr32.lib');
|
|
|
|
$proj->AddLibrary($self->{options}->{gss} . '\lib\i386\gssapi32.lib');
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
if ($self->{options}->{iconv})
|
|
|
|
{
|
|
|
|
$proj->AddIncludeDir($self->{options}->{iconv} . '\include');
|
|
|
|
$proj->AddLibrary($self->{options}->{iconv} . '\lib\iconv.lib');
|
|
|
|
}
|
2017-06-12 17:05:20 +02:00
|
|
|
if ($self->{options}->{icu})
|
|
|
|
{
|
|
|
|
$proj->AddIncludeDir($self->{options}->{icu} . '\include');
|
2017-06-13 15:13:32 +02:00
|
|
|
if ($self->{platform} eq 'Win32')
|
|
|
|
{
|
|
|
|
$proj->AddLibrary($self->{options}->{icu} . '\lib\icuin.lib');
|
|
|
|
$proj->AddLibrary($self->{options}->{icu} . '\lib\icuuc.lib');
|
|
|
|
$proj->AddLibrary($self->{options}->{icu} . '\lib\icudt.lib');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$proj->AddLibrary($self->{options}->{icu} . '\lib64\icuin.lib');
|
|
|
|
$proj->AddLibrary($self->{options}->{icu} . '\lib64\icuuc.lib');
|
|
|
|
$proj->AddLibrary($self->{options}->{icu} . '\lib64\icudt.lib');
|
|
|
|
}
|
2017-06-12 17:05:20 +02:00
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
if ($self->{options}->{xml})
|
|
|
|
{
|
|
|
|
$proj->AddIncludeDir($self->{options}->{xml} . '\include');
|
2017-05-12 16:17:54 +02:00
|
|
|
$proj->AddIncludeDir($self->{options}->{xml} . '\include\libxml2');
|
2012-06-10 21:20:04 +02:00
|
|
|
$proj->AddLibrary($self->{options}->{xml} . '\lib\libxml2.lib');
|
|
|
|
}
|
|
|
|
if ($self->{options}->{xslt})
|
|
|
|
{
|
|
|
|
$proj->AddIncludeDir($self->{options}->{xslt} . '\include');
|
|
|
|
$proj->AddLibrary($self->{options}->{xslt} . '\lib\libxslt.lib');
|
|
|
|
}
|
2016-09-11 18:46:55 +02:00
|
|
|
if ($self->{options}->{uuid})
|
|
|
|
{
|
|
|
|
$proj->AddIncludeDir($self->{options}->{uuid} . '\include');
|
|
|
|
$proj->AddLibrary($self->{options}->{uuid} . '\lib\uuid.lib');
|
|
|
|
}
|
2012-06-10 21:20:04 +02:00
|
|
|
return $proj;
|
2006-09-04 23:30:40 +02:00
|
|
|
}
|
|
|
|
|
2007-03-12 20:10:50 +01:00
|
|
|
sub Save
|
|
|
|
{
|
2012-06-10 21:20:04 +02:00
|
|
|
my ($self) = @_;
|
|
|
|
my %flduid;
|
|
|
|
|
|
|
|
$self->GenerateFiles();
|
2012-07-05 03:47:49 +02:00
|
|
|
foreach my $fld (keys %{ $self->{projects} })
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
foreach my $proj (@{ $self->{projects}->{$fld} })
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
$proj->Save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-27 04:24:13 +02:00
|
|
|
open(my $sln, '>', "pgsql.sln") || croak "Could not write to pgsql.sln\n";
|
|
|
|
print $sln <<EOF;
|
2012-01-03 14:44:26 +01:00
|
|
|
Microsoft Visual Studio Solution File, Format Version $self->{solutionFileVersion}
|
|
|
|
# $self->{visualStudioName}
|
2006-09-04 23:30:40 +02:00
|
|
|
EOF
|
|
|
|
|
2017-03-27 04:24:13 +02:00
|
|
|
print $sln $self->GetAdditionalHeaders();
|
2014-01-26 15:49:10 +01:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
foreach my $fld (keys %{ $self->{projects} })
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
foreach my $proj (@{ $self->{projects}->{$fld} })
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2017-03-27 04:24:13 +02:00
|
|
|
print $sln <<EOF;
|
2012-01-03 14:44:26 +01:00
|
|
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "$proj->{name}", "$proj->{name}$proj->{filenameExtension}", "$proj->{guid}"
|
2006-09-04 23:30:40 +02:00
|
|
|
EndProject
|
|
|
|
EOF
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
if ($fld ne "")
|
|
|
|
{
|
|
|
|
$flduid{$fld} = Win32::GuidGen();
|
2017-03-27 04:24:13 +02:00
|
|
|
print $sln <<EOF;
|
2006-09-04 23:30:40 +02:00
|
|
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "$fld", "$fld", "$flduid{$fld}"
|
|
|
|
EndProject
|
|
|
|
EOF
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
}
|
2006-09-04 23:30:40 +02:00
|
|
|
|
2017-03-27 04:24:13 +02:00
|
|
|
print $sln <<EOF;
|
2006-09-04 23:30:40 +02:00
|
|
|
Global
|
|
|
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
2010-01-01 18:34:25 +01:00
|
|
|
Debug|$self->{platform}= Debug|$self->{platform}
|
|
|
|
Release|$self->{platform} = Release|$self->{platform}
|
2006-09-04 23:30:40 +02:00
|
|
|
EndGlobalSection
|
|
|
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
|
|
EOF
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
foreach my $fld (keys %{ $self->{projects} })
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2012-07-05 03:47:49 +02:00
|
|
|
foreach my $proj (@{ $self->{projects}->{$fld} })
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2017-03-27 04:24:13 +02:00
|
|
|
print $sln <<EOF;
|
2010-01-01 18:34:25 +01:00
|
|
|
$proj->{guid}.Debug|$self->{platform}.ActiveCfg = Debug|$self->{platform}
|
|
|
|
$proj->{guid}.Debug|$self->{platform}.Build.0 = Debug|$self->{platform}
|
|
|
|
$proj->{guid}.Release|$self->{platform}.ActiveCfg = Release|$self->{platform}
|
|
|
|
$proj->{guid}.Release|$self->{platform}.Build.0 = Release|$self->{platform}
|
2006-09-04 23:30:40 +02:00
|
|
|
EOF
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
}
|
2006-09-04 23:30:40 +02:00
|
|
|
|
2017-03-27 04:24:13 +02:00
|
|
|
print $sln <<EOF;
|
2006-09-04 23:30:40 +02:00
|
|
|
EndGlobalSection
|
|
|
|
GlobalSection(SolutionProperties) = preSolution
|
|
|
|
HideSolutionNode = FALSE
|
|
|
|
EndGlobalSection
|
|
|
|
GlobalSection(NestedProjects) = preSolution
|
|
|
|
EOF
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
foreach my $fld (keys %{ $self->{projects} })
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
|
|
|
next if ($fld eq "");
|
2012-07-05 03:47:49 +02:00
|
|
|
foreach my $proj (@{ $self->{projects}->{$fld} })
|
2012-06-10 21:20:04 +02:00
|
|
|
{
|
2017-03-27 04:24:13 +02:00
|
|
|
print $sln "\t\t$proj->{guid} = $flduid{$fld}\n";
|
2012-06-10 21:20:04 +02:00
|
|
|
}
|
|
|
|
}
|
2006-09-04 23:30:40 +02:00
|
|
|
|
2017-03-27 04:24:13 +02:00
|
|
|
print $sln <<EOF;
|
2006-09-04 23:30:40 +02:00
|
|
|
EndGlobalSection
|
|
|
|
EndGlobal
|
|
|
|
EOF
|
2017-03-27 04:24:13 +02:00
|
|
|
close($sln);
|
2018-05-27 15:08:42 +02:00
|
|
|
return;
|
2006-09-04 23:30:40 +02:00
|
|
|
}
|
|
|
|
|
2007-04-26 12:36:47 +02:00
|
|
|
sub GetFakeConfigure
|
|
|
|
{
|
2012-06-10 21:20:04 +02:00
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
my $cfg = '--enable-thread-safety';
|
2017-05-18 01:01:23 +02:00
|
|
|
$cfg .= ' --enable-cassert' if ($self->{options}->{asserts});
|
2016-06-12 10:19:56 +02:00
|
|
|
$cfg .= ' --enable-nls' if ($self->{options}->{nls});
|
2016-03-04 16:59:47 +01:00
|
|
|
$cfg .= ' --enable-tap-tests' if ($self->{options}->{tap_tests});
|
2016-06-12 10:19:56 +02:00
|
|
|
$cfg .= ' --with-ldap' if ($self->{options}->{ldap});
|
2012-06-10 21:20:04 +02:00
|
|
|
$cfg .= ' --without-zlib' unless ($self->{options}->{zlib});
|
2014-07-12 19:36:28 +02:00
|
|
|
$cfg .= ' --with-extra-version' if ($self->{options}->{extraver});
|
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
|
|
|
$cfg .= ' --with-openssl' if ($self->{options}->{openssl});
|
2014-07-12 19:36:28 +02:00
|
|
|
$cfg .= ' --with-ossp-uuid' if ($self->{options}->{uuid});
|
|
|
|
$cfg .= ' --with-libxml' if ($self->{options}->{xml});
|
|
|
|
$cfg .= ' --with-libxslt' if ($self->{options}->{xslt});
|
|
|
|
$cfg .= ' --with-gssapi' if ($self->{options}->{gss});
|
2017-06-12 17:05:20 +02:00
|
|
|
$cfg .= ' --with-icu' if ($self->{options}->{icu});
|
2014-07-12 19:36:28 +02:00
|
|
|
$cfg .= ' --with-tcl' if ($self->{options}->{tcl});
|
|
|
|
$cfg .= ' --with-perl' if ($self->{options}->{perl});
|
|
|
|
$cfg .= ' --with-python' if ($self->{options}->{python});
|
2012-06-10 21:20:04 +02:00
|
|
|
|
|
|
|
return $cfg;
|
2007-04-26 12:36:47 +02:00
|
|
|
}
|
|
|
|
|
2014-01-26 15:49:10 +01:00
|
|
|
package VS2013Solution;
|
|
|
|
|
|
|
|
#
|
|
|
|
# Package that encapsulates a Visual Studio 2013 solution file
|
|
|
|
#
|
|
|
|
|
|
|
|
use Carp;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use base qw(Solution);
|
|
|
|
|
2018-06-30 18:28:55 +02:00
|
|
|
no warnings qw(redefine); ## no critic
|
2018-05-31 14:13:02 +02:00
|
|
|
|
2014-01-26 15:49:10 +01:00
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my $classname = shift;
|
|
|
|
my $self = $classname->SUPER::_new(@_);
|
|
|
|
bless($self, $classname);
|
|
|
|
|
2014-05-30 09:27:40 +02:00
|
|
|
$self->{solutionFileVersion} = '12.00';
|
|
|
|
$self->{vcver} = '12.00';
|
|
|
|
$self->{visualStudioName} = 'Visual Studio 2013';
|
|
|
|
$self->{VisualStudioVersion} = '12.0.21005.1';
|
|
|
|
$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
|
2014-01-26 15:49:10 +01:00
|
|
|
|
2014-05-30 09:27:40 +02:00
|
|
|
return $self;
|
2014-01-26 15:49:10 +01:00
|
|
|
}
|
|
|
|
|
2016-04-29 13:59:47 +02:00
|
|
|
package VS2015Solution;
|
|
|
|
|
|
|
|
#
|
|
|
|
# Package that encapsulates a Visual Studio 2015 solution file
|
|
|
|
#
|
|
|
|
|
|
|
|
use Carp;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use base qw(Solution);
|
|
|
|
|
2018-06-30 18:28:55 +02:00
|
|
|
no warnings qw(redefine); ## no critic
|
2018-05-31 14:13:02 +02:00
|
|
|
|
2016-04-29 13:59:47 +02:00
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my $classname = shift;
|
|
|
|
my $self = $classname->SUPER::_new(@_);
|
|
|
|
bless($self, $classname);
|
|
|
|
|
|
|
|
$self->{solutionFileVersion} = '12.00';
|
|
|
|
$self->{vcver} = '14.00';
|
|
|
|
$self->{visualStudioName} = 'Visual Studio 2015';
|
|
|
|
$self->{VisualStudioVersion} = '14.0.24730.2';
|
|
|
|
$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
|
|
|
|
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
2017-09-25 14:03:05 +02:00
|
|
|
package VS2017Solution;
|
|
|
|
|
|
|
|
#
|
|
|
|
# Package that encapsulates a Visual Studio 2017 solution file
|
|
|
|
#
|
|
|
|
|
|
|
|
use Carp;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use base qw(Solution);
|
|
|
|
|
2018-06-30 18:28:55 +02:00
|
|
|
no warnings qw(redefine); ## no critic
|
2018-05-31 14:13:02 +02:00
|
|
|
|
2017-09-25 14:03:05 +02:00
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my $classname = shift;
|
|
|
|
my $self = $classname->SUPER::_new(@_);
|
|
|
|
bless($self, $classname);
|
|
|
|
|
|
|
|
$self->{solutionFileVersion} = '12.00';
|
|
|
|
$self->{vcver} = '15.00';
|
|
|
|
$self->{visualStudioName} = 'Visual Studio 2017';
|
|
|
|
$self->{VisualStudioVersion} = '15.0.26730.3';
|
|
|
|
$self->{MinimumVisualStudioVersion} = '10.0.40219.1';
|
|
|
|
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
2014-01-26 15:49:10 +01:00
|
|
|
sub GetAdditionalHeaders
|
|
|
|
{
|
|
|
|
my ($self, $f) = @_;
|
|
|
|
|
|
|
|
return qq|VisualStudioVersion = $self->{VisualStudioVersion}
|
|
|
|
MinimumVisualStudioVersion = $self->{MinimumVisualStudioVersion}
|
|
|
|
|;
|
|
|
|
}
|
|
|
|
|
2006-09-04 23:30:40 +02:00
|
|
|
1;
|