* Move acl package to pflag
Signed-off-by: Matt Lord <mattalord@gmail.com>
* Stragglers
Signed-off-by: Matt Lord <mattalord@gmail.com>
* Gofmt after GH merge conflict resolution
Signed-off-by: Matt Lord <mattalord@gmail.com>
* Merge in new vtbackup work
Signed-off-by: Matt Lord <mattalord@gmail.com>
* Address linter errors:
context-as-argument: context.Context should be the first parameter of a function (revive)
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
* [sqlparser] Use interoperable flag.Parsed function
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [cli] [servenv] Migrate `--mysql_server_version` flag to pflag
Closes#11144.
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* no mysql_server_version for vtorc
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [internal/flag] Add interoperable _flag.Lookup helper function
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [logutil] Migrate flag definitions to pflag, install on all servenv-compliant binaries
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [go/cmd/*] Ensure all non-servenv compliant entrypoints register logutil flags
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [endtoend] fix test data
Signed-off-by: Andrew Mason <andrew@planetscale.com>
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [log] Migrate flags to pflag
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* WIP: moving vttestserver over
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Migrate all non-servenv commands to register log flags manually
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [vttestserver] handle flags with care
Signed-off-by: Andrew Mason <andrew@planetscale.com>
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Switch to `pflag` for all parsing
This transparently swaps the cli parsing library used by `internal/flag`
from the standard library `flag` package to `spf13/pflag`.
It also introduces hook points for packages throughout the vitess codebase
to register their flags for either all commands using `servenv` or a
particular subset of commands. This allows these packages to continue to
define their flag variables in a package-private way, but without
polluting the global flagset.
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Workaround exit code difference between stdlib `flag` and `pflag`
tl;dr stdlib `flag` has [this][1] and `pflag` does not
[1]: dcf0929de6
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* adjust test data for difference in spacing between pflag/stdflag
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* update lingering legacy flag tests
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Update vtgate/tabletgateway.go to use new interface to isolate flags, update test data
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* update flags in java test code
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [vttestserver] tidy imports
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [vttestserver] fix flags
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [vttlstest] fix flags in usage message
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [vtclient] fix flags
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [vttablet] tidy imports
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [vttablet] fix flags in error messages
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [mysqlctl] fix flags in usage strings
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [vtbackup] fix flags in error strings
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [vtbench] fix flags in example comments
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [vtclient] fix flags in usage strings
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [vtexplain] fix flags in usage
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* [vtctldclient] fix flags and some usages while here
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Need to update tests in vt/vttest as well for tests to pass
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* No double dash needed for `vtctlclient`, only for `vtctl` directly, apparently
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Add helper function to issue deprecation warnings when parsing flags
This package is internal, and extremely temporary. After the
necessary backwards-compatability deprecation cycle to switch to
`pflag`, will be removed.
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Update `cmd` callsites that don't parse via `servenv` to use deprecation-aware parser
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Override `Usage` func to show flags with double-dashes in `-h` output
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Extract and rework the deprecation warning text, plus a little cleaner structure
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Fixup import ordering for `context` while I'm here
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Handle positional arguments to filter out the double-dash for backwards compatibility
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Refactor to support subflag usages and custom usage funcs
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Add ability to filter out certain flags from the Usage
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Documentation for SetUsage nonsense
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Override custom Usages, preserving intended effects
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Special consideration for v1 reshard workflow cli
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Update flags in tests
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Filter out double-dash separator when running `vtctl`/`vtctlclient` <= v13.0.0
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Add release notes for CLI deprecations with advice
Signed-off-by: Andrew Mason <andrew@planetscale.com>
* Extracted the opentracing wrapper to it's own file
* Commented all the public methods
* gofmt/goimports
* Made sure the two interceptor builders are similar
Signed-off-by: Andres Taylor <antaylor@squareup.com>
Note: This is the revert of a temporary revert and has the same effect
as the original PR: https://github.com/vitessio/vitess/pull/3830
Revert "Revert "Factor out glog references""
This reverts commit 246e2898d2.
Signed-off-by: David Weitzman <dweitzman@pinterest.com>
This commit consists only of the changes from running the following:
```
find go -name '*.go' | xargs -n 10 -- sed -i -r -e \
's,"github.com/youtube/vitess/go/,"vitess.io/vitess/go/,'
```
Issue #2681
We still can't get rid of the legacy 1.7 functions because of how
interfaces work. However, I assume that database/sql won't use them
if it finds the newer 'Context' functions in the driver.
Also, go1.9 has allowed us to implement support for custom types.
We still need to exploit this flexibility to add support for
unsigned and other exotic MySQL types.
That way it's using a random port, not always the same one, and doesn't
conflict with other tests.
Also adding a helper method to vttest to specify both schemas.
When --max_random_id > --min_random_id, for each query, a random number is
generated in [min_random_id, max_random_id) and attached to the end of
the bind variables.
Please refer to #2694 and #2670 for motivation and reasoning for
this change.
I've tried to follow best practice in inserting the copyright
headers. In other open source projects, not all files carry
the notice. For example documentation doesn't. I've followed
similar ground rules.
I did not change the php because there is a separate LICENSE
file there by Pixel Federation. We'll first need to notify
them our intent before changing anything there.
As for the presubmit check, it's going to be non-trivial
because of the number of exceptions, like file types,
directories and generated code. So, it will have to be
a separate project.
This addresses #2723.
This change is essentially a new protocol for V3. Although
backward compatible, it changes the connection model.
Basically, the newer V3 features will work only if you used
the new protocol.
The new model deprecates keyspace_shard, tablet_type and options
from ExecuteRequest and moves them into the Session. This means
that the Session is generally not empty, and may be updated
by any call to Execute or ExecuteBatch, even if the statements are
not transactional. Consequently, transactional methods like Begin,
etc. are deprecated in favor of Execute("begin").
Transaction modes will now be supported by new `SET` syntax, which
will correspondingly update the Session variable.
This also makes a connection that contains a session non-multiplexable.
We'll need to resolve whether it's still worth exposing this flexibility
to the clients, and if so, how.
For now, I've updated the Go driver to use the "modern" protocol.
However, the low level rpc (Impl) continues to support the older
functions like Begin, etc. This allows us to test the legacy
functionality.
All other clients: Python, PHP and Java are currently unchanged.
Given that this is a major protocol change, it hints at a 3.0,
but the changes are 2.1 compatible with the following exceptions:
* Go driver uses the new protocol.
* vtclient binary requires `-target` instead of `-tablet-type`, etc.
All tests are passing including PHP & Java clients. In terms
of upgrade:
* PHP and Java can be upgraded by just updating the code.
* Python will probably require a brand new library. The existing
vtdb contains way too much baggage, and it may not be worth
retrofitting this new incompatible protocol onto what's
currently there. I'm looking for a name. `vtdb2`, `vitessdb`?
Also log the first error per error code.
I've also changed the behavior of the multi DML mode to continue executing more queries and not returning early if an error occurs.
vttest will start an actual MySQL instance and the vtcombo binary.
Then the test runs various queries and verifies that the number of rows affected is correct.
Due to the external processes, this test takes ~8 seconds to run.
This required several vtclient changes:
- return error instead of using exit.Return(1)
- enhanced "results" struct and always return it now
- moved DML logic into separate function and changed it to return a "results" as well
- moved non-DML logic into a function as well
Before this change, a user could provide flags *after* the query and these would be ignored by the code. Now, the user gets an error and can fix the call.
I've left out the row support functions because most of them are
not supported by the protocol. The most important changes
are supported: contexts and named arguments.
* Deleted the deprecated shard specific connection support.
* Built go1.8, fixed compilation errors and added tests.
* Fixed documentation that was still stating support for v1 API.
* Fixed custom_sharding test that was relying on v1 API.
* Doc comments updated to explain isolation levels and named args.
* Code review comments addressed.