Skip to content

Commit

Permalink
Merge pull request #184 from heroku/fsre/version-check-works-with-tim…
Browse files Browse the repository at this point in the history
…ing-off

Fix bug when doing an version check with \timing on
  • Loading branch information
andscoop authored Feb 21, 2022
2 parents c77299b + 1cd2138 commit fd933c2
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@ function * ensureNonStarterPlan (db) {
}

function * newTotalExecTimeField (db) {
const newTotalExecTimeFieldQuery = 'SELECT current_setting(\'server_version_num\')::numeric >= 130000'
const newTotalExecTimeFieldRaw = yield pg.psql.exec(db, newTotalExecTimeFieldQuery)
const newTotalExecTimeFieldQuery = `SELECT current_setting('server_version_num')::numeric >= 130000`
const newTotalExecTimeFieldRaw = yield pg.psql.exec(db, newTotalExecTimeFieldQuery, ['-t', '-q'])

// error checks
let newTotalExecTimeField = newTotalExecTimeFieldRaw.split('\n')
if (newTotalExecTimeField.length !== 6) {
throw new Error('Unable to determine database version')
}
newTotalExecTimeField = newTotalExecTimeFieldRaw.split('\n')[2].trim()
const newTotalExecTimeField = newTotalExecTimeFieldRaw.split("\n")[0].trim()

if (newTotalExecTimeField !== 't' && newTotalExecTimeField !== 'f') {
throw new Error(`Unable to determine database version, expected "t" or "f", got: "${newTotalExecTimeField}"`)
Expand Down

0 comments on commit fd933c2

Please sign in to comment.