Remove leading/trailing spaces in string list type configuration parameters.
authorBo Peng <pengbo@sraoss.co.jp>
Thu, 9 May 2024 00:11:06 +0000 (09:11 +0900)
committerBo Peng <pengbo@sraoss.co.jp>
Thu, 9 May 2024 00:11:06 +0000 (09:11 +0900)
If the string list type configuration parameters (e.g. unix_socket_directories, pcp_socket_dir, etc.) contain white spaces, it may cause startup failure.

doc.ja/src/sgml/connection-settings.sgml
doc/src/sgml/connection-settings.sgml
src/config/pool_config_variables.c

index 91581086a0afbf82e2f275d9b1312dccb9685a6c..4e044cf4bd0606b135d94f081f6f4f7bfbf75423 100644 (file)
       <!--
       The directory where the UNIX domain socket(s) accepting connections for
       <productname>Pgpool-II</productname> will be created. Multiple sockets
-      can be created by listing multiple directories separated by commas. Default
-      is <literal>/tmp</literal>. Be aware that this sockets might be deleted
-      by a cron job. We recommend to set this value to <literal>/var/run</literal>
-      or such directory.
+      can be created by listing multiple directories separated by commas.
+      Leading and trailing spaces in each setting value will be automatically
+      removed. Default is <literal>/tmp</literal>. Be aware that this sockets
+      might be deleted by a cron job. We recommend to set this value to
+      <literal>/var/run</literal> or such directory.
       -->
       <productname>Pgpool-II</productname>が接続を受け付けるUNIXドメインソケットを置くディレクトリです。
       コンマで区切った複数のディレクトリのリストを設定すると複数のUNIXドメインソケットファイルを作成します。
+      各設定値の先頭と末尾に空白が入っている場合は、自動的に削除されます。
       デフォルト値は<literal>/tmp</literal>です。
       このソケットは、cron によって削除されることがあるので注意してください。
       <literal>/var/run</literal>などのディレクトリに変更することをお勧めします。
       The directory where the UNIX domain socket accepting connections for
       PCP process will be created. Multiple sockets can be created
       by listing multiple directories separated by commas.
+      Leading and trailing spaces in each setting value will be
+      automatically removed.
       Default is <literal>/tmp</literal>. Be aware that
       this socket might be deleted by a cron job. We recommend
       to set this value to <literal>/var/run</literal> or such
       -->
       PCPプロセスが接続を受け付けるUNIXドメインソケットを置くディレクトリです。
       コンマで区切った複数のディレクトリのリストを設定すると複数のUNIXドメインソケットファイルを作成します。
+      各設定値の先頭と末尾に空白が入っている場合は、自動的に削除されます。
       デフォルト値は<literal>/tmp</literal>です。
       このソケットは、cron によって削除されることがあるので注意してください。
       <literal>/var/run</literal>などのディレクトリに変更することをお勧めします。
index 5b0af0a496749722005d2e60aec855d5a1fd8ed6..34739f234fd62635996ee212b8953bb21bfc56cd 100644 (file)
      <para>
       The directory where the UNIX domain socket(s) accepting connections for
       <productname>Pgpool-II</productname> will be created. Multiple sockets
-      can be created by listing multiple directories separated by commas. Default
-      is <literal>/tmp</literal>. Be aware that this sockets might be deleted
-      by a cron job. We recommend to set this value to <literal>/var/run</literal>
-      or such directory.
+      can be created by listing multiple directories separated by commas.
+      Leading and trailing spaces in each setting value will be automatically
+      removed. Default is <literal>/tmp</literal>. Be aware that this sockets
+      might be deleted by a cron job. We recommend to set this value to
+      <literal>/var/run</literal> or such directory.
      </para>
      <para>
       This parameter can only be set at server start.
       The directory where the UNIX domain socket accepting
       connections for PCP process will be created. Multiple sockets
       can be created by listing multiple directories separated by commas.
+      Leading and trailing spaces in each setting value will be
+      automatically removed.
       Default is <literal>/tmp</literal>. Be aware that this socket
       might be deleted by a cron job. We recommend to set this
       value to <literal>/var/run</literal> or such directory.
index 995fd257d9e5b850af13c0572a8c7d0148e49e42..6a32fa2c8cb274860d010f3eb306f49fdc32bde8 100644 (file)
@@ -3078,6 +3078,19 @@ get_list_from_string(const char *str, const char *delimi, int *n)
 
        for (token = strtok(temp_string, delimi); token != NULL; token = strtok(NULL, delimi))
        {
+               int i;
+
+               /* skip leading whitespace */
+               while (isspace(*token))
+                       token++;
+
+               /* skip trailing whitespace */
+               i = strlen(token) - 1;
+               while (i >= 0 && isspace(token[i])) {
+                       token[i] = '\0';
+                       i--;
+               }
+
                tokens[*n] = pstrdup(token);
                ereport(DEBUG3,
                                (errmsg("initializing pool configuration"),