* ProcessIncomingNotify * * Scan the queue for arriving notifications and report them to the front * end. The notifications might be from other sessions, or our own; * there's no need to distinguish here. * * If "flush" is true, force any frontend messages out immediately. * * NOTE: since we are outside any transaction, we must create our own. */
| 2250 | * NOTE: since we are outside any transaction, we must create our own. |
| 2251 | */ |
| 2252 | static void |
| 2253 | ProcessIncomingNotify(bool flush) |
| 2254 | { |
| 2255 | bool client_wait_timeout_enabled; |
| 2256 | |
| 2257 | /* We *must* reset the flag */ |
| 2258 | notifyInterruptPending = false; |
| 2259 | |
| 2260 | /* Do nothing else if we aren't actively listening */ |
| 2261 | if (listenChannels == NIL) |
| 2262 | return; |
| 2263 | |
| 2264 | client_wait_timeout_enabled = DisableClientWaitTimeoutInterrupt(); |
| 2265 | |
| 2266 | if (Trace_notify) |
| 2267 | elog(DEBUG1, "ProcessIncomingNotify"); |
| 2268 | |
| 2269 | set_ps_display("notify interrupt"); |
| 2270 | |
| 2271 | /* |
| 2272 | * We must run asyncQueueReadAllNotifications inside a transaction, else |
| 2273 | * bad things happen if it gets an error. |
| 2274 | */ |
| 2275 | StartTransactionCommand(); |
| 2276 | |
| 2277 | asyncQueueReadAllNotifications(); |
| 2278 | |
| 2279 | CommitTransactionCommand(); |
| 2280 | |
| 2281 | /* |
| 2282 | * If this isn't an end-of-command case, we must flush the notify messages |
| 2283 | * to ensure frontend gets them promptly. |
| 2284 | */ |
| 2285 | if (flush) |
| 2286 | pq_flush(); |
| 2287 | |
| 2288 | set_ps_display("idle"); |
| 2289 | |
| 2290 | if (Trace_notify) |
| 2291 | elog(DEBUG1, "ProcessIncomingNotify: done"); |
| 2292 | |
| 2293 | if (client_wait_timeout_enabled) |
| 2294 | EnableClientWaitTimeoutInterrupt(); |
| 2295 | } |
| 2296 | |
| 2297 | /* |
| 2298 | * Send NOTIFY message to my front end. |
no test coverage detected