CONTEXT: PL/pgSQL function transaction_test1() line 6 at COMMIT
SQL state: 2D000
The exact version of PostgreSQL: PostgreSQL 12.7 (Ubuntu 12.7-0ubuntu0.20.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, 64-bit
I copy and paste your example, and it works for me. And the contents of the table look good to me:
$ psql Time: 4.458 ms psql (12.7) Type "help" for help.