diff options
author | randomdan <randomdan@localhost> | 2011-02-13 21:02:18 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2011-02-13 21:02:18 +0000 |
commit | c94daa95e01e9b8d4c941e344268b8d7bdc4b688 (patch) | |
tree | 6141d4fc0570fdfd2c2640316f5efefb4a39009f /libpqpp | |
parent | Minor tweaks to improve perforamce on PG bulk deletes (diff) | |
download | libdbpp-postgresql-c94daa95e01e9b8d4c941e344268b8d7bdc4b688.tar.bz2 libdbpp-postgresql-c94daa95e01e9b8d4c941e344268b8d7bdc4b688.tar.xz libdbpp-postgresql-c94daa95e01e9b8d4c941e344268b8d7bdc4b688.zip |
Fixed handling of ?s in string literals
Diffstat (limited to 'libpqpp')
-rw-r--r-- | libpqpp/command.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libpqpp/command.cpp b/libpqpp/command.cpp index 7617bd1..a7dd1fd 100644 --- a/libpqpp/command.cpp +++ b/libpqpp/command.cpp @@ -33,11 +33,16 @@ PQ::Command::prepare() const psql.reserve(sql.length() + 20); char buf[4]; int p = 1; + bool inquote = false; for(std::string::const_iterator i = sql.begin(); i != sql.end(); i++) { - if (*i == '?') { + if (*i == '?' && !inquote) { snprintf(buf, 4, "$%d", p++); psql += buf; } + else if (*i == '\'') { + inquote = !inquote; + psql += *i; + } else { psql += *i; } |