1
0
Fork 0

Merge pull request #1690 from rqlite/random-blob-panic

Check for isTextType in panic-proof way
master
Philip O'Toole 7 months ago committed by GitHub
commit 3c0da15903
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,3 +1,7 @@
## 8.20.2 (unreleased)
### Implementation changes and bug fixes
- [PR #1690](https://github.com/rqlite/rqlite/pull/1690): Check for `isTextType` in panic-proof way.
## 8.20.2 (February 16th 2024)
### Implementation changes and bug fixes
- [PR #1685](https://github.com/rqlite/rqlite/pull/1685): Rename a Proto (but not its fields).

@ -1430,8 +1430,10 @@ func normalizeRowValues(row []interface{}, types []string) ([]*command.Parameter
}
case []byte:
if isTextType(types[i]) {
values[i].Value = &command.Parameter_S{
S: string(val),
values[i] = &command.Parameter{
Value: &command.Parameter_S{
S: string(val),
},
}
} else {
values[i] = &command.Parameter{

@ -146,6 +146,35 @@ func testSQLiteTimeTypes(t *testing.T, db *DB) {
}
}
func testSQLiteRandomBlob(t *testing.T, db *DB) {
_, err := db.ExecuteStringStmt("CREATE TABLE large_data (id INTEGER PRIMARY KEY, large_text TEXT)")
if err != nil {
t.Fatalf("failed to create table: %s", err.Error())
}
_, err = db.ExecuteStringStmt(`
WITH RECURSIVE generate_large_data(id, large_text) AS (
SELECT 1, randomblob(1)
UNION ALL
SELECT id + 1, randomblob(1)
FROM generate_large_data
WHERE id < 2
)
INSERT INTO large_data(id, large_text)
SELECT id, large_text FROM generate_large_data
`)
if err != nil {
t.Fatalf("failed to create table: %s", err.Error())
}
r, err := db.QueryStringStmt("SELECT * FROM large_data LIMIT 1")
if err != nil {
t.Fatalf("failed to query master table: %s", err.Error())
}
if !strings.Contains(asJSON(r), "large_text") {
// Just check that it doesn't panic.
t.Fatalf("unexpected results for query, expected large_text, got %s", asJSON(r))
}
}
func testNotNULLField(t *testing.T, db *DB) {
_, err := db.ExecuteStringStmt("CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name TEXT)")
if err != nil {
@ -1558,6 +1587,7 @@ func Test_DatabaseCommonOperations(t *testing.T) {
{"SQLiteMasterTable", testSQLiteMasterTable},
{"SQLiteTimeTypes", testSQLiteTimeTypes},
{"NotNULLField", testNotNULLField},
{"RandomBlob", testSQLiteRandomBlob},
{"EmptyStatements", testEmptyStatements},
{"SimpleSingleStatements", testSimpleSingleStatements},
{"SimpleStatementsNumeric", testSimpleStatementsNumeric},

Loading…
Cancel
Save