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

Why is this package not based on mysqli? #94

Closed
BenMorel opened this issue Dec 23, 2019 · 7 comments
Closed

Why is this package not based on mysqli? #94

BenMorel opened this issue Dec 23, 2019 · 7 comments

Comments

@BenMorel
Copy link

First of all I'm sorry as this is not really an issue, but I got curious and StackOverflow closed my question as off-topic, so I thought I'd ask here directly:

Why isn't amphp/mysql based on mysqli?

mysqli supports async queries, so was there a reason why this library was not simply built of top of mysqli, instead of re-implementing the whole MySQL protocol?

Thanks for your time!

@bwoebi
Copy link
Member

bwoebi commented Dec 25, 2019

mysqli_poll() is just polling ... mysql. It does not provide you any possibility to poll any other streams together with the mysql data.
There's no underlying file descriptors exposed by mysqli which the event loop could use.

@BenMorel
Copy link
Author

Thank you for the explanation! 👍 This makes perfectly sense now.

@dbalabka
Copy link
Contributor

@bwoebi am I right that MySQLi should some function like \pg_socket to provide access to connection socket?
https://github.com/amphp/postgres/blob/master/src/PgSqlConnection.php

If so, it might be reasonable to propose missing functionality via RFC into PHP Core. IMO MySQL support is crucial for async support. In contrast with recently implemented Fibers, it might give opportunity for adopting Amp into projects via such popular DBALs like Doctrine.

@bwoebi
Copy link
Member

bwoebi commented Jul 23, 2021

No, you are not right. The issue is at the protocol level. The mysql protocol does not allow for multiple queries executing at the same time on a single socket. Which why we are using connection pooling.

@kelunik
Copy link
Member

kelunik commented Jul 23, 2021

@bwoebi one query per connection is fine, an exposed socket would still be useful to avoid the userland protocol implementation.

@dbalabka
Copy link
Contributor

dbalabka commented Jul 23, 2021

@bwoebi the reason why I'm asking is that recently I've found that MySql 8 client library supports async queries:

https://dev.mysql.com/doc/c-api/8.0/en/c-api-asynchronous-interface.html

Does it might mean that MySQL protocol supports async queries now?

@dbalabka
Copy link
Contributor

dbalabka commented Aug 9, 2021

Answering my previous question. Obviously, MySQL binary protocol is sync, so nothing changed, the C client just works with the connection pool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants