[Git][debian-gis-team/pgsql-ogr-fdw][upstream] New upstream version 1.1.7
Bas Couwenberg (@sebastic)
gitlab at salsa.debian.org
Wed May 21 04:30:18 BST 2025
Bas Couwenberg pushed to branch upstream at Debian GIS Project / pgsql-ogr-fdw
Commits:
d361f4cc by Bas Couwenberg at 2025-05-21T05:19:57+02:00
New upstream version 1.1.7
- - - - -
6 changed files:
- Makefile
- data/pt_two.prj
- ogr_fdw.c
- ogr_fdw.h
- ogr_fdw_common.c
- ogr_fdw_info.c
Changes:
=====================================
Makefile
=====================================
@@ -20,7 +20,10 @@ EXTRA_CLEAN = sql/*.sql expected/*.out
GDAL_CONFIG = gdal-config
GDAL_CFLAGS = $(shell $(GDAL_CONFIG) --cflags)
-GDAL_LIBS = $(shell $(GDAL_CONFIG) --libs)
+GDAL_LIBS = $(shell $(GDAL_CONFIG) --libs)
+
+# For MacOS
+# GDAL_LIBS += -rpath $(shell $(GDAL_CONFIG) --prefix)/lib
PG_CONFIG = pg_config
REGRESS_OPTS = --encoding=UTF8
@@ -28,8 +31,6 @@ REGRESS_OPTS = --encoding=UTF8
PG_CPPFLAGS += $(GDAL_CFLAGS)
LIBS += $(GDAL_LIBS)
SHLIB_LINK := $(LIBS)
-# For MacOS
-#SHLIB_LINK += -rpath /usr/local/lib
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
=====================================
data/pt_two.prj
=====================================
@@ -1 +1 @@
-GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
\ No newline at end of file
+GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295], AUTH["EPSG",4326]]
=====================================
ogr_fdw.c
=====================================
@@ -39,6 +39,7 @@
*/
#include "ogr_fdw.h"
+
PG_MODULE_MAGIC;
/*
@@ -183,7 +184,7 @@ Oid GEOMETRYOID = InvalidOid;
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,1,0)
-const char* const gdalErrorTypes[] =
+static const char* const gdalErrorTypes[] =
{
"None",
"AppDefined",
@@ -1034,6 +1035,9 @@ ogrGetForeignPaths(PlannerInfo* root,
NULL, /* PathTarget */
#endif
baserel->rows,
+#if PG_VERSION_NUM >= 180000
+ 0, /* disabled_nodes */
+#endif
planstate->startup_cost,
planstate->total_cost,
NIL, /* no pathkeys */
@@ -1049,7 +1053,6 @@ ogrGetForeignPaths(PlannerInfo* root,
); /* no fdw_private data */
}
-
/*
* Convert an OgrFdwSpatialFilter into a List so it can
* be safely passed through the fdw_private list.
@@ -1466,11 +1469,8 @@ ogrReadColumnData(OgrFdwState* state)
OgrFieldEntry* found_entry;
OgrFieldEntry entry;
-#if PG_VERSION_NUM >= 110000
- Form_pg_attribute att_tuple = &tupdesc->attrs[i];
-#else
- Form_pg_attribute att_tuple = tupdesc->attrs[i];
-#endif
+ Form_pg_attribute att_tuple = TupleDescAttr(tupdesc, i);
+
OgrFdwColumn col = tbl->cols[i];
col.pgattnum = att_tuple->attnum;
col.pgtype = att_tuple->atttypid;
@@ -1602,60 +1602,77 @@ ogrReadColumnData(OgrFdwState* state)
return;
}
+
/*
* ogrLookupGeometryFunctionOid
*
* Find the procedure Oids of useful functions so we can call
- * them later.
+ * them later. In the case where multiple functions have the
+ * same signature, in different namespaces (???) we might have
+ * problems, but that seems very unlikely.
+ *
+ * https://github.com/pramsey/pgsql-ogr-fdw/issues/266
*/
static Oid
ogrLookupGeometryFunctionOid(const char* proname)
{
- List* names;
- FuncCandidateList clist;
+ CatCList *clist;
+ int i;
+ Oid result = InvalidOid;
/* This only works if PostGIS is installed */
- if (ogrGetGeometryOid() == InvalidOid || ogrGetGeometryOid() == BYTEAOID)
+ if (ogrGetGeometryOid() == InvalidOid ||
+ ogrGetGeometryOid() == BYTEAOID)
{
- return InvalidOid;
+ return result;
}
-#if PG_VERSION_NUM < 160000
- names = stringToQualifiedNameList(proname);
-#else
- names = stringToQualifiedNameList(proname,NULL);
-#endif
-#if PG_VERSION_NUM < 90400
- clist = FuncnameGetCandidates(names, -1, NIL, false, false);
-#elif PG_VERSION_NUM < 140000
- clist = FuncnameGetCandidates(names, -1, NIL, false, false, false);
-#else
- clist = FuncnameGetCandidates(names, -1, NIL, false, false, false, false);
-#endif
+ if (!proname) return result;
+
+ /* Search syscache by name only */
+ clist = SearchSysCacheList1(PROCNAMEARGSNSP,
+ CStringGetDatum(proname));
if (!clist) return InvalidOid;
- if (streq(proname, "st_setsrid"))
+ for (i = 0; i < clist->n_members; i++)
{
- do
+ HeapTuple proctup = &clist->members[i]->tuple;
+ Form_pg_proc procform = (Form_pg_proc) GETSTRUCT(proctup);
+ Oid *proargtypes = procform->proargtypes.values;
+ int pronargs = procform->pronargs;
+
+#if PG_VERSION_NUM >= 120000
+ Oid procoid = procform->oid;
+#else
+ Oid procoid = HeapTupleGetOid(proctup);
+#endif
+
+ /* ST_SetSRID(geometry, integer) */
+ if (streq(proname, "st_setsrid") &&
+ pronargs == 2 &&
+ proargtypes[0] == ogrGetGeometryOid())
{
- int i;
- for (i = 0; i < clist->nargs; i++)
- {
- if (clist->args[i] == ogrGetGeometryOid())
- {
- return clist->oid;
- }
- }
+ result = procoid;
+ break;
+ }
+ /* postgis_typmod_srid(typmod) */
+ else if (streq(proname, "postgis_typmod_srid") &&
+ pronargs == 1)
+ {
+ /* postgis_typmod_srid(integer) */
+ result = procoid;
+ break;
+ }
+ else
+ {
+ elog(ERROR, "%s could not find function '%s'",
+ __func__, proname);
}
- while ((clist = clist->next));
- }
- else if (streq(proname, "postgis_typmod_srid"))
- {
- return clist->oid;
}
- return InvalidOid;
+ ReleaseSysCacheList(clist);
+ return result;
}
/*
@@ -2067,7 +2084,7 @@ ogrFeatureToSlot(const OGRFeatureH feat, TupleTableSlot* slot, const OgrFdwExecS
for (uint32 i = 0; i < ilist_size; i++)
{
bool is_null = false;
- snprintf(cstr, CSTR_SZ, "%ld", ilist[i]);
+ snprintf(cstr, CSTR_SZ, OGR_FDW_FRMT_INT64, OGR_FDW_CAST_INT64(ilist[i]));
abs = accumArrayResult(abs,
pgDatumFromCString(cstr, &col, execstate->ogr.char_encoding, &is_null),
is_null,
@@ -2675,13 +2692,10 @@ ogrGetFidColumn(const TupleDesc td)
int i;
for (i = 0; i < td->natts; i++)
{
-#if PG_VERSION_NUM >= 110000
- NameData attname = td->attrs[i].attname;
- Oid atttypeid = td->attrs[i].atttypid;
-#else
- NameData attname = td->attrs[i]->attname;
- Oid atttypeid = td->attrs[i]->atttypid;
-#endif
+ Form_pg_attribute att_tuple = TupleDescAttr(td, i);
+ NameData attname = att_tuple->attname;
+ Oid atttypeid = att_tuple->atttypid;
+
if ((atttypeid == INT4OID || atttypeid == INT8OID) &&
strcaseeq("fid", attname.data))
{
@@ -2721,7 +2735,8 @@ ogrAddForeignUpdateTargets(PlannerInfo* planinfo,
elog(ERROR, "table '%s' does not have a 'fid' column", RelationGetRelationName(target_relation));
}
- att = &tupdesc->attrs[fid_column];
+ att = TupleDescAttr(tupdesc, fid_column);
+
/* Make a Var representing the desired value */
var = makeVar(parsetree->resultRelation,
att->attnum,
@@ -2833,6 +2848,7 @@ ogrExecForeignUpdate(EState* estate,
int64 fid;
OGRFeatureH feat;
OGRErr err;
+ Form_pg_attribute attrs;
elog(DEBUG3, "%s: entered function", __func__);
@@ -2849,11 +2865,9 @@ ogrExecForeignUpdate(EState* estate,
/* What is the value of the FID for this record? */
fid_datum = slot->tts_values[fid_column];
-#if PG_VERSION_NUM >= 110000
- fid_type = td->attrs[fid_column].atttypid;
-#else
- fid_type = td->attrs[fid_column]->atttypid;
-#endif
+ attrs = TupleDescAttr(td, fid_column);
+ fid_type = attrs->atttypid;
+
if (fid_type == INT8OID)
{
fid = DatumGetInt64(fid_datum);
@@ -3070,6 +3084,7 @@ ogrExecForeignDelete(EState* estate,
Datum fid_datum;
int64 fid;
OGRErr err;
+ Form_pg_attribute attrs;
elog(DEBUG3, "%s: entered function", __func__);
@@ -3086,11 +3101,8 @@ ogrExecForeignDelete(EState* estate,
/* What is the value of the FID for this record? */
fid_datum = planSlot->tts_values[fid_column];
-#if PG_VERSION_NUM >= 110000
- fid_type = td->attrs[fid_column].atttypid;
-#else
- fid_type = td->attrs[fid_column]->atttypid;
-#endif
+ attrs = TupleDescAttr(td, fid_column);
+ fid_type = attrs->atttypid;
if (fid_type == INT8OID)
{
=====================================
ogr_fdw.h
=====================================
@@ -22,6 +22,7 @@
#include "access/reloptions.h"
#include "access/sysattr.h"
#include "access/transam.h"
+#include "access/tupdesc.h"
#include "catalog/indexing.h"
#include "catalog/namespace.h"
#include "catalog/pg_collation.h"
@@ -51,6 +52,7 @@
#include "parser/parsetree.h"
#include "storage/ipc.h"
#include "utils/builtins.h"
+#include "utils/catcache.h"
#include "utils/date.h"
#include "utils/fmgroids.h"
#include "utils/lsyscache.h"
@@ -84,6 +86,8 @@
/* hexwkb is not. */
#define OGR_FDW_HEXWKB TRUE
+extern Oid GEOMETRYOID;
+
typedef enum
{
OGR_UNMATCHED,
=====================================
ogr_fdw_common.c
=====================================
@@ -13,6 +13,7 @@
#include "stringbuffer.h"
#include "pg_config_manual.h"
+
/* Prototype for function that must be defined in PostgreSQL (it is) */
/* and in ogr_fdw_info (it is) */
const char * quote_identifier(const char *ident);
@@ -122,7 +123,9 @@ ogrTypeToPgType(OGRFieldDefnH ogr_fld, char *pgtype, size_t width)
}
#endif
ogr_fld_width = OGR_Fld_GetWidth(ogr_fld);
- if (ogr_fld_width > 0)
+
+ /* MaxAttrSize = 10*1024*1024 */
+ if (ogr_fld_width > 0 && ogr_fld_width < 10*1024*1024)
snprintf(pgtype, width, "varchar(%d)", ogr_fld_width);
else
snprintf(pgtype, width, "varchar");
=====================================
ogr_fdw_info.c
=====================================
@@ -59,7 +59,7 @@ strip_spaces(char* str)
/* in the ogr_fdw_common module works */
const char* quote_identifier(const char* ident);
-char identifier[NAMEDATALEN+3];
+static char identifier[NAMEDATALEN+3];
const char*
quote_identifier(const char* ident)
@@ -76,7 +76,8 @@ quote_identifier(const char* ident)
}
return identifier;
}
-char config_options[STR_MAX_LEN] = {0};
+
+static char config_options[STR_MAX_LEN] = {0};
static void
View it on GitLab: https://salsa.debian.org/debian-gis-team/pgsql-ogr-fdw/-/commit/d361f4cc5d24d1453dd1307687b4ed7b028196c4
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/pgsql-ogr-fdw/-/commit/d361f4cc5d24d1453dd1307687b4ed7b028196c4
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20250521/667ab2c4/attachment-0001.htm>
More information about the Pkg-grass-devel
mailing list