It seems that the query is not tied to a specific table schema and can be executed after changing the schema. In fact, the prepared statement is laid on the list of columns that was at the time the statement was created.
In real life, the problem was revealed as follows: the class responsible for communicating with the database caches the prepared statements. Cached statements broke when it was necessary to change the base scheme during execution (do not ask why it was required: not everything in life is done the way we want). Be careful!