Make DatabasePostgres::serverIsReadOnly() check default_transaction_read_only
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 15 Jun 2017 08:36:39 +0000 (01:36 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 15 Jun 2017 08:36:39 +0000 (01:36 -0700)
Change-Id: If6088c15271a827fedc6a585e070bab6c1acc371

includes/libs/rdbms/database/DatabasePostgres.php

index 57acd01..b9d5a2d 100644 (file)
@@ -1367,6 +1367,13 @@ SQL;
                return false;
        }
 
+       public function serverIsReadOnly() {
+               $res = $this->query( "SHOW default_transaction_read_only", __METHOD__ );
+               $row = $this->fetchObject( $res );
+
+               return $row ? ( strtolower( $row->default_transaction_read_only ) === 'on' ) : false;
+       }
+
        /**
         * @param string $lockName
         * @return string Integer