On 8/31/07, Tom Lane <[EMAIL PROTECTED]> wrote:
> Andrew Dunstan <[EMAIL PROTECTED]> writes:
> > Here's a patch (minus catalog bump) which I think does that.
>
> Looks sane in a very quick once-over, but I didn't test it.

works fine (here was my test). thanks for quick resolution to this
issue. strings returned in binary format is IMO ok.

enum.c:
include "libpq-fe.h"
#include "string.h"
#include <stdlib.h>


int main(int argc, char **argv)
{
  PGconn *c = PQconnectdb("user=postgres");
  PGresult *r;
  r = PQexecParams(c, "select 'foo'::foo", 0, NULL, NULL, NULL, NULL, 1);

  ExecStatusType t = PQresultStatus(r);

  if(t != PGRES_COMMAND_OK & t != PGRES_TUPLES_OK)
  {
    printf("%s", PQresultErrorMessage(r));
    exit(1);
  }

  char* f = PQgetvalue(r,0,0);
  int len = 3;
  int format = 1;
  PQclear(r);

  r = PQexecParams(c, "select $1::foo", 1, NULL, (const char* const
*)&f, &len, &format, 1);

  if(t != PGRES_COMMAND_OK & t != PGRES_TUPLES_OK)
  {
    printf("%s", PQresultErrorMessage(r));
    exit(1);
  }

  PQfinish(c);
}

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

                http://www.postgresql.org/about/donate

Reply via email to