Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit86896be

Browse files
committed
Move timeofday() implementation out of nabstime.c.
nabstime.c is about to be removed, but timeofday() isn't related tothe rest of the functionality therein, and some find it useful. Moveto timestamp.c.Discussion:https://postgr.es/m/20181009192237.34wjp3nmw7oynmmr@alap3.anarazel.dehttps://postgr.es/m/20180928223240.kgwc4czzzekrpsid%40alap3.anarazel.de
1 parente9edc1b commit86896be

File tree

2 files changed

+20
-29
lines changed

2 files changed

+20
-29
lines changed

‎src/backend/utils/adt/nabstime.c

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,32 +1539,3 @@ parsetinterval(char *i_string,
15391539
"tinterval",i_string)));
15401540
*i_start=*i_end=INVALID_ABSTIME;/* keep compiler quiet */
15411541
}
1542-
1543-
1544-
/*****************************************************************************
1545-
*
1546-
*****************************************************************************/
1547-
1548-
/*
1549-
* timeofday -
1550-
* returns the current time as a text. similar to timenow() but returns
1551-
* seconds with more precision (up to microsecs). (I need this to compare
1552-
* the Wisconsin benchmark with Illustra whose TimeNow() shows current
1553-
* time with precision up to microsecs.) - ay 3/95
1554-
*/
1555-
Datum
1556-
timeofday(PG_FUNCTION_ARGS)
1557-
{
1558-
structtimevaltp;
1559-
chartempl[128];
1560-
charbuf[128];
1561-
pg_time_ttt;
1562-
1563-
gettimeofday(&tp,NULL);
1564-
tt= (pg_time_t)tp.tv_sec;
1565-
pg_strftime(templ,sizeof(templ),"%a %b %d %H:%M:%S.%%06d %Y %Z",
1566-
pg_localtime(&tt,session_timezone));
1567-
snprintf(buf,sizeof(buf),templ,tp.tv_usec);
1568-
1569-
PG_RETURN_TEXT_P(cstring_to_text(buf));
1570-
}

‎src/backend/utils/adt/timestamp.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,26 @@ GetSQLLocalTimestamp(int32 typmod)
16091609
returnts;
16101610
}
16111611

1612+
/*
1613+
* timeofday(*) -- returns the current time as a text.
1614+
*/
1615+
Datum
1616+
timeofday(PG_FUNCTION_ARGS)
1617+
{
1618+
structtimevaltp;
1619+
chartempl[128];
1620+
charbuf[128];
1621+
pg_time_ttt;
1622+
1623+
gettimeofday(&tp,NULL);
1624+
tt= (pg_time_t)tp.tv_sec;
1625+
pg_strftime(templ,sizeof(templ),"%a %b %d %H:%M:%S.%%06d %Y %Z",
1626+
pg_localtime(&tt,session_timezone));
1627+
snprintf(buf,sizeof(buf),templ,tp.tv_usec);
1628+
1629+
PG_RETURN_TEXT_P(cstring_to_text(buf));
1630+
}
1631+
16121632
/*
16131633
* TimestampDifference -- convert the difference between two timestamps
16141634
*into integer seconds and microseconds

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp