File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,11 @@ pub unsafe extern "C" fn _PG_init() {
148
148
GucContext :: Userset ,
149
149
GucFlags :: NO_SHOW_ALL ,
150
150
) ;
151
+ #[ cfg( any( feature = "pg15" , feature = "pg16" , feature = "pg17" ) ) ]
152
+ unsafe {
153
+ use pg_sys:: AsPgCStr ;
154
+ pg_sys:: MarkGUCPrefixReserved ( "lantern_extras" . as_pg_cstr ( ) ) ;
155
+ }
151
156
}
152
157
153
158
#[ pg_guard]
@@ -245,3 +250,24 @@ pub mod pg_test {
245
250
]
246
251
}
247
252
}
253
+
254
+ #[ cfg( any( test, feature = "pg_test" ) ) ]
255
+ #[ pg_schema]
256
+ pub mod tests {
257
+
258
+ // note: this will not get to unwrap, since the failure in the result only represents
259
+ // failures in the SPI machinery.
260
+ // Postgres aborts the transaction and returns an error message to the client when the SPI
261
+ // query fails. So, the rust interface has no Error representation for a failed query.
262
+ // As a last resort we can ensure the test panics with the expected message.
263
+ // https://www.postgresql.org/docs/current/spi.html
264
+
265
+ #[ cfg( any( feature = "pg15" , feature = "pg16" , feature = "pg17" ) ) ]
266
+ #[ pgrx:: pg_test]
267
+ #[ should_panic( expected = "invalid configuration parameter name" ) ]
268
+ fn lantern_extras_prefix_reserved ( ) {
269
+ use pgrx:: { error, Spi } ;
270
+ Spi :: run ( "SET lantern_extras.aldkjalsdkj_invalid_param = 42" ) . unwrap ( ) ;
271
+ error ! ( "Managed to update a reserved-prefix variable. This should never be reached" ) ;
272
+ }
273
+ }
You can’t perform that action at this time.
0 commit comments