88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.139 2005/07/2203:46:34 momjian Exp $
11+ * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.140 2005/07/2215:15:38 momjian Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -3944,11 +3944,13 @@ timestamp_zone(PG_FUNCTION_ARGS)
39443944PG_RETURN_TIMESTAMPTZ (timestamp );
39453945
39463946/* Find the specified timezone? */
3947- len = (VARSIZE (zone )- VARHDRSZ > TZ_STRLEN_MAX )?TZ_STRLEN_MAX :(VARSIZE (zone )- VARHDRSZ );
3948- memcpy (tzname ,VARDATA (zone ),len );
3947+ len = (VARSIZE (zone )- VARHDRSZ > TZ_STRLEN_MAX ) ?
3948+ TZ_STRLEN_MAX :VARSIZE (zone )- VARHDRSZ ;
3949+ memcpy (tzname ,VARDATA (zone ),len );
39493950tzname [len ]= 0 ;
39503951tzp = pg_tzset (tzname );
3951- if (!tzp ) {
3952+ if (!tzp )
3953+ {
39523954ereport (ERROR ,
39533955(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
39543956errmsg ("time zone \"%s\" not recognised" ,
@@ -3958,15 +3960,16 @@ timestamp_zone(PG_FUNCTION_ARGS)
39583960
39593961/* Apply the timezone change */
39603962if (timestamp2tm (timestamp ,& tz ,& tm ,& fsec ,NULL ,tzp )!= 0 ||
3961- tm2timestamp (& tm ,fsec ,NULL ,& result )!= 0 ) {
3963+ tm2timestamp (& tm ,fsec ,NULL ,& result )!= 0 )
3964+ {
39623965ereport (ERROR ,
39633966(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
39643967errmsg ("could not convert to time zone \"%s\"" ,
39653968tzname )));
39663969PG_RETURN_NULL ();
39673970}
39683971PG_RETURN_TIMESTAMPTZ (timestamp2timestamptz (result ));
3969- }/* timestamp_zone() */
3972+ }
39703973
39713974/* timestamp_izone()
39723975 * Encode timestamp type with specified time interval as time zone.
@@ -4022,7 +4025,6 @@ timestamp2timestamptz(Timestamp timestamp)
40224025
40234026if (TIMESTAMP_NOT_FINITE (timestamp ))
40244027result = timestamp ;
4025-
40264028else
40274029{
40284030if (timestamp2tm (timestamp ,NULL ,tm ,& fsec ,NULL ,NULL )!= 0 )
@@ -4057,7 +4059,6 @@ timestamptz_timestamp(PG_FUNCTION_ARGS)
40574059
40584060if (TIMESTAMP_NOT_FINITE (timestamp ))
40594061result = timestamp ;
4060-
40614062else
40624063{
40634064if (timestamp2tm (timestamp ,& tz ,tm ,& fsec ,& tzn ,NULL )!= 0 )
@@ -4082,7 +4083,6 @@ timestamptz_zone(PG_FUNCTION_ARGS)
40824083text * zone = PG_GETARG_TEXT_P (0 );
40834084TimestampTz timestamp = PG_GETARG_TIMESTAMPTZ (1 );
40844085Timestamp result ;
4085-
40864086int tz ;
40874087pg_tz * tzp ;
40884088char tzname [TZ_STRLEN_MAX ];
@@ -4094,12 +4094,14 @@ timestamptz_zone(PG_FUNCTION_ARGS)
40944094PG_RETURN_NULL ();
40954095
40964096/* Find the specified zone */
4097- len = (VARSIZE (zone )- VARHDRSZ > TZ_STRLEN_MAX )?TZ_STRLEN_MAX :(VARSIZE (zone )- VARHDRSZ );
4098- memcpy (tzname ,VARDATA (zone ),len );
4097+ len = (VARSIZE (zone )- VARHDRSZ > TZ_STRLEN_MAX ) ?
4098+ TZ_STRLEN_MAX :VARSIZE (zone )- VARHDRSZ ;
4099+ memcpy (tzname ,VARDATA (zone ),len );
40994100tzname [len ]= 0 ;
41004101tzp = pg_tzset (tzname );
41014102
4102- if (!tzp ) {
4103+ if (!tzp )
4104+ {
41034105ereport (ERROR ,
41044106(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
41054107errmsg ("time zone \"%s\" not recognized" ,tzname )));
@@ -4108,15 +4110,16 @@ timestamptz_zone(PG_FUNCTION_ARGS)
41084110}
41094111
41104112if (timestamp2tm (timestamp ,& tz ,& tm ,& fsec ,NULL ,tzp )!= 0 ||
4111- tm2timestamp (& tm ,fsec ,NULL ,& result )) {
4113+ tm2timestamp (& tm ,fsec ,NULL ,& result ))
4114+ {
41124115ereport (ERROR ,
41134116(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
41144117errmsg ("could not to convert to time zone \"%s\"" ,tzname )));
41154118PG_RETURN_NULL ();
41164119}
41174120
41184121PG_RETURN_TIMESTAMP (result );
4119- }/* timestamptz_zone() */
4122+ }
41204123
41214124/* timestamptz_izone()
41224125 * Encode timestamp with time zone type with specified time interval as time zone.
@@ -4149,4 +4152,4 @@ timestamptz_izone(PG_FUNCTION_ARGS)
41494152result = dt2local (timestamp ,tz );
41504153
41514154PG_RETURN_TIMESTAMP (result );
4152- }/* timestamptz_izone() */
4155+ }