cdr table: additional permissions in PostgreSQL 8.1.X

Comment on Asterisk cdr pgsql
Joined: Sat 14 of Apr, 2007

cdr table: additional permissions in PostgreSQL 8.1.X

Posted:Sat 14 of Apr, 2007 (15:54 UTC)
If you just use GRANT to allow INSERT to the user asterisk, with PostgreSQL 8.1.X (I used 8.1.8) you will get an error from the asterisk server similar to:

Apr 14 16:49:59 ERROR[6661]: cdr_pgsql.c:154 pgsql_log: cdr_pgsql: Failed to insert call detail record into database!
Apr 14 16:49:59 ERROR[6661]: cdr_pgsql.c:155 pgsql_log: cdr_pgsql: Reason: ERROR: permission denied for sequence cdr_acctid_seq.

In such cases, you need to add additonal permissions to the user asterisk for the sequence "cdr_acctid_seq" that is created upon the creation of the "AcctId BIGSERIAL PRIMARY KEY" counter in the table "cdr". You only need to grant UPDATE to asterisk for this sequence by typing

GRANT UPDATE ON cdr_acctid_seq TO asterisk;

at e.g. the psql prompt (as user postgres) and asterisk resumes logging.