Skip to content

Commit fbdb203

Browse files
committed
Back out part of patch that should be applied later.
1 parent 22f0303 commit fbdb203

File tree

3 files changed

+28
-25
lines changed

3 files changed

+28
-25
lines changed

src/backend/utils/adt/datetime.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.148 2005/05/27 15:15:23 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.149 2005/05/27 15:16:44 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -3461,9 +3461,12 @@ EncodeTimeOnly(struct pg_tm * tm, fsec_t fsec, int *tzp, int style, char *str)
34613461
#ifdef HAVE_INT64_TIMESTAMP
34623462
sprintf(str + strlen(str), ":%02d.%06d", tm->tm_sec, fsec);
34633463
#else
3464-
sprintf(str + strlen(str), ":%012.9f", tm->tm_sec + fsec);
3464+
sprintf(str + strlen(str), ":%013.10f", tm->tm_sec + fsec);
34653465
#endif
3466-
TrimTrailingZeros(str);
3466+
/* chop off trailing pairs of zeros... */
3467+
while (strcmp((str + strlen(str) - 2), "00") == 0 &&
3468+
*(str + strlen(str) - 3) != '.')
3469+
*(str + strlen(str) - 2) = '\0';
34673470
}
34683471
else
34693472
sprintf(str + strlen(str), ":%02d", tm->tm_sec);
@@ -3801,7 +3804,7 @@ EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str)
38013804
sprintf(cp, ".%06d", Abs(fsec));
38023805
#else
38033806
fsec += tm->tm_sec;
3804-
sprintf(cp, ":%012.9f", fabs(fsec));
3807+
sprintf(cp, ":%013.10f", fabs(fsec));
38053808
#endif
38063809
TrimTrailingZeros(cp);
38073810
cp += strlen(cp);

src/interfaces/ecpg/pgtypeslib/interval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str)
511511
sprintf(cp, ".%06d", Abs(fsec));
512512
#else
513513
fsec += tm->tm_sec;
514-
sprintf(cp, ":%012.9f", fabs(fsec));
514+
sprintf(cp, ":%013.10f", fabs(fsec));
515515
#endif
516516
TrimTrailingZeros(cp);
517517
cp += strlen(cp);

src/test/regress/expected/horology.out

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -205,62 +205,62 @@ SET DateStyle = 'ISO';
205205
-- As of 7.4, allow time without time zone having a time zone specified
206206
SELECT time without time zone '040506.789+08';
207207
time
208-
--------------
209-
04:05:06.789
208+
---------------
209+
04:05:06.7890
210210
(1 row)
211211

212212
SELECT time without time zone '040506.789-08';
213213
time
214-
--------------
215-
04:05:06.789
214+
---------------
215+
04:05:06.7890
216216
(1 row)
217217

218218
SELECT time without time zone 'T040506.789+08';
219219
time
220-
--------------
221-
04:05:06.789
220+
---------------
221+
04:05:06.7890
222222
(1 row)
223223

224224
SELECT time without time zone 'T040506.789-08';
225225
time
226-
--------------
227-
04:05:06.789
226+
---------------
227+
04:05:06.7890
228228
(1 row)
229229

230230
SELECT time with time zone '040506.789+08';
231231
timetz
232-
-----------------
233-
04:05:06.789+08
232+
------------------
233+
04:05:06.7890+08
234234
(1 row)
235235

236236
SELECT time with time zone '040506.789-08';
237237
timetz
238-
-----------------
239-
04:05:06.789-08
238+
------------------
239+
04:05:06.7890-08
240240
(1 row)
241241

242242
SELECT time with time zone 'T040506.789+08';
243243
timetz
244-
-----------------
245-
04:05:06.789+08
244+
------------------
245+
04:05:06.7890+08
246246
(1 row)
247247

248248
SELECT time with time zone 'T040506.789-08';
249249
timetz
250-
-----------------
251-
04:05:06.789-08
250+
------------------
251+
04:05:06.7890-08
252252
(1 row)
253253

254254
SELECT time with time zone 'T040506.789 +08';
255255
timetz
256-
-----------------
257-
04:05:06.789+08
256+
------------------
257+
04:05:06.7890+08
258258
(1 row)
259259

260260
SELECT time with time zone 'T040506.789 -08';
261261
timetz
262-
-----------------
263-
04:05:06.789-08
262+
------------------
263+
04:05:06.7890-08
264264
(1 row)
265265

266266
SET DateStyle = 'Postgres, MDY';

0 commit comments

Comments
 (0)