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) {


 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?



  • Options
    Hi As far i recall their is no netive precomplier suport in vertica
  • Options
    Thank you for the answer, but I did not understand it. What is "netive precomplier"? My question was about connecting to Vertica from C++, and passing parameters. I still need help.
  • Options
    I think your only option in C++ is to use ODBC 
  • Options
    ODBC is not the most efficient, and a lower level interface such as libpq is desired. Afaik Vertica is based on Postgres, and libpq should be working as is. However, question is if/how different libpq for Vertica? My tests show that almost all features are working via standard libpq. Can someone help to figure out issue with passing parameters? Thanks!
  • Options
    Hi Kinstantin,

    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.


Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file