Skip to content

Commit 12ac331

Browse files
committed
Add skip_load parameter to connect and setUpAge functions to control plugin loading.
Fix for apache#2325
1 parent 23146a4 commit 12ac331

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

drivers/python/age/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ def version():
2525

2626

2727
def connect(dsn=None, graph=None, connection_factory=None, cursor_factory=ClientCursor, load_from_plugins=False,
28-
**kwargs):
28+
skip_load=False, **kwargs):
2929

3030
dsn = conninfo.make_conninfo('' if dsn is None else dsn, **kwargs)
3131

3232
ag = Age()
3333
ag.connect(dsn=dsn, graph=graph, connection_factory=connection_factory, cursor_factory=cursor_factory,
34-
load_from_plugins=load_from_plugins, **kwargs)
34+
load_from_plugins=load_from_plugins, skip_load=skip_load, **kwargs)
3535
return ag
3636

3737
# Dummy ResultHandler

drivers/python/age/age.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,13 @@ def load(self, data: bytes | bytearray | memoryview) -> Any | None:
137137
return parseAgeValue(data_bytes.decode('utf-8'))
138138

139139

140-
def setUpAge(conn:psycopg.connection, graphName:str, load_from_plugins:bool=False):
140+
def setUpAge(conn:psycopg.connection, graphName:str, load_from_plugins:bool=False, skip_load:bool=False):
141141
with conn.cursor() as cursor:
142-
if load_from_plugins:
143-
cursor.execute("LOAD '$libdir/plugins/age';")
144-
else:
145-
cursor.execute("LOAD 'age';")
142+
if not skip_load:
143+
if load_from_plugins:
144+
cursor.execute("LOAD '$libdir/plugins/age';")
145+
else:
146+
cursor.execute("LOAD 'age';")
146147

147148
cursor.execute("SET search_path = ag_catalog, '$user', public;")
148149

@@ -333,9 +334,9 @@ def __init__(self):
333334

334335
# Connect to PostgreSQL Server and establish session and type extension environment.
335336
def connect(self, graph:str=None, dsn:str=None, connection_factory=None, cursor_factory=ClientCursor,
336-
load_from_plugins:bool=False, **kwargs):
337+
load_from_plugins:bool=False, skip_load:bool=False, **kwargs):
337338
conn = psycopg.connect(dsn, cursor_factory=cursor_factory, **kwargs)
338-
setUpAge(conn, graph, load_from_plugins)
339+
setUpAge(conn, graph, load_from_plugins, skip_load=skip_load)
339340
self.connection = conn
340341
self.graphName = graph
341342
return self

0 commit comments

Comments
 (0)