Compiled stored procedures can silently change behavior during database migration
When migrating stored procedures between databases, a procedure that compiles without errors can still produce different results depending on how edge cases are handled. In PL/pgSQL, SELECT INTO without STRICT silently assigns nulls when no rows are found and discards extra rows when multiple matches exist, while SELECT INTO STRICT raises explicit errors for both conditions. The choice between these modes is a behavioral decision, not a syntax fix, and can alter how a procedure responds to zero or multiple matching rows. Similarly, using RAISE NOTICE instead of RAISE EXCEPTION changes whether a problem is merely reported or causes the transaction to abort. Thorough migration testing should cover edge-case inputs — such as zero or duplicate rows — rather than relying solely on the standard single-match scenario.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in