Merge pull request #1381 from mattn/eliminate-bounds-checks

Eliminate unnecessary bounds checks in hot paths
diff --git a/_example/json/json.go b/_example/json/json.go
index 181934b..08e75cd 100644
--- a/_example/json/json.go
+++ b/_example/json/json.go
@@ -33,7 +33,9 @@
 	}
 	defer db.Close()
 
-	_, err = db.Exec(`create table foo (tag jsonb)`)
+	// Using a json-typed column
+	// Verify type: `create table foo (tag text) strict`
+	_, err = db.Exec(`create table foo (tag json)`)
 	if err != nil {
 		log.Fatal(err)
 	}
@@ -78,4 +80,50 @@
 		log.Fatal(err)
 	}
 	fmt.Println(country)
+
+	// Using a jsonb-typed column
+	// Verify type: `create table bar (tag blob) strict`
+	_, err = db.Exec(`create table bar (tag jsonb)`)
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	stmt, err = db.Prepare("insert into bar(tag) values(jsonb(?))")
+	if err != nil {
+		log.Fatal(err)
+	}
+	defer stmt.Close()
+	_, err = stmt.Exec(`{"name": "mattn", "country": "japan"}`)
+	if err != nil {
+		log.Fatal(err)
+	}
+	_, err = stmt.Exec(`{"name": "michael", "country": "usa"}`)
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	err = db.QueryRow("select tag->>'country' from bar where tag->>'name' = 'mattn'").Scan(&country)
+	if err != nil {
+		log.Fatal(err)
+	}
+	fmt.Println(country)
+
+	err = db.QueryRow("select json(tag) from bar where tag->>'name' = 'mattn'").Scan(&tag)
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	fmt.Println(tag.Name)
+
+	tag.Country = "日本"
+	_, err = db.Exec(`update bar set tag = jsonb(?) where tag->>'name' == 'mattn'`, &tag)
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	err = db.QueryRow("select tag->>'country' from bar where tag->>'name' = 'mattn'").Scan(&country)
+	if err != nil {
+		log.Fatal(err)
+	}
+	fmt.Println(country)
 }
diff --git a/sqlite3_opt_vtable.go b/sqlite3_opt_vtable.go
index 9b164b3..9761bf3 100644
--- a/sqlite3_opt_vtable.go
+++ b/sqlite3_opt_vtable.go
@@ -301,10 +301,18 @@
 	OpLT            = 16
 	OpGE            = 32
 	OpMATCH         = 64
-	OpLIKE          = 65 /* 3.10.0 and later only */
-	OpGLOB          = 66 /* 3.10.0 and later only */
-	OpREGEXP        = 67 /* 3.10.0 and later only */
-	OpScanUnique    = 1  /* Scan visits at most 1 row */
+	OpLIKE          = 65  /* 3.10.0 and later only */
+	OpGLOB          = 66  /* 3.10.0 and later only */
+	OpREGEXP        = 67  /* 3.10.0 and later only */
+	OpNE            = 68  /* 3.21.0 and later only */
+	OpISNOT         = 69  /* 3.21.0 and later */
+	OpISNOTNULL     = 70  /* 3.21.0 and later */
+	OpISNULL        = 71  /* 3.21.0 and later */
+	OpIS            = 72  /* 3.21.0 and later */
+	OpLIMIT         = 73  /* 3.38.0 and later */
+	OpOFFSET        = 74  /* 3.38.0 and later */
+	OpFUNCTION      = 150 /* 3.25.0 and later */
+	OpScanUnique    = 1   /* Scan visits at most 1 row */
 )
 
 // InfoConstraint give information of constraint.