Patch to correct 64-bit money type in 8.3devel

From: Andrew Chernow <ac(at)esilo(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: Patch to correct 64-bit money type in 8.3devel
Date: 2007-08-20 14:24:17
Message-ID: 46C9A411.6090103@esilo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Attached is a patch for the 8.3devel 64-bit money type. Bug reported
here: http://archives.postgresql.org/pgsql-bugs/2007-08/msg00137.php.

Run the test program included in the bug report to see the issue. Then
apply patch and run the test again.

Andrew Chernow

Index: src/backend/utils/adt/cash.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/adt/cash.c,v
retrieving revision 1.71
diff -c -C6 -r1.71 cash.c
*** src/backend/utils/adt/cash.c 12 Jul 2007 23:51:10 -0000 1.71
--- src/backend/utils/adt/cash.c 20 Aug 2007 14:10:44 -0000
***************
*** 369,394 ****
*/
Datum
cash_recv(PG_FUNCTION_ARGS)
{
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);

! PG_RETURN_CASH((Cash) pq_getmsgint(buf, sizeof(Cash)));
}

/*
* cash_send - converts cash to
binary format
*/
Datum
cash_send(PG_FUNCTION_ARGS)
{
Cash arg1 = PG_GETARG_CASH(0);
StringInfoData buf;

pq_begintypsend(&buf);
! pq_sendint(&buf, arg1, sizeof(Cash));
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}

/*
* Comparison functions
*/
--- 369,394 ----
*/
Datum
cash_recv(PG_FUNCTION_ARGS)
{
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);

! PG_RETURN_CASH((Cash) pq_getmsgint64(buf));
}

/*
* cash_send - converts cash to
binary format
*/
Datum
cash_send(PG_FUNCTION_ARGS)
{
Cash arg1 = PG_GETARG_CASH(0);
StringInfoData buf;

pq_begintypsend(&buf);
! pq_sendint64(&buf, arg1);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}

/*
* Comparison functions
*/

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2007-08-20 14:46:24 Re: HOT patch - version 14
Previous Message Heikki Linnakangas 2007-08-20 14:16:08 Re: HOT patch - version 14