I use postgresql-8.1.11 @CentOS as Drupal database, and it seems to have more strict SQL syntax. That's why the one couldn't omit "AS" in "SELECT u.name name_c".

I saw this error in admin/user/accounts with original LDAP provisioning

user warning: query: SELECT l.*, u.name name_c FROM drupal_ldapprov l LEFT JOIN drupal_users u ON l.cuid = u.uid WHERE l.status = 1 ORDER BY registered DESC LIMIT 20 OFFSET 0 in /home/www/sogo/popla.nu/drupal/sites/all/modules/ldap_provisioning/ldapprov.module on line 1255.

And similar errors were at admin/user/accounts/created, admin/user/accounts/rejected, and admin/user/accounts/deleted.

This is the patch fixing the issue (see the full version of my comment):

diff -rupN ldapprov.module  ldapprov.module.fixed
--- ldapprov.module     2009-02-01 12:52:22.000000000 +0600
+++ ldapprov.module.fixed       2009-02-01 12:54:11.000000000 +0600
@@ -1239,12 +1239,12 @@ function ldapprov_list_form(&$form_state

   if (in_array($status, array(1, 2, 4))) {
     // Accounts are not created.
-    $sql = "SELECT l.*, u.name name_c FROM {ldapprov} l LEFT JOIN {users} u ON l.cuid = u.uid WHERE l.status = %d";
+    $sql = "SELECT l.*, u.name AS name_c FROM {ldapprov} l LEFT JOIN {users} u ON l.cuid = u.uid WHERE l.status = %d";
     $query_count = "SELECT COUNT(l.rid) FROM {ldapprov} l LEFT JOIN {users} u ON l.cuid = u.uid WHERE l.status = %d";
   }
   elseif ($status == 3) {
     // Accounts are created.
-    $sql = "SELECT l.*, u.name name_c, u2.name name_u FROM {ldapprov} l INNER JOIN {users} u2 ON l.uid = u2.uid LEFT JOIN {users} u ON l.cuid = u.uid WHERE l.status = %d";
+    $sql = "SELECT l.*, u.name AS name_c, u2.name AS name_u FROM {ldapprov} l INNER JOIN {users} u2 ON l.uid = u2.uid LEFT JOIN {users} u ON l.cuid = u.uid WHERE l.status = %d";
     $query_count = "SELECT COUNT(l.rid) FROM {ldapprov} l INNER JOIN {users} u2 ON l.uid = u2.uid LEFT JOIN {users} u ON l.cuid = u.uid WHERE l.status = %d";
   }
   else {

Comments

miglius’s picture

I have fixed this in the dev version. Have found one more missing AS statement. Thanks for catching it.

miglius’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit e31d0d2 on master, 6.x-2.x, 6.x-1.x by miglius:
    ldap_provisioning: fixed SQL error on PostgreSQL in admin/user/accounts...

  • Commit e31d0d2 on master, 6.x-2.x, 6.x-1.x by miglius:
    ldap_provisioning: fixed SQL error on PostgreSQL in admin/user/accounts...