Skip to content

Commit e8851fc

Browse files
authored
Merge branch 'master' into pure_float_1
2 parents 41ff3da + 0c46de4 commit e8851fc

28 files changed

+411
-106
lines changed

.github/workflows/CI.yml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
POSTGIS_VERSION : "3.4.2"
3030
HTTP_PROXY: ""
3131
HTTPS_PROXY: ""
32+
SQLITE_FOR_TESTING_DIR: "/opt/CI_sqlite"
3233
strategy:
3334
fail-fast: false
3435
matrix:
@@ -46,32 +47,38 @@ jobs:
4647
- name: set_proxy
4748
run: bash GitHubActions/env.sh
4849

50+
- name: download PostGIS, ${{ matrix.config }} mode
51+
run: |
52+
if [[ "${{ matrix.config }}" == "postgis" ]]; then
53+
bash GitHubActions/download_postgis.sh ${{ env.POSTGIS_VERSION }}
54+
fi
55+
4956
- name: install locales
5057
run: bash GitHubActions/install_locales.sh
5158

52-
- name: build PostgreSQL ${{ matrix.pg }} with ${{ matrix.config }}
59+
- name: build PostgreSQL ${{ matrix.pg }}
5360
run: bash GitHubActions/build_postgres.sh ${{ matrix.pg }}
5461

55-
- name: build PostGIS ${{ env.POSTGIS_VERSION }} for PostgreSQL ${{ matrix.pg }}, ${{ matrix.config }} mode
56-
run: |
57-
if [[ "${{ matrix.config }}" == "postgis" ]]; then
58-
bash GitHubActions/build_postgis.sh ${{ matrix.pg }} ${{ env.POSTGIS_VERSION }}
59-
fi
60-
6162
- name: install SQLite, ${{ matrix.config }} mode
6263
run: |
6364
if [[ "${{ matrix.config }}" == "default" ]]; then
64-
bash GitHubActions/install_sqlite.sh ${{ env.SQLITE_VERSION }} ${{ env.SQLITE_YEAR }} "${{ matrix.config }}"
65+
bash GitHubActions/install_sqlite.sh ${{ env.SQLITE_VERSION }} ${{ env.SQLITE_YEAR }} ${{ matrix.config }} ${{ env.SQLITE_FOR_TESTING_DIR }}
6566
elif [[ "${{ matrix.config }}" == "postgis" ]]; then
66-
bash GitHubActions/install_sqlite.sh ${{ env.SQLITE_VERSION }} ${{ env.SQLITE_YEAR }} "${{ matrix.config }}" --enable-rtree
67+
bash GitHubActions/install_sqlite.sh ${{ env.SQLITE_VERSION }} ${{ env.SQLITE_YEAR }} ${{ matrix.config }} ${{ env.SQLITE_FOR_TESTING_DIR }} --enable-rtree
68+
fi
69+
70+
- name: build PostGIS ${{ env.POSTGIS_VERSION }} for PostgreSQL ${{ matrix.pg }}, ${{ matrix.config }} mode
71+
run: |
72+
if [[ "${{ matrix.config }}" == "postgis" ]]; then
73+
bash GitHubActions/build_postgis.sh ${{ matrix.pg }} ${{ env.POSTGIS_VERSION }}
6774
fi
6875
6976
- name: build sqlite_fdw, ${{ matrix.config }} mode
7077
run: |
71-
bash GitHubActions/build_sqlite_fdw.sh ${{ matrix.pg }} ${{ matrix.config }}
78+
bash GitHubActions/build_sqlite_fdw.sh ${{ matrix.pg }} ${{ matrix.config }} ${{ env.SQLITE_FOR_TESTING_DIR }}
7279
7380
- name: execute sqlite_fdw test
74-
run: bash GitHubActions/execute_test.sh ${{ matrix.pg }} ${{ matrix.config }}
81+
run: bash GitHubActions/execute_test.sh ${{ matrix.pg }} ${{ matrix.config }} ${{ env.SQLITE_FOR_TESTING_DIR }}
7582

7683
- name: download output files (regression.diffs)
7784
if: failure()
@@ -83,3 +90,4 @@ jobs:
8390
workdir/postgresql-${{ matrix.pg }}/contrib/sqlite_fdw/regression.out
8491
workdir/postgresql-${{ matrix.pg }}/contrib/sqlite_fdw/results
8592
retention-days: 7
93+

GitHubActions/build_postgis.sh

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
################################################################################
44
#
5-
# This script downloads PostgreSQL from the official web site into ./workdir
5+
# This script downloads PostGIS from the official web site into ./workdir
66
# then builds it.
77
#
88
# Usage: ./build_postgis.sh pg_version postgis_version
@@ -17,23 +17,18 @@
1717
POSTGRESQL_VERSION=$1
1818
POSTGIS_VERSION=$2
1919

20-
cd ./workdir
21-
cd postgresql-${POSTGRESQL_VERSION}
22-
2320
# Install necessary dependencies
2421
sudo apt update
2522
sudo apt install -y build-essential libxml2-dev libgeos-dev libproj-dev libgdal-dev libjson-c-dev libprotobuf-c-dev protobuf-c-compiler
2623

27-
GEOS_CONFIG_PATH=$(which geos-config)
28-
24+
cd ./workdir
2925
# Download and compile PostGIS
30-
cd contrib
31-
wget http://download.osgeo.org/postgis/source/postgis-${POSTGIS_VERSION}.tar.gz
32-
tar -xzf postgis-${POSTGIS_VERSION}.tar.gz
33-
mv postgis-${POSTGIS_VERSION} postgis -v
34-
cd postgis
26+
cp -vr postgis postgresql-${POSTGRESQL_VERSION}/contrib
27+
cd postgresql-${POSTGRESQL_VERSION}/contrib/postgis
3528
echo " - PostGIS directory"
29+
GEOS_CONFIG_PATH=$(which geos-config)
3630
export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
3731
./configure --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-geosconfig=$GEOS_CONFIG_PATH
3832
make
3933
sudo make install
34+

GitHubActions/build_sqlite_fdw.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
#
55
# This script builds sqlite_fdw in PostgreSQL source tree.
66
#
7-
# Usage: ./build_sqlite_fdw.sh pg_version mode
7+
# Usage: ./build_sqlite_fdw.sh pg_version mode sqlite_for_testing_dir
88
# pg_version is a PostgreSQL version like 17.0 to be built in.
99
# mode is flag for sqlite_fdw compiler.
10+
# sqlite_for_testing_dir: path to install directory of SQLite version for testing
1011
#
1112
# Requirements
1213
# - the source code of sqlite_fdw is available by git clone.
@@ -18,14 +19,16 @@ VERSION="$1"
1819
MODE="$2"
1920

2021
mkdir -p ./workdir/postgresql-${VERSION}/contrib/sqlite_fdw
21-
tar zxvf ./sqlite_fdw.tar.gz -C ./workdir/postgresql-${VERSION}/contrib/sqlite_fdw/
22+
tar zxf ./sqlite_fdw.tar.gz -C ./workdir/postgresql-${VERSION}/contrib/sqlite_fdw/
2223
cd ./workdir/postgresql-${VERSION}/contrib/sqlite_fdw
23-
export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
24+
25+
# show locally compiled sqlite library
26+
ls -la /usr/local/lib
2427

2528
if [ "$MODE" == "postgis" ]; then
26-
make ENABLE_GIS=1
29+
make ENABLE_GIS=1 SQLITE_FOR_TESTING_DIR="$3"
2730
else
28-
make
31+
make SQLITE_FOR_TESTING_DIR="$3"
2932
fi
3033

3134
sudo make install

GitHubActions/download_postgis.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
################################################################################
4+
#
5+
# This script downloads PostGIS from the official web site into ./workdir
6+
# then builds it.
7+
#
8+
# Usage: ./download_postgis.sh postgis_version
9+
# postgis_version is a PostGIS version to be installed.
10+
#
11+
# Requirements
12+
# - be able to connect to the PostGIS official web site by wget.
13+
#
14+
################################################################################
15+
16+
POSTGIS_VERSION=$1
17+
18+
mkdir -p ./workdir
19+
cd ./workdir
20+
pgisfile="postgis-${POSTGIS_VERSION}.tar.gz"
21+
if [ ! -f "$pgisfile" ]; then
22+
wget -nv "http://download.osgeo.org/postgis/source/$pgisfile"
23+
tar -xzf "$pgisfile"
24+
mv postgis-${POSTGIS_VERSION} postgis -v
25+
echo "PostGIS source code directory " $(dirname $(readlink -f postgis))
26+
else
27+
echo "PostGIS downloaded"
28+
fi

GitHubActions/execute_test.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
# sqlite_fdw. If all tests are passed, this script will exit successfully.
77
# Otherwise, it will exit with failure.
88

9-
# Usage: ./execute_test.sh pg_version mode
9+
# Usage: ./execute_test.sh pg_version mode sqlite_for_testing_dir
1010
# pg_version is a PostgreSQL version to be tested like 17.0.
1111
# mode is flag for sqlite_fdw compiler.
12+
# sqlite_for_testing_dir: path to install directory of SQLite version for testing
1213
#
1314
# Requiremets
1415
# - the source code of PostgreSQL is located in ./workdir/postgresql-{pg_version}.
@@ -22,6 +23,7 @@
2223

2324
VERSION=$1
2425
MODE="$2"
26+
SQLITE_FOR_TESTING_DIR="$3"
2527

2628
cd ./workdir/postgresql-${VERSION}/contrib/sqlite_fdw
2729

GitHubActions/install_locales.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ sudo apt-get install locales language-pack-ja
1717
sudo locale-gen ja_JP.EUC-JP
1818
sudo apt-get install language-pack-ko-base language-pack-ko
1919
sudo locale-gen ko_KR.EUC-KR
20-
sudo apt -get install language-pack-bg-base language-pack-bg
20+
sudo apt-get install language-pack-bg-base language-pack-bg
2121
sudo locale-gen bg_BG
22+
sudo apt-get install libreadline8 libreadline-dev

GitHubActions/install_sqlite.sh

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
# This sript downloads SQLite source code from the official web site into
66
# ./workdir then builds and installs it.
77
#
8-
# Usage: ./install_sqlite.sh version year testing_mode [configure_options]
8+
# Usage: ./install_sqlite.sh version year testing_mode sqlite_for_testing_dir [configure_options]
99
# version: SQLite version to be installed.
1010
# year: A year of SQLite released. It is used for determining a download URL.
1111
# testing_mode: 'default' or 'postgis' value.
12+
# sqlite_for_testing_dir: path to install directory of the specified SQLite version
1213
# configure_options: are a list of option for sqlite server.
1314
#
14-
# Ex) ./install_sqlite.sh 3420000 2023 postgis --enable-rtree
15+
# Ex) ./install_sqlite.sh 3420000 2023 postgis /opt/sqlite_for_testing --enable-rtree
1516
#
1617
# Requirements
1718
# - be able to connect to the SQLite official web site by curl.
@@ -22,27 +23,36 @@
2223
VERSION="$1"
2324
YEAR="$2"
2425
TESTING_MODE="$3"
26+
SQLITE_FOR_TESTING_DIR="$4"
2527

2628
CONFIGURE_OPTIONS=""
2729

2830
while (( "$#" )); do
29-
CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS $4"
31+
CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS $5"
3032
shift
3133
done
3234

35+
echo "SQLite ver $VERSION ($YEAR), mode $TESTING_MODE, install to $SQLITE_FOR_TESTING_DIR with options $CONFIGURE_OPTIONS";
36+
3337
mkdir -p ./workdir
3438
cd ./workdir
35-
curl -O https://www.sqlite.org/${YEAR}/sqlite-src-${VERSION}.zip
36-
unzip sqlite-src-${VERSION}.zip > /dev/null
37-
cd sqlite-src-${VERSION}
38-
39-
if [ -z "$CONFIGURE_OPTIONS" ]; then
40-
./configure --enable-fts5
41-
else
42-
./configure --enable-fts5 $CONFIGURE_OPTIONS
39+
vsrc="sqlite-src-${VERSION}"
40+
adr="https://www.sqlite.org/${YEAR}/$vsrc.zip"
41+
echo "SQLite source code archive: $adr"
42+
wget "$adr" -O "$vsrc.zip"
43+
unzip "$vsrc.zip" > /dev/null
44+
cd "$vsrc"
45+
46+
export CFLAGS=-DSQLITE_ENABLE_COLUMN_METADATA
47+
confcom="./configure --enable-fts5 --prefix=$SQLITE_FOR_TESTING_DIR"
48+
if [ ! -z "$CONFIGURE_OPTIONS" ]; then
49+
confcom+="$CONFIGURE_OPTIONS"
4350
fi
51+
echo "SQLite configure call: $confcom"
52+
$confcom
4453

4554
make
55+
echo "----- SQLITE INSTALL directory $SQLITE_FOR_TESTING_DIR -----"
4656
sudo make install
4757

4858
if [ "$TESTING_MODE" == "postgis" ]; then

Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ GIS_DEP_TESTS = $(GIS_DEP_TESTS_DIR)/type $(GIS_DEP_TESTS_DIR)/auto_import $(GIS
3333

3434
ifndef REGRESS
3535
# System tests, full default sequence
36-
REGRESS = extra/sqlite_fdw_post $(DATA_TYPE_TESTS) extra/join extra/limit extra/aggregates extra/prepare extra/select_having extra/select extra/insert extra/update extra/encodings sqlite_fdw aggregate selectfunc $(GIS_DEP_TESTS)
36+
REGRESS = libsqlite extra/sqlite_fdw_post $(DATA_TYPE_TESTS) extra/join extra/limit extra/aggregates extra/prepare extra/select_having extra/select extra/insert extra/update extra/encodings sqlite_fdw aggregate selectfunc $(GIS_DEP_TESTS)
3737
endif
3838

3939
# Other encodings also are tested. Client encoding should be UTF-8.
@@ -47,7 +47,12 @@ else
4747
DLSUFFIX = .so
4848
endif
4949

50+
ifdef SQLITE_FOR_TESTING_DIR
51+
SHLIB_LINK := -L$(SQLITE_FOR_TESTING_DIR)/lib -lsqlite3
52+
PG_CFLAGS += -I$(SQLITE_FOR_TESTING_DIR)/include -Wl,-rpath,$(SQLITE_FOR_TESTING_DIR)/lib
53+
else
5054
SHLIB_LINK := -lsqlite3
55+
endif
5156

5257
ifdef ENABLE_GIS
5358
override SHLIB_LINK += -lspatialite
@@ -81,9 +86,17 @@ $(shell mkdir -p results/$(REGRESS_PREFIX_SUB)/extra)
8186
$(shell mkdir -p results/$(REGRESS_PREFIX_SUB)/types)
8287
$(shell mkdir -p results/$(REGRESS_PREFIX_SUB)/$(GIS_DEP_TESTS_DIR))
8388

89+
# $(info ENABLE_GIS is $(ENABLE_GIS))
90+
# $(info SHLIB_LINK is $(SHLIB_LINK))
91+
# $(info LD_LIBRARY_PATH is $(LD_LIBRARY_PATH))
92+
# $(info PG_CFLAGS is $(PG_CFLAGS))
93+
# $(info PG_CPPFLAGS is $(PG_CPPFLAGS))
94+
# $(info REGRESS is $(REGRESS))
95+
# $(info DLSUFFIX is $(DLSUFFIX))
8496

8597
ifdef ENABLE_GIS
8698
check: temp-install
8799
temp-install: EXTRA_INSTALL+=contrib/postgis
88100
checkprep: EXTRA_INSTALL+=contrib/postgis
89101
endif
102+

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ Features
4545
- Support mixed SQLite [data affinity](https://www.sqlite.org/datatype3.html) input and filtering (`SELECT`/`WHERE` usage) for such data types as
4646
- `timestamp`: `text` and `int`,
4747
- `uuid`: `text`(32..39) and `blob`(16),
48-
- `bool`: `text`(1..5) and `int`,
49-
- `double precision`, `float` and `numeric`: `real` values and special values with `text` affinity (`+Infinity`, `-Infinity`, `NaN`),
50-
- `macaddr`: `text`(12..17) or `blob`(6) or `integer`,
51-
- `macaddr8`: `text`(16..23) or `blob`(8) or `integer`.
48+
- `bool`: `text`(1..5) and `int`,
49+
- `double precision`, `float` and `numeric`: `real` values and special values with `text` affinity (`+Infinity`, `-Infinity`, `NaN`),
50+
- `macaddr`: `text`(12..17) or `blob`(6) or `integer`,
51+
- `macaddr8`: `text`(16..23) or `blob`(8) or `integer`.
5252
- Support mixed SQLite [data affinity](https://www.sqlite.org/datatype3.html) output (`INSERT`/`UPDATE`) for such data types as
5353
- `timestamp`: `text`(default) or `int`,
54-
- `uuid`: `text`(36) or `blob`(16)(default),
55-
- `macaddr`: `text`(17) or `blob`(6) or `integer`(default),
56-
- `macaddr8`: `text`(23) or `blob`(8) or `integer`(default).
54+
- `uuid`: `text`(36) or `blob`(16)(default),
55+
- `macaddr`: `text`(17) or `blob`(6) or `integer`(default),
56+
- `macaddr8`: `text`(23) or `blob`(8) or `integer`(default).
5757
- Full support for `+Infinity` (means ∞) and `-Infinity` (means -∞) special values for IEEE 754-2008 numbers in `double precision`, `float` and `numeric` columns including such conditions as ` n < '+Infinity'` or ` m > '-Infinity'`.
5858
- Bidirectional data transformation for `geometry` and `geography` data types for SpatiaLite ↔ PostGIS. [EWKB](https://libgeos.org/specifications/wkb/#extended-wkb) data transport is used. See [GIS support description](GIS.md).
5959

@@ -500,7 +500,7 @@ Once for a foreign datasource you need, as PostgreSQL superuser. Please specify
500500
CREATE SERVER sqlite_server
501501
FOREIGN DATA WRAPPER sqlite_fdw
502502
OPTIONS (
503-
database '/path/to/database'
503+
database '/path/to/database'
504504
);
505505
```
506506

expected/13.15/libsqlite.out

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
-- Test for SQLite library code source and defaults
2+
--Testcase 1:
3+
CREATE EXTENSION sqlite_fdw;
4+
--Testcase 2:
5+
SELECT sqlite_fdw_sqlite_version();
6+
sqlite_fdw_sqlite_version
7+
---------------------------
8+
3046000
9+
(1 row)
10+
11+
--Testcase 3:
12+
SELECT length(sqlite_fdw_sqlite_code_source());
13+
length
14+
--------
15+
84
16+
(1 row)
17+
18+
--Testcase 4:
19+
SELECT sqlite_fdw_sqlite_code_source();
20+
sqlite_fdw_sqlite_code_source
21+
--------------------------------------------------------------------------------------
22+
2024-05-23 13:25:27 96c92aba00c8375bc32fafcdf12429c58bd8aabfcadab6683e35bbb9cdebf19e
23+
(1 row)
24+
25+
--Testcase 7:
26+
DROP EXTENSION sqlite_fdw CASCADE;

expected/13.15/sqlite_fdw.out

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,16 +1462,18 @@ SELECT * FROM noprimary;
14621462
--get version
14631463
--Testcase 153:
14641464
\df sqlite*
1465-
List of functions
1466-
Schema | Name | Result data type | Argument data types | Type
1467-
--------+----------------------------+------------------+-----------------------------------------+------
1468-
public | sqlite_fdw_disconnect | boolean | text | func
1469-
public | sqlite_fdw_disconnect_all | boolean | | func
1470-
public | sqlite_fdw_get_connections | SETOF record | OUT server_name text, OUT valid boolean | func
1471-
public | sqlite_fdw_handler | fdw_handler | | func
1472-
public | sqlite_fdw_validator | void | text[], oid | func
1473-
public | sqlite_fdw_version | integer | | func
1474-
(6 rows)
1465+
List of functions
1466+
Schema | Name | Result data type | Argument data types | Type
1467+
--------+-------------------------------+------------------+-----------------------------------------+------
1468+
public | sqlite_fdw_disconnect | boolean | text | func
1469+
public | sqlite_fdw_disconnect_all | boolean | | func
1470+
public | sqlite_fdw_get_connections | SETOF record | OUT server_name text, OUT valid boolean | func
1471+
public | sqlite_fdw_handler | fdw_handler | | func
1472+
public | sqlite_fdw_sqlite_code_source | text | | func
1473+
public | sqlite_fdw_sqlite_version | integer | | func
1474+
public | sqlite_fdw_validator | void | text[], oid | func
1475+
public | sqlite_fdw_version | integer | | func
1476+
(8 rows)
14751477

14761478
--Testcase 154:
14771479
SELECT * FROM public.sqlite_fdw_version();

0 commit comments

Comments
 (0)