~ubuntu-branches/ubuntu/natty/postgresql-8.4/natty-security

« back to all changes in this revision

Viewing changes to src/backend/utils/adt/date.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-11 16:59:35 UTC
  • mfrom: (5.1.1 karmic)
  • Revision ID: james.westby@ubuntu.com-20090711165935-jfwin6gfrxf0gfsi
Tags: 8.4.0-2
* debian/libpq-dev.install: Ship catalog/genbki.h. (Closes: #536139)
* debian/rules: Drop --enable-cassert for final release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 *
9
9
 *
10
10
 * IDENTIFICATION
11
 
 *        $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.144 2009/01/01 17:23:49 momjian Exp $
 
11
 *        $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.146 2009/06/11 14:49:03 momjian Exp $
12
12
 *
13
13
 *-------------------------------------------------------------------------
14
14
 */
231
231
                strcpy(str, EARLY);
232
232
        else if (DATE_IS_NOEND(dt))
233
233
                strcpy(str, LATE);
234
 
        else                                            /* shouldn't happen */
 
234
        else    /* shouldn't happen */
235
235
                elog(ERROR, "invalid argument for EncodeSpecialDate");
236
236
}
237
237
 
1088
1088
 
1089
1089
#ifdef HAVE_INT64_TIMESTAMP
1090
1090
        result = pq_getmsgint64(buf);
 
1091
 
 
1092
        if (result < INT64CONST(0) || result > USECS_PER_DAY)
 
1093
                ereport(ERROR,
 
1094
                                (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
 
1095
                                 errmsg("time out of range")));
1091
1096
#else
1092
1097
        result = pq_getmsgfloat8(buf);
 
1098
 
 
1099
        if (result < 0 || result > (double) SECS_PER_DAY)
 
1100
                ereport(ERROR,
 
1101
                                (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
 
1102
                                 errmsg("time out of range")));
1093
1103
#endif
1094
1104
 
1095
1105
        AdjustTimeForTypmod(&result, typmod);
1853
1863
 
1854
1864
#ifdef HAVE_INT64_TIMESTAMP
1855
1865
        result->time = pq_getmsgint64(buf);
 
1866
 
 
1867
        if (result->time < INT64CONST(0) || result->time > USECS_PER_DAY)
 
1868
                ereport(ERROR,
 
1869
                                (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
 
1870
                                 errmsg("time out of range")));
1856
1871
#else
1857
1872
        result->time = pq_getmsgfloat8(buf);
 
1873
 
 
1874
        if (result->time < 0 || result->time > (double) SECS_PER_DAY)
 
1875
                ereport(ERROR,
 
1876
                                (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
 
1877
                                 errmsg("time out of range")));
1858
1878
#endif
 
1879
 
1859
1880
        result->zone = pq_getmsgint(buf, sizeof(result->zone));
1860
1881
 
 
1882
        /* we allow GMT displacements up to 14:59:59, cf DecodeTimezone() */
 
1883
        if (result->zone <= -15 * SECS_PER_HOUR ||
 
1884
                result->zone >= 15 * SECS_PER_HOUR)
 
1885
                ereport(ERROR,
 
1886
                                (errcode(ERRCODE_INVALID_TIME_ZONE_DISPLACEMENT_VALUE),
 
1887
                                 errmsg("time zone displacement out of range")));
 
1888
 
1861
1889
        AdjustTimeForTypmod(&(result->time), typmod);
1862
1890
 
1863
1891
        PG_RETURN_TIMETZADT_P(result);
2524
2552
        pg_tz      *tzp;
2525
2553
 
2526
2554
        /*
2527
 
         * Look up the requested timezone.  First we look in the date token table
 
2555
         * Look up the requested timezone.      First we look in the date token table
2528
2556
         * (to handle cases like "EST"), and if that fails, we look in the
2529
2557
         * timezone database (to handle cases like "America/New_York").  (This
2530
2558
         * matches the order in which timestamp input checks the cases; it's