summaryrefslogtreecommitdiff
path: root/libpqpp/command.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libpqpp/command.cpp')
-rw-r--r--libpqpp/command.cpp32
1 files changed, 2 insertions, 30 deletions
diff --git a/libpqpp/command.cpp b/libpqpp/command.cpp
index 419d953..6edc090 100644
--- a/libpqpp/command.cpp
+++ b/libpqpp/command.cpp
@@ -6,14 +6,13 @@
static std::string addrStr(void * p, unsigned int no) {
std::string r;
r.resize(30);
- r.resize(snprintf(const_cast<char *>(r.c_str()), 30, "pStatement-%u-%p", no, p));
+ r.resize(snprintf(const_cast<char *>(r.c_str()), 30, "pStatement_%u_%p", no, p));
return r;
}
PQ::Command::Command(const Connection * conn, const std::string & sql, unsigned int no) :
DB::Command(sql),
stmntName(addrStr(this, no)),
- prepared(false),
c(conn)
{
}
@@ -26,34 +25,6 @@ PQ::Command::~Command()
}
void
-PQ::Command::prepare() const
-{
- if (!prepared) {
- std::string psql;
- 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 == '?' && !inquote) {
- snprintf(buf, 4, "$%d", p++);
- psql += buf;
- }
- else if (*i == '\'') {
- inquote = !inquote;
- psql += *i;
- }
- else {
- psql += *i;
- }
- }
- c->checkResultFree(PQprepare(
- c->conn, stmntName.c_str(), psql.c_str(), values.size(), NULL), PGRES_COMMAND_OK);
- prepared = true;
- }
-}
-
-void
PQ::Command::paramsAtLeast(unsigned int n)
{
if (values.size() <= n) {
@@ -63,6 +34,7 @@ PQ::Command::paramsAtLeast(unsigned int n)
}
else {
free(values[n]);
+ values[n] = NULL;
}
}