MyBB Community Forums

Full Version: [D] PostgreSQL error when registering, 1.4.4
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Registers new user very nicely, but then returns an error. Very annoying and may have significant impact on what happens during registration, but no such problems have I noticed.

I am not sure whether this is a general bug or it's because of my not-really-correct mybb upgrading and modifying to work with Postgres, so I'll send a lot of debug information.
MyBB has experienced an internal SQL error and cannot continue.
SQL Error:
55000 - ERROR: currval of sequence "mybb_userfields_ufid_seq" is not yet defined in this session 
Query:
SELECT currval('mybb_userfields_ufid_seq') AS last_value
Sequence "mybb.mybb_userfields_ufid_seq"
    Column     |  Type
---------------+---------
 sequence_name | name
 last_value    | bigint
 increment_by  | bigint
 max_value     | bigint
 min_value     | bigint
 cache_value   | bigint
 log_cnt       | bigint
 is_cycled     | boolean
 is_called     | boolean
         Table "mybb.mybb_userfields"
 Column |  Type   |         Modifiers
--------+---------+---------------------------
 ufid   | integer | not null default 0
 fid1   | text    | not null default ''::text
 fid2   | text    | not null default ''::text
 fid3   | text    | not null default ''::text
Indexes:
    "mybb_userfields_pkey" PRIMARY KEY, btree (ufid)
Index "mybb.mybb_userfields_pkey"
 Column |  Type
--------+---------
 ufid   | integer
primary key, btree, for table "mybb.mybb_userfields"
This was resolved in MyBB 1.4.4 - Please make sure your running that.
Ouch.

I'm sure I'm running 1.4.4, but I may have done something wrong with upgrade. Could you please provide the solution which has been applied to 1.4.3 to fix it? I mean a part of code fixing the problem.

Should it simply be "nextval" instead of "currval"?
Did you run the upgrade script when you upgraded to 1.4.4?
Of course. 1.4.3 -> 1.4.4
Run this manually then: CREATE SEQUENCE mybb_userfields_ufid_seq;
It already exists, as you can see from my bug report.
I'm not sure what's wrong then. I have setup multiple MyBB PostgreSQL forums in the past and they all work fine (including a 1.4.3 and 1.4.4 one)
It works fine, but sends this error after registration. Anyway, thanks for your help.

And I have fixed it for my forum - now I call insert_query for this table with insert_id=false, so that it does not call insert_id() function. I could do this because we don't use the value returned from insert_query.

inc/datahandlers/users.php:
987: $db->insert_query("userfields", $user['user_fields'], false);
1198: $db->insert_query("userfields", $user_fields, false);
I applied your fix seeing as it won't do any harm and it looks like another staff member is able to replicate this as well.
Pages: 1 2