Skip to content

Commit

Permalink
tests run
Browse files Browse the repository at this point in the history
  • Loading branch information
pramsey committed Dec 12, 2023
1 parent 49c7156 commit 2e6bb71
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 27 deletions.
16 changes: 6 additions & 10 deletions input/pgsql.source
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ CREATE FOREIGN TABLE bytea_fdw (
tm time,
dttm timestamp,
varch char(8),
txtarr text[],
yn char
) SERVER pgserver OPTIONS (layer 'bytea_local');

SELECT fid, name, geom, age, size, value, num, dt, tm, dttm, varch, txtarr, yn FROM bytea_fdw;
SELECT fid, name, geom, age, size, value, num, dt, tm, dttm, varch, yn FROM bytea_fdw;

SELECT a.name, b.name
FROM bytea_local a
Expand Down Expand Up @@ -135,9 +134,10 @@ SELECT a.fid, a.name, b.name
USING (fid);

----------------------------------------------------------------------
-- Array support
-- Populate local array table

SET client_min_messages = NOTICE;

DROP TABLE IF EXISTS array_local;
CREATE TABLE array_local (
fid integer primary key,
geom bytea,
Expand All @@ -147,18 +147,14 @@ CREATE TABLE array_local (
b boolean[]
);

----------------------------------------------------------------------
-- Populate local table

INSERT INTO array_local (fid,txt, int, flt, b) VALUES
(1, ARRAY['Jim'], ARRAY[1,2,3], ARRAY[3.4,5.6,7.8], ARRAY[true,false]),
(2, ARRAY['Jim',NULL,'Joe'], ARRAY[1,3,NULL,4], ARRAY[4.5,NULL,3.4], ARRAY[false,NULL]),
(3, NULL, NULL, NULL, NULL);

----------------------------------------------------------------------
-- Create remote table
-- Create remote array table

DROP FOREIGN TABLE IF EXISTS array_fdw;
CREATE FOREIGN TABLE array_fdw (
fid bigint,
geom bytea,
Expand All @@ -171,7 +167,7 @@ CREATE FOREIGN TABLE array_fdw (
SELECT fid, txt, int, flt, b FROM array_fdw;

----------------------------------------------------------------------
-- Update remote table
-- Update remote array table

UPDATE array_fdw SET
txt = ARRAY['newJim', 'newJoe'],
Expand Down
5 changes: 2 additions & 3 deletions ogr_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,6 @@ ogrReadColumnData(OgrFdwState* state)
{
/* Extra type info needed to form the array */
col.pgisarray = true;
get_typlenbyvalalign(col.pgelmtype, &col.pgtyplen, &col.pgtypbyval, &col.pgtypalign);
}
else
col.pgelmtype = col.pgtype;
Expand All @@ -1414,9 +1413,9 @@ ogrReadColumnData(OgrFdwState* state)

/* Get the PgSQL column name */
#if PG_VERSION_NUM >= 110000
col.pgname = get_attname(rel->rd_id, att_tuple->attnum, false);
col.pgname = pstrdup(get_attname(rel->rd_id, att_tuple->attnum, false));
#else
col.pgname = get_attname(rel->rd_id, att_tuple->attnum);
col.pgname = pstrdup(get_attname(rel->rd_id, att_tuple->attnum));
#endif

/* Handle FID first */
Expand Down
25 changes: 11 additions & 14 deletions ogr_fdw.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,28 +98,25 @@ typedef enum {
typedef struct OgrFdwColumn
{
/* PgSQL metadata */
int pgattnum; /* PostgreSQL attribute number */
int pgattisdropped; /* PostgreSQL attribute dropped? */
char* pgname; /* PostgreSQL column name */
Oid pgtype; /* PostgreSQL data type */
int pgtypmod; /* PostgreSQL type modifier */
int pgattnum; /* PgSQL attribute number */
int pgattisdropped; /* PgSQL attribute dropped? */
char* pgname; /* PgSQL column name */
Oid pgtype; /* PgQL data type */
int pgtypmod; /* PgSQL type modifier */

bool pgisarray;
Oid pgelmtype; /* If column is array then this is nonzero */
int16 pgtyplen;
bool pgtypbyval;
char pgtypalign;

/* For reading */
Oid pginputfunc; /* PostgreSQL function to convert cstring to type */
/* For reading. If array, for array element type. */
Oid pginputfunc; /* PgSQL convert cstring to type */
Oid pginputioparam;
Oid pgrecvfunc; /* PostgreSQL function to convert binary to type */
Oid pgrecvfunc; /* PgSQL convert binary to type */
Oid pgrecvioparam;

/* For writing */
Oid pgoutputfunc; /* PostgreSQL function to convert type to cstring */
/* For writing. If array, for array element type. */
Oid pgoutputfunc; /* PgSQL convert type to cstring */
bool pgoutputvarlena;
Oid pgsendfunc; /* PostgreSQL function to convert type to binary */
Oid pgsendfunc; /* PgSQL convert type to binary */
bool pgsendvarlena;

/* OGR metadata */
Expand Down

0 comments on commit 2e6bb71

Please sign in to comment.