Avoid privilege requirements by using an advisory lock in test setup (postgres). (#3753)

* feat(sqlx-postgres): use advisory lock to avoid setup race condition

* fix(sqlx-postgres): numeric hex constants not supported before postgres 16
This commit is contained in:
kildrens
2025-02-21 02:13:56 +00:00
committed by GitHub
parent 8dce6bd9e1
commit a9dfb4f2c1

View File

@@ -134,8 +134,9 @@ async fn test_context(args: &TestArgs) -> Result<TestContext<Postgres>, Error> {
// I couldn't find a bug on the mailing list for `CREATE SCHEMA` specifically,
// but a clearly related bug with `CREATE TABLE` has been known since 2007:
// https://www.postgresql.org/message-id/200710222037.l9MKbCJZ098744%40wwwmaster.postgresql.org
// magic constant 8318549251334697844 is just 8 ascii bytes 'sqlxtest'.
r#"
lock table pg_catalog.pg_namespace in share row exclusive mode;
select pg_advisory_xact_lock(8318549251334697844);
create schema if not exists _sqlx_test;