diff --git a/composer.json b/composer.json
index 2dc16113f6..a600aae077 100644
--- a/composer.json
+++ b/composer.json
@@ -92,6 +92,7 @@
         "pre-autoload-dump": "Drupal\\Core\\Composer\\Composer::preAutoloadDump",
         "drupal-phpunit-upgrade-check": "Drupal\\Core\\Composer\\Composer::upgradePHPUnit",
         "drupal-phpunit-upgrade": "@composer update phpunit/phpunit symfony/phpunit-bridge phpspec/prophecy symfony/yaml --with-dependencies --no-progress",
+        "drupal-pgsql-fallback": "@composer require drupal/pgsql_fallback:^2",
         "post-update-cmd": [
             "Drupal\\Composer\\Composer::generateMetapackages"
         ],
diff --git a/core/lib/Drupal/Core/Composer/Composer.php b/core/lib/Drupal/Core/Composer/Composer.php
index bd87d53922..12bb65e1fe 100644
--- a/core/lib/Drupal/Core/Composer/Composer.php
+++ b/core/lib/Drupal/Core/Composer/Composer.php
@@ -323,6 +323,11 @@ public static function upgradePHPUnit(Event $event) {
         ->getEventDispatcher()
         ->dispatchScript('drupal-phpunit-upgrade');
     }
+
+    // Hack to get DrupalCI to install the pgsql_fallback contrib project.
+    $event->getComposer()
+      ->getEventDispatcher()
+      ->dispatchScript('drupal-pgsql-fallback');
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Database/Database.php b/core/lib/Drupal/Core/Database/Database.php
index 719dd29c4d..24dff3efec 100644
--- a/core/lib/Drupal/Core/Database/Database.php
+++ b/core/lib/Drupal/Core/Database/Database.php
@@ -468,6 +468,15 @@ public static function convertDbUrlToConnectionInfo($url, $root) {
     }
     $driver = $matches[1];
 
+    // Make DrupalCI test the fallback pgsql driver instead of the core one.
+    if ($driver === 'pgsql') {
+      $driver = 'PgsqlFallback';
+      // Replace the driver name in the URL.
+      $url = $driver . substr($url, 5);
+      // Append the module query parameter to the URL.
+      $url .= '?module=pgsql_fallback';
+    }
+
     // Determine if the database driver is provided by a module.
     $module = NULL;
     $connection_class = NULL;
diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/BackendCompilerPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/BackendCompilerPass.php
index 86db1ba7bc..6b0b68e740 100644
--- a/core/lib/Drupal/Core/DependencyInjection/Compiler/BackendCompilerPass.php
+++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/BackendCompilerPass.php
@@ -46,7 +46,7 @@ public function process(ContainerBuilder $container) {
     }
     else {
       try {
-        $default_backend = $container->get('database')->driver();
+        $default_backend = $container->get('database')->databaseType();
         $container->set('database', NULL);
       }
       catch (\Exception $e) {
