mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-05 18:58:58 -06:00
Merge pull request #5291 from dolthub/steph/dolt-5241
update query timing to be accurate when using dolt sql-client
This commit is contained in:
@@ -68,7 +68,7 @@ func prettyPrintResultsWithSummary(ctx *sql.Context, resultFormat PrintResultFor
|
||||
}
|
||||
}()
|
||||
|
||||
start := time.Now()
|
||||
start := ctx.QueryTime()
|
||||
|
||||
// TODO: this isn't appropriate for JSON, CSV, other structured result formats
|
||||
if isOkResult(sqlSch) {
|
||||
|
||||
@@ -323,6 +323,9 @@ func (cmd SqlClientCmd) Exec(ctx context.Context, commandStr string, args []stri
|
||||
return
|
||||
}
|
||||
|
||||
// grab time for query timing
|
||||
startTime := time.Now()
|
||||
|
||||
rows, err := conn.Query(query)
|
||||
if err != nil {
|
||||
shell.Println(color.RedString(err.Error()))
|
||||
@@ -336,6 +339,7 @@ func (cmd SqlClientCmd) Exec(ctx context.Context, commandStr string, args []stri
|
||||
}
|
||||
if wrapper.HasMoreRows() {
|
||||
sqlCtx := sql.NewContext(ctx)
|
||||
sqlCtx.SetQueryTime(startTime)
|
||||
err = engine.PrettyPrintResultsExtended(sqlCtx, engine.FormatTabular, wrapper.Schema(), wrapper)
|
||||
if err != nil {
|
||||
shell.Println(color.RedString(err.Error()))
|
||||
|
||||
@@ -58,7 +58,7 @@ require (
|
||||
github.com/cenkalti/backoff/v4 v4.1.3
|
||||
github.com/cespare/xxhash v1.1.0
|
||||
github.com/creasty/defaults v1.6.0
|
||||
github.com/dolthub/go-mysql-server v0.14.1-0.20230202040457-507ba0a4421f
|
||||
github.com/dolthub/go-mysql-server v0.14.1-0.20230202214904-d8078b5023fa
|
||||
github.com/google/flatbuffers v2.0.6+incompatible
|
||||
github.com/kch42/buzhash v0.0.0-20160816060738-9bdec3dec7c6
|
||||
github.com/mitchellh/go-ps v1.0.0
|
||||
|
||||
@@ -161,8 +161,8 @@ github.com/dolthub/flatbuffers v1.13.0-dh.1 h1:OWJdaPep22N52O/0xsUevxJ6Qfw1M2txC
|
||||
github.com/dolthub/flatbuffers v1.13.0-dh.1/go.mod h1:CorYGaDmXjHz1Z7i50PYXG1Ricn31GcA2wNOTFIQAKE=
|
||||
github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U=
|
||||
github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0=
|
||||
github.com/dolthub/go-mysql-server v0.14.1-0.20230202040457-507ba0a4421f h1:bkJg9Lvj5vnyA/FFdJR1qcOkR5qYPKs287WtimU+etw=
|
||||
github.com/dolthub/go-mysql-server v0.14.1-0.20230202040457-507ba0a4421f/go.mod h1:aVtgxAf6Bfs0hCj+KzIH7Y1aAxg7/7FlslouCh94VVQ=
|
||||
github.com/dolthub/go-mysql-server v0.14.1-0.20230202214904-d8078b5023fa h1:UU6d1FzkVbGlbub1TF5YSmoJ+CiGGlvL5h7d+d4+10M=
|
||||
github.com/dolthub/go-mysql-server v0.14.1-0.20230202214904-d8078b5023fa/go.mod h1:ZQfmjFs5Gk5WrMeOIE5qZWdWt6Z12kt7K5aVNho+XhY=
|
||||
github.com/dolthub/ishell v0.0.0-20221214210346-d7db0b066488 h1:0HHu0GWJH0N6a6keStrHhUAK5/o9LVfkh44pvsV4514=
|
||||
github.com/dolthub/ishell v0.0.0-20221214210346-d7db0b066488/go.mod h1:ehexgi1mPxRTk0Mok/pADALuHbvATulTh6gzr7NzZto=
|
||||
github.com/dolthub/jsonpath v0.0.0-20210609232853-d49537a30474 h1:xTrR+l5l+1Lfq0NvhiEsctylXinUMFhhsqaEcl414p8=
|
||||
|
||||
@@ -147,3 +147,15 @@ teardown() {
|
||||
[ $status -eq 0 ]
|
||||
[[ $output =~ " test_dashes " ]] || false
|
||||
}
|
||||
|
||||
@test "sql-client: prints accurate query timing" {
|
||||
skiponwindows "Missing dependencies"
|
||||
cd repo1
|
||||
start_sql_server repo1
|
||||
cd ../
|
||||
run dolt sql-client --host=0.0.0.0 --port=$PORT --user=dolt <<SQL
|
||||
USE repo1;
|
||||
SELECT SLEEP(2);
|
||||
SQL
|
||||
[[ $output =~ "1 row in set (2".*" sec)" ]] || false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user