leafo / pgmoon

A pure Lua Postgres driver for use in OpenResty & more
MIT License
395 stars 93 forks source link

add method isconnected to detect if the inner sock is connected. #72

Closed spacewander closed 2 years ago

spacewander commented 6 years ago

Sometimes we need to call 'disconnect' explicitly in db driver wrapper module. But pgmoon will close the sock when sock operation failed. Thus it is unsafe to call 'disconnect' again. With 'isconnected' method we could detect if the sock is still connected, avoid calling 'disconnect' twice.

leafo commented 2 years ago

There will no longer be a exception when calling disconnect on a closed connection, it will only return nil and potentially an error message