Connecting to Vertica via libpq
I'm developing a C++ program for Vertica 6 on Windows/MSVC. I'm using libpq compiled off the Postgres 9 source. Connection and simple statements are working fine. But when I try to pass a parameter, I'm getting: "ERROR: Insufficient data left in message".
Here is code:
string sCommandText("SELECT * FROM columns WHERE table_name=?");
char preparedQueryName[16] = "q1234567890abcd";
PQresult* res = ::PQprepare(conn, preparedQueryName, sCommandText.c_str(), nParams, paramTypes);
if (::PQresultStatus(res) == PGRES_COMMAND_OK || strcmp(::PQresultErrorField(res, PG_DIAG_SQLSTATE), "42P05") == 0) {
::PQclear(res);
res = ::PQexecPrepared(conn, preparedQueryName, nParams, paramValues, paramLengths, paramFormats);
}
Can libpq from Postgres be used for Vertica, or should I use special libpq designed for Vertica?
Thanks!
Here is code:
string sCommandText("SELECT * FROM columns WHERE table_name=?");
char preparedQueryName[16] = "q1234567890abcd";
PQresult* res = ::PQprepare(conn, preparedQueryName, sCommandText.c_str(), nParams, paramTypes);
if (::PQresultStatus(res) == PGRES_COMMAND_OK || strcmp(::PQresultErrorField(res, PG_DIAG_SQLSTATE), "42P05") == 0) {
::PQclear(res);
res = ::PQexecPrepared(conn, preparedQueryName, nParams, paramValues, paramLengths, paramFormats);
}
Can libpq from Postgres be used for Vertica, or should I use special libpq designed for Vertica?
Thanks!
0
Comments
While certain pieces of Vertica's client/server protocol are very similar to those of PostgreSQL, some of them are not. We have not publicly documented our client/server protocol, but I will say that several pieces of it are significantly different from that of PostgreSQL, and that describing our protocol as being based on that of PostgreSQL is no longer as accurate as it once was.
I'm not in a position to comment on third-party drivers generally; what exists, what's permitted, etc. I personally think they're cool. But I don't have to deal with the headaches that they create :-) (It's difficult to correctly reverse-engineer any protocol; there are always bugs in the attempt, and there are a surprising number of people out there who will insist that we learn about and fix anything that says "Vertica" on it, whether or not we wrote it or even have access to the code...)
That said, I don't think it would be a technical impossibility to retrofit libpg for Vertica; but I think it'd take some work to get it right.
Adam