Commit Graph

1323 Commits (a658f5ecdaeac0d65df9d17fdcd4ab72912e898c)

Author SHA1 Message Date
Burak Yücesoy 291aafd11d Merge pull request #662 from citusdata/fix/fix_ALTER_TABLE_SET_SCHEMA
Fix ALTER TABLE SET SCHEMA
2016-07-22 18:07:39 +03:00
Burak Yucesoy bdff72ed75 Fix ALTER TABLE SET SCHEMA
Fixes #132

We hook into ALTER ... SET SCHEMA and warn out if user tries to change schema of a
distributed table.

We also hook into ALTER TABLE ALL IN TABLE SPACE statements and warn out if citus has
been loaded.
2016-07-22 17:52:40 +03:00
Murat Tuncer 0782b8f34e Merge pull request #660 from citusdata/outer_join_fix_for_flattened_queries
Prevent outer join crash when subquery is flatten
2016-07-22 17:16:33 +03:00
Murat Tuncer 5d996a6891 Fix outer join crash when subquery is flatten 2016-07-22 17:01:19 +03:00
Jason Petersen a53a2fe8b0 Merge pull request #653 from citusdata/fix/fix_worker_fetch_regular_table_with_schema
Fix worker_fetch_regular_table with schema

cr: @jasonmp85
2016-07-22 00:56:07 -06:00
Burak Yucesoy b58872b441
Fix worker_fetch_regular_table with schema
Fixes #504
Fixes #646

We changed signature of worker_fetch_regular_table to accept schema name as parameter to
make it work with schemas.
2016-07-22 00:44:02 -06:00
Jason Petersen 69fbdc90c5 Merge pull request #627 from citusdata/feature/mod_in_xact
Permit "single-shard" transactions

cr: @anarazel
2016-07-21 16:37:38 -06:00
Jason Petersen 5d525fba24
Permit "single-shard" transactions
Allows the use of modification commands (INSERT/UPDATE/DELETE) within
transaction blocks (delimited by BEGIN and ROLLBACK/COMMIT), so long as
all modifications hit a subset of nodes involved in the first such com-
mand in the transaction. This does not circumvent the requirement that
each individual modification command must still target a single shard.

For instance, after sending BEGIN, a user might INSERT some rows to a
shard replicated on two nodes. Subsequent modifications can hit other
shards, so long as they are on one or both of these nodes.

SAVEPOINTs are supported, though if the user actually attempts to send
a ROLLBACK command that specifies a SAVEPOINT they will receive an
ERROR at the end of the topmost transaction.

Placements are only marked inactive if at least one replica succeeds
in a transaction where others fail. Non-atomic behavior is possible if
the shard targeted by the initial modification within a transaction has
a higher replication factor than another shard within the same block
and a node with the latter shard has a failure during the COMMIT phase.

Other methods of denoting transaction blocks (multi-statement commands
sent all at once and functions written in e.g. PL/pgSQL or other such
languages) are not presently supported; their treatment remains the
same as before.
2016-07-21 15:57:22 -06:00
Joe Nelson f7a1191b0a Update docs links (#663)
Thanks to @joerg84 for pointing out the broken links

Closes #658
2016-07-21 13:39:40 -07:00
Burak Yücesoy aa15043b09 Merge pull request #655 from citusdata/fix/fix_555_hll_with_schema
Fix COUNT DISTINCT approximation with schema
2016-07-21 18:01:33 +03:00
Burak Yucesoy 20debfc0ee Fix COUNT DISTINCT approximation with schema
Fixes #555

Before this change, we were resolving HLL function and type Oid without qualified name.
Now we find the schema name where HLL objects are stored and generate qualified names for
each objects.

Similar fix is also applied for cstore_table_size function call.
2016-07-21 17:29:18 +03:00
Burak Yücesoy fdd6c57bdf Merge pull request #644 from citusdata/fix/fix_73_master_apply_delete_command_with_schema
Fix master_apply_delete_command with schema
2016-07-21 15:13:39 +03:00
Burak Yucesoy bca672e0a4 Fix master_apply_delete_command with schema
Fixes #73
2016-07-21 15:09:20 +03:00
Burak Yücesoy 85bfad781b Merge pull request #643 from citusdata/add_schema_name_to_worker_apply_shard_ddl_command
Add schema name to worker apply shard ddl command
2016-07-21 14:23:29 +03:00
Burak Yucesoy 2f0158dde1 Change worker_apply_shard_ddl_command to accept schema name as parameter
Fixes #565
Fixes #626

To add schema support to citus, we need to schema-prefix all table names, object names etc.
in the queries sent to worker nodes. However; query deparsing is not available for most of
DDL commands, therefore it is not easy to generate worker query in the master node.

As a solution we are sending schema names along with shard id and query to run to worker
nodes with worker_apply_shard_ddl_command.

To not break \STAGE command we pass public schema as paramater while calling
worker_apply_shard_ddl_command from there. This will not cause problem if user uses \STAGE
in different schema because passes schema name is used only if there is no schema name is
given in the query.
2016-07-21 14:17:26 +03:00
Metin Döşlü bdd57ec9d0 Merge pull request #649 from citusdata/router_executor_prepare_support
Router executor prepare support for non-partition columns
2016-07-21 11:14:26 +03:00
Metin Doslu a811e09dd4 Add support for prepared statements with parameterized non-partition columns in router executor 2016-07-21 11:09:28 +03:00
Marco Slot 082b6b9416 Merge pull request #656 from citusdata/cleanup/commit-handler
Move CompleteShardPlacementTransactions to multi_shard_transaction.c
2016-07-20 12:50:06 +02:00
Marco Slot 2388968b62 Move CompleteShardPlacementTransactions to multi_shard_transaction.c 2016-07-20 12:10:46 +02:00
Burak Yücesoy 7babcaa5e5 Merge pull request #637 from citusdata/always_schema_prefix_worker_queries
Always schema-prefix worker queries
2016-07-20 10:47:06 +03:00
Burak Yucesoy a0e8f9eb64 Always schema-prefix worker queries
Fixes #215
Fixes #267
Fixes #502
Fixes #556
Fixes #557
Fixes #560
Fixes #568
Fixes #623
Fixes #624

With this change we schema-prefix table names, operator names and composite types.
2016-07-20 10:42:24 +03:00
Eren Başak 7d1e8a3e6e Merge pull request #654 from citusdata/fix_unused_istoplevel_variable
Fix Unused Parameter isTopLevel in ExecuteDistributedDDLCommand
2016-07-19 14:27:29 +03:00
Eren Başak 1063fbc80a Fix Unused Parameter isTopLevel in ExecuteDistributedDDLCommand
This change fixes the unused variable problem in
`ExecuteDistributedDDLCommand` function (multi_utility.c). The
parameter is meant to be used in PreventTransactionChain call.
2016-07-19 14:14:02 +03:00
Eren Başak b5e806ff55 Merge pull request #618 from citusdata/ddl_propagation_2pc
Propagate DDL Commands via 2PC
2016-07-19 10:54:57 +03:00
Eren 3eaff48114 Propagate DDL Commands with 2PC
Fixes #513

This change modifies the DDL Propagation logic so that DDL queries
are propagated via 2-Phase Commit protocol. This way, failures during
the execution of distributed DDL commands will not leave the table in
an intermediate state and the pending prepared transactions can be
commited manually.

DDL commands are not allowed inside other transaction blocks or functions.

DDL commands are performed with 2PC regardless of the value of
`citus.multi_shard_commit_protocol` parameter.

The workflow of the successful case is this:
1. Open individual connections to all shard placements and send `BEGIN`
2. Send `SELECT worker_apply_shard_ddl_command(<shardId>, <DDL Command>)`
to all connections, one by one, in a serial manner.
3. Send `PREPARE TRANSCATION <transaction_id>` to all connections.
4. Sedn `COMMIT` to all connections.

Failure cases:
- If a worker problem occurs before sending of all DDL commands is finished, then
all changes are rolled back.
- If a worker problem occurs after all DDL commands are sent but not after
`PREPARE TRANSACTION` commands are finished, then all changes are rolled back.
However, if a worker node is failed, then the prepared transactions in that worker
should be rolled back manually.
- If a worker problem occurs during `COMMIT PREPARED` statements are being sent,
then the prepared transactions on the failed workers should be commited manually.
- If master fails before the first 'PREPARE TRANSACTION' is sent, then nothing is
changed on workers.
- If master fails during `PREPARE TRANSACTION` commands are being sent, then the
prepared transactions on workers should be rolled back manually.
- If master fails during `COMMIT PREPARED` or `ROLLBACK PREPARED` commands are being
sent, then the remaining prepared transactions on the workers should be handled manually.

This change also helps with #480, since failed DDL changes no longer mark
failed placements as inactive.
2016-07-19 10:44:11 +03:00
Murat Tuncer 25cbbf217b Merge pull request #651 from citusdata/501_user_original_query_in_modify_task
Make router planner use original query
2016-07-19 07:45:40 +03:00
Murat Tuncer 4d992c8143 Make router planner use original query 2016-07-18 18:23:04 +03:00
Eren Başak 654a4ac71d Merge pull request #596 from citusdata/limit_offset_support
Add LIMIT/OFFSET Support
2016-07-18 12:38:08 +03:00
Eren 5b54e28f93 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 a69a25781a Merge pull request #488 from citusdata/213-support-stable-functions
Evaluate functions on master
2016-07-13 13:42:45 -07:00
Andres Freund 4cf0a4e48e citus_indent fixups 2016-07-13 11:45:51 -07:00
Brian Cloutier 0cad3b22cc Simplify code and fix include guards in citus_clauses 2016-07-13 11:45:51 -07:00
Brian Cloutier 08384ddc71 cosmetic changes 2016-07-13 11:45:51 -07:00
Brian Cloutier af9515f669 Only reparse queries if the planner flags them for reparsing 2016-07-13 11:45:51 -07:00
Brian Cloutier 4820366a6f citus_indent and some renaming 2016-07-13 11:45:51 -07:00
Brian Cloutier ae91768c96 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 b01d19db3d 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 cab03a6274 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 800cb26ffd 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 41ed433b0e
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 18236b18b5 Merge pull request #578 from citusdata/feature/returning
Support RETURNING
2016-07-01 13:15:36 -07:00
Andres Freund 4549e06884 Add regression tests for RETURNING. 2016-07-01 13:07:12 -07:00
Andres Freund cccba66f24 Support RETURNING for modification commands.
Fixes: #242
2016-07-01 13:07:12 -07:00
Andres Freund c38c1adce1 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 e1282b6d70 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 f78c135e63 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 d5ad8d7db9 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 0b6819f773 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 e5ecf92328 Add null check to SqlStateMatchesCategory()
Fixes #634
2016-07-01 12:28:46 -07:00
Jason Petersen e064cacea9
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