36{
41 bool throw = true;
44 const char *
result =
"<unset>";
48
49
50
51
52
56 errmsg(
"%s can only be executed as a top-level statement",
57 "WAIT FOR"),
58 errdetail(
"WAIT FOR cannot be used within a function, procedure, or DO block.")));
59
60
63
65 {
67 {
69
73
75
84 else
87 errmsg(
"unrecognized value for %s option \"%s\": \"%s\"",
90 }
92 {
95 double dval;
96
100
102
104 {
109 }
110
111
112
113
114
115
117
118
122 errmsg(
"timeout value is out of range"));
123
124 if (dval < 0)
127 errmsg(
"timeout cannot be negative"));
128
130 }
132 {
135
137
139 }
140 else
141 {
144 errmsg(
"option \"%s\" not recognized",
147 }
148 }
149
150
151
152
153
154
155
156
157
158
159
160
163
164
165
166
167
169
170
174 errmsg(
"WAIT FOR must be called without an active or registered snapshot"),
175 errdetail(
"WAIT FOR cannot be executed within a transaction with an isolation level higher than READ COMMITTED."));
176
177
178
179
180
182
183
184
185
186
188 {
192 errmsg(
"recovery is in progress"),
193 errhint(
"Waiting for primary_flush can only be done on a primary server. "
194 "Use standby_flush mode on a standby server.")));
195 }
196
197
199
200
201
202
204 {
206
208 break;
209
211 if (throw)
212 {
214
215 switch (lsnType)
216 {
220 errmsg(
"timed out while waiting for target LSN %X/%08X to be replayed; current standby_replay LSN %X/%08X",
223 break;
224
228 errmsg(
"timed out while waiting for target LSN %X/%08X to be written; current standby_write LSN %X/%08X",
231 break;
232
236 errmsg(
"timed out while waiting for target LSN %X/%08X to be flushed; current standby_flush LSN %X/%08X",
239 break;
240
244 errmsg(
"timed out while waiting for target LSN %X/%08X to be flushed; current primary_flush LSN %X/%08X",
247 break;
248
249 default:
250 elog(
ERROR,
"unexpected wait LSN type %d", lsnType);
251 }
252 }
253 else
255 break;
256
258 if (throw)
259 {
261 {
263
264 switch (lsnType)
265 {
269 errmsg(
"recovery is not in progress"),
270 errdetail(
"Recovery ended before target LSN %X/%08X was replayed; last standby_replay LSN %X/%08X.",
273 break;
274
278 errmsg(
"recovery is not in progress"),
279 errdetail(
"Recovery ended before target LSN %X/%08X was written; last standby_write LSN %X/%08X.",
282 break;
283
287 errmsg(
"recovery is not in progress"),
288 errdetail(
"Recovery ended before target LSN %X/%08X was flushed; last standby_flush LSN %X/%08X.",
291 break;
292
293 default:
294 elog(
ERROR,
"unexpected wait LSN type %d", lsnType);
295 }
296 }
297 else
298 {
299 switch (lsnType)
300 {
304 errmsg(
"recovery is not in progress"),
305 errhint(
"Waiting for the standby_replay LSN can only be executed during recovery."));
306 break;
307
311 errmsg(
"recovery is not in progress"),
312 errhint(
"Waiting for the standby_write LSN can only be executed during recovery."));
313 break;
314
318 errmsg(
"recovery is not in progress"),
319 errhint(
"Waiting for the standby_flush LSN can only be executed during recovery."));
320 break;
321
322 default:
323 elog(
ERROR,
"unexpected wait LSN type %d", lsnType);
324 }
325 }
326 }
327 else
328 result =
"not in recovery";
329 break;
330 }
331
332
334
335
337
338
340
342}
#define Assert(condition)
#define FLOAT8_FITS_IN_INT64(num)
char * defGetString(DefElem *def)
bool defGetBoolean(DefElem *def)
void errorConflictingDefElem(DefElem *defel, ParseState *pstate)
int errcode(int sqlerrcode)
int errhint(const char *fmt,...) pg_attribute_printf(1
int errdetail(const char *fmt,...) pg_attribute_printf(1
#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)
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)
int pg_strcasecmp(const char *s1, const char *s2)
static Datum CStringGetDatum(const char *X)
bool ActiveSnapshotSet(void)
bool HaveRegisteredOrActiveSnapshot(void)
void PopActiveSnapshot(void)
void InvalidateCatalogSnapshot(void)
#define InvalidTransactionId
TupleDesc WaitStmtResultDesc(WaitStmt *stmt)
bool RecoveryInProgress(void)
#define LSN_FORMAT_ARGS(lsn)
bool PromoteIsTriggered(void)
XLogRecPtr GetCurrentLSNForWaitType(WaitLSNType lsnType)
WaitLSNResult WaitForLSN(WaitLSNType lsnType, XLogRecPtr targetLSN, int64 timeout)
@ WAIT_LSN_RESULT_NOT_IN_RECOVERY
@ WAIT_LSN_RESULT_TIMEOUT
@ WAIT_LSN_RESULT_SUCCESS
@ WAIT_LSN_TYPE_PRIMARY_FLUSH
@ WAIT_LSN_TYPE_STANDBY_REPLAY
@ WAIT_LSN_TYPE_STANDBY_FLUSH
@ WAIT_LSN_TYPE_STANDBY_WRITE