From 9c3390e6bb092b10de71e653af54002088f8ca7b Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Wed, 13 Dec 2023 14:11:39 -0800 Subject: [PATCH] Fix linux crash --- Makefile | 3 ++- ogr_fdw.c | 2 +- output/pgsql.source | 10 +++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 1eb5fa3..60eeeed 100644 --- a/Makefile +++ b/Makefile @@ -34,9 +34,10 @@ SHLIB_LINK := $(LIBS) PGXS := $(shell $(PG_CONFIG) --pgxs) include $(PGXS) -PG_VERSION_NUM = $(shell awk '/PG_VERSION_NUM/ { print $$3 }' $(shell $(PG_CONFIG) --includedir-server)/pg_config.h) +PG_VERSION_NUM = $(shell pg_config --version | cut -f2 -d' ' | awk -F. '{printf "%d%04d", $$1, $$2}') HAS_IMPORT_SCHEMA = $(shell [ $(PG_VERSION_NUM) -ge 90500 ] && echo yes) + # order matters, file first, import last REGRESS = file pgsql ifeq ($(HAS_IMPORT_SCHEMA),yes) diff --git a/ogr_fdw.c b/ogr_fdw.c index fb876bf..2ac5806 100644 --- a/ogr_fdw.c +++ b/ogr_fdw.c @@ -1663,7 +1663,7 @@ pgDatumFromCString(const char* cstr, const OgrFdwColumn *col, int char_encoding, char *cstr_decoded; /* Zero length implies NULL for all non-strings */ - if (cstr_len == 0 && col->ogrfldtype != OFTString) + if (cstr_len == 0 && (col->ogrfldtype != OFTString && col->ogrfldtype != OFTStringList)) { *is_null = true; return value; diff --git a/output/pgsql.source b/output/pgsql.source index c21bace..ba5d396 100644 --- a/output/pgsql.source +++ b/output/pgsql.source @@ -215,11 +215,11 @@ CREATE FOREIGN TABLE array_fdw ( b boolean[] ) SERVER pgserver OPTIONS (layer 'array_local'); SELECT fid, txt, int, flt, b FROM array_fdw; - fid | txt | int | flt | b ------+----------------+-----------+---------------+------- - 1 | {Jim} | {1,2,3} | {3.4,5.6,7.8} | {t,f} - 2 | {Jim,NULL,Joe} | {1,3,0,4} | {4.5,0,3.4} | {f,f} - 3 | | | | + fid | txt | int | flt | b +-----+--------------+-----------+---------------+------- + 1 | {Jim} | {1,2,3} | {3.4,5.6,7.8} | {t,f} + 2 | {Jim,"",Joe} | {1,3,0,4} | {4.5,0,3.4} | {f,f} + 3 | | | | (3 rows) ----------------------------------------------------------------------