Cannot insert data into tables

darren

Member
Hello,

I have upgrade to v10 of Dadabik and since my upgrade whenever I try to insert data I receive a
[pre]
[08] Error: during last ID fetching.
[/pre]

Now I do not have the email after insert parameter on in the config, which I have read may cause this.

When I check my logs for php errors. there are none associated however the error log for Postgresql shows errors that are strange

Here is the output

[pre]
2019-12-14 15:14:12 PST [2138-8] natcat_admin@NatCatDatabase DETAIL: parameters: $1 = 'Test', $2 = 'Test', $3 = '123456', $4 = 'NEWPORT BEACh', $5 = '3924', $6 = '12345', $7 = '2222', $8 = 'test@example.com', $9 = 'hi', $10 = '0', $11 = '0', $12 = ''
2019-12-14 15:16:25 PST [20549-1] natcat_admin@NatCatDatabase ERROR: relation "mail_list_id_seq" does not exist
2019-12-14 15:16:25 PST [20549-2] natcat_admin@NatCatDatabase STATEMENT: SELECT CURRVAL($1)
2019-12-14 15:16:25 PST [20549-3] natcat_admin@NatCatDatabase ERROR: current transaction is aborted, commands ignored until end of transaction block
2019-12-14 15:16:25 PST [20549-4] natcat_admin@NatCatDatabase STATEMENT: DEALLOCATE pdo_stmt_00000307
2019-12-14 15:16:25 PST [20549-5] natcat_admin@NatCatDatabase ERROR: current transaction is aborted, commands ignored until end of transaction block
2019-12-14 15:16:25 PST [20549-6] natcat_admin@NatCatDatabase STATEMENT: DEALLOCATE pdo_stmt_00000013
2019-12-14 15:16:25 PST [20549-7] natcat_admin@NatCatDatabase ERROR: current transaction is aborted, commands ignored until end of transaction block
2019-12-14 15:16:25 PST [20549-8] natcat_admin@NatCatDatabase STATEMENT: DEALLOCATE pdo_stmt_00000015

[/pre]

this log doesnt make much sense to me but I just wanted to share it in case it helped

System info

PHP Version: 7.3.12-1+ubuntu16.04.1+deb.sury.org+1

postgres version: 10.11 (Ubuntu 10.11-1.pgdg16.04+1)

Web server: Apache/2.4.18 (Ubuntu)

Client: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36
 

eugenio

Administrator
Staff member
Hello,
you are right, you might have this issue with postgres and V. 10, thanks for your detailed report.

What is happening is that DaDaBIK assumes you have a serial field for each of your tables, filled up by a sequence having the default name assigned by postgres: TABLENAME_UNIQUEFIELD_seq, but you might not have it and postgres complains the sequence does not exist.

A quick fix: edit /include/db_functions_pdo.php and change, in the function get_last_ID_db(), this line of code:


if (isset($sequence_name)){

to:

if (isset($sequence_name) && $sequence_name === $prefix_internal_table.'unique_ids_value_unique_id_seq'){


and the line:

global $conn, $dbms_type;

to:

global $conn, $dbms_type, $prefix_internal_table;

This prevents you to correctly use the revisions feature and the after insert hook, but they won't work anyway if you don't have the default sequence name.

Let me know if this fixes the problem; if you are using uploads, please check if uploads are still working correctly, assigning a unique name (name of the file UNDERSCORE an incrementing integer number) to the files you are uploading.

I'll publish a more complete solution here or directly in the next version.

Best,
 
Top