Parpalak wrote:Are you sure that these ALTER queries will work on PostgreSQL and SQLite?
I fail to see how that is relevant - database conversion code will almost certainly need to be hard-coded for every database separately. That is, if you want a reliable code.
It was not me who designed db_update.php so I can't explain its logic in details. To tell you the truth, I'm still confused a little with all these encodings and collations in databases. But I want to fix bugs if they exists and will continue investigating.
Well, my main database is Firebird so I can't really tell you details about PostgreSQL and SQLite.
With MySQL, you don't care what encoding the data is stored in the database. All you need to do to get UTF8 output, regardless of encoding actually used by the database, is:
1) Make sure table structure matches table data. Which is NOT the case with many PunBB 1.2 installations, including mine - PunBB 1.2 did not create the tables correctly.
2) Make sure SET NAMES utf8 is called before any other SQL command.
Even if #1 is not satisfied, this approach will not lead to data loss on old data - old posts will simply display incorrectly, but as soon as table structure is fixed to match the data, everything will be fine.
Upgrade script uses a much more dangerous approach of reading all data, converting it to UTF8 and writing it back.