diff --git a/src/compat/compat.h b/src/compat/compat.h index 614356581..f2a1a46d7 100644 --- a/src/compat/compat.h +++ b/src/compat/compat.h @@ -175,6 +175,15 @@ get_vacuum_options(const VacuumStmt *stmt) (analyze ? VACOPT_ANALYZE : 0); } +/* PG14 splits Copy code into separate code for COPY FROM and COPY TO + * since we were only interested in the COPY FROM parts we macro CopyFromState + * to CopyState for versions < 14 + * https://github.com/postgres/postgres/commit/c532d15ddd + */ +#if PG14_LT +#define CopyFromState CopyState +#endif + /* PG13 added a dstlen parameter to pg_b64_decode and pg_b64_encode */ #if PG13_LT #define pg_b64_encode_compat(src, srclen, dst, dstlen) pg_b64_encode((src), (srclen), (dst)) diff --git a/src/copy.c b/src/copy.c index e159ad9b6..f554399f4 100644 --- a/src/copy.c +++ b/src/copy.c @@ -36,6 +36,7 @@ #include #include +#include "compat/compat.h" #include "hypertable.h" #include "copy.h" #include "dimension.h" @@ -56,7 +57,7 @@ */ static CopyChunkState * -copy_chunk_state_create(Hypertable *ht, Relation rel, CopyFromFunc from_func, CopyState cstate, +copy_chunk_state_create(Hypertable *ht, Relation rel, CopyFromFunc from_func, CopyFromState cstate, TableScanDesc scandesc) { CopyChunkState *ccstate; @@ -272,7 +273,7 @@ copyfrom(CopyChunkState *ccstate, List *range_table, Hypertable *ht, void (*call /* Set up callback to identify error line number. * * It is not necessary to add an entry to the error context stack if we do - * not have a CopyState or callback. In that case, we just use the existing + * not have a CopyFromState or callback. In that case, we just use the existing * error already on the context stack. */ if (ccstate->cstate && callback) { @@ -608,7 +609,7 @@ void timescaledb_DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed, Hypertable *ht) { CopyChunkState *ccstate; - CopyState cstate; + CopyFromState cstate; bool pipe = (stmt->filename == NULL); Relation rel; List *attnums = NIL; @@ -653,6 +654,9 @@ timescaledb_DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *proces cstate = BeginCopyFrom(pstate, rel, +#if PG14_GE + NULL, +#endif stmt->filename, stmt->is_program, NULL, diff --git a/src/copy.h b/src/copy.h index 04d40c651..820f50463 100644 --- a/src/copy.h +++ b/src/copy.h @@ -27,7 +27,7 @@ typedef struct CopyChunkState EState *estate; ChunkDispatch *dispatch; CopyFromFunc next_copy_from; - CopyState cstate; + CopyFromState cstate; TableScanDesc scandesc; Node *where_clause; } CopyChunkState; diff --git a/tsl/src/remote/dist_copy.c b/tsl/src/remote/dist_copy.c index 0610d86ea..137d14aaf 100644 --- a/tsl/src/remote/dist_copy.c +++ b/tsl/src/remote/dist_copy.c @@ -631,7 +631,7 @@ remote_copy_get_copycmd(RemoteCopyContext *context) } static StringInfo -parse_next_text_row(CopyState cstate, List *attnums, TextCopyContext *ctx) +parse_next_text_row(CopyFromState cstate, List *attnums, TextCopyContext *ctx) { StringInfo row_data = makeStringInfo(); int i; @@ -693,7 +693,7 @@ generate_binary_copy_data(Datum *values, bool *nulls, List *attnums, FmgrInfo *o } static StringInfo -parse_next_binary_row(CopyState cstate, List *attnums, BinaryCopyContext *ctx) +parse_next_binary_row(CopyFromState cstate, List *attnums, BinaryCopyContext *ctx) { if (!NextCopyFrom(cstate, ctx->econtext, ctx->values, ctx->nulls)) return NULL; @@ -702,7 +702,7 @@ parse_next_binary_row(CopyState cstate, List *attnums, BinaryCopyContext *ctx) } static bool -read_next_copy_row(RemoteCopyContext *context, CopyState cstate) +read_next_copy_row(RemoteCopyContext *context, CopyFromState cstate) { if (context->binary_operation) context->row_data = parse_next_binary_row(cstate, context->attnums, context->data_context);