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

Insert max UInt64 #80

Closed
simPod opened this issue Aug 1, 2018 · 5 comments
Closed

Insert max UInt64 #80

simPod opened this issue Aug 1, 2018 · 5 comments

Comments

@simPod
Copy link
Contributor

simPod commented Aug 1, 2018

How do you insert 18446744073709551615 value to column of type UInt64? Thx

@isublimity
Copy link
Contributor

isublimity commented Aug 2, 2018

I think it's not easy to decide ;(
There is a system limitation is PHP_INT_MAX = 9223372036854775807
If variable more than PHP auto convert to Float : Integer overflow on a 64-bit system
http://php.net/manual/en/language.types.integer.php

https://stackoverflow.com/questions/34033575/is-it-possible-to-use-a-large-unsigned-int64-without-losing-precision-in-php

https://stackoverflow.com/questions/864058/how-to-have-64-bit-integer-on-php

Try use direct write gmp_strval and $client->transport()->write('INSERT INTO ')

$client = new ClickHouseDB\Client($config);
$client->write('DROP TABLE IF EXISTS _phpCh_UINT64Test');
$client->write('CREATE TABLE _phpCh_UINT64Test (ui64 UInt64) Engine=Log');

//
$value="18446744073709551615"; // WARN! STRING !
//
$client->transport()->write('INSERT INTO _phpCh_UINT64Test VALUES ( '.gmp_strval($value).' )');
echo "insert done\n";
print_r($client->select('SELECT ui64 FROM _phpCh_UINT64Test')->rows());


@simPod
Copy link
Contributor Author

simPod commented Aug 2, 2018

I'm preparing a PR with friendlier approach. I just wanted to check whether you have stumbled upon this and have solution or not. Thanks!

I'd leave this open until that PR submission.

@isublimity
Copy link
Contributor

@simPod Clouse issue - "as an unsolvable" ?

@simPod
Copy link
Contributor Author

simPod commented Sep 24, 2018 via email

@isublimity
Copy link
Contributor

Good work! Thx!

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

No branches or pull requests

2 participants