Commit Graph

4165 Commits (7c891a01a96ab2f7dd33e96fa3933a807cf5a96c)

Author SHA1 Message Date
Philip Dubé f344c1a4bc
Merge pull request #3654 from citusdata/2776_modifying_ctes
Modifying ctes in router planner
2020-06-11 15:26:00 +00:00
Philip Dubé 1722d8ac8b Allow routing modifying CTEs
We still recursively plan some cases, eg:
- INSERTs
- SELECT FOR UPDATE when reference tables in query
- Everything must be same single shard & replication model
2020-06-11 15:14:06 +00:00
Hadi Moshayedi e37c385d6c
Merge pull request #3899 from citusdata/explain_analyze_sort_by_time
Include execution duration in worker_last_saved_explain_analyze
2020-06-11 04:05:41 -07:00
Hadi Moshayedi 0e3140c14d Include execution duration in worker_last_saved_explain_analyze 2020-06-11 02:54:54 -07:00
Hadi Moshayedi 93b79880fe
Merge pull request #3864 from citusdata/explain_analyze_cte
CTE statistics in EXPLAIN ANALYZE
2020-06-11 02:49:06 -07:00
Hadi Moshayedi 7c52c6edb0 CTE statistics in EXPLAIN ANALYZE 2020-06-11 02:39:59 -07:00
Hadi Moshayedi fe8a9c721c
Merge pull request #3891 from citusdata/explain_analyze_worker_query
Show query text in EXPLAIN output
2020-06-11 02:38:07 -07:00
Hadi Moshayedi 1f6d6ee4a5 Show query text in EXPLAIN output 2020-06-11 02:19:55 -07:00
Hadi Moshayedi 9a49f10c49
Merge pull request #3890 from citusdata/explain_analyze_exec_once
Do EXPLAIN ANALYZE at the same time as execution to avoid executing twice.
2020-06-11 02:17:38 -07:00
Hadi Moshayedi bb96ef5047 Does the EXPLAIN ANALYZE at the same time as execution, so avoids executing twice.
We wrap worker tasks in worker_save_query_explain_analyze() so we can fetch
their explain output later by a call worker_last_saved_explain_analyze().

Fixes #3519
Fixes #2347
Fixes #2613
Fixes #621
2020-06-11 01:55:57 -07:00
Hadi Moshayedi 8551affc1e
Merge pull request #3892 from citusdata/explain_execute
Test we don't support multi-shard EXPLAIN EXECUTE
2020-06-10 17:19:10 -07:00
Hadi Moshayedi 6ca621bd16 Test we don't support multi-shard EXPLAIN EXECUTE 2020-06-10 17:11:27 -07:00
Jelte Fennema 6f2eb4cdb6
Remove FlattenJoinVars (#3880)
This code is not needed anymore since #3668 was merged.
It's actually causing some issues when using the binary Postgres 
protocol, because postgres thinks it gets a `bigint` from
the worker, but actually gets an normal `int`. 
The query in question that fails is this:
```sql
CREATE TABLE test_table_1(id int, val1 int);
CREATE TABLE test_table_2(id int, val1 bigint);
SELECT create_distributed_table('test_table_1', 'id');
SELECT create_distributed_table('test_table_2', 'id');
INSERT INTO test_table_1 VALUES(1,1),(2,2),(3,3);
INSERT INTO test_table_2 VALUES(1,1),(3,3),(4,5);

SELECT val1
FROM test_table_1 LEFT JOIN test_table_2 USING(id, val1)
ORDER BY 1;
```

The difference in queries that is sent to the workers after this change is this, for this query:
```diff
--- query_old.sql	2020-06-09 09:51:21.460000000 +0200
+++ query_new.sql	2020-06-09 09:51:39.500000000 +0200
@@ -1 +1 @@
-SELECT worker_column_1 AS val1 FROM (SELECT test_table_1.val1 AS worker_column_1 FROM (public.test_table_1_102015 test_table_1(id, val1) LEFT JOIN public.test_table_2_102019 test_table_2(id, val1) USING (id, val1))) worker_subquery
+SELECT worker_column_1 AS val1 FROM (SELECT val1 AS worker_column_1 FROM (public.test_table_1_102015 test_table_1(id, val1) LEFT JOIN public.test_table_2_102019 test_table_2(id, val1) USING (id, val1))) worker_subquery
```
2020-06-10 17:24:53 +02:00
Jelte Fennema f4791fcb10
Remove SwallowErrors by using PathNameDeleteTemporaryDir (#3893)
This is a different version of #3634. It also removes SwallowErrors, but
instead of modifying our own functions to not throw errors, it uses the
postgres built in `PathNameDeleteTemporaryDir` function. This function
does not throw errors.

Since this change is for a bugfix, I tried to minimize the changes.

PRs with the following changes would be good to do separately from this
PR:
1. Use PathName(Create|Open|Delete)Temporary(File|Dir) to open and
   remove all files/dirs instead of our own custom file functions.
2. Prefix our outmost files/directories with `PG_TEMP_FILE_PREFIX` so
   that they are identified by Postgres as temporary files, which will be
   removed at postmaster start. This way we do not have to do this cleanup
   ourselves.
3. Store the files in the temporary table space if it exists.

Fixes #3634
Fixes #3618
2020-06-10 17:04:07 +02:00
Hanefi Onaldi 6e9324e99d
Merge pull request #3841 from citusdata/copy_max_adaptive_executor_pool_size 2020-06-10 17:25:12 +03:00
Onder Kalaci 640717bea2
Copy doesn't use more than MaxAdaptiveExecutor
Co-authored-by: Hanefi Önaldı <Hanefi.Onaldi@Microsoft.com>
2020-06-10 16:46:21 +03:00
Jelte Fennema b87bae71bb
Error out when using different users in the same transaction (#3869)
Fixes #3867

As described in the issue above we return incorrect results when
changing user within a transaction. This causes us to error out instead.
2020-06-10 14:07:40 +02:00
Marco Slot 02a70df656
Merge pull request #3889 from citusdata/fix/stage_generates_utility_commands
Execute shard creation as utility tasks
2020-06-10 11:51:24 +02:00
Marco Slot 1243b6a948 Execute shard creation as utility tasks 2020-06-10 11:29:49 +02:00
Önder Kalacı 34554a2957
Merge pull request #3886 from citusdata/fix_coercion
Coerce types properly for distribution keys when necessary
2020-06-10 10:50:47 +02:00
Onder Kalaci 06461ca55f Coerce types properly for INSERT
Also, unify similar code-paths to rely on more accurate function.
2020-06-10 10:40:28 +02:00
Hadi Moshayedi 08d2b9b40b
Merge pull request #3881 from citusdata/explain_analyze_udfs
Implement EXPLAIN ANALYZE udfs.
2020-06-09 10:12:21 -07:00
Hadi Moshayedi 5cdfa9f571 Implement EXPLAIN ANALYZE udfs.
Implements worker_save_query_explain_analyze and worker_last_saved_explain_analyze.

worker_save_query_explain_analyze executes and returns results of query while
saving its EXPLAIN ANALYZE to be fetched later.

worker_last_saved_explain_analyze returns the saved EXPLAIN ANALYZE result.
2020-06-09 10:02:05 -07:00
Onur Tirtir a4f1c41391
Implement GetQueryLockMode helper (#3860)
If we want to get necessary lockmode for a relation RangeVar within
a query, we can get the lockmode easily from the RangeVar itself (if
pg version >= 12).

However, if we want to decide the lockmode appropriate for the
"query", we can derive this information by using GetQueryLockMode
according to the code comment from RangeTblEntry->rellockmode.
2020-06-09 13:08:44 +03:00
Hadi Moshayedi 5781aaf6c7
Merge pull request #3883 from citusdata/circ_deps
typedef TupleDestination only once
2020-06-09 01:36:41 -07:00
Hadi Moshayedi 198d5d8b0f typedef TupleDestination once 2020-06-08 20:38:28 -07:00
Hadi Moshayedi 6869d7bfb2
Merge pull request #3878 from citusdata/explain_analyze_initial_cleanup
Explain Analyze tests & cleanup
2020-06-07 00:06:11 -07:00
Hadi Moshayedi 45a41e249f Test EXPLAIN ANALYZE doesn't show repartition join tasks 2020-06-06 23:24:45 -07:00
Hadi Moshayedi 02cff1a7c6 Test that EXPLAIN ANALYZE is not supported for some forms of INSERT/SELECT 2020-06-06 23:24:45 -07:00
Hadi Moshayedi f54a8e53c0 Remove unused consts from multi_explain.c 2020-06-06 23:24:45 -07:00
Hadi Moshayedi 797405f3d1
Merge pull request #3871 from citusdata/tupledest
Implement TupleDestination to allow custom processing of task results.
2020-06-06 10:50:02 -07:00
Hadi Moshayedi 0bfd39ea52 Implement TupleDestination intereface.
Implements a new `TupleDestination` interface to allow custom tuple processing per task.

This can be specially useful if a task contains multiple queries. An example of this EXPLAIN
ANALYZE, where it needs to add some UDF calls to the query to fetch the explain output
from worker after fetching the actual query results.
2020-06-05 17:47:40 -07:00
SaitTalhaNisanci d0f47eb338
Check the removeType in IsDropCitusStmt (#3859)
We should check the remove type in IsDropCitusStmt because if the remove
type is not OBJECT_EXTENSION then the stored objects in
dropStmt->objects may not be of type Value. This was crashing PG-13.

Also rename the method as IsDropCitusExtensionStmt.
2020-06-05 20:49:54 +03:00
Onur Tirtir f7224a12f2
Implement PushOverrideEmptySearchPath (#3874)
To reduce code duplication, implement function that pushes search_path
to be NIL and sets addCatalog to true so that all objects outside of
pg_catalog will be schema-prefixed.
2020-06-05 19:23:59 +03:00
Onur Tirtir 8b39d12846
Append IF NOT EXISTS to deparsed CREATE SERVER commands (#3875)
Append IF NOT EXISTS to CREATE SERVER commands generated by
pg_get_serverdef_string function when deparsing an existing server
object that a foreign table depends.
2020-06-05 18:04:33 +03:00
Onur Tirtir 741e808049
Merge pull request #3873 from citusdata/refactor/implement-explicit-index
Implement IndexIsImpliedByAConstraint
2020-06-05 16:05:08 +03:00
Onur Tirtir f3f711e097 Implement IndexIsImpliedByAConstraint 2020-06-05 15:33:54 +03:00
Philip Dubé 4f63443b49
Merge pull request #3861 from citusdata/remove-null-plannerrestrictioncontext-check
multi_router_planner: Remove NULL check which would've segfaulted earlier
2020-06-02 13:18:30 +00:00
Philip Dubé 25f86bca3f multi_router_planner: Remove NULL check which would've segfaulted earlier 2020-06-02 13:08:38 +00:00
Philip Dubé 1b0776f98e
Merge pull request #3863 from citusdata/remove-getupdateordeleterte
multi_router_planner: replace GetUpdateOrDeleteRTE with ExtractResultRelationRTE
2020-06-02 12:58:42 +00:00
Philip Dubé 2623aefe38 multi_router_planner: replace GetUpdateOrDeleteRTE with ExtractResultRelationRTE 2020-06-02 00:22:30 +00:00
Onur Tirtir 738a4ddb58
Merge pull request #3858 from citusdata/copy_paste_pg_get_triggerdef
* Error out if creating a citus table from a table having triggers already.
* Error out for CREATE TRIGGER commands that are run on citus tables.
* Introduce the ability to deparse CREATE TRIGGER commands needed to recreate triggers on a table.
2020-06-01 10:35:45 +03:00
Onur Tirtir dfcc18468c Error out for unsupported trigger objects
Error out if creating a citus table from a table having triggers.
Error out for CREATE TRIGGER commands that are run on citus tables.
2020-05-31 23:10:01 +03:00
Onur Tirtir 6e6bc155a9 Implement methods to process & recreate triggers on citus tables 2020-05-31 15:28:17 +03:00
Onur Tirtir 5af64084ea Copy & paste pg_get_triggerdef_worker from Postgres 2020-05-31 15:25:07 +03:00
Philip Dubé dca09e998f
Merge pull request #3857 from citusdata/use_RelationGetPartitionDesc
use RelationGetPartitionDesc to be more safe
2020-05-29 15:12:57 +00:00
Sait Talha Nisanci dec2b28d49 use RelationGetPartitionDesc to be more safe
For getting the partition desc, we should use RelationGetPartitionDesc
method so that even if it is NULL, it will be created in the method.
2020-05-29 10:55:52 +03:00
Philip Dubé a3c470b2b8
Merge pull request #3834 from citusdata/prep-routing-modifying-ctes
Prep routing modifying ctes
2020-05-20 17:35:36 +00:00
Philip Dubé c0515dcd67 This prepares for routing modifying CTEs, where modLevel should not be used to infer whether a plan is a select or not
SELECT_TASK is renamed to READ_TASK as a SELECT with modifying CTEs will be a MODIFYING_TASK

RouterInsertJob: Assert originalQuery->commandType == CMD_INSERT
CreateModifyPlan: Assert originalQuery->commandType != CMD_SELECT

Remove unused function IsModifyDistributedPlan

DistributedExecution, ExecutionParams, DistributedPlan: Rename hasReturning to expectResults
SELECTs set expectResults to true

Rename CreateSingleTaskRouterPlan to CreateSingleTaskRouterSelectPlan
2020-05-20 17:26:12 +00:00
Onur Tirtir 780c72bdc8
Merge pull request #3846 from citusdata/implement-table-constraints-internal
Refactor the methods accessing to pg_constraint
2020-05-20 17:45:59 +03:00