Menu

Testing Stored Procedures in Postgres — Why PL/pgSQL Only Fails at Call Time, and What a Test Has to Build First
📰

Testing Stored Procedures in Postgres — Why PL/pgSQL Only Fails at Call Time, and What a Test Has to Build First

DEV Community: cicd·Marcus·3 days ago
#cbMzFJMi
#devtocicd#devto#dev#probe#procedure
Long article (7373 words) — no AI summary yet.
Reading 0:00
15s threshold

A click on "Duplicate" in the project list, a red notice "The project could not be duplicated", nothing else. The server log has the reason: a procedure reads a column that has not existed for five months. During those five months, the deploy ran green on four environments, production included. The convention check had nothing to complain about, and more than a thousand unit tests were green. None of these nets had ever called the procedure. PL/pgSQL resolves the column names in a body only at call time, and in an empty throwaway database nothing calls the procedure.

This article shows why there is no cheap test layer for the behavior of stored procedures in Postgres, and how to test Postgres stored procedures without installing a tool for it.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.