@@ -340,7 +340,8 @@ async def _get_statement(
340
340
* ,
341
341
named : bool = False ,
342
342
use_cache : bool = True ,
343
- record_class = None
343
+ record_class = None ,
344
+ disable_custom_codec = False ,
344
345
):
345
346
if record_class is None :
346
347
record_class = self ._protocol .get_record_class ()
@@ -371,7 +372,9 @@ async def _get_statement(
371
372
record_class = record_class ,
372
373
)
373
374
need_reprepare = False
374
- types_with_missing_codecs = statement ._init_types ()
375
+ types_with_missing_codecs = statement ._init_types (
376
+ disable_custom_codec = disable_custom_codec
377
+ )
375
378
tries = 0
376
379
while types_with_missing_codecs :
377
380
settings = self ._protocol .get_settings ()
@@ -387,7 +390,9 @@ async def _get_statement(
387
390
# which has blown away the anonymous statement we've prepared
388
391
# for the query, so we need to re-prepare it.
389
392
need_reprepare = not intro_stmt .name and not statement .name
390
- types_with_missing_codecs = statement ._init_types ()
393
+ types_with_missing_codecs = statement ._init_types (
394
+ disable_custom_codec = disable_custom_codec
395
+ )
391
396
tries += 1
392
397
if tries > 5 :
393
398
# In the vast majority of cases there will be only
@@ -401,7 +406,7 @@ async def _get_statement(
401
406
402
407
# Now that types have been resolved, populate the codec pipeline
403
408
# for the statement.
404
- statement ._init_codecs ()
409
+ statement ._init_codecs (disable_custom_codec )
405
410
406
411
if need_reprepare :
407
412
await self ._protocol .prepare (
@@ -424,7 +429,12 @@ async def _get_statement(
424
429
425
430
async def _introspect_types (self , typeoids , timeout ):
426
431
return await self .__execute (
427
- self ._intro_query , (list (typeoids ),), 0 , timeout )
432
+ self ._intro_query ,
433
+ (list (typeoids ),),
434
+ 0 ,
435
+ timeout ,
436
+ disable_custom_codec = True ,
437
+ )
428
438
429
439
def cursor (
430
440
self ,
@@ -571,7 +581,8 @@ async def fetchrow(
571
581
query ,
572
582
* args ,
573
583
timeout = None ,
574
- record_class = None
584
+ record_class = None ,
585
+ _disable_custom_codec = False ,
575
586
):
576
587
"""Run a query and return the first row.
577
588
@@ -601,6 +612,7 @@ async def fetchrow(
601
612
1 ,
602
613
timeout ,
603
614
record_class = record_class ,
615
+ disable_custom_codec = _disable_custom_codec ,
604
616
)
605
617
if not data :
606
618
return None
@@ -1110,7 +1122,8 @@ async def set_type_codec(self, typename, *,
1110
1122
self ._check_open ()
1111
1123
1112
1124
typeinfo = await self .fetchrow (
1113
- introspection .TYPE_BY_NAME , typename , schema )
1125
+ introspection .TYPE_BY_NAME , typename , schema ,
1126
+ _disable_custom_codec = True )
1114
1127
if not typeinfo :
1115
1128
raise ValueError ('unknown type: {}.{}' .format (schema , typename ))
1116
1129
@@ -1141,7 +1154,8 @@ async def reset_type_codec(self, typename, *, schema='public'):
1141
1154
"""
1142
1155
1143
1156
typeinfo = await self .fetchrow (
1144
- introspection .TYPE_BY_NAME , typename , schema )
1157
+ introspection .TYPE_BY_NAME , typename , schema ,
1158
+ _disable_custom_codec = True )
1145
1159
if not typeinfo :
1146
1160
raise ValueError ('unknown type: {}.{}' .format (schema , typename ))
1147
1161
@@ -1191,7 +1205,8 @@ async def set_builtin_type_codec(self, typename, *,
1191
1205
self ._check_open ()
1192
1206
1193
1207
typeinfo = await self .fetchrow (
1194
- introspection .TYPE_BY_NAME , typename , schema )
1208
+ introspection .TYPE_BY_NAME , typename , schema ,
1209
+ _disable_custom_codec = True )
1195
1210
if not typeinfo :
1196
1211
raise exceptions .InterfaceError (
1197
1212
'unknown type: {}.{}' .format (schema , typename ))
@@ -1578,7 +1593,8 @@ async def _execute(
1578
1593
timeout ,
1579
1594
* ,
1580
1595
return_status = False ,
1581
- record_class = None
1596
+ record_class = None ,
1597
+ disable_custom_codec = False ,
1582
1598
):
1583
1599
with self ._stmt_exclusive_section :
1584
1600
result , _ = await self .__execute (
@@ -1588,6 +1604,7 @@ async def _execute(
1588
1604
timeout ,
1589
1605
return_status = return_status ,
1590
1606
record_class = record_class ,
1607
+ disable_custom_codec = disable_custom_codec ,
1591
1608
)
1592
1609
return result
1593
1610
@@ -1599,7 +1616,8 @@ async def __execute(
1599
1616
timeout ,
1600
1617
* ,
1601
1618
return_status = False ,
1602
- record_class = None
1619
+ record_class = None ,
1620
+ disable_custom_codec = False ,
1603
1621
):
1604
1622
executor = lambda stmt , timeout : self ._protocol .bind_execute (
1605
1623
stmt , args , '' , limit , return_status , timeout )
@@ -1609,6 +1627,7 @@ async def __execute(
1609
1627
executor ,
1610
1628
timeout ,
1611
1629
record_class = record_class ,
1630
+ disable_custom_codec = disable_custom_codec ,
1612
1631
)
1613
1632
1614
1633
async def _executemany (self , query , args , timeout ):
@@ -1626,20 +1645,23 @@ async def _do_execute(
1626
1645
timeout ,
1627
1646
retry = True ,
1628
1647
* ,
1629
- record_class = None
1648
+ record_class = None ,
1649
+ disable_custom_codec = False ,
1630
1650
):
1631
1651
if timeout is None :
1632
1652
stmt = await self ._get_statement (
1633
1653
query ,
1634
1654
None ,
1635
1655
record_class = record_class ,
1656
+ disable_custom_codec = disable_custom_codec ,
1636
1657
)
1637
1658
else :
1638
1659
before = time .monotonic ()
1639
1660
stmt = await self ._get_statement (
1640
1661
query ,
1641
1662
timeout ,
1642
1663
record_class = record_class ,
1664
+ disable_custom_codec = disable_custom_codec ,
1643
1665
)
1644
1666
after = time .monotonic ()
1645
1667
timeout -= after - before
0 commit comments