[postgis-devel] st_asflatgeobuf detoast crash

Julien Rouhaud rjuju123 at gmail.com
Sat Jun 18 19:52:33 PDT 2022


Hi,

On Sat, Jun 18, 2022 at 07:52:53PM -0400, Regina Obe wrote:
> Thanks.  Ticketed at
> 
> https://trac.osgeo.org/postgis/ticket/517

Thanks Regina!  I think the last digit is missing, the url should be
https://trac.osgeo.org/postgis/ticket/5173.

I've also now fixed my environment and can run regression tests, so I'm
attaching a proper patch with a regression test.

Should I add the patch to the ticket too?
-------------- next part --------------
>From 6e3f5f8e9fa5b508e04c3ac00db0b179c415b2ab Mon Sep 17 00:00:00 2001
From: Julien Rouhaud <julien.rouhaud at free.fr>
Date: Sun, 19 Jun 2022 10:44:57 +0800
Subject: [PATCH v1] Fix ST_AsFlatGeobuf with rows that doesn't contain
 geometry.

---
 postgis/flatgeobuf.c             | 3 +++
 regress/core/flatgeobuf.sql      | 3 +++
 regress/core/flatgeobuf_expected | 1 +
 3 files changed, 7 insertions(+)

diff --git a/postgis/flatgeobuf.c b/postgis/flatgeobuf.c
index 1b502e546..2d63bf0a6 100644
--- a/postgis/flatgeobuf.c
+++ b/postgis/flatgeobuf.c
@@ -110,6 +110,9 @@ static void inspect_table(struct flatgeobuf_agg_ctx *ctx)
 		columns_size++;
 	}
 
+	if (!geom_found)
+		elog(ERROR, "flatgeobuf: no geometry column found in the row");
+
 	if (columns_size > 0) {
 		ctx->ctx->columns = columns;
 		ctx->ctx->columns_size = columns_size;
diff --git a/regress/core/flatgeobuf.sql b/regress/core/flatgeobuf.sql
index 10a535bc2..1f859a02b 100644
--- a/regress/core/flatgeobuf.sql
+++ b/regress/core/flatgeobuf.sql
@@ -14,6 +14,9 @@ select 'T1', id, ST_AsText(geom) from ST_FromFlatGeobuf(null::flatgeobuf_t1, (
 --    select ST_AsFlatGeobuf(q) fgb from (select null::geometry limit 0) q)
 --);
 
+-- no geometry column
+SELECT 'T3', ST_AsFlatGeobuf(row(1)) FROM (SELECT 1) q;
+
 select '--- Geometry roundtrips ---';
 
 -- 2D Point
diff --git a/regress/core/flatgeobuf_expected b/regress/core/flatgeobuf_expected
index 61c617de3..00f71d7be 100644
--- a/regress/core/flatgeobuf_expected
+++ b/regress/core/flatgeobuf_expected
@@ -1,5 +1,6 @@
 --- Null geometry ---
 T1|0|
+ERROR:  flatgeobuf: no geometry column found in the row
 --- Geometry roundtrips ---
 P1|0|POINT(1.1 2.1)
 P2|0|POINT Z (1.1 2.11 3.2)
-- 
2.35.0



More information about the postgis-devel mailing list