diff --git a/src/copy.c b/src/copy.c index 047026229..49d9cab4b 100644 --- a/src/copy.c +++ b/src/copy.c @@ -458,6 +458,11 @@ timescaledb_DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *proces Relation rel; Oid relid; List *range_table = NIL; + TupleDesc tupDesc; + AclMode required_access = (is_from ? ACL_INSERT : ACL_SELECT); + List *attnums; + ListCell *cur; + RangeTblEntry *rte; /* Disallow COPY to/from file or program except to superusers. */ if (!pipe && !superuser()) @@ -477,15 +482,7 @@ timescaledb_DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *proces } if (!is_from || NULL == stmt->relation) - { elog(ERROR, "timescale DoCopy should only be called for COPY FROM"); - } - - TupleDesc tupDesc; - AclMode required_access = (is_from ? ACL_INSERT : ACL_SELECT); - List *attnums; - ListCell *cur; - RangeTblEntry *rte; Assert(!stmt->query); @@ -504,6 +501,7 @@ timescaledb_DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *proces tupDesc = RelationGetDescr(rel); attnums = timescaledb_CopyGetAttnums(tupDesc, rel, stmt->attlist); + foreach(cur, attnums) { int attno = lfirst_int(cur) - @@ -514,6 +512,7 @@ timescaledb_DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *proces else rte->selectedCols = bms_add_member(rte->selectedCols, attno); } + ExecCheckRTPerms(range_table, true); /* diff --git a/src/dimension.c b/src/dimension.c index e7f67545f..34b4131de 100644 --- a/src/dimension.c +++ b/src/dimension.c @@ -208,7 +208,7 @@ calculate_closed_range_default(Dimension *dim, int64 value) range_end; /* The interval that divides the dimension into N equal sized slices */ - int64 interval = DIMENSION_SLICE_CLOSED_MAX / ((int64)dim->fd.num_slices); + int64 interval = DIMENSION_SLICE_CLOSED_MAX / ((int64) dim->fd.num_slices); int64 last_start = interval * (dim->fd.num_slices - 1); if (value < 0)