Make libpqsrv_cancel's return const char *, not char *
authorAlvaro Herrera <[email protected]>
Fri, 5 Apr 2024 16:23:10 +0000 (18:23 +0200)
committerAlvaro Herrera <[email protected]>
Fri, 5 Apr 2024 16:23:10 +0000 (18:23 +0200)
Per headerscheck's C++ check.

Discussion: https://postgr.es/m/372769.1712179784@sss.pgh.pa.us

contrib/dblink/dblink.c
contrib/postgres_fdw/connection.c
src/include/libpq/libpq-be-fe-helpers.h

index de858e165abdc5b779ad33de68564c217b5f5d93..755293456fff687183c969aeb9724db24af13c35 100644 (file)
@@ -1347,7 +1347,7 @@ Datum
 dblink_cancel_query(PG_FUNCTION_ARGS)
 {
    PGconn     *conn;
-   char       *msg;
+   const char *msg;
    TimestampTz endtime;
 
    dblink_init();
index e4595926641229f33e0673e6dd9bea94c4875445..603e043af40ba164874e081ce1eeb746edccd802 100644 (file)
@@ -1332,7 +1332,7 @@ pgfdw_cancel_query(PGconn *conn)
 static bool
 pgfdw_cancel_query_begin(PGconn *conn, TimestampTz endtime)
 {
-   char       *errormsg = libpqsrv_cancel(conn, endtime);
+   const char *errormsg = libpqsrv_cancel(conn, endtime);
 
    if (errormsg != NULL)
        ereport(WARNING,
index 8be9aa1f2f990914541059e80e03221d261df681..fe508292743f6080738b3cc4b8e54c597dda7908 100644 (file)
@@ -382,11 +382,11 @@ libpqsrv_get_result(PGconn *conn, uint32 wait_event_info)
  * Note: this function leaks a string's worth of memory when reporting
  * libpq errors.  Make sure to call it in a transient memory context.
  */
-static inline char *
+static inline const char *
 libpqsrv_cancel(PGconn *conn, TimestampTz endtime)
 {
    PGcancelConn *cancel_conn;
-   char       *error = NULL;
+   const char *error = NULL;
 
    cancel_conn = PQcancelCreate(conn);
    if (cancel_conn == NULL)