Skip to content
Snippets Groups Projects
Commit 4007436a authored by Nikita Pettik's avatar Nikita Pettik Committed by Kirill Yukhin
Browse files

sql: bind BLOB value as BLOB not as STRING

It is obvious that BLOB (that is value encoded in msgpack with MP_BIN
format) values must be bound as BLOBs, not as strings. Unfortunately,
they were bound as strings, which lead to wrong resulting type
calculations after execution of SQL statement.
parent 71c6e823
No related branches found
No related tags found
No related merge requests found
......@@ -1313,11 +1313,20 @@ sql_bind_blob(sql_stmt * pStmt,
int i, const void *zData, int nData, void (*xDel) (void *)
)
{
#ifdef SQL_ENABLE_API_ARMOR
if (nData < 0)
return SQL_MISUSE;
#endif
return bindText(pStmt, i, zData, nData, xDel);
struct Vdbe *p = (Vdbe *) pStmt;
int rc = vdbeUnbind(p, i);
if (rc == SQL_OK) {
if (zData != 0) {
struct Mem *var = &p->aVar[i - 1];
rc = sqlVdbeMemSetStr(var, zData, nData, 0, xDel);
if (rc == SQL_OK)
rc = sql_bind_type(p, i, "BLOB");
rc = sqlApiExit(p->db, rc);
}
} else if (xDel != SQL_STATIC && xDel != SQL_TRANSIENT) {
xDel((void *)zData);
}
return rc;
}
int
......@@ -1331,7 +1340,7 @@ sql_bind_blob64(sql_stmt * pStmt,
if (nData > 0x7fffffff) {
return invokeValueDestructor(zData, xDel, 0);
} else {
return bindText(pStmt, i, zData, (int)nData, xDel);
return sql_bind_blob(pStmt, i, zData, (int)nData, xDel);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment