summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/components/sqldb/pgsql.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/trunk/components/sqldb/pgsql.hpp')
-rw-r--r--sca-cpp/trunk/components/sqldb/pgsql.hpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/sca-cpp/trunk/components/sqldb/pgsql.hpp b/sca-cpp/trunk/components/sqldb/pgsql.hpp
index 7dca38b086..df9b2724ff 100644
--- a/sca-cpp/trunk/components/sqldb/pgsql.hpp
+++ b/sca-cpp/trunk/components/sqldb/pgsql.hpp
@@ -63,7 +63,7 @@ public:
debug(table, "pgsql::pgsql::table");
conn = PQconnectdb(c_str(conninfo));
if (PQstatus(conn) != CONNECTION_OK) {
- mkfailure<bool>(string("Could not connect to postgresql database: ") + PQerrorMessage(conn));
+ mkfailure<bool>(string("Couldn't connect to postgresql database: ") + PQerrorMessage(conn));
return;
}
setup(true);
@@ -106,7 +106,7 @@ private:
debug("pgsql::setup::reset");
PQreset(conn);
if (PQstatus(conn) != CONNECTION_OK)
- return mkfailure<bool>(string("Could not reconnect to postgresql database: ") + PQerrorMessage(conn));
+ return mkfailure<bool>(string("Couldn't reconnect to postgresql database: ") + PQerrorMessage(conn));
}
debug("pgsql::setup::init");
@@ -115,10 +115,10 @@ private:
string ks = string("select a.attname from pg_attribute a, pg_class c where a.attrelid = c.relfilenode and c.relname = '") + table + string("' and a.attnum in (1, 2) order by a.attnum;");
PGresult* kr = PQexec(conn, c_str(ks));
if (PQresultStatus(kr) != PGRES_TUPLES_OK)
- return mkfailure<bool>(string("Could not execute postgresql column select statement: ") + pgfailure(kr, conn));
+ return mkfailure<bool>(string("Couldn't execute postgresql column select statement: ") + pgfailure(kr, conn));
if (PQntuples(kr) != 2) {
PQclear(kr);
- return mkfailure<bool>(string("Could not find postgresql table key and value column names"));
+ return mkfailure<bool>(string("Couldn't find postgresql table key and value column names"));
}
const string kname = PQgetvalue(kr, 0, 0);
const string vname = PQgetvalue(kr, 1, 0);
@@ -128,25 +128,25 @@ private:
{
PGresult* r = PQprepare(conn, "post", c_str(string("insert into ") + table + string(" values($1, $2);")), 2, NULL);
if (PQresultStatus(r) != PGRES_COMMAND_OK)
- return mkfailure<bool>(string("Could not prepare post postgresql SQL statement: ") + pgfailure(r, conn));
+ return mkfailure<bool>(string("Couldn't prepare post postgresql SQL statement: ") + pgfailure(r, conn));
PQclear(r);
}
{
PGresult* r = PQprepare(conn, "put", c_str(string("update ") + table + string(" set ") + vname + string(" = $2 where ") + kname + string(" = $1;")), 2, NULL);
if (PQresultStatus(r) != PGRES_COMMAND_OK)
- return mkfailure<bool>(string("Could not prepare put postgresql SQL statement: ") + pgfailure(r, conn));
+ return mkfailure<bool>(string("Couldn't prepare put postgresql SQL statement: ") + pgfailure(r, conn));
PQclear(r);
}
{
PGresult* r = PQprepare(conn, "get", c_str(string("select * from ") + table + string(" where ") + kname + string(" = $1;")), 1, NULL);
if (PQresultStatus(r) != PGRES_COMMAND_OK)
- return mkfailure<bool>(string("Could not prepare get postgresql SQL statement: ") + pgfailure(r, conn));
+ return mkfailure<bool>(string("Couldn't prepare get postgresql SQL statement: ") + pgfailure(r, conn));
PQclear(r);
}
{
PGresult* r = PQprepare(conn, "delete", c_str(string("delete from ") + table + string(" where ") + kname + string(" = $1;")), 1, NULL);
if (PQresultStatus(r) != PGRES_COMMAND_OK)
- return mkfailure<bool>(string("Could not prepare delete postgresql SQL statement: ") + pgfailure(r, conn));
+ return mkfailure<bool>(string("Couldn't prepare delete postgresql SQL statement: ") + pgfailure(r, conn));
PQclear(r);
}
return true;
@@ -175,7 +175,7 @@ const failable<bool> post(const value& key, const value& val, const PGSql& pgsql
const char* params[2] = { c_str(ks), c_str(vs) };
PGresult* r = PQexecPrepared(pgsql.conn, "post", 2, params, NULL, NULL, 0);
if (PQresultStatus(r) != PGRES_COMMAND_OK)
- return mkfailure<bool>(string("Could not execute insert postgresql SQL statement: ") + pgfailure(r, pgsql.conn));
+ return mkfailure<bool>(string("Couldn't execute insert postgresql SQL statement: ") + pgfailure(r, pgsql.conn));
PQclear(r);
debug(true, "pgsql::post::result");
@@ -197,7 +197,7 @@ const failable<bool> put(const value& key, const value& val, const PGSql& pgsql)
const char* params[2] = { c_str(ks), c_str(vs) };
PGresult* r = PQexecPrepared(pgsql.conn, "put", 2, params, NULL, NULL, 0);
if (PQresultStatus(r) != PGRES_COMMAND_OK)
- return mkfailure<bool>(string("Could not execute update postgresql SQL statement: ") + pgfailure(r, pgsql.conn));
+ return mkfailure<bool>(string("Couldn't execute update postgresql SQL statement: ") + pgfailure(r, pgsql.conn));
const string t = PQcmdTuples(r);
if (t != "0") {
PQclear(r);
@@ -208,7 +208,7 @@ const failable<bool> put(const value& key, const value& val, const PGSql& pgsql)
PGresult* pr = PQexecPrepared(pgsql.conn, "post", 2, params, NULL, NULL, 0);
if (PQresultStatus(pr) != PGRES_COMMAND_OK)
- return mkfailure<bool>(string("Could not execute insert postgresql SQL statement: ") + pgfailure(pr, pgsql.conn));
+ return mkfailure<bool>(string("Couldn't execute insert postgresql SQL statement: ") + pgfailure(pr, pgsql.conn));
PQclear(pr);
debug(true, "pgsql::put::result");
@@ -228,10 +228,10 @@ const failable<value> get(const value& key, const PGSql& pgsql) {
const char* params[1] = { c_str(ks) };
PGresult* r = PQexecPrepared(pgsql.conn, "get", 1, params, NULL, NULL, 0);
if (PQresultStatus(r) != PGRES_TUPLES_OK)
- return mkfailure<value>(string("Could not execute select postgresql SQL statement: ") + pgfailure(r, pgsql.conn));
+ return mkfailure<value>(string("Couldn't execute select postgresql SQL statement: ") + pgfailure(r, pgsql.conn));
if (PQntuples(r) < 1) {
PQclear(r);
- return mkfailure<value>(string("Could not get postgresql entry: ") + PQerrorMessage(pgsql.conn));
+ return mkfailure<value>(string("Couldn't get postgresql entry: ") + PQerrorMessage(pgsql.conn));
}
const char* data = PQgetvalue(r, 0, 1);
const value val(scheme::readValue(string(data)));
@@ -254,7 +254,7 @@ const failable<bool> del(const value& key, const PGSql& pgsql) {
const char* params[1] = { c_str(ks) };
PGresult* r = PQexecPrepared(pgsql.conn, "delete", 1, params, NULL, NULL, 0);
if (PQresultStatus(r) != PGRES_COMMAND_OK)
- return mkfailure<bool>(string("Could not execute delete postgresql SQL statement: ") + pgfailure(r, pgsql.conn));
+ return mkfailure<bool>(string("Couldn't execute delete postgresql SQL statement: ") + pgfailure(r, pgsql.conn));
PQclear(r);
debug(true, "pgsql::delete::result");