Commit Graph

5221 Commits (3c8482893151d5df07a97f046ffd1846b268427c)

Author SHA1 Message Date
Halil Ozan Akgul 1174046a33 Adds bytea equivalents of ltrim() and rtrim() to ruleutils_14.c
Relevant PG commit:
a6cf3df4ebdcbc7857910a67f259705645383e9f
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul 71691ecf06 Adds HASH_STRINGS flag to ruleutils_14.c
Relevant PG commit:
b3817f5f774663d55931dd4fab9c5a94a15ae7ab
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul e72bd0c1a1 Removes dependency.h from ruleutils_14.c
Relevant PG commit:
8b069ef5dca97cd737a5fd64c420df3cd61ec1c9
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul d4874f5ad2 Removes indexing.h header from ruleutils_14.c
Relevant PG commit:
bdc4edbea6fc847f806e1e7118d730e159512bfc
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul 1cb865deb8 Adds SQL syntax function calls related changes to ruleutils_14.c
Relevant PG commit:
40c24bfef92530bd846e111c1742c2a54441c62c
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul b4f76303c6 Updates F_ARRAY_UNNEST to F_UNNEST_ANYARRAY in ruleutils_14.c
Relevant PG commit:
8e1f37c07aafd4bb7aa6e1e1982010af11f8b5c7
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul 30f77b29a7 Fixes some appendStringInfos in ruleutils_14.c
Relevant PG commit:
110d81728a0a006abcf654543fc15346f8043dc0
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul 69aa240b99 Adds for_each_from to ruleutils_14.c
Relevant PG commit:
56fe008996bc1a547ce60c8dddd2ca821cac163e
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul beb49f0d53 Updates AlternativeSubPlan comment in ruleutils_14.c
Relevant PG commit:
41efb8340877e8ffd0023bb6b2ef22ffd1ca014d
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul e642f6c97f Removes support for postfix operators from ruleutils_14.c
Relevant PG commit:
1ed6b895634ce0dc5fd4bd040e87252b32182cba
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul a710b3b949 Removes some comments with printf %.*s format from ruleutils_14.c
Relevant PG commit:

c410af098c46949e36607eb13689e697fa2def97
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul e38b75799d Fixes some indentation in ruleutils_14.c
Relevant PG commit:

fa27dd40d5c5f56a1ee837a75c97549e992e32a4
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul 1d5053b652 Removes support for old protocols in Copy functions from PG14
Some Copy related functions copied from Postgres had support for both old and new protocols
Postgres removed support for old version so we remove it too

Relevant PG commit:
3174d69fb96a66173224e60ec7053b988d5ed4d9
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul 82858ca8fe Introduces ProcessUtility macros for readOnlyTree parameter
New macros: standard_ProcessUtility_compat, ProcessUtility_compat, ColumnarProcessUtility_compat, PrevProcessUtilityHook_compat

The functions now have a new bool parameter: readOnlyTree
These new macros give us the ability to use this new parameter for PG14 and it doesn't give the parameter for previous versions

In multi_ProcessUtility and ColumnarProcessUtility, before doing anything else, we check if readOnlyTree parameter is true and create a copy of pstmt
Existing readOnlyTree parameters are set to false since we already handle the read only case at multi_ProcessUtility and ColumnarProcessUtility

Relevant PG commit:
7c337b6b527b7052e6a751f966d5734c56f668b5
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul 5df6251619 Removes CopyGetAttnums function definition for PG14
This function was copied from Postgres but it is not static at PG14
So we keep the definition only for previous versions

Relevant PG commit:
c532d15dddff14b01fe9ef1d465013cb8ef186df
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul db2d9af863 Introduces BeginCopyFrom_compat macro
BeginCopyFrom function now has a new whereClause parameter.
In the function this parameter is assigned to the whereClause field of the CopyFromState returned
Currently in Postgres there is only one place where this argument isn't NULL, and in previous PG version the whereClause argument of copy state is set right after the function call
Since we don't have such example all current whereClause parameters are set to NULL

Relevant PG commit:
c532d15dddff14b01fe9ef1d465013cb8ef186df
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul 35cfa5d7b9 Introduces CopyFromState_compat macro
CopyState struct is divided into parts and one of them is CopyFromState
This macro uses the appropriate one for PG versions

Relevant PG commit:
c532d15dddff14b01fe9ef1d465013cb8ef186df
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul 8f34f84ce6 Introduces IsReindexWithParam_compat macro
In ReindexStmt concurrent field is moved to options and then options are converted to params list.
This macro uses previous fields for previous versions and the new params list with a new function named IsReindexWithParam for PG14

Relevant PG commits:
844c05abc3f1c1703bf17cf44ab66351ed9711d2
b5913f6120792465f4394b93c15c2e2ac0c08376
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul 37ae22ce3e Introduces macros for vacuum options
VacOptTernaryValue enum is renamed to VacOptValue.
In the enum there were three values, VACOPT_TERNARY_DEFAULT, VACOPT_TERNARY_DISABLED, and VACOPT_TERNARY_ENABLED
Now there are four values VACOPTVALUE_UNSPECIFIED, VACOPTVALUE_AUTO, VACOPTVALUE_DISABLED, and VACOPTVALUE_ENABLED

New macros are VacOptValue_compat, VACOPTVALUE_UNSPECIFIED_COMPAT, VACOPTVALUE_DISABLED_COMPAT, and VACOPTVALUE_ENABLED_COMPAT
The VACOPTVALUE_UNSPECIFIED_COMPAT matches VACOPT_TERNARY_DEFAULT and VACOPTVALUE_UNSPECIFIED. And there are no macro for VACOPTVALUE_AUTO.

Relevant PG commit:
3499df0dee8c4ea51d264a674df5b5e31991319a
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul ebf1b7e23f Introduces macros for functions that now have include_out_arguments argument
New macros: FuncnameGetCandidates_compat and expand_function_arguments_compat

The functions (the ones without _compat) now have a new bool include_out_arguments parameter
These new macros give us the ability to use this new parameter for PG14 and it doesn't give the parameter for previous versions
Existing include_out_arguments parameters are set to 'false' to keep current behavior

Relevant PG commit:
e56bce5d43789cce95d099554ae9593ada92b3b7
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul 347ae2928f Introduces stats_compat macro for MemoryContextMethods->stats
stats function now have a new bool print_to_stderr parameter
This new macro gives us the ability to use this new parameter for PG14 and it doesn't give the parameter for previous versions
Existing print_to_stderr parameter is set to true to keep current behavior

Relevant PG commit:
43620e328617c1f41a2a54c8cee01723064e3ffa
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul 54ee93885a Introduces getObjectTypeDescription_compat and getObjectIdentity_compat macros
getObjectTypeDescription and getObjectIdentity functions now have a new bool missing_ok parameter
These new macros give us the ability to use this new parameter for PG14 and they don't give the parameter for previous versions
Currently all missing_ok parameters are set to false to keep current behavior

Relevant PG commit:
2a10fdc4307a667883f7a3369cb93a721ade9680
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul f8d3e50f25 Introduces STATUS_WAITING_COMPAT macro
The STATUS_WAITING define is removed and an enum with PROC_WAIT_STATUS_WAITING is added instead
This macro uses appropriate one

Relevant PG commit:
a513f1dfbf2c29a51b0f7cbd5913ce2d2ee452c5
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul 3c10e0f568 Introduces ROLE_MONITOR_COMPAT macro
DEFAULT_ROLE_MONITOR is renamed to ROLE_PG_MONITOR
This macro uses appropriate one

Relevant PG commit:
c9c41c7a337d3e2deb0b2a193e9ecfb865d8f52b
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul 4bc0c80bba Adds index_delete_tuples instead of compute_xid_horizon_for_tuples
Relevant PG commit:
d168b666823b6e0bcf60ed19ce24fb5fb91b8ccf
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul b790ecf180 Introduces F_NEXTVAL_COMPAT macro
Name of F_NEXTVAL_OID is changed to F_NEXTVAL

Relevant PG commit:
8e1f37c07aafd4bb7aa6e1e1982010af11f8b5c7
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul f933d2a57a Includes defrem.h in index.c 2021-09-03 15:27:24 +03:00
Halil Ozan Akgul 63cdb4b70a Adds AlterTableStmtObjType macro
AlterTableStmt's relkind field is changed into objtype
New AlterTableStmtObjType macro uses the appropriate one

Relevant PG commit:
cc35d8933a211d9965eb1c1d2749a903d5735db2
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul 1b6c8348fb Adds PG14 to version_compat.h and columnar_version_compat.h files 2021-09-03 15:27:24 +03:00
Halil Ozan Akgul 7a27d7cee3 Adds copy of ruleutils_13.c as ruleutils_14.c 2021-09-03 15:27:24 +03:00
Halil Ozan Akgul 5aace9bb37 Enables Postgres 14 in configure 2021-09-03 15:27:24 +03:00
jeff-davis 4718b6bcdf
Generate parameterized paths for columnar scans. (#5172)
Allow ColumnarScans to push down join quals by generating
parameterized paths. This significantly expands the utility of chunk
group filtering, making a ColumnarScan behave similar to an index when
on the inner of a nested loop join.

Also, evaluate all parameters on beginscan/rescan, which also works
for external parameters.

Fixes #4488.
2021-09-02 22:22:48 -07:00
Onur Tirtir e41854f590
Merge pull request #4818 from citusdata/col/show-projected-cols 2021-09-02 19:14:19 +03:00
Onur Tirtir 37d0ecfbb7 Show projected cols for columnar tables in EXPLAIN output 2021-09-02 19:05:32 +03:00
Onur Tirtir 42ba82fb67 Comment ColumnarAttrNeeded 2021-09-02 13:20:11 +03:00
Onur Tirtir 9cb5ef5007 Pass ColumnarScanDesc to ColumnarScanChunkGroupsFiltered 2021-09-02 13:20:11 +03:00
Naisila Puka 4fb05efabb
Distributes partition-to-be table before ProcessUtility (#5191)
* Skip ALTER TABLE constraint checks while planning

* Revert previous commit's solution, keep tests

* Distribute partition-to-be table before ProcessUtility

* Acquire locks in PreprocessAlterTableStmtAttachPartition
2021-09-02 13:07:42 +03:00
Onur Tirtir 889a2731cb
Split columnar stripe reservation into two phases (#5188)
Previously, we were doing `first_row_number` reservation for the first
row written to current `WriteState` but were doing `stripe_id`
reservation when flushing the `WriteState` and were inserting the
related record to `columnar.stripe` at that time as well.

However, inserting `columnar.stripe` record at flush-time is
problematic. This is because, as told in #5160, if relation has
any index-based constraints and if there are two concurrent
writes that are inserting conflicting key values for that constraint,
then postgres relies on `tableAM->fetch_index_tuple`
(=`columnar_fetch_index_tuple`) callback to return `true` when
indexAM is checking against possible constraint violations.

However, pending writes of other backends are not visible to concurrent
sessions in columnar since we were not inserting the stripe metadata
record until flushing the stripe.

With this commit, we split stripe reservation into two phases:
i) Reserve `stripe_id` and insert a "dummy" record to `columnar.stripe`
at the very same time we reserve `first_row_number`, i.e. when writing
the first row to the current `WriteState`.
ii) At flush time, do the storage level allocation and complete the
missing fields of the dummy record inserted into `columnar.stripe`
during i).

That way, any concurrent writes would be able to check against possible
constraint violations by using `SnapshotDirty` when scanning
`columnar.stripe`.

Note that `columnar_fetch_index_tuple` still wouldn't be able to fill
the output tupleslot for the requested tid but it would at least return
`true` for such index look-up's and we believe this should be sufficient
for the caller indexAM callback to make the concurrent writer block on
prior one.

That is how we fix #5160.

Only downside of reserving `stripe_id` at the same time we reserve
`first_row_number` is that now any aborted writes would also waste
some amount of `stripe_id` as in the case of `first_row_number` but
we are just wasting them one-by-one.

Considering the fact that we waste `first_row_number` by the amount
stripe row limit (=150k by default) in such cases, this shouldn't be
important at all.
2021-09-02 11:49:14 +03:00
Onur Tirtir 0bf29200eb
Merge pull request #5154 from citusdata/col/use-correct-snapshot 2021-09-02 11:20:27 +03:00
Onur Tirtir bf4dfad6f7 Update curcid of given snapshot if it is MVCC
Before starting to scan a columnar table, we always flush the pending
writes to disk.

However, we increment command counter after modifying metadata tables.

On the other hand, now that we _don't always use_ xact snapshot to scan
a columnar table, writes that we just flushed might not be visible to
the query that just flushed pending writes to disk since curcid of
provided snapshot would become smaller than the command id being used
when modifying metadata tables.

To give an example, before this change, below was a possible scenario
due to the changes that we made to use the correct snapshot.

```sql
CREATE TABLE t(a int, b int) USING columnar;
BEGIN;
  INSERT INTO t VALUES (5, 10);

  SELECT * FROM t;
  ┌───┬───┐
  │ a │ b │
  ├───┼───┤
  └───┴───┘
  (0 rows)

  SELECT * FROM t;
  ┌───┬────┐
  │ a │ b  │
  ├───┼────┤
  │ 5 │ 10 │
  └───┴────┘
  (1 row)
```
2021-09-02 11:11:59 +03:00
Onur Tirtir 6c26c67ea0 Flush write state when initializing read state
In next commit, we will adjust curcid of the snapshot being used when
scanning the columnar table.

However, for index scan, snapshot is provided not when beginning scan
but within fetch-tuple call.

For this reason, start flushing pending writes in init_columnar_read_state
since this seem to be a prerequisite step that needs to be done before
scanning a columnar table regardless of the scan method being used.
2021-09-02 11:10:11 +03:00
Onur Tirtir db0e4ce889 Increment command counter in FinishModifyRelation instead
Seems that we always increment the command counter right after
finishing metadata table modification.

For this reason, it makes sense to call CommandCounterIncrement
within FinishModifyRelation.
2021-09-02 11:10:11 +03:00
Onur Tirtir 0b4ed075b5 Use correct snapshot when reading a columnar table
Instead of using xact snapshot, use the snapshot provided
to columnarAM when scanning table.
2021-09-02 11:10:11 +03:00
Naisila Puka bd91df298f
Fixes ConnectionModifiedPlacement output for a failed transaction (#5198) 2021-08-31 18:58:46 +03:00
Naisila Puka 7755d5ed3a
Fixes order of citus_drop_all_shards arguments (#5200) 2021-08-31 18:25:38 +03:00
Naisila Puka acb5ae6ab6
Skip dropping shards when we know it's a partition (#5176) 2021-08-31 17:41:37 +03:00
SaitTalhaNisanci 5ae01303d4
Use get_attnum to find the attribute number of target entry (#5220)
* Use get_attnum to find the attribute number of target entry
2021-08-31 16:47:19 +03:00
Jelte Fennema 481f8be084
Fix crash in shard rebalancer when no distributed tables exist (#5205)
The logging of the amount of ignored moves crashed when no distributed
tables existed in a cluster. This also fixes in passing that the logging
of ignored moves logs the correct number of ignored moves if there
exist multiple colocation groups and all are rebalanced at the same time.
2021-08-31 14:15:24 +02:00
SaitTalhaNisanci d50830d4cc
Update failure tests README (#5197)
* Update failure tests README

I keep finding this page when trying to run failure tests, so updating the README that way:
https://github.com/pypa/pipenv/issues/3363#issuecomment-452171564

Co-authored-by: Hanefi Onaldi <Hanefi.Onaldi@microsoft.com>

Co-authored-by: Hanefi Onaldi <Hanefi.Onaldi@microsoft.com>
2021-08-26 12:35:06 +03:00
Hanefi Onaldi 7e39c7ea83
Replace master with citus in logs and comments (#5210)
I replaced 

- master_add_node,
- master_add_inactive_node
- master_activate_node

with

- citus_add_node,
- citus_add_inactive_node
- citus_activate_node

respectively.
2021-08-26 11:31:17 +03:00