MyBB Community Forums

Full Version: PostgreSQL's `drop_table()` may result in errors
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The primary part of DROP TABLE should work fine but the following DROP SEQUENCE part may not work:

https://github.com/mybb/mybb/blob/mybb_1...1286-L1293
https://github.com/mybb/mybb/blob/mybb_1...#L482-L487

As in the above code, there might be at least two issues:
1. The variable $table in the query doesn't have $table_prefix.
2. The query SQL to DROP SEQUENCE is using single quotes so the variables in it won't get expanded.
3. The query SQL to find any sequences that are still linked to the current table is wrong. The view that has sequence information is information_schema.sequences but not information_schema.constraint_column_usage which is used for constraints and keys.

About the sequence's add/drop:
- In PostgreSQL 8.2 and later, CREATE SEQUENCE ... OWNED BY ... is allowed. Thus, when a table is dropped any sequences owned by it will also get dropped, created by either the serial data type or CREATE SEQUENCE ... OWNED BY ....
- But in PostgreSQL 8.1 and previous versions, the OWNED BY clause hasn't been supported yet. MyBB officially supports PostgreSQL >= 8.1, so we have to maintain this code.
Hi,

Thank you for your report. We have pushed this issue to our Github repository for further analysis where you can track our commits and progress with fixing this bug. Discussions regarding this bug may also take place there too.

Follow this link to visit the issue on Github: https://github.com/mybb/mybb/issues/4502

Thanks for contributing to MyBB!

Regards,
The MyBB Group
I can confirm that linked pull request https://github.com/mybb/mybb/pull/4503

Works on a pgsql 13 install. Of note, for 1.9 I will be recommending a minimum required of pgsql 9 -- older versions are no longer supported and most by now probably have upgraded.