Граф коммитов

443 Коммитов

Автор SHA1 Сообщение Дата
David Weitzman 349a564beb Reduce the number of unit tests that require VTROOT by moving testdata closer to the tests
Signed-off-by: David Weitzman <dweitzman@pinterest.com>
2019-01-23 19:28:54 -08:00
Derek Perkins 9ab9ecc149 exec_cases: add passing messages OnDup test
Signed-off-by: Derek Perkins <derek@derekperkins.com>
2019-01-09 13:47:26 -07:00
Derek Perkins 28def542b6 exec_cases: add failing tests for msgs on dupe
Signed-off-by: Derek Perkins <derek@derekperkins.com>
2019-01-09 12:58:28 -07:00
Rafael Chacon 130790f35f Adds support for update by destination
Signed-off-by: Rafael Chacon <rafael@slack-corp.com>
2018-12-04 17:02:42 -08:00
Michael Demmer 32dd398dd5
Merge pull request #4336 from planetscale/ss-vtgatev3
select *: expand column list for tables with authoritative column lists
2018-11-21 21:19:16 -05:00
Sugu Sougoumarane 6ceac0c832 BUG: fix unexpected panic in vtgate
VTGate panics if you try to insert into a vindex. Explicitly
check for this case.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
2018-11-20 11:16:08 -08:00
Sugu Sougoumarane 066779f520 select *: more review comments
I also had to fixup vtexplain to make it load vschemas with enums
properly.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
2018-11-19 15:11:46 -08:00
Sugu Sougoumarane b30a5c6a1a select *: address review comments
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
2018-11-18 08:56:56 -08:00
Sugu Sougoumarane cf87a287cd select *: expand columns for authoritative tables
Add logic to use new symtab metadata about authoritative
tables to expand 'select *' expressions into the full
column list.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
2018-11-18 08:14:55 -08:00
Sugu Sougoumarane af9817fad2 select *: is_authoritative flag
If this flag is set for a table, we'll treat the column list
as authoritative and expand select *.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
2018-11-18 08:14:55 -08:00
Sugu Sougoumarane 6ec82cffd8
Merge pull request #3923 from sougou/sq2
vtgate: subquery support
2018-11-18 08:10:27 -08:00
Sugu Sougoumarane 102645e4e9 subquery: final touches
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
2018-11-17 20:51:54 -08:00
Sugu Sougoumarane 16af2b83d8 subquery: address review comments
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
2018-11-17 14:19:00 -08:00
Sugu Sougoumarane a372d9f924 vtgate: subquery support
This implementation follows the design from doc/VTGateSubqueries.md.

A new PulloutSubquery primitive has been created. Its action is to
execute a subquery, save the resulting value(s) in a bind variable,
and pass that down to the underlying primitive.

The type of value set depends on whether the subquery occurred in
an IN clause, etc. In the case of IN and NOT IN clauses, if the
list returned is empty, a guard variable is set to work around
the inability for IN clauses to handle an empty list syntax.

Subqueries can only be pulled out if they are not correlated.
Correlated subqueries will be handled when we add the
ability to execute expressions in VTGate.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
2018-10-30 21:03:09 -07:00
Sugu Sougoumarane a931137308 ddl: support multi-table statements
rename and drop allow multiple tables in the DDL.
This change adds support for them.

* Introduced two new members to DDL: 'from' and 'to' table lists.
* NewName is deprecated.
* For single table DDLs, only Table is set.
* For multi-table DDLs, 'from' and 'to' tables are set as needed.
* The vttablet ddl plan had unused fields. They've been deleted.
* The permissions code has been updated to use the new table names.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
2018-10-30 10:44:38 -07:00
Michael Demmer c8a7bc5402 rename the SHARD_PARTIAL directive to SCATTER_ERRORS_AS_WARNINGS
Given the updated design whereby vtgate will return any shard
error as a warning, change the comment directive to more
intuitively express what the behavior is.

Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-10-16 09:38:59 -07:00
Michael Demmer 4ef379a5cd add planbuilder support for a SHARD_PARTIAL comment directive
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-10-11 12:25:21 -07:00
Aaron Young e9b91d0517 Allow updating fields to null
Signed-off-by: Aaron Young <aaron.young@gmail.com>
2018-09-08 08:36:20 -04:00
Sugu Sougoumarane d9f7390257
Merge pull request #4150 from tinyspeck/vtexplain-set-dbname
add support for vtexplain to override the dbname target
2018-08-24 13:46:01 -07:00
Michael Demmer 4659a01410 add support for vtexplain to override the dbname target
This change adds a --dbname option to the vtexplain binary so that
callers can simulate what vtgate will do when the application connects
with a specific database name.

Add a test to show how this can be used to bypass the v3 routing and
send queries directly to a shard.

Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-08-23 06:14:32 -07:00
Sugu Sougoumarane c3159d9e87
Merge pull request #4134 from sougou/pin
vschema: allow pins in vschema
2018-08-15 18:31:17 -07:00
Sugu Sougoumarane 9ab49cec53 vschema: allow pins in vschema
Pinning was an internal feature used for pinning the
dual table to shard 0. Exposing this ability in vschema
allows someone to pin an unsharded table to a specific
shard.

This is still not a full feature because we ned to
think about the various use cases like resharding etc.
But it can be used for testing purposes.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
2018-08-14 15:00:30 -07:00
Sugu Sougoumarane 630fbbfeca vtgate planbuilder: verify same vindex
When two parts of a query use the same unique vindex
values, we also have to check that they use the same
vindex.

Otherwise, we end up merging queries that use different
videxes but coincidentally have the same values.

I've consolidated all places that perform this check
and added the vindex check in that function.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
2018-08-14 13:08:07 -07:00
Alex Charis abc62a96c0 fixup tests to reflect that vtgate no longer intercepts database() function
Signed-off-by: Alex Charis <acharis@hubspot.com>
2018-07-03 14:13:31 -04:00
Sugu Sougoumarane 6dcacbb876
Merge pull request #4060 from tinyspeck/fix-bug-timeouts
Fix bug in where timeout condition is checked
2018-06-28 20:10:06 -07:00
Sugu Sougoumarane 287ecc1c22
Merge pull request #4048 from tinyspeck/vtexplain-support-partitions
vtexplain support partitions
2018-06-28 19:42:14 -07:00
Rafael Chacon 849a2913c5 Fix bug in where timeout condition is checked
The following fixes a bug where timeouts where not being properly propagated
when using limit or count clauses.

This needs to be done before the full route is wireup. Otherwise the type
pattern matching won't work.

Signed-off-by: Rafael Chacon <rafael@slack-corp.com>
2018-06-28 17:10:15 -07:00
Michael Demmer ce7d6700d3 planbuilder: set table name in plan even in passthrough dml mode
Rework the implementation of passthrough DML mode so that it tries
to set the Table in the plan before returning.

This fixes an annoyance in which the per-table metrics don't properly
include DMLs in passthrough mode because they are generated dynamically
based on the table name in the plan stats.

Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-06-26 10:30:01 -07:00
Michael Demmer 3e2647058b vtexplain: strip all comments from the schema definition
In cases of partitioned tables, mysql will include version-specific
comment directives in the output of a `show create table` command.

Add support in vtexplain to strip all the comments from the sql
schema prior to trying to parse so that it will simply ignore the
partition directives.

Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-06-22 13:40:38 -07:00
Sugu Sougoumarane b374cd6b8b
Merge pull request #3998 from sougou/selectdb
v3: support database() function
2018-06-07 19:40:14 -07:00
Sugu Sougoumarane 9b63bbf204 tabletserver: dmls: like is not equality
Fixes #4007
Tabletserver was treating 'like' expressions as equality.
a like 'a%' is not the same as a = 'a%'.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
2018-06-06 21:46:10 -07:00
Sugu Sougoumarane 65fc9dffe4 v3: support database() function
Fixes #3954
This is an alternate PR to #3962. The implementation is less
efficient, but more correct. This allows you to use the
database() call anywherei in the sql, and v3 will substitute
it to the actual target string.

If necessary, we can add an optimization that won't send the
query to the vttablets.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
2018-06-01 20:46:29 -07:00
David Weitzman 771863d369 Disallow GET_LOCK() calls in vttablet.
Named locks are unsafe with server-side connection pooling.

See https://github.com/vitessio/vitess/issues/3631 for background.

Signed-off-by: David Weitzman <dweitzman@pinterest.com>
2018-05-31 15:10:10 -07:00
Rafael Chacon d99301c568 Adds directive to set timeouts into SELECT queries
* Queries that include the QUERY_TIMEOUT_MS directive will timeout if execution
  time exceeds the value provided in the directive.
* In this iteration, timeouts are only supported for selects. Once we do the
  refactor of removing sql.Preview from the engine, it should be really straight
  forward to refactor this code and support this feature for all statements.
* This feature can be used in the following way:
   select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from users

* Added integration test and validated locally that it works as expected.

* Queries that include the QUERY_TIMEOUT_MS directive will timeout.
* In this itereation, they are only supported for selects. Once we do the
  refactor of removing sql.Preview from the engine, it should be really straight
  forward to refactor this code and support for all statements.
* This feature can be used in the following way:
  select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from use

Signed-off-by: Rafael Chacon <rafael@slack-corp.com>
2018-05-23 15:21:24 -07:00
Sugu Sougoumarane b4a5514dd4
Merge pull request #3925 from dweitzman/leading_whitespace
Also remove leading whitespace in SplitMarginComments.
2018-05-20 21:02:54 -07:00
David Weitzman 4352731e86 Also remove leading whitespace in SplitMarginComments.
This was separated from the previous diff because it impacts query plans, although in seemingly-harmless way.

Signed-off-by: David Weitzman <dweitzman@pinterest.com>
2018-05-14 09:23:34 -07:00
Rafael Chacon 69df7f6095 Adds support for multi shard autocommit
* Also, updated some commments to be clearer about the intent of the test.

Signed-off-by: Rafael Chacon <rafael@slack-corp.com>
2018-05-12 19:05:17 -07:00
Rafael Chacon 491c754654 Improve tests per review
Signed-off-by: Rafael Chacon <rafael@slack-corp.com>
2018-05-12 18:44:28 -07:00
Rafael Chacon fd467d59a5 Adds support to scattered updates
Signed-off-by: Rafael Chacon <rafael@slack-corp.com>
2018-05-12 18:44:28 -07:00
Daniel Tahara 98e162a6a2 [Sqlparser] VALUES(...) should take a fully-qualified column name
A values expression is allowed to take a fully qualified (table.col),
but the current parser only allows unqualified columns. I have modified
the grammar, plan builder, and AST accordingly.

Signed-off-by: Daniel Tahara <tahara@dropbox.com>
2018-05-10 16:49:25 -07:00
Sugu Sougoumarane a14b21cb33
Merge pull request #3848 from tinyspeck/on-dup-shard-key
Insert on duplicate key query support enhancement
2018-05-09 07:35:36 -07:00
Michael Demmer 35fde4c184 include the MultiShardAutocommit boolean in the plan json
To help debugging whether or not the comment was parsed properly, include
the boolean for MultiShardAutocommit in the plan JSON.

Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-04-23 21:33:01 -07:00
Rafael Chacon 32848b5022 Insert on duplicate key query support enhancement
* The following commit adds support to upsert statements when vindex column is
  being set to the same value provided in the `VALUES`. e.g:

  INSERT INTO table a,b VALUES ('a', 'b') on duplicate key update a=values(a)

* Remove unsuded parameter from isVindex changing function.

Signed-off-by: Rafael Chacon <rafael@slack-corp.com>
2018-04-18 22:53:25 -07:00
Michael Demmer a3012fada7 add vtexplan case for shard targeted delete with single round trip
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-04-13 09:23:29 -07:00
Michael Demmer 6329d3fc3f change the vitess query hint sigil to /*vt+
As suggested by sougou in PR review, change the comment hint to
/*vt+ ... */ from /*vt! ... */.

Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-04-13 08:05:10 -07:00
Michael Demmer 95d04c6ab5 add vtexplain cases to demonstrate single round trip autocommit option
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-04-13 08:05:10 -07:00
Scott Lanning f04cbc716d make vtexplain treat columns case-insensitively
It works already in vtgate, just specific to vtexplain.
If you have a column name in all caps but code uses lowercase (or vice versa),
vtexplain will choke with something like:

  unknown error: invalid column UPPIE

Just strings.ToLower() the column name.

Signed-off-by: Scott Lanning <scott.lanning@booking.com>
2018-04-04 18:25:57 +02:00
Rafael Chacon 0841b58601 Add more validations and name refactor
Signed-off-by: Rafael Chacon <rafael@slack-corp.com>
2018-03-22 13:12:53 -07:00
Rafael Chacon 5e2a957984 Initial commit for range query support inside from clause
* Some general refactor of plan builders (move them to have their own files).
* Refactor parse destination code and put it in key package.
* Add general support for range queries in delete statements.

Signed-off-by: Rafael Chacon <rafael@slack-corp.com>
2018-03-22 13:10:24 -07:00
Sugu Sougoumarane db50fb5147
Merge pull request #3756 from sougou/v3multi
v3: misc fixes
2018-03-20 12:32:00 -07:00