Skip to content

Commit

Permalink
RELEASE v2.3.0 (#38)
Browse files Browse the repository at this point in the history
Co-authored-by: Nguyen Ngoc Son <jopoly>
  • Loading branch information
jopoly authored Dec 20, 2023
1 parent e21e041 commit e6c224a
Show file tree
Hide file tree
Showing 186 changed files with 48,976 additions and 32,579 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ GridDB Foreign Data Wrapper for PostgreSQL
==========================================

This is a foreign data wrapper (FDW) to connect [PostgreSQL](https://www.postgresql.org/)
to [GridDB](https://github.com/griddb). This FDW works with PostgreSQL 11, 12, 13, 14, 15 and confirmed with GridDB 5.0.0.
to [GridDB](https://github.com/griddb). This FDW works with PostgreSQL 12, 13, 14, 15, 16 and confirmed with GridDB 5.1.0.


<img src="https://upload.wikimedia.org/wikipedia/commons/2/29/Postgresql_elephant.svg" align="center" height="100" alt="PostgreSQL"/> + <img src="https://docs.griddb.net/logo.png" align="center" height="100" alt="GridDB"/>

Expand Down Expand Up @@ -447,7 +448,7 @@ Reference FDW realisation, `postgres_fdw`

License
-------
Copyright (c) 2018, TOSHIBA CORPORATION
Copyright (c) 2018, TOSHIBA CORPORATION
Copyright (c) 2011-2016, EnterpriseDB Corporation

Permission to use, copy, modify, and distribute this software and its
Expand All @@ -457,4 +458,4 @@ the following two paragraphs appear in all copies.

See the [`LICENSE`][1] file for full details.

[1]: LICENSE
[1]: LICENSE
4 changes: 3 additions & 1 deletion connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,9 @@ griddb_get_connections(PG_FUNCTION_ARGS)
HASH_SEQ_STATUS scan;
ConnCacheEntry *entry;

#if PG_VERSION_NUM >= 150000
#if PG_VERSION_NUM > 150000
InitMaterializedSRF(fcinfo, 0);
#elif PG_VERSION_NUM == 150000
SetSingleFuncCall(fcinfo, 0);
#else
/* check to see if caller supports us returning a tuplestore */
Expand Down
103 changes: 103 additions & 0 deletions deparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ static Node *griddb_deparse_sort_group_clause(Index ref, List *tlist, bool force
deparse_expr_cxt *context);
static void griddb_append_function_name(Oid funcid, deparse_expr_cxt *context);
static bool exist_in_function_list(char *funcname, const char **funclist);
static GSType convert_pgtyp_to_gstyp(Oid type_oid);

/* List of unique function of GridDB */
static const char *GridDBUniqueFunction[] = {
Expand Down Expand Up @@ -2845,3 +2846,105 @@ exist_in_function_list(char *funcname, const char **funclist)
}
return false;
}

/*
* Convert type OID info of Postgresql table into a type name of Griddb.
*/
static GSType
convert_pgtyp_to_gstyp(Oid type_oid)
{
switch (type_oid)
{
case TEXTOID:
case CHAROID:
case VARCHAROID:
return GS_TYPE_STRING;
case BOOLOID:
return GS_TYPE_BOOL;
case INT2OID:
return GS_TYPE_SHORT;
case INT4OID:
return GS_TYPE_INTEGER;
case INT8OID:
return GS_TYPE_LONG;
case FLOAT4OID:
return GS_TYPE_FLOAT;
case FLOAT8OID:
return GS_TYPE_DOUBLE;
case TIMESTAMPOID:
return GS_TYPE_TIMESTAMP;
case BYTEAOID:
return GS_TYPE_BLOB;
case TEXTARRAYOID:
return GS_TYPE_STRING_ARRAY;
case BOOLARRAYOID:
return GS_TYPE_BOOL_ARRAY;
case INT2ARRAYOID:
return GS_TYPE_SHORT_ARRAY;
case INT4ARRAYOID:
return GS_TYPE_INTEGER_ARRAY;
case INT8ARRAYOID:
return GS_TYPE_LONG_ARRAY;
case FLOAT4ARRAYOID:
return GS_TYPE_FLOAT_ARRAY;
case FLOAT8ARRAYOID:
return GS_TYPE_DOUBLE_ARRAY;
case TIMESTAMPARRAYOID:
return GS_TYPE_TIMESTAMP_ARRAY;
default:
elog(ERROR, "cannot convert %d to GSType", type_oid);
}
}

/*
* Construct Container Infomation for CREATING
*/
GSContainerInfo
griddb_set_container_info(GSContainerInfo containerinfo, Relation rel)
{
TupleDesc tupdesc = RelationGetDescr(rel);
int i;
int column_count = 0;
GSContainerInfo container_info;
GSColumnInfo columnInfo;
GSColumnInfo *columnInfoList;

container_info = (GSContainerInfo) GS_CONTAINER_INFO_INITIALIZER;

/* count number of columns */
for (i = 0; i < tupdesc->natts; i++)
{
Form_pg_attribute att = TupleDescAttr(tupdesc, i);

/* Ignore dropped columns. */
if (att->attisdropped)
continue;

column_count++;
}

columnInfoList = palloc0(column_count * sizeof(GSColumnInfo));

/* deparse column */
for (i = 0; i < tupdesc->natts; i++)
{
Form_pg_attribute att = TupleDescAttr(tupdesc, i);

/* Ignore dropped columns. */
if (att->attisdropped)
continue;

/* Use attribute name */
columnInfo.name = NameStr(att->attname);
columnInfo.type = convert_pgtyp_to_gstyp(att->atttypid);
if (att->attnotnull)
columnInfo.options = GS_TYPE_OPTION_NOT_NULL;

columnInfoList[i] = columnInfo;
}

container_info.columnInfoList = columnInfoList;
container_info.columnCount = column_count;

return container_info;
}
Loading

0 comments on commit e6c224a

Please sign in to comment.