I am using PostgreSQL 7.4.7 (debian stable default)- I have had a few probs, firstly the module wont upgrade cleanly:

Update #2
    * Failed: ALTER TABLE {term_access} ADD grant_list TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL
    * Failed: UPDATE {term_access} SET grant_list = grant_view
    * Failed: ALTER TABLE {term_access_defaults} ADD grant_list TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL
    * Failed: UPDATE {term_access_defaults} SET grant_list = grant_view

Having read the postgresql ALTER notes there are a few issues. Firstly, the update seems to have mysql types.

But also:

In the current implementation of ADD COLUMN, default and NOT NULL clauses for the new column are not supported. The new column always comes into being with all values null. You can use the SET DEFAULT form of ALTER TABLE to set the default afterward. (You may also want to update the already existing rows to the new default value, using UPDATE.) If you want to mark the column non-null, use the SET NOT NULL form after you've entered non-null values for the column in all rows.

To get round this i quickly tried running these queries:

ALTER TABLE term_access ADD COLUMN grant_list smallint;
ALTER TABLE term_access ALTER COLUMN grant_list SET DEFAULT (0)::smallint; 
UPDATE term_access SET grant_list = grant_view;
ALTER TABLE term_access_defaults ADD COLUMN grant_list smallint;
ALTER TABLE term_access_defaults ALTER column grant_list SET default (0)::smallint NOT NULL;
UPDATE term_access_defaults SET grant_list = grant_view;

Which seemed to work for postgres.

However, there still seems to be problems with the use of bit_or(), which from what I can tell does not exist for with postgres 7.4.

    * warning: pg_query(): Query failed: ERROR: function bit_or(smallint) does not exist HINT: No function matches the given name and argument types. You may need to add explicit type casts. in /var/www/drupal-4.7.0-rc3/includes/database.pgsql.inc on line 84.
    * user warning: query: SELECT t.tid, d.vid, BIT_OR(t.grant_list) AS grant_list FROM term_access t INNER JOIN term_data d ON t.tid=d.tid WHERE t.rid in ('1') AND grant_list = 1 group by t.tid, d.vid in /var/www/drupal-4.7.0-rc3/includes/database.pgsql.inc on line 103.
    * warning: pg_query(): Query failed: ERROR: invalid input syntax for integer: "" in /var/www/drupal-4.7.0-rc3/includes/database.pgsql.inc on line 84.
    * user warning: query: SELECT t.* FROM term_node r INNER JOIN term_data t ON r.tid = t.tid INNER JOIN vocabulary v ON t.vid = v.vid WHERE (t.tid IN ('')) AND r.nid = 350 ORDER BY v.weight, t.weight, t.name in /var/www/drupal-4.7.0-rc3/includes/database.pgsql.inc on line 103.
    * warning: pg_query(): Query failed: ERROR: invalid input syntax for integer: "" in /var/www/drupal-4.7.0-rc3/includes/database.pgsql.inc on line 84.
    * user warning: query: SELECT t.* FROM term_node r INNER JOIN term_data t ON r.tid = t.tid INNER JOIN vocabulary v ON t.vid = v.vid WHERE (t.tid IN ('')) AND r.nid = 230 ORDER BY v.weight, t.weight, t.name in /var/www/drupal-4.7.0-rc3/includes/database.pgsql.inc on line 103.
    * warning: pg_query(): Query failed: ERROR: invalid input syntax for integer: "" in /var/www/drupal-4.7.0-rc3/includes/database.pgsql.inc on line 84.
    * user warning: query: SELECT t.* FROM term_node r INNER JOIN term_data t ON r.tid = t.tid INNER JOIN vocabulary v ON t.vid = v.vid WHERE (t.tid IN ('')) AND r.nid = 163 ORDER BY v.weight, t.weight, t.name in /var/www/drupal-4.7.0-rc3/includes/database.pgsql.inc on line 103.

Apologies as i've done this all rather quickly and without full research, but this looks like the 4.7 version taxonmy_access is incompatible with postgres 7.4?

CommentFileSizeAuthor
#3 taxonomy_access.install.diff.txt2.03 KBpoltawski

Comments

keve’s picture

Sorry, i have no ability to test Postgresql. :(
Thanks for coment, and the script, i will change hook_update in .install file.

Concerning Bit_or: Please check if script below in .install file applied well.

      if (version_compare($version, '8.0', '<')) {
        // PRIOR TO POSTGRESQL 8.0: making a BIT_OR aggregate function
        db_query("CREATE AGGREGATE BIT_OR (
          basetype = smallint,
          sfunc = int2or,
          stype = smallint
        );");
      }

Can you apply this pgsql script manually? Did it solve your problem?

If this did not apply automatically in .install file, we have to check the install script. Can you help in this, to check it again, why did not this happen?

poltawski’s picture

Can you apply this pgsql script manually? Did it solve your problem?
That does indeed, thanks. Although there are still errors which I think are unrelated.

If this did not apply automatically in .install file, we have to check the install script. Can you help in this, to check it again, why did not this happen?

It didn't apply because I was upgrading rather than installing the module I think?

Was the BIT_OR function in the previous version of the module? It sounds like my version of sql was not up to date.

However, I think taxonomy_access_update_2() needs updating, i'll try and create a patch for you.

poltawski’s picture

Status: Active » Needs review
StatusFileSize
new2.03 KB

I've made a patch

if (db_result(db_query("DESC {term_access} 'grant_list'"))) {
     drupal_set_message(t("Taxonomy Access - Update #2: No queries executed. Field 'grant_list' already exists in tables 'term_access'."), 'error');
}

is a mysql specific thing, which I can't think of a good way to recreate in postgres, so i've kinda ignored it..

Taxonmy_access now seems to update cleanly, however with my drupal upgrade it only gets into the update.php listing if I first visit the admin/modules listing, then upgrade (but this could just be my broken install..)

keve’s picture

Status: Needs review » Fixed

Commited to HEAD w/ some more corrections.

Anonymous’s picture

Status: Fixed » Closed (fixed)