1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-06 07:49:08 +03:00

Change typreceive function API so that receive functions get the same

optional arguments as text input functions, ie, typioparam OID and
atttypmod.  Make all the datatypes that use typmod enforce it the same
way in typreceive as they do in typinput.  This fixes a problem with
failure to enforce length restrictions during COPY FROM BINARY.
This commit is contained in:
Tom Lane
2005-07-10 21:14:00 +00:00
parent 2e330699fa
commit d78397d301
18 changed files with 333 additions and 144 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.110 2005/06/15 00:34:08 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.111 2005/07/10 21:13:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -982,12 +982,21 @@ Datum
time_recv(PG_FUNCTION_ARGS)
{
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 typmod = PG_GETARG_INT32(2);
TimeADT result;
#ifdef HAVE_INT64_TIMESTAMP
PG_RETURN_TIMEADT((TimeADT) pq_getmsgint64(buf));
result = pq_getmsgint64(buf);
#else
PG_RETURN_TIMEADT((TimeADT) pq_getmsgfloat8(buf));
result = pq_getmsgfloat8(buf);
#endif
AdjustTimeForTypmod(&result, typmod);
PG_RETURN_TIMEADT(result);
}
/*
@@ -1774,18 +1783,24 @@ Datum
timetz_recv(PG_FUNCTION_ARGS)
{
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
TimeTzADT *time;
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 typmod = PG_GETARG_INT32(2);
TimeTzADT *result;
time = (TimeTzADT *) palloc(sizeof(TimeTzADT));
result = (TimeTzADT *) palloc(sizeof(TimeTzADT));
#ifdef HAVE_INT64_TIMESTAMP
time->time = pq_getmsgint64(buf);
result->time = pq_getmsgint64(buf);
#else
time->time = pq_getmsgfloat8(buf);
result->time = pq_getmsgfloat8(buf);
#endif
time->zone = pq_getmsgint(buf, sizeof(time->zone));
result->zone = pq_getmsgint(buf, sizeof(result->zone));
PG_RETURN_TIMETZADT_P(time);
AdjustTimeForTypmod(&(result->time), typmod);
PG_RETURN_TIMETZADT_P(result);
}
/*