supabase / splinter

Supabase Postgres Linter
https://supabase.github.io/splinter/
66 stars 6 forks source link

Lint for non-immutable generated columns #58

Open darora opened 2 months ago

darora commented 2 months ago

Generated columns in Postgres are required to only use immutable functions, but this does not seem to be enforced at creation time. It can, however, cause the upgrade process to fail.

olirice commented 1 month ago

this does not seem to be enforced at creation time

I tried

create table abc (
  id int primary key,
  x timestamp generated always as ( now() ) stored
);

on 15.1 and 16.2 and got a

ERROR:  42P17: generation expression is not immutable

in both cases

@darora do you have a reproducible way to get into the bad state that I can use for testing?

relevant (internal) slack thread