Static type checking
As of super commit b8311a3, type checking in SuperDB is all dynamic. This prevents us from being able to deliver some functionality, such as error messages at parse time about queries that are doomed to fail. Specific examples we encounter that will benefit from our adding support for static type checking will be linked to this Epic.
Details
Here's a simple example that illustrates a problem that will be addressed by static type checking.
We'll start with this working query in Postgres:
$ psql postgres
psql (17.5 (Homebrew))
Type "help" for help.
postgres=# SELECT * FROM (VALUES
(1, 'apple'),
(2, 'banana'),
(3, 'cherry')
) AS fruits(id, name)
WHERE id=2;
id | name
----+--------
2 | banana
(1 row)
But if we attempt to use a value of a mismatched type in the WHERE clause, now we get an error message at query parse time.
postgres=# SELECT * FROM (VALUES
(1, 'apple'),
(2, 'banana'),
(3, 'cherry')
) AS fruits(id, name)
WHERE id='abc';
ERROR: invalid input syntax for type integer: "abc"
LINE 6: WHERE id='abc';
Meanwhile in SuperDB, the example with the matching types works the same as we saw in Postgres:
$ super -version
Version: b8311a333
$ super -c "
SELECT * FROM (VALUES
(1, 'apple'),
(2, 'banana'),
(3, 'cherry')
) AS fruits(id, name)
WHERE id=2;"
{id:2,name:"banana"}
However when we try to use the mismatched type in the WHERE clause, rather than an error message, the equality check fails quietly and no output is produced.
$ super -c "
SELECT * FROM (VALUES
(1, 'apple'),
(2, 'banana'),
(3, 'cherry')
) AS fruits(id, name)
WHERE id='abc';"
[no output]