]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Pin standard_conforming_strings on the PostgreSQL CI test database
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 13 May 2026 03:47:36 +0000 (21:47 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 13 May 2026 03:47:36 +0000 (21:47 -0600)
PQescapeStringConn doubles backslashes when the connection's
std_strings flag is false, which trips the backslash assertion in
src/tests/modules/sql_postgresql/escape.unlang on test servers where
the parameter isn't being reported as on. Pin it at the database
level in postgresql-setup.sh so every connection inherits it, and
restore the backslash assertion in the test.

scripts/ci/postgresql-setup.sh
src/tests/modules/sql_postgresql/escape.unlang

index 1e1abfbe67ad38523dccac3926350ea62a4be372..6f62b2e19362690e991db4b1a3b5b511deea2eb2 100755 (executable)
@@ -16,6 +16,14 @@ psql -h "${SQL_POSTGRESQL_TEST_SERVER}" -c 'drop user radius;' -U postgres || tr
 echo "PostgreSQL - Creating database"
 psql -h "${SQL_POSTGRESQL_TEST_SERVER}" -c 'create database radius;' -U postgres || true
 
+#
+#  Pin standard_conforming_strings = on for new connections to this DB.
+#  Modern PostgreSQL defaults to on (since 9.1), but pinning it here makes
+#  the escape tests' expected output deterministic across server configs.
+#
+echo "PostgreSQL - Pinning standard_conforming_strings"
+psql -h "${SQL_POSTGRESQL_TEST_SERVER}" -c 'ALTER DATABASE radius SET standard_conforming_strings = on;' -U postgres
+
 echo "PostgreSQL - Execute schema.sql"
 psql -h "${SQL_POSTGRESQL_TEST_SERVER}" -U postgres radius < raddb/mods-config/sql/main/postgresql/schema.sql
 
index fa9862f728312ccb8596e928deeaf60b320b77ce..e307ab2836ad3efd20c916cff3f6a70f7278696c 100644 (file)
@@ -1,10 +1,10 @@
 #
 #  PostgreSQL escape function (via PQescapeStringConn).
 #
-#  With standard_conforming_strings = on (the default since 9.1)
-#  PQescapeStringConn only doubles single quotes.  Backslashes and
-#  other byte values pass through unchanged - the SQL string literal
-#  grammar treats them as literal characters.
+#  Assumes standard_conforming_strings = on on the test server.  Under that
+#  mode PQescapeStringConn only doubles single quotes - backslashes and
+#  other byte values pass through unchanged.  The CI postgres setup script
+#  pins this on the test database.
 #
 #  String literals in unlang are marked "safe for any escape" so we wrap
 #  each input in %taint(...) to force the escape to actually run.
@@ -29,8 +29,7 @@ if (%sql.escape(%taint("''")) != "''''") {
 }
 
 #
-#  Backslash passes through (assumes standard_conforming_strings = on
-#  on the test server, which is the default in modern PostgreSQL).
+#  Backslash passes through unchanged.
 #
 if (%sql.escape(%taint("back\\slash")) != "back\\slash") {
        test_fail