Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory error with long sql strings #566

Merged
merged 4 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ EMFLAGS = \
-s EXPORTED_RUNTIME_METHODS=@src/exported_runtime_methods.json \
-s SINGLE_FILE=0 \
-s NODEJS_CATCH_EXIT=0 \
-s NODEJS_CATCH_REJECTION=0
-s NODEJS_CATCH_REJECTION=0 \
-s STACK_SIZE=5MB

EMFLAGS_ASM = \
-s WASM=0
Expand All @@ -56,7 +57,7 @@ EMFLAGS_OPTIMIZED= \
--closure 1

EMFLAGS_DEBUG = \
-s ASSERTIONS=1 \
-s ASSERTIONS=2 \
-O1

BITCODE_FILES = out/sqlite3.bc out/extension-functions.bc
Expand Down
34 changes: 34 additions & 0 deletions test/test_long_sql_statement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// test for https://github.com/sql-js/sql.js/issues/561
exports.test = function (sql, assert) {
// Create a database
var db = new sql.Database();
var len = 70000;
var many_a = "";
for (var i = 0; i < len; i++) many_a += 'a';

var res = db.exec("select length('" + many_a + "') as len");
var expectedResult = [
{
columns: ['len'],
values: [
[len]
]
}
];
assert.deepEqual(res, expectedResult, "length of long string");
};

if (module == require.main) {
const target_file = process.argv[2];
const sql_loader = require('./load_sql_lib');
sql_loader(target_file).then((sql) => {
require('test').run({
'test long sql string (issue 561)': function (assert) {
exports.test(sql, assert);
}
});
}).catch((e) => {
console.error(e);
assert.fail(e);
});
}
Loading