mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
Tigthen binary receive functions so that they reject values that the text
input functions don't accept either. While the backend can handle such values fine, they can cause trouble in clients and in pg_dump/restore. This is followup to the original issue on time datatype reported by Andrew McNamara a while ago. Like that one, none of these seem worth back-patching.
This commit is contained in:
@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.161 2009/06/11 14:49:03 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.162 2009/09/04 11:20:22 heikki Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -786,20 +786,25 @@ tintervalrecv(PG_FUNCTION_ARGS)
|
||||
{
|
||||
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
|
||||
TimeInterval tinterval;
|
||||
int32 status;
|
||||
|
||||
tinterval = (TimeInterval) palloc(sizeof(TimeIntervalData));
|
||||
|
||||
tinterval->status = pq_getmsgint(buf, sizeof(tinterval->status));
|
||||
tinterval->data[0] = pq_getmsgint(buf, sizeof(tinterval->data[0]));
|
||||
tinterval->data[1] = pq_getmsgint(buf, sizeof(tinterval->data[1]));
|
||||
|
||||
if (!(tinterval->status == T_INTERVAL_INVAL ||
|
||||
tinterval->status == T_INTERVAL_VALID))
|
||||
if (tinterval->data[0] == INVALID_ABSTIME ||
|
||||
tinterval->data[1] == INVALID_ABSTIME)
|
||||
status = T_INTERVAL_INVAL; /* undefined */
|
||||
else
|
||||
status = T_INTERVAL_VALID;
|
||||
|
||||
if (status != tinterval->status)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||
errmsg("invalid status in external \"tinterval\" value")));
|
||||
|
||||
tinterval->data[0] = pq_getmsgint(buf, sizeof(tinterval->data[0]));
|
||||
tinterval->data[1] = pq_getmsgint(buf, sizeof(tinterval->data[1]));
|
||||
|
||||
PG_RETURN_TIMEINTERVAL(tinterval);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user