foreach ($order as $new_pos => $old_pos) {
      if ($sql) {
        $sql .= ', ';
      }
      $sql .= ' (%d, %d, %d, %d, %d)';
      $args[] = $form_values['sqid'];
      $args[] = $form_values['qid'];
      $args[] = $nids[$old_pos];

      // $new_pos starts from 0 but we start from 1.
      $args[] = $new_pos + 1;
      $args[] = $now;
      $subqueue->count++;
    }
    $sql = "INSERT INTO {nodequeue_nodes} (sqid, qid, nid, position, timestamp) VALUES $sql";
    db_query($sql, $args);

$sql is not a standard compliant sql query (more of a mysql convention) as it does multiple inserts, for our uses I have changed the code block to be:

    foreach ($order as $new_pos => $old_pos) {
      $sql = ' (%d, %d, %d, %d, %d)';
      $subqueue->count++;
      $sql = "INSERT INTO {nodequeue_nodes} (sqid, qid, nid, position, timestamp) VALUES $sql";
      db_query($sql, $form_values['sqid'], $form_values['qid'], $nids[$old_pos], $new_pos + 1, $now);
    }

Inserts one at a time. Currently it is hard to tell the difference in the efficiency of the multiple insert vs. single calls. If anyone has any input please respond.

Comments

fumanchu182’s picture

Title: PgSQL error at line » PgSQL for insert statements.

Had to update the title as it was incomplete.

cedarm’s picture

Status: Active » Closed (duplicate)

Duplicate of #290969: Postgres compatibility. There is a patch available too, which is more complete.

cedarm’s picture

Status: Closed (duplicate) » Active

Apologies. The issue mentioned above is for the D6 version. The patch may still be applicable, but I'm not in a position to test it on D5.

The code in the description of this issue may work fine, but you'll probably find that the various SELECTs with s.*, etc, still need fixing.

ezra-g’s picture

Status: Active » Closed (duplicate)

I think this is a duplicate of that issue, since it changes queries in both modules, including this overlapping one. @fumanchu182, it would be helpful if you could see[#290969] for a question about this change.

Thanks!