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

Commitfad2e22

Browse files
author
Vladimir Ershov
committed
run tasks but still fail sometimes
1 parent5f85e54 commitfad2e22

10 files changed

+401
-108
lines changed

‎src/memutils.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ MemoryContext init_worker_mem_ctx(const char *name)
1515
returnSchedulerWorkerContext;
1616
}
1717

18+
MemoryContextswitch_to_worker_context(void)
19+
{
20+
AssertState(SchedulerWorkerContext!=NULL);
21+
returnMemoryContextSwitchTo(SchedulerWorkerContext);
22+
}
23+
1824
void*worker_alloc(Sizesize)
1925
{
2026
AssertState(SchedulerWorkerContext!=NULL);

‎src/memutils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
externMemoryContextSchedulerWorkerContext;
88

99
MemoryContextinit_worker_mem_ctx(constchar*name);
10+
MemoryContextswitch_to_worker_context(void);
1011
void*worker_alloc(Sizesize);
1112
voiddelete_worker_mem_ctx(void);
1213

‎src/pgpro_scheduler.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ worker_spi_sigterm(SIGNAL_ARGS)
6363
errno=save_errno;
6464
}
6565

66+
/** Some utils **/
67+
6668
TimestampTztimestamp_add_seconds(TimestampTzto,intadd)
6769
{
6870
if(to==0)to=GetCurrentTimestamp();
@@ -72,6 +74,63 @@ TimestampTz timestamp_add_seconds(TimestampTz to, int add)
7274
returnadd+to;
7375
}
7476

77+
intget_integer_from_string(char*s,intstart,intlen)
78+
{
79+
charbuff[100];
80+
81+
memcpy(buff,s+start,len);
82+
buff[len]=0;
83+
returnatoi(buff);
84+
}
85+
86+
char*make_date_from_timestamp(TimestampTzts)
87+
{
88+
structpg_tmdt;
89+
char*str=worker_alloc(sizeof(char)*17);
90+
inttz;
91+
fsec_tfsec;
92+
constchar*tzn;
93+
94+
timestamp2tm(ts,&tz,&dt,&fsec,&tzn,NULL );/* TODO ERROR */
95+
sprintf(str,"%04d-%02d-%02d %02d:%02d",dt.tm_year ,dt.tm_mon,
96+
dt.tm_mday,dt.tm_hour,dt.tm_min);
97+
returnstr;
98+
}
99+
100+
TimestampTzget_timestamp_from_string(char*str)
101+
{
102+
structpg_tmdt;
103+
inttz;
104+
TimestampTzts;
105+
106+
memset(&dt,0,sizeof(structtm));
107+
dt.tm_year=get_integer_from_string(str,0,4);
108+
dt.tm_mon=get_integer_from_string(str,5,2);
109+
dt.tm_mday=get_integer_from_string(str,8,2);
110+
dt.tm_hour=get_integer_from_string(str,11,2);
111+
dt.tm_min=get_integer_from_string(str,14,2);
112+
113+
tz=DetermineTimeZoneOffset(&dt,session_timezone);
114+
115+
tm2timestamp(&dt,0,&tz,&ts);
116+
117+
returnts;
118+
}
119+
120+
TimestampTz_round_timestamp_to_minute(TimestampTzts)
121+
{
122+
#ifdefHAVE_INT64_TIMESTAMP
123+
returnts-ts %USECS_PER_MINUTE;
124+
#else
125+
returnts-ts %SECS_PER_MINUTE;
126+
#endif
127+
}
128+
129+
130+
/** END of SOME UTILS **/
131+
132+
133+
75134
char_array_t*readBasesToCheck(void)
76135
{
77136
constchar*value;

‎src/pgpro_scheduler.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ void parent_scheduler_main(Datum) pg_attribute_noreturn();
2323
intcheckSchedulerNamespace(void);
2424
voidmanager_worker_main(Datumarg);
2525
pid_tregisterManagerWorker(schd_manager_t*man);
26+
2627
TimestampTztimestamp_add_seconds(TimestampTzto,intadd);
28+
char*make_date_from_timestamp(TimestampTzts);
29+
intget_integer_from_string(char*s,intstart,intlen);
30+
TimestampTzget_timestamp_from_string(char*str);
31+
TimestampTz_round_timestamp_to_minute(TimestampTzts);
2732

2833
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp