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

Commit427a964

Browse files
committed
|From: Keith Parks <emkxp01@mtcc.demon.co.uk>
|Subject: [PATCH] adding SYS_TIME just for fun.||Hi,||Whilst I was playing round with the European dates patch I noticed the sysfunc()|that allows you to do :-||create table test ( da date);|insert into test values (SYS_DATE);||and have the current system date inserted.||So I thought it would be nice to have the SYS_TIME facility too.||I've cloned the function and changed a few things and there you have it,|you can now do:||create table test2 ( ti time);|insert into test2 values (SYS_TIME);
1 parent1d8a696 commit427a964

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎src/backend/parser/sysfunc.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,26 @@ static char *Sysfunc_system_date(void)
4545
return&buf[0];
4646
}
4747

48+
staticchar*Sysfunc_system_time(void)
49+
{
50+
time_tcur_time_secs;
51+
structtm*cur_time_expanded;
52+
staticcharbuf[10];/* Just for safety, y'understand... */
53+
54+
time(&cur_time_secs);
55+
cur_time_expanded=localtime(&cur_time_secs);
56+
sprintf(buf,"%2.2d:%2.2d:%2.2d",cur_time_expanded->tm_hour,
57+
cur_time_expanded->tm_min,cur_time_expanded->tm_sec);
58+
59+
return&buf[0];
60+
}
61+
4862
char*SystemFunctionHandler(char*funct)
4963
{
5064
if (!strcmp(funct,"SYS_DATE"))
5165
returnSysfunc_system_date();
66+
if (!strcmp(funct,"SYS_TIME"))
67+
returnSysfunc_system_time();
5268
return"*unknown function*";
5369
}
5470

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp