[3.0] Misc PostgreSQL fixes - #9524
Conversation
18fbd94 to
a96f0fb
Compare
| $this->query( | ||
| 'UPDATE ' . $short_table_name . ' | ||
| SET ' . $column_info['name'] . ' = ' . $default . ' | ||
| WHERE ' . $column_info['name'] . ' = NULL', |
There was a problem hiding this comment.
doesn't work since null is a state like true or false, so you had to use "is" operator and not =
There was a problem hiding this comment.
Derp. Of course you are correct.
There was a problem hiding this comment.
Once the = NULL has been corrected to IS NULL, do you see any other issues with this code?
| $col_str .= ($count > 0 ? ',' : ''); | ||
| $col_str .= $columnName . ' = EXCLUDED.' . $columnName; | ||
| $count++; | ||
| $indexed_columns = array_unique(array_merge(...array_map( |
There was a problem hiding this comment.
to dense logic for me, dunno what it all do
There was a problem hiding this comment.
$indexed_columns will be a list of columns that are included in any PRIMARY KEY or UNIQUE index. This list is then used to filter the list of columns that will be included in $key_str. That way, only columns that are part of a unique index will be included in the ON CONFLICT (...) statement.
This is my fix for the "Unapproving a post fails at runtime" issue in #9519, where ON CONFLICT (id_msg) DO NOTHING causes the error there is no unique or exclusion constraint matching the ON CONFLICT specification.
f74a5a4 to
a122db6
Compare
|
I tested this against a real 2.1 → 3.0 upgrade on PostgreSQL 17, restoring the committed SMF 2.1.7 baseline from #9330 (403 members, 6 000 messages, 24 boards), and against a fresh PostgreSQL install. The substance of this is right and it fixes the things it set out to fix — but three faults stop it running at all on PostgreSQL, so none of that is reachable as it stands. 1.
|
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
…ge_column() Signed-off-by: Jon Stovell <jonstovell@gmail.com>
a122db6 to
d9b09fa
Compare
|
Retested at f22c999 with current All four things I raised are fixed, and the effect is bigger than the sum of them.
The upgrade completes on PostgreSQL. As far as I can tell that is the first time it has. With the two Primary keys surviving is the part worth pausing on. That was the data-loss half of #9519, and it holds. The migration this now reaches cannot runThe upgrade gets all the way to That migration calls
The real name is It is worth fixing here rather than elsewhere, because 37df0da is already aiming at exactly this — it drops the $row['name'] = str_replace($real_table_name . '_', '', $row['name']);which strips if (empty($row['is_primary'])) {
$row['name'] = str_replace($real_table_name . '_', '', $row['name']);
}With that in, the same probe reports: and the upgrade runs to completion, which is where the numbers above come from.
|
|
I went and wrote the two remaining fixes so the suggestion is a concrete one rather than a description. Happy either way: fold them into this branch, or say the word and I will open a pull request against it. Both are in 1. The primary key keeps the name the database gave it
// The primary key keeps the name the database gave it, because that
// is the name remove_index() has to hand to DROP CONSTRAINT.
// Stripping the table off smf_foo_pkey leaves 'pkey', which names
// nothing.
if (empty($row['is_primary'])) {
$row['name'] = str_replace($real_table_name . '_', '', $row['name']);
}2. The conflict target comes from an index, not from
|
This suggestion would break other code that use the list returned from |
cfc1884 to
2872ca8
Compare
|
Retested at 2872ca8 with current Both of the things I raised are fixed, and the PostgreSQL upgrade now completes on this branch alone — the only thing I patched locally is #9521, which is unrelated and stops MySQL in exactly the same place. Handling the primary key in And the conflict target now describes a real index, so Two things in that block are still worth a look. Both predate this branch, and neither blocks the upgrade — I only found them because this is the code being rewritten.
|
|
Latest commits should address the remaining issues, @albertlast. When you get a chance, please confirm. |
|
Checked To be clear about what this is: I have not re-run the full 2.1 → 3.0 upgrade for this round. I replayed the two code paths against the real catalog rows from a PostgreSQL 17 install and then ran the SQL they produce. That is enough to settle both questions, but the end-to-end run is still owed once the second one lands.
|
ebde515 to
0b64195
Compare
…lumn() Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
…insert() Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Previously, we were using a bare query that only worked for MySQL. This code works for both MySQL and PostgreSQL. Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
0b64195 to
e433307
Compare
That was silly of me. I'm not sure what I was thinking there. Fixed now.
Good catch. Fixed now.
Good idea. Added in latest commits.
Don't care. |
|
Checked Method, so it is clear what this is and is not: I loaded the branch's own classes against the dev PostgreSQL 17 container and drove them directly — no full upgrade run this round. Where I say "before" and "after" below, that is the same script against The opclass — fixed
and the The backfill guard — fixed
The index cache breaks
|
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
ebe5fa3 to
a707a09
Compare
|
Done. Should be ready for testing now. |
|
Checked The cache now answers for the shape it was asked forSplitting the entry into and The other order no longer hands a flat list to code expecting detail: Deriving And The invalidation gaps are closed
|
|
Here is the full run I owed, at The only thing patched locally is #9521's The zero on the PostgreSQL log line is the one that needed proving, since the failures this branch is about never reach What that means for the three things
The opclass upsert works. Primary keys survive, 69 against 69 on both engines. That was the data-loss half of #9519 and it holds on a real upgrade, not just a probe. One result worth reading carefully
ADD CONSTRAINT "smf_log_search_results_pkey" PRIMARY KEY ("id_search", "id_topic", "id_msg");so The flip side is that this baseline does not exercise the MySQL specificsThe baseline is a genuine pre-3.0 forum rather than a clean one, and the engine-specific steps did their work: after the upgrade there are 0 non-InnoDB tables (it starts with two MyISAM ones) and 0 tables not in utf8mb4 (the database starts as utf8mb3). What is left over, none of it this branch's
Both engines through the upgrader, both forums browsing afterwards, and no errors either engine kept quiet about. This looks right to me. |
Fixes #9519