8.3devel BUG with Cash send and recv - Mailing list pgsql-bugs

From Andrew Chernow
Subject 8.3devel BUG with Cash send and recv
Date
Msg-id 46C8A3A1.9010203@esilo.com
Whole thread Raw
List pgsql-bugs
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

pgsql-bugs by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: BUG #3555: does not work VACUUM
Next
From: "Ruediger Kemmler"
Date:
Subject: BUG #3556: Installroutine hides destination folder