@@ -342,13 +342,16 @@ async def _get_statement(
342342* ,
343343named : bool = False ,
344344use_cache : bool = True ,
345+ ignore_custom_codec = False ,
345346record_class = None
346347 ):
347348if record_class is None :
348349record_class = self ._protocol .get_record_class ()
349350
350351if use_cache :
351- statement = self ._stmt_cache .get ((query , record_class ))
352+ statement = self ._stmt_cache .get (
353+ (query , record_class , ignore_custom_codec )
354+ )
352355if statement is not None :
353356return statement
354357
@@ -371,6 +374,7 @@ async def _get_statement(
371374query ,
372375timeout ,
373376record_class = record_class ,
377+ ignore_custom_codec = ignore_custom_codec ,
374378 )
375379need_reprepare = False
376380types_with_missing_codecs = statement ._init_types ()
@@ -415,7 +419,8 @@ async def _get_statement(
415419 )
416420
417421if use_cache :
418- self ._stmt_cache .put ((query , record_class ), statement )
422+ self ._stmt_cache .put (
423+ (query , record_class , ignore_custom_codec ), statement )
419424
420425# If we've just created a new statement object, check if there
421426# are any statements for GC.
@@ -426,7 +431,12 @@ async def _get_statement(
426431
427432async def _introspect_types (self , typeoids , timeout ):
428433return await self .__execute (
429- self ._intro_query , (list (typeoids ),), 0 , timeout )
434+ self ._intro_query ,
435+ (list (typeoids ),),
436+ 0 ,
437+ timeout ,
438+ ignore_custom_codec = True ,
439+ )
430440
431441async def _introspect_type (self , typename , schema ):
432442if (
@@ -439,20 +449,22 @@ async def _introspect_type(self, typename, schema):
439449 [typeoid ],
440450limit = 0 ,
441451timeout = None ,
452+ ignore_custom_codec = True ,
442453 )
443- if rows :
444- typeinfo = rows [0 ]
445- else :
446- typeinfo = None
447454else :
448- typeinfo = await self .fetchrow (
449- introspection .TYPE_BY_NAME , typename , schema )
455+ rows = await self ._execute (
456+ introspection .TYPE_BY_NAME ,
457+ [typename , schema ],
458+ limit = 1 ,
459+ timeout = None ,
460+ ignore_custom_codec = True ,
461+ )
450462
451- if not typeinfo :
463+ if not rows :
452464raise ValueError (
453465'unknown type:{}.{}' .format (schema , typename ))
454466
455- return typeinfo
467+ return rows [ 0 ]
456468
457469def cursor (
458470self ,
@@ -1325,7 +1337,9 @@ def _mark_stmts_as_closed(self):
13251337def _maybe_gc_stmt (self , stmt ):
13261338if (
13271339stmt .refs == 0
1328- and not self ._stmt_cache .has ((stmt .query , stmt .record_class ))
1340+ and not self ._stmt_cache .has (
1341+ (stmt .query , stmt .record_class , stmt .ignore_custom_codec )
1342+ )
13291343 ):
13301344# If low-level `stmt` isn't referenced from any high-level
13311345# `PreparedStatement` object and is not in the `_stmt_cache`:
@@ -1589,6 +1603,7 @@ async def _execute(
15891603timeout ,
15901604* ,
15911605return_status = False ,
1606+ ignore_custom_codec = False ,
15921607record_class = None
15931608 ):
15941609with self ._stmt_exclusive_section :
@@ -1599,6 +1614,7 @@ async def _execute(
15991614timeout ,
16001615return_status = return_status ,
16011616record_class = record_class ,
1617+ ignore_custom_codec = ignore_custom_codec ,
16021618 )
16031619return result
16041620
@@ -1610,6 +1626,7 @@ async def __execute(
16101626timeout ,
16111627* ,
16121628return_status = False ,
1629+ ignore_custom_codec = False ,
16131630record_class = None
16141631 ):
16151632executor = lambda stmt , timeout : self ._protocol .bind_execute (
@@ -1620,6 +1637,7 @@ async def __execute(
16201637executor ,
16211638timeout ,
16221639record_class = record_class ,
1640+ ignore_custom_codec = ignore_custom_codec ,
16231641 )
16241642
16251643async def _executemany (self , query , args , timeout ):
@@ -1637,20 +1655,23 @@ async def _do_execute(
16371655timeout ,
16381656retry = True ,
16391657* ,
1658+ ignore_custom_codec = False ,
16401659record_class = None
16411660 ):
16421661if timeout is None :
16431662stmt = await self ._get_statement (
16441663query ,
16451664None ,
16461665record_class = record_class ,
1666+ ignore_custom_codec = ignore_custom_codec ,
16471667 )
16481668else :
16491669before = time .monotonic ()
16501670stmt = await self ._get_statement (
16511671query ,
16521672timeout ,
16531673record_class = record_class ,
1674+ ignore_custom_codec = ignore_custom_codec ,
16541675 )
16551676after = time .monotonic ()
16561677timeout -= after - before
0 commit comments