-
-
Notifications
You must be signed in to change notification settings - Fork 499
Closed
Description
fn main() -> Result<(), postgres::Error> {
use postgres::{Client, NoTls};
let mut client = Client::connect("host=localhost user=postgres", NoTls)?;
let _ = client.batch_execute("drop table t");
client.batch_execute("create table t (i int, unique (i) DEFERRABLE INITIALLY DEFERRED);")?;
client.execute("insert into t values (1);", &[])?;
client.execute("insert into t values (1);", &[])?;
client.execute("insert into t values (1);", &[])?;
println!("rows: {}", client.query("SELECT * FROM t", &[])?.len());
Ok(())
}
Here we expect 3 rows to be present because the three execute calls succeed, however only one row is actually present. This happens because the ErrorResponse message is produced only after postgres attempts to commit the transaction in response to the Sync message. Using deferred constraints causes postgres to delay constraint checking until transaction commit time.
See https://github.com/MaterializeInc/database-issues/issues/2673
Metadata
Metadata
Assignees
Labels
No labels