Issue information

Issue ID
#2858
Status
Working as Intended
Severity
None
Started
Hercules Elf Bot
Mar 12, 2009 17:15
Last Post
Hercules Elf Bot
Mar 12, 2009 17:15
Confirmation
N/A

Hercules Elf Bot - Mar 12, 2009 17:15

Originally posted by [b]theultramage[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=2858

I had a piece of code where I needed to construct an sql statement, which represented an INSERT query with a list of multiple rows to insert. Since the number entries to actually insert is not given in advance, I decided to construct the query string and bind the columns in parallel, and just prepare&execute the statement once everything is ready. Since binding calls do not actually interact with mysql code, this would be perfectly correct.

There is an obstacle in sql.c however.
CODE
/// Prepares the statement.
int SqlStmt_PrepareV(SqlStmt* self, const char* query, va_list args)
{
...
    self->bind_params = false;

    return SQL_SUCCESS;
}
Calling SqlStmt_Prepare() erases the information that there are params ready to be bound.
I do not believe this code behaves correctly. What is the purpose of that "self->bind_params = false;" line?