agentm / project-m36

Project: M36 Relational Algebra Engine
The Unlicense
892 stars 48 forks source link

implement schema hashing #353

Closed agentm closed 1 year ago

agentm commented 2 years ago

When a client connects to a PostgreSQL database, it has specific expectations about what schema is in available, but there is no way for the database to guarantee it. If there is any skew between what the client's queries expect vis-a-vis table and column mentioned then this results in a fatal runtime error.

This error is completely preventable however if the client simply checks that the schema matches the expectation. Basically, the database schema itself should represent a type.

To begin with, this can achieved with a simple hash of the schema to represent the type in a compressed fashion. The client can then store a hash of the expected schema and compare it after connecting to the database. If the schema hash does not match, the client should report an error to the user immediately about the schema mismatch.