From 237231a1572ff74f08bd07d088b3579b0fc782a7 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Tue, 12 Dec 2023 16:22:25 -0800 Subject: [PATCH] int64 --- ogr_fdw.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/ogr_fdw.c b/ogr_fdw.c index a935e68..fb876bf 100644 --- a/ogr_fdw.c +++ b/ogr_fdw.c @@ -1762,7 +1762,7 @@ ogrFeatureToSlot(const OGRFeatureH feat, TupleTableSlot* slot, const OgrFdwExecS char fidstr[256]; snprintf(fidstr, 256, OGR_FDW_FRMT_INT64, OGR_FDW_CAST_INT64(fid)); - values[i] = pgDatumFromCString(fidstr, &col, PG_SQL_ASCII, &is_null); + values[i] = pgDatumFromCString(fidstr, &col, execstate->ogr.char_encoding, &is_null); nulls[i] = is_null; } } @@ -1966,9 +1966,29 @@ ogrFeatureToSlot(const OGRFeatureH feat, TupleTableSlot* slot, const OgrFdwExecS break; } + #if GDAL_VERSION_MAJOR >= 2 case OFTInteger64List: + { + int ilist_size; + const int64 *ilist = (int64*)OGR_F_GetFieldAsInteger64List(feat, ogrfldnum, &ilist_size); + ArrayBuildState *abs = initArrayResult(col.pgelmtype, CurrentMemoryContext, false); + for (uint32 i = 0; i < ilist_size; i++) + { + bool is_null = false; + snprintf(cstr, CSTR_SZ, "%ld", ilist[i]); + abs = accumArrayResult(abs, + pgDatumFromCString(cstr, &col, execstate->ogr.char_encoding, &is_null), + is_null, + col.pgelmtype, + CurrentMemoryContext); + } + values[i] = makeArrayResult(abs, CurrentMemoryContext); + nulls[i] = false; + break; + } #endif + case OFTIntegerList: { int ilist_size; @@ -1979,7 +1999,7 @@ ogrFeatureToSlot(const OGRFeatureH feat, TupleTableSlot* slot, const OgrFdwExecS bool is_null = false; snprintf(cstr, CSTR_SZ, "%d", ilist[i]); abs = accumArrayResult(abs, - pgDatumFromCString(cstr, &col, PG_SQL_ASCII, &is_null), + pgDatumFromCString(cstr, &col, execstate->ogr.char_encoding, &is_null), is_null, col.pgelmtype, CurrentMemoryContext); @@ -1999,7 +2019,7 @@ ogrFeatureToSlot(const OGRFeatureH feat, TupleTableSlot* slot, const OgrFdwExecS bool is_null = false; snprintf(cstr, CSTR_SZ, "%g", rlist[i]); abs = accumArrayResult(abs, - pgDatumFromCString(cstr, &col, PG_SQL_ASCII, &is_null), + pgDatumFromCString(cstr, &col, execstate->ogr.char_encoding, &is_null), is_null, col.pgelmtype, CurrentMemoryContext); @@ -2017,7 +2037,7 @@ ogrFeatureToSlot(const OGRFeatureH feat, TupleTableSlot* slot, const OgrFdwExecS { bool is_null = false; abs = accumArrayResult(abs, - pgDatumFromCString(*cstrs, &col, PG_SQL_ASCII, &is_null), + pgDatumFromCString(*cstrs, &col, execstate->ogr.char_encoding, &is_null), is_null, col.pgelmtype, CurrentMemoryContext);