From cdc15dcf87524d3fe401f922ff2bbb6b81059a22 Mon Sep 17 00:00:00 2001 From: Jason Fulghum Date: Fri, 17 Jun 2022 12:50:16 -0700 Subject: [PATCH 1/3] Improved error message when a multistatement exec query fails during execution and added a bats test for customer issue https://github.com/dolthub/dolt/issues/3512 --- go/cmd/dolt/commands/sql.go | 1 + integration-tests/bats/sql-spatial-types.bats | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/go/cmd/dolt/commands/sql.go b/go/cmd/dolt/commands/sql.go index 43e915f800..8830f869ad 100644 --- a/go/cmd/dolt/commands/sql.go +++ b/go/cmd/dolt/commands/sql.go @@ -735,6 +735,7 @@ func runMultiStatementMode(ctx *sql.Context, se *engine.SqlEngine, input io.Read if rowIter != nil { err = engine.PrettyPrintResults(ctx, se.GetReturnFormat(), sqlSch, rowIter, HasTopLevelOrderByClause(query)) if err != nil { + err = fmt.Errorf("error executing query on line %d: %v", scanner.statementStartLine, err) return errhand.VerboseErrorFromError(err) } } diff --git a/integration-tests/bats/sql-spatial-types.bats b/integration-tests/bats/sql-spatial-types.bats index a9672ff185..c8c3ae1519 100644 --- a/integration-tests/bats/sql-spatial-types.bats +++ b/integration-tests/bats/sql-spatial-types.bats @@ -74,7 +74,7 @@ teardown() { [[ "$output" =~ "POLYGON((0.123 0.456,1.22 1.33,1.11 0.99,0.123 0.456))" ]] || false } -@test "sql-spatial-types: create geometry table and insert existing spetial types" { +@test "sql-spatial-types: create geometry table and insert existing spatial types" { skip_nbf_dolt_1 # create geometry table @@ -105,7 +105,6 @@ teardown() { [[ "$output" =~ "POLYGON((1 2,3 4,5 6,1 2))" ]] || false } - @test "sql-spatial-types: prevent point as primary key" { run dolt sql -q "create table point_tbl (p point primary key)" [ "$status" -eq 1 ] @@ -213,7 +212,7 @@ teardown() { run dolt sql -q "INSERT INTO pt VALUES (2, ST_GEOMFROMTEXT(ST_ASWKT(POINT(1,2)), 4326))" [ "$status" -eq 1 ] - [ "$output" = "The SRID of the geometry does not match the SRID of the column 'p'. The SRID of the geometry is 4326, but the SRID of the column is 0. Consider changing the SRID of the geometry or the SRID property of the column." ] + [[ "$output" =~ "The SRID of the geometry does not match the SRID of the column 'p'. The SRID of the geometry is 4326, but the SRID of the column is 0. Consider changing the SRID of the geometry or the SRID property of the column." ]] || false run dolt sql -q "SELECT ST_ASWKT(p) FROM pt" [[ ! "$output" =~ "POINT(1 2)" ]] || false @@ -260,3 +259,14 @@ SQL [ "$status" -eq 1 ] [[ "$output" =~ "The SRID of the geometry does not match the SRID of the column 'p'. The SRID of the geometry is 4326, but the SRID of the column is 0. Consider changing the SRID of the geometry or the SRID property of the column." ]] || false } + +@test "sql-spatial-types: multistatement exec with unsupported spatial types" { + dolt sql -q "CREATE TABLE t1 (i int primary key, g GEOMETRY NOT NULL);" + + run dolt sql << SQL +INSERT INTO t1 values (0, point(1,2)); +INSERT INTO t1 VALUES (1,0x000000000104000000030000000101000000000000000000F03F000000000000F03F010100000000000000000000400000000000000040010100000000000000000008400000000000000840); +SQL + [ "$status" -eq 1 ] + [[ "$output" =~ "error executing query on line 2: unsupported feature: MultiPoint geospatial type" ]] || false +} From e82ab2a4b42bde095de00745c748ee9db9109663 Mon Sep 17 00:00:00 2001 From: Jason Fulghum Date: Fri, 17 Jun 2022 17:51:25 -0700 Subject: [PATCH 2/3] Updating error string to match changes from GMS. --- integration-tests/bats/sql-spatial-types.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/bats/sql-spatial-types.bats b/integration-tests/bats/sql-spatial-types.bats index c8c3ae1519..2922f92e6f 100644 --- a/integration-tests/bats/sql-spatial-types.bats +++ b/integration-tests/bats/sql-spatial-types.bats @@ -268,5 +268,5 @@ INSERT INTO t1 values (0, point(1,2)); INSERT INTO t1 VALUES (1,0x000000000104000000030000000101000000000000000000F03F000000000000F03F010100000000000000000000400000000000000040010100000000000000000008400000000000000840); SQL [ "$status" -eq 1 ] - [[ "$output" =~ "error executing query on line 2: unsupported feature: MultiPoint geospatial type" ]] || false + [[ "$output" =~ "error executing query on line 2: unsupported geospatial type: MultiPoint from value: 0x0" ]] || false } From ff28894e15437f0fe5ce24d92de283a049afb4bd Mon Sep 17 00:00:00 2001 From: Jason Fulghum Date: Fri, 17 Jun 2022 18:23:51 -0700 Subject: [PATCH 3/3] Updating tests from error message format change --- integration-tests/bats/sql-branch.bats | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/integration-tests/bats/sql-branch.bats b/integration-tests/bats/sql-branch.bats index 0db1e9944a..05cfb7efd0 100644 --- a/integration-tests/bats/sql-branch.bats +++ b/integration-tests/bats/sql-branch.bats @@ -74,12 +74,12 @@ teardown() { dolt branch existing_branch run dolt sql -q "SELECT DOLT_BRANCH('existing_branch')" [ $status -eq 1 ] - [ "$output" = "fatal: A branch named 'existing_branch' already exists." ] + [[ "$output" =~ "fatal: A branch named 'existing_branch' already exists." ]] || false # empty branch run dolt sql -q "SELECT DOLT_BRANCH('')" [ $status -eq 1 ] - [ "$output" = "error: cannot branch empty string" ] + [[ "$output" =~ "error: cannot branch empty string" ]] || false } @test "sql-branch: CALL DOLT_BRANCH throws error" { @@ -164,12 +164,12 @@ SQL # branch copying from is empty run dolt sql -q "SELECT DOLT_BRANCH('-c','','copy')" [ $status -eq 1 ] - [ "$output" = "error: cannot branch empty string" ] + [[ "$output" =~ "error: cannot branch empty string" ]] || false # branch copying to is empty run dolt sql -q "SELECT DOLT_BRANCH('-c','main','')" [ $status -eq 1 ] - [ "$output" = "error: cannot branch empty string" ] + [[ "$output" =~ "error: cannot branch empty string" ]] || false dolt branch 'existing_branch' run dolt branch @@ -180,12 +180,12 @@ SQL # branch copying from that don't exist run dolt sql -q "SELECT DOLT_BRANCH('-c', 'original', 'copy');" [ $status -eq 1 ] - [ "$output" = "fatal: A branch named 'original' not found" ] + [[ "$output" =~ "fatal: A branch named 'original' not found" ]] || false # branch copying to that exists run dolt sql -q "SELECT DOLT_BRANCH('-c', 'main', 'existing_branch');" [ $status -eq 1 ] - [ "$output" = "fatal: A branch named 'existing_branch' already exists." ] + [[ "$output" =~ "fatal: A branch named 'existing_branch' already exists." ]] || false } @test "sql-branch: CALL DOLT_BRANCH -c throws error on error cases" {