Opened 3 years ago
Last modified 3 years ago
#33741 closed Bug
Transaction Management inside PROCEDURE — at Initial Version
| Reported by: | Victor Vieux | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 4.0 |
| Severity: | Normal | Keywords: | database procedure transaction |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Hello,
I have a PROCEDURE that uses [Transaction Management](https://www.postgresql.org/docs/current/plpgsql-transactions.html) from postgres (meaning there are COMMITs inside the procedure itself)
It runs fine in postgres, but when trying to invoke it from django either via
with connection.cursor() as c:
c.execute(...)
or
cursor.callproc
I get the following error:
django.db.utils.InternalError: invalid transaction termination CONTEXT: PL/pgSQL function xxx() line xx at COMMIT
I think that's because when executing raw queries with execute, they are run inside a transaction?
Is there a way to bypass this?
Thanks.
Note:
See TracTickets
for help on using tickets.