33{
37 bool throw = true;
40 const char *result = "<unset>";
41 bool timeout_specified = false;
42 bool no_throw_specified = false;
43
44
47
49 {
50 if (strcmp(defel->defname, "timeout") == 0)
51 {
52 char *timeout_str;
53 const char *hintmsg;
54 double result;
55
56 if (timeout_specified)
58 timeout_specified = true;
59
61
63 {
65 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
66 errmsg(
"invalid timeout value: \"%s\"", timeout_str),
67 hintmsg ?
errhint(
"%s",
_(hintmsg)) : 0);
68 }
69
70
71
72
73
74
75 result = rint(result);
76
77
80 errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
81 errmsg(
"timeout value is out of range"));
82
83 if (result < 0)
85 errcode(ERRCODE_INVALID_PARAMETER_VALUE),
86 errmsg(
"timeout cannot be negative"));
87
88 timeout = (
int64) result;
89 }
90 else if (strcmp(defel->defname, "no_throw") == 0)
91 {
92 if (no_throw_specified)
94
95 no_throw_specified = true;
96
98 }
99 else
100 {
103 errmsg(
"option \"%s\" not recognized",
104 defel->defname),
106 }
107 }
108
109
110
111
112
113
114
115
116
117
118
119
120
123
124
125
126
127
129
130
133 errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
134 errmsg(
"WAIT FOR must be only called without an active or registered snapshot"),
135 errdetail(
"WAIT FOR cannot be executed from a function or a procedure or within a transaction with an isolation level higher than READ COMMITTED."));
136
137
138
139
140
142
144
145
146
147
148 switch (waitLSNResult)
149 {
151
152 result = "success";
153 break;
154
156 if (throw)
158 errcode(ERRCODE_QUERY_CANCELED),
159 errmsg(
"timed out while waiting for target LSN %X/%08X to be replayed; current replay LSN %X/%08X",
162 else
163 result = "timeout";
164 break;
165
167 if (throw)
168 {
170 {
172 errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
173 errmsg(
"recovery is not in progress"),
174 errdetail(
"Recovery ended before replaying target LSN %X/%08X; last replay LSN %X/%08X.",
177 }
178 else
180 errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
181 errmsg(
"recovery is not in progress"),
182 errhint(
"Waiting for the replay LSN can only be executed during recovery."));
183 }
184 else
185 result = "not in recovery";
186 break;
187 }
188
189
191
192
194
195
197
199}
#define FLOAT8_FITS_IN_INT64(num)
char * defGetString(DefElem *def)
bool defGetBoolean(DefElem *def)
void errorConflictingDefElem(DefElem *defel, ParseState *pstate)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
const TupleTableSlotOps TTSOpsVirtual
void end_tup_output(TupOutputState *tstate)
TupOutputState * begin_tup_output_tupdesc(DestReceiver *dest, TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
#define do_text_output_oneline(tstate, str_to_emit)
#define DirectFunctionCall1(func, arg1)
bool parse_real(const char *value, double *result, int flags, const char **hintmsg)
Assert(PointerIsAligned(start, uint64))
int parser_errposition(ParseState *pstate, int location)
#define foreach_node(type, var, lst)
Datum pg_lsn_in(PG_FUNCTION_ARGS)
static XLogRecPtr DatumGetLSN(Datum X)
static Datum CStringGetDatum(const char *X)
bool ActiveSnapshotSet(void)
bool HaveRegisteredOrActiveSnapshot(void)
void PopActiveSnapshot(void)
void InvalidateCatalogSnapshot(void)
#define InvalidTransactionId
TupleDesc WaitStmtResultDesc(WaitStmt *stmt)
#define LSN_FORMAT_ARGS(lsn)
bool PromoteIsTriggered(void)
XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI)
WaitLSNResult WaitForLSN(WaitLSNType lsnType, XLogRecPtr targetLSN, int64 timeout)
@ WAIT_LSN_RESULT_NOT_IN_RECOVERY
@ WAIT_LSN_RESULT_TIMEOUT
@ WAIT_LSN_RESULT_SUCCESS