There is what looks like a bug in 8.3devel. When getting the money type in binary format from a libpq client, the below error is thrown from the backend:

ERROR:  unsupported integer size 8

It appears that the Cash typedef, defined in include/utils/cash.h, has changed to an int64 (previously an int32). The cash_send and cash_recv functions, in backend/utils/adt/cash.c, are still calling pq_sendint and pq_getmsgint.

I tested on an 8.2rc box and that did not suffer from this issue because it uses a 32-bit Cash type.

Below is a test to reproduce the issue.

create table money_test (amount money);
insert into money_test values ('13.85');

/* libpq test code (breaks on 8.3devel, works on 8.2rc) */
#include <libpq-fe.h>
#include <stdio.h>

int main(void)
{
  PGresult *res;
  PGconn *conn = PQconnectdb("hostaddr=127.0.0.1  user=postgres");

  if(PQstatus(conn) != CONNECTION_OK)
  {
    printf("connection failure\n");
    return 1;
  }

  res = PQexecParams(
    conn,
    "SELECT amount FROM money_test LIMIT 1",
    0,
    (const Oid *)NULL,
    (const char * const *)NULL,
    (const int *)NULL,
    (const int *)NULL,
    1); /* binary */

  printf("tuples=%d, err=%s, res_err=%s\n",
    PQntuples(res),
    PQerrorMessage(conn),
    PQresultErrorMessage(res));

  PQclear(res);
  PQfinish(conn);
  return 0;
}

andrew

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to