-
Notifications
You must be signed in to change notification settings - Fork 29
Description
Given the following database definition:
CREATE TABLE accounts(user_id INT, balance INT);
CREATE OR REPLACE FUNCTION transfer_funds(sender_id INT, receiver_id INT, amount NUMERIC)
RETURNS void
LANGUAGE SQL
BEGIN ATOMIC
UPDATE accounts SET balance = balance - amount WHERE user_id = sender_id;
UPDATE accounts SET balance = balance + amount WHERE user_id = receiver_id;
END;When pgschema dump is run, we get the following output:
--
-- pgschema database dump
--
-- Dumped from database version PostgreSQL 17.0
-- Dumped by pgschema version 1.6.0
--
-- Name: accounts; Type: TABLE; Schema: -; Owner: -
--
CREATE TABLE IF NOT EXISTS accounts (
user_id integer,
balance integer
);
--
-- Name: transfer_funds(integer, integer, numeric); Type: FUNCTION; Schema: -; Owner: -
--
CREATE OR REPLACE FUNCTION transfer_funds(
sender_id integer,
receiver_id integer,
amount numeric
)
RETURNS void
LANGUAGE sql
VOLATILE
AS $$BEGIN ATOMIC
UPDATE accounts SET balance = ((accounts.balance)::numeric - transfer_funds.amount)
WHERE (accounts.user_id = transfer_funds.sender_id);
UPDATE accounts SET balance = ((accounts.balance)::numeric + transfer_funds.amount)
WHERE (accounts.user_id = transfer_funds.receiver_id);
END$$;When this dump is fed back into pgschema plan we get the following error:
Error: failed to apply desired state: failed to apply schema SQL to temporary schema pgschema_tmp_20260114_184221_2ffb480d: ERROR: syntax error at or near "ATOMIC" (SQLSTATE 42601)
Reactions are currently unavailable