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

This commit is contained in:
Jason Fulghum
2022-06-17 12:50:16 -07:00
parent 80e809541f
commit cdc15dcf87
2 changed files with 14 additions and 3 deletions

View File

@@ -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)
}
}

View File

@@ -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
}