Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for running on Windows #233

Merged
merged 18 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
2a919d8
Extract source: Output special includes as include files, not source …
lfittl Dec 30, 2023
c546c48
Add src/include folder for internal headers and included .c files
lfittl Dec 30, 2023
5913775
Avoid use of mmap, asprintf and strndup to improve portability
lfittl Dec 30, 2023
1a39cc9
Improve handling of Postgres version-related defines
lfittl Jan 1, 2024
85c0264
GH actions: Update to actions/checkout@v4
lfittl Jan 1, 2024
d081aa7
extract_source: Improve rewriting of thread local variables in includes
lfittl Jan 1, 2024
b2be8d5
Remove strnlen fallback implementation
lfittl Jan 1, 2024
eb9c256
Further improve compatibility with non-POSIX systems and C89 compilers
lfittl Jan 1, 2024
52164d8
extract_source: Handle additional includes that are always needed dir…
lfittl Jan 1, 2024
ee67862
Windows support: Keep port/win32{,_msvc} includes and add to CFLAGS
lfittl Jan 1, 2024
ab3adeb
Windows support: Simplify write_stderr and should_output_to_client
lfittl Jan 1, 2024
c3d58c6
Windows support: Pull in necessary code during source extraction
lfittl Jan 1, 2024
c407f72
Windows support: Add fallback implementation for strlcpy
lfittl Jan 1, 2024
d564c68
Windows support: Use correct pg_config defines when on _WIN32/_WIN64
lfittl Jan 1, 2024
8e91de2
Windows support: Use pg_config_os.h to include port/win32.h if needed
lfittl Jan 1, 2024
f23298f
Windows support: Add Makefile.msvc for building with MSVC and "nmake"
lfittl Jan 1, 2024
8ca6228
Windows support: Add GitHub actions for testing with MSVC and MSYS2
lfittl Jan 1, 2024
59586e4
Windows support: Don't use CRLFs for regression test .sql files
lfittl Jan 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sql binary
39 changes: 38 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
valgrind: [valgrind,no-valgrind]
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Cache protobuf library
if: matrix.protobuf_lib == 'protobuf-cpp'
id: cache-protobuf
Expand Down Expand Up @@ -71,3 +71,40 @@ jobs:
run: make $FLAGS
env:
FLAGS: ${{ format('{0} {1} {2}', steps.make_flags.outputs.proto_flags, steps.make_flags.outputs.compiler_flags, steps.make_flags.outputs.debug_flags) }}
build_windows_msvc:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
arch: [x64, x86]
steps:
- name: Configure MSVC developer console
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- name: Check out code
uses: actions/checkout@v4
- name: Build and run tests
run: nmake /F Makefile.msvc
build_windows_msys2:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
sys: [mingw64, mingw32, ucrt64, clang64]
steps:
- name: Set up MSYS2 and compiler
uses: msys2/setup-msys2@v2
with:
msystem: ${{matrix.sys}}
pacboy: >-
toolchain:p
install: >-
make
diffutils
- name: Check out code
uses: actions/checkout@v4
- name: Build and run tests
shell: msys2 {0}
run: |
make
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ postgres.tar.bz2

*.o
*.a
*.obj
pg_query.lib

examples/*
!examples/*.c
Expand All @@ -17,3 +19,5 @@ test/*.dSYM

tmp/*
!tmp/.gitkeep

.vs/*
47 changes: 34 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ PGDIRBZ2 = $(root_dir)/tmp/postgres.tar.bz2

PG_VERSION = 16.1
PG_VERSION_MAJOR = $(call word-dot,$(PG_VERSION),1)
PG_VERSION_NUM = 160001
PROTOC_VERSION = 25.1

VERSION = 5.0.0
Expand All @@ -30,10 +31,13 @@ else
endif

SRC_FILES := $(wildcard src/*.c src/postgres/*.c) vendor/protobuf-c/protobuf-c.c vendor/xxhash/xxhash.c protobuf/pg_query.pb-c.c
NOT_OBJ_FILES := src/pg_query_enum_defs.o src/pg_query_fingerprint_defs.o src/pg_query_fingerprint_conds.o src/pg_query_outfuncs_defs.o src/pg_query_outfuncs_conds.o src/pg_query_readfuncs_defs.o src/pg_query_readfuncs_conds.o src/postgres/guc-file.o src/postgres/scan.o src/pg_query_json_helper.o $(patsubst %.c,%.o,$(wildcard src/postgres/src_backend_nodes_*.funcs.c))
OBJ_FILES := $(filter-out $(NOT_OBJ_FILES), $(SRC_FILES:.c=.o))
OBJ_FILES := $(SRC_FILES:.c=.o)

override CFLAGS += -g -I. -I./vendor -I./src/postgres/include -Wall -Wno-unused-function -Wno-unused-value -Wno-unused-variable -fno-strict-aliasing -fwrapv -fPIC
override CFLAGS += -g -I. -I./vendor -I./src/include -I./src/postgres/include -Wall -Wno-unused-function -Wno-unused-value -Wno-unused-variable -fno-strict-aliasing -fwrapv -fPIC

ifeq ($(OS),Windows_NT)
override CFLAGS += -I./src/postgres/include/port/win32
endif

override PG_CONFIGURE_FLAGS += -q --without-readline --without-zlib --without-icu

Expand Down Expand Up @@ -80,7 +84,7 @@ CC ?= cc
# Experimental use of Protobuf C++ library, primarily used to validate JSON output matches Protobuf JSON mapping
CXX_SRC_FILES := src/pg_query_outfuncs_protobuf_cpp.cc protobuf/pg_query.pb.cc
ifeq ($(USE_PROTOBUF_CPP),1)
override CXXFLAGS += `pkg-config --cflags protobuf` -I. -I./src/postgres/include -DHAVE_PTHREAD -std=c++17 -Wall -Wno-unused-function -Wno-zero-length-array -Wno-c99-extensions -fwrapv -fPIC
override CXXFLAGS += `pkg-config --cflags protobuf` -I. -I./src/include -I./src/postgres/include -DHAVE_PTHREAD -std=c++17 -Wall -Wno-unused-function -Wno-zero-length-array -Wno-c99-extensions -fwrapv -fPIC
ifeq ($(DEBUG),1)
override CXXFLAGS += -O0 -g
else
Expand All @@ -90,7 +94,7 @@ ifeq ($(USE_PROTOBUF_CPP),1)

# Don't use regular Protobuf-C or JSON implementation (instead implement the same methods using the C++ library)
SRC_FILES := $(filter-out src/pg_query_outfuncs_json.c src/pg_query_outfuncs_protobuf.c, $(SRC_FILES))
OBJ_FILES := $(filter-out $(NOT_OBJ_FILES), $(SRC_FILES:.c=.o)) $(CXX_SRC_FILES:.cc=.o)
OBJ_FILES := $(SRC_FILES:.c=.o) $(CXX_SRC_FILES:.cc=.o)
else
# Make sure we always clean C++ object files
CLEANOBJS += $(CXX_SRC_FILES:.cc=.o)
Expand Down Expand Up @@ -132,21 +136,38 @@ $(PGDIR):
echo "#define StaticAssertDecl(condition, errmessage)" >> $(PGDIR)/src/include/c.h
# Add pg_config.h overrides
cat scripts/pg_config_overrides.h >> $(PGDIR)/src/include/pg_config.h
# Only define strlcpy when needed
sed -i "" '$(shell echo 's/\#include "c.h"/#include "c.h"\n#if HAVE_DECL_STRLCPY == 0/')' $(PGDIR)/src/port/strlcpy.c
echo "#endif // HAVE_DECL_STRLCPY == 0" >> $(PGDIR)/src/port/strlcpy.c
# Define symbols needed by elog.c that are commonly defined by win32/signal.c
echo "#ifdef WIN32" >> $(PGDIR)/src/backend/utils/error/elog.c
echo "volatile int pg_signal_queue;" >> $(PGDIR)/src/backend/utils/error/elog.c
echo "int pg_signal_mask;" >> $(PGDIR)/src/backend/utils/error/elog.c
echo "void pgwin32_dispatch_queued_signals(void) {}" >> $(PGDIR)/src/backend/utils/error/elog.c
echo "#endif" >> $(PGDIR)/src/backend/utils/error/elog.c

extract_source: $(PGDIR)
-@ $(RM) -rf ./src/postgres/
mkdir ./src/postgres
mkdir ./src/postgres/include
LIBCLANG=/Library/Developer/CommandLineTools/usr/lib/libclang.dylib ruby ./scripts/extract_source.rb $(PGDIR)/ ./src/postgres/
cp $(PGDIR)/src/include/storage/dsm_impl.h ./src/postgres/include/storage
cp $(PGDIR)/src/include/port/atomics/arch-x86.h ./src/postgres/include/port/atomics
cp $(PGDIR)/src/include/port/atomics/arch-arm.h ./src/postgres/include/port/atomics
cp $(PGDIR)/src/include/port/atomics/arch-ppc.h ./src/postgres/include/port/atomics
touch ./src/postgres/guc-file.c
# Override OS-specific pg_config_os.h to only load Win32 logic (the primary port logic that matters for libpg_query), if needed
echo "#if defined(_WIN32) || defined(_WIN64)" > ./src/postgres/include/pg_config_os.h
echo "#include \"port/win32.h\"" >> ./src/postgres/include/pg_config_os.h
# Don't mark anything as visible based on how Postgres defines it
echo "#undef PGDLLIMPORT" >> ./src/postgres/include/pg_config_os.h
echo "#undef PGDLLEXPORT" >> ./src/postgres/include/pg_config_os.h
# Avoid getting incorrect sigsetjmp overrides
echo "#ifdef __clang__" >> ./src/postgres/include/pg_config_os.h
echo "#undef __MINGW64__" >> ./src/postgres/include/pg_config_os.h
echo "#endif /* __clang__ */" >> ./src/postgres/include/pg_config_os.h
echo "#endif" >> ./src/postgres/include/pg_config_os.h
# Adjust version string to ignore differences in build environments
sed -i "" '$(shell echo 's/\#define PG_VERSION_STR .*/#define PG_VERSION_STR "PostgreSQL $(PG_VERSION) \(libpg_query\)"/')' ./src/postgres/include/pg_config.h
# Copy version information so its easily accessible
sed -i "" '$(shell echo 's/\#define PG_MAJORVERSION .*/'`grep "\#define PG_MAJORVERSION " ./src/postgres/include/pg_config.h`'/')' pg_query.h
sed -i "" '$(shell echo 's/\#define PG_VERSION .*/'`grep "\#define PG_VERSION " ./src/postgres/include/pg_config.h`'/')' pg_query.h
sed -i "" '$(shell echo 's/\#define PG_VERSION_NUM .*/'`grep "\#define PG_VERSION_NUM " ./src/postgres/include/pg_config.h`'/')' pg_query.h
sed -i "" '$(shell echo 's/\#define PG_MAJORVERSION .*/#define PG_MAJORVERSION "$(PG_VERSION_MAJOR)"/')' pg_query.h
sed -i "" '$(shell echo 's/\#define PG_VERSION .*/#define PG_VERSION "$(PG_VERSION)"/')' pg_query.h
sed -i "" '$(shell echo 's/\#define PG_VERSION_NUM .*/#define PG_VERSION_NUM $(PG_VERSION_NUM)/')' pg_query.h
# Copy regress SQL files so we can use them in tests
rm -f ./test/sql/postgres_regress/*.sql
cp $(PGDIR)/src/test/regress/sql/*.sql ./test/sql/postgres_regress/
Expand Down
108 changes: 108 additions & 0 deletions Makefile.msvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Makefile for "nmake", part of Microsoft Visual Studio Compiler (MSVC) on Windows
Copy link
Member

@seanlinsley seanlinsley Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should go ahead and switch to a platform-independent build script to avoid makefile drift. Since we already include Ruby, maybe it could be a set of rake tasks?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point re: Makefile drift. I wonder if there is a way to maintain the list of tests (and examples) another way, or just discover all of them in the test/examples directories, to avoid having to add new tests to both.

Generating Makefiles could work, but I worry that the indirection (i.e. having to go through a generation script first) isn't obvious - i.e. I'd prefer if we could find a way to avoid that extra step.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about something like CMake / Meson, which generates Makefiles on *nix platforms and NMake specific Makefiles on Windows?

Copy link
Member Author

@lfittl lfittl Jan 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Postgres itself started using Meson for this purpose, but that of course then introduces a build-time dependency (which I'm 50/50 on whether its okay to add).

I think for now I'll not adjust this since this is already a massive PR, but I think we could come back to this at a future time.

One approach to solving the duplication for tests/examples specifically could be to have a Makefile in the tests and examples folders that can run on either platform. The main motivation for not doing that in the root folder Makefile is that there are a bunch of features not supported by nmake that make it hard to write a portable Makefile that can do the code generation/etc conditionally.


TARGET = pg_query
ARLIB = $(TARGET).lib

SRC_FILES = src/*.c src/postgres/*.c vendor/protobuf-c/protobuf-c.c vendor/xxhash/xxhash.c protobuf/pg_query.pb-c.c

CFLAGS = -I. -I./vendor -I./src/postgres/include -I./src/include -I./src/postgres/include/port/win32 -I./src/postgres/include/port/win32_msvc

RM = del

all: examples test build

build: $(ARLIB)

clean:
$(RM) *.obj
$(RM) pg_query.lib

.PHONY: all clean build build_shared extract_source examples test install

$(ARLIB): clean $(SRC_FILES)
$(CC) $(CFLAGS) /c $(SRC_FILES)
lib /OUT:pg_query.lib *.obj

EXAMPLES = examples/simple examples/scan examples/normalize examples/simple_error examples/normalize_error examples/simple_plpgsql
examples: $(EXAMPLES)
.\examples\simple
.\examples\scan
.\examples\normalize
.\examples\simple_error
.\examples\normalize_error
.\examples\simple_plpgsql

examples/simple: examples/simple.c $(ARLIB)
$(CC) $(CFLAGS) -o $@ examples/simple.c $(ARLIB)

examples/scan: examples/scan.c $(ARLIB)
$(CC) $(CFLAGS) -o $@ examples/scan.c $(ARLIB)

examples/normalize: examples/normalize.c $(ARLIB)
$(CC) $(CFLAGS) -o $@ examples/normalize.c $(ARLIB)

examples/simple_error: examples/simple_error.c $(ARLIB)
$(CC) $(CFLAGS) -o $@ examples/simple_error.c $(ARLIB)

examples/normalize_error: examples/normalize_error.c $(ARLIB)
$(CC) $(CFLAGS) -o $@ examples/normalize_error.c $(ARLIB)

examples/simple_plpgsql: examples/simple_plpgsql.c $(ARLIB)
$(CC) $(CFLAGS) -o $@ examples/simple_plpgsql.c $(ARLIB)

TESTS = test/deparse test/fingerprint test/fingerprint_opts test/normalize test/parse test/parse_opts test/parse_protobuf test/parse_protobuf_opts test/parse_plpgsql test/scan test/split
test: $(TESTS)
.\test\deparse
.\test\fingerprint
.\test\fingerprint_opts
.\test\normalize
.\test\parse
.\test\parse_opts
.\test\parse_protobuf
.\test\parse_protobuf_opts
.\test\scan
.\test\split

# Doesn't work because of C2026: string too big, trailing characters truncated
#test/complex: test/complex.c $(ARLIB)
# We have "-Isrc/" because this test uses pg_query_fingerprint_with_opts
# $(CC) $(CFLAGS) -o $@ -Isrc/ test/complex.c $(ARLIB)

# Doesn't work since this requires pthreads
#test/concurrency: test/concurrency.c test/parse_tests.c $(ARLIB)
# $(CC) $(CFLAGS) -o $@ test/concurrency.c $(ARLIB)

test/deparse: test/deparse.c test/deparse_tests.c $(ARLIB)
$(CC) $(CFLAGS) -o $@ test/deparse.c $(ARLIB)

test/fingerprint: test/fingerprint.c test/fingerprint_tests.c $(ARLIB)
# We have "-Isrc/" because this test uses pg_query_fingerprint_with_opts
$(CC) $(CFLAGS) -o $@ -Isrc/ test/fingerprint.c $(ARLIB)

test/fingerprint_opts: test/fingerprint_opts.c test/fingerprint_opts_tests.c $(ARLIB)
# We have "-Isrc/" because this test uses pg_query_fingerprint_with_opts
$(CC) $(CFLAGS) -o $@ -Isrc/ test/fingerprint_opts.c $(ARLIB)

test/normalize: test/normalize.c test/normalize_tests.c $(ARLIB)
$(CC) $(CFLAGS) -o $@ test/normalize.c $(ARLIB)

test/parse: test/parse.c test/parse_tests.c $(ARLIB)
$(CC) $(CFLAGS) -o $@ test/parse.c $(ARLIB)

test/parse_opts: test/parse_opts.c test/parse_opts_tests.c $(ARLIB)
$(CC) $(CFLAGS) -o $@ test/parse_opts.c $(ARLIB)

test/parse_plpgsql: test/parse_plpgsql.c test/parse_tests.c $(ARLIB)
$(CC) $(CFLAGS) -o $@ test/parse_plpgsql.c $(ARLIB)

test/parse_protobuf: test/parse_protobuf.c test/parse_tests.c $(ARLIB)
$(CC) $(CFLAGS) -o $@ test/parse_protobuf.c $(ARLIB)

test/parse_protobuf_opts: test/parse_protobuf_opts.c test/parse_opts_tests.c $(ARLIB)
$(CC) $(CFLAGS) -o $@ test/parse_protobuf_opts.c $(ARLIB)

test/scan: test/scan.c test/scan_tests.c $(ARLIB)
$(CC) $(CFLAGS) -o $@ test/scan.c $(ARLIB)

test/split: test/split.c test/split_tests.c $(ARLIB)
$(CC) $(CFLAGS) -o $@ test/split.c $(ARLIB)
72 changes: 59 additions & 13 deletions scripts/extract_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def run
@basepath + 'src/port/win32env.c', # Win32 only
@basepath + 'src/port/win32security.c', # Win32 only
@basepath + 'src/port/gettimeofday.c', # Win32 only
@basepath + 'src/port/strlcpy.c', # Not needed and conflicts with available function
@basepath + 'src/port/strnlen.c', # Not needed and conflicts with available function
@basepath + 'src/port/strlcat.c', # Not needed and conflicts with available function
@basepath + 'src/port/unsetenv.c', # Not needed and conflicts with available function
@basepath + 'src/port/getaddrinfo.c', # Not needed and conflicts with available function
Expand Down Expand Up @@ -214,14 +214,33 @@ def self.analysis_filename(filename, basepath)

def analyze_file(file)
index = FFI::Clang::Index.new(true, true)
translation_unit = index.parse_translation_unit(file, [
flags = [
'-I', @basepath + 'src/include',
'-I', '/usr/local/opt/openssl/include',
'-I', `xcrun --sdk macosx --show-sdk-path`.strip + '/usr/include',
'-DDLSUFFIX=".bundle"',
'-g',
'-DUSE_ASSERT_CHECKING'
])
'-ferror-limit=0',
'-DUSE_ASSERT_CHECKING',
# EXEC_BACKEND is used on Windows, and can always be safely set during code analysis
'-DEXEC_BACKEND',
]

# For certain files, use WIN32 define - we can't always do this since it pulls unnecessary code in other cases
if file == @basepath + 'src/backend/utils/error/elog.c' || file == @basepath + 'src/backend/utils/mb/mbutils.c'
flags << '-DWIN32'
flags << '-D__CYGWIN__' # Avoid pulling in win32_port.h (which includes a bunch of system headers we don't actually have)
end

# To override built-ins, we must avoid pulling in any system headers, so pretend we already defined c.h
if file == @basepath + 'src/port/strlcpy.c'
flags << '-DC_H'
flags << '-DHAVE_DECL_STRLCPY=0'
flags << '-Dsize_t=unsigned'
end

translation_unit = index.parse_translation_unit(file, flags)

cursor = translation_unit.cursor

func_cursor = nil
Expand Down Expand Up @@ -363,7 +382,7 @@ def deep_resolve(method_name, depth: 0, trail: [], global_resolved_by_parent: []
end

def special_include_file?(filename)
filename[/\/(reg(c|e)_[\w_]+|guc-file|qsort_tuple|repl_scanner|levenshtein|bootscanner|like_match)\.c$/] || filename[/\/[\w_]+_impl.h$/]
filename[/\/(reg(c|e)_[\w_]+|guc-file|qsort_tuple|repl_scanner|levenshtein|bootscanner|like_match)\.c$/] || filename[/\/[\w_]+\.funcs.c$/] || filename[/\/[\w_]+_impl.h$/]
end

def write_out
Expand Down Expand Up @@ -427,20 +446,22 @@ def write_out
end
all_thread_local_variables += file_thread_local_variables

if special_include_file?(filename)
out_name = File.basename(filename)
else
unless special_include_file?(filename)
out_name = filename.gsub(%r{^#{@basepath}}, '').gsub('/', '_')
File.write(@out_path + out_name, str)
end

File.write(@out_path + out_name, str)
end

#return

@include_files_to_output.each do |include_file|
next if special_include_file?(include_file)
additional_includes = Dir.glob(@basepath + 'src/include/storage/dsm_impl.h') +
Dir.glob(@basepath + 'src/include/port/atomics/**/*.h') +
Dir.glob(@basepath + 'src/include/port/win32/**/*.h') +
Dir.glob(@basepath + 'src/include/port/win32_msvc/**/*.h') +
Dir.glob(@basepath + 'src/include/port/win32.h') +
Dir.glob(@basepath + 'src/include/port/win32_port.h')

(@include_files_to_output + additional_includes).each do |include_file|
if include_file.start_with?(@basepath + 'src/include')
out_file = @out_path + include_file.gsub(%r{^#{@basepath}src/}, '')
else
Expand All @@ -449,7 +470,7 @@ def write_out

code = File.read(include_file)
all_thread_local_variables.each do |variable|
code.gsub!(/(PGDLLIMPORT|extern)\s+(const|volatile)?\s*(\w+)\s+(\*{0,2})#{variable}(\[\])?;/, "\\1 __thread \\2 \\3 \\4#{variable}\\5;")
code.gsub!(/(extern\s+)(PGDLLIMPORT\s+)?(const\s+)?(volatile\s+)?(\w+)\s+(\*{0,2})#{variable}(\[\])?;/, "\\1\\2__thread \\3\\4\\5 \\6#{variable}\\7;")
end

FileUtils.mkdir_p File.dirname(out_file)
Expand Down Expand Up @@ -539,6 +560,20 @@ def write_out
}
)) # We're always working with fn_rettype = VOIDOID, due to our use of plpgsql_compile_inline

# Mocks REQUIRED for Windows support
runner.mock('write_stderr', %(
void
write_stderr(const char *fmt,...)
{
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
fflush(stderr);
va_end(ap);
}
)) # Avoid pulling in write_console/write_eventlog, and instead always output to stderr (like on POSIX)
runner.mock('should_output_to_client', 'static inline bool should_output_to_client(int elevel) { return false; }') # Avoid pulling in postmaster.c, which has a bunch of Windows-specific code hidden behind a define

## ---

# SQL Parsing
Expand Down Expand Up @@ -592,6 +627,17 @@ def write_out
runner.deep_resolve('pg_rightmost_one_pos32')
runner.deep_resolve('pg_popcount32')

# Required for Windows support
runner.deep_resolve('newNodeMacroHolder')
runner.deep_resolve('pg_leftmost_one_pos')
runner.deep_resolve('pg_rightmost_one_pos')
runner.deep_resolve('pg_number_of_ones')
runner.deep_resolve('GetMessageEncoding')
runner.deep_resolve('strlcpy')
runner.deep_resolve('pg_signal_queue')
runner.deep_resolve('pg_signal_mask')
runner.deep_resolve('pgwin32_dispatch_queued_signals')

runner.write_out

#puts runner.unresolved.inspect
Expand Down
Loading
Loading