Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 19cbe48

Browse filesBrowse files
authored
Fix memory error with long sql strings (#566)
* add a test for #561 * fix memory issue with long sql strings fixes #561 thanks @kripken for the fix: #561 (comment) * include the new stack size on all targets * remove debig log
1 parent 53335a9 commit 19cbe48
Copy full SHA for 19cbe48

File tree

2 files changed

+37
-2
lines changed
Filter options

2 files changed

+37
-2
lines changed

‎Makefile

Copy file name to clipboardExpand all lines: Makefile
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ EMFLAGS = \
3737
-s EXPORTED_RUNTIME_METHODS=@src/exported_runtime_methods.json \
3838
-s SINGLE_FILE=0 \
3939
-s NODEJS_CATCH_EXIT=0 \
40-
-s NODEJS_CATCH_REJECTION=0
40+
-s NODEJS_CATCH_REJECTION=0 \
41+
-s STACK_SIZE=5MB
4142

4243
EMFLAGS_ASM = \
4344
-s WASM=0
@@ -56,7 +57,7 @@ EMFLAGS_OPTIMIZED= \
5657
--closure 1
5758

5859
EMFLAGS_DEBUG = \
59-
-s ASSERTIONS=1 \
60+
-s ASSERTIONS=2 \
6061
-O1
6162

6263
BITCODE_FILES = out/sqlite3.bc out/extension-functions.bc

‎test/test_long_sql_statement.js

Copy file name to clipboard
+34Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// test for https://github.com/sql-js/sql.js/issues/561
2+
exports.test = function (sql, assert) {
3+
// Create a database
4+
var db = new sql.Database();
5+
var len = 70000;
6+
var many_a = "";
7+
for (var i = 0; i < len; i++) many_a += 'a';
8+
9+
var res = db.exec("select length('" + many_a + "') as len");
10+
var expectedResult = [
11+
{
12+
columns: ['len'],
13+
values: [
14+
[len]
15+
]
16+
}
17+
];
18+
assert.deepEqual(res, expectedResult, "length of long string");
19+
};
20+
21+
if (module == require.main) {
22+
const target_file = process.argv[2];
23+
const sql_loader = require('./load_sql_lib');
24+
sql_loader(target_file).then((sql) => {
25+
require('test').run({
26+
'test long sql string (issue 561)': function (assert) {
27+
exports.test(sql, assert);
28+
}
29+
});
30+
}).catch((e) => {
31+
console.error(e);
32+
assert.fail(e);
33+
});
34+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.