Skip to content

Commit 5aabe2d

Browse files
committed
fix: installation of libpg when installing pg-query-ext through pie
1 parent 4bbfc07 commit 5aabe2d

File tree

3 files changed

+12
-44
lines changed

3 files changed

+12
-44
lines changed

src/extension/pg-query-ext/README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,16 @@ sudo dnf install protobuf-c-devel git make gcc
3333
**Install the extension:**
3434

3535
```bash
36-
# Simple installation (auto-downloads libpg_query for PostgreSQL 17)
36+
# Simple installation (auto-downloads libpg_query)
3737
pie install flow-php/pg-query-ext
3838

39-
# Install with a specific PostgreSQL grammar version (15, 16, or 17)
40-
pie install flow-php/pg-query-ext --with-pg-version=16
41-
42-
# Or with a pre-installed libpg_query
39+
# Or with a pre-installed libpg_query (must be version 17+)
4340
pie install flow-php/pg-query-ext --with-pg-query=/usr/local
4441
```
4542

46-
The extension will automatically download and build the appropriate libpg_query version if not found on your system.
47-
48-
**Supported PostgreSQL versions:**
43+
The extension will automatically download and build libpg_query 17-latest if not found on your system.
4944

50-
| PostgreSQL | libpg_query version |
51-
|------------|---------------------|
52-
| 17 | 17-6.1.0 (default) |
53-
| 16 | 16-5.2.0 |
54-
| 15 | 15-4.2.4 |
45+
> **Note:** This extension uses PostgreSQL 17 grammar (libpg_query 17-latest). It requires `postgres_deparse.h` which is only available in libpg_query 17+.
5546
5647
### Requirements
5748

src/extension/pg-query-ext/composer.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@
2727
"name": "with-pg-query",
2828
"needs-value": false,
2929
"description": "Path to libpg_query installation (optional - will auto-download if not found)"
30-
},
31-
{
32-
"name": "with-pg-version",
33-
"needs-value": true,
34-
"description": "PostgreSQL grammar version: 15, 16, or 17 (default: 17)"
3530
}
3631
],
3732
"support-zts": true,

src/extension/pg-query-ext/ext/config.m4

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,10 @@ PHP_ARG_WITH([pg-query],
55
[AS_HELP_STRING([--with-pg-query@<:@=DIR@:>@],
66
[Include pg_query support. DIR is the libpg_query install prefix (optional - will download if not found)])])
77

8-
PHP_ARG_WITH([pg-version],
9-
[PostgreSQL grammar version],
10-
[AS_HELP_STRING([--with-pg-version@<:@=VERSION@:>@],
11-
[PostgreSQL grammar version: 15, 16, or 17 (default: 17)])], [17], [no])
12-
138
if test "$PHP_PG_QUERY" != "no"; then
14-
dnl Map PostgreSQL version to libpg_query version
15-
case "$PHP_PG_VERSION" in
16-
15)
17-
LIBPG_QUERY_VERSION="15-4.2.4"
18-
;;
19-
16)
20-
LIBPG_QUERY_VERSION="16-5.2.0"
21-
;;
22-
17|yes|"")
23-
LIBPG_QUERY_VERSION="17-latest"
24-
PHP_PG_VERSION="17"
25-
;;
26-
*)
27-
AC_MSG_ERROR([Unsupported PostgreSQL version: $PHP_PG_VERSION. Supported versions: 15, 16, 17])
28-
;;
29-
esac
30-
31-
AC_MSG_NOTICE([Using PostgreSQL $PHP_PG_VERSION grammar (libpg_query $LIBPG_QUERY_VERSION)])
9+
dnl libpg_query 17-latest is required for postgres_deparse.h support
10+
LIBPG_QUERY_VERSION="17-latest"
11+
AC_MSG_NOTICE([Using libpg_query $LIBPG_QUERY_VERSION (PostgreSQL 17 grammar)])
3212

3313
PG_QUERY_DIR=""
3414

@@ -42,12 +22,14 @@ if test "$PHP_PG_QUERY" != "no"; then
4222
AC_MSG_CHECKING([for libpg_query])
4323

4424
for i in $SEARCH_PATH ; do
45-
if test -r "$i/pg_query.h" && test -r "$i/libpg_query.a"; then
25+
dnl Check flat directory structure (headers and lib in same dir)
26+
if test -r "$i/pg_query.h" && test -r "$i/postgres_deparse.h" && test -r "$i/libpg_query.a"; then
4627
PG_QUERY_DIR=$i
4728
AC_MSG_RESULT([found in $i])
4829
break
4930
fi
50-
if test -r "$i/include/pg_query.h" && test -r "$i/lib/libpg_query.a"; then
31+
dnl Check standard include/lib directory structure
32+
if test -r "$i/include/pg_query.h" && test -r "$i/include/postgres_deparse.h" && test -r "$i/lib/libpg_query.a"; then
5133
PG_QUERY_DIR=$i
5234
PG_QUERY_INCLUDE_DIR="$i/include"
5335
PG_QUERY_LIB_DIR="$i/lib"
@@ -61,7 +43,7 @@ if test "$PHP_PG_QUERY" != "no"; then
6143

6244
dnl Check bundled directory
6345
if test -z "$PG_QUERY_DIR"; then
64-
if test -r "$EXT_DIR/libpg_query/pg_query.h" && test -r "$EXT_DIR/libpg_query/libpg_query.a"; then
46+
if test -r "$EXT_DIR/libpg_query/pg_query.h" && test -r "$EXT_DIR/libpg_query/postgres_deparse.h" && test -r "$EXT_DIR/libpg_query/libpg_query.a"; then
6547
PG_QUERY_DIR="$EXT_DIR/libpg_query"
6648
AC_MSG_RESULT([using bundled libpg_query])
6749
fi

0 commit comments

Comments
 (0)