Skip to content

Commit

Permalink
Adding redshift as a wire-compatible scheme for postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth Shaw committed Jun 16, 2018
1 parent 689b5cf commit cd61869
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ supported out of the box:
| PostgreSQL (postgres) | pg, postgresql, pgsql |
| SQLite3 (sqlite3) | sq, sqlite, file |
| | |
| Amazon Redshift (redshift) | rs [postgres] |
| CockroachDB (cockroachdb) | cr, cockroach, crdb, cdb [postgres] |
| MemSQL (memsql) | me [mysql] |
| TiDB (tidb) | ti [mysql] |
Expand Down Expand Up @@ -133,6 +134,7 @@ to be imported:
| PostgreSQL (postgres) | [github.com/lib/pq](https://github.com/lib/pq) |
| SQLite3 (sqlite3) | [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) |
| | |
| Amazon Redshift (redshift) | [github.com/lib/pq](https://github.com/lib/pq) |
| CockroachDB (cockroachdb) | [github.com/lib/pq](https://github.com/lib/pq) |
| MemSQL (memsql) | [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) |
| TiDB (tidb) | [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) |
Expand Down
2 changes: 2 additions & 0 deletions dburl.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
// PostgreSQL (postgres) | pg, postgresql, pgsql
// SQLite3 (sqlite3) | sq, sqlite, file
// -----------------------------|-------------------------------------------
// Amazon Redshift (redshift) | rs [postgres]
// CockroachDB (cockroachdb) | cr, cockroach, crdb, cdb [postgres]
// MemSQL (memsql) | me [mysql]
// TiDB (tidb) | ti [mysql]
Expand Down Expand Up @@ -110,6 +111,7 @@
// PostgreSQL (postgres) | github.com/lib/pq
// SQLite3 (sqlite3) | github.com/mattn/go-sqlite3
// -----------------------------|-------------------------------------------------
// Amazon Redshift (redshift) | github.com/lib/pq
// CockroachDB (cockroachdb) | github.com/lib/pq
// MemSQL (memsql) | github.com/go-sql-driver/mysql
// TiDB (tidb) | github.com/go-sql-driver/mysql
Expand Down
8 changes: 7 additions & 1 deletion dburl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ func TestBadParse(t *testing.T) {
{`cockroach+unix:/var/run/postgresql`, ErrInvalidTransportProtocol},
{`cockroach:./path`, ErrInvalidTransportProtocol},
{`cockroach+unix:./path`, ErrInvalidTransportProtocol},
{`redshift:/var/run/postgresql`, ErrInvalidTransportProtocol},
{`redshift+unix:/var/run/postgresql`, ErrInvalidTransportProtocol},
{`redshift:./path`, ErrInvalidTransportProtocol},
{`redshift+unix:./path`, ErrInvalidTransportProtocol},
{`pg:./path/to/socket`, ErrRelativePathNotSupported}, // relative paths are not possible for postgres sockets
{`pg+unix:./path/to/socket`, ErrRelativePathNotSupported},
{`snowflake://`, ErrMissingHost},
Expand Down Expand Up @@ -131,9 +135,11 @@ func TestParse(t *testing.T) {
{`ig://user:pass@localhost:9999/?timeout=1000`, `ignite`, `tcp://localhost:9999?password=pass&timeout=1000&username=user`},
{`ig://user:pass@localhost:9999/dbname?timeout=1000`, `ignite`, `tcp://localhost:9999/dbname?password=pass&timeout=1000&username=user`},

{`snowflake://host/dbname/schema`, `snowflake`, `host/dbname/schema`},
{`snowflake://host/dbname/schema`, `snowflake`, `host/dbname/schema`}, // 58
{`sf://user@host:9999/dbname/schema?timeout=1000`, `snowflake`, `user@host:9999/dbname/schema?timeout=1000`},
{`sf://user:pass@localhost:9999/dbname/schema?timeout=1000`, `snowflake`, `user:pass@localhost:9999/dbname/schema?timeout=1000`},

{`rs://user:pass@amazon.com/dbname`, `postgres`, `postgres://user:pass@amazon.com:5439/dbname`}, // 61
}

for i, test := range tests {
Expand Down
1 change: 1 addition & 0 deletions scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func BaseSchemes() []Scheme {
// wire compatibles
{"cockroachdb", GenFromURL("postgres://localhost:26257/?sslmode=disable"), 0, false, []string{"cr", "cockroach", "crdb", "cdb"}, "postgres"},
{"memsql", GenMySQL, 0, false, nil, "mysql"},
{"redshift", GenFromURL("postgres://localhost:5439/"), 0, false, []string{"rs"}, "postgres"},
{"tidb", GenMySQL, 0, false, nil, "mysql"},
{"vitess", GenMySQL, 0, false, []string{"vt"}, "mysql"},

Expand Down

0 comments on commit cd61869

Please sign in to comment.