[SCM] PostGIS branch stable-3.5 updated. 3.5.5-6-g6bdb14bb6
git at osgeo.org
git at osgeo.org
Tue Mar 17 13:26:58 PDT 2026
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".
The branch, stable-3.5 has been updated
via 6bdb14bb6657d23af50057551935aac2d101e901 (commit)
via 0141017ea1728864997eccf9995cfca893066e55 (commit)
from e4e72fda305f5a2aec43908191cb260277c87729 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 6bdb14bb6657d23af50057551935aac2d101e901
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Tue Mar 17 13:26:51 2026 -0700
News item for GH-850
diff --git a/NEWS b/NEWS
index ff7816473..b7a5fe7f4 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ PostgreSQL 12-18 required. GEOS 3.8+ required. Proj 6.1+ required.
- #6055, Remove rare extension priv escalation case.
Reported by Sven Klemm (Tiger Data), Allistair Ishmael Hakim (allistair.sh)
and Daniel Bakker
+ - GH-850 Use quote_identifier to build tables in pgis_tablefromflatgeobuf (Ariel Mashraki)
PostGIS 3.5.5
commit 0141017ea1728864997eccf9995cfca893066e55
Author: Ariel Mashraki <ariel at mashraki.co.il>
Date: Tue Mar 17 13:41:59 2026 +0200
Use quote_identifier to build tables in pgis_tablefromflatgeobuf
diff --git a/postgis/lwgeom_in_flatgeobuf.c b/postgis/lwgeom_in_flatgeobuf.c
index f0db9253a..ac460ff7a 100644
--- a/postgis/lwgeom_in_flatgeobuf.c
+++ b/postgis/lwgeom_in_flatgeobuf.c
@@ -75,13 +75,9 @@ Datum pgis_tablefromflatgeobuf(PG_FUNCTION_ARGS)
char *schema;
text *table_input;
char *table;
- char *format;
- char *sql;
bytea *data;
uint16_t i;
- char **column_defs;
- size_t column_defs_total_len;
- char *column_defs_str;
+ StringInfoData sql;
if (PG_ARGISNULL(0))
PG_RETURN_NULL();
@@ -107,48 +103,34 @@ Datum pgis_tablefromflatgeobuf(PG_FUNCTION_ARGS)
flatgeobuf_check_magicbytes(ctx);
flatgeobuf_decode_header(ctx->ctx);
- column_defs = palloc(sizeof(char *) * ctx->ctx->columns_size);
- column_defs_total_len = 0;
+ initStringInfo(&sql);
+ appendStringInfo(&sql, "create table %s.%s (id int, geom geometry",
+ quote_identifier(schema), quote_identifier(table));
+
POSTGIS_DEBUGF(2, "found %d columns", ctx->ctx->columns_size);
for (i = 0; i < ctx->ctx->columns_size; i++) {
flatgeobuf_column *column = ctx->ctx->columns[i];
const char *name = column->name;
uint8_t column_type = column->type;
char *pgtype = get_pgtype(column_type);
- size_t len = strlen(name) + 1 + strlen(pgtype) + 1;
- column_defs[i] = palloc0(sizeof(char) * len);
- strcat(column_defs[i], name);
- strcat(column_defs[i], " ");
- strcat(column_defs[i], pgtype);
- column_defs_total_len += len;
- }
- column_defs_str = palloc0(sizeof(char) * column_defs_total_len + (ctx->ctx->columns_size * 2) + 2 + 1);
- if (ctx->ctx->columns_size > 0)
- strcat(column_defs_str, ", ");
- for (i = 0; i < ctx->ctx->columns_size; i++) {
- strcat(column_defs_str, column_defs[i]);
- if (i < ctx->ctx->columns_size - 1)
- strcat(column_defs_str, ", ");
+ appendStringInfo(&sql, ", %s %s", quote_identifier(name), pgtype);
}
- POSTGIS_DEBUGF(2, "column_defs_str %s", column_defs_str);
+ appendStringInfoChar(&sql, ')');
- format = "create table %s.%s (id int, geom geometry%s)";
- sql = palloc0(strlen(format) + strlen(schema) + strlen(table) + strlen(column_defs_str) + 1);
-
- sprintf(sql, format, schema, table, column_defs_str);
-
- POSTGIS_DEBUGF(3, "sql: %s", sql);
+ POSTGIS_DEBUGF(3, "sql: %s", sql.data);
if (SPI_connect() != SPI_OK_CONNECT)
elog(ERROR, "Failed to connect SPI");
- if (SPI_execute(sql, false, 0) != SPI_OK_UTILITY)
+ if (SPI_execute(sql.data, false, 0) != SPI_OK_UTILITY)
elog(ERROR, "Failed to create table");
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "Failed to finish SPI");
+ pfree(sql.data);
+
POSTGIS_DEBUG(3, "finished");
PG_RETURN_NULL();
diff --git a/regress/core/flatgeobuf.sql b/regress/core/flatgeobuf.sql
index 10a535bc2..df46eca1e 100644
--- a/regress/core/flatgeobuf.sql
+++ b/regress/core/flatgeobuf.sql
@@ -158,6 +158,26 @@ select 'E1', id, bool_1, ST_AsText(geom), bool_2 from ST_FromFlatGeobuf(null::fl
) q)
);
+select '--- Quoted identifiers ---';
+
+-- Verify that special characters in column names are properly quoted
+select ST_FromFlatGeobufToTable('public', 'flatgeobuf_qi', (
+ select ST_AsFlatGeobuf(q) from (
+ select null::geometry, null::text as "col name; with special--chars"
+ ) q
+));
+select 'QI1' where exists (
+ select 1 from information_schema.columns
+ where table_schema = 'public'
+ and table_name = 'flatgeobuf_qi'
+ and column_name = 'col name; with special--chars'
+);
+select 'QI2' where exists (
+ select 1 from information_schema.tables
+ where table_schema = 'public' and table_name = 'flatgeobuf_t1'
+);
+
drop table if exists public.flatgeobuf_t1;
drop table if exists public.flatgeobuf_a1;
drop table if exists public.flatgeobuf_e1;
+drop table if exists public.flatgeobuf_qi;
diff --git a/regress/core/flatgeobuf_expected b/regress/core/flatgeobuf_expected
index 61c617de3..c93738ff9 100644
--- a/regress/core/flatgeobuf_expected
+++ b/regress/core/flatgeobuf_expected
@@ -24,3 +24,6 @@ ERROR: mixed geometry type is not supported
A1|0||t|1|2|3|4|1.2|1.3|2016-06-23 03:44:52.134125+00|hello
--- Exotic roundtrips ---
E1|0|t|POINT(1.1 2.1)|f
+--- Quoted identifiers ---
+QI1
+QI2
-----------------------------------------------------------------------
Summary of changes:
NEWS | 1 +
postgis/lwgeom_in_flatgeobuf.c | 40 +++++++++++-----------------------------
regress/core/flatgeobuf.sql | 20 ++++++++++++++++++++
regress/core/flatgeobuf_expected | 3 +++
4 files changed, 35 insertions(+), 29 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list