@@ -342,13 +342,16 @@ async def _get_statement(
342
342
* ,
343
343
named : bool = False ,
344
344
use_cache : bool = True ,
345
+ ignore_custom_codec = False ,
345
346
record_class = None
346
347
):
347
348
if record_class is None :
348
349
record_class = self ._protocol .get_record_class ()
349
350
350
351
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
+ )
352
355
if statement is not None :
353
356
return statement
354
357
@@ -371,6 +374,7 @@ async def _get_statement(
371
374
query ,
372
375
timeout ,
373
376
record_class = record_class ,
377
+ ignore_custom_codec = ignore_custom_codec ,
374
378
)
375
379
need_reprepare = False
376
380
types_with_missing_codecs = statement ._init_types ()
@@ -415,7 +419,8 @@ async def _get_statement(
415
419
)
416
420
417
421
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 )
419
424
420
425
# If we've just created a new statement object, check if there
421
426
# are any statements for GC.
@@ -426,7 +431,12 @@ async def _get_statement(
426
431
427
432
async def _introspect_types (self , typeoids , timeout ):
428
433
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
+ )
430
440
431
441
async def _introspect_type (self , typename , schema ):
432
442
if (
@@ -439,20 +449,22 @@ async def _introspect_type(self, typename, schema):
439
449
[typeoid ],
440
450
limit = 0 ,
441
451
timeout = None ,
452
+ ignore_custom_codec = True ,
442
453
)
443
- if rows :
444
- typeinfo = rows [0 ]
445
- else :
446
- typeinfo = None
447
454
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
+ )
450
462
451
- if not typeinfo :
463
+ if not rows :
452
464
raise ValueError (
453
465
'unknown type: {}.{}' .format (schema , typename ))
454
466
455
- return typeinfo
467
+ return rows [ 0 ]
456
468
457
469
def cursor (
458
470
self ,
@@ -1325,7 +1337,9 @@ def _mark_stmts_as_closed(self):
1325
1337
def _maybe_gc_stmt (self , stmt ):
1326
1338
if (
1327
1339
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
+ )
1329
1343
):
1330
1344
# If low-level `stmt` isn't referenced from any high-level
1331
1345
# `PreparedStatement` object and is not in the `_stmt_cache`:
@@ -1589,6 +1603,7 @@ async def _execute(
1589
1603
timeout ,
1590
1604
* ,
1591
1605
return_status = False ,
1606
+ ignore_custom_codec = False ,
1592
1607
record_class = None
1593
1608
):
1594
1609
with self ._stmt_exclusive_section :
@@ -1599,6 +1614,7 @@ async def _execute(
1599
1614
timeout ,
1600
1615
return_status = return_status ,
1601
1616
record_class = record_class ,
1617
+ ignore_custom_codec = ignore_custom_codec ,
1602
1618
)
1603
1619
return result
1604
1620
@@ -1610,6 +1626,7 @@ async def __execute(
1610
1626
timeout ,
1611
1627
* ,
1612
1628
return_status = False ,
1629
+ ignore_custom_codec = False ,
1613
1630
record_class = None
1614
1631
):
1615
1632
executor = lambda stmt , timeout : self ._protocol .bind_execute (
@@ -1620,6 +1637,7 @@ async def __execute(
1620
1637
executor ,
1621
1638
timeout ,
1622
1639
record_class = record_class ,
1640
+ ignore_custom_codec = ignore_custom_codec ,
1623
1641
)
1624
1642
1625
1643
async def _executemany (self , query , args , timeout ):
@@ -1637,20 +1655,23 @@ async def _do_execute(
1637
1655
timeout ,
1638
1656
retry = True ,
1639
1657
* ,
1658
+ ignore_custom_codec = False ,
1640
1659
record_class = None
1641
1660
):
1642
1661
if timeout is None :
1643
1662
stmt = await self ._get_statement (
1644
1663
query ,
1645
1664
None ,
1646
1665
record_class = record_class ,
1666
+ ignore_custom_codec = ignore_custom_codec ,
1647
1667
)
1648
1668
else :
1649
1669
before = time .monotonic ()
1650
1670
stmt = await self ._get_statement (
1651
1671
query ,
1652
1672
timeout ,
1653
1673
record_class = record_class ,
1674
+ ignore_custom_codec = ignore_custom_codec ,
1654
1675
)
1655
1676
after = time .monotonic ()
1656
1677
timeout -= after - before
0 commit comments