PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pqmq.h File Reference
#include "lib/stringinfo.h"
#include "storage/procnumber.h"
#include "storage/shm_mq.h"
Include dependency graph for pqmq.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void pq_redirect_to_shm_mq (dsm_segment *seg, shm_mq_handle *mqh)
 
void pq_set_parallel_leader (pid_t pid, ProcNumber procNumber)
 
void pq_parse_errornotice (StringInfo msg, ErrorData *edata)
 

Function Documentation

◆ pq_parse_errornotice()

void pq_parse_errornotice ( StringInfo  msg,
ErrorData edata 
)
extern

Definition at line 229 of file pqmq.c.

230{
231 /* Initialize edata with reasonable defaults. */
232 MemSet(edata, 0, sizeof(ErrorData));
233 edata->elevel = ERROR;
234 edata->assoc_context = CurrentMemoryContext;
235
236 /* Loop over fields and extract each one. */
237 for (;;)
238 {
239 char code = pq_getmsgbyte(msg);
240 const char *value;
241
242 if (code == '\0')
243 {
244 pq_getmsgend(msg);
245 break;
246 }
248
249 switch (code)
250 {
251 case PG_DIAG_SEVERITY:
252 /* ignore, trusting we'll get a nonlocalized version */
253 break;
255 if (strcmp(value, "DEBUG") == 0)
256 {
257 /*
258 * We can't reconstruct the exact DEBUG level, but
259 * presumably it was >= client_min_messages, so select
260 * DEBUG1 to ensure we'll pass it on to the client.
261 */
262 edata->elevel = DEBUG1;
263 }
264 else if (strcmp(value, "LOG") == 0)
265 {
266 /*
267 * It can't be LOG_SERVER_ONLY, or the worker wouldn't
268 * have sent it to us; so LOG is the correct value.
269 */
270 edata->elevel = LOG;
271 }
272 else if (strcmp(value, "INFO") == 0)
273 edata->elevel = INFO;
274 else if (strcmp(value, "NOTICE") == 0)
275 edata->elevel = NOTICE;
276 else if (strcmp(value, "WARNING") == 0)
277 edata->elevel = WARNING;
278 else if (strcmp(value, "ERROR") == 0)
279 edata->elevel = ERROR;
280 else if (strcmp(value, "FATAL") == 0)
281 edata->elevel = FATAL;
282 else if (strcmp(value, "PANIC") == 0)
283 edata->elevel = PANIC;
284 else
285 elog(ERROR, "unrecognized error severity: \"%s\"", value);
286 break;
287 case PG_DIAG_SQLSTATE:
288 if (strlen(value) != 5)
289 elog(ERROR, "invalid SQLSTATE: \"%s\"", value);
290 edata->sqlerrcode = MAKE_SQLSTATE(value[0], value[1], value[2],
291 value[3], value[4]);
292 break;
294 edata->message = pstrdup(value);
295 break;
297 edata->detail = pstrdup(value);
298 break;
300 edata->hint = pstrdup(value);
301 break;
303 edata->cursorpos = pg_strtoint32(value);
304 break;
306 edata->internalpos = pg_strtoint32(value);
307 break;
309 edata->internalquery = pstrdup(value);
310 break;
311 case PG_DIAG_CONTEXT:
312 edata->context = pstrdup(value);
313 break;
315 edata->schema_name = pstrdup(value);
316 break;
318 edata->table_name = pstrdup(value);
319 break;
321 edata->column_name = pstrdup(value);
322 break;
324 edata->datatype_name = pstrdup(value);
325 break;
327 edata->constraint_name = pstrdup(value);
328 break;
330 edata->filename = pstrdup(value);
331 break;
333 edata->lineno = pg_strtoint32(value);
334 break;
336 edata->funcname = pstrdup(value);
337 break;
338 default:
339 elog(ERROR, "unrecognized error field code: %d", code);
340 break;
341 }
342 }
343}
#define MemSet(start, val, len)
Definition c.h:1107
#define LOG
Definition elog.h:32
#define FATAL
Definition elog.h:42
#define WARNING
Definition elog.h:37
#define PANIC
Definition elog.h:44
#define DEBUG1
Definition elog.h:31
#define ERROR
Definition elog.h:40
#define MAKE_SQLSTATE(ch1, ch2, ch3, ch4, ch5)
Definition elog.h:58
#define elog(elevel,...)
Definition elog.h:228
#define NOTICE
Definition elog.h:36
#define INFO
Definition elog.h:35
static struct @177 value
char * pstrdup(const char *in)
Definition mcxt.c:1781
MemoryContext CurrentMemoryContext
Definition mcxt.c:160
int32 pg_strtoint32(const char *s)
Definition numutils.c:382
#define PG_DIAG_INTERNAL_QUERY
#define PG_DIAG_SCHEMA_NAME
#define PG_DIAG_CONSTRAINT_NAME
#define PG_DIAG_DATATYPE_NAME
#define PG_DIAG_SOURCE_LINE
#define PG_DIAG_STATEMENT_POSITION
#define PG_DIAG_SOURCE_FILE
#define PG_DIAG_MESSAGE_HINT
#define PG_DIAG_SQLSTATE
#define PG_DIAG_SEVERITY_NONLOCALIZED
#define PG_DIAG_TABLE_NAME
#define PG_DIAG_MESSAGE_PRIMARY
#define PG_DIAG_COLUMN_NAME
#define PG_DIAG_MESSAGE_DETAIL
#define PG_DIAG_CONTEXT
#define PG_DIAG_SEVERITY
#define PG_DIAG_SOURCE_FUNCTION
#define PG_DIAG_INTERNAL_POSITION
void pq_getmsgend(StringInfo msg)
Definition pqformat.c:634
int pq_getmsgbyte(StringInfo msg)
Definition pqformat.c:398
const char * pq_getmsgrawstring(StringInfo msg)
Definition pqformat.c:607
static int fb(int x)

References CurrentMemoryContext, DEBUG1, elog, ERROR, FATAL, fb(), INFO, LOG, MAKE_SQLSTATE, MemSet, NOTICE, PANIC, PG_DIAG_COLUMN_NAME, PG_DIAG_CONSTRAINT_NAME, PG_DIAG_CONTEXT, PG_DIAG_DATATYPE_NAME, PG_DIAG_INTERNAL_POSITION, PG_DIAG_INTERNAL_QUERY, PG_DIAG_MESSAGE_DETAIL, PG_DIAG_MESSAGE_HINT, PG_DIAG_MESSAGE_PRIMARY, PG_DIAG_SCHEMA_NAME, PG_DIAG_SEVERITY, PG_DIAG_SEVERITY_NONLOCALIZED, PG_DIAG_SOURCE_FILE, PG_DIAG_SOURCE_FUNCTION, PG_DIAG_SOURCE_LINE, PG_DIAG_SQLSTATE, PG_DIAG_STATEMENT_POSITION, PG_DIAG_TABLE_NAME, pg_strtoint32(), pq_getmsgbyte(), pq_getmsgend(), pq_getmsgrawstring(), pstrdup(), value, and WARNING.

Referenced by ProcessParallelApplyMessage(), ProcessParallelMessage(), and ProcessRepackMessage().

◆ pq_redirect_to_shm_mq()

void pq_redirect_to_shm_mq ( dsm_segment seg,
shm_mq_handle mqh 
)
extern

Definition at line 56 of file pqmq.c.

57{
63}
@ DestRemote
Definition dest.h:89
void on_dsm_detach(dsm_segment *seg, on_dsm_detach_callback function, Datum arg)
Definition dsm.c:1140
ProtocolVersion FrontendProtocol
Definition globals.c:30
CommandDest whereToSendOutput
Definition postgres.c:97
uint64_t Datum
Definition postgres.h:70
const PQcommMethods * PqCommMethods
Definition pqcomm.c:165
#define PG_PROTOCOL_LATEST
Definition pqcomm.h:95
static void pq_cleanup_redirect_to_shm_mq(dsm_segment *seg, Datum arg)
Definition pqmq.c:70
static const PQcommMethods PqCommMqMethods
Definition pqmq.c:42
static shm_mq_handle * pq_mq_handle
Definition pqmq.c:29

References DestRemote, fb(), FrontendProtocol, on_dsm_detach(), PG_PROTOCOL_LATEST, pq_cleanup_redirect_to_shm_mq(), pq_mq_handle, PqCommMethods, PqCommMqMethods, and whereToSendOutput.

Referenced by ParallelApplyWorkerMain(), ParallelWorkerMain(), and RepackWorkerMain().

◆ pq_set_parallel_leader()

void pq_set_parallel_leader ( pid_t  pid,
ProcNumber  procNumber 
)
extern

Definition at line 85 of file pqmq.c.

86{
90}
#define Assert(condition)
Definition c.h:943
static ProcNumber pq_mq_parallel_leader_proc_number
Definition pqmq.c:32
static pid_t pq_mq_parallel_leader_pid
Definition pqmq.c:31

References Assert, pq_mq_parallel_leader_pid, pq_mq_parallel_leader_proc_number, PqCommMethods, and PqCommMqMethods.

Referenced by ParallelApplyWorkerMain(), ParallelWorkerMain(), and RepackWorkerMain().