Skip to content
Open
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
12 changes: 9 additions & 3 deletions src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,16 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
return fetchArrayTypes()
}

initial && !initial.reserve && execute(initial)
options.shared.retries = retries = 0
if (!initial.reserve) {
execute(initial)
options.shared.retries = retries = 0
initial = null
return
}

// `fetch_types: false` with a queued `reserve()` — there is nothing to
// execute, so fall through and let `onopen(connection)` below resolve it.
initial = null
return
}

while (sent.length && (query = sent.shift()) && (query.active = true, query.cancelled))
Expand Down
10 changes: 10 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2707,6 +2707,16 @@ t('Ensure reserve on query throws proper error', async() => {
]
})

t('reserve with fetch_types: false on a cold pool', async() => {
const sql = postgres({ ...options, fetch_types: false }) // eslint-disable-line
const reserved = await sql.reserve()
const [{ x }] = await reserved`select 1 as x`
reserved.release()
await sql.end()

return [1, x]
})

t('query during copy error', async() => {
const sql = postgres(options) // eslint-disable-line
await sql`create table test (id serial primary key, name text)`
Expand Down