Skip to content

Commit

Permalink
add release 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
minh1leanh committed Jan 9, 2024
1 parent c7cc9f2 commit 737e177
Show file tree
Hide file tree
Showing 301 changed files with 47,261 additions and 31,898 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ endif #!CXX_CLIENT
EXTENSION = influxdb_fdw
DATA = influxdb_fdw--1.0.sql influxdb_fdw--1.1.sql influxdb_fdw--1.1--1.2.sql influxdb_fdw--1.2.sql influxdb_fdw--1.3.sql

REGRESS = aggregate influxdb_fdw selectfunc extra/join extra/limit extra/aggregates extra/insert extra/prepare extra/select_having extra/select extra/influxdb_fdw_post schemaless/aggregate schemaless/influxdb_fdw schemaless/selectfunc schemaless/schemaless schemaless/extra/join schemaless/extra/limit schemaless/extra/aggregates schemaless/extra/prepare schemaless/extra/select_having schemaless/extra/insert schemaless/extra/select schemaless/extra/influxdb_fdw_post schemaless/add_fields schemaless/add_tags schemaless/add_multi_key
REGRESS = extra/aggregates

UNAME = uname
OS := $(shell $(UNAME))
Expand Down Expand Up @@ -75,8 +75,8 @@ MAJORVERSION := $(basename $(VERSION))
endif
endif

ifeq (,$(findstring $(MAJORVERSION), 11 12 13 14 15))
$(error PostgreSQL 11, 12, 13, 14 or 15 is required to compile this extension)
ifeq (,$(findstring $(MAJORVERSION), 12 13 14 15 16.0))
$(error PostgreSQL 12, 13, 14, 15 or 16.0 is required to compile this extension)
endif

ifdef REGRESS_PREFIX
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ InfluxDB Foreign Data Wrapper for PostgreSQL
============================================

This is a foreign data wrapper (FDW) to connect [PostgreSQL](https://www.postgresql.org/)
to [InfluxDB](https://www.influxdata.com) database file. This FDW works with PostgreSQL 11, 12, 13, 14, 15 and confirmed with
to [InfluxDB](https://www.influxdata.com) database file. This FDW works with PostgreSQL 12, 13, 14, 15, 16.0 and confirmed with
- InfluxDB 1.8: with either [influxdb1-go](#install-influxdb-go-client-library) client or [influxdb-cxx](#install-influxdb_cxx-client-library) client.
- InfluxDB 2.2: with [influxdb-cxx](#install-influxdb_cxx-client-library) client via InfluxDB v1 compatibility API.

Expand Down Expand Up @@ -288,7 +288,7 @@ Supported platforms
`influxdb_fdw` was developed on Linux, and should run on any
reasonably POSIX-compliant system.

`influxdb_fdw` is designed to be compatible with PostgreSQL 11 ~ 15.
`influxdb_fdw` is designed to be compatible with PostgreSQL 12 ~ 16.0.

Installation
------------
Expand Down Expand Up @@ -780,6 +780,10 @@ the number of points with field1 and field2 are different in *InfluxDB* database
- Conditions like `WHERE time + interval '1 day' < now()` do not work. Please use `WHERE time < now() - interval '1 day'`.
- InfluxDB FDW does not return an error even if it is overflow.
- `EXP` function of *InfluxDB* may return different precision number for different PC.
- InfluxDB only supports some basic types for tags (string only) and fields (string, float, integer or boolean) => most Postgres types cannot be supported.
- `IMPORT FOREIGN SCHEMA` should be used to identify foreign tables.
- If the user defines it manually, it is necessary to use the correct mapping type in the foreign table to avoid some unexpected behavior because of type mismatch or unsupported in InfluxDB.
- If a user wants to use an unsupported type with InfluxDB data, PostgreSQL's explicit cast functions should be used instead of define column type in foreign table directly.

When a query to foreign tables fails, you can find why it fails by seeing a query executed in *InfluxDB* with `EXPLAIN VERBOSE`.

Expand Down Expand Up @@ -812,7 +816,7 @@ Reference FDW realisation, `postgres_fdw`
License
-------

Copyright (c) 2018-2023, TOSHIBA CORPORATION
Copyright (c) 2018, TOSHIBA CORPORATION

Copyright (c) 2011-2016, EnterpriseDB Corporation

Expand Down
80 changes: 53 additions & 27 deletions deparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@
#include "access/htup_details.h"
#include "access/sysattr.h"
#include "catalog/pg_aggregate.h"
#include "catalog/pg_authid.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
#include "catalog/pg_type.h"
#include "commands/defrem.h"
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
#include "nodes/plannodes.h"
#include "optimizer/clauses.h"
Expand Down Expand Up @@ -228,7 +232,7 @@ static bool influxdb_foreign_expr_walker(Node *node,
/*
* Functions to construct string representation of a node tree.
*/
static void influxdb_deparse_expr(Expr *expr, deparse_expr_cxt *context);
static void influxdb_deparse_expr(Expr *node, deparse_expr_cxt *context);
static void influxdb_deparse_var(Var *node, deparse_expr_cxt *context);
static void influxdb_deparse_const(Const *node, deparse_expr_cxt *context, int showtype);
static void influxdb_deparse_param(Param *node, deparse_expr_cxt *context);
Expand Down Expand Up @@ -287,6 +291,7 @@ bool influxdb_is_star_func(Oid funcid, char *in);
static bool influxdb_is_unique_func(Oid funcid, char *in);
static bool influxdb_is_supported_builtin_func(Oid funcid, char *in);
static bool exist_in_function_list(char *funcname, const char **funclist);
static void add_backslash(StringInfo buf, const char *ptr, const char *regex_special);

/*
* Local variables.
Expand Down Expand Up @@ -2116,6 +2121,24 @@ influxdb_deparse_column_ref(StringInfo buf, int varno, int varattno, Oid vartype
}
}

static void
add_backslash(StringInfo buf, const char *ptr, const char *regex_special)
{
char ch = *ptr;

/* Check regex special character */
if (strchr(regex_special, ch) != NULL)
{
/* Escape this char */
appendStringInfoChar(buf, '\\');
appendStringInfoChar(buf, ch);
}
else
{
appendStringInfoChar(buf, ch);
}
}

/*
* Append a SQL string regex representing "val" to buf.
*
Expand Down Expand Up @@ -2167,23 +2190,13 @@ influxdb_deparse_string_regex(StringInfo buf, const char *val)
elog(ERROR, "invalid pattern matching");
}
else
default:
{
char ch = *ptr;

/* Check regex special character */
if (strchr(regex_special, ch) != NULL)
{
/* Escape this char */
appendStringInfoChar(buf, '\\');
appendStringInfoChar(buf, ch);
}
else
{
appendStringInfoChar(buf, ch);
}
add_backslash(buf, ptr, regex_special);
}
break;
default:
add_backslash(buf, ptr, regex_special);
break;
}

ptr++;
Expand Down Expand Up @@ -3462,6 +3475,13 @@ influxdb_append_group_by_clause(List *tlist, deparse_expr_cxt *context)
Assert(!query->groupingSets);

context->influx_fill_expr = NULL;
/*
* We intentionally print query->groupClause not processed_groupClause,
* leaving it to the remote planner to get rid of any redundant GROUP BY
* items again. This is necessary in case processed_groupClause reduced
* to empty, and in any case the redundancy situation on the remote might
* be different than what we think here.
*/
foreach(lc, query->groupClause)
{
SortGroupClause *grp = (SortGroupClause *) lfirst(lc);
Expand Down Expand Up @@ -3808,7 +3828,7 @@ influxdb_is_tag_key(const char *colname, Oid reloid)
ListCell *lc;

/* Get FDW options */
options = influxdb_get_options(reloid);
options = influxdb_get_options(reloid, GetUserId());

/* If there is no tag in "tags" option, it means column is field */
if (!options->tags_list)
Expand All @@ -3831,19 +3851,13 @@ influxdb_is_tag_key(const char *colname, Oid reloid)
*****************************************************************************/

/*
* influxdb_contain_functions
* influxdb_contain_functions_walker
* Recursively search for functions within a clause.
*
* Returns true if any function (or operator implemented by function) is found.
*
* We will recursively look into TargetEntry exprs.
*/
static bool
influxdb_contain_functions(Node *clause)
{
return influxdb_contain_functions_walker(clause, NULL);
}

static bool
influxdb_contain_functions_walker(Node *node, void *context)
{
Expand All @@ -3860,10 +3874,10 @@ influxdb_contain_functions_walker(Node *node, void *context)
{
/* Recurse into subselects */
return query_tree_walker((Query *) node,
influxdb_contain_functions,
influxdb_contain_functions_walker,
context, 0);
}
return expression_tree_walker(node, influxdb_contain_functions,
return expression_tree_walker(node, influxdb_contain_functions_walker,
context);
}

Expand Down Expand Up @@ -3894,7 +3908,7 @@ influxdb_is_foreign_function_tlist(PlannerInfo *root,
{
TargetEntry *tle = lfirst_node(TargetEntry, lc);

if (influxdb_contain_functions((Node *) tle->expr))
if (influxdb_contain_functions_walker((Node *) tle->expr, NULL))
{
is_contain_function = true;
break;
Expand Down Expand Up @@ -4149,7 +4163,7 @@ influxdb_get_number_tag_key(Oid relid, schemaless_info *pslinfo)
influxdb_opt *options;

/* Get FDW options */
options = influxdb_get_options(relid);
options = influxdb_get_options(relid, GetUserId());

return list_length(options->tags_list);
}
Expand Down Expand Up @@ -4558,3 +4572,15 @@ influxdb_escape_record_string(char *string)

return buffer->data;
}

/*
* Construct DROP MEASUREMENT <measurement_name> query.
* This query deletes all data and series from the specified <measurement_name>
* and deletes the measurement from the index.
*/
void
influxdb_deparse_drop_measurement_stmt(StringInfo buf, Relation rel)
{
appendStringInfo(buf, "DROP MEASUREMENT ");
influxdb_deparse_relation(buf, rel);
}
Loading

0 comments on commit 737e177

Please sign in to comment.