Control: tags -1 + patch
Please find attached a patch.
I have not tested the package except the build-time tests. Initially,
I tried to follow upstream's desire for custom memory management, so I
created a pcre2_general_context in _PG_init (changing the
pgpcre_malloc/pgpcre_free prototypes as is required). Unfortunately,
the test program crashes when pfree is invoked in
src:pcre2:src/pcre2_match.c:6846. It looks like palloc/pfree are not
suitable as PCRE2 custom memory management functions as they use memory
context like in PCRE2 itself. Or I am misunderstanding something.
>From f46d9ca762751a3c856369d781cf69554c31e001 Mon Sep 17 00:00:00 2001
From: Yavor Doganov
Date: Sat, 16 Dec 2023 22:29:20 +0200
Subject: [PATCH] Port to PCRE2 (#101).
---
debian/changelog | 6 +
debian/control | 2 +-
debian/control.in | 2 +-
debian/patches/pcre2.patch | 268 +
debian/patches/series | 1 +
5 files changed, 277 insertions(+), 2 deletions(-)
create mode 100644 debian/patches/pcre2.patch
create mode 100644 debian/patches/series
diff --git a/debian/changelog b/debian/changelog
index 1d0f545..cba8632 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+pgpcre (0.20190509-7) UNRELEASED; urgency=medium
+
+ * Port to PCRE2 (Closes: #101).
+
+ -- Yavor Doganov Sat, 16 Dec 2023 22:27:38 +0200
+
pgpcre (0.20190509-6) unstable; urgency=medium
* Upload for PostgreSQL 16.
diff --git a/debian/control b/debian/control
index 1073417..bb8c141 100644
--- a/debian/control
+++ b/debian/control
@@ -6,7 +6,7 @@ Uploaders:
Christoph Berg ,
Build-Depends:
debhelper-compat (= 13),
- libpcre3-dev,
+ libpcre2-dev,
pkg-config,
postgresql-all (>= 217~),
Standards-Version: 4.6.2
diff --git a/debian/control.in b/debian/control.in
index 5fe2318..0f01b24 100644
--- a/debian/control.in
+++ b/debian/control.in
@@ -6,7 +6,7 @@ Uploaders:
Christoph Berg ,
Build-Depends:
debhelper-compat (= 13),
- libpcre3-dev,
+ libpcre2-dev,
pkg-config,
postgresql-all (>= 217~),
Standards-Version: 4.6.2
diff --git a/debian/patches/pcre2.patch b/debian/patches/pcre2.patch
new file mode 100644
index 000..f138fb1
--- /dev/null
+++ b/debian/patches/pcre2.patch
@@ -0,0 +1,268 @@
+Description: Port to PCRE2.
+Bug-Debian: https://bugs.debian.org/101
+Author: Yavor Doganov
+Forwarded: no
+Last-Update: 2023-12-16
+---
+
+--- pgpcre-0.20190509.orig/Makefile
pgpcre-0.20190509/Makefile
+@@ -6,12 +6,12 @@
+ OBJS = pgpcre.o
+ DATA = pgpcre--0.sql pgpcre--1.sql pgpcre--0--1.sql
+
+-ifeq (no,$(shell $(PKG_CONFIG) libpcre || echo no))
++ifeq (no,$(shell $(PKG_CONFIG) libpcre2-8 || echo no))
+ $(warning libpcre not registed with pkg-config, build might fail)
+ endif
+
+-PG_CPPFLAGS += $(shell $(PKG_CONFIG) --cflags-only-I libpcre)
+-SHLIB_LINK += $(shell $(PKG_CONFIG) --libs libpcre)
++PG_CPPFLAGS += $(shell $(PKG_CONFIG) --cflags-only-I libpcre2-8)
++SHLIB_LINK += $(shell $(PKG_CONFIG) --libs libpcre2-8)
+
+ REGRESS = init test unicode
+ REGRESS_OPTS = --inputdir=test
+--- pgpcre-0.20190509.orig/pgpcre.c
pgpcre-0.20190509/pgpcre.c
+@@ -5,7 +5,8 @@
+ #include
+ #include
+
+-#include
++#define PCRE2_CODE_UNIT_WIDTH 8
++#include
+
+ PG_MODULE_MAGIC;
+
+@@ -57,19 +58,19 @@
+ pcre_in(PG_FUNCTION_ARGS)
+ {
+ char *input_string = PG_GETARG_CSTRING(0);
+- pcre *pc;
+- const char *err;
+- int erroffset;
+- size_t in_strlen;
+- int rc, total_len, pcsize;
++ pcre2_code *pc;
++ int err;
++ PCRE2_SIZE erroffset;
++ size_t in_strlen, pcsize;
++ int rc, total_len;
+ pgpcre *result;
+
+ in_strlen = strlen(input_string);
+
+ if (GetDatabaseEncoding() == PG_UTF8)
+- pc = pcre_compile(input_string, PCRE_UTF8 | PCRE_UCP, ,
, NULL);
++ pc = pcre2_compile((PCRE2_SPTR) input_string, in_strlen,
PCRE2_UTF | PCRE2_UCP, , , NULL);
+ else if (GetDatabaseEncoding() == PG_SQL_ASCII)
+- pc = pcre_compile(input_string, 0, , , NULL);
++ pc = pcre2_compile((PCRE2_SPTR) input_string, in_strlen, 0,
, , NULL);
+ else
+ {
+ char *utf8string;
+@@ -78,22 +79,27 @@
+
in_strlen,
+
GetDatabaseEncoding(),
+
PG_UTF8);
+- pc = pcre_compile(utf8string, PCRE_UTF8 | PCRE_UCP, ,
, NULL);
++ pc = pcre2_compile((PCRE2_SPTR) utf8string, strlen(utf8string),
PCRE2_UTF | PCRE2_UCP, , , NULL);
+ if (utf8string != input_string)
+