This can no longer be reproduced on 17.10.x, 18.4.x and master. The LIKE query in XWikiHibernateStore#hasDocuments() is still not escaped, so for a space a_b it still returns the children of a-b, but since XWIKI-18525 (fixed in 13.4) the results are filtered in Java (result.equals(space) || result.startsWith(space + '.')), which discards these wrong matches. The space row is thus correctly deleted and no ghost entry remains in the page tree.
The missing escaping still causes the opposite problem for pages with a dot in their name on PostgreSQL, MySQL and MariaDB (children are missed and the parent space row is wrongly deleted), which is reported in XWIKI-25012.
This message was sent by Atlassian Jira (v9.3.0#930000-sha1:287aeb6)
If image attachments aren't displayed, see this article.