summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/date.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-07-10 21:14:00 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-07-10 21:14:00 +0000
commitd78397d301172cccce14d5d789f296c47dd47c5e (patch)
tree4104dc887976aee14286c0c0a7be03f84af43b7d /src/backend/utils/adt/date.c
parent2e330699fae72c40f5237ce0f4fc210c483d2816 (diff)
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.
Diffstat (limited to 'src/backend/utils/adt/date.c')
-rw-r--r--src/backend/utils/adt/date.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index abc6155594f..4f8f96075d9 100644
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -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));
+
+ AdjustTimeForTypmod(&(result->time), typmod);
- PG_RETURN_TIMETZADT_P(time);
+ PG_RETURN_TIMETZADT_P(result);
}
/*