@@ -342,13 +342,16 @@ async def _get_statement(
342342 * ,
343343 named : bool = False ,
344344 use_cache : bool = True ,
345+ ignore_custom_codec = False ,
345346 record_class = None
346347 ):
347348 if record_class is None :
348349 record_class = self ._protocol .get_record_class ()
349350
350351 if 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+ )
352355 if statement is not None :
353356 return statement
354357
@@ -371,6 +374,7 @@ async def _get_statement(
371374 query ,
372375 timeout ,
373376 record_class = record_class ,
377+ ignore_custom_codec = ignore_custom_codec ,
374378 )
375379 need_reprepare = False
376380 types_with_missing_codecs = statement ._init_types ()
@@ -415,7 +419,8 @@ async def _get_statement(
415419 )
416420
417421 if 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
427432 async def _introspect_types (self , typeoids , timeout ):
428433 return 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
431441 async def _introspect_type (self , typename , schema ):
432442 if (
@@ -439,20 +449,22 @@ async def _introspect_type(self, typename, schema):
439449 [typeoid ],
440450 limit = 0 ,
441451 timeout = None ,
452+ ignore_custom_codec = True ,
442453 )
443- if rows :
444- typeinfo = rows [0 ]
445- else :
446- typeinfo = None
447454 else :
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 :
452464 raise ValueError (
453465 'unknown type: {}.{}' .format (schema , typename ))
454466
455- return typeinfo
467+ return rows [ 0 ]
456468
457469 def cursor (
458470 self ,
@@ -1325,7 +1337,9 @@ def _mark_stmts_as_closed(self):
13251337 def _maybe_gc_stmt (self , stmt ):
13261338 if (
13271339 stmt .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(
15891603 timeout ,
15901604 * ,
15911605 return_status = False ,
1606+ ignore_custom_codec = False ,
15921607 record_class = None
15931608 ):
15941609 with self ._stmt_exclusive_section :
@@ -1599,6 +1614,7 @@ async def _execute(
15991614 timeout ,
16001615 return_status = return_status ,
16011616 record_class = record_class ,
1617+ ignore_custom_codec = ignore_custom_codec ,
16021618 )
16031619 return result
16041620
@@ -1610,6 +1626,7 @@ async def __execute(
16101626 timeout ,
16111627 * ,
16121628 return_status = False ,
1629+ ignore_custom_codec = False ,
16131630 record_class = None
16141631 ):
16151632 executor = lambda stmt , timeout : self ._protocol .bind_execute (
@@ -1620,6 +1637,7 @@ async def __execute(
16201637 executor ,
16211638 timeout ,
16221639 record_class = record_class ,
1640+ ignore_custom_codec = ignore_custom_codec ,
16231641 )
16241642
16251643 async def _executemany (self , query , args , timeout ):
@@ -1637,20 +1655,23 @@ async def _do_execute(
16371655 timeout ,
16381656 retry = True ,
16391657 * ,
1658+ ignore_custom_codec = False ,
16401659 record_class = None
16411660 ):
16421661 if timeout is None :
16431662 stmt = await self ._get_statement (
16441663 query ,
16451664 None ,
16461665 record_class = record_class ,
1666+ ignore_custom_codec = ignore_custom_codec ,
16471667 )
16481668 else :
16491669 before = time .monotonic ()
16501670 stmt = await self ._get_statement (
16511671 query ,
16521672 timeout ,
16531673 record_class = record_class ,
1674+ ignore_custom_codec = ignore_custom_codec ,
16541675 )
16551676 after = time .monotonic ()
16561677 timeout -= after - before
0 commit comments