Commit Graph

295 Commits (c92c81b5504a53cee345673ee5213f06cbeed445)

Author SHA1 Message Date
Eren c92c81b550 Add LIMIT/OFFSET Support
Fixes #394

This change adds LIMIT/OFFSET support for non router-plannable
distributed queries.

In cases that we can push the LIMIT down, we add the OFFSET value to
that LIMIT in the worker queries. When a query with LIMIT x OFFSET y is issued,
the query is propagated to the workers as LIMIT (x+y) OFFSET 0, and on the
master table, the original LIMIT and OFFSET values are used. With this change,
we can use OFFSET wherever we can use LIMIT.
2016-07-18 12:00:24 +03:00
Andres Freund 802f19ab82 Merge pull request #488 from citusdata/213-support-stable-functions
Evaluate functions on master
2016-07-13 13:42:45 -07:00
Andres Freund bafafcd1bf citus_indent fixups 2016-07-13 11:45:51 -07:00
Brian Cloutier 728eefcf2b Simplify code and fix include guards in citus_clauses 2016-07-13 11:45:51 -07:00
Brian Cloutier 9a5e529f6f cosmetic changes 2016-07-13 11:45:51 -07:00
Brian Cloutier c46cb19cda Only reparse queries if the planner flags them for reparsing 2016-07-13 11:45:51 -07:00
Brian Cloutier d792c0af4d citus_indent and some renaming 2016-07-13 11:45:51 -07:00
Brian Cloutier e73b4ac026 Evaluate functions on the master
- Enables using VOLATILE functions (like nextval()) in INSERT queries
- Enables using STABLE functions (like now()) targetLists and joinTrees

UPDATE and INSERT can now contain non-immutable functions. INSERT can contain any kind of
expression, while UPDATE can contain any STABLE function, so long as a Var is not passed
into the STABLE function, even indirectly. UPDATE TagetEntry's can now also include Vars.

There's an exception, CASE/COALESCE statements may not contain mutable functions.

Functions calls in master_modify_multiple_shards are also evaluated.
2016-07-13 11:45:51 -07:00
Burak Yücesoy 09296fe6f2 Merge pull request #611 from citusdata/fix/fix_463_copy_on_array_of_user_defined_types
Fix COPY produces error when using array of user-defined types
2016-07-13 11:43:21 +03:00
Burak Yucesoy 7cb92b8bb1 Fix COPY produces error when using array of user-defined types
Fixes #463

OID of user-defined types may be different in master and worker nodes. This causes errors
while sending data between nodes with binary nodes. Because binary copy format adds OID
of the element if it is in an array. The code adding OID is in PostgreSQL code, therefore
we cannot change it. Instead we decided to use text format if we try to send array of
user-defined type.
2016-07-13 11:12:24 +03:00
Jason Petersen f1d8b68b78 Merge pull request #639 from citusdata/feature/no_is_null_pruning
Remove hash-pruning logic for NULL values

cr: @sumedhpathak
2016-07-06 17:08:11 -06:00
Jason Petersen 9157ac9f10 Remove hash-pruning logic for NULL values
It turns out some tests exercised this behavior, but removing it should
have no ill effects. Besides, both copy and INSERT disallow NULLs in a
table's partition column.

Fixes a bug where anti-joins on hash-partitioned distributed tables
would incorrectly prune shards early, result in incorrect results (test
included).
2016-07-06 17:04:21 -06:00
Andres Freund 1b59e36c0c Merge pull request #578 from citusdata/feature/returning
Support RETURNING
2016-07-01 13:15:36 -07:00
Andres Freund c945ea310b Add regression tests for RETURNING. 2016-07-01 13:07:12 -07:00
Andres Freund 586f738bc7 Support RETURNING for modification commands.
Fixes: #242
2016-07-01 13:07:12 -07:00
Andres Freund 610e17d94a Combine router executor paths for select and modify commands.
The upcoming RETURNING support would otherwise require too much
duplication.  This contains most of the pieces required for RETURNING
support, except removing the planner checks and adjusting regression
test output.
2016-07-01 13:07:12 -07:00
Andres Freund c9505a47ab Remember original targetlist in MultiQueryContainerNode().
The old targetlist wasn't used so far, but the upcoming RETURNING
support relies on it.

This also allows to get rid of some crufty code in
multi_executor.c:multi_ExecutorStart(), which used the worker query's
targetlist instead of the main statement's (which didn't have one up to
now).
2016-07-01 12:50:12 -07:00
Andres Freund 63fcd4a505 Fix definition of faux targetlist element inserted to prevent backward scans.
The targetlist contains TargetEntrys containing expressions, not
expressions directly. That didn't matter so far, but with the upcoming
RETURNING support, the targetlist is inspected to build a TupleDesc.
ExecCleanTypeFromTL hits an assert when looking at something that's not
a TargetEntry.

Mark the entry as resjunk, so it's not actually used.
2016-07-01 12:50:12 -07:00
Andres Freund 3201ef8764 Add tests verifying that updates return correct tuple counts.
This unfortunately requires adding a new table, triggering renumbering
of a number of shard ids.
2016-07-01 12:50:12 -07:00
Andres Freund 508597ae04 Merge pull request #636 from citusdata/fix/634_null_check_sqlStateString
Add null check to SqlStateMatchesCategory()
2016-07-01 12:37:06 -07:00
Metin Doslu 85db53c8fe Add null check to SqlStateMatchesCategory()
Fixes #634
2016-07-01 12:28:46 -07:00
Jason Petersen 518adff539 Minor formatting fix
Noticed that uncrustify doesn't like the array-of-struct literals, so
omitting them from formatting (at least here).
2016-06-28 13:09:57 -06:00
Jason Petersen f132dbad1a Use literal instead of constant to fix 9.4 build
PG_UINT32_MAX doesn't exist before 9.5. Missed this because I removed
my assert-enabled builds during packaging work.

Fixes #619
2016-06-28 12:36:14 -06:00
Andres Freund adef93830d Merge pull request #574 from citusdata/fix/fix_439_missing_flex
Detect flex in citus configure script, instead of relying postgres'.
2016-06-22 11:10:01 -07:00
Andres Freund 891dd366d2 Provide our own psqlscan.l->psqlscan.l rule.
As postgres's generic .l -> .c Makefile rule uses ifdef - which is
evaluated early, not during rule evaluation - we have to override the
rule, in addition to the detection of FLEX in the previous commit.

Fixes: #439
2016-06-22 11:03:23 -07:00
Andres Freund 05a679b537 Detect flex in citus configure script, instead of relying postgres'.
If postgres was compiled without flex support - possible when building
from a tarball, because those contain the flex generated files - citus
compilation would fail, because FLEX is defined as missing.

Add detection for flex, overwriting postgres' detection if one was
found.

Fixes: #439
2016-06-22 11:03:22 -07:00
Jason Petersen ff4b677d41 Merge pull request #615 from citusdata/feature/purge_connections
Purge connection if re-raising error

cr: @anarazel
2016-06-21 10:01:33 -06:00
Jason Petersen 56f145e7fa Purge connection if re-raising error
The only way we re-raise an error is if the raiseError flag is true, so
might as well purge connection in that block rather than independently
checking errorLevel.
2016-06-21 09:51:12 -06:00
Murat Tuncer 2d10d4975d Merge pull request #610 from citusdata/501_single_worker_queries
Refactor multi_planner to create router plan directly
2016-06-21 12:54:30 +03:00
Murat Tuncer e86b4b397c Refactor multi_planner to create router plan directly
If router plan creation fails, it falls back to normal planner
2016-06-21 12:50:21 +03:00
Jason Petersen d742ceb6d8 Add CHANGELOG entries for 5.1.1 release
cr: @sumedhpathak
2016-06-17 16:03:32 -06:00
Burak Yücesoy 7061b7cdcc Merge pull request #602 from citusdata/fix/fix_78_append_table_to_shard_with_schema
Fix master_append_table_to_shard to work with schemas
2016-06-17 04:46:20 +03:00
Burak Yucesoy 2da5ae240e Fix master_append_table_to_shard to work with schemas
Fixes #78

With this change, it is possible to append a table in any schema to shard. The function
master_append_table_to_shard now supports schema names.
2016-06-17 04:35:00 +03:00
Andres Freund 260a1045e5 Merge pull request #608 from citusdata/fix_pruning_performance
Fix join pruning performance
2016-06-16 17:43:43 -07:00
Andres Freund acb36b4505 Store ShardInterval instead of shardId in RangeTableFragments.
For CITUS_RTE_RELATION type fragments, reloading shardIntervals from the
database is rather expensive. So store a pointer to the full shard
interval, instead of just the shard id.  There's no new memory lifetime
hazards here, because we already passed a pointer to the shardInterval's
->shardId field around.

The plan time for the query in issue #607 goes from 2889 ms to 106 ms.
with this change.
2016-06-16 17:31:35 -07:00
Andres Freund 1e07a94435 Use cached comparator in ShardIntervalsOverlap().
By far the most expensive part of ShardIntervalsOverlap() is computing
the function to use to determine overlap. Luckily we already have that
computed and cached.

The plan time for the query in issue #607 goes from 8764 ms to 2889 ms
with this change.
2016-06-16 17:21:19 -07:00
Andres Freund 51aca7a80c Merge pull request #603 from citusdata/fix/outer-join-filter
Do not copy outer join clauses into WHERE
2016-06-16 17:16:49 -07:00
Andres Freund 1c24d703d7 Add tests for LEFT JOIN ON clauses preventing matches left/right. 2016-06-16 16:53:02 -07:00
Marco Slot f15ec5554c Do not copy outer join clauses into WHERE 2016-06-16 16:42:32 -07:00
Andres Freund 0055b7c25e Merge pull request #604 from citusdata/fix_alter_extension
Fix Alter Extension
2016-06-16 14:35:30 -07:00
Metin Doslu 7ede3db4f5 Drop function from public and create in pg_catalog
Fixes #600
2016-06-16 14:08:40 -07:00
Hanna Wischmann 92ea74e8f9 Fix the documentation link from Citus 5.0 to Citus 5.1 (#593) 2016-06-16 10:45:36 -07:00
Murat Tuncer 052d0998b9 Merge pull request #585 from citusdata/faster_regression_tests
Faster regression tests
2016-06-15 16:48:51 +03:00
Murat Tuncer aeb6443898 Reduce regression test runtime
-Added 2 more schedules for task-tracker and multi-binary
 instead of running multi_schedule 3 times
-set task-tracker-delay for each long running schedule
2016-06-15 16:35:07 +03:00
Metin Döşlü f1fcebd267 Merge pull request #588 from citusdata/fix/fix_550_append_shardId_before_escaping_table_names
Append shardId before escaping the table name
2016-06-15 14:48:11 +03:00
Burak Yucesoy bdf9ca2466 Append shardId before escaping the table name
Fixes #550, fixes #545

If table name contains special characters, it needs to be escaped. However in some cases,
we escape table name before appending shardId, which causes syntax error in the queries
sent to worker nodes. With this change we now append shardId before escaping table names.
2016-06-15 04:15:40 +03:00
Murat Tuncer 032ba73f65 Merge pull request #586 from citusdata/fix_275_remove_variant_files_from_tests
Remove variant files from regression tests
2016-06-13 12:26:51 +03:00
Murat Tuncer 5fddb9c34e Remove variant files
This checkin removes variant files we needed
due to differences in outputs of pg94 and pg95 runs.
However, variant file for test multi_upsert stays
since this file tests for a feature that does not
exist in pg94, and outputs are drastically different.
2016-06-13 12:12:06 +03:00
Ahmet Eren Basak a7b203849c Merge pull request #591 from citusdata/fix_compile_time_warning_in_multi_logical_optimizer
Eliminate compile time warnings in multi_logical_optimizer.c
2016-06-10 12:33:18 +03:00
Eren ae5687e726 Eliminate compile time warnings in multi_logical_optimizer.c
This change removes some issues about mixed declarations
and code in TablePartitioningSupportsDistinct() and
WorkerExtendedOpNode() functions.
2016-06-10 12:27:12 +03:00