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

perf: optimize session variables in HANA #339

Merged
merged 2 commits into from
Nov 10, 2023
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
7 changes: 1 addition & 6 deletions hana/lib/HANAService.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,7 @@ class HANAService extends SQLService {
}

async set(variables) {
const columns = Object.keys(variables).map(
k => `SET '${k.replace(/'/g, "''")}'='${(variables[k] + '').replace(/'/g, "''")}';`,
)
const sql = `DO BEGIN ${columns.join('')} END;`

await this.dbc.exec(sql)
this.dbc.set(variables)
}

async onSELECT({ query, data }) {
Expand Down
5 changes: 5 additions & 0 deletions hana/lib/drivers/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ class HANADriver {
return prom(this._native, 'exec')(sql)
}

set(variables) {
variables
throw new Error('Implementation missing')
}

/**
* Commits the current transaction
*/
Expand Down
4 changes: 4 additions & 0 deletions hana/lib/drivers/hana-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class HANAClientDriver extends driver {
this._native.setAutoCommit(false)
}

set(variables) {
Object.keys(variables).forEach(k => this._native.setClientInfo(k, variables[k]))
}

async prepare(sql) {
const ret = await super.prepare(sql)
ret.stream = async (values, one) => {
Expand Down
5 changes: 5 additions & 0 deletions hana/lib/drivers/hdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class HDBDriver extends driver {
this.connected = false
}

set(variables) {
const clientInfo = this._native._connection.getClientInfo()
Object.keys(variables).forEach(k => clientInfo.setProperty(k, variables[k]))
}

async prepare(sql) {
const ret = await super.prepare(sql)
ret.stream = async (values, one) => {
Expand Down
Loading