From a9dfb4f2c1f370845162a475f003919b7b6ee69f Mon Sep 17 00:00:00 2001 From: kildrens <5198060+kildrens@users.noreply.github.com> Date: Fri, 21 Feb 2025 02:13:56 +0000 Subject: [PATCH] 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 --- sqlx-postgres/src/testing/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sqlx-postgres/src/testing/mod.rs b/sqlx-postgres/src/testing/mod.rs index 373bd772d..af20fe87e 100644 --- a/sqlx-postgres/src/testing/mod.rs +++ b/sqlx-postgres/src/testing/mod.rs @@ -134,8 +134,9 @@ async fn test_context(args: &TestArgs) -> Result, 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;