On 21 February 2017 at 17:50, Alexey Kopytov <akopytov@xxxxxxxxx> wrote:
On Tue, 21 Feb 2017 17:18:55 +1100, Daurnimator wrote:
On 21 February 2017 at 17:01, Alexey Kopytov <akopytov@xxxxxxxxx> wrote:
On Tue, 21 Feb 2017 11:29:54 +1100, Daurnimator wrote:
On 20 February 2017 at 23:19, Alexey Kopytov <akopytov@xxxxxxxxx> wrote:
databases usually provide only synchronous client libraries
Most databases have async mode available in their clients.
e.g. postgresql's libpq has PQsetnonblocking()
For the ones that don't have that available via the official clients,
people have often written alternative client libraries.
- PostgreSQL allows at most one async query in flight. Which doesn't make
it
truly asynchronous. Not in the context being discussed, at least.
Sure it does, you can create as many PGConn objects as you desire.
Yes you then have to juggle the multiple connections through some
polling mechanism, but you would have had to do that anyway!
Yeah, "some polling mechanism" is exactly where the problem hides. That is
sometimes called "simulated asynchronous IO" as opposed to the native
asynchronous IO. See, that's why people have implemented asynchronous IO in
the Linux kernel, even though non-blocking IO was already available.
Plus there are plenty of those around for lua and luajit.
Infact, here's a library I wrote for postgres:
https://github.com/daurnimator/cqueues-pgsql
Thanks for the pointer, but that's not what I'm looking for. Please
understand the difference between a non-blocking interface, an asynchronous
interface and pipelining. The three concepts are related, but they are not
the same.
- MySQL does not have a maintained asynchronous client library.
libattachsql
is abandonware, and the new X protocol is a completely different story.
So no, life is not as simple as it may sound.
Indeed mysql is a bit of an outlier: it's one of the few without a
well maintained async C library.
However this doesn't mean that they don't exist or can't be found. e.g.
- I have one at work which I unfortunately can't share
- node.js has one at https://github.com/mysqljs/mysql ;(probably not
useful for you)
- openresty has one:
https://github.com/openresty/lua-resty-mysql/blob/master/lib/resty/mysql.lua
This can probably be ported to 'normal' luajit without too much
effort.
Thanks again for the links, but that's not what I need. There is no way you
can implement a truly asynchronous interface unless the underlying protocol
allows it. Which is not the case for PostgreSQL, MySQL and likely many other
ones that I'm not interested in at the moment.