List:Internals« Previous MessageNext Message »
From:Michael Widenius Date:June 18 2001 1:41pm
Subject:Anyone for a mysql_queryf()
View as plain text  
hi!

>>>>> "John" == John Birrell <jb@stripped> writes:

John> I thought it'd be convenient to have a printf style
John> query function to keep my client code simple, so I
John> looked at what this would involve.

John> Attached is a patch which implements this in the
John> embedded server code. Changes to the client/server
John> code are no big deal. The patch relies on vasprintf()
John> in the OS, so I guess a my_vasprintf() or something
John> would be required. [ FWIW, this patch also fixes the
John> last_errno/last_error bug I reported earlier ]

John> Is there any interest in adding this to the API
John> for 4.0?

Sorry no. The reason I don't want to add this is that this will not
work for parameters that contains binary \0 or strings that contains
', \ or "

Instead, I would like to add in 4.0 that one can dor 'prepared queries'
and send arguments in binary format.

This is not really difficult to do, the biggest change is to hack a
little in the client/server protocol.

The benefits would be:

- No need for quoting.
- Faster code (no conversion of numbers to strings and back)
- Make it easy to implement parameter handing in Perl and MyODBC.

John> I'd actually like to go one step further and pass in
John> a flag to dispatch_command to indicate if the
John> packet pointer has been allocated in this manner.
John> Then, for the embedded case only, there is no need
John> for dispatch_command to do a memdup - it can just
John> take ownership of the memory passed to it. No need
John> to slow it down doing a copy that isn't necessary.

There is a lot of things we can do much better in the client/server
protocol handling in the embedded client.

Tim should be working on cleaning up this part during the next month.

Regards,
Monty
Thread
Anyone for a mysql_queryf()John Birrell16 Jun
  • Re: Anyone for a mysql_queryf()Sinisa Milivojevic16 Jun
  • Re: Anyone for a mysql_queryf()Sasha Pachev16 Jun
    • Re: Anyone for a mysql_queryf()Michael Widenius18 Jun
  • Anyone for a mysql_queryf()Michael Widenius18 Jun