in reply to Re^2: sockets mysql and recv
in thread sockets mysql and recv

Wild guess: your problem is that you don't have the libmysqlclient development files installed. Search for a package named libmysqlclient-dev or something like that.

Replies are listed 'Best First'.
Re^4: sockets mysql and recv
by oddmedley (Novice) on Dec 03, 2006 at 00:35 UTC
    from what I've read you need mysql, perl and DBD::mysql all to be compiled with the same compiler. For me that's a hassle. I have loads of perl modules installed and would hate to have to go through all that again, plus mysql takes an age to install from source. If I could just compile the source to make libmysqlclient.a, then perhaps that would be worth a go, but not sure how to do that (did give it a go).

    Anyway, I've had a tinker with Net::MySQL and it seems the query results (got from the 1st recv() call) from the query causing problems for the 2nd recv() call are less that 512 bytes, while those that are from working queries on non-empty tables are more than 512 bytes.. aha! I thought, let's just test the length of the first recieved data from the socket and not try and get more if it's less than 512 bytes.

    Well that's what I tried and to my pleasant surprise it actually seems to work! I've tested it for queries that should return a single row with a single int column as well as various others and they all appear to work fine, and the problem with SELECT from empty tables is fixed! :)

    I realize this is a very dodgy solution without knowing exactly what the size of the 1st returned data from mysql depends on. I would prefer to know why recv is hanging and also exactly how to tell when mysql has finished sending a result (I did search through the docs and/or source for mysql, socket, IO::socket and even mysql++ for clues but couldn't find any)... so more ideas welcome!

    (if anyone is interested in my simple (and possibly disaster inviting) tweak to Net::MySQL)

    sub _get_record_by_server { my $self = shift; my $packet = shift; my $mysql = $self->{socket}; $self->_get_column_length($packet); if(length($packet) >= 512 ){ # added while ($self->_has_next_packet($packet)) { my $next_result; $mysql->recv($next_result, BUFFER_LENGTH, 0); $packet .= $next_result; $self->_dump_packet($next_result) if Net::MySQL->debug; } } # added $self->{selected_record} = $packet; }