A way to run non-transactional DDL commands / PG requires autocommit to modify a type ?!
See original GitHub issueMigrated issue, originally created by Wichert Akkerman (@wichert)
Unfortunately not all DDL commands for PostgreSQL can be used in a transaction. I ran into this when trying to add a new value to an enum:
db=# BEGIN;
BEGIN
db=# ALTER TYPE article_type ADD VALUE 'unknown';
ERROR: ALTER TYPE ... ADD cannot run inside a transaction block
I’m not sure what the best way to handle this is in alembic currently. Perhaps do op.execute('COMMIT')
manually? Perhaps alembic needs an in-between-commit operation for this.
Issue Analytics
- State:
- Created 10 years ago
- Comments:11 (1 by maintainers)
Top Results From Across the Web
SQL statements That Cause an Implicit Commit - MariaDB
List of statements which implicitly commit the current transaction. ... As a rule of thumb, such statements are DDL statements. The same statements...
Read more >13.3.1 START TRANSACTION, COMMIT, and ROLLBACK ...
By default, MySQL runs with autocommit mode enabled. ... SELECT @A:=SUM(salary) FROM table1 WHERE type=1; UPDATE table2 SET summary=@A WHERE type=1; COMMIT;.
Read more >Non-transactional data access and the auto-commit mode
The autocommit mode is useful for ad hoc execution of SQL. Imagine that you connect to your database with an SQL console and...
Read more >why commit is not required for DDL Commands — oracle-tech
DDL is auto commit and you need not to issue commit statement as it affects on structure or meta data in the database...
Read more >Non-Transactional DML Statements - PingCAP Docs
Usually, memory-consuming transactions need to be split into multiple SQL statements to bypass the transaction size limit. Non-transactional DML statements ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Wichert Akkerman (@wichert) wrote:
Looks like psycopg2 doesn’t do that here for some reason. This code ran without problems:
Mike Bayer has proposed a fix for this issue in the master branch:
Add autocommit_block https://gerrit.sqlalchemy.org/1463