[SCM] PostGIS branch master updated. 3.6.0rc2-397-g29bd2e10c
git at osgeo.org
git at osgeo.org
Tue Mar 17 13:23:08 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, master has been updated
via 29bd2e10c284291fd1fd386131eb88ac7b1975eb (commit)
via bd08920ac3685cf31bdcb017dd77aa89dbfe07f6 (commit)
from e27a0d0ba496937ed6676ac7e84e76b821a6b172 (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 29bd2e10c284291fd1fd386131eb88ac7b1975eb
Merge: e27a0d0ba bd08920ac
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Tue Mar 17 13:22:59 2026 -0700
Merge branch 'a8m-master'
commit bd08920ac3685cf31bdcb017dd77aa89dbfe07f6
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 8435cd14e..97ed26b16 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:
postgis/lwgeom_in_flatgeobuf.c | 40 +++++++++++-----------------------------
regress/core/flatgeobuf.sql | 20 ++++++++++++++++++++
regress/core/flatgeobuf_expected | 3 +++
3 files changed, 34 insertions(+), 29 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list