-
Notifications
You must be signed in to change notification settings - Fork 32
fix: hana preparations use map #1682
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -335,9 +335,14 @@ class HANAService extends SQLService { | |
|
|
||
| // prepare and exec are both implemented inside the drivers | ||
| prepare(sql, hasBlobs) { | ||
| const stmt = this.ensureDBC().prepare(sql, hasBlobs) | ||
| // we store the statements, to release them on commit/rollback all at once | ||
| this.dbc.statements.push(stmt) | ||
| // we store the prepared statements for caching | ||
| // and to release them on commit/rollback all at once | ||
| let stmt = this.ensureDBC().statements.get(sql); | ||
| if (!stmt) { | ||
| const newPS = this.ensureDBC().prepare(sql, hasBlobs) | ||
| this.ensureDBC().statements.set(sql, newPS) | ||
| stmt = newPS | ||
| } | ||
| return stmt | ||
| } | ||
|
|
||
|
|
@@ -1358,7 +1363,8 @@ SELECT ${mixing} FROM JSON_TABLE(SRC.JSON, '$' COLUMNS(${extraction}) ERROR ON E | |
| async onCall({ query, data }, name, schema) { | ||
| const isAsync = /\sASYNC\s*$/.test(query) | ||
| const outParameters = isAsync ? [{ PARAMETER_NAME: 'ASYNC_CALL_ID' }] : await this._getProcedureMetadata(name, schema) | ||
| const ps = await this.prepare(query) | ||
| // make procedure preparations unique to avoid caching issues with internal procedures | ||
| const ps = await this.prepare(query+'--'+this.ensureDBC().statements.length) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By changing the |
||
| const ret = this.ensureDBC() && await ps.proc(data, outParameters) | ||
| return isAsync ? ret.ASYNC_CALL_ID[0] : ret | ||
| } | ||
|
|
@@ -1385,7 +1391,7 @@ SELECT ${mixing} FROM JSON_TABLE(SRC.JSON, '$' COLUMNS(${extraction}) ERROR ON E | |
|
|
||
| onBEGIN() { | ||
| DEBUG?.('BEGIN') | ||
| if (this.dbc) this.dbc.statements = [] | ||
| if (this.dbc) this.dbc.statements = new Map() | ||
| return this.dbc?.begin() | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fundamentally flawed, because it is possible to run the same
sqlstatement in "parallel" at this level which will start throwing errors when the same statement instance is called withexec/executeas the statement has state. Therefor it is required to create a queue for each statement until it is finished with anexec/execute.