poggit / libasynql

Asynchronous MySQL access library for PocketMine plugins.
https://poggit.github.io/libasynql
Apache License 2.0
132 stars 44 forks source link

bccomp() type error on certain MySQL column types #45

Open Endermanbugzjfc opened 4 years ago

Endermanbugzjfc commented 4 years ago

Describe the bug

image

Fatal error: Uncaught TypeError: bccomp() expects parameter 1 to be string, int given in phar:///home/container/virions/libasynql.phar/src/poggit/libasynql/mysqli/MysqliThread.php:186
Stack trace:
#0 phar:///home/container/virions/libasynql.phar/src/poggit/libasynql/mysqli/MysqliThread.php(186): bccomp(1, '922337203685477...')
#1 phar:///home/container/virions/libasynql.phar/src/poggit/libasynql/mysqli/MysqliThread.php(224): poggit\libasynql\mysqli\MysqliThread->poggit\libasynql\mysqli\{closure}(1)
#2 phar:///home/container/virions/libasynql.phar/src/poggit/libasynql/mysqli/MysqliThread.php(155): poggit\libasynql\mysqli\MysqliThread->toSelectResult(Object(mysqli_result))
#3 phar:///home/container/virions/libasynql.phar/src/poggit/libasynql/base/SqlSlaveThread.php(85): poggit\libasynql\mysqli\MysqliThread->executeQuery(Object(mysqli), 3, 'SELECT record_i...', Array)
#4 [internal function]: poggit\libasynql\base\SqlSlaveThread->run()
#5 {main}
thrown in phar:///home/container/virions/libasynql.phar/src/poggit/libasynql/mysqli/MysqliThread.php on line 186

Sample code

-- #            { pre_registered
-- #              :username string
SELECT record_id
FROM pre_registered
WHERE username = :username
LIMIT 1;
-- #            }

Expected behavior

record_id is a unsigned bigint, the error didn't occur when no result is selected

Environment

OS: linux and idk other stuffs (Same result on Windows10) PocketMine version: 3.14.2 Libasynql version: 3.3.1

Endermanbugzjfc commented 4 years ago

Somehow fixed by setting record_id to unsigned int

SOF3 commented 4 years ago

This seems a bug indeed.

matcracker commented 3 years ago

Hi, I had the same problem today. ~Why is it necessary to manage precision? We shouldn't worry as we are using PHP 64-bit.~

Otherwise we need to use CONVERT function or use GMP extension but I don't think it's included in PocketMine binaries files.

matcracker commented 3 years ago

However, there would be a problem, int casting is not possible. We must therefore transform the value into a float.

SOF3 commented 3 years ago

unsigned longs?