You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
create a new database and clone the us-jails database in it
mkdir ~/doltdbs/
cd doltdbs
dolt clone dolthub/us-jails
Run this query from the command line:
>dolt sql -q "SELECT count(*) FROM dolt_diff_jails WHERE from_commit=HASHOF('HEAD~2') AND to_commit=HASHOF('HEAD~1');"
+----------+
| count(*) |
+----------+
| 3 |
+----------+
Now running the following program with a dsn that points to your local doltdbs directory we created earlier:
package main
import (
"context"
"database/sql"
"fmt"
"os"
_ "github.com/dolthub/driver"
)
func errExit(err error) {
if err != nil {
fmt.Fprintf(os.Stderr, err.Error())
os.Exit(1)
}
}
func main() {
if len(os.Args) != 2 {
fmt.Println("Expected a single command line argument in the format: file:///path/to/doltdbs?commitname=<user_name>&commitemail=<email>&database=<database>")
return
}
dataSource := os.Args[1]
db, err := sql.Open("dolt", dataSource)
errExit(err)
ctx := context.Background()
stmt, err := db.PrepareContext(ctx, "SELECT count(*) FROM dolt_diff_jails WHERE from_commit=HASHOF(?) AND to_commit=HASHOF(?);")
errExit(err)
rows, err := stmt.QueryContext(ctx, "HEAD~2", "HEAD~1")
errExit(err)
var count int
rows.Next()
err = rows.Scan(&count)
errExit(err)
fmt.Println("COUNT(*) =", count)
}
The output is: COUNT(*) = 5320
Which does not match the results retrieved from the command line. It does match what you get from the command line if you do not include the where clause.
The text was updated successfully, but these errors were encountered:
create a new database and clone the us-jails database in it
Run this query from the command line:
Now running the following program with a dsn that points to your local doltdbs directory we created earlier:
The output is:
COUNT(*) = 5320
Which does not match the results retrieved from the command line. It does match what you get from the command line if you do not include the where clause.
The text was updated successfully, but these errors were encountered: