While building up my schema (i.e., dev mode), I would like to use ASSERT to “confirm” that I’m doing what I think I’m doing.
I tried to use
create function api.login(...) returns void language plpgsql as $$ declare ... begin ... ASSERT current_user::text = "anonymous", 'Unexpected user'; ... end; $$;
Postgres renders the clause as a select statement and reports the error that
column "anonymous" does not exist. Right now, that’s throwing me a bit given the like:
select (2 + 2 = 4) > t -- this does not generate an error select current_user = 'db_user' > t
I’m new to using Postgres (a. what took me so long?! b. and using sql outside of data processing :)), so would greatly appreciate learning the best way to assert the user is what I think it is (not to mention, conveying the security intent).
Thank you in advance!