Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-21876

Some uses of bound params fail with postgres

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: Database SQL/XMLDB
    • Labels:
      None
    • Database:
      PostgreSQL
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      I've attached a patch which fixes a couple of instances of this problem, but I suspect it will be found elsewhere as well.

      The problem is that postgres is strict about using positional parameters with pg_query_params(). Whereas the MySQL DML driver "emulates" the bound parameters (see emulate_bound_params()), the postgres driver relies on the pgsql SERVER to do this. Postgres only supports the use of these parameters as scalar values. See http://www.postgresql.org/docs/8.2/static/sql-expressions.html

      So for example, this query would fail:

      if ($nodeleted) {
      $and = "AND deleted = 0";
      } else {
      $and = "";
      }

      $users = get_records_sql("SELECT * FROM

      {user}

      WHERE auth='?' ?", array('ldap', $and));

      it gets a parse error on $2.

      Forums rss generation is broken because of this!

        Attachments

          Activity

            People

            Assignee:
            skodak Petr Skoda
            Reporter:
            ashleyholman Ashley Holman
            Tester:
            Nobody
            Participants:
            Component watchers:
            Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

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