When I want to create user, I'm getting an error:
PDOException: SQLSTATE[55000]: Object not in prerequisite state: 7 ERROR: currval of sequence "subscriptions_sid_seq" is not yet defined in this session: INSERT INTO subscriptions (module, field, value, send_interval, author_uid, send_updates, send_comments, recipient_uid) SELECT s.module AS module, s.field AS field, s.value AS value, s.send_interval AS send_interval, s.author_uid AS author_uid, s.send_updates AS send_updates, s.send_comments AS send_comments, 94 AS recipient_uid FROM subscriptions s WHERE (s.recipient_uid IN (:db_condition_placeholder_0)) ; Array ( ) v subscriptions_user_insert() (riadok 336 z .....modules/subscriptions/subscriptions.module).
I'm using Drupal 7.15, last dev version of Subscriptions.
Comment | File | Size | Author |
---|---|---|---|
#8 | 1807356-8-user-insert-query.patch | 526 bytes | karleberts |
#6 | 1807356-6-user-insert-query.patch | 439 bytes | karleberts |
Comments
Comment #1
salvisPostgreSQL quirks are not critical.
Any PostgreSQL gurus out there?
Comment #2
salvisSorry, no one seems to know how to fix this.
Comment #3
salvisSimilar pgsql issues:
#1815158: PostgreSQL & MS SQL Server: PDO error on forum administration interface first access
#1320148: Install error on PostgreSQL
According to the PostgreSQL documentation, the subselect returning nothing should not be a problem.
I've tried listing the ->fields() and I've tried ->useDefaults(), both without success (resulting in MySQL errors).
Comment #4
ecomundo CreditAttribution: ecomundo commentedWe have the same issue here. Many of the admin actions returns the error : PDOException: SQLSTATE[55000]: Object not in prerequisite state: 7 ERROR: currval of sequence "sequence_name" is not yet defined in this session.
According to our research, the currval function return the last nextval executed with the active database session. The lastval function returning the last nexval for all database session. So both of this functions are not define if no nextval has been executed.
Comment #5
salvisSubscriptions does not deal with currval/nextval/etc. at all. Apparently, this happens in the database layer, but I have no idea why and what for.
Comment #6
karleberts CreditAttribution: karleberts commentedThe problem seems to be when a new user is created the subselect returns nothing, so the insert doesn't actually insert anything either. By default, db_insert returns the id of the row by calling PDO::lastInsertId (which seems to just call currval() on the sequence), hence the error when nothing is inserted.
Modifying the options to db_insert to not return the id allows this step to be skipped; the return value for the insert isn't used anyway.
Comment #8
karleberts CreditAttribution: karleberts commentedSubmitted patch in the wrong format. This should be better.
Comment #9
salvisOh, great, thank you for the analysis and patch.
Can someone else on pgsql confirm that this fixes the problem?
Comment #10
jweowu CreditAttribution: jweowu commentedConfirmed.
This is clearly a bug in the database layer, but I believe this patch is the cleanest workaround.
Comment #11
salvisGreat, thanks karleberts and jweowu!
Pushed to the -dev version.