Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-14679 META: DB layer 2.0
  3. MDL-17374

postgres native driver, socket connection not working for me

    XMLWordPrintable

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: Database SQL/XMLDB
    • Labels:
      None
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      The following bit of code, where it tries to use a socket connection if you are on localhost, does not work here on my computer.

      Worse, it fails with the generic

      Error: Database connection failed

      It is possible that the database is overloaded or otherwise not running properly.

      The site administrator should also check that the database details have been
      correctly specified in config.php

      error, which gives you no clue as to what is actually happening. It took me quite a lot of digging around to acutally get the error message, and find it was coming from around this bit of code, and then try adding 'false and ' to the start of this if statement to make it work again. (Luckily, I knew that you had worked on this over the weekend, so I knew roughly where to look.)

      Using sockets seems like a good idea in principle, but it needs to be reliable. Sorry to be the bearer of ill news Petr.

      // Unix socket connections should have lower overhead
      if (empty($this->dboptions['forcetcp']) and ($this->dbhost === 'localhost' or $this->dbhost === '127.0.0.1'))

      { $connection = "user='$this->dbuser' password='$pass' dbname='$this->dbname'"; }

      else {
      if (empty($this->dboptions['dbport']))

      { $port = 5432; }

      else

      { $port = $this->dboptions['dbport']; }

      $connection = "host='$this->dbhost' port='$port' user='$this->dbuser' password='$pass' dbname='$this->dbname'";
      }

        Attachments

          Activity

            People

            • Assignee:
              skodak Petr Skoda
              Reporter:
              timhunt Tim Hunt
              Tester:
              Tim Hunt
              Participants:
              Component watchers:
              Jake Dallimore, Jun Pataleta
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                24/Nov/10