mirror of
https://github.com/neondatabase/neon.git
synced 2025-12-22 21:59:59 +00:00
As a DBaaS provider, Neon needs to provide a stable platform for customers to build applications upon. At the same time however, we also need to enable customers to use the latest and greatest technology, so they can prototype their work, and we can solicit feedback. If all extensions are treated the same in terms of stability, it is hard to meet that goal. There are now two new GUCs created by the Neon extension: neon.allow_unstable_extensions: This is a session GUC which allows a session to install and load unstable extensions. neon.unstable_extensions: This is a comma-separated list of extension names. We can check if a CREATE EXTENSION statement is attempting to install an unstable extension, and if so, deny the request if neon.allow_unstable_extensions is not set to true. Signed-off-by: Tristan Partin <tristan@neon.tech> Co-authored-by: Konstantin Knizhnik <knizhnik@neon.tech>
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING, cast
|
|
|
|
import pytest
|
|
from psycopg2.errors import InsufficientPrivilege
|
|
|
|
if TYPE_CHECKING:
|
|
from fixtures.neon_fixtures import NeonEnv
|
|
|
|
|
|
def test_unstable_extensions_installation(neon_simple_env: NeonEnv):
|
|
"""
|
|
Test that the unstable extension support within the neon extension can
|
|
block extension installation.
|
|
"""
|
|
env = neon_simple_env
|
|
|
|
neon_unstable_extensions = "pg_prewarm,amcheck"
|
|
|
|
endpoint = env.endpoints.create(
|
|
"main",
|
|
config_lines=[
|
|
"neon.allow_unstable_extensions=false",
|
|
f"neon.unstable_extensions='{neon_unstable_extensions}'",
|
|
],
|
|
)
|
|
endpoint.respec(skip_pg_catalog_updates=False)
|
|
endpoint.start()
|
|
|
|
with endpoint.cursor() as cursor:
|
|
cursor.execute("SELECT current_setting('neon.unstable_extensions')")
|
|
result = cursor.fetchone()
|
|
assert result is not None
|
|
setting = cast("str", result[0])
|
|
assert setting == neon_unstable_extensions
|
|
|
|
with pytest.raises(InsufficientPrivilege):
|
|
cursor.execute("CREATE EXTENSION pg_prewarm")
|
|
|
|
with pytest.raises(InsufficientPrivilege):
|
|
cursor.execute("CREATE EXTENSION amcheck")
|
|
|
|
# Make sure that we can install a "stable" extension
|
|
cursor.execute("CREATE EXTENSION pageinspect")
|
|
|
|
cursor.execute("BEGIN")
|
|
cursor.execute("SET neon.allow_unstable_extensions TO true")
|
|
cursor.execute("CREATE EXTENSION pg_prewarm")
|
|
cursor.execute("COMMIT")
|