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

Unsupported SQL type NEWDECIMAL #39

Closed
punkUser opened this issue May 9, 2014 · 6 comments
Closed

Unsupported SQL type NEWDECIMAL #39

punkUser opened this issue May 9, 2014 · 6 comments

Comments

@punkUser
Copy link

punkUser commented May 9, 2014

Hi guys,

When I try to use a query with an aggregate function in the select list (notable "SUM(field)") it seems that MySQL tries to return it as a "NEWDECIMAL" type which mysql-native doesn't currently seem to support. For reference, my MySQL server version is "5.5.29-0ubuntu0.12.04.1".

As a test, I added the following to the switch statement in consumeIfComplete:
case SQLType.NEWDECIMAL:
return packet.consumeIfComplete!int(false, unsigned);
... which seems to work ok for my simple test case. I'm not sure if "long" or something else would be more appropriate here... the MySQL protocol docs on NEWDECIMAL are pretty sparse to say the least :)

Have I got some sort of weird config going on or is this a known issue? If so, is the above implementation legitimate?

Cheers!

@punkUser
Copy link
Author

Quick update - I changed this to "double" (instead of int) to handle cases where aggregates that return float values (ex. avg) are used. Still not 100% sure this is a proper solution but it has been working for me so far.

@bhechinger
Copy link

Task terminated with unhandled exception: Unsupported SQL type NEWDECIMAL

This is: mysql Ver 14.14 Distrib 5.6.20, for osx10.7 (x86_64) using EditLine wrapper

I'm not even sure where this is coming from since the table doesn't have NEWDECIMAL and I'm just doing 'SELECT * from [table]'!

Also, mysql-native is from ~master today.

@bhechinger
Copy link

A small amount of research shows that this was introduced in MySQL 5.0. The solution the MySQLdb python module folks did is here:

http://sourceforge.net/p/mysql-python/bugs/165/

Back in 2006. We should get this fixed ASAP and to that end I think punkUser's double is correct.

Abscissa pushed a commit to Abscissa/mysql-native that referenced this issue Oct 3, 2014
@Abscissa
Copy link

Abscissa commented Oct 3, 2014

I'm a little uneasy about the fix just because there appears to be basically no documentation on NEWDECIMAL to go by. But commit 4199dca appears to fix the issue (for me too, on my fresh new MariaDB 5.5 installation). So we should be good then.

@Abscissa Abscissa closed this as completed Oct 3, 2014
@bhechinger
Copy link

Yeah, I immediately started doing research after opening this and was just absolutely floored at how there was ZERO documentation on something they added 8+ years ago. It's borderline criminal.

Thanks for putting the patch in, this was a very large thorn in my side.

@Abscissa
Copy link

Abscissa commented Jun 6, 2017

While looking into #111 (which appears to be related to this), I managed to find some NEWDECIMAL documentation, thatnks to MariaDB:

https://mariadb.com/kb/en/mariadb/resultset-row/#decimal-binary-encoding

But based on that, I'm surprised that treating NEWDECIMAL as a DOUBLE ever worked at all. I'll have to look into that.

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

3 participants