-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Hi,
I’ve encountered some strange behavior in your package. If I prepare a statement using a given connection, and then try to execute that prepared statement inside a transaction on the same connection, the execution hangs indefinitely.
However, if I prepare the statement inside the transaction, everything works as expected.
Does this mean that it’s not possible to use pre-prepared statements within a transaction, even if they are created on the same connection? Is this the intended behavior?
Thanks in advance for your clarification.
Best regards,
import 'dart:async';
import 'package:postgres/postgres.dart';
import 'package:dotenv/dotenv.dart';
import 'dart:io';
void main() async {
final envPath = Platform.environment['DB_CONFIG'];
final env = DotEnv()..load([envPath!]);
final endpoint = Endpoint(
host: env['DB_HOST']!,
database: env['DB_NAME']!,
port: int.parse(env['DB_PORT']!),
username: env['DB_USER']!,
password: env['DB_PASSWORD']!,
);
var c1 = await Connection.open(endpoint);
var s1 = await c1.prepare('SELECT * FROM catalog.test FOR SHARE');
var completer1 = Completer();
c1.runTx(
(txSession) async {
print('try lock');
var s2 = await txSession.prepare('SELECT * FROM catalog.test FOR SHARE');
// s1 = s2;
// Here the request hangs for some reason.
// But if you use the second query instead of the current value, then
// everything is fine (s1 = s2).
await s1.run(null);
print('blocking completed');
return completer1.future;
},
);
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working