Amazon Web Services has added PL/pgSQL to Aurora DSQL, its serverless distributed SQL database. Developers can now create stored functions and procedures, run anonymous code blocks and keep procedural logic next to their data. AWS announced the feature on November 19, 2026.
This closes one of the most visible gaps between Aurora DSQL and standard PostgreSQL. Many existing PostgreSQL applications lean on stored procedures for validation and multi-step transactions. AWS says such code can now move to Aurora DSQL with minimal changes, though a few PL/pgSQL features remain off limits.
What Changed
Aurora DSQL is built for apps that need active-active availability across several AWS Regions with fast reads and writes. Until now, any branching or looping logic had to live in the application, which meant extra round trips between the app and the database.
With PL/pgSQL, that logic can run inside the database. Code can mix SQL with IF and ELSE branches, loops and variable assignment. AWS gives the example of a funds transfer procedure that checks a balance, updates several tables and deals with error conditions in one database call.
The feature is available in every AWS Region that offers Aurora DSQL.
Supported Statements
The Aurora DSQL user guide lists four statements for writing and running PL/pgSQL code:
- CREATE FUNCTION, for routines that return a value
- CREATE PROCEDURE, for routines that perform work without returning a value, with COMMIT and ROLLBACK allowed when the procedure is called at the top level
- CALL, to run a procedure
- DO, to run a one-off anonymous block without saving a function
Beyond these statements, Aurora DSQL follows the PL/pgSQL behavior described in the PostgreSQL documentation, apart from the limits listed below.
Limits to Know Before Porting Code
Several PL/pgSQL features are not supported. Using one returns SQLSTATE 0A000, which is the feature not supported error. The main limits are:
- No EXCEPTION blocks, so errors cannot be trapped with BEGIN, EXCEPTION and END inside the database
- No explicit cursors, which rules out CURSOR and REFCURSOR declarations, OPEN, FETCH, MOVE, CLOSE and cursor FOR loops
- Only RAISE NOTICE and RAISE WARNING for messages, with RAISE LOG and RAISE DEBUG rejected
- Only user-defined error codes such as P0001 in RAISE EXCEPTION, not system-reserved codes like XX000
For loops over query results, the guide recommends the FOR ... IN query form instead of a cursor. For error handling, it says to catch errors in the application rather than in the procedure.
What It Means for Developers
The missing EXCEPTION support is the limit most likely to bite. A large share of PostgreSQL procedures catch a unique violation or another error and then take a fallback path. That code will fail on Aurora DSQL, so the retry or fallback has to move up into the application layer.
There is an upside to this. When the app owns error handling, all retry and fallback rules sit in one layer, where they are easier to test and log than code buried inside the database.
Cursor code also needs a rewrite, but usually a simple one. Most explicit cursor loops can become a FOR record IN SELECT loop with the same body. Logging through RAISE LOG should switch to RAISE NOTICE or to logging in the app.
Where the feature helps most is in cutting round trips. In a multi-Region setup, each trip to the database adds latency. Packing a read, a check and several writes into one CALL can make a real difference for short transactions such as order placement or balance transfers.
Aurora DSQL has gained several features this month. The site has also covered its new audit logging for SQL statements and SQL statement statistics in Database Insights.
How to Get Started
No setting is needed. Connect to an Aurora DSQL cluster with any PostgreSQL client and run CREATE FUNCTION or CREATE PROCEDURE with LANGUAGE plpgsql. Before porting an existing schema, search the code for EXCEPTION, CURSOR, REFCURSOR, FETCH and RAISE LOG to find the parts that need changes.
Test each routine on a development cluster first. Any call that touches an unsupported feature fails with SQLSTATE 0A000, which makes the gaps easy to spot in a test run.
Conclusion
PL/pgSQL support makes Aurora DSQL a much closer match for real PostgreSQL workloads. Stored functions, procedures and DO blocks now work, with the main trade-off being that error trapping and explicit cursors must be handled differently.
Sources
- AWS What's New: Amazon Aurora DSQL now supports PL/pgSQL functions and procedures
- Amazon Aurora DSQL User Guide: PL/pgSQL in Aurora DSQL
See my articles more often when you search Google.
