Bug #21500 Indirect parameters for prepared statmets
Submitted: 8 Aug 2006 10:41
Reporter: Duncan Simpson Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:5.0 OS:Linux (Linux (but n/a))
Assigned to: CPU Architecture:Any
Tags: libpq, mysql_stmt_bind_param, prepared statement
Triage: D5 (Feature request)

[8 Aug 2006 10:41] Duncan Simpson
Description:
It would be nice if I could write code could along the lines of
<... create statmemt, prepare query, etc...>
MYSQL_BIND p;
MYSQL_STMT pq;
const char *s;
<... bind paramaters and think ...>
p.buffer_type=MYSQL_VAR_STRING | MYSQL_INDIRECT
p.buffer=&s;
<... process result ...>
mysql_bind_param(pq, &p);
<... process result ...>
s="halmet";
mysql_execute(pq);
<... process result ...>
s="brutus";
mysql_execute(pq);

The effect of the MYSQL_INDIRECT in the above be to tell libpq that the buffer points to a pointer to the data, not the data itself. I actually want this fir restoring strings into a database, where there is not necessaily any sensible maximum string length and the data is avialable in memory. Duplicating data just increases memory cosumption, reduces performance and set your code up for buffer overrun exploits.

P.S. Yes, I know that just calling mysql_stmt_bind_param again works, but that is easier to miss and less elegant than MYSQL_INDIRECT IMHO.

How to repeat:
Not applicable.