[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pq 862bf023c0 20/63: Add processing for asynchronous no
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pq 862bf023c0 20/63: Add processing for asynchronous notices. |
Date: |
Mon, 14 Feb 2022 23:24:20 -0500 (EST) |
branch: externals/pq
commit 862bf023c048e845f0ff83dadf4387fa63c46109
Author: Andreas Seltenreich <seltenreich@gmx.de>
Commit: Andreas Seltenreich <seltenreich@gmx.de>
Add processing for asynchronous notices.
closes #1.
---
pq.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/pq.c b/pq.c
index a59c7eec95..9177abfac7 100644
--- a/pq.c
+++ b/pq.c
@@ -13,6 +13,23 @@ int plugin_is_GPL_compatible;
static emacs_value Qnil;
static emacs_value Qt;
+#define NOTICE_FORMAT "pq: %s"
+
+static void pq_notice_rx (void *arg, const PGresult *res)
+{
+ char *msg = PQresultErrorMessage(res);
+ emacs_env *env = arg;
+ emacs_value Fmessage = env->intern (env, "message");
+ size_t len = strlen(msg);
+ if (!len)
+ return;
+ emacs_value args [2] = {
+ env->make_string(env, NOTICE_FORMAT, strlen(NOTICE_FORMAT)),
+ env->make_string(env, msg, len-1 /* cut trailing newline */)
+ };
+ env->funcall (env, Fmessage, 2, args);
+}
+
void pq_finalize_pointer(void *user_ptr)
{
PGconn *conn = user_ptr;
@@ -126,9 +143,15 @@ Fpq_query (emacs_env *env, ptrdiff_t nargs, emacs_value
args[], void *data)
paramValues[i] = my_string_to_c(env, args[2+i]);
char *command = my_string_to_c(env, args[1]);
+
+ PQnoticeReceiver old_notice_rx =
+ PQsetNoticeReceiver(conn, pq_notice_rx, env);
+
PGresult *res = PQexecParams(conn, command, nParams,
NULL, paramValues, NULL, NULL, 0);
+ PQsetNoticeReceiver(conn, old_notice_rx, NULL);
+
for (int i=0; i<nParams; i++)
free((void *)paramValues[i]);
- [elpa] externals/pq cdc04b0b61 27/63: Add missing PQclear calls, (continued)
- [elpa] externals/pq cdc04b0b61 27/63: Add missing PQclear calls, ELPA Syncer, 2022/02/14
- [elpa] externals/pq 6f6d8728e5 38/63: Test expected error on invalid encoding., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 527e544165 46/63: Improve error handling on connection failure., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 7a15153e8d 58/63: Protect against NULL SQLSTATE., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 966a05ef25 07/63: Initialize client_encoding to utf8., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 2f63308225 24/63: Use PQexec instead of PQexecParams when no parameters are specified., ELPA Syncer, 2022/02/14
- [elpa] externals/pq a70d1fe40d 37/63: Test encoding by using some high unicode codepoints., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 795260553a 17/63: Use load-path in test.el, ELPA Syncer, 2022/02/14
- [elpa] externals/pq a03d2c2e9b 44/63: Update README, ELPA Syncer, 2022/02/14
- [elpa] externals/pq 12c54fbf15 14/63: Add undef DEFUN macro, ELPA Syncer, 2022/02/14
- [elpa] externals/pq 862bf023c0 20/63: Add processing for asynchronous notices.,
ELPA Syncer <=
- [elpa] externals/pq 9e719959b3 12/63: Avoid global variable for pq:error symbol., ELPA Syncer, 2022/02/14
- [elpa] externals/pq ca337173dd 08/63: Explicitly free the libpq result., ELPA Syncer, 2022/02/14
- [elpa] externals/pq e1d1b77b88 34/63: test: Notice receiver., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 499dc3b50e 57/63: Re-introduce custom error signal pq:error with SQLSTATE., ELPA Syncer, 2022/02/14
- [elpa] externals/pq d738d21b6a 52/63: Add checks for non-local exit., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 8151e0bc99 60/63: Add function pq:notifies to support LISTEN., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 46e38888e3 01/63: Initial commit., ELPA Syncer, 2022/02/14
- [elpa] externals/pq b72ee45524 02/63: Add .gitignore, flush tempfile., ELPA Syncer, 2022/02/14
- [elpa] externals/pq dfa4ad04bb 03/63: README: clarify., ELPA Syncer, 2022/02/14
- [elpa] externals/pq 8e13d07737 16/63: Update Makefile, ELPA Syncer, 2022/02/14