]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
test: fix tests with master version of crdb
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 12 Sep 2025 15:14:00 +0000 (17:14 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 12 Sep 2025 15:41:45 +0000 (17:41 +0200)
The server version reported is 250300. Tests fail with the error:

    psycopg.errors.OperatorIntervention: this schema change is
    disallowed because table "execmany" is locked and this operation cannot
    automatically unlock the table

    DETAIL:  To unlock the table, execute `ALTER TABLE execmany SET (schema_locked = false);`

    After the schema change completes, we recommend setting it back to
    true with `ALTER TABLE execmany SET (schema_locked = true);`.

    HINT:  Locking the table improves changefeed performance; see
    https://www.cockroachlabs.com/docs/dev/changefeed-best-practices.html#lock-the-schema-on-changefeed-watched-tables

tests/_test_cursor.py

index ee4b4acae00dc3dbeb365597e5c8ef5421dac4b8..fdc38daece6699f801564c4664c3cefdd35df0ab 100644 (file)
@@ -15,8 +15,7 @@ from psycopg.rows import RowMaker
 
 @pytest.fixture(scope="session")
 def _execmany(svcconn):
-    cur = svcconn.cursor()
-    cur.execute(
+    svcconn.execute(
         """
         drop table if exists execmany;
         create table execmany (id serial primary key, num integer, data text)
@@ -26,8 +25,7 @@ def _execmany(svcconn):
 
 @pytest.fixture(scope="function")
 def execmany(svcconn, _execmany):
-    cur = svcconn.cursor()
-    cur.execute("truncate table execmany")
+    svcconn.execute("delete from execmany")
 
 
 def ph(cur: Any, query: str) -> str: