For my use case I need to create event triggers on ddl_command_end
and sql_drop
but get the error:
ERROR: permission denied to create event trigger "xxxx" (SQLSTATE 42501)
Is it possible to enable even triggers in a Neon database?
For my use case I need to create event triggers on ddl_command_end
and sql_drop
but get the error:
ERROR: permission denied to create event trigger "xxxx" (SQLSTATE 42501)
Is it possible to enable even triggers in a Neon database?
Yeah, I am continuously getting these errors for ex:
I want to add new column
ALTER TABLE users
ADD phone_number varchar(255);
error: ERROR: must be owner of table users (SQLSTATE 42501)
Hey
You’ve probably created tables via SQL editor at https://console.neon.tech and tried to run another DDL operation via a connection using the received connection string (or vice versa).
SQL editor connects with another user therefore you don’t have enough permissions to perform such DDL operations.
For instance, I’ve executed all queries via psql
.
neondb=> CREATE TABLE emp (
empname text,
salary integer,
last_date timestamp,
last_user text
);
CREATE TABLE
neondb=> CREATE FUNCTION emp_stamp() RETURNS trigger AS $emp_stamp$
BEGIN
-- Check that empname and salary are given
IF NEW.empname IS NULL THEN
RAISE EXCEPTION 'empname cannot be null';
END IF;
IF NEW.salary IS NULL THEN
RAISE EXCEPTION '% cannot have null salary', NEW.empname;
END IF;
-- Who works for us when they must pay for it?
IF NEW.salary < 0 THEN
RAISE EXCEPTION '% cannot have a negative salary', NEW.empname;
END IF;
-- Remember who changed the payroll when
NEW.last_date := current_timestamp;
NEW.last_user := current_user;
RETURN NEW;
END;
$emp_stamp$ LANGUAGE plpgsql;
CREATE FUNCTION
neondb=> CREATE TRIGGER emp_stamp BEFORE INSERT OR UPDATE ON emp
FOR EACH ROW EXECUTE FUNCTION emp_stamp();
CREATE TRIGGER
neondb=> INSERT INTO emp(empname) VALUES (NULL);
ERROR: empname cannot be null
CONTEXT: PL/pgSQL function emp_stamp() line 5 at RAISE