When PL/pgSQL stored procedures and functions belong in your PostgreSQL design
If your team has inherited server-side logic on self-hosted PostgreSQL, or is about to write some, the first decision is not how to write it but whether it belongs in the database at all. PL/pgSQL is PostgreSQL's built-in procedural language, used to write functions and procedures that run inside the server, close to the data. It supports variables, control flow, loops, exception handling and SQL statements embedded directly in the code. The reference is the PL/pgSQL chapter of the PostgreSQL documentation, which should be the starting point for any review of existing code. Application code, by contrast, runs in a separate process, is usually deployed on its own release cycle, and reaches the database over a connection. Logic in the database runs wherever the server runs, is shared by every client that can call it, and is versioned with the schema unless your team manages it separately.
That difference drives the core question: should a given rule execute next to the data or in the application? Logic that must hold no matter which client writes the data is a strong candidate, such as invariants that multiple services touch, data-shaping steps that would otherwise move large result sets over the network, or batch jobs that need transaction control close to the rows they change. Logic that depends on business workflows, external APIs, or frequent product changes usually fits better in application code, where tests, deployment tooling and reviewers are already in place. Before writing anything, list each candidate rule, the clients that depend on it, how often it changes, and who must be able to read and approve the change. Confirm with your database owner which role will deploy and roll back server-side code, because that role carries the risk of a bad change reaching every client at once.
Functions, procedures and when each fits
This table compares PL/pgSQL functions and procedures by how they are called, what they can return, whether they control transactions, and which workloads they suit. Read each row as a design question: if the logic must run inside a query or trigger, a function is the only option, and if it must commit in batches, a procedure is the fit.
| Decision point | Function | Procedure |
|---|---|---|
| How it is invoked | Called inside SELECT, WHERE, DEFAULT or triggers, or with SELECT for a standalone call | Invoked with CALL, never inside a query expression |
| Return values | Returns a scalar, a row, a set or nothing (void), and can feed a query directly | Returns no value; results come back through INOUT parameters or tables written by the body |
| Transaction control | Cannot COMMIT or ROLLBACK inside its body; it runs in the caller's transaction | Can COMMIT and ROLLBACK inside its body, which suits chunked batch work |
| Batch jobs | Poor fit for long loops that must commit progress, since the whole call is one transaction | Good fit for archiving, purging or backfills that commit every N rows |
| Data validation | Good fit for checks reused in constraints, CHECK expressions or queries | Fit for validation steps run as a job, with explicit rollback on failure |
| Triggers | Required: a trigger must call a function that returns trigger | Not usable as a trigger function |
| Reporting logic | Good fit for set-returning functions that dashboards or views call | Less suited, because reports read results rather than run commands |
| Review and testing | Easy to unit-test with SELECT and assert results in a rollback block | Test with CALL in a session, checking committed state at each step |
How transaction control changes between functions and procedures
A PL/pgSQL function runs as part of the transaction that called it. It cannot issue COMMIT or ROLLBACK itself, so the caller decides when the work becomes durable or is discarded. If the caller rolls back, every change the function made rolls back with it. This makes functions a good fit for logic that must succeed or fail as one unit with the surrounding statement, such as validation helpers, computed values and trigger bodies. The trade-off is that a long-running function holds its locks and its snapshot until the outer transaction ends, so the function's scope has a direct effect on contention.
- No transaction control: Attempting COMMIT or ROLLBACK inside a function raises an error, because the function has no transaction of its own to end.
- Exception blocks as savepoints: A BEGIN block with an EXCEPTION clause creates an internal subtransaction, which adds overhead when used inside tight loops.
- Usable in queries: Functions can be called from SELECT, WHERE and index expressions, which procedures cannot.
- Locks held for the full call: Row locks taken by the function persist until the caller's transaction finishes, not until the function returns.
- Atomic by default: A single error anywhere in the call stack aborts the whole outer transaction unless the code traps the error.
Before relying on this behavior, confirm the rules for your target version in the PostgreSQL documentation on transaction management in PL/pgSQL.
Procedures are invoked with CALL, and they can manage transactions. Inside a procedure, COMMIT and ROLLBACK end the current transaction and let the next statement start a new one. This is the mechanism for splitting long jobs into durable chunks. The documented constraint is that a procedure can only control transactions when it is called from the top level, outside an explicit transaction block. If the caller has already opened a transaction with BEGIN, the procedure cannot commit partway through, and the attempt fails.
- Calling context matters: A procedure called from inside a function, a DO block that has already started a transaction, or an application transaction started with BEGIN cannot commit independently.
- Each commit ends the snapshot: Work committed mid-procedure becomes visible to other sessions immediately, so the procedure's intermediate state is not atomic.
- Session settings and cursors: Cursors and some session state must be handled carefully across commits, since a commit closes cursors that are not declared WITH HOLD.
- Error handling is explicit: A failure after a commit cannot roll back earlier chunks, so each chunk needs its own idempotent logic or a record of progress.
- Driver behavior: Some client libraries wrap CALL in a transaction by default, which silently removes the ability to commit inside the procedure.
Check the CALL and CREATE PROCEDURE pages in the PostgreSQL documentation for your major version, and test the procedure through the same driver your application uses.
Batch processing is the most common reason to choose a procedure. A loop that updates or deletes rows in chunks can commit after each chunk, which releases locks, lets vacuum reclaim space during the run and limits how much work is lost on failure. The cost is that each chunk is a separate transaction with its own commit overhead, and each commit makes partial results visible to readers. Choosing the chunk size is therefore a locking and throughput decision, not just a performance setting. Large single transactions can hold locks for a long time and delay replication, while very small chunks multiply commit and round-trip costs.
- Chunk by key range or limit: Process rows in ordered batches using a key range or a LIMIT clause, and record the last key processed so reruns resume safely.
- Use SKIP LOCKED for competing workers: FOR UPDATE SKIP LOCKED lets several workers claim different rows without blocking each other.
- Commit cadence sets lock duration: Shorter transactions release row and table locks sooner, which reduces blocking for application queries.
- Watch dead tuple accumulation: Long loops that update many rows create dead tuples that vacuum can only remove after old snapshots end, so long-open snapshots slow cleanup.
- Replication lag: Very large transactions produce large WAL bursts that can delay standbys, which matters for read replicas and failover targets.
Test chunk sizes against a copy of production data and monitor lock waits and replication lag during the run, using the locking and replication guidance in the PostgreSQL documentation for your version.
The transaction rules for procedures have been stable across recent major versions, but behavior depends on how the procedure is called, and that depends on your application stack. Verify the rules against the documentation for the exact major version you run, because the release notes and PL/pgSQL reference change over time and your supported versions are listed in the PostgreSQL versioning policy. Confirm version support before you design around a feature, since a version that is near end of life will need an upgrade plan regardless of how the procedure is written.
- Major version in the docs: Read the CREATE PROCEDURE and CALL pages for your version rather than relying on memory or blog posts.
- Driver and ORM behavior: Confirm whether your database driver, connection pooler and migration tool open implicit transactions around CALL.
- Pooler transaction mode: Connection poolers in transaction mode return the server connection after each transaction, so session state assumptions must hold across commits.
- Migration tooling: Schema migration frameworks often wrap each file in a transaction, which can block procedures that commit.
- Test the exact call path: Run the same CALL statement from the application, the scheduler and a manual session, since each may behave differently.
Record the verified behavior for each procedure in its documentation and repeat the check during every major version upgrade.
What converts cleanly from Oracle PL/SQL or T-SQL and what does not
Most Oracle PL/SQL and T-SQL logic moves to PL/pgSQL with syntax changes, but several features carry different semantics that only show up at runtime. The cards below cover the areas where a conversion that looks correct can still behave differently, so each one needs an explicit decision and a test.
Package-style organization
Oracle packages bundle related procedures, functions and package state into one named unit, and T-SQL uses schemas and modules as loose groupings. PostgreSQL has no package object, so the usual approach is a schema per domain with functions grouped inside it. Package variables that hold state across calls have no direct equivalent and must be redesigned, often as session settings or explicit parameters. Check every package body for session state before you split it up.
Exception handling semantics
PL/SQL uses named exceptions such as NO_DATA_FOUND and TOO_MANY_ROWS, and T-SQL uses TRY and CATCH blocks with error functions. PL/pgSQL uses BEGIN and EXCEPTION blocks with condition names such as no_data_found, and an exception rolls back the whole block to an implicit savepoint. Code that catches an error and continues in Oracle or SQL Server may silently lose work or behave differently in PostgreSQL. Test each handler with the error paths you expect in production.
Cursors and row-by-row loops
Explicit cursors, implicit FOR loops and T-SQL cursors can be translated directly, but they often run row by row where a set-based statement would be faster and easier to review. PL/pgSQL supports cursors with FOR loops and refcursors returned to callers, and the behavior of open cursors across transaction boundaries depends on how the routine is called. Confirm whether each cursor is read-only, scrollable or held across a commit before you keep the loop as written.
Implicit transactions and commit control
T-SQL can run with implicit transactions enabled, and Oracle begins a transaction on the first DML statement and ends it on COMMIT or ROLLBACK. In PostgreSQL, a function runs inside the caller's transaction and cannot commit, so transaction control only works in procedures called with CALL. Logic that relies on an Oracle autonomous transaction or a T-SQL batch commit needs redesign, and the boundary of each unit of work should be written down before conversion begins.
Temporary tables and system functions
Global temporary tables in Oracle and table variables or #temp tables in SQL Server have different lifetimes and visibility rules than PostgreSQL temporary tables, which are session-scoped and can be created with ON COMMIT options. Functions such as SYSDATE, GETDATE, ROWNUM, TOP, DECODE, NVL and system catalog views have different names or behavior, and some have no direct equivalent. Build a list of every system function and dynamic SQL call in the source, then map each one to a PostgreSQL form and verify the result set.
Inventory and test every converted routine
Conversion tools and manual rewrites both produce code that compiles but may not match the original results. Start with a complete inventory of procedures, functions, triggers, packages and the jobs that call them, including those scheduled outside the database. For each routine, run the original and converted versions against the same input data and compare outputs, row counts and error behavior. Treat any routine without a passing comparison as unconverted, and confirm the expected results with the team that owns the business logic.
How to build and deploy PL/pgSQL logic in sequence
This sequence turns business rules into server-side PL/pgSQL routines that are versioned, privilege-controlled, reviewed before release and verified on a staging copy before production. Each step closes with a check the team can point to.
Write down the business rules first
Before any code, the business owner and the database team agree on each rule the routine must enforce, the inputs and outputs, the error cases and which system is the source of truth for each value. Write the rules as short numbered statements in the repository next to the code, so reviewers can check the implementation against them later. The step is done when every routine has a written rule set that a non-author can read and confirm, and any rule with no clear owner is escalated before it is coded.
Choose a function or procedure for each routine
Decide per routine whether it returns a value or a set and runs inside the caller's transaction (a function), or must commit or roll back partway through a batch (a procedure invoked with CALL, which can issue its own COMMIT or ROLLBACK). Functions can be used in queries, while procedures cannot. Record the decision and its reason in the same document as the rules. The step is done when each routine has a stated type and the team agrees that no batch job relies on transaction control inside a function.
Set the schema and privilege design
Decide which schema holds the routines, who owns them, and which roles may execute them. Revoke the default EXECUTE grant to PUBLIC where it is not wanted, grant execution to named application or reporting roles, and set SECURITY DEFINER only where a routine must run with its owner's rights, with a fixed search_path. Review the grants with a query against the catalog rather than by memory. The step is done when a role-by-routine grant matrix exists and a test role confirms that it can call only the routines it should.
Write migrations under version control
Put every CREATE FUNCTION, CREATE OR REPLACE and CREATE PROCEDURE statement in versioned migration files that run in the same order in every environment. Keep one routine per file where practical, store the previous definition for rollback, and avoid editing migrations that have already run. Use a migration tool your team already operates. The step is done when a clean database can be built from the migration history alone and the result matches the definitions in the repository.
Pass each change through a review gate
Open a merge request for each migration and require review by someone other than the author, with the business rules document attached. The reviewer checks the logic against the rules, the privilege grants, the use of SECURITY DEFINER, dynamic SQL built from input, error handling and transaction control. Automated linting and static checks run in the same pipeline. The step is done when the change is approved, the pipeline is green and the review record names the rules each routine was checked against.
Run unit and behavior tests against each routine
Write tests that call each routine with normal inputs, boundary values and invalid inputs, and assert on returned values, raised errors and changed rows. Run them in a disposable database created from the migrations, so tests start from a known state. For procedures, include a test that confirms a rollback leaves no partial changes. The step is done when the suite passes in the pipeline and each business rule has at least one test that would fail if the rule were broken.
Rehearse the release on a staging copy
Apply the migrations to a staging database restored from a recent production backup, with personal data masked where the rules require it. Confirm that the migrations apply without errors, that existing callers still work, that the grants match the matrix, and that execution time on realistic volumes is acceptable. Confirm the rollback path as well. Check the backup used for the copy actually restores. The step is done when the staging results are recorded and any gap has been fixed and retested.
Deploy to production and verify behavior
Apply the reviewed migrations in a planned window, then run a short set of post-deployment checks: confirm the routine definitions and grants match the repository, run smoke calls that the rules document lists, and watch error logs and query timing for the first period of use. Keep the rollback script ready until the checks pass. The step is done when the deployed catalog state is recorded alongside the release, and the team has signed off that the smoke checks and monitoring show expected behavior.
How stored logic moves from review to production
The path starts with a migration file committed to version control, then passes peer review and automated tests run against a disposable PostgreSQL instance. Only after those checks does the same change move to staging and then production through the migration tool. The application role should receive execute rights on reviewed functions, while the owner role that creates and alters them stays under the database team's control. Check that each environment applies the same reviewed file and that no one edits function bodies directly on a live server.
Reviewed stored logic moves through tests and environments, with the owner role kept separate from the application role.
Security risks in server-side logic: SECURITY DEFINER, privileges and search_path
Server-side routines run with privileges that can exceed those of the caller, so a mistake in one function can expose data far beyond its intended scope. The risks below cluster around who can run a routine, which privileges it uses, which objects it resolves, and who can change it.
SECURITY DEFINER runs with owner privileges
A function declared SECURITY DEFINER executes with the privileges of the role that owns it, not the role that calls it. That is useful for exposing a narrow operation, such as writing one audit row, without granting base table access. The risk is that any logic inside the function, including dynamic SQL built from arguments, runs with the owner's rights. Review each definer function for input handling, confirm the owner is a role with the minimum required privileges, and check that the function is not owned by a superuser or a role that owns many schemas.
Authentication methodsEXECUTE granted to PUBLIC by default
PostgreSQL grants EXECUTE on new functions to PUBLIC by default, so every role that can connect to the database may be able to call a function unless the grant is revoked. Teams often discover this only after a sensitive function appears callable by an application role or a reporting account. Revoke EXECUTE from PUBLIC on functions that carry business or security logic, then grant it explicitly to the roles that need it. Confirm the default behavior against the PostgreSQL version you run, and include the grant state in your review of each migration.
Unqualified names and search_path
A function that refers to a table, operator or another function without a schema prefix resolves that name through the session's search_path. A user who can create objects in a schema that appears earlier in the path can shadow the intended object, and a SECURITY DEFINER function will then run the attacker's code with owner rights. Schema-qualify every reference in routines, and set a fixed search_path on definer functions with the SET clause so the resolution does not depend on the caller's session. Also restrict CREATE on schemas that appear in any search path.
Secrets stored in function bodies
Teams sometimes place API keys, connection strings or passwords directly in a function body, a trigger, or a dynamic SQL string. Anyone with access to read the catalog, including roles granted EXECUTE and some monitoring accounts, can see that text through the function definition. Keep credentials in a secrets manager or in externally controlled configuration, pass only references into the database, and confirm that the roles which can read pg_proc or run definition queries are limited to people who should see the logic. Check your code review and migration files for embedded secrets as well.
Audit of who can change routines
A routine's behavior can change without any change to the application code if a role with CREATE or ownership rights on its schema replaces the function. Replacing a definer function with a different body is one of the quieter ways to gain privileges. Limit ownership and CREATE rights on schemas holding routines, record every CREATE OR REPLACE and ALTER FUNCTION in a migration log or audit trail, and compare deployed definitions against the reviewed source on a schedule. Ask the team who holds ownership of each routine schema and how changes reach production.
How to test stored logic and keep it reviewable
Stored logic deserves the same test discipline as application code because a faulty function or procedure runs inside the database, where every application, report and batch job that calls it inherits the defect. Start by writing unit-style tests against fixtures: a small, known set of rows loaded in a scratch database, a call to the function or procedure, and an assertion on the result and on the rows it changed. Run these tests in a transaction that rolls back, so each test starts from the same state. For conversions from Oracle PL/SQL or T-SQL, add regression tests that capture the output of the original system for a representable set of inputs, including nulls, boundary dates and rounding cases, and compare the PL/pgSQL result against it. These tests, not a code read, are what show that a converted function behaves the same way.
Keep the logic reviewable by treating migration files as the change record. Put one function or procedure per file where practical, so a diff shows the actual behavior change instead of a long file with a small edit buried inside it. Use names that state the business action, such as a function that closes a loan account rather than one called proc_upd_3. Add comments that explain the business intent and the rule being enforced, not a restatement of each line. Ask reviewers to read the test change alongside the logic change, and confirm with your own change-control process whether database logic needs a separate sign-off step.
Keep logic thin where application tests are easier to write and run. Validation that depends on request context, feature flags or external services usually belongs in the application, with the database enforcing only the invariants that must hold no matter which client connects, such as constraints, check rules and the state transitions that protect financial or regulated records. Every rule moved into the database is one more rule your test suite must cover in a language your team may read less often. Decide the boundary early, document it in the repository, and review it whenever a new function is proposed.
Questions teams ask before building PL/pgSQL logic
What drives the cost of converting Oracle PL/SQL or T-SQL code to PL/pgSQL?
The main driver is how much of the source code relies on vendor-specific features, not the line count alone. Packages, autonomous transactions, cursor-heavy loops, dynamic SQL, vendor-specific error handling and built-in packages that have no direct PostgreSQL equivalent all add analysis and rewrite work. Cost also depends on how many objects call each other, because a routine that depends on twelve others must be tested as a group. Ask any provider to inventory the source objects by type, dependency and vendor-specific feature before quoting, and ask which parts they expect to redesign rather than translate line by line. Conversion tools can help with the mechanical part, but someone still has to review each result against the original behavior.
How long does a PL/pgSQL conversion project take?
Duration follows the number of routines, their complexity and the number of test cases needed to prove behavior matches the source. A set of simple lookup functions takes far less time than a batch-processing package with transaction control, error logging and scheduled runs. Other factors are how many dependent applications call the logic, whether the business rules are documented, and how quickly the client can confirm expected results. Ask for a written schedule tied to a routine inventory, with milestones for conversion, test execution and sign-off. Any duration you are given should be traceable to those counts and to the test scope, and you should ask what changes if the inventory grows during the work.
What does the client team need to provide for this work?
The client team needs to supply access to the source database or schema exports, the list of applications that call the routines, and people who can explain the business rules behind them. Without those inputs, the converted logic can match the code but not the intent. Teams usually need to provide a non-production environment with representative data, a way to run the existing batch jobs or reports for comparison, and a decision-maker who can accept or reject differences in behavior. Ask the provider which artifacts they need in week one, who on your side signs off on rounding, date and null handling, and how long your reviewers will need to set aside for code review.
Can our in-house team convert and maintain PL/pgSQL logic itself?
An in-house team can do this when it already knows PostgreSQL well, has database engineers who can read the source dialect, and has time to build a regression test suite. The risks are less about syntax and more about subtle differences in transaction behavior, implicit type conversion, error handling and locking. Teams without prior PostgreSQL experience often underestimate how much testing is needed before logic leaves the source system. Before deciding, check whether you have at least one person who can review procedures for transaction control, whether you can maintain tests in version control, and whether the work can be scheduled alongside existing commitments. A partner can also train your team as part of the engagement, which is worth asking for explicitly.
Should business rules live in PostgreSQL functions or in application code?
Put logic in the database when it must hold regardless of which application writes the data, when it enforces integrity constraints, or when set-based processing on large tables is faster where the data sits. Keep logic in application code when it changes often, depends on external services, needs complex branching that your developers test more easily in their usual frameworks, or must scale horizontally with application instances. Many teams split the work: the database enforces invariants and batch transformations, while the application handles workflows and user-facing rules. Ask who will own each rule after go-live, how changes will be deployed and reviewed, and whether your existing test pipeline can cover database routines.
Is it safe to keep stored procedures reviewable as the codebase grows?
It is safe when routines live in version control, changes go through the same review process as application code, and every routine has automated tests that run before deployment. The main reviewability risks are routines edited directly on production, undocumented dependencies between functions and procedures, and transaction control scattered across many callers. Ask how migrations will be versioned, whether a schema migration tool will manage routine definitions, and how you will identify which applications call each function before changing it. Clear naming, comments that describe business intent and a short list of owners for each module make review far faster for security and compliance reviewers as well.
What testing should we require before PL/pgSQL logic goes live?
Require tests that compare results from the source system and the PostgreSQL version using the same inputs, plus tests for error paths, null handling, rounding, date boundaries and transaction rollback. Unit tests help with individual functions, but the most useful evidence usually comes from replaying representative batches and comparing outputs row by row. Ask whether the test suite will run in continuous integration, who approves differences, and how test data is anonymized if it comes from production. Also confirm that permissions are tested, because a routine that runs as the wrong role can expose data even when its output looks correct.
Does moving logic into the database change our security and access model?
Yes. Functions and procedures can run with the privileges of their owner when defined as SECURITY DEFINER, and that setting needs deliberate review because it can grant callers more access than they hold directly. Ownership, execute privileges and the search path also affect what a routine can reach. Ask the provider how they will document each routine's owner, privileges and whether it runs as definer or invoker, and how those settings will be checked in review. Access reviews for auditors become simpler when this information is kept in the same repository as the code.
Limits to confirm in your PostgreSQL version and environment
Procedural logic behaves differently depending on the PostgreSQL major version, the driver and the connection pooler in front of the database. The cards below list the limits to confirm before you commit business logic to stored routines, so the design holds in your environment rather than only in a test database.
Procedural features by major version
Check which PL/pgSQL syntax, extensions and language options your target major version supports, including the options available in the version you plan to run for the next several years. Supported versions and end-of-life dates differ, so a routine written for one release may need changes before an upgrade. Confirm the exact behavior in the official documentation for your version and keep a list of features your team depends on, such as specific exception handling or dynamic SQL patterns.
- Support per major version
- 5 years
Transaction control through the driver
A procedure that issues COMMIT or ROLLBACK only works when it is called outside an open transaction block, so the way your application driver wraps calls matters. Some drivers open a transaction by default, which can make a procedure fail or silently run in a different transaction scope than the one you tested. Verify with your exact driver and its autocommit setting, and record the calling pattern in your standards.
Connection pooler session behavior
Transaction-mode poolers such as PgBouncer hand a server connection to different clients between transactions, so session state set with SET, temporary tables and advisory locks may not persist as the routine expects. Check the pool mode, the version you run (PgBouncer 1.26.1 was released on October 14, 2026 with security fixes), and whether your routines depend on session-level settings. Confirm the pooler documentation for the mode you choose.
PgBouncer sitePerformance under your workload
A routine that runs in milliseconds on a test dataset can slow down on production volumes, particularly when it loops over rows, calls functions per row or plans dynamic SQL repeatedly. Test with data sized and distributed like production, and measure plan behavior for the parameter values your users send. Record baseline timings so a later upgrade or schema change can be compared against them.
Testing tools your team must add
PostgreSQL does not ship a complete unit testing framework for routines, so teams usually add a test runner such as pgTAP or a harness in their CI pipeline. Confirm that the tool supports your major version, that it can run against a disposable database, and that it works with your migration tool. Ask the implementation partner or your own engineers to name each tool and who maintains it after handover.
Ownership and privileges of routines
Functions run with the privileges of their owner unless they are marked SECURITY DEFINER, and that setting changes what a caller can reach. Confirm how your roles, schema privileges and default execute grants are set up in your environment, because public execute rights are granted by default on new functions. Review these settings with your security team before any routine touches regulated data.
What DeployOpen needs from your team to scope the work
Before DeployOpen can write a fixed-scope quote for PL/pgSQL work, we need an inventory of every routine in the database: functions, procedures, triggers, and the scheduled jobs that call them. For each object, list its name, schema, language, whether it is a FUNCTION or a PROCEDURE, and which applications or roles call it. Include pg_cron or operating system scheduler entries if they exist, and any logic that lives in the application layer and duplicates a database routine. Without this list, the effort to convert, test and review the code cannot be estimated, and the largest unknowns usually sit in triggers and jobs nobody has documented.
The second input is access. We need read access to the source catalog, either a live connection with a read-only role or schema-only exports taken with pg_dump --schema-only, plus any Oracle PL/SQL or T-SQL source that the PostgreSQL code was ported from. Provide sample data that exercises the edge cases the business cares about, such as null handling, rounding, date boundaries and currency precision, because those are where converted routines drift. Named business owners must sign off on each rule with a worked example. Confirm with your team which PostgreSQL major version runs in production, since the supported versions and their end-of-life dates are listed in the PostgreSQL versioning policy.
Finally, describe the test and deployment process you already use. Tell us whether routines are kept in version control, whether migrations run through a tool, who approves changes, and whether a staging environment matches production. If none of these exist, the quote should include them as deliverables, and you should decide who will own them after handover. The scope, deliverables, acceptance criteria and timelines are agreed in writing before work starts, so every input above should be confirmed in writing as well. Ask DeployOpen to state which inputs it assumed and what changes if an assumption turns out to be wrong.
How DeployOpen scopes, builds and supports PL/pgSQL logic
DeployOpen plans, implements and hands over PL/pgSQL stored procedures and functions inside PostgreSQL clusters that run in your own infrastructure. Each engagement starts with a written scope that defines which logic moves, how it is tested and who maintains it after handover.
How we scope
- Inventory the existing functions, procedures, triggers and calling applications before agreeing any build work.
- Agree in writing which logic is ported, rewritten or retired, and which PostgreSQL major version it targets.
- Define the test, review and deployment process for logic changes, and who approves each release.
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
How we build
- Write functions and procedures with explicit signatures, security settings and error handling that reviewers can read.
- Build a regression test suite that runs against a copy of your schema and representative reference data.
- Compare results from migrated logic against the original system for agreed transaction samples.
- Keep the database code in version control with a review step before anything reaches a shared environment.
How we hand over
- Deliver a written catalogue of routines, their owners, dependencies, privileges and calling applications.
- Document transaction boundaries, known differences from the source dialect and the reasons behind each choice.
- Walk your database and application teams through the test suite, deployment steps and rollback procedure.
- Confirm with your security team how execution rights, definer settings and role grants are reviewed over time.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers once the handover is complete.
- A retainer can cover review of new routines, regression runs after PostgreSQL minor or major upgrades, and test maintenance.
- Ask any provider to confirm how logic changes are reviewed, tested and rolled back before they accept a retainer.

