diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php
index 4f18f6a..a41cba5 100644
--- a/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php
@@ -202,15 +202,17 @@ function initializeDatabase() {
         );
       }
 
-      db_query('CREATE OR REPLACE FUNCTION "substring_index"(text, text, integer) RETURNS text AS
-        \'SELECT array_to_string((string_to_array($1, $2)) [1:$3], $2);\'
-        LANGUAGE \'sql\''
-      );
+      if (!db_query("SELECT COUNT(*) FROM pg_proc WHERE proname = 'substring_index'")->fetchField()) {
+        db_query('CREATE OR REPLACE FUNCTION "substring_index"(text, text, integer) RETURNS text AS
+          \'SELECT array_to_string((string_to_array($1, $2)) [1:$3], $2);\'
+          LANGUAGE \'sql\''
+        );
+      }
 
       $this->pass(t('PostgreSQL has initialized itself.'));
     }
     catch (\Exception $e) {
-      $this->fail(t('Drupal could not be correctly setup with the existing database. Revise any errors.'));
+      $this->fail(t('Drupal could not be correctly setup with the existing database due to the following error: @error.', ['@error' => $e->getMessage()]));
     }
   }
 
