Commit Graph

6866 Commits (1e5decad7514c2c23d5a13a7984c2075bb6e5c71)

Author SHA1 Message Date
eren 7e19ebe679 FIX "mixed declarations and code" Warning in multi_physical_planner.c
Fixes #477

This change fixes the compile time warning message in BuildMapMergeJob in
multi_physical_planner.c about mixed declarations and code. Basically, the
problematic declaration is moved up so that no expression is before it.
2016-04-29 11:18:04 +03:00
Brian Cloutier 0036eb3253 Allow references to columns in UPDATE statements (#472)
Allow references to columns in UPDATE statements

Queries like "UPDATE tbl SET column = column + 1" are now allowed, so long as you don't use any IMMUTABLE functions.
2016-04-28 05:45:16 -07:00
Ahmet Eren Basak 66eab4e629 Merge pull request #471 from citusdata/rename_copy_transaction_manager
Rename citus.copy_transaction_manager to citus.multi_shard_commit_protocol
2016-04-28 15:28:20 +03:00
eren ab240a7d4c Rename copy_transaction_manager
This change renames the distributed transaction manager parameter from
citus.copy_transaction_manager to citus.multi_shard_commit_protocol.

Distributed transaction manager has been used only by the COPY on hash
partitioned tables but it can be used by upcoming features so, we needed
to rename so that its name do not contain a reference to COPY.

The change also includes renames like transaction_manager_options to
commit_protocol_options and TRANSACTION_MANAGER_1PC to COMMIT_PROTOCOL_1PC.

With this change, declaration of MultiShardCommitProtocol (was
CopyTransactionManager) is moved from multi_copy.c to multi_transaction.c.
2016-04-28 15:12:50 +03:00
Andres Freund 0ce1e3ddaf Perform permission checks on operations re-implemented by citus.
Currently that's just COPY FROM.  There's other places where we could
check for permissions earlier (to fail less verbosely), but since
there's other pending changes in the whole DDL area, which is affected
by this, I'm just adding a note to those places.
2016-04-27 10:28:36 -07:00
Andres Freund 758a70a8ff Create new shards as owned the distributed table's owner.
That's important because ownership of relations implies special
privileges. Without this change, a distributed table can be accessible
by a table's owner, but a shard created by another user might not.
2016-04-27 10:28:33 -07:00
Andres Freund 3a264db2fe Add ReplicateGrantStmt().
This is the basis for coordinating GRANT/REVOKE across nodes.
2016-04-27 10:28:25 -07:00
Andres Freund 7c281fbe07 Add pg_get_table_grants() function and support extending GRANTs. 2016-04-27 10:28:25 -07:00
Andres Freund eae65404d0 Grant SELECT for pg_catalog.pg_dist* to PUBLIC.
Given pg_class et al. are readable by everyone there's little point in
restricting read only access to citus catalogs.
2016-04-27 10:28:25 -07:00
Andres Freund a5b3dcddb3 Run some commands as superuser to allow normal users to execute queries.
Some small parts of citus currently require superuser privileges; which
is obviously not desirable for production scenarios. Run these small
parts under superuser privileges (we use the extension owner) to avoid
that.

This does not yet coordinate grants between master and workers. Thus it
allows to create shards, load data, and run queries as a non-superuser,
but it is not easily possible to allow differentiated accesses to
several users.
2016-04-27 10:28:22 -07:00
Andres Freund 25615ee9d7 Add CitusExtensionOwner(), to execute some priviledged operations under.
There exist some operations we have to execute with elevated
privileges. The most expedient user for that is the user owning the
citusdb extension.
2016-04-27 10:26:08 -07:00
Andres Freund bf87e08331 Replace direct inserts in csql's \stage by serverside functions.
\stage so far directly inserted into pg_dist_shard and
pg_dist_shard_placement. That makes it hard to do effective permission
checks.  Thus move the inserts into two C functions.

These two new functions aren't the nicest abstraction. But as we are
planning to obsolete \stage, it doesn't seem worthwhile to refactor the
client-side code of \stage to allow the use of
master_create_empty_shard() et al.
2016-04-27 10:23:35 -07:00
Andres Freund 12a246de37 Perform permission checks in functions manipulating distributed tables.
Previously several commands, amongst them commands like
master_create_distributed_table(), were allowed for everyone. That's not
good: Even though citus currently requires superuser permissions, we
shouldn't allow non-superusers to perform actions as sensitive as making
a table distributed.

There's no checks on the worker_* functions, as these usually just punt
the action to underlying postgres functionality, which then perform the
necessary checks.
2016-04-27 10:22:20 -07:00
Andres Freund 25f919576f Add very basic infrastructure for schema upgrade scripts.
Citus' extension version now has a -$schemaversion appendix.  When the
schema is changed, a new schema version has to be added; changes to the
same schema version several commits inside a single pull request are ok.

Schema migration scripts between each schema version have to be
added. To ensure upgrade scripts work correctly a new regression test
ensures that all steps work.

The extension scripts to-be-used for CREATE EXTENSION (i.e. not
extension updates) are generated by concatenating citus.sql and the
relevant migration scripts.
2016-04-27 10:00:08 -07:00
Andres Freund 5ffce3393a Always create database for regression tests with a fixed username.
Otherwise the owner of relations and such will depend on the username of
the user running the regression tests. As "postgres" is the most common
username for that purpose, hardcode that in pg_regress_multi.pl.
2016-04-27 10:00:08 -07:00
Andres Freund 42d232c0e8 Use the current session's username when connecting to worker nodes.
So far we've always used libpq defaults when connecting to workers; bar
special environment variables being set that'll always be the user that
started the server.  That's not desirable because it prevents using
users with fewer privileges.

Thus change the various APIs creating connections to workers to always
use usernames. That means:
1) MultiClientConnect() needs to, optionally, accept a username
2) GetOrEstablishConnection(), including the underlying cache, need to
   use the current user as part of the connection cache key. That way
   connections for separate users are distinct, and we always use one
   with the correct authorization.
3) The task tracker needs to keep track of the username associated with
   a task, so it can use it when establishing connections outside the
   originating session.
2016-04-27 10:00:08 -07:00
Önder Kalacı abb4ec019f Merge pull request #446 from citusdata/fast_shard_pruning
Add fast shard pruning path for INSERTs on hash partitioned tables
2016-04-27 11:33:20 +03:00
Onder Kalaci 108114ab99 Apply final code review feedback
- Fix o(n^2) loop to o(n)
- Collapse two if statements into a single one
- Some coding conventions feedback
2016-04-27 10:36:03 +03:00
Onder Kalaci c4b783b70b Fix Merge Conflict
This commit fixes merge conflicts.
2016-04-26 11:18:47 +03:00
Onder Kalaci 6c7abc2ba5 Add fast shard pruning path for INSERTs on hash partitioned tables
This commit adds a fast shard pruning path for INSERTs on
hash-partitioned tables. The rationale behind this change is
that if there exists a sorted shard interval array, a single
index lookup on the array allows us to find the corresponding
shard interval. As mentioned above, we need a sorted
(wrt shardminvalue) shard interval array. Thus, this commit
updates shardIntervalArray to sortedShardIntervalArray in the
metadata cache. Then uses the low-level API that is defined in
multi_copy to handle the fast shard pruning.

The performance impact of this change is more apparent as more
shards exist for a distributed table. Previous implementation
was relying on linear search through the shard intervals. However,
this commit relies on constant lookup time on shard interval
array. Thus, the shard pruning becomes less dependent on the
shard count.
2016-04-26 11:16:00 +03:00
Joe Nelson 996e56f623 Emphasize our slack room (#464)
* Replace IRC link with Slack signup

Also replace google groups badge with slack badge
2016-04-22 14:54:13 -07:00
Brian Cloutier 1a8939e30d Merge pull request #456 from citusdata/367-drop-extension-messages
DROP EXTENSION without any warnings
2016-04-22 13:39:08 -07:00
Brian Cloutier 7a6d689259 Clear metadata_cache upon DROP EXTENSION
When we notice that pg_dist_partition is being invalidated we assume
that the citus extension is being dropped and drop state such as
extensionLoaded and the cached oids of all the metadata tables.

This frees the user from needing to reconnect after running DROP
EXTENSION, so we also no longer send a warning message.
2016-04-22 07:25:49 -07:00
Önder Kalacı 8232813066 Merge pull request #427 from citusdata/feature/dynamic_executor
Add router planner and dynamic executor selection
2016-04-21 15:33:34 +03:00
Murat Tuncer a88d3ecd4e Add dynamic executor selection
- non-router plannable queries can be executed
  by router executor if they satisfy the criteria
- router executor is removed from configuration,
  now task executor can not be set to router
- removed some tests that error out for router executor
2016-04-21 09:15:33 +03:00
Murat Tuncer 938546b938 Add router plannable check and router planning logic
for single shard select queries
2016-04-21 09:15:33 +03:00
Brian Cloutier 73bc20688c Merge pull request #399 from citusdata/count_distinct_pushdown
Add support for count(distinct) on hash partitioned tables
2016-04-20 05:13:48 -07:00
Brian Cloutier 7b1dc0d511 Support count(distinct) on hash partitioned tables
Also add test to ensure we get the same results when running
count(distinct) on range and hash partitioned tables.
2016-04-20 04:54:07 -07:00
Önder Kalacı 49b0c61f8d Merge pull request #459 from citusdata/fix_warning_in_logical_optimizer
FIX Complie Time Warning in multi_logical_optimizer.c
2016-04-20 12:59:34 +03:00
eren 53186b4e67 FIX Warning Message in multi_logical_optimizer.c
With #426, some new warning messages started to arise, because of
cross assignment of Node and Expr pointers. This change fixes the
warnings with type casts.
2016-04-20 11:33:29 +03:00
Jason Petersen 0ac9bf2bcb Merge pull request #426 from citusdata/bugfix/#375-prune-with-subquery-pushdown-varchar
Fix Shard Pruning Problem With Subqueries on VARCHAR Partition Columns

cr: @jasonmp85
2016-04-19 22:06:30 -06:00
eren 448527c3af
Fix JOINs on varchar columns with subquery pushdown
Fixes #379

Varchar VAR struct is wrapped in RELABELTYPE struct inside PostgreSQL code and
IsPartitionColumnRecursive function considers only VAR types so returning false
for varchar.

This change adds strip_implicit_coercions() call to the columnExpression in
IsPartitionColumnRecursive function so that we get rid of implicit coercions like
RELABELTYPE are stripped to VAR.
2016-04-19 21:55:50 -06:00
eren 399b5738b0
Fix Join Problem With VARCHAR Partition Columns
This change fixes the problem with joins with VARCHAR columns. Prior to
this change, when we tried to do large table joins on varchar columns, we got
an error of the form:
ERROR: cannot perform local joins that involve expressions
DETAIL: local joins can be performed between columns only.

This is because we have a check in CheckJoinBetweenColumns() which requires the
join clause to have only 'Var' nodes (i.e. columns). Postgres adds a relabel t
ype cast to cast the varchar to text; hence the type of the node is not T_Var
and the join fails.

The fix involves calling strip_implicit_coercions() to the left and right
arguments so that RELABELTYPE is stripped to VAR.

Fixes #76.
2016-04-19 21:55:50 -06:00
eren 1ffc30d7f5
Fix Shard Pruning Problem With Subqueries on VARCHAR Partition Columns
Fixes #375

Prior to this change, shard pruning couldn't be done if:
- Table is hash-distributed
- Partition column of is VARCHAR
- Query to be pruned is a subquery

There were two problems:
- A bug in left-side/right-side checks for the partition column
- We were not considering relabeled types (VARCHAR was relabeled as TEXT)
2016-04-19 21:55:50 -06:00
Metin Döşlü 339e1364d5 Merge pull request #445 from citusdata/feature/master-copy-for-append-partitioning
Add COPY support on master node for append partitioned relations

CR: @marcocitus
2016-04-19 22:08:02 +03:00
Metin Doslu 132a77f992 Add COPY support on master node for append partitioned relations 2016-04-19 21:57:59 +03:00
Jason Petersen 991f73c4f4 Merge pull request #450 from citusdata/unused-variables
Fix various unused variable warnings

cr: @jasonmp85
2016-04-19 12:44:38 -06:00
Andres Freund 39233c54ac
Remove wholly unused variable.
This avoids a -Wunused warning.
2016-04-19 12:31:13 -06:00
Andres Freund 29b8576a33
Annotate variables only used for asserts with PG_USED_FOR_ASSERTS_ONLY.
This avoids '-Wunused-but-set-variable' type warnings when compiling
without assertions, e.g. against a system postgres.
2016-04-19 12:31:12 -06:00
Jason Petersen cb7a397b0c Merge pull request #441 from citusdata/add_hash_op_comment
Add clarifying comment in HashableClauseMutator

cr: @marcocitus
2016-04-19 12:29:45 -06:00
Jason Petersen 30fdb59a80
Add clarifying comment in HashableClauseMutator
While reading this code last week, it appeared as though there was no
place we ensured that the partition clause actually used equality ops.
As such, I was worried that we might transform a clause such as id < 5
into a constraint like hash(id) = hash(5) when doing shard pruning. The
relevant code seemed to just ensure:

  1. The node is an OpExpr
  2. With a related hash function
  3. It compares the partition column
  4. Against a constant

A superficial reading implied we didn't actually make sure the original
op was equality-related, but it turns out the hash lookup function DOES
ensure that for us. So I added a comment.
2016-04-19 12:21:11 -06:00
Murat Tuncer 0b35c47932 Merge pull request #410 from citusdata/350-error-during-duplicate-index-creation
Error out earlier when creating an index with a name collision.
2016-04-19 07:26:31 +03:00
Brian Cloutier 1df4b8ba32 Better error on "CREATE INDEX already_exists ..."
Previously (if you're creating the index with the same name on different
tables) we successfully ran the command on the workers before failing it
on the master and leaving no record of the index.

Now we check whether the index exists on the master before sending
commands to the workers.

--

Also make the error better when user attampts to create an index without
a name. Previously those statements returned:

brian=# create index on c (b);
WARNING:  could not receive query results from localhost:9700
DETAIL:  Client error: cannot extend name for null index name
ERROR:  could not execute DDL command on worker node shards

They now return

brian=# create index on c (b);
ERROR:  creating index without a name on a distributed table is
currently unsupported
2016-04-18 13:33:53 -07:00
Jason Petersen 86bc73ef8a Merge pull request #423 from citusdata/422-incorrect-node-port-type
Treat nodePort as the 64bit integer it is.

cr: @anarazel
2016-04-15 12:42:11 -06:00
Jason Petersen c0b6505720 Merge branch 'master' into 422-incorrect-node-port-type 2016-04-15 12:30:50 -06:00
Jason Petersen 1a370cd1ba Merge pull request #451 from citusdata/fix_int64const_use
Fix use of INT64CONST macro

cr: @anarazel
2016-04-15 12:30:24 -06:00
Brian Cloutier 35bbc1dbfd Treat nodePort as the 64bit integer it is 2016-04-15 11:29:36 -07:00
Jason Petersen fb4f84207c
Fix use of INT64CONST macro
This macro is intended to receive a bare integer literal (no suffix).
It adds a suffix as necessary, depending upon available features. On
e.g. 32-bit platforms, the existing code failed to compile because a
suffix was added to the existing suffix. This fixes that problem.
2016-04-15 12:13:56 -06:00
Andres Freund 6860327cf9 Merge pull request #449 from citusdata/freebsd-fixes
Freebsd fixes #2 

Fixes #407 #411
2016-04-15 09:56:11 -07:00
Matthew Seaman b1a3801e58 Regularize include paths for some postgresql headers.
Addresses #411
2016-04-15 09:37:22 -07:00