Commit Graph

5237 Commits (814d302ba8cfdbc6618c1095272b5945a8cbc327)

Author SHA1 Message Date
Onur Tirtir 9801f743ce Revoke read access to columnar.chunk from unprivileged user (#5313)
Since this could expose chunk min/max values to unprivileged users.
(cherry picked from commit 77a2dd68da)
2021-09-22 16:24:08 +03:00
Onur Tirtir 8e3246a2f3 Columnar CustomScan: Pushdown BoolExpr's as we do before
(cherry picked from commit 68335285b4)
2021-09-22 11:44:12 +03:00
Onur Tirtir 1feb7102b8 Check if xact id is in progress before checking if aborted (#5312)
(cherry picked from commit e6ed764f63)
2021-09-22 11:44:12 +03:00
Onur Tirtir 9cde3d4122 Add CheckCitusVersion() calls to columnarAM (#5308)
Considering all code-paths that we might interact with a columnar table,
add `CheckCitusVersion` calls to tableAM callbacks:
- initializing table scan (`columnar_beginscan` & `columnar_index_fetch_begin`)
- setting a new filenode for a relation (storage initializiation or a table rewrite)
- truncating the storage
- inserting tuple (single and multi)

Also add `CheckCitusVersion` call to:
- drop hook (`ColumnarTableDropHook`)
- `alter_columnar_table_set` & `alter_columnar_table_reset` UDFs
(cherry picked from commit f8b1ff7214)
2021-09-20 17:33:51 +03:00
Onder Kalaci 7da6d68675 Add missing version checks for citus_internal_XXX functions
(cherry picked from commit cea937f52f)
2021-09-20 13:50:47 +03:00
Hanefi Onaldi a913b90ff3
Bump Citus version to 10.2.0 2021-09-15 05:55:36 +03:00
Gurkan Indibay 082667a985
Add changelog entries for 10.2.0 2021-09-15 05:20:13 +03:00
jeff-davis 6e8b19984e
Columnar: separate plan and runtime quals. (#5261)
* Columnar: separate plain and exec quals.

Make a clear separation between plain quals, which contain constants
or extern params; and exec quals, which contain exec params and can't
be evaluated until a rescan.

Fixes #5258.

* more vanilla tests

Co-authored-by: Onur Tirtir <onurcantirtir@gmail.com>
2021-09-13 10:54:53 -07:00
jeff-davis d48ceee238
Columnar: add method ReparameterizeCustomPathByChild. (#5275)
When performing a partition-wise join, the planner will adjust paths
parameterized by the parent rel to instead parameterize by the child
rel directly. When this reparameterization happens, we also need to
adjust the join quals to reference the child rather than the parent.

Fixes #5257.
2021-09-13 10:33:48 -07:00
Onur Tirtir ea61efb63a
Not flush writes until need to read them when doing index-scan on columnar (#5247)
Not flush pending writes if given tid belongs to a "flushed" or
"aborted" stripe write, or to an "in-progress" stripe write of
another backend.

That way, we would reduce the cases where we flush single-tuple
stripes during index scan.

To do that, we follow below steps for index look-up's:

- Do not flush any pending writes and do stripe metadata look-up for
  given tid.
  If tuple with tid is found, then no need to do another look-up
  since we already found the tuple without needing to flush pending
  writes.

- If tuple is not found without flushing pending writes, then we have two
  scenarios:

  -  If given tid belongs to a pending write of my backend, then do stripe
     metadata look-up for given tid. But this time first **flush any pending
     writes**.
     
  -  Otherwise, just return false from `index_fetch_tuple` since flushing
      pending writes wouldn't help.
2021-09-13 18:41:20 +02:00
Onur Tirtir 4ee0fb2758
Make sure to skip aborted writes when reading the first tuple (#5274)
With 5825c44d5f, we made the changes to
skip aborted writes when scanning a columnar table.

However, looks like we forgot to handle such cases for the very first
call made to columnar_getnextslot. That means, that commit only
considered the intermediate stripe read operations.

However, functions called by columnar_getnextslot to find first stripe
to read (ColumnarBeginRead & ColumnarRescan) were not caring about
those aborted writes.

To fix that, we teach AdvanceStripeRead to find the very first stripe
to read, and then start using it where were blindly calling
FindNextStripeByRowNumber.
2021-09-13 11:50:53 +03:00
Burak Velioglu 531ad83b8c
Merge pull request #5263 from citusdata/velioglu/handle_errors_on_abort
Swallow errors while aborting remote transactions
2021-09-10 11:18:47 +03:00
Burak Velioglu ceec5d72e3
Swallow errors while aborting remote transactions 2021-09-10 11:06:16 +03:00
Naisila Puka a69abe3be0
Fixes bug about int and smallint sequences on MX (#5254)
* Introduce worker_nextval udf for int&smallint column defaults

* Fix current tests and add new ones for worker_nextval
2021-09-09 23:41:07 +03:00
Nils Dijk 80a44a7b93
prevent double inclusion of columnar_tableam.h (#5266)
Recently there are some warnings during the compilation of Citus.
Part of the warnings come due to the `columnar_tableam.h` header not being properly guarded with defines and ifndef's.

This PR fixes these warnings.
2021-09-09 17:37:58 +02:00
Onur Tirtir be74518965
Improve memset calls made to reset bool arrays (#5262) 2021-09-09 17:56:03 +03:00
Halil Ozan Akgül f4428412a0
Merge pull request #5234 from citusdata/cte_with_search_clause
Errors for CTEs with search clause
2021-09-09 13:53:44 +03:00
Halil Ozan Akgul 19af1cef2f Errors for CTEs with search clause
Relevant PG commit:
3696a600e2292d43c00949ddf0352e4ebb487e5b
2021-09-09 13:48:24 +03:00
Marco Slot b3f1a94688
Merge pull request #5256 from citusdata/marcocitus/worker_append_table_to_shard
Perform copy command as regular user in worker_append_table_to_shard
2021-09-09 12:37:36 +02:00
Marco Slot f84164a000 Avoid switch to superuser in worker_merge_files_into_table 2021-09-09 11:00:29 +02:00
Marco Slot 04388e13b0 Add worker_append_table_to_shard permissions tests 2021-09-09 11:00:29 +02:00
Marco Slot 4faa49775b Perform copy command as regular user in worker_append_table_to_shard 2021-09-09 11:00:29 +02:00
Hanefi Onaldi 9ae912a8c8
Prevent C-style comments in all directories (#5250) 2021-09-09 11:54:58 +03:00
SaitTalhaNisanci e3e0a028c7
return early in case we want to skip outer vars (#5259) 2021-09-09 10:53:36 +03:00
Onur Tirtir 32e3e51ed4
Fix a compiler warning that we get on debian (#5260) 2021-09-08 20:03:59 +03:00
Onur Tirtir 74d9d2a718
Merge pull request #5246 from citusdata/col/no-index-only 2021-09-08 14:19:39 +03:00
Onur Tirtir 9935dfb958 Remove a flaky test from columnar_paths
We already knew that it was flaky. Moreover, now it failed on my
branch too.

So removing it with this commit.
2021-09-08 14:15:22 +03:00
Onur Tirtir be3914ae28 Prevent generating index-only "Path"s for columnar tables
Previously, even when `EXPLAIN` output tells that we will do
index-only scan, it was never the case since columnar tables
don't have the visibility fork that postgres is looking for.

For this reason, visibility check done in
`IndexOnlyNext->VM_ALL_VISIBLE`
code-path was always returning false and postgres was reading
the tuple from the columnar relation itself.
2021-09-08 14:14:24 +03:00
Onur Tirtir cc49e63222
Not read heaptuple after closing pg_rewrite (#5255) 2021-09-08 13:03:17 +02:00
Onur Tirtir 3340f17c4e
Prevent planner from choosing parallel scan for columnar tables (#5245)
Previously, for regular table scans, we were setting `RelOptInfo->partial_pathlist`
to `NIL` via `set_rel_pathlist_hook` to discard scan `Path`s that need to use any
parallel workers, this was working nicely.

However, when building indexes, this hook doesn't get called so we were not
able to prevent spawning parallel workers when building an index. For this
reason, 9b4dc2f804 added basic
implementation for `columnar_parallelscan_*` callbacks but also made some
changes to skip using those workers when building the index.

However, now that we are doing stripe reservation in two stages, we call 
`heap_inplace_update` at some point to complete stripe reservation.
However, postgres throws an error if we call `heap_inplace_update` during
a parallel operation, even if we don't actually make use of those workers.

For this reason, with this pr, we make sure to not generate scan `Path`s that
need to use any parallel workers by using `get_relation_info_hook`.

This is indeed useful to prevent spawning parallel workers during index builds.
2021-09-08 13:53:43 +03:00
Onur Tirtir 5825c44d5f
Handle aborted writes properly when scanning a columnar table (#5244)
If it is certain that we will not use any `parallel_worker`s for a columnar table,
then stripe entries inserted by aborted transactions become visible to
`SnapshotAny` and that causes `REINDEX` to fail by throwing a duplicate key
error.

To fix that:
* consider three states for a stripe write operation:
   "flushed", "aborted", or "in-progress",
* make sure to have a clear separation between them, and
* act according to those three states when reading from a columnar table
2021-09-08 13:26:11 +03:00
Onur Tirtir 5dc619162d
Add valgrind test target for multi-1 (#5251) 2021-09-07 16:27:34 +03:00
Jelte Fennema 5f46372416
Merge pull request #5242 from citusdata/enable-binary-protocol-on-pg14
Since PG14 we can now use binary encoding for arrays and composite types
that contain user defined types. This was fixed in this commit in
Postgres: 670c0a1d47

This change starts using that knowledge, by not necessarily falling back
to text encoding anymore for those types.

While doing this and testing a bit more I found various cases where
binary encoding would fail that our checks didn't cover. This fixes
those cases and adds tests for those. It also fixes EXPLAIN ANALYZE 
never using binary encoding, which was a leftover of workaround that
was not necessary anymore.

Finally, it changes the default for both `citus.enable_binary_protocol`
and `citus.binary_worker_copy_format` to `true` for PG14 and up. In our
cloud offering `binary_worker_copy_format` already was true by default.
`enable_binary_protocol` had some bug with MX and user defined types, 
this bug was fixed by the above mentioned fixes.
2021-09-06 10:44:08 +02:00
Jelte Fennema bb5c494104 Enable binary encoding by default on PG14
Since PG14 we can now use binary encoding for arrays and composite types
that contain user defined types. This was fixed in this commit in
Postgres: 670c0a1d47

This change starts using that knowledge, by not necessarily falling back
to text encoding anymore for those types.

While doing this and testing a bit more I found various cases where
binary encoding would fail that our checks didn't cover. This fixes
those cases and adds tests for those. It also fixes EXPLAIN ANALYZE
never using binary encoding, which was a leftover of workaround that
was not necessary anymore.

Finally, it changes the default for both `citus.enable_binary_protocol`
and `citus.binary_worker_copy_format` to `true` for PG14 and up. In our
cloud offering `binary_worker_copy_format` already was true by default.
`enable_binary_protocol` had some bug with MX and user defined types,
this bug was fixed by the above mentioned fixes.
2021-09-06 10:27:29 +02:00
SaitTalhaNisanci 148f51cb98
Merge pull request #5243 from citusdata/update/pg14_images
Update pg14 images
2021-09-06 10:56:19 +03:00
Sait Talha Nisanci 52fd2de76c Update pg14 images 2021-09-06 10:07:52 +03:00
Burak Velioglu eada7f0bbc
Merge pull request #5236 from citusdata/velioglu/partition_helper_udfs
Add helper UDFs for easy time partition management
2021-09-03 23:17:54 +03:00
Burak Velioglu c3895f35cd
Add helper UDFs for easy time partition management
- get_missing_time_partition_ranges: Gets the ranges of missing partitions for the given table, interval and range unless any existing partition conflicts with calculated missing ranges.

- create_time_partitions: Creates partitions by getting range values from get_missing_time_partition_ranges.

- drop_old_time_partitions: Drops partitions of the table older than given threshold.
2021-09-03 23:03:13 +03:00
Onur Tirtir 2b71263e40
Align columnar path costing functions (#5239)
* Rename RecostColumnarPaths to CostColumnarPaths

* Rename RecostColumnarIndexPath to CostColumnarIndexPath

* Reorder args of CostColumnarScan to align with other two costing functions

* Not adjust index scan start-up cost

* Rename ColumnarIndexScanAddTotalCost to ColumnarIndexScanAdditionalCost

* Reflect that index scan will at least read one stripe in totalCost calculation

* Organize declarations in columnar_customscan.c
2021-09-03 19:37:42 +03:00
jeff-davis cc58b58f73
Columnar: reserve metapage flag for UNLOGGED support. (#5237)
Reserve space in the metapage for a flag to support UNLOGGED tables in
the future without a metapage upgrade.
2021-09-03 08:40:55 -07:00
Halil Ozan Akgül f67574496c
Merge pull request #5238 from citusdata/error_reindex_dist_part_tables
Adds error message for REINDEX TABLE queries on distributed partition…
2021-09-03 17:24:44 +03:00
Halil Ozan Akgul 7fadfb74bb Adds error message for REINDEX TABLE queries on distributed partitioned tables 2021-09-03 16:46:42 +03:00
SaitTalhaNisanci 9f211eb874
Merge pull request #5209 from citusdata/pg14_support
Add Pg14 support
2021-09-03 16:22:38 +03:00
Sait Talha Nisanci 3ad3bbba84 Apply latest version compat without conflicts 2021-09-03 16:09:59 +03:00
Sait Talha Nisanci 0b67fcf81d Fix style 2021-09-03 16:09:59 +03:00
Halil Ozan Akgul e1f5520e1a Adds propagation of ALTER TABLE .. ALTER COLUMN .. SET COMPRESSION .. 2021-09-03 15:44:28 +03:00
SaitTalhaNisanci 902af39a04 Add join alias tests (#5233)
PG COMMIT: 055fee7eb4dcc78e58672aef146334275e1cc40d
2021-09-03 15:44:28 +03:00
SaitTalhaNisanci 2a2ebab1fa Add tests for jsonb subscripting (#5232)
PG commit: 676887a3b0b8e3c0348ac3f82ab0d16e9a24bd43
2021-09-03 15:44:28 +03:00
Ahmet Gedemenli 2b263f9a2a ALTER STATISTICS .. OWNER TO CURRENT_ROLE (#5225)
(cherry picked from commit 42322caf90ca094777aa01376e02d1187afc1560)
2021-09-03 15:44:28 +03:00
Onder Kalaci 82a3b20fb3 Fix flaky test 2021-09-03 15:44:28 +03:00