# PostgreSQL - Invoking SQL function while doing CREATE OR REPLACE on it

**URL:** <https://forum.liquibase.org/t/postgresql-invoking-sql-function-while-doing-create-or-replace-on-it/8189>\
**Category:** Uncategorized\
**Created:** [May 4, 2023, 4:54pm UTC](https://forum.liquibase.org/t/postgresql-invoking-sql-function-while-doing-create-or-replace-on-it/8189 "2023-05-04T16:54:16Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![namahesh](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@namahesh](https://forum.liquibase.org/u/namahesh)\
**Post date:** [May 5, 2023, 1:21pm UTC](https://forum.liquibase.org/t/postgresql-invoking-sql-function-while-doing-create-or-replace-on-it/8189/3 "2023-05-05T13:21:07Z")

</div>

Hi @PJatLiquibase ,

I am using the community edition of Liquibase, so this is being done using a formatted SQL changelog.

I realized what was happening.  
I had 2 `changeSet`s in a single changelog:

- `changeSet` 1 - was dropping a user-defined type (using `DROP TYPE CASCADE`) which was inadvertently also dropping these functions which were using this type
- `changeSet` 2 - was doing a `CREATE OR REPLACE FUNCTION` which re-created these functions

Since each changeSet is a separate transaction, the tiny gap in time after the first transaction commit, but before the second transaction could commit was when these functions actually ceased to exist.  
Any invocations of these functions during this time window failed.

This has been fixed now.  
Appreciate your response.

Thanks,  
Nagendra

---

_[View the full topic](https://forum.liquibase.org/t/postgresql-invoking-sql-function-while-doing-create-or-replace-on-it/8189)._
