Implement the RowsColumnTypeScanType interface in the go sql driver#12007
Implement the RowsColumnTypeScanType interface in the go sql driver#12007frouioui merged 1 commit intovitessio:mainfrom
Conversation
246df24 to
99b8440
Compare
|
Just to add to the conversation here... When I initially wrote https://github.com/jimsmart/schema some 5 years ago, I realised that the various database drivers out there actually have very different support for what is returned as sql.ColumType metadata. I tried to catalogue some of that info, in a separate project — originally with the intent of further looking into the differences, and submitting issues / patches, and perhaps even opening an issue on the main Go repo to discuss / track some of the issues I found. Unfortunately, to date, I never got around to any of that. But here is the project I built to catalogue the driver capabilities WRT sql.ColumnType — the table in the main README is manually composed, but in the subfolders all of the READMEs are automatically generated (and it is from these that the main README is summarised). These individual reports can be accessed via the 'View' link in the Report column in the project's top-level README. I only test common column types. Note that this project, and its reports, have not been updated in ~5yrs. https://github.com/jimsmart/drivercaps The long and short of it, and why I mention it here, is that support for .ScanType() varies greatly, with some drivers returning their own types for certain column types — browsing the individual reports for what other db drivers return for common column types may be helpful to you as a point of reference. |
|
@johanoskarsson So, the vitess-driver is not actively worked on. We usually suggest that users use the standard mysql connection to vitess, or alternatively connect using grpc. Have you tried connection using the normal mysql connection protocol? I'll look over your changes as well, just wanted to share this piece of info first. |
frouioui
left a comment
There was a problem hiding this comment.
Everything looks good to me, thank you for your contribution!
|
I assume the test failure is unrelated to this PR? |
|
can you do a merge from the main and push? |
|
Done, thanks! |
b2311dc to
083a2d5
Compare
…or Vitess in order to get the column types Signed-off-by: Johan Oskarsson <joskarsson@slack-corp.com>
083a2d5 to
f1f2ab4
Compare
…or Vitess in order to get the column types (vitessio#12007) Signed-off-by: Johan Oskarsson <joskarsson@slack-corp.com> Signed-off-by: Johan Oskarsson <joskarsson@slack-corp.com> Co-authored-by: Johan Oskarsson <joskarsson@slack-corp.com>
* Add `VStreamerCount` stat to `vttablet` (vitessio#11978) * Add `VStreamersActive` stat to `vttablet` Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * Improve desc Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * Add PR suggestions Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * Move to *stats.Gauge Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * Single defer Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * Add `Uptime` metric (vitessio#12712) * Add `Uptime` metric to `vtgate`+`vttablet` Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * move to go/vt/servenv/status.go Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * Use nanoseconds for uptime Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * Move Uptime metrics to servenv.go, remove dupe start time.Time Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * Use serverStart time.Time Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> --------- Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * Implement the RowsColumnTypeScanType interface in the go sql driver for Vitess in order to get the column types (vitessio#12007) Signed-off-by: Johan Oskarsson <joskarsson@slack-corp.com> Signed-off-by: Johan Oskarsson <joskarsson@slack-corp.com> Co-authored-by: Johan Oskarsson <joskarsson@slack-corp.com> * Add vstream metrics to vtgate (vitessio#13098) * Add vstream metrics to vtgate Signed-off-by: twthorn <thomaswilliamthornton@gmail.com> * Update unit test name and use cell variable Signed-off-by: twthorn <thomaswilliamthornton@gmail.com> * Reset metrics for TestVStreamsCreatedAndLagMetrics, fix data race issue Signed-off-by: twthorn <thomaswilliamthornton@gmail.com> --------- Signed-off-by: twthorn <thomaswilliamthornton@gmail.com> * add lock to flaky TestValidateVersionShard test Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * typo Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> --------- Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> Signed-off-by: Johan Oskarsson <joskarsson@slack-corp.com> Signed-off-by: twthorn <thomaswilliamthornton@gmail.com> Co-authored-by: Johan Oskarsson <johan@oskarsson.nu> Co-authored-by: Johan Oskarsson <joskarsson@slack-corp.com> Co-authored-by: Thomas Thornton <thomaswilliamthornton@gmail.com>
Description
I attempted to use https://github.com/jimsmart/schema to introspect the vitess schema via the vitessdriver. Much to my surprise all of the column types were returned as
interface{}. I dug deeper and found that the Go sql code attempts to cast the row toRowsColumnTypeScanTypeand if that fails it will not be able to return the types.RowsColumnTypeScanTypecontains just one function that I've implemented below. Example of how the mysql drivers implemented it: https://github.com/go-sql-driver/mysql/blob/4591e42e65cf483147a7c7a4f4cfeac81b21c917/fields.go#L140Overall it's fairly straight forward I have tested it against our vitess locally. However a few of the types are unfamiliar to me, such as HEXNUM so any extra eyes would be appreciated.
Related Issue(s)
Adding the vitess dialect to the schema project here jimsmart/schema#21
Checklist
Deployment Notes
Should not require any particular deployment notes.