[19.0] parent_store: the range match of 9b1872b179 depends on the collation; descendants keep a stale parent_path on databases not in "C"
Impacted versions: 19.0 from commit 9b1872b179 ("[PERF] orm: match parent_store descendants by range instead of LIKE", odoo/odoo#287180). Seen in the official image odoo:19.0 of 2026-09-26 (19.0-20260926). The image of 2026-09-08 (19.0-20260908) is not affected.
Current behaviour: On a database whose collation is not C, moving a record of a _parent_store model updates the parent_path of the moved record but not the paths of its descendants. They keep the old prefix, so child_of and parent_of searches, and every record rule built on them, answer from stale paths.
A database that Odoo creates itself is usually safe: _create_empty_database uses template0 with LC_COLLATE 'C' by default. Databases created outside Odoo inherit the cluster's locale and are affected. Examples are createdb, the POSTGRES_DB of the official postgres image, a managed service such as Amazon RDS, and --db-template=template1.
Expected behaviour: The descendants get the new prefix, as they did with the LIKE match.
Steps to reproduce:
- Start
postgres:16with its default locale (en_US.utf8) and create the database outside Odoo, for example withPOSTGRES_DBorcreatedb. Installproductwithodoo -i product --without-demo --stop-after-init. - In
odoo shell:
Cat = env["product.category"]
a = Cat.create({"name": "A"})
b = Cat.create({"name": "B", "parent_id": a.id})
c = Cat.create({"name": "C", "parent_id": b.id})
d = Cat.create({"name": "D"})
b.parent_id = d
env.flush_all(); env.invalidate_all()
print(c.parent_path, Cat.search([("id", "child_of", d.id)]).ids)- Results, with the ids A=4, B=5, C=6, D=7 (expected path of C:
7/5/6/):
| Image | Database collation | C.parent_path |
child_of D |
|---|---|---|---|
| 19.0-20260926 | en_US.utf8 |
4/5/6/ (stale) |
[5, 7] (C missing) |
| 19.0-20260908 | en_US.utf8 |
7/5/6/ |
[5, 6, 7] |
| 19.0-20260926 | C |
7/5/6/ |
[5, 6, 7] |
Cause: _parent_store_update now selects the descendants with
AND child.parent_path >= node.parent_path
AND child.parent_path < left(node.parent_path, -1) || '0'This relies on byte order, where / (0x2F) sorts right before 0 (0x30). The commit message says the range works "whatever the collation", but a linguistic collation gives / no primary weight. With glibc 2.41 and en_US.utf8 the order is 45, 4/50, 450, 4/5/6/, 456. For the node 4/5/ the upper bound is 4/50, and the child 4/5/6/ sorts after it:
SELECT '4/5/6/' < '4/50' COLLATE "C" AS c_collation, -- true
'4/5/6/' < '4/50' COLLATE "en_US.utf8" AS en_us; -- falseThe old LIKE condition is true under both collations.
Suggested fix: Compare both bounds under COLLATE "C", and give the parent_path index the same collation (or text_pattern_ops), so that the planner keeps the index scan this commit was written for. Alternatively, use the range only where the database collation is C and keep LIKE elsewhere.
Environment: PostgreSQL 16.14 (Debian, glibc 2.41, libc locale provider), Docker on arm64. amd64 was not checked.
How we found it: A test in our own addons moves a record of a _parent_store model that has a child, and checks that the child's path follows. The test started failing on the first CI run that pulled the image of 2026-09-26; our CI database comes from POSTGRES_DB. We pinned the image to the digest of 2026-09-08 until this is fixed.
Source: odoo/odoo