Coder Social home page Coder Social logo

Comments (9)

medvednikov avatar medvednikov commented on May 30, 2024

I tried to fix (c *Conn) writeResultset, but it's not trivial.

r.Fields contains nil values [ <NIL> <NIL> <NIL> ], and then a Dump() is called on that.

from go-mysql.

medvednikov avatar medvednikov commented on May 30, 2024

I think I got it, can you have a look?

https://github.com/siddontang/go-mysql/pull/31/files

Thanks

from go-mysql.

siddontang avatar siddontang commented on May 30, 2024

Thanks @medvednikov

what's your test sql? or can you add this test like in go-mysql/client ?

from go-mysql.

medvednikov avatar medvednikov commented on May 30, 2024

Sorry, didn't make it clear that I was using the server package. I'm building a small MySQL proxy.

I had a look at server_test.go, you are always returning []interface{}{1, "hello world"}, so it's not possible to test empty results.

This is one of the possible queries:

select str, f, e from mixer_test_conn where false

from go-mysql.

siddontang avatar siddontang commented on May 30, 2024

Thanks, I will see it on weekend.

from go-mysql.

siddontang avatar siddontang commented on May 30, 2024

Hi @medvednikov
I found the problem in mysql/resultset_helper.go BuildSimpleTextResultset, if the resultset is empty, the field can't be made correctly.

So maybe the best way to build result fields is to retrieve these in table directly, not from return rows values. Your PR only ignores this error, but we will still get an invalid data, you can use a wireshark to test in real mysql and can see that if the rows is empty, we can still get correct fields response.

Sorry that I don't have any time to fix or improve this. 😭

from go-mysql.

medvednikov avatar medvednikov commented on May 30, 2024

Hi @siddontang
Thanks for debugging this.
With my fix I get Empty set (0.07 sec), the same response a real MySQL server sends me.
I don't know the MySQL protocol well enough to see what's missing there :)
If this PR doesn't break anything, could you please approve it, since it fixes our problem, and it would be nice not to have to maintain a fork.
Thanks

from go-mysql.

siddontang avatar siddontang commented on May 30, 2024

Hi @medvednikov

You should use wireshark to capture the mysql protocol, and you can see it.
Only using mysql client doesn't work.

from go-mysql.

siddontang avatar siddontang commented on May 30, 2024

I merge this, but maybe we could find a better way later.

from go-mysql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.