libduckdb-sys 1.20000.0

Native bindings to the libduckdb library, C API
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
/* automatically generated by rust-bindgen 0.72.1 */

pub const DUCKDB_V2_API_VERSION_MAJOR: u32 = 2;
pub const DUCKDB_V2_API_VERSION_MINOR: u32 = 0;
pub const DUCKDB_V2_API_VERSION_PATCH: u32 = 0;
pub const DUCKDB_V2_API_ALLOW_DEPRECATED: u32 = 1;
pub const DUCKDB_V2_BYTES_INLINE_LENGTH: u32 = 12;
pub type idx_t = u64;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_extension_info {
    _unused: [u8; 0],
}
pub type duckdb_v2_extension_handle = *mut _duckdb_extension_info;
#[repr(u32)]
#[non_exhaustive]
#[doc = " The order guarantee a producer of rows makes about its output, which decides whether the rows it produces must be\n kept in order downstream."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_ORDER_PRESERVATION {
    #[doc = " The rows have no meaningful order. The engine may reorder them freely, and consumers that otherwise keep\n insertion order, such as query results, INSERT and COPY, run in parallel without ordering them."]
    DUCKDB_V2_ORDER_PRESERVATION_NO_ORDER = 0,
    #[doc = " The rows are produced in insertion order, which the engine keeps unless the `preserve_insertion_order` setting is\n disabled."]
    DUCKDB_V2_ORDER_PRESERVATION_INSERTION_ORDER = 1,
    #[doc = " The rows are produced in an order that must be kept, as if sorted by an `ORDER BY`, even when the\n `preserve_insertion_order` setting is disabled."]
    DUCKDB_V2_ORDER_PRESERVATION_FIXED_ORDER = 2,
    #[doc = " The rows are produced in an order that must be kept, as if sorted by an `ORDER BY`, even when the\n `preserve_insertion_order` setting is disabled."]
    DUCKDB_V2_ORDER_PRESERVATION_MAX_ENUM = 2147483647,
}
#[doc = " An opaque, owned handle to the V2 environment: the required root through which instance handles are created. All\n instances under one environment share an instance cache, so file-level conflicts — the same database file opened\n twice — are detected across them. Destroying the environment refuses with ERROR_RESOURCE_IN_USE while any instance\n created through it is still alive; destroy those first."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_environment {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An opaque, owned handle to the V2 environment: the required root through which instance handles are created. All\n instances under one environment share an instance cache, so file-level conflicts — the same database file opened\n twice — are detected across them. Destroying the environment refuses with ERROR_RESOURCE_IN_USE while any instance\n created through it is still alive; destroy those first."]
pub type duckdb_v2_environment_handle = *mut _duckdb_v2_environment;
#[doc = " An opaque, owned handle to a DuckDB database instance: a buffer pool, a scheduler, a set of GLOBAL settings, and the\n databases attached to it. Created empty by `duckdb_v2_instance_create()`; databases are attached with\n `duckdb_v2_instance_attach()`, made the default with `duckdb_v2_instance_set_default()`, and detached with\n `duckdb_v2_instance_detach()`. Always destroy via `duckdb_v2_instance_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_instance {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An opaque, owned handle to a DuckDB database instance: a buffer pool, a scheduler, a set of GLOBAL settings, and the\n databases attached to it. Created empty by `duckdb_v2_instance_create()`; databases are attached with\n `duckdb_v2_instance_attach()`, made the default with `duckdb_v2_instance_set_default()`, and detached with\n `duckdb_v2_instance_detach()`. Always destroy via `duckdb_v2_instance_destroy()`."]
pub type duckdb_v2_instance_handle = *mut _duckdb_v2_instance;
#[doc = " An opaque, owned handle to a DuckDB connection: a session on a database instance with its own LOCAL settings and\n transaction state. Always destroy via `duckdb_v2_connection_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_connection {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An opaque, owned handle to a DuckDB connection: a session on a database instance with its own LOCAL settings and\n transaction state. Always destroy via `duckdb_v2_connection_destroy()`."]
pub type duckdb_v2_connection_handle = *mut _duckdb_v2_connection;
#[doc = " A borrowed handle to the scope config options are read from and written at. Taken from an instance\n (`duckdb_v2_instance_get_config()`), a connection (`duckdb_v2_connection_get_config()`) or a context\n (`duckdb_v2_context_get_config()`), and valid for as long as its source is; the caller never destroys it. An\n instance's config is the GLOBAL scope alone; a connection's or a context's config reads that client's cascade (its\n SESSION value, else the GLOBAL one, else the default) and writes at any scope the option supports."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_config {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed handle to the scope config options are read from and written at. Taken from an instance\n (`duckdb_v2_instance_get_config()`), a connection (`duckdb_v2_connection_get_config()`) or a context\n (`duckdb_v2_context_get_config()`), and valid for as long as its source is; the caller never destroys it. An\n instance's config is the GLOBAL scope alone; a connection's or a context's config reads that client's cascade (its\n SESSION value, else the GLOBAL one, else the default) and writes at any scope the option supports."]
pub type duckdb_v2_config_handle = *mut _duckdb_v2_config;
#[doc = " An opaque, owned, read-only descriptor of a single config option as registered on an instance: its canonical name,\n default value, description, the scopes it may be written at, and aliases. It carries no current value: read that with\n the *_get_option_value functions, and write it with the *_set_option functions. Returned by the *_get_option_by_name\n and *_get_option_by_index functions; the caller always destroys it via `duckdb_v2_option_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_option {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An opaque, owned, read-only descriptor of a single config option as registered on an instance: its canonical name,\n default value, description, the scopes it may be written at, and aliases. It carries no current value: read that with\n the *_get_option_value functions, and write it with the *_set_option functions. Returned by the *_get_option_by_name\n and *_get_option_by_index functions; the caller always destroys it via `duckdb_v2_option_destroy()`."]
pub type duckdb_v2_option_handle = *mut _duckdb_v2_option;
#[doc = "! Opaque detail for a failed call; destroy with `duckdb_v2_error_info_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_error_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = "! Opaque detail for a failed call; destroy with `duckdb_v2_error_info_destroy()`."]
pub type duckdb_v2_error_info_handle = *mut _duckdb_v2_error_info;
#[doc = " An opaque, owned handle to a logical type. Carries a type id plus any kind-specific metadata: decimal width and\n scale, enum dictionary, list / array / struct / map / union child types, alias. A type is read-only once constructed;\n instances arrive from a query result schema, or from one of the create_type_* constructors. Always destroy via\n `duckdb_v2_logical_type_destroy()`. Borrowed strings returned by the getters are valid only until then."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_logical_type {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An opaque, owned handle to a logical type. Carries a type id plus any kind-specific metadata: decimal width and\n scale, enum dictionary, list / array / struct / map / union child types, alias. A type is read-only once constructed;\n instances arrive from a query result schema, or from one of the create_type_* constructors. Always destroy via\n `duckdb_v2_logical_type_destroy()`. Borrowed strings returned by the getters are valid only until then."]
pub type duckdb_v2_logical_type_handle = *mut _duckdb_v2_logical_type;
#[doc = " An opaque, owned handle to a single SQL value: a logical type plus a typed payload. Always destroy via\n `duckdb_v2_value_destroy()`. The string returned by `duckdb_v2_value_get_varchar()` / `duckdb_v2_value_get_blob()` is\n borrowed and valid only until then. That holds for BIGNUM too, where what is borrowed is the opaque storage form;\n `duckdb_v2_bignum_decode()` translates it into a magnitude and a sign flag, writing into a buffer the caller\n supplies."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_value {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An opaque, owned handle to a single SQL value: a logical type plus a typed payload. Always destroy via\n `duckdb_v2_value_destroy()`. The string returned by `duckdb_v2_value_get_varchar()` / `duckdb_v2_value_get_blob()` is\n borrowed and valid only until then. That holds for BIGNUM too, where what is borrowed is the opaque storage form;\n `duckdb_v2_bignum_decode()` translates it into a magnitude and a sign flag, writing into a buffer the caller\n supplies."]
pub type duckdb_v2_value_handle = *mut _duckdb_v2_value;
#[doc = " An opaque, owned handle to the streaming result of a query. Carries the schema (column names and logical types), the\n statement type, and the result type from prepare time; row data is produced incrementally by stepping\n (`duckdb_v2_result_step()`) or draining (`duckdb_v2_result_fetch_chunk()`). Single consumer: step from one thread at\n a time.\n\n A result is a cursor on the connection's execution, not a box of data. While its statement runs — at most until it is\n finished, cancelled, errored, or destroyed — the connection refuses new queries with ERROR_RESOURCE_IN_USE, and the\n query's transaction stays open, deferring version cleanup and checkpointing, so drain or destroy it promptly.\n Side-effecting statements (PRAGMA, ALTER, ...) take effect only once the result is drained. Always destroy via\n `duckdb_v2_result_destroy()`, which is safe even on a partially consumed stream."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_result {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An opaque, owned handle to the streaming result of a query. Carries the schema (column names and logical types), the\n statement type, and the result type from prepare time; row data is produced incrementally by stepping\n (`duckdb_v2_result_step()`) or draining (`duckdb_v2_result_fetch_chunk()`). Single consumer: step from one thread at\n a time.\n\n A result is a cursor on the connection's execution, not a box of data. While its statement runs — at most until it is\n finished, cancelled, errored, or destroyed — the connection refuses new queries with ERROR_RESOURCE_IN_USE, and the\n query's transaction stays open, deferring version cleanup and checkpointing, so drain or destroy it promptly.\n Side-effecting statements (PRAGMA, ALTER, ...) take effect only once the result is drained. Always destroy via\n `duckdb_v2_result_destroy()`, which is safe even on a partially consumed stream."]
pub type duckdb_v2_result_handle = *mut _duckdb_v2_result;
#[doc = " An opaque, owned handle to a data chunk: a set of vectors of equal logical length plus a cardinality (row count).\n\n A data chunk is the main \"unit of execution\" in DuckDB, and the main unit of data transfer in the API. It may be\n owned or borrowed, depending on the context."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_data_chunk {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An opaque, owned handle to a data chunk: a set of vectors of equal logical length plus a cardinality (row count).\n\n A data chunk is the main \"unit of execution\" in DuckDB, and the main unit of data transfer in the API. It may be\n owned or borrowed, depending on the context."]
pub type duckdb_v2_data_chunk_handle = *mut _duckdb_v2_data_chunk;
#[doc = " A borrowed handle to a vector within a data chunk, carrying a part of a column's values. Vectors are always borrowed\n from a data chunk, and are valid only as long as their parent data chunk is alive."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_vector {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed handle to a vector within a data chunk, carrying a part of a column's values. Vectors are always borrowed\n from a data chunk, and are valid only as long as their parent data chunk is alive."]
pub type duckdb_v2_vector_handle = *mut _duckdb_v2_vector;
#[doc = " A borrowed handle to a \"arena allocator\".\n\n Bytes handed out by `duckdb_v2_arena_allocate()` share the same lifetime as the arena itself.\n `duckdb_v2_vector_get_arena()` yields the arena backing the out-of-line bytes of non-inlined VARCHAR / BLOB / BIT /\n BIGNUM values, valid until the owning vector is flattened, reallocated, or destroyed."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_arena {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed handle to a \"arena allocator\".\n\n Bytes handed out by `duckdb_v2_arena_allocate()` share the same lifetime as the arena itself.\n `duckdb_v2_vector_get_arena()` yields the arena backing the out-of-line bytes of non-inlined VARCHAR / BLOB / BIT /\n BIGNUM values, valid until the owning vector is flattened, reallocated, or destroyed."]
pub type duckdb_v2_arena_handle = *mut _duckdb_v2_arena;
#[doc = " A borrowed handle to a client context: a connection seen from inside DuckDB. Handed out within DuckDB-managed scopes\n — function bind / init / exec callbacks, replacement scans, and the extension entrypoint — and valid only for the\n duration of that scope; the caller never destroys it. Within that scope a transaction is already active. A context\n reaches the same capabilities a connection does, through `duckdb_v2_context_get_factory()`,\n `duckdb_v2_context_get_config()`, `duckdb_v2_context_get_file_system()` and `duckdb_v2_context_log()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_context {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed handle to a client context: a connection seen from inside DuckDB. Handed out within DuckDB-managed scopes\n — function bind / init / exec callbacks, replacement scans, and the extension entrypoint — and valid only for the\n duration of that scope; the caller never destroys it. Within that scope a transaction is already active. A context\n reaches the same capabilities a connection does, through `duckdb_v2_context_get_factory()`,\n `duckdb_v2_context_get_config()`, `duckdb_v2_context_get_file_system()` and `duckdb_v2_context_log()`."]
pub type duckdb_v2_context_handle = *mut _duckdb_v2_context;
#[doc = " A borrowed handle to the scope values, types, data chunks and column data collections are created in. Taken from an\n instance (`duckdb_v2_instance_get_factory()`), a connection (`duckdb_v2_connection_get_factory()`) or a context\n (`duckdb_v2_context_get_factory()`), and valid for as long as its source is; the caller never destroys it. A factory\n resolves in the scope of its source: a connection's or a context's factory reaches the catalog and the client's\n settings, while an instance's factory knows only the built-in types and casts, with default settings, and refuses\n anything that needs a catalog."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_factory {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed handle to the scope values, types, data chunks and column data collections are created in. Taken from an\n instance (`duckdb_v2_instance_get_factory()`), a connection (`duckdb_v2_connection_get_factory()`) or a context\n (`duckdb_v2_context_get_factory()`), and valid for as long as its source is; the caller never destroys it. A factory\n resolves in the scope of its source: a connection's or a context's factory reaches the catalog and the client's\n settings, while an instance's factory knows only the built-in types and casts, with default settings, and refuses\n anything that needs a catalog."]
pub type duckdb_v2_factory_handle = *mut _duckdb_v2_factory;
#[doc = " An entry in a selection-vector.\n\n A selection-vector is a \"dictionary\" represented as an array of indices (sel_t's) mapping \"logical\" row indices to\n the \"physical\" offsets in a vectors primary data buffer. Used by \"dictionary vectors\" to represent a filtered or\n \"sparse\" view of the vector's data."]
pub type duckdb_v2_sel_t = u32;
#[doc = "! VARCHAR storage. The bytes must contain valid UTF-8. Read the transparent bytes fields directly."]
pub type duckdb_v2_varchar_t = duckdb_v2_bytes;
#[doc = "! BLOB storage. Read the transparent bytes fields directly."]
pub type duckdb_v2_blob_t = duckdb_v2_bytes;
#[doc = "! BIT storage. Byte 0 is the padding-bit count, bytes 1.. the data."]
pub type duckdb_v2_bit_t = duckdb_v2_bytes;
#[doc = "! BIGNUM storage. Decode via `duckdb_v2_bignum_decode()`."]
pub type duckdb_v2_bignum_t = duckdb_v2_bytes;
#[doc = " A borrowed name view with the same layout as str, marking a string DuckDB treats as a SQL identifier: one matched\n case-insensitively. Compare two identifiers case-insensitively rather than byte for byte, and render one into SQL\n through the identifier-quoting entry point rather than embedding it raw. The catalog preserves casing; some\n registries (config settings) canonicalize to lowercase.\n\n An identifier passed into the API must be valid UTF-8; otherwise the call fails with `ERROR_INPUT_INVALID`."]
pub type duckdb_v2_identifier_t = duckdb_v2_str;
#[doc = " Receives text produced by DuckDB\n\n Invoked exactly once per producing call, with the complete text in a single view.\n\n The view is borrowed for the duration of the call only. Copy what you need before returning, and do not retain `text`\n or `text->ptr`. The bytes are NOT guaranteed to be null-terminated.\n\n `err` is a live error slot, never NULL. Populate it with `duckdb_v2_error_info_set_code()` /\n `duckdb_v2_error_info_set_text()` to signal failure to DuckDB. Do not destroy it yourself.\n\n The sink runs inside DuckDB's call frame: it must not throw or unwind across the boundary, and it must not re-enter\n the API on the handle being operated on."]
pub type duckdb_v2_text_sink_fn = ::std::option::Option<
    unsafe extern "C" fn(
        text: *const duckdb_v2_str,
        user_data: *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
#[doc = " Compares two caller-defined resources for equality.\n\n Invoked when DuckDB needs to compare two opaque handles. The callback is responsible for interpreting the pointers\n and comparing the underlying resources. Return true if they are equal, false otherwise.\n\n The callback runs inside DuckDB's call frame: it must not throw or unwind across the boundary, and it must not\n re-enter the API on the handle being operated on."]
pub type duckdb_v2_opaque_equals_fn =
    ::std::option::Option<unsafe extern "C" fn(a: *mut ::std::os::raw::c_void, b: *mut ::std::os::raw::c_void) -> bool>;
#[doc = " Destroys a caller-defined resource.\n\n Invoked when DuckDB needs to destroy an opaque handle. The callback is responsible for interpreting the pointer and\n freeing the underlying resource.\n\n The callback runs inside DuckDB's call frame: it must not throw or unwind across the boundary, and it must not\n re-enter the API on the handle being operated on."]
pub type duckdb_v2_opaque_destroy_fn = ::std::option::Option<unsafe extern "C" fn(data: *mut ::std::os::raw::c_void)>;
#[doc = " A borrowed, length-delimited string view: `ptr` points at `len` bytes of character data. The bytes are NOT guaranteed\n to be null-terminated and may contain interior null bytes, so always honor `len` rather than scanning for a\n terminator. The view never owns its bytes; the function that produced it documents how long they live (typically\n \"valid until the owning handle is destroyed\"). `{NULL, 0}` is the canonical empty view, and `ptr` must not be\n dereferenced when `len` is 0. Not to be confused with `bytes`, the transparent 16-byte *storage* format for a\n variable-size value in a vector.\n\n Functions take an input view as a `const str *`, which must not be NULL; a NULL pointer, or a view whose `ptr` is\n NULL while `len` is nonzero, fails with ERROR_INPUT_INVALID. Point at a `{NULL, 0}` view to pass an empty string.\n\n Text inputs, such as VARCHAR values and names, must contain valid UTF-8. The caller is responsible for ensuring this;\n API functions do not necessarily validate the input. Binary inputs, such as BLOB values, do not require valid UTF-8."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct duckdb_v2_str {
    pub ptr: *const ::std::os::raw::c_char,
    pub len: idx_t,
}
#[doc = " 16-byte storage for a variable-size, byte-backed value: VARCHAR, BLOB, BIT, or BIGNUM. The bytes are inlined when the\n length is at most BYTES_INLINE_LENGTH, in value.inlined.inlined; otherwise value.pointer.ptr holds them and\n value.pointer.prefix repeats the first\n 4. The union is transparent, so read the fields directly. VARCHAR and\n BLOB carry no further encoding; BIT and BIGNUM do. For BIT, byte 0 is the padding-bit count and bytes 1.. are the\n data; BIGNUM is decoded via `duckdb_v2_bignum_decode()`."]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct duckdb_v2_bytes {
    pub value: duckdb_v2_bytes__bindgen_ty_1,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union duckdb_v2_bytes__bindgen_ty_1 {
    pub pointer: duckdb_v2_bytes__bindgen_ty_1__bindgen_ty_1,
    pub inlined: duckdb_v2_bytes__bindgen_ty_1__bindgen_ty_2,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct duckdb_v2_bytes__bindgen_ty_1__bindgen_ty_1 {
    pub length: u32,
    pub prefix: [::std::os::raw::c_char; 4usize],
    pub ptr: *mut ::std::os::raw::c_char,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct duckdb_v2_bytes__bindgen_ty_1__bindgen_ty_2 {
    pub length: u32,
    pub inlined: [::std::os::raw::c_char; 12usize],
}
#[doc = " An opaque, owned handle to a caller-defined resource. Bundles the pointer with optional callbacks that destroy and\n compare the resource."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct duckdb_v2_opaque {
    pub ptr: *mut ::std::os::raw::c_void,
    pub destroy: duckdb_v2_opaque_destroy_fn,
    pub equals: duckdb_v2_opaque_equals_fn,
}
#[repr(u32)]
#[non_exhaustive]
#[doc = "! Error codes for API calls."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_ERROR {
    #[doc = "! Success."]
    DUCKDB_V2_ERROR_NONE = 0,
    #[doc = "! Generic API error."]
    DUCKDB_V2_ERROR_API = 1,
    #[doc = "! The specified file could not be found."]
    DUCKDB_V2_ERROR_IO_FILE_NOT_FOUND = 1001,
    #[doc = "! Failed to read from the storage device."]
    DUCKDB_V2_ERROR_IO_READ_FAILURE = 1002,
    #[doc = "! Unexpected end of file reached."]
    DUCKDB_V2_ERROR_IO_EOF = 1003,
    #[doc = "! A generic I/O error occurred while reading or writing data."]
    DUCKDB_V2_ERROR_IO_GENERAL = 1004,
    #[doc = "! A network-level failure occurred during an I/O operation."]
    DUCKDB_V2_ERROR_IO_NETWORK = 1005,
    #[doc = "! An HTTP request issued by the database failed."]
    DUCKDB_V2_ERROR_IO_HTTP = 1006,
    #[doc = "! General invalid input error."]
    DUCKDB_V2_ERROR_INPUT_INVALID = 2001,
    #[doc = "! A specific function parameter is malformed."]
    DUCKDB_V2_ERROR_INPUT_PARAMETER_INVALID = 2002,
    #[doc = "! A provided value is outside the acceptable range."]
    DUCKDB_V2_ERROR_INPUT_OUT_OF_RANGE = 2003,
    #[doc = "! An object exceeded its maximum permitted size."]
    DUCKDB_V2_ERROR_INPUT_OBJECT_SIZE = 2004,
    #[doc = " The metadata asked for is known only once execution binds the statement that produces it, because the statement\n expands into several. Step the result and ask again."]
    DUCKDB_V2_ERROR_INPUT_METADATA_DEFERRED = 2005,
    #[doc = "! The requested resource is already in use."]
    DUCKDB_V2_ERROR_RESOURCE_IN_USE = 3001,
    #[doc = "! An allocation failed because the system ran out of memory."]
    DUCKDB_V2_ERROR_RESOURCE_OUT_OF_MEMORY = 3002,
    #[doc = "! A connection-level failure occurred (e.g. the connection has been closed or invalidated)."]
    DUCKDB_V2_ERROR_RESOURCE_CONNECTION = 3003,
    #[doc = "! An operation failed because of an unresolved dependency between catalog objects."]
    DUCKDB_V2_ERROR_RESOURCE_DEPENDENCY = 3004,
    #[doc = "! An extension required by the operation is not loaded."]
    DUCKDB_V2_ERROR_RESOURCE_MISSING_EXTENSION = 3005,
    #[doc = "! Autoloading an extension failed."]
    DUCKDB_V2_ERROR_RESOURCE_AUTOLOAD = 3006,
    #[doc = "! A value could not be converted to the requested type."]
    DUCKDB_V2_ERROR_TYPE_CONVERSION = 4001,
    #[doc = "! An unknown or unsupported type was encountered."]
    DUCKDB_V2_ERROR_TYPE_UNKNOWN = 4002,
    #[doc = "! A type was used in a context where it is not valid."]
    DUCKDB_V2_ERROR_TYPE_INVALID = 4003,
    #[doc = "! Two values or expressions have incompatible types."]
    DUCKDB_V2_ERROR_TYPE_MISMATCH = 4004,
    #[doc = "! A decimal value is out of range or otherwise invalid."]
    DUCKDB_V2_ERROR_TYPE_DECIMAL = 4005,
    #[doc = "! Division by zero was attempted."]
    DUCKDB_V2_ERROR_TYPE_DIVIDE_BY_ZERO = 4006,
    #[doc = "! The query could not be parsed."]
    DUCKDB_V2_ERROR_QUERY_PARSER = 5001,
    #[doc = "! The query contains a syntax error."]
    DUCKDB_V2_ERROR_QUERY_SYNTAX = 5002,
    #[doc = "! Binding the query against the catalog failed (e.g. unknown column or table)."]
    DUCKDB_V2_ERROR_QUERY_BINDER = 5003,
    #[doc = "! The query could not be translated into a logical plan."]
    DUCKDB_V2_ERROR_QUERY_PLANNER = 5004,
    #[doc = "! An error occurred during query optimization."]
    DUCKDB_V2_ERROR_QUERY_OPTIMIZER = 5005,
    #[doc = "! An expression in the query is invalid or could not be evaluated."]
    DUCKDB_V2_ERROR_QUERY_EXPRESSION = 5006,
    #[doc = "! An error occurred while executing the physical plan."]
    DUCKDB_V2_ERROR_QUERY_EXECUTOR = 5007,
    #[doc = "! The task scheduler reported an error while running the query."]
    DUCKDB_V2_ERROR_QUERY_SCHEDULER = 5008,
    #[doc = "! The requested feature or operation is not implemented."]
    DUCKDB_V2_ERROR_QUERY_NOT_IMPLEMENTED = 5009,
    #[doc = "! A prepared-statement parameter has not been bound to a value."]
    DUCKDB_V2_ERROR_QUERY_PARAMETER_NOT_RESOLVED = 5010,
    #[doc = "! A prepared-statement parameter was used in a position where it is not allowed."]
    DUCKDB_V2_ERROR_QUERY_PARAMETER_NOT_ALLOWED = 5011,
    #[doc = "! A catalog operation failed (e.g. object not found or already exists)."]
    DUCKDB_V2_ERROR_DATABASE_CATALOG = 6001,
    #[doc = "! A transaction-level error occurred (e.g. conflict or aborted transaction)."]
    DUCKDB_V2_ERROR_DATABASE_TRANSACTION = 6002,
    #[doc = "! A constraint (primary key, unique, foreign key, NOT NULL, check) was violated."]
    DUCKDB_V2_ERROR_DATABASE_CONSTRAINT = 6003,
    #[doc = "! An index operation failed."]
    DUCKDB_V2_ERROR_DATABASE_INDEX = 6004,
    #[doc = "! A sequence operation failed (e.g. overflow or invalid usage)."]
    DUCKDB_V2_ERROR_DATABASE_SEQUENCE = 6005,
    #[doc = "! An error related to catalog statistics occurred."]
    DUCKDB_V2_ERROR_DATABASE_STATISTICS = 6006,
    #[doc = "! Serializing or deserializing a database object failed."]
    DUCKDB_V2_ERROR_DATABASE_SERIALIZATION = 6007,
    #[doc = "! A settings-related error occurred (e.g. setting an unknown option)."]
    DUCKDB_V2_ERROR_CONFIGURATION_SETTINGS = 7001,
    #[doc = "! The database configuration is invalid."]
    DUCKDB_V2_ERROR_CONFIGURATION_INVALID = 7002,
    #[doc = "! The operation is not permitted under the current configuration."]
    DUCKDB_V2_ERROR_CONFIGURATION_PERMISSION = 7003,
    #[doc = "! An internal invariant was violated; this indicates a bug in DuckDB."]
    DUCKDB_V2_ERROR_RUNTIME_INTERNAL = 8001,
    #[doc = "! A fatal error occurred; the database is no longer usable."]
    DUCKDB_V2_ERROR_RUNTIME_FATAL = 8002,
    #[doc = "! The operation was interrupted (e.g. by a cancel request)."]
    DUCKDB_V2_ERROR_RUNTIME_INTERRUPT = 8003,
    #[doc = "! A required pointer was unexpectedly null."]
    DUCKDB_V2_ERROR_RUNTIME_NULL_POINTER = 8004,
    #[doc = "! A required pointer was unexpectedly null."]
    DUCKDB_V2_ERROR_MAX_ENUM = 2147483647,
}
#[repr(u32)]
#[non_exhaustive]
#[doc = " Identifies a configurable function property. Pass one of these to `duckdb_v2_scalar_function_set_property()` or\n `duckdb_v2_aggregate_function_set_property()` together with a matching `DUCKDB_V2_FUNCTION_PROPERTY_VALUE`. The high\n byte is the function-type group: COMMON (`0x01xxxx`) keys apply to all function types, while group-specific keys\n (e.g. aggregate `0x03xxxx`) are only valid for that function type and are rejected with an error otherwise."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_FUNCTION_PROPERTY_KEY {
    #[doc = " How stable/deterministic the function's result is across rows and queries. Accepts the\n `FUNCTION_PROPERTY_STABILITY_*` values. Defaults to `CONSISTENT`."]
    DUCKDB_V2_FUNCTION_PROPERTY_STABILITY = 65536,
    #[doc = " Whether the function handles NULL inputs itself. Accepts the `FUNCTION_PROPERTY_NULL_HANDLING_*` values. Defaults\n to `DEFAULT` (NULL in, NULL out)."]
    DUCKDB_V2_FUNCTION_PROPERTY_NULL_HANDLING = 65792,
    #[doc = " Whether the function can raise a runtime error. Accepts the `FUNCTION_PROPERTY_FALLIBILITY_*` values. Functions\n created through this API default to `FALLIBLE`, since their callbacks can report errors."]
    DUCKDB_V2_FUNCTION_PROPERTY_FALLIBILITY = 66048,
    #[doc = " How the function interacts with collations on its arguments. Accepts the `FUNCTION_PROPERTY_COLLATION_HANDLING_*`\n values. Defaults to `PROPAGATE`."]
    DUCKDB_V2_FUNCTION_PROPERTY_COLLATION_HANDLING = 66304,
    #[doc = " Aggregate only. Whether the aggregate's result depends on the order in which rows are aggregated. Accepts the\n `FUNCTION_PROPERTY_AGG_ORDER_DEPENDENT_*` values. Defaults to `YES`."]
    DUCKDB_V2_FUNCTION_PROPERTY_AGG_ORDER_DEPENDENT = 196608,
    #[doc = " Aggregate only. Whether the aggregate's result is affected by a DISTINCT modifier. Accepts the\n `FUNCTION_PROPERTY_AGG_DISTINCT_DEPENDENT_*` values. Defaults to `YES`."]
    DUCKDB_V2_FUNCTION_PROPERTY_AGG_DISTINCT_DEPENDENT = 196864,
    #[doc = " Aggregate only. Whether the aggregate's result is affected by a DISTINCT modifier. Accepts the\n `FUNCTION_PROPERTY_AGG_DISTINCT_DEPENDENT_*` values. Defaults to `YES`."]
    DUCKDB_V2_FUNCTION_PROPERTY_KEY_MAX_ENUM = 2147483647,
}
#[repr(u32)]
#[non_exhaustive]
#[doc = " A value for a `DUCKDB_V2_FUNCTION_PROPERTY_KEY`. Each key owns a 256-value block: a value `V` is valid for key `K`\n iff `(V & 0xFFFF00) == K`, and shares the key's function-type group (`V & 0xFF0000`) in its high byte. Passing a\n value that does not match the key is rejected with an error. Boolean-like properties are expressed as named values so\n that additional values can be added later without breaking the ABI."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_FUNCTION_PROPERTY_VALUE {
    #[doc = "! The function always returns the same result given the same input."]
    DUCKDB_V2_FUNCTION_PROPERTY_STABILITY_CONSISTENT = 65536,
    #[doc = "! The result may differ per row (e.g. random())."]
    DUCKDB_V2_FUNCTION_PROPERTY_STABILITY_VOLATILE = 65537,
    #[doc = "! The result is stable within a single query/transaction but may change across queries (e.g. now())."]
    DUCKDB_V2_FUNCTION_PROPERTY_STABILITY_CONSISTENT_WITHIN_QUERY = 65538,
    #[doc = "! Default NULL handling: if any argument is NULL the result is NULL and the function is not invoked for that row."]
    DUCKDB_V2_FUNCTION_PROPERTY_NULL_HANDLING_DEFAULT = 65792,
    #[doc = "! The function handles NULL inputs itself and is invoked even when arguments are NULL."]
    DUCKDB_V2_FUNCTION_PROPERTY_NULL_HANDLING_SPECIAL = 65793,
    #[doc = " The function never raises a runtime error. Declaring this promises that the callbacks never report an error; an\n error reported anyway becomes an internal error."]
    DUCKDB_V2_FUNCTION_PROPERTY_FALLIBILITY_INFALLIBLE = 66048,
    #[doc = "! The function may raise a runtime error for some inputs."]
    DUCKDB_V2_FUNCTION_PROPERTY_FALLIBILITY_FALLIBLE = 66049,
    #[doc = "! The function combines collations from its inputs and propagates them to its result (default)."]
    DUCKDB_V2_FUNCTION_PROPERTY_COLLATION_HANDLING_PROPAGATE = 66304,
    #[doc = "! Combinable collations are executed on the input arguments before the function runs."]
    DUCKDB_V2_FUNCTION_PROPERTY_COLLATION_HANDLING_PUSH_COMBINABLE = 66305,
    #[doc = "! Collations are ignored by the function."]
    DUCKDB_V2_FUNCTION_PROPERTY_COLLATION_HANDLING_IGNORE = 66306,
    #[doc = "! The aggregate's result depends on the order in which rows are aggregated (default)."]
    DUCKDB_V2_FUNCTION_PROPERTY_AGG_ORDER_DEPENDENT_YES = 196608,
    #[doc = "! The aggregate's result does not depend on input order."]
    DUCKDB_V2_FUNCTION_PROPERTY_AGG_ORDER_DEPENDENT_NO = 196609,
    #[doc = "! The aggregate's result is affected by a DISTINCT modifier (default)."]
    DUCKDB_V2_FUNCTION_PROPERTY_AGG_DISTINCT_DEPENDENT_YES = 196864,
    #[doc = "! The aggregate's result is not affected by a DISTINCT modifier."]
    DUCKDB_V2_FUNCTION_PROPERTY_AGG_DISTINCT_DEPENDENT_NO = 196865,
    #[doc = "! The aggregate's result is not affected by a DISTINCT modifier."]
    DUCKDB_V2_FUNCTION_PROPERTY_VALUE_MAX_ENUM = 2147483647,
}
unsafe extern "C" {
    #[doc = " Allocate `byte_len` bytes from the arena.\n\n Returns a writable pointer to `byte_len` uninitialized bytes, valid for as long as the arena is. There is no minimum\n or maximum allocation size, and the arena may return a pointer to a block of memory that is larger than `byte_len`.\n The arena will free all allocated memory when it is destroyed, so the caller should not attempt to free the returned\n pointer themselves.\n\n history:\n - unstable: v2.0.0\n\n @param arena The arena to allocate from.\n @param byte_len Number of bytes to reserve. May be 0.\n @param out_ptr Receives a writable pointer to byte_len arena-owned bytes.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arena_allocate(
        arena: duckdb_v2_arena_handle,
        byte_len: idx_t,
        out_ptr: *mut *mut u8,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
#[repr(u32)]
#[non_exhaustive]
#[doc = " The mode a cast is being executed in. A normal cast must either succeed for every row or report an error, which\n aborts the query. A \"try\" cast (SQL TRY_CAST, and implicit casts the engine probes speculatively) tolerates per-row\n failures: the callback writes NULL for the rows it could not convert instead of aborting. Read with\n `duckdb_v2_cast_function_exec_get_mode()`, and passed to `duckdb_v2_vector_cast()`."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_CAST_MODE {
    #[doc = "! A regular cast. A conversion failure reported through the error slot aborts the query."]
    DUCKDB_V2_CAST_MODE_NORMAL = 0,
    #[doc = " A \"try\" cast. Conversion failures should be written as NULLs into the output vector; an error reported through\n the slot is swallowed and the affected rows are left NULL."]
    DUCKDB_V2_CAST_MODE_TRY = 1,
    #[doc = " A \"try\" cast. Conversion failures should be written as NULLs into the output vector; an error reported through\n the slot is swallowed and the affected rows are left NULL."]
    DUCKDB_V2_CAST_MODE_MAX_ENUM = 2147483647,
}
#[doc = " An owned opaque handle to a cast function being built. Created with `duckdb_v2_cast_function_create()`, configured\n with the setter functions (e.g. `duckdb_v2_cast_function_set_source_type()`,\n `duckdb_v2_cast_function_set_exec_callback()`, etc.), made available with\n `duckdb_v2_connection_register_cast_function()` or `duckdb_v2_extension_register_cast_function()`, and destroyed with\n `duckdb_v2_cast_function_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_cast_function {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned opaque handle to a cast function being built. Created with `duckdb_v2_cast_function_create()`, configured\n with the setter functions (e.g. `duckdb_v2_cast_function_set_source_type()`,\n `duckdb_v2_cast_function_set_exec_callback()`, etc.), made available with\n `duckdb_v2_connection_register_cast_function()` or `duckdb_v2_extension_register_cast_function()`, and destroyed with\n `duckdb_v2_cast_function_destroy()`."]
pub type duckdb_v2_cast_function_handle = *mut _duckdb_v2_cast_function;
#[doc = " A borrowed opaque handle to the arguments supplied to a cast function during the execution \"exec\" phase. The \"exec\"\n callback receives this handle and can use it to access the input vector, the output vector to write into, the number\n of rows to convert, and the mode the cast is running in."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_cast_function_exec_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a cast function during the execution \"exec\" phase. The \"exec\"\n callback receives this handle and can use it to access the input vector, the output vector to write into, the number\n of rows to convert, and the mode the cast is running in."]
pub type duckdb_v2_cast_function_exec_info_handle = *mut _duckdb_v2_cast_function_exec_info;
pub type duckdb_v2_cast_function_exec_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_cast_function_exec_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
unsafe extern "C" {
    #[doc = " Creates a new cast function through a factory.\n\n The function starts out empty: configure it with the setter functions (e.g.\n `duckdb_v2_cast_function_set_source_type()`, `duckdb_v2_cast_function_set_exec_callback()`, etc.), then make it\n available with `duckdb_v2_connection_register_cast_function()` or `duckdb_v2_extension_register_cast_function()`. The\n caller owns the returned handle and must destroy it with `duckdb_v2_cast_function_destroy()`, also after\n registration.\n\n The cast function can only be registered on the database the factory belongs to.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create the cast function through.\n @param function On success, receives the newly created cast function. Owned by the caller.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_cast_function_create(
        factory: duckdb_v2_factory_handle,
        function: *mut duckdb_v2_cast_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the type the cast converts from.\n\n The type is borrowed and copied. Calling this again replaces the previous source type. A source type must be set\n before registration, and it must be a fully defined concrete type.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the source type of.\n @param source_type The type to cast from. Borrowed for the call only.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_cast_function_set_source_type(
        function: duckdb_v2_cast_function_handle,
        source_type: duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the type the cast converts to.\n\n The type is borrowed and copied. Calling this again replaces the previous target type. A target type must be set\n before registration, and it must be a fully defined concrete type.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the target type of.\n @param target_type The type to cast to. Borrowed for the call only.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_cast_function_set_target_type(
        function: duckdb_v2_cast_function_handle,
        target_type: duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets what it costs to apply this cast implicitly.\n\n The binder uses the cost to choose between candidate implicit casts: a lower non-negative cost makes the cast more\n likely to be picked, a higher one less likely. Built-in widening casts sit in the [0, 20] range, so a cost above 100\n effectively puts this cast last. A negative cost -- the default -- means the cast is never applied implicitly and is\n reached only through an explicit CAST or TRY_CAST.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the implicit cast cost of.\n @param cost The cost. Negative disables implicit casting.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_cast_function_set_implicit_cast_cost(
        function: duckdb_v2_cast_function_handle,
        cost: i64,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets arbitrary user data on the cast function.\n\n Associates an opaque pointer with the function, retrievable from the exec callback via\n `duckdb_v2_cast_function_exec_get_user_data()`. The opaque handle bundles the pointer with an optional destructor,\n invoked when the data is no longer needed. The data is read-only during execution: the same pointer is shared by\n every thread running the cast.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the user data of.\n @param data Opaque handle bundling the user data pointer plus an optional destructor.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_cast_function_set_user_data(
        function: duckdb_v2_cast_function_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the exec callback of the cast function.\n\n The exec callback implements the conversion: it is invoked during query execution with a batch of input values and\n must fill the output vector. An exec callback must be set before registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the exec callback of.\n @param callback The exec callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_cast_function_set_exec_callback(
        function: duckdb_v2_cast_function_handle,
        callback: duckdb_v2_cast_function_exec_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_cast_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_cast_function_exec_get_user_data(
        info: duckdb_v2_cast_function_exec_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns how many rows this execution must convert.\n\n The number of rows held by the input vector, and the number of entries the callback must write to the output vector.\n Note that this may be less than a full vector: a constant input is converted as a single row and the result is\n expanded by the engine.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param count Receives the number of rows.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_cast_function_exec_get_row_count(
        info: duckdb_v2_cast_function_exec_info_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the input vector holding the values to convert.\n\n The vector holds the source type's values for the current batch; use `duckdb_v2_cast_function_exec_get_row_count()`\n for the number of rows. Borrowed; valid only for the duration of the callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param vector Receives the borrowed input vector.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_cast_function_exec_get_input(
        info: duckdb_v2_cast_function_exec_info_handle,
        vector: *mut duckdb_v2_vector_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the output vector the exec callback must write into.\n\n The callback must write one entry per input row; use `duckdb_v2_cast_function_exec_get_row_count()` for the number of\n rows. Borrowed; valid only for the duration of the callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param vector Receives the borrowed output vector to write into.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_cast_function_exec_get_output(
        info: duckdb_v2_cast_function_exec_info_handle,
        vector: *mut duckdb_v2_vector_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the mode the cast is being executed in.\n\n In `CAST_MODE_TRY` a conversion failure should be written as a NULL into the output vector rather than reported\n through the error slot, since the engine discards the error and keeps whatever the callback left in the output.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param mode Receives the cast mode.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_cast_function_exec_get_mode(
        info: duckdb_v2_cast_function_exec_info_handle,
        mode: *mut DUCKDB_V2_CAST_MODE,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the cast function, making it available to CAST and TRY_CAST.\n\n The cast is registered on the connection's database and takes effect immediately for every connection; it is not part\n of the connection's transaction, so a rollback does not undo it. Registration requires a source type, a target type\n and an exec callback; both types must be fully defined concrete types. Registering a cast for a pair that already has\n one replaces it. The cast function must have been created through a factory of the same database. The caller still\n owns the handle after registration and must destroy it with `duckdb_v2_cast_function_destroy()`, which does not\n affect the registered function.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection to register on.\n @param function The cast function to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_register_cast_function(
        conn: duckdb_v2_connection_handle,
        function: duckdb_v2_cast_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the cast function, making it available to CAST and TRY_CAST.\n\n The cast is registered on the loading extension's database. Use this from the extension's load callback. Registration\n requires a source type, a target type and an exec callback; both types must be fully defined concrete types.\n Registering a cast for a pair that already has one replaces it. The cast function must have been created through a\n factory of the same database. The caller still owns the handle after registration and must destroy it with\n `duckdb_v2_cast_function_destroy()`, which does not affect the registered function.\n\n history:\n - unstable: v2.0.0\n\n @param extension The loading extension.\n @param function The cast function to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_extension_register_cast_function(
        extension: duckdb_v2_extension_handle,
        function: duckdb_v2_cast_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the cast function, releasing its resources.\n\n Null-safe: passing a null pointer or null handle is a no-op. The handle is set to null on return to prevent\n double-destruction. Destroying the handle after registration does not affect the registered function.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_cast_function_destroy(function: *mut duckdb_v2_cast_function_handle) -> DUCKDB_V2_ERROR;
}
#[doc = " A column data collection represents a set of (buffer-managed) data chunks.\n\n You can append chunks to the collection iteratively, and then scan the collection back to retrieve the chunks in\n order. DuckDB will manage the memory for the chunks, and transparently offload chunks to disk if necessary. A\n collection shall not be scanned while it is being appended to, and vice versa. A collection shall not be appended to\n concurrently, but it can be scanned concurrently by multiple threads using a shared scan state and per-thread worker\n scan states. For concurrent appends, consider creating multiple collections and \"combining\" them into one collection\n at the end."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_column_data_collection {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A column data collection represents a set of (buffer-managed) data chunks.\n\n You can append chunks to the collection iteratively, and then scan the collection back to retrieve the chunks in\n order. DuckDB will manage the memory for the chunks, and transparently offload chunks to disk if necessary. A\n collection shall not be scanned while it is being appended to, and vice versa. A collection shall not be appended to\n concurrently, but it can be scanned concurrently by multiple threads using a shared scan state and per-thread worker\n scan states. For concurrent appends, consider creating multiple collections and \"combining\" them into one collection\n at the end."]
pub type duckdb_v2_column_data_collection_handle = *mut _duckdb_v2_column_data_collection;
#[doc = " Opaque state handle for shared state across multiple threads scanning a column data collection. This is used to\n coordinate work distribution, track global progress, or store any other state that needs to be shared across threads\n during the scan of the collection."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_column_data_collection_shared_scan_state {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " Opaque state handle for shared state across multiple threads scanning a column data collection. This is used to\n coordinate work distribution, track global progress, or store any other state that needs to be shared across threads\n during the scan of the collection."]
pub type duckdb_v2_column_data_collection_shared_scan_state_handle =
    *mut _duckdb_v2_column_data_collection_shared_scan_state;
#[doc = " Opaque state handle for local state while scanning a column data collection. This is used to track progress and any\n other state that needs to be maintained on a per-thread basis across calls while scanning the collection. It also\n keeps the buffers backing the most recently scanned chunk alive: chunks are scanned zero-copy, so a scanned chunk's\n data is only valid until the worker state's next scan call or its destruction."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_column_data_collection_worker_scan_state {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " Opaque state handle for local state while scanning a column data collection. This is used to track progress and any\n other state that needs to be maintained on a per-thread basis across calls while scanning the collection. It also\n keeps the buffers backing the most recently scanned chunk alive: chunks are scanned zero-copy, so a scanned chunk's\n data is only valid until the worker state's next scan call or its destruction."]
pub type duckdb_v2_column_data_collection_worker_scan_state_handle =
    *mut _duckdb_v2_column_data_collection_worker_scan_state;
#[doc = " Opaque state handle for appending to a column data collection. This is used to track progress and any other state\n that needs to be maintained across calls while appending to the collection."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_column_data_collection_append_state {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " Opaque state handle for appending to a column data collection. This is used to track progress and any other state\n that needs to be maintained across calls while appending to the collection."]
pub type duckdb_v2_column_data_collection_append_state_handle = *mut _duckdb_v2_column_data_collection_append_state;
unsafe extern "C" {
    #[doc = " Creates an empty column data collection from a factory.\n\n Allocates a new, empty column data collection, drawing its buffers from the factory's database. The collection starts\n with no chunks and is ready to have chunks appended to it. A collection must have at least one column; an empty types\n array is rejected with INVALID_INPUT.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param types_array Pointer to an array of logical_type handles, one per column. This defines the schema for the\n chunks that will be stored in the collection. All chunks appended to this collection must have vectors that conform\n to these types.\n @param types_count Number of elements in the types_array.\n @param out_collection Receives the new collection handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_data_collection_create(
        factory: duckdb_v2_factory_handle,
        types_array: *const duckdb_v2_logical_type_handle,
        types_count: idx_t,
        out_collection: *mut duckdb_v2_column_data_collection_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Drops all buffered rows, keeping the column types.\n\n Drops all buffered rows and releases their memory. The column types are unchanged and the collection is immediately\n appendable again. Existing append and scan states are invalidated. Use `duckdb_v2_column_data_collection_clear()`\n instead to keep the memory for the next appends.\n\n history:\n - unstable: v2.0.0\n\n @param collection The collection to reset.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_data_collection_reset(
        collection: duckdb_v2_column_data_collection_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Drops all buffered rows, keeping the column types and the memory.\n\n Like `duckdb_v2_column_data_collection_reset()`, but the buffers are retained rather than released, so the next\n appends write into memory that is already allocated. Use this when the collection is refilled repeatedly. The column\n types are unchanged and the collection is immediately appendable again. Existing append and scan states are\n invalidated.\n\n history:\n - unstable: v2.0.0\n\n @param collection The collection to clear.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_data_collection_clear(
        collection: duckdb_v2_column_data_collection_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys a column data collection and all its chunks.\n\n Cleans up the collection and all resources associated with it, including all contained chunks. Sets the collection\n handle to NULL.\n\n history:\n - unstable: v2.0.0\n\n @param collection The collection to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_data_collection_destroy(
        collection: *mut duckdb_v2_column_data_collection_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Merges the source collection into the target collection, consuming the source in the process.\n\n Transfers all chunks from the source collection to the target collection. This destroys the source collection,\n setting the source handle to NULL. The two collections must have the same column types, and must have been created\n from factories of the same database: the transferred chunks keep their original buffers, so combining collections\n from different databases would tie the target to a buffer manager it does not own.\n\n history:\n - unstable: v2.0.0\n\n @param target The collection to merge into. After the call, this collection will contain all chunks from both\n collections.\n @param source The collection to merge from. This collection will be destroyed by this operation and its handle set to\n NULL.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_data_collection_combine(
        target: duckdb_v2_column_data_collection_handle,
        source: *mut duckdb_v2_column_data_collection_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the total number of rows across all chunks in the collection.\n\n Sums the row counts of all chunks in the collection. This is the total number of rows represented by the collection,\n which may be more than the number of rows in any individual chunk.\n\n history:\n - unstable: v2.0.0\n\n @param collection The collection to inspect.\n @param out_row_count Receives the total row count.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_data_collection_row_count(
        collection: duckdb_v2_column_data_collection_handle,
        out_row_count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Initializes an append state for the collection.\n\n Returns an append state handle that can be used to append chunks to the collection while maintaining any necessary\n state across calls.\n\n history:\n - unstable: v2.0.0\n\n @param collection The collection to prepare for appending.\n @param out_state Receives the new append state handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_data_collection_append_state_create(
        collection: duckdb_v2_column_data_collection_handle,
        out_state: *mut duckdb_v2_column_data_collection_append_state_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys an append state handle.\n\n Cleans up any resources associated with the append state. After this call, the state handle must not be used again.\n\n history:\n - unstable: v2.0.0\n\n @param state The append state to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_data_collection_append_state_destroy(
        state: *mut duckdb_v2_column_data_collection_append_state_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Appends a data chunk to the collection.\n\n Appends a copy of the given chunk to the end of the collection. The chunk's column count and types must equal the\n collection's exactly; a mismatch is rejected with INVALID_INPUT before anything is copied. VARCHAR values must\n already contain valid UTF-8; this function does not validate text. Complex-typed vectors may be flattened in place by\n the copy.\n\n history:\n - unstable: v2.0.0\n\n @param collection The collection to append to.\n @param state The append state to use this append operation.\n @param chunk The chunk to append.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_data_collection_append(
        collection: duckdb_v2_column_data_collection_handle,
        state: duckdb_v2_column_data_collection_append_state_handle,
        chunk: duckdb_v2_data_chunk_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Initializes a shared scan state for the collection.\n\n Returns a shared scan state handle that can be used by multiple threads to coordinate scanning of the collection.\n Caller owns the returned state and must destroy it via column_data_collection_shared_scan_state_destroy when done.\n\n history:\n - unstable: v2.0.0\n\n @param collection The collection to prepare for shared scanning.\n @param out_state Receives the new shared scan state handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_data_collection_shared_scan_state_create(
        collection: duckdb_v2_column_data_collection_handle,
        out_state: *mut duckdb_v2_column_data_collection_shared_scan_state_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys a shared scan state handle.\n\n Cleans up any resources associated with the shared scan state. After this call, the state handle must not be used\n again.\n\n history:\n - unstable: v2.0.0\n\n @param state The shared scan state to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_data_collection_shared_scan_state_destroy(
        state: *mut duckdb_v2_column_data_collection_shared_scan_state_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Initializes a worker scan state for the collection.\n\n Returns a \"local\" scan state handle for a worker thread to use while scanning the collection. This allows each thread\n to maintain its own progress and any other necessary information across multiple scan calls, while still coordinating\n with other threads via the shared scan state.\n\n history:\n - unstable: v2.0.0\n\n @param collection The collection to prepare for worker scanning.\n @param out_state Receives the new worker scan state handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_data_collection_worker_scan_state_create(
        collection: duckdb_v2_column_data_collection_handle,
        out_state: *mut duckdb_v2_column_data_collection_worker_scan_state_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys a worker scan state handle.\n\n Cleans up any resources associated with the worker scan state. After this call, the state handle must not be used\n again.\n\n history:\n - unstable: v2.0.0\n\n @param state The worker scan state to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_data_collection_worker_scan_state_destroy(
        state: *mut duckdb_v2_column_data_collection_worker_scan_state_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Scans the collection to retrieve the next data chunk, using shared state for coordination across threads and\n worker-local state for individual progress tracking.\n\n Retrieves the next chunk of data from the collection based on the provided shared scan state and worker-local scan\n state. The output chunk's column count and types must equal the collection's exactly; a mismatch is rejected with\n INVALID_INPUT.\n\n The scan is zero-copy where possible: the output chunk's vectors may reference the collection's buffers, kept alive\n by the worker scan state. The chunk's data is therefore only valid until the next scan call with the same worker\n state, or until the worker state or the collection is destroyed, whichever comes first. Copy the data out (or append\n it to another collection) before continuing the scan if it must outlive that window.\n\n history:\n - unstable: v2.0.0\n\n @param collection The collection to scan.\n @param shared_state The shared scan state to use for coordinating across threads.\n @param worker_state The worker-local scan state to use for this thread's scan operation.\n @param out_chunk The output chunk to write to.\n @param did_produce_chunk Receives true when a chunk was produced by this call, or false when the scan has completed\n (the chunk is then reset to empty).\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_data_collection_scan(
        collection: duckdb_v2_column_data_collection_handle,
        shared_state: duckdb_v2_column_data_collection_shared_scan_state_handle,
        worker_state: duckdb_v2_column_data_collection_worker_scan_state_handle,
        out_chunk: duckdb_v2_data_chunk_handle,
        did_produce_chunk: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
#[repr(u32)]
#[non_exhaustive]
#[doc = " The scope of an option's value. Writes take DEFAULT, GLOBAL or SESSION: DEFAULT writes to the option's default scope\n (`duckdb_v2_option_get_default_scope()`), like SQL `SET name = value`; GLOBAL writes through to the instance, visible\n to all connections, like `SET GLOBAL`; SESSION writes to one connection's session only, like `SET SESSION`. Reads\n report GLOBAL or SESSION, as DuckDB attributes the value: an option no scope sets reads as GLOBAL, its default, and a\n legacy option read through a connection or context reads as SESSION."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_SETTING_SCOPE {
    #[doc = "! Write only: the option's default scope (`duckdb_v2_option_get_default_scope()`), not its default value."]
    DUCKDB_V2_SETTING_SCOPE_DEFAULT = 0,
    #[doc = "! The instance's value, visible to all connections."]
    DUCKDB_V2_SETTING_SCOPE_GLOBAL = 1,
    #[doc = "! A connection's session value."]
    DUCKDB_V2_SETTING_SCOPE_SESSION = 2,
    #[doc = "! A connection's session value."]
    DUCKDB_V2_SETTING_SCOPE_MAX_ENUM = 2147483647,
}
unsafe extern "C" {
    #[doc = " Borrows the config of an instance: the GLOBAL scope.\n\n Reads report GLOBAL, and writes are `SET GLOBAL`. Writing at SESSION scope returns ERROR_INPUT_INVALID: an instance\n has no session. Options that can only be chosen at startup are passed to `duckdb_v2_instance_create_with_options()`.\n The returned handle is borrowed: it is valid for as long as the instance is, and must not be destroyed.\n\n history:\n - unstable: v2.0.0\n\n @param instance The instance.\n @param out_config Receives the borrowed config.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_instance_get_config(
        instance: duckdb_v2_instance_handle,
        out_config: *mut duckdb_v2_config_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the config of a connection.\n\n Reads follow the connection's cascade: its SESSION value if it set one, otherwise the GLOBAL value, otherwise the\n default. Writes accept any scope the option supports. The returned handle is borrowed: it is valid for as long as the\n connection is, and must not be destroyed.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection.\n @param out_config Receives the borrowed config.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_get_config(
        conn: duckdb_v2_connection_handle,
        out_config: *mut duckdb_v2_config_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the config of a context.\n\n The same scope `duckdb_v2_connection_get_config()` gives for the context's connection. The returned handle is\n borrowed: it is valid for as long as the context is, and must not be destroyed.\n\n history:\n - unstable: v2.0.0\n\n @param ctx The context.\n @param out_config Receives the borrowed config.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_context_get_config(
        ctx: duckdb_v2_context_handle,
        out_config: *mut duckdb_v2_config_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reads the effective value of an option in this config, and the scope it came from.\n\n Aliases resolve transparently, and an unknown name returns ERROR_INPUT_INVALID. The caller destroys the returned\n value.\n\n history:\n - unstable: v2.0.0\n\n @param config The config to read from.\n @param name Option name (canonical or alias).\n @param out_value Receives the value, typed as the option. Owned by the caller.\n @param out_scope Receives the scope the value came from.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_config_get_option_value(
        config: duckdb_v2_config_handle,
        name: *const duckdb_v2_identifier_t,
        out_value: *mut duckdb_v2_value_handle,
        out_scope: *mut DUCKDB_V2_SETTING_SCOPE,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Writes an option in this config.\n\n `scope` chooses the destination, mirroring SQL:\n   - DEFAULT writes to the option's default scope, like a bare `SET name = value`.\n   - GLOBAL writes through to the instance, visible to all connections, like `SET GLOBAL`.\n   - SESSION writes to one connection's session only, like `SET SESSION`.\n A scope neither the option (`duckdb_v2_option_supports_scope()`) nor the config supports returns ERROR_INPUT_INVALID;\n an instance's config supports only GLOBAL. The value is cast to the option's type as SQL `SET` does. An unknown name\n is rejected unless an extension that defines it can be autoloaded. An option that can only be chosen at startup is\n rejected: pass it to `duckdb_v2_instance_create_with_options()`.\n\n history:\n - unstable: v2.0.0\n\n @param config The config to write to.\n @param name Option name (canonical or alias).\n @param value The value, cast to the option's type as SQL `SET` does. Borrowed.\n @param scope Target scope: DEFAULT, GLOBAL, or SESSION.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_config_set_option_value(
        config: duckdb_v2_config_handle,
        name: *const duckdb_v2_identifier_t,
        value: duckdb_v2_value_handle,
        scope: DUCKDB_V2_SETTING_SCOPE,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Writes an option in this config from text, the form SQL `SET` accepts.\n\n `duckdb_v2_config_set_option_value()` with the text as a VARCHAR value: the engine casts it to the option's type, so\n this is the one-call form for a setting spelled the way SQL spells it, e.g. \"1GB\" for memory_limit. Scope handling\n and errors are `duckdb_v2_config_set_option_value()`'s.\n\n history:\n - unstable: v2.0.0\n\n @param config The config to write to.\n @param name Option name (canonical or alias).\n @param setting The setting, in the textual form SQL `SET` accepts.\n @param scope Target scope: DEFAULT, GLOBAL, or SESSION.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_config_set_option_text(
        config: duckdb_v2_config_handle,
        name: *const duckdb_v2_identifier_t,
        setting: *const duckdb_v2_str,
        scope: DUCKDB_V2_SETTING_SCOPE,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Describes a config option registered on this config's instance, by name.\n\n Allocates an option descriptor: canonical name, default value, description, supported and default scopes, and\n aliases. Aliases resolve transparently — passing an alias returns the canonical option, with the alias listed in its\n alias array. An unknown name returns ERROR_INPUT_INVALID, which includes an option of an extension that has not\n loaded yet. The caller destroys the returned option.\n\n history:\n - unstable: v2.0.0\n\n @param config The config whose instance registered the options.\n @param name Option name (canonical or alias).\n @param out_option Receives the option descriptor.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_config_get_option_by_name(
        config: duckdb_v2_config_handle,
        name: *const duckdb_v2_identifier_t,
        out_option: *mut duckdb_v2_option_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of config options registered on this config's instance.\n\n Counts core options plus the extension options registered on this instance. Aliases are NOT counted separately; each\n one is reachable through its canonical option's alias array.\n\n history:\n - unstable: v2.0.0\n\n @param config The config whose instance registered the options.\n @param out_count Receives the option count.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_config_get_option_count(
        config: duckdb_v2_config_handle,
        out_count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Describes the config option at the given index on this config's instance.\n\n Index space: [0, core_count) addresses core options, [core_count, total) extension options. The mapping is stable for\n as long as no extension registers new options. An out-of-range index returns ERROR_INPUT_INVALID. The caller destroys\n the returned option.\n\n history:\n - unstable: v2.0.0\n\n @param config The config whose instance registered the options.\n @param index The option index, in [0, option_count).\n @param out_option Receives the option descriptor.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_config_get_option_by_index(
        config: duckdb_v2_config_handle,
        index: idx_t,
        out_option: *mut duckdb_v2_option_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys an option descriptor.\n\n Frees the handle along with the strings it owns. On success the slot is set to null. Safe to call on an already-null\n slot.\n\n history:\n - unstable: v2.0.0\n\n @param option The option handle to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_option_destroy(option: *mut duckdb_v2_option_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the option's canonical name.\n\n When the option was resolved from an alias, this still reports the canonical name; the alias is reachable via\n `duckdb_v2_option_get_alias()`.\n\n history:\n - unstable: v2.0.0\n\n @param option The option.\n @param out_name Receives a borrowed view of the option name. Valid until the option is destroyed.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_option_get_name(
        option: duckdb_v2_option_handle,
        out_name: *mut duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the option's static default, as a value of the option's type.\n\n A NULL value for an option whose declaration has no default. The caller destroys the returned value.\n\n history:\n - unstable: v2.0.0\n\n @param option The option.\n @param out_value Receives the default value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_option_get_default_value(
        option: duckdb_v2_option_handle,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the option's human-readable description.\n\n history:\n - unstable: v2.0.0\n\n @param option The option.\n @param out_description Receives a borrowed view of the description. Valid until the option is destroyed.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_option_get_description(
        option: duckdb_v2_option_handle,
        out_description: *mut duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reports whether the option may be written at a scope.\n\n GLOBAL and SESSION are the scopes to ask about; DEFAULT is supported by every option that supports either. A write at\n an unsupported scope returns ERROR_INPUT_INVALID.\n\n history:\n - unstable: v2.0.0\n\n @param option The option.\n @param scope The scope to ask about.\n @param out_supported Receives whether a write at the scope is accepted.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_option_supports_scope(
        option: duckdb_v2_option_handle,
        scope: DUCKDB_V2_SETTING_SCOPE,
        out_supported: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the scope a DEFAULT write of the option goes to: GLOBAL or SESSION.\n\n history:\n - unstable: v2.0.0\n\n @param option The option.\n @param out_scope Receives the default scope.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_option_get_default_scope(
        option: duckdb_v2_option_handle,
        out_scope: *mut DUCKDB_V2_SETTING_SCOPE,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of aliases registered for this option.\n\n Zero for an extension option; extension options carry no aliases.\n\n history:\n - unstable: v2.0.0\n\n @param option The option.\n @param out_count Receives the alias count.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_option_get_alias_count(
        option: duckdb_v2_option_handle,
        out_count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the alias name at the given index.\n\n An out-of-range index returns ERROR_INPUT_INVALID.\n\n history:\n - unstable: v2.0.0\n\n @param option The option.\n @param index The alias index, in [0, alias_count).\n @param out_alias Receives a borrowed view of the alias. Valid until the option is destroyed.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_option_get_alias(
        option: duckdb_v2_option_handle,
        index: idx_t,
        out_alias: *mut duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Opens a connection to an instance.\n\n Each connection carries its own client context and session-scoped (LOCAL) settings. Connections to the same instance\n share its catalog, buffer pool, and transaction manager. A connection may be created before any database is attached\n to the instance; until one is, only the system catalog and the connection's temporary catalog are visible. The caller\n destroys it via `duckdb_v2_connection_destroy()`.\n\n history:\n - unstable: v2.0.0\n\n @param instance The instance to connect to.\n @param out_conn Receives the new connection handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_create(
        instance: duckdb_v2_instance_handle,
        out_conn: *mut duckdb_v2_connection_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the connection.\n\n Always succeeds. Releases the connection's reference on the underlying database instance, which survives for as long\n as anything else still references it. On success the handle is set to null. Safe to call on an already-null slot.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_destroy(conn: *mut duckdb_v2_connection_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Interrupts the query currently executing on the connection.\n\n The cross-thread (but not cross-connection) cancellation entry point for streaming results: safe to call from any\n thread within the execution of a query through a connection, including while another thread steps the query's result.\n A no-op when no query is active. Cancellation surfaces on the consuming side as step status CANCELLED\n (`duckdb_v2_result_step()`), or as ERROR_RUNTIME_INTERRUPT (`duckdb_v2_result_fetch_chunk()`).\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection whose active query to interrupt.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_interrupt(
        conn: duckdb_v2_connection_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Captures a snapshot of the active query's execution progress.\n\n Reads the percentage and row counts from one consistent snapshot of the query currently executing on the connection.\n Safe to call from any thread, including while another thread steps the query's result.\n\n Progress is published only when the enable_progress_bar option is set; the bridge does not enable tracking itself.\n Both row counts are 0 when no information is available. The percentage is -1 when tracking is disabled, no query is\n active, or no progress has been published yet.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection.\n @param out_percentage Receives the percentage complete in [0, 100], -1 if tracking is disabled, no query is active,\n or no progress has been published yet.\n @param out_rows_processed Receives the number of rows processed so far.\n @param out_total_rows_to_process Receives the total number of rows the query will process.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_progress_get(
        conn: duckdb_v2_connection_handle,
        out_percentage: *mut f64,
        out_rows_processed: *mut u64,
        out_total_rows_to_process: *mut u64,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
#[doc = " An owned opaque handle to a custom type being built. Created with `duckdb_v2_custom_type_create()`, configured with\n `duckdb_v2_custom_type_set_name()` and `duckdb_v2_custom_type_set_base_type()`, made available with\n `duckdb_v2_connection_register_custom_type()` or `duckdb_v2_extension_register_custom_type()`, and destroyed with\n `duckdb_v2_custom_type_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_custom_type {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned opaque handle to a custom type being built. Created with `duckdb_v2_custom_type_create()`, configured with\n `duckdb_v2_custom_type_set_name()` and `duckdb_v2_custom_type_set_base_type()`, made available with\n `duckdb_v2_connection_register_custom_type()` or `duckdb_v2_extension_register_custom_type()`, and destroyed with\n `duckdb_v2_custom_type_destroy()`."]
pub type duckdb_v2_custom_type_handle = *mut _duckdb_v2_custom_type;
unsafe extern "C" {
    #[doc = " Creates a new custom type through a factory.\n\n The type starts out empty: configure it with `duckdb_v2_custom_type_set_name()` and\n `duckdb_v2_custom_type_set_base_type()`, then make it available with `duckdb_v2_connection_register_custom_type()` or\n `duckdb_v2_extension_register_custom_type()`. The caller owns the returned handle and must destroy it with\n `duckdb_v2_custom_type_destroy()`, also after registration.\n\n The custom type can only be registered on the database the factory belongs to.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create the custom type through.\n @param type On success, receives the newly created custom type. Owned by the caller.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_type_create(
        factory: duckdb_v2_factory_handle,
        type_: *mut duckdb_v2_custom_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the name of the custom type.\n\n This is the name the type is referred to by in SQL, and the alias carried by every logical type instance of it. The\n name is borrowed and copied. Calling this again replaces the previous name. A name must be set before registration.\n\n history:\n - unstable: v2.0.0\n\n @param type The type to set the name of.\n @param name The name to set. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_type_set_name(
        type_: duckdb_v2_custom_type_handle,
        name: *const duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the base type of the custom type.\n\n The custom type shares the base type's internal representation but is logically distinct, so it can carry its own\n cast functions. The type is borrowed and copied. Calling this again replaces the previous base type. A base type must\n be set before registration, and it must be a fully defined concrete type -- ANY is a signature wildcard, not\n something a registered type can be built on.\n\n history:\n - unstable: v2.0.0\n\n @param type The type to set the base type of.\n @param base_type The logical type to base the custom type on. Borrowed for the call only.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_type_set_base_type(
        type_: duckdb_v2_custom_type_handle,
        base_type: duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the custom type, making it available for use in SQL queries.\n\n The type is registered on the connection's database, visible to every connection, in the connection's transaction:\n inside an explicit transaction, it is invisible to other connections until the transaction commits, and a rollback\n undoes it. Registration requires a name and a complete base type. The custom type must have been created through a\n factory of the same database. The caller still owns the handle after registration and must destroy it with\n `duckdb_v2_custom_type_destroy()`, which does not affect the registered type.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection to register on.\n @param type The custom type to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_register_custom_type(
        conn: duckdb_v2_connection_handle,
        type_: duckdb_v2_custom_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the custom type, making it available for use in SQL queries.\n\n The type is registered on the loading extension's database and attributed to the extension. Use this from the\n extension's load callback. Registration requires a name and a complete base type. The custom type must have been\n created through a factory of the same database. The caller still owns the handle after registration and must destroy\n it with `duckdb_v2_custom_type_destroy()`, which does not affect the registered type.\n\n history:\n - unstable: v2.0.0\n\n @param extension The loading extension.\n @param type The custom type to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_extension_register_custom_type(
        extension: duckdb_v2_extension_handle,
        type_: duckdb_v2_custom_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the custom type, releasing its resources.\n\n Null-safe: passing a null pointer or null handle is a no-op. The handle is set to null on return to prevent\n double-destruction. Destroying the handle after registration does not affect the registered type.\n\n history:\n - unstable: v2.0.0\n\n @param type The type to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_type_destroy(type_: *mut duckdb_v2_custom_type_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates an empty data chunk with the given column types, drawing its allocator from a factory.\n\n The chunk's vectors are allocated through the factory's database, so the memory is accounted to that database.\n Allocates one FLAT vector per element of the types array, each at default capacity. Every vector starts at size 0;\n set it with vector_set_size once the vector is populated. The chunk is caller-owned and must be destroyed via\n data_chunk_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param types Pointer to an array of logical_type handles, one per column.\n @param column_count Number of elements in the types array.\n @param out_chunk Receives the new chunk handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_data_chunk_create(
        factory: duckdb_v2_factory_handle,
        types: *const duckdb_v2_logical_type_handle,
        column_count: idx_t,
        out_chunk: *mut duckdb_v2_data_chunk_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a deep copy of a data chunk, drawing its allocator from a factory.\n\n Allocates a new chunk with the source chunk's column types and copies all rows into it, through the factory's\n database. The copy is flattened and owns all its data, so it stays valid after the source chunk or whatever backs it\n (such as a column data collection scan state) is destroyed. The returned chunk is caller-owned and must be destroyed\n via data_chunk_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param chunk The chunk to copy. Left unchanged.\n @param out_chunk Receives the new chunk handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_data_chunk_copy(
        factory: duckdb_v2_factory_handle,
        chunk: duckdb_v2_data_chunk_handle,
        out_chunk: *mut duckdb_v2_data_chunk_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys a data chunk handle.\n\n Null-safe: passing nullptr or a slot already set to nullptr is a no-op. On success the slot is set to nullptr. Any\n vector previously borrowed from this chunk becomes invalid.\n\n history:\n - unstable: v2.0.0\n\n @param chunk The chunk to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_data_chunk_destroy(chunk: *mut duckdb_v2_data_chunk_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Empties a data chunk so it can be filled again.\n\n The chunk's size becomes 0, and each of its vectors becomes a writable FLAT vector of its type again, as on creation,\n so a chunk can be reused for one batch after another instead of being created for each. Data, views and pointers\n taken from the chunk or its vectors beforehand do not survive this. Must not be called on a chunk DuckDB lends to a\n callback for reading.\n\n history:\n - unstable: v2.0.0\n\n @param chunk The chunk to clear.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_data_chunk_clear(
        chunk: duckdb_v2_data_chunk_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the row count of a data chunk.\n\n history:\n - unstable: v2.0.0\n\n @param chunk The chunk.\n @param out_size Receives the row count.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_data_chunk_get_size(
        chunk: duckdb_v2_data_chunk_handle,
        out_size: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of rows a data chunk can hold, e.g. how many rows the exec callback of a table function may write\n into its output chunk in one call.\n\n history:\n - unstable: v2.0.0\n\n @param chunk The chunk.\n @param out_capacity Receives the number of rows the chunk can hold.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_data_chunk_get_capacity(
        chunk: duckdb_v2_data_chunk_handle,
        out_capacity: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of vectors in a data chunk.\n\n Equals the column count of the producing result.\n\n history:\n - unstable: v2.0.0\n\n @param chunk The chunk.\n @param out_count Receives the vector count.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_data_chunk_get_vector_count(
        chunk: duckdb_v2_data_chunk_handle,
        out_count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the vector at the given index in a data chunk.\n\n The returned handle is borrowed and valid until the chunk is destroyed; do not destroy it. An out-of-range index\n returns ERROR_INPUT_INVALID.\n\n history:\n - unstable: v2.0.0\n\n @param chunk The chunk.\n @param index The vector index, in [0, vector_count).\n @param out_vector Receives the borrowed vector handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_data_chunk_get_vector(
        chunk: duckdb_v2_data_chunk_handle,
        index: idx_t,
        out_vector: *mut duckdb_v2_vector_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates the V2 environment. Call once at program start.\n\n history:\n - unstable: v2.0.0\n\n @param out_env Receives the new environment handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_environment_create(
        out_env: *mut duckdb_v2_environment_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the environment.\n\n Refuses with ERROR_RESOURCE_IN_USE while any instance created through this environment is still alive; destroy those\n instances first, then retry. On success the handle is set to null.\n\n history:\n - unstable: v2.0.0\n\n @param env The environment.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_environment_destroy(env: *mut duckdb_v2_environment_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of instances currently alive under the environment.\n\n A diagnostic accessor, for tracking down leaked instances when `duckdb_v2_environment_destroy()` returns\n ERROR_RESOURCE_IN_USE. The count is a snapshot and may change before the next call.\n\n history:\n - unstable: v2.0.0\n\n @param env The environment.\n @param out_count Receives the number of live instances.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_environment_get_instance_count(
        env: duckdb_v2_environment_handle,
        out_count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the error code associated with an error info handle.\n\n On success, writes the info's error code to `*out_code`. On failure (e.g. if `info` is invalid), leaves `*out_code`\n unchanged and returns a non-success error code.\n\n history:\n - unstable: v2.0.0\n\n @param info The error info handle to query.\n @param out_code The error code associated with the info, if the call succeeds.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_error_info_get_code(
        info: duckdb_v2_error_info_handle,
        out_code: *mut DUCKDB_V2_ERROR,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the error text associated with an error info handle.\n\n Returns a borrowed pointer to the info's null-terminated error text. The pointer is owned by DuckDB and is valid\n until the info is destroyed or a new text is set; callers must not free it, and must not read it once the info has\n been destroyed.\n\n history:\n - unstable: v2.0.0\n\n @param info The error info handle to query.\n @param out_text Receives a borrowed view of the text. Owned by DuckDB; valid until the info handle is destroyed.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_error_info_get_text(
        info: duckdb_v2_error_info_handle,
        out_text: *mut duckdb_v2_str,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the error text body without the leading category prefix.\n\n Returns a borrowed view of the same text error_info_get_text reports, minus the leading \"<Type> Error: \" prefix. This\n is the authoritative unprefixed body: the API exposes no type name, so the prefix cannot be reconstructed and the\n body cannot be derived from error_info_get_text. Unprefixed does not mean plain — the body keeps whatever form it was\n rendered in (a LINE/caret block by default, JSON under errors_as_json). `{NULL, 0}` when there is no text. The\n pointer is owned by DuckDB and valid until the info handle is destroyed.\n\n history:\n - unstable: v2.0.0\n\n @param info The error info handle to query.\n @param out_raw_text Receives a borrowed view of the raw text. Owned by DuckDB; valid until the info handle is\n destroyed.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_error_info_get_raw_text(
        info: duckdb_v2_error_info_handle,
        out_raw_text: *mut duckdb_v2_str,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the error code for an error info handle.\n\n On success, replaces the info's error code with the provided one. On failure, nothing is changed. Accepts a `nullptr`\n info handle, in which case the call is a no-op and returns ERROR_NONE.\n\n history:\n - unstable: v2.0.0\n\n @param info The error info handle to set. On success, updated with the provided code.\n @param code The error code to set in the info.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_error_info_set_code(info: duckdb_v2_error_info_handle, code: DUCKDB_V2_ERROR) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the error text for an error info handle.\n\n On success, replaces the info's text with the provided one; DuckDB allocates its own copy of the string. On failure,\n nothing is changed. Accepts a `nullptr` info handle, in which case the call is a no-op and returns ERROR_NONE.\n\n history:\n - unstable: v2.0.0\n\n @param info The error info handle to set. On success, updated with the provided text.\n @param text The error text to set in the info.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_error_info_set_text(
        info: duckdb_v2_error_info_handle,
        text: *const duckdb_v2_str,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys an error info handle and frees its resources.\n\n Null-safe: calling with a null handle, or a null pointer-to-handle, is a no-op and returns ERROR_NONE. On return\n `*info` is set to nullptr. Safe to call on any info DuckDB returned.\n\n history:\n - unstable: v2.0.0\n\n @param info The error info handle to destroy. Set to nullptr on return.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_error_info_destroy(info: *mut duckdb_v2_error_info_handle) -> DUCKDB_V2_ERROR;
}
#[doc = " Hands back the function-pointer table for the API version the extension was built against, or NULL if this DuckDB\n cannot serve it.\n\n The extension calls it exactly once, first, through DUCKDB_EXTENSION_API_INIT; nothing else in the API may be called\n before it succeeds. A NULL return means the load has already failed and DuckDB has recorded why, so the entrypoint\n must return without touching the error slot. Statically linked extensions resolve DuckDB's symbols at link time and\n never call it, so for those the field is NULL."]
pub type duckdb_v2_extension_get_api_fn = ::std::option::Option<
    unsafe extern "C" fn(
        extension: duckdb_v2_extension_handle,
        version: *const ::std::os::raw::c_char,
    ) -> *const ::std::os::raw::c_void,
>;
#[doc = " The single argument to a V2 C extension entrypoint. Borrowed for the duration of the call: none of its fields outlive\n the entrypoint, and the extension destroys none of them."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct duckdb_v2_extension_input {
    #[doc = "! Fetches the versioned function-pointer table. NULL for a statically linked extension."]
    pub get_api: duckdb_v2_extension_get_api_fn,
    #[doc = "! The extension being loaded, and the token get_api takes."]
    pub extension: duckdb_v2_extension_handle,
    #[doc = " A borrowed context to read and run queries through, with a transaction already active. Valid only until the\n extension entrypoint returns; do not retain or destroy it."]
    pub context: duckdb_v2_context_handle,
    #[doc = " A live error slot: never NULL, and never pointing at NULL. Populate it with error_info_set_code, and optionally\n error_info_set_text, to fail the load. Do not destroy it -- DuckDB owns it. Pass a slot of your own to calls\n whose failure you intend to handle, so only a failure you mean to abort the load with lands here."]
    pub err: *mut duckdb_v2_error_info_handle,
}
unsafe extern "C" {
    #[doc = " Borrows the factory of an instance.\n\n The factory creates the built-in types and their values, casts with the built-in casts only, and allocates data\n chunks and column data collections through the instance. Anything that needs a catalog — catalog-registered types,\n qualified type names — returns ERROR_INPUT_INVALID. The returned handle is borrowed: it is valid for as long as the\n instance is, and must not be destroyed.\n\n history:\n - unstable: v2.0.0\n\n @param instance The instance.\n @param out_factory Receives the borrowed factory.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_instance_get_factory(
        instance: duckdb_v2_instance_handle,
        out_factory: *mut duckdb_v2_factory_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the factory of a connection.\n\n The factory reaches the connection's catalog and settings. Catalog lookups run in the connection's active\n transaction, or in a transaction of their own when none is open; nothing else opens a transaction. The returned\n handle is borrowed: it is valid for as long as the connection is, and must not be destroyed.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection.\n @param out_factory Receives the borrowed factory.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_get_factory(
        conn: duckdb_v2_connection_handle,
        out_factory: *mut duckdb_v2_factory_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the factory of a context.\n\n The factory reaches the context's catalog and settings, within the transaction the context already has. The returned\n handle is borrowed: it is valid for as long as the context is, and must not be destroyed.\n\n history:\n - unstable: v2.0.0\n\n @param ctx The context.\n @param out_factory Receives the borrowed factory.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_context_get_factory(
        ctx: duckdb_v2_context_handle,
        out_factory: *mut duckdb_v2_factory_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
#[repr(u32)]
#[non_exhaustive]
#[doc = " How `duckdb_v2_file_system_open()` opens a file. These are not a bitmask -- apply them one at a time with\n `duckdb_v2_file_open_options_set_flag()`, calling it once per behaviour you want, e.g. `FILE_FLAG_WRITE` then\n `FILE_FLAG_CREATE` to write to a file and create it when it does not exist."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_FILE_FLAG {
    #[doc = "! Not a flag. The zero value, so that an uninitialized variable does not name a behaviour; applying it is an\n! error."]
    DUCKDB_V2_FILE_FLAG_INVALID = 0,
    #[doc = "! Open the file with \"read\" capabilities."]
    DUCKDB_V2_FILE_FLAG_READ = 1,
    #[doc = "! Open the file with \"write\" capabilities."]
    DUCKDB_V2_FILE_FLAG_WRITE = 2,
    #[doc = "! Create the file if it does not exist, and open it as it is if it does."]
    DUCKDB_V2_FILE_FLAG_CREATE = 3,
    #[doc = " Create the file if it does not exist, and truncate it to empty if it does. To fail instead of truncating, combine\n `FILE_FLAG_CREATE` with `FILE_FLAG_EXCLUSIVE_CREATE`."]
    DUCKDB_V2_FILE_FLAG_CREATE_NEW = 4,
    #[doc = "! Open the file in \"append\" mode."]
    DUCKDB_V2_FILE_FLAG_APPEND = 5,
    #[doc = "! Fail if the file already exists. A modifier on `FILE_FLAG_CREATE`, and meaningless without it."]
    DUCKDB_V2_FILE_FLAG_EXCLUSIVE_CREATE = 6,
    #[doc = " The file will be read and written at explicit offsets from several threads at once. Pass it whenever\n `duckdb_v2_file_read_at()` or `duckdb_v2_file_write_at()` are used concurrently -- a file system that would\n otherwise assume sequential access, by caching, buffering, or keeping a single cursor, needs to know not to."]
    DUCKDB_V2_FILE_FLAG_PARALLEL_ACCESS = 7,
    #[doc = " Read the file through DuckDB's external file cache, which keeps the bytes that were read in memory, so that later\n reads of the same file - also by later queries - do not have to read them again. Whether a local file is cached\n is decided by the `cache_local_files` setting. Only meaningful for reading."]
    DUCKDB_V2_FILE_FLAG_EXTERNAL_FILE_CACHE = 8,
    #[doc = " Read the file through DuckDB's external file cache, which keeps the bytes that were read in memory, so that later\n reads of the same file - also by later queries - do not have to read them again. Whether a local file is cached\n is decided by the `cache_local_files` setting. Only meaningful for reading."]
    DUCKDB_V2_FILE_FLAG_MAX_ENUM = 2147483647,
}
#[doc = " A borrowed opaque handle to a file system. Obtained from `duckdb_v2_instance_get_file_system()`,\n `duckdb_v2_connection_get_file_system()` or `duckdb_v2_context_get_file_system()`, and used to open files with\n `duckdb_v2_file_system_open()`. Borrowed: the handle belongs to the instance, connection or context it came from, is\n valid only for as long as that is, and must not be destroyed."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_file_system {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to a file system. Obtained from `duckdb_v2_instance_get_file_system()`,\n `duckdb_v2_connection_get_file_system()` or `duckdb_v2_context_get_file_system()`, and used to open files with\n `duckdb_v2_file_system_open()`. Borrowed: the handle belongs to the instance, connection or context it came from, is\n valid only for as long as that is, and must not be destroyed."]
pub type duckdb_v2_file_system_handle = *mut _duckdb_v2_file_system;
#[doc = " An owned opaque handle to the options a file is opened with. Created with `duckdb_v2_file_open_options_create()`,\n configured with `duckdb_v2_file_open_options_set_flag()` and `duckdb_v2_file_open_options_set_value()`, passed to\n `duckdb_v2_file_system_open()`, and destroyed with `duckdb_v2_file_open_options_destroy()`. One options object can\n open any number of files, and destroying it does not affect files already opened with it."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_file_open_options {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned opaque handle to the options a file is opened with. Created with `duckdb_v2_file_open_options_create()`,\n configured with `duckdb_v2_file_open_options_set_flag()` and `duckdb_v2_file_open_options_set_value()`, passed to\n `duckdb_v2_file_system_open()`, and destroyed with `duckdb_v2_file_open_options_destroy()`. One options object can\n open any number of files, and destroying it does not affect files already opened with it."]
pub type duckdb_v2_file_open_options_handle = *mut _duckdb_v2_file_open_options;
#[doc = " An owned opaque handle to an open file, produced by `duckdb_v2_file_system_open()` and destroyed with\n `duckdb_v2_file_destroy()`. Read, write, seek and sync through the `file_*` functions. Only usable while the file\n system it was opened through is still valid."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_file {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned opaque handle to an open file, produced by `duckdb_v2_file_system_open()` and destroyed with\n `duckdb_v2_file_destroy()`. Read, write, seek and sync through the `file_*` functions. Only usable while the file\n system it was opened through is still valid."]
pub type duckdb_v2_file_handle = *mut _duckdb_v2_file;
#[doc = " Receives one path matched by `duckdb_v2_file_system_path_glob()`.\n\n The view is borrowed for the duration of the call only, and is not guaranteed to be null-terminated. Report an error\n through `err`, a live slot that must not be destroyed, to stop the glob: `duckdb_v2_file_system_path_glob()` then\n fails with that error. The callback must not throw or unwind across the boundary."]
pub type duckdb_v2_file_system_path_glob_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        path: *const duckdb_v2_str,
        user_data: *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
unsafe extern "C" {
    #[doc = " Borrows the file system of a context.\n\n The returned handle is borrowed: it is valid only for as long as the context is, and must not be destroyed.\n\n history:\n - unstable: v2.0.0\n\n @param context The context to take the file system from.\n @param file_system Receives the borrowed file system.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_context_get_file_system(
        context: duckdb_v2_context_handle,
        file_system: *mut duckdb_v2_file_system_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the file system of an instance.\n\n Paths are resolved with the instance's GLOBAL settings and secrets, and file I/O is not attributed to any query.\n\n The returned handle is borrowed: it is valid only for as long as the instance is, and must not be destroyed.\n\n history:\n - unstable: v2.0.0\n\n @param instance The instance to take the file system from.\n @param file_system Receives the borrowed file system.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_instance_get_file_system(
        instance: duckdb_v2_instance_handle,
        file_system: *mut duckdb_v2_file_system_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the file system of a connection.\n\n Paths are resolved with the connection's settings and secrets, and file I/O is attributed to its running query, as\n through `duckdb_v2_context_get_file_system()` in a callback.\n\n The returned handle is borrowed: it is valid only for as long as the connection is, and must not be destroyed.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection to take the file system from.\n @param file_system Receives the borrowed file system.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_get_file_system(
        conn: duckdb_v2_connection_handle,
        file_system: *mut duckdb_v2_file_system_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a set of open options for a file system.\n\n The options start out empty: give them flags with `duckdb_v2_file_open_options_set_flag()`, which is required, and\n optionally attach values with `duckdb_v2_file_open_options_set_value()`. They are then passed to\n `duckdb_v2_file_system_open()`, and can be reused for as many opens as you like. The caller owns the returned handle\n and must destroy it with `duckdb_v2_file_open_options_destroy()`.\n\n The options belong to the file system they were created from, since which values mean anything depends on which file\n system ends up handling the path.\n\n history:\n - unstable: v2.0.0\n\n @param file_system The file system the options are for.\n @param options On success, receives the new options. Owned by the caller; destroy via\n `duckdb_v2_file_open_options_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_open_options_create(
        file_system: duckdb_v2_file_system_handle,
        options: *mut duckdb_v2_file_open_options_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Applies one flag to the options.\n\n Additive: call it once per behaviour you want, and applying the same flag twice is harmless. At least one flag must\n be applied before the options can open anything, since the flags are what say whether the file is being read or\n written. There is no way to take a flag back -- build a fresh set of options instead.\n\n `FILE_FLAG_INVALID` names no behaviour and is rejected, as is any value that is not a `DUCKDB_V2_FILE_FLAG`.\n\n history:\n - unstable: v2.0.0\n\n @param options The options to apply the flag to.\n @param flag The flag to apply.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_open_options_set_flag(
        options: duckdb_v2_file_open_options_handle,
        flag: DUCKDB_V2_FILE_FLAG,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Attaches a named value to the options.\n\n These are hints for whichever file system ends up handling the path, and what they mean is that file system's\n business: a value it does not recognise is ignored rather than rejected, and the same name can mean different things\n to different file systems. They are the same values a file system reports when listing files, so a known file size or\n modification time learned from a listing can be handed straight back to avoid re-reading it.\n\n The name and the value are borrowed and copied, so the caller may destroy the value immediately after. Setting the\n same name again replaces the previous value. Names are case-sensitive.\n\n history:\n - unstable: v2.0.0\n\n @param options The options to set the value on.\n @param name The name of the value. Borrowed and copied.\n @param value The value. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_open_options_set_value(
        options: duckdb_v2_file_open_options_handle,
        name: *const duckdb_v2_str,
        value: duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the options, releasing their resources.\n\n Null-safe: passing a null pointer or null handle is a no-op. The handle is set to null on return to prevent\n double-destruction. Files already opened with these options are unaffected.\n\n history:\n - unstable: v2.0.0\n\n @param options The options to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_open_options_destroy(options: *mut duckdb_v2_file_open_options_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Opens a file.\n\n Opens the file at the given path through the file system, which routes it the way the engine would -- a path handled\n by a registered virtual or remote file system goes there rather than to local disk. The returned handle is owned by\n the caller and must be destroyed with `duckdb_v2_file_destroy()`.\n\n The options carry the flags and any file-system-specific values; see `duckdb_v2_file_open_options_create()`. Opening\n without having set flags fails, since the flags are what say whether the file is being read or written.\n\n Failure to open -- a missing file without `FILE_FLAG_CREATE`, insufficient permissions, an existing file under\n `FILE_FLAG_EXCLUSIVE_CREATE` -- is reported as an error.\n\n Flag combinations that contradict each other, such as naming neither read nor write or combining `FILE_FLAG_CREATE`\n with `FILE_FLAG_CREATE_NEW`, are a programming error rather than a supported input. An assertion build catches them;\n elsewhere the behaviour is whatever the underlying file system does with them.\n\n history:\n - unstable: v2.0.0\n\n @param file_system The file system to open the file through.\n @param file_path The path of the file to open. Borrowed for the call only.\n @param options How to open the file. Borrowed for the call only, and reusable across opens.\n @param file On success, receives the open file. Owned by the caller; destroy via `duckdb_v2_file_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_system_open(
        file_system: duckdb_v2_file_system_handle,
        file_path: *const duckdb_v2_str,
        options: duckdb_v2_file_open_options_handle,
        file: *mut duckdb_v2_file_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reports whether a file exists at the given path.\n\n The path is routed the way `duckdb_v2_file_system_open()` routes it, so asking about a path handled by a remote file\n system may reach out to it. A directory is not a file, and reports false.\n\n history:\n - unstable: v2.0.0\n\n @param file_system The file system to ask.\n @param path The path to check. Borrowed for the call only.\n @param out_exists Receives whether a file exists at the path.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_system_path_exists(
        file_system: duckdb_v2_file_system_handle,
        path: *const duckdb_v2_str,
        out_exists: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reports whether a path names a remote file, e.g. one under `s3://`, `https://`, `gcs://` or `azure://`.\n\n Decided from the path alone: no file system is consulted, so it answers even when the extension providing the remote\n file system is not loaded.\n\n history:\n - unstable: v2.0.0\n\n @param file_system The file system the path is meant for.\n @param path The path to check. Borrowed for the call only.\n @param out_is_remote Receives whether the path names a remote file.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_system_path_is_remote(
        file_system: duckdb_v2_file_system_handle,
        path: *const duckdb_v2_str,
        out_is_remote: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Expands a path as the file system does when opening it: a leading `~` becomes the home directory, as the\n `home_directory` setting configures it.\n\n A path without anything to expand is handed back as it is. The expanded path is handed to `sink` in a single call.\n\n history:\n - unstable: v2.0.0\n\n @param file_system The file system whose settings expand the path.\n @param path The path to expand. Borrowed for the call only.\n @param sink Receives the expanded path in a single call. Borrowed for the duration of that call; see text_sink for\n the full contract.\n @param user_data Opaque pointer passed through to sink untouched. May be NULL.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_system_path_expand(
        file_system: duckdb_v2_file_system_handle,
        path: *const duckdb_v2_str,
        sink: duckdb_v2_text_sink_fn,
        user_data: *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Finds the files matching a glob pattern, e.g. `*.csv` or `data_?.json` in a directory, handing each matched path to\n `callback`.\n\n The pattern is routed the way `duckdb_v2_file_system_open()` routes a path, so globbing a remote path may reach out\n to the file system handling it, and is only supported where that file system supports it. A pattern without glob\n characters matches the file it names, if there is one. Matching nothing is not an error. In which order the paths are\n handed over is up to the file system.\n\n history:\n - unstable: v2.0.0\n\n @param file_system The file system to glob in.\n @param pattern The glob pattern. Borrowed for the call only.\n @param callback Invoked once per matched path.\n @param user_data Opaque pointer passed through to `callback` untouched. May be NULL.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_system_path_glob(
        file_system: duckdb_v2_file_system_handle,
        pattern: *const duckdb_v2_str,
        callback: duckdb_v2_file_system_path_glob_callback_fn,
        user_data: *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Moves, or renames, a file from one path to another.\n\n The move is handled by the file system `source` routes to, the way `duckdb_v2_file_system_open()` routes a path;\n moving a file between two file systems is not supported. Whether an existing file at `target` is replaced, and\n whether the move is atomic, is up to that file system.\n\n history:\n - unstable: v2.0.0\n\n @param file_system The file system to move the file in.\n @param source The path of the file to move. Borrowed for the call only.\n @param target The path to move the file to. Borrowed for the call only.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_system_path_move(
        file_system: duckdb_v2_file_system_handle,
        source: *const duckdb_v2_str,
        target: *const duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Removes the file at a path, if there is one.\n\n The path is routed the way `duckdb_v2_file_system_open()` routes it. A path with no file is not an error:\n `out_removed` then receives false. A file that exists but cannot be removed is.\n\n history:\n - unstable: v2.0.0\n\n @param file_system The file system to remove the file from.\n @param path The path of the file to remove. Borrowed for the call only.\n @param out_removed Optional. Receives whether a file was removed.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_system_path_remove(
        file_system: duckdb_v2_file_system_handle,
        path: *const duckdb_v2_str,
        out_removed: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reads from the file into a caller-supplied buffer.\n\n Reads up to `buffer_size` bytes from the file's current position, advancing it by however many were read. Fewer bytes\n than asked for is normal at the end of the file, and zero means there is nothing left; neither is an error. The file\n must have been opened with `FILE_FLAG_READ`.\n\n Use `duckdb_v2_file_read_at()` to read at an explicit offset instead, which leaves the position alone and so can run\n on several threads at once.\n\n history:\n - unstable: v2.0.0\n\n @param file The file to read from.\n @param buffer A caller-owned buffer of at least `buffer_size` bytes, receiving what was read.\n @param buffer_size The maximum number of bytes to read.\n @param bytes_read Receives how many bytes were actually read, which may be fewer than `buffer_size` at the end of the\n file.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_read(
        file: duckdb_v2_file_handle,
        buffer: *mut ::std::os::raw::c_void,
        buffer_size: idx_t,
        bytes_read: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Writes a caller-supplied buffer to the file.\n\n Writes up to `buffer_size` bytes at the file's current position, advancing it by however many were written. The file\n must have been opened with `FILE_FLAG_WRITE` or `FILE_FLAG_APPEND`. Writes may be buffered; use\n `duckdb_v2_file_sync()` to force them out.\n\n Use `duckdb_v2_file_write_at()` to write at an explicit offset instead, which leaves the position alone and so can\n run on several threads at once.\n\n history:\n - unstable: v2.0.0\n\n @param file The file to write to.\n @param buffer A caller-owned buffer of at least `buffer_size` bytes, holding what to write.\n @param buffer_size The number of bytes to write.\n @param bytes_written Receives how many bytes were actually written.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_write(
        file: duckdb_v2_file_handle,
        buffer: *const ::std::os::raw::c_void,
        buffer_size: idx_t,
        bytes_written: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reads from a fixed offset, without moving the file's position.\n\n Reads exactly `buffer_size` bytes starting at `location`. Unlike `duckdb_v2_file_read()`, a short read is an error\n rather than a result: reaching the end of the file before `buffer_size` bytes fails, so there is no count to report\n back. The file's read/write position is untouched, which is what makes this safe to call from several threads at once\n -- provided the file was opened with `FILE_FLAG_PARALLEL_ACCESS`.\n\n The file must have been opened with `FILE_FLAG_READ`.\n\n history:\n - unstable: v2.0.0\n\n @param file The file to read from.\n @param buffer A caller-owned buffer of at least `buffer_size` bytes, receiving what was read.\n @param buffer_size The number of bytes to read. All of them are read, or the call fails.\n @param location The absolute byte offset to read from, measured from the start of the file.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_read_at(
        file: duckdb_v2_file_handle,
        buffer: *mut ::std::os::raw::c_void,
        buffer_size: idx_t,
        location: idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Writes at a fixed offset, without moving the file's position.\n\n Writes exactly `buffer_size` bytes starting at `location`, extending the file when the offset is past its end. Unlike\n `duckdb_v2_file_write()` there is no count to report back: all of the bytes are written, or the call fails. The\n file's read/write position is untouched, which is what makes this safe to call from several threads at once --\n provided the file was opened with `FILE_FLAG_PARALLEL_ACCESS`, and that the threads write disjoint ranges.\n\n The file must have been opened with `FILE_FLAG_WRITE`. Writes may be buffered; use `duckdb_v2_file_sync()` to force\n them out.\n\n history:\n - unstable: v2.0.0\n\n @param file The file to write to.\n @param buffer A caller-owned buffer of at least `buffer_size` bytes, holding what to write.\n @param buffer_size The number of bytes to write. All of them are written, or the call fails.\n @param location The absolute byte offset to write at, measured from the start of the file.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_write_at(
        file: duckdb_v2_file_handle,
        buffer: *const ::std::os::raw::c_void,
        buffer_size: idx_t,
        location: idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the file's current read/write position, as a byte offset from the start of the file.\n\n history:\n - unstable: v2.0.0\n\n @param file The file to query.\n @param position Receives the current position, as a byte offset from the start of the file.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_tell(
        file: duckdb_v2_file_handle,
        position: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the total size of the file in bytes.\n\n history:\n - unstable: v2.0.0\n\n @param file The file to query.\n @param size Receives the total size of the file in bytes.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_size(
        file: duckdb_v2_file_handle,
        size: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Moves the file's read/write position.\n\n Sets the position to an absolute byte offset from the start of the file; subsequent reads and writes start there.\n Seeking past the end is allowed, and reading from there yields nothing.\n\n history:\n - unstable: v2.0.0\n\n @param file The file to seek within.\n @param position The absolute byte offset to seek to, measured from the start of the file.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_seek(
        file: duckdb_v2_file_handle,
        position: idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Flushes buffered writes to persistent storage.\n\n Forces anything still buffered out to storage, which is what makes writes durable across a crash or a process exit.\n Closing or destroying the handle flushes as well.\n\n history:\n - unstable: v2.0.0\n\n @param file The file to synchronize.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_sync(file: duckdb_v2_file_handle, err: *mut duckdb_v2_error_info_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Closes the file without destroying the handle.\n\n Releases the operating-system resources behind the file, such as its descriptor. The handle itself stays valid and\n must still be destroyed with `duckdb_v2_file_destroy()`, but it can no longer read, write or seek.\n\n history:\n - unstable: v2.0.0\n\n @param file The file to close.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_close(file: duckdb_v2_file_handle, err: *mut duckdb_v2_error_info_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the file, closing it if it is still open.\n\n Null-safe: passing a null pointer or null handle is a no-op. The handle is set to null on return to prevent\n double-destruction.\n\n history:\n - unstable: v2.0.0\n\n @param file The file to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_file_destroy(file: *mut duckdb_v2_file_handle) -> DUCKDB_V2_ERROR;
}
#[doc = " A borrowed opaque handle to the call site a bind callback is binding. Every function family's bind callback receives\n this handle next to its own bind info. It gives access to the arguments of the call, the function's user data, and\n the bind data.\n\n The arguments form one list in four parts, in this order: one argument per positional-only and standard parameter, in\n declaration order; the arguments `*args` received, in call order; one argument per named-only parameter, in\n declaration order; and the arguments `**kwargs` received, in call order. How the caller passed an argument does not\n matter: a standard parameter passed by name is at its declared position. A parameter the call omitted is present with\n its default value. See `duckdb_v2_function_bind_get_arg_count()` for the size of each part."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_function_bind_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the call site a bind callback is binding. Every function family's bind callback receives\n this handle next to its own bind info. It gives access to the arguments of the call, the function's user data, and\n the bind data.\n\n The arguments form one list in four parts, in this order: one argument per positional-only and standard parameter, in\n declaration order; the arguments `*args` received, in call order; one argument per named-only parameter, in\n declaration order; and the arguments `**kwargs` received, in call order. How the caller passed an argument does not\n matter: a standard parameter passed by name is at its declared position. A parameter the call omitted is present with\n its default value. See `duckdb_v2_function_bind_get_arg_count()` for the size of each part."]
pub type duckdb_v2_function_bind_info_handle = *mut _duckdb_v2_function_bind_info;
unsafe extern "C" {
    #[doc = " Retrieves the user data set on the function being bound, e.g. via `duckdb_v2_scalar_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_function_bind_get_user_data(
        info: duckdb_v2_function_bind_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the function's \"bind data\" from the bind callback.\n\n The bind data is stored with the bound call site and retrievable from every later callback. The opaque handle bundles\n the pointer with an optional destructor, invoked when the bind data is no longer needed, and an optional equality\n callback used when comparing two bound call sites; without one, pointer equality is used. Scalar functions set their\n bind data through `duckdb_v2_scalar_function_bind_set_bind_data()` instead.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param data Opaque handle bundling the bind data pointer plus optional destructor and equality callbacks.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_function_bind_set_bind_data(
        info: duckdb_v2_function_bind_info_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of arguments of the call site being bound, split into the four parts of the argument list.\n\n The parts follow each other in this order: the positional-only and standard parameters, the arguments `*args`\n received, the named-only parameters, and the arguments `**kwargs` received. The argument at index `i` of the\n named-only part is therefore at index `positional_fixed + positional_variadic + i`. Valid indices for the other\n argument functions are [0, the sum of the four counts). Every out-parameter may be NULL, in which case nothing is\n written to it.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param positional_fixed Optional. Receives the number of positional-only and standard parameters.\n @param positional_variadic Optional. Receives the number of arguments `*args` received, 0 when the signature has\n none.\n @param named_fixed Optional. Receives the number of named-only parameters.\n @param named_variadic Optional. Receives the number of arguments `**kwargs` received, 0 when the signature has none.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_function_bind_get_arg_count(
        info: duckdb_v2_function_bind_info_handle,
        positional_fixed: *mut idx_t,
        positional_variadic: *mut idx_t,
        named_fixed: *mut idx_t,
        named_variadic: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the type of the argument at the given index.\n\n Fails if the index is out of bounds. The returned type is owned by the caller and must be destroyed via\n `duckdb_v2_logical_type_destroy()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param index The index of the argument.\n @param type Receives the argument type. Owned by the caller; destroy via `duckdb_v2_logical_type_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_function_bind_get_arg_type(
        info: duckdb_v2_function_bind_info_handle,
        index: idx_t,
        type_: *mut duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Folds the argument at the given index to a constant value.\n\n Fails if the argument is not constant, e.g. a column reference, or if the index is out of bounds. The arguments of a\n table or pragma function are always constant. The resulting value may be NULL. The returned value is owned by the\n caller and must be destroyed via `duckdb_v2_value_destroy()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param index The index of the argument.\n @param value Receives the constant value. Owned by the caller; destroy via `duckdb_v2_value_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_function_bind_get_arg_value(
        info: duckdb_v2_function_bind_info_handle,
        index: idx_t,
        value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the name of the argument at the given index.\n\n For an argument of a declared parameter, this is the parameter name. For an argument `**kwargs` received, it is the\n name the caller passed, which may be the name of a positional-only parameter. An argument `*args` received has no\n name, and yields an empty name. Fails if the index is out of bounds. The name is borrowed and valid only for the\n duration of the callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param index The index of the argument.\n @param name Receives a borrowed view of the argument name. Valid only for the duration of the callback.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_function_bind_get_arg_name(
        info: duckdb_v2_function_bind_info_handle,
        index: idx_t,
        name: *mut duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Looks up the index of an argument by name.\n\n Names are matched case-insensitively, against the names a caller can pass an argument by: those of the standard and\n named-only parameters, and those `**kwargs` received. Positional-only parameters are skipped, so `f(1, x := 2)` with\n a positional-only `x` finds the argument `**kwargs` received. A name the call did not pass is not an error: `found`\n receives false and `index` is left untouched. A standard or named-only parameter is always found, as the call either\n passed it or it carries its default value.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param name The name to look up. Borrowed for the call only.\n @param index Receives the index of the argument, if found.\n @param found Receives whether the call has an argument of that name.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_function_bind_get_arg_index(
        info: duckdb_v2_function_bind_info_handle,
        name: *const duckdb_v2_identifier_t,
        index: *mut idx_t,
        found: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
#[doc = " A borrowed opaque handle to the documentation of a function overload. Taken from the function it documents with\n `duckdb_v2_scalar_function_get_docs()`, `duckdb_v2_aggregate_function_get_docs()`,\n `duckdb_v2_table_function_get_docs()`, `duckdb_v2_pragma_function_get_docs()` or\n `duckdb_v2_macro_function_get_docs()`, and valid for as long as that function handle is; the caller never destroys\n it."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_function_docs {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the documentation of a function overload. Taken from the function it documents with\n `duckdb_v2_scalar_function_get_docs()`, `duckdb_v2_aggregate_function_get_docs()`,\n `duckdb_v2_table_function_get_docs()`, `duckdb_v2_pragma_function_get_docs()` or\n `duckdb_v2_macro_function_get_docs()`, and valid for as long as that function handle is; the caller never destroys\n it."]
pub type duckdb_v2_function_docs_handle = *mut _duckdb_v2_function_docs;
unsafe extern "C" {
    #[doc = " Sets the description of the function overload.\n\n The description is borrowed and copied. Calling this again replaces the previous description.\n\n history:\n - unstable: v2.0.0\n\n @param docs The documentation to set the description of.\n @param description The description to set. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_function_docs_set_description(
        docs: duckdb_v2_function_docs_handle,
        description: *const duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Adds an example of calling the function overload.\n\n The title and the example are borrowed and copied, and examples are reported in the order they were added.\n\n history:\n - unstable: v2.0.0\n\n @param docs The documentation to add the example to.\n @param title Optional. The title of the example; NULL or an empty view for none. Borrowed and copied.\n @param example The example, e.g. a SQL expression calling the function. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_function_docs_add_example(
        docs: duckdb_v2_function_docs_handle,
        title: *const duckdb_v2_str,
        example: *const duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Adds a category the function overload belongs to, e.g. \"string\" or \"aggregate\".\n\n The category is borrowed and copied, and categories are reported in the order they were added.\n\n history:\n - unstable: v2.0.0\n\n @param docs The documentation to add the category to.\n @param category The category. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_function_docs_add_category(
        docs: duckdb_v2_function_docs_handle,
        category: *const duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
#[repr(u32)]
#[non_exhaustive]
#[doc = " How a caller passes the argument for a parameter, following Python's parameter kinds. A signature orders its\n parameters by kind, in the order the values are listed here. Pass one of these to\n `duckdb_v2_function_signature_add_parameter()`."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_FUNCTION_PARAMETER_KIND {
    #[doc = " Passed by position only. The name is invisible to a caller: a named argument with the same name is received by\n `**kwargs`, or rejected when the signature has none."]
    DUCKDB_V2_FUNCTION_PARAMETER_KIND_POSITIONAL_ONLY = 0,
    #[doc = "! Passed by position or by name."]
    DUCKDB_V2_FUNCTION_PARAMETER_KIND_STANDARD = 1,
    #[doc = " `*args`: receives the positional arguments left over after the positional-only and standard parameters, each cast\n to the parameter type. ANY leaves them un-cast."]
    DUCKDB_V2_FUNCTION_PARAMETER_KIND_POSITIONAL_VARIADIC = 2,
    #[doc = "! Passed by name only."]
    DUCKDB_V2_FUNCTION_PARAMETER_KIND_NAMED_ONLY = 3,
    #[doc = " `**kwargs`: receives the named arguments that match no other parameter, each cast to the parameter type. ANY\n leaves them un-cast."]
    DUCKDB_V2_FUNCTION_PARAMETER_KIND_NAMED_VARIADIC = 4,
    #[doc = " `**kwargs`: receives the named arguments that match no other parameter, each cast to the parameter type. ANY\n leaves them un-cast."]
    DUCKDB_V2_FUNCTION_PARAMETER_KIND_MAX_ENUM = 2147483647,
}
#[doc = "! An opaque handle to a function signature. Carries the function's parameters and return type."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_function_signature {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = "! An opaque handle to a function signature. Carries the function's parameters and return type."]
pub type duckdb_v2_function_signature_handle = *mut _duckdb_v2_function_signature;
unsafe extern "C" {
    #[doc = " Adds a parameter to a signature.\n\n The kind decides how a caller passes the argument; see `DUCKDB_V2_FUNCTION_PARAMETER_KIND`. The signature keeps its\n parameters ordered by kind, and parameters of the same kind in the order they were added, so parameters of different\n kinds can be added in any order. A default value makes the parameter optional; `*args` and `**kwargs` cannot have\n one.\n\n Registration fails when two parameters share a name, when the signature has more than one `*args` or `**kwargs`\n parameter, or when a standard parameter without a default value follows one with a default value.\n\n history:\n - unstable: v2.0.0\n\n @param sig The signature to configure.\n @param name The parameter name. Borrowed and copied.\n @param type The parameter type. ANY accepts an argument of any type without casting it. Borrowed and copied.\n @param value Optional default value, borrowed and copied. Will be cast to the parameter type.\n @param kind How a caller passes the argument for the parameter.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_function_signature_add_parameter(
        sig: duckdb_v2_function_signature_handle,
        name: *const duckdb_v2_identifier_t,
        type_: duckdb_v2_logical_type_handle,
        value: duckdb_v2_value_handle,
        kind: DUCKDB_V2_FUNCTION_PARAMETER_KIND,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the return type of a signature.\n\n Sets the signature's return type. The type is borrowed and copied. Calling this again overwrites the previous return\n type. An INVALID type is rejected with ERROR_INPUT_INVALID. Whether a concrete return type is required, and whether\n ANY is accepted, depends on the function family and is enforced when the signature is registered with a builder.\n\n history:\n - unstable: v2.0.0\n\n @param sig The signature to configure.\n @param type The return type. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_function_signature_set_return_type(
        sig: duckdb_v2_function_signature_handle,
        type_: duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Renders a name as a SQL identifier, quoting and escaping only when required.\n\n Produces the SQL text for the name: the name itself when it is already a legal bare identifier, or the name\n double-quoted with interior double quotes doubled when it is a keyword or contains characters that require quoting.\n This is the engine's own identifier rendering, so the result parses back to a name equal to the input.\n\n Writes into a caller-supplied buffer, so nothing is allocated on the caller's behalf and nothing has to be freed.\n Pass out_text = NULL to size the buffer without rendering into it: out_length then receives the length, and\n out_capacity is ignored. With out_text != NULL, out_capacity must be at least out_length + 1, or the call returns\n ERROR_INPUT_OBJECT_SIZE with out_length set to the required length and out_text left untouched.\n\n out_length never counts the terminator, but a successful write always appends one, so the buffer is usable as a C\n string.\n\n history:\n - unstable: v2.0.0\n\n @param name The name to render. Borrowed for the call only.\n @param out_text Caller-owned buffer receiving the text plus a null terminator, or NULL to only report the required\n length in out_length.\n @param out_capacity Bytes available in out_text, terminator included. Ignored when out_text is NULL.\n @param out_length Receives the text length excluding the null terminator — written on success and on\n ERROR_INPUT_OBJECT_SIZE.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_identifier_render_quoted(
        name: *const duckdb_v2_identifier_t,
        out_text: *mut ::std::os::raw::c_char,
        out_capacity: idx_t,
        out_length: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
#[doc = " An opaque, owned handle to the `(KEY value)` options of one `duckdb_v2_instance_attach()` call, as SQL `ATTACH`\n accepts them. Created from the instance handle it will be used with via `duckdb_v2_attach_options_create()`; destroy\n it via `duckdb_v2_attach_options_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_attach_options {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An opaque, owned handle to the `(KEY value)` options of one `duckdb_v2_instance_attach()` call, as SQL `ATTACH`\n accepts them. Created from the instance handle it will be used with via `duckdb_v2_attach_options_create()`; destroy\n it via `duckdb_v2_attach_options_destroy()`."]
pub type duckdb_v2_attach_options_handle = *mut _duckdb_v2_attach_options;
unsafe extern "C" {
    #[doc = " Creates an instance under the environment with no startup options.\n\n The instance is ready on return, with no database attached: attach one with `duckdb_v2_instance_attach()` and pick\n the default with `duckdb_v2_instance_set_default()`, or connect with `duckdb_v2_connection_create()`. To choose an\n option that cannot change once the instance exists, such as access_mode, use\n `duckdb_v2_instance_create_with_options()` instead. The caller destroys the instance via\n `duckdb_v2_instance_destroy()`.\n\n history:\n - unstable: v2.0.0\n\n @param env The environment.\n @param out_instance Receives the new instance handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_instance_create(
        env: duckdb_v2_environment_handle,
        out_instance: *mut duckdb_v2_instance_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates an instance under the environment, configured with startup options.\n\n Behaves as `duckdb_v2_instance_create()`, applying the startup options first.\n\n Startup options are (name, value) pairs in two parallel arrays, the values in the textual form SQL `SET` accepts.\n They are the only way to choose an option that cannot change once the instance exists, such as access_mode or\n allow_unsigned_extensions; every other option can be written now or later through `duckdb_v2_instance_get_config()`.\n An option that needs a running instance (the logging options, allowed_directories, allowed_paths,\n disabled_filesystems) returns ERROR_INPUT_INVALID here: write it through the instance's config after creation. A name\n no core option or loaded extension defines is kept for an extension to consume while the instance starts up, and\n creation fails with the names none claimed. The caller destroys the instance via `duckdb_v2_instance_destroy()`.\n\n history:\n - unstable: v2.0.0\n\n @param env The environment.\n @param option_names Optional. An array of option_count option names (canonical or alias). Pass NULL when option_count\n is 0.\n @param option_values Optional. An array of option_count values, parallel to option_names, in the textual form SQL\n `SET` accepts. Pass NULL when option_count is 0.\n @param option_count The number of startup options.\n @param out_instance Receives the new instance handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_instance_create_with_options(
        env: duckdb_v2_environment_handle,
        option_names: *const duckdb_v2_str,
        option_values: *const duckdb_v2_str,
        option_count: idx_t,
        out_instance: *mut duckdb_v2_instance_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the instance handle.\n\n Always succeeds. Every attached database is closed with the instance. The instance itself stays alive for as long as\n any connection still references it; when the last reference drops, it is destroyed and its database files become\n available to open again. On success the handle is set to null. Safe to call on an already-null slot.\n\n history:\n - unstable: v2.0.0\n\n @param instance The instance handle to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_instance_destroy(instance: *mut duckdb_v2_instance_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Attaches a database to the instance.\n\n Attaches the database at `path` exactly like `ATTACH 'path'`:\n   - `:memory:` or an empty view attaches a fresh in-memory database.\n   - any other path attaches that file, creating it if it does not exist.\n `name` is the name to attach under, like `ATTACH ... AS name`; it is how `duckdb_v2_instance_detach()` and\n `duckdb_v2_instance_set_default()` refer to the database. Null, or an empty view, derives the name from the path the\n way SQL `ATTACH` without `AS` does:\n   - `memory` for `:memory:` or an empty view;\n   - otherwise the file name up to its first `.`, without any `?query` parameters (`/data/sales.2024.db` attaches as\n `sales`), with `_db` appended when that is a reserved name such as `system` or `temp`. Naming is how two files with\n the same base name, or `:memory:` twice, attach side by side. `options` may be null; it carries the `(KEY value)`\n options of SQL `ATTACH`, for per-database options such as READ_ONLY, BLOCK_SIZE or ENCRYPTION_KEY, and must have been\n created from this instance handle. `make_default` makes the attached database the default for connections created\n afterwards, exactly as a `duckdb_v2_instance_set_default()` call right after the attach would; otherwise the default\n is left alone. A path that is already attached on this or any other instance of the environment returns\n ERROR_RESOURCE_IN_USE, and a name that is already attached fails. Options that only apply at startup are passed to\n `duckdb_v2_instance_create_with_options()`.\n\n history:\n - unstable: v2.0.0\n\n @param instance The instance handle.\n @param name Optional. The name to attach under; null or an empty view for the name derived from the path. Borrowed\n and copied.\n @param path Path to the database file, or `:memory:` / an empty view for an in-memory database.\n @param options Optional attach options created from `instance`, or null to attach with defaults under the derived\n name.\n @param make_default Whether to make the attached database the default for connections created afterwards.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_instance_attach(
        instance: duckdb_v2_instance_handle,
        name: *const duckdb_v2_identifier_t,
        path: *const duckdb_v2_str,
        options: duckdb_v2_attach_options_handle,
        make_default: bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Detaches the database attached under `name`.\n\n Detaches it like `DETACH`, checkpointing a file database first. Unlike SQL, the default database may be detached too;\n new connections then start without a default until `duckdb_v2_instance_set_default()` names another, and existing\n connections bound to it keep it alive until their transaction on it ends and fail unqualified DDL afterwards. Returns\n ERROR_INPUT_INVALID when no database is attached under that name. Connections that still reference the database keep\n it alive until they release it.\n\n history:\n - unstable: v2.0.0\n\n @param instance The instance handle.\n @param name The name the database is attached under. Borrowed.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_instance_detach(
        instance: duckdb_v2_instance_handle,
        name: *const duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Makes the database attached under `name` the default database for connections created from now on.\n\n A connection binds to the default database when it is created, so this does not retarget existing connections: their\n default stays what it was when they connected, or what they chose with `USE`. The default is where unqualified DDL\n and unqualified table lookups that miss the temporary catalog go. It stays the default for new connections until\n another `duckdb_v2_instance_set_default()` call or until it is detached; a connection whose default has been detached\n fails unqualified DDL with a message saying so until it selects another with `USE`. Returns ERROR_INPUT_INVALID when\n no database is attached under that name.\n\n history:\n - unstable: v2.0.0\n\n @param instance The instance handle.\n @param name The name the database is attached under. Borrowed.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_instance_set_default(
        instance: duckdb_v2_instance_handle,
        name: *const duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates an empty set of attach options for use with `duckdb_v2_instance_attach()` on `instance`.\n\n Starts empty. The caller destroys it via `duckdb_v2_attach_options_destroy()`; the options may be destroyed as soon\n as the attach call returns, and reused for further attaches before that.\n\n history:\n - unstable: v2.0.0\n\n @param instance The instance handle the options will be used with.\n @param out_options Receives the new options handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_attach_options_create(
        instance: duckdb_v2_instance_handle,
        out_options: *mut duckdb_v2_attach_options_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets one attach option, like a `(KEY value)` entry of SQL `ATTACH`.\n\n The key is matched case-insensitively, as an unquoted SQL identifier is. The setting is passed on as the text a\n quoted SQL literal would produce: the engine casts the options it knows (READ_ONLY, RECOVERY_MODE, TYPE,\n DEFAULT_TABLE, VACUUM_REBUILD_INDEXES, BLOCK_SIZE, ENCRYPTION_KEY, ...) and hands the rest to the storage extension\n that ends up owning the database, which decides what they mean. Keys must be valid UTF-8; an unknown or ill-typed\n option fails the attach. Both views are borrowed and copied. Setting the same key again replaces it.\n\n history:\n - unstable: v2.0.0\n\n @param options The attach options.\n @param key The option name, e.g. READ_ONLY.\n @param setting The option value, in the textual form a quoted SQL literal would carry.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_attach_options_set(
        options: duckdb_v2_attach_options_handle,
        key: *const duckdb_v2_identifier_t,
        setting: *const duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys an attach options handle.\n\n On success the slot is set to null. Safe to call on an already-null slot.\n\n history:\n - unstable: v2.0.0\n\n @param options The attach options to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_attach_options_destroy(options: *mut duckdb_v2_attach_options_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the version of the linked DuckDB library.\n\n history:\n - unstable: v2.0.0\n\n @param out_version The version string.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_library_version(
        out_version: *mut duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
#[repr(u32)]
#[non_exhaustive]
#[doc = " Severity of a log message. Mirrors DuckDB's own log levels, and is compared against the configured threshold: an\n entry below it is dropped."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_LOG_LEVEL {
    #[doc = "! Finest detail; off in any default configuration."]
    DUCKDB_V2_LOG_LEVEL_TRACE = 10,
    #[doc = "! Diagnostic detail."]
    DUCKDB_V2_LOG_LEVEL_DEBUG = 20,
    #[doc = "! Ordinary progress information."]
    DUCKDB_V2_LOG_LEVEL_INFO = 30,
    #[doc = "! A recoverable problem."]
    DUCKDB_V2_LOG_LEVEL_WARNING = 40,
    #[doc = "! An operation failed."]
    DUCKDB_V2_LOG_LEVEL_ERROR = 50,
    #[doc = "! An unrecoverable failure."]
    DUCKDB_V2_LOG_LEVEL_FATAL = 60,
    #[doc = "! An unrecoverable failure."]
    DUCKDB_V2_LOG_LEVEL_MAX_ENUM = 2147483647,
}
unsafe extern "C" {
    #[doc = " Writes a message to DuckDB's log.\n\n The entry is attributed to the context's connection scope, so it carries that connection's ids. Whether it is\n recorded at all is up to the database's log configuration: if logging is off, or level is below the configured\n threshold, or log_type is not among the enabled types, the call succeeds and writes nothing. An empty log_type\n selects the default type. Read entries back with `SELECT * FROM duckdb_logs`.\n\n history:\n - unstable: v2.0.0\n\n @param ctx The context to log through.\n @param level Severity of the message.\n @param log_type The log type to record under, matched case-sensitively. Empty selects the default type.\n @param message The message body. Borrowed for the call only.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_context_log(
        ctx: duckdb_v2_context_handle,
        level: DUCKDB_V2_LOG_LEVEL,
        log_type: *const duckdb_v2_str,
        message: *const duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Writes a message to DuckDB's log.\n\n The entry is attributed to the database scope: it carries no connection or query ids. Whether it is recorded at all\n is up to the database's log configuration: if logging is off, or level is below the configured threshold, or log_type\n is not among the enabled types, the call succeeds and writes nothing. An empty log_type selects the default type.\n Read entries back with `SELECT * FROM duckdb_logs`.\n\n history:\n - unstable: v2.0.0\n\n @param instance The instance to log through.\n @param level Severity of the message.\n @param log_type The log type to record under, matched case-sensitively. Empty selects the default type.\n @param message The message body. Borrowed for the call only.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_instance_log(
        instance: duckdb_v2_instance_handle,
        level: DUCKDB_V2_LOG_LEVEL,
        log_type: *const duckdb_v2_str,
        message: *const duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Writes a message to DuckDB's log.\n\n The entry is attributed to the connection scope, so it carries the connection's ids. Whether it is recorded at all is\n up to the database's log configuration: if logging is off, or level is below the configured threshold, or log_type is\n not among the enabled types, the call succeeds and writes nothing. An empty log_type selects the default type. Read\n entries back with `SELECT * FROM duckdb_logs`.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection to log through.\n @param level Severity of the message.\n @param log_type The log type to record under, matched case-sensitively. Empty selects the default type.\n @param message The message body. Borrowed for the call only.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_log(
        conn: duckdb_v2_connection_handle,
        level: DUCKDB_V2_LOG_LEVEL,
        log_type: *const duckdb_v2_str,
        message: *const duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
#[doc = " An owned qualified name: an ordered path of one to three non-empty identifier parts whose last element is the object\n name. Construct with `duckdb_v2_qname_parse()` or `duckdb_v2_qname_create()`, read with\n `duckdb_v2_qname_get_part_count()` and `duckdb_v2_qname_get_part()`, render back to SQL with\n `duckdb_v2_qname_render()`, compare with `duckdb_v2_qname_equals()`, and destroy with `duckdb_v2_qname_destroy()`.\n Two handles are compared with `duckdb_v2_qname_equals()`, never by pointer."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_qname {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned qualified name: an ordered path of one to three non-empty identifier parts whose last element is the object\n name. Construct with `duckdb_v2_qname_parse()` or `duckdb_v2_qname_create()`, read with\n `duckdb_v2_qname_get_part_count()` and `duckdb_v2_qname_get_part()`, render back to SQL with\n `duckdb_v2_qname_render()`, compare with `duckdb_v2_qname_equals()`, and destroy with `duckdb_v2_qname_destroy()`.\n Two handles are compared with `duckdb_v2_qname_equals()`, never by pointer."]
pub type duckdb_v2_qname_handle = *mut _duckdb_v2_qname;
unsafe extern "C" {
    #[doc = " Parses SQL text into a qualified name.\n\n Applies the engine's qualified-name rules: dots separate parts, and a double-quoted part may contain dots and doubled\n interior quotes. More than three parts and an unterminated quote are rejected with the parser's own error. Invalid\n UTF-8 and text without at least one non-empty part are rejected with `ERROR_INPUT_INVALID`. When the parts are\n already separate, build the name with `duckdb_v2_qname_create()` rather than joining them and parsing the result.\n\n history:\n - unstable: v2.0.0\n\n @param text The name text to parse. Borrowed for the call only.\n @param name On success, receives the qualified name. Owned by the caller; destroy via `duckdb_v2_qname_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_qname_parse(
        text: *const duckdb_v2_str,
        name: *mut duckdb_v2_qname_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a qualified name from its parts.\n\n The parts are ordered outermost first, so the last one is the object name. Between one and three parts are accepted\n -- the engine qualifies at most catalog.schema.name today -- and every part must be non-empty: partial qualification\n is expressed by passing fewer parts, never by empty placeholders. Zero parts, more than three, and an empty part are\n all rejected with `ERROR_INPUT_INVALID`. The parts are borrowed and copied.\n\n history:\n - unstable: v2.0.0\n\n @param parts An array of `part_count` non-empty identifier views, outermost first.\n @param part_count The number of parts, between one and three.\n @param name On success, receives the qualified name. Owned by the caller; destroy via `duckdb_v2_qname_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_qname_create(
        parts: *const duckdb_v2_identifier_t,
        part_count: idx_t,
        name: *mut duckdb_v2_qname_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns how many parts the qualified name has.\n\n Always at least one. Valid indices for `duckdb_v2_qname_get_part()` are [0, count), and the object name is the part\n at count - 1.\n\n history:\n - unstable: v2.0.0\n\n @param name The qualified name.\n @param count Receives the number of parts.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_qname_get_part_count(
        name: duckdb_v2_qname_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows one part of the qualified name.\n\n Parts are ordered outermost first, so the object name is the part at `duckdb_v2_qname_get_part_count()` - 1. The view\n is valid until the qualified name is destroyed. An index outside [0, count) is rejected with\n `ERROR_INPUT_OUT_OF_RANGE`.\n\n history:\n - unstable: v2.0.0\n\n @param name The qualified name.\n @param index Zero-based part index.\n @param part Receives a borrowed view of the part, valid until the qualified name is destroyed.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_qname_get_part(
        name: duckdb_v2_qname_handle,
        index: idx_t,
        part: *mut duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Renders the qualified name as SQL text.\n\n Joins the parts with dots, quoting and escaping each one only where the identifier requires it, so the result parses\n back through `duckdb_v2_qname_parse()` to an equal name.\n\n Writes into a caller-supplied buffer, so nothing is allocated on the caller's behalf and nothing has to be freed.\n Pass out_text = NULL to size the buffer without rendering into it: out_length then receives the length, and\n out_capacity is ignored. With out_text != NULL, out_capacity must be at least out_length + 1, or the call returns\n ERROR_INPUT_OBJECT_SIZE with out_length set to the required length and out_text left untouched.\n\n out_length never counts the terminator, but a successful write always appends one, so the buffer is usable as a C\n string.\n\n history:\n - unstable: v2.0.0\n\n @param name The qualified name to render.\n @param out_text Caller-owned buffer receiving the text plus a null terminator, or NULL to only report the required\n length in out_length.\n @param out_capacity Bytes available in out_text, terminator included. Ignored when out_text is NULL.\n @param out_length Receives the text length excluding the null terminator — written on success and on\n ERROR_INPUT_OBJECT_SIZE.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_qname_render(
        name: duckdb_v2_qname_handle,
        out_text: *mut ::std::os::raw::c_char,
        out_capacity: idx_t,
        out_length: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Compares two qualified names.\n\n True when both have the same number of parts and every part matches case-insensitively, which is the engine's own\n identifier equality: casing never distinguishes two names. This is the only way to compare names; two handles holding\n equal names are still distinct pointers.\n\n history:\n - unstable: v2.0.0\n\n @param left The first qualified name.\n @param right The second qualified name.\n @param result Receives whether the two names are equal.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_qname_equals(
        left: duckdb_v2_qname_handle,
        right: duckdb_v2_qname_handle,
        result: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Hashes a qualified name.\n\n Consistent with `duckdb_v2_qname_equals()`: names that compare equal hash equal, casing differences included. The\n value is not stable across processes or library versions, so use it for in-process lookup tables only and never\n persist it.\n\n history:\n - unstable: v2.0.0\n\n @param name The qualified name to hash.\n @param hash Receives the hash value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_qname_hash(
        name: duckdb_v2_qname_handle,
        hash: *mut u64,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the qualified name, releasing its resources.\n\n Null-safe: passing a null pointer or null handle is a no-op. The handle is set to null on return to prevent\n double-destruction. Any part views borrowed from it become dangling.\n\n history:\n - unstable: v2.0.0\n\n @param name The qualified name to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_qname_destroy(name: *mut duckdb_v2_qname_handle) -> DUCKDB_V2_ERROR;
}
#[doc = " An owned snapshot of the metrics of a query. Taken with `duckdb_v2_connection_get_query_metrics()`, read from its\n root node via `duckdb_v2_query_metrics_get_root()`, and destroyed with `duckdb_v2_query_metrics_destroy()`. Later\n queries do not update it."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_query_metrics {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned snapshot of the metrics of a query. Taken with `duckdb_v2_connection_get_query_metrics()`, read from its\n root node via `duckdb_v2_query_metrics_get_root()`, and destroyed with `duckdb_v2_query_metrics_destroy()`. Later\n queries do not update it."]
pub type duckdb_v2_query_metrics_handle = *mut _duckdb_v2_query_metrics;
#[doc = " A borrowed opaque handle to one node of a query metrics snapshot, valid for as long as the snapshot is. Read its name\n with `duckdb_v2_query_metrics_node_get_name()`, its metrics with `duckdb_v2_query_metrics_node_get_metric()` or by\n index, and its children with `duckdb_v2_query_metrics_node_get_child()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_query_metrics_node {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to one node of a query metrics snapshot, valid for as long as the snapshot is. Read its name\n with `duckdb_v2_query_metrics_node_get_name()`, its metrics with `duckdb_v2_query_metrics_node_get_metric()` or by\n index, and its children with `duckdb_v2_query_metrics_node_get_child()`."]
pub type duckdb_v2_query_metrics_node_handle = *mut _duckdb_v2_query_metrics_node;
unsafe extern "C" {
    #[doc = " Takes a snapshot of the metrics of the last query the connection finished.\n\n The snapshot is owned by the caller and does not change afterwards. It holds the metrics DuckDB's profiling\n configuration gathered: without profiling enabled, the root node carries no metrics and has no children. A snapshot\n is not promised to be complete; any metric, and any operator node, may be missing.\n\n Fails with `ERROR_RESOURCE_IN_USE` while a query is running on the connection, i.e. while a result of it has not yet\n been drained or destroyed.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection to take the snapshot of.\n @param metrics On success, receives the owned snapshot. Destroy via `duckdb_v2_query_metrics_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_get_query_metrics(
        conn: duckdb_v2_connection_handle,
        metrics: *mut duckdb_v2_query_metrics_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Enables or disables profiling for the queries the connection runs from now on.\n\n While profiling is enabled, DuckDB gathers the metrics `duckdb_v2_connection_get_query_metrics()` reports. Profiling\n also prints the profile of every query, as configured by the `enable_profiling` and `profiling_output` options, which\n by default print a query tree to the standard output: set `enable_profiling` to `no_output` to only gather the\n metrics. Disabling profiling stops both.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection to enable or disable profiling for.\n @param enabled Whether to enable profiling.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_enable_profiling(
        conn: duckdb_v2_connection_handle,
        enabled: bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the root node of the snapshot, which describes the query as a whole. Its children, if any, describe the\n operators that executed the query.\n\n history:\n - unstable: v2.0.0\n\n @param metrics The snapshot.\n @param node Receives the borrowed root node. Valid until the snapshot is destroyed.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_query_metrics_get_root(
        metrics: duckdb_v2_query_metrics_handle,
        node: *mut duckdb_v2_query_metrics_node_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the name of the node: `QUERY` for the root node, and the name of the operator, e.g. `TABLE_SCAN`, for the\n other nodes.\n\n history:\n - unstable: v2.0.0\n\n @param node The node.\n @param name Receives a borrowed view of the name. Valid until the snapshot is destroyed.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_query_metrics_node_get_name(
        node: duckdb_v2_query_metrics_node_handle,
        name: *mut duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of children of the node. Valid indices for `duckdb_v2_query_metrics_node_get_child()` are [0,\n count).\n\n history:\n - unstable: v2.0.0\n\n @param node The node.\n @param count Receives the number of children.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_query_metrics_node_get_child_count(
        node: duckdb_v2_query_metrics_node_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the child of the node at index. An out-of-range index is rejected with `ERROR_INPUT_OUT_OF_RANGE`.\n\n history:\n - unstable: v2.0.0\n\n @param node The node.\n @param index Zero-based child index.\n @param child Receives the borrowed child. Valid until the snapshot is destroyed.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_query_metrics_node_get_child(
        node: duckdb_v2_query_metrics_node_handle,
        index: idx_t,
        child: *mut duckdb_v2_query_metrics_node_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of metrics the node carries. Valid indices for `duckdb_v2_query_metrics_node_get_metric_name()`\n and `duckdb_v2_query_metrics_node_get_metric_value()` are [0, count); the order of the metrics is unspecified.\n\n history:\n - unstable: v2.0.0\n\n @param node The node.\n @param count Receives the number of metrics.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_query_metrics_node_get_metric_count(
        node: duckdb_v2_query_metrics_node_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the name of the metric at index, e.g. `query.total_time`. An out-of-range index is rejected with\n `ERROR_INPUT_OUT_OF_RANGE`.\n\n history:\n - unstable: v2.0.0\n\n @param node The node.\n @param index Zero-based metric index.\n @param name Receives a borrowed view of the name. Valid until the snapshot is destroyed.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_query_metrics_node_get_metric_name(
        node: duckdb_v2_query_metrics_node_handle,
        index: idx_t,
        name: *mut duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value of the metric at index, a number such as a UBIGINT count or a DOUBLE duration. An out-of-range\n index is rejected with `ERROR_INPUT_OUT_OF_RANGE`.\n\n history:\n - unstable: v2.0.0\n\n @param node The node.\n @param index Zero-based metric index.\n @param value Receives the owned value. Destroy via `duckdb_v2_value_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_query_metrics_node_get_metric_value(
        node: duckdb_v2_query_metrics_node_handle,
        index: idx_t,
        value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Looks up a metric of the node by name, e.g. `query.total_time`. When the node does not carry it, `present` receives\n false and `value` receives null.\n\n history:\n - unstable: v2.0.0\n\n @param node The node.\n @param name The name of the metric, matched exactly. Borrowed for the call only.\n @param value Receives the owned value, if present. Destroy via `duckdb_v2_value_destroy()`.\n @param present Receives whether the node carries the metric.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_query_metrics_node_get_metric(
        node: duckdb_v2_query_metrics_node_handle,
        name: *const duckdb_v2_str,
        value: *mut duckdb_v2_value_handle,
        present: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the snapshot, releasing its resources and invalidating the nodes borrowed from it.\n\n Null-safe: passing a null pointer or null handle is a no-op. The handle is set to null on return to prevent\n double-destruction.\n\n history:\n - unstable: v2.0.0\n\n @param metrics The snapshot to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_query_metrics_destroy(metrics: *mut duckdb_v2_query_metrics_handle) -> DUCKDB_V2_ERROR;
}
#[doc = " An owned, ordered list of (name, type) fields. Read with schema_get_count and schema_get_field. Destroy via\n schema_destroy."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_schema {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned, ordered list of (name, type) fields. Read with schema_get_count and schema_get_field. Destroy via\n schema_destroy."]
pub type duckdb_v2_schema_handle = *mut _duckdb_v2_schema;
unsafe extern "C" {
    #[doc = " Returns the number of fields in a schema.\n\n history:\n - unstable: v2.0.0\n\n @param schema The schema.\n @param out_count Receives the field count.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_schema_get_count(
        schema: duckdb_v2_schema_handle,
        out_count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the name and type of the field at the given index.\n\n out_name and out_type are valid only until the schema is destroyed, and out_type must not be destroyed. An\n out-of-range index is rejected with ERROR_INPUT_INVALID.\n\n history:\n - unstable: v2.0.0\n\n @param schema The schema.\n @param index Zero-based field index.\n @param out_name Receives a borrowed view of the field name. Valid until the schema is destroyed.\n @param out_type Receives a borrowed field type. Valid until the schema is destroyed; do not destroy it.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_schema_get_field(
        schema: duckdb_v2_schema_handle,
        index: idx_t,
        out_name: *mut duckdb_v2_identifier_t,
        out_type: *mut duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys a schema handle.\n\n Frees the handle along with the names and types it owns. On success the slot is set to null. Safe to call on an\n already-null slot.\n\n history:\n - unstable: v2.0.0\n\n @param schema The schema handle to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_schema_destroy(schema: *mut duckdb_v2_schema_handle) -> DUCKDB_V2_ERROR;
}
#[repr(u32)]
#[non_exhaustive]
#[doc = "! The lexical class of a token."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_TOKEN_TYPE {
    #[doc = "! Not an actual token class; out_type is set to this when `duckdb_v2_token_iterator_next()` fails."]
    DUCKDB_V2_TOKEN_TYPE_INVALID = 0,
    #[doc = "! A keyword of the connection's grammar."]
    DUCKDB_V2_TOKEN_TYPE_KEYWORD = 1,
    #[doc = "! A bare or double-quoted identifier, quotes included."]
    DUCKDB_V2_TOKEN_TYPE_IDENTIFIER = 2,
    #[doc = "! A quoted or dollar-quoted string, delimiters included."]
    DUCKDB_V2_TOKEN_TYPE_STRING_LITERAL = 3,
    #[doc = "! A numeric literal."]
    DUCKDB_V2_TOKEN_TYPE_NUMBER_LITERAL = 4,
    #[doc = "! An operator or punctuation run other than the statement terminator."]
    DUCKDB_V2_TOKEN_TYPE_OPERATOR = 5,
    #[doc = "! A line or block comment, delimiters included."]
    DUCKDB_V2_TOKEN_TYPE_COMMENT = 6,
    #[doc = "! A statement-terminating semicolon."]
    DUCKDB_V2_TOKEN_TYPE_TERMINATOR = 7,
    #[doc = " Not a token; reported by token_iterator_next once the input is exhausted, with start equal to the input length\n and length 0."]
    DUCKDB_V2_TOKEN_TYPE_END_OF_INPUT = 8,
    #[doc = " Not a token; reported by token_iterator_next once the input is exhausted, with start equal to the input length\n and length 0."]
    DUCKDB_V2_TOKEN_TYPE_MAX_ENUM = 2147483647,
}
#[doc = "! An opaque, owned handle to an iterator over the tokens of a SQL string, produced by tokenize_sql."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_token_iterator {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = "! An opaque, owned handle to an iterator over the tokens of a SQL string, produced by tokenize_sql."]
pub type duckdb_v2_token_iterator_handle = *mut _duckdb_v2_token_iterator;
unsafe extern "C" {
    #[doc = " Tokenizes a SQL string into an iterator over its tokens.\n\n Lexical tokenization, in the context of whatever grammar extensions are loaded on the given connection. Closing the\n connection or changing settings afterwards does not affect the tokens. The SQL string is borrowed for the call only,\n the caller may free it once this call returns. Whitespace is not a token. Malformed input is not an error;\n `duckdb_v2_token_iterator_ends_unterminated()` reports whether the input ended inside an open token.\n\n *out_iterator is set to NULL on failure.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection supplying the grammar.\n @param sql The SQL text. Borrowed for the call only; may contain interior null bytes. {NULL, 0} is the empty input.\n @param out_iterator Receives the new iterator handle. Destroy via token_iterator_destroy.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_tokenize_sql(
        conn: duckdb_v2_connection_handle,
        sql: *const duckdb_v2_str,
        out_iterator: *mut duckdb_v2_token_iterator_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Yields the next token, or END_OF_INPUT once exhausted.\n\n On success writes the token's class, byte offset and byte length into the out-parameters. The lexeme is the input\n bytes [start, start + length). Once the input is exhausted, every call gives TOKEN_TYPE_END_OF_INPUT with start equal\n to the input length and length 0. On failure out params are set to TOKEN_TYPE_INVALID, 0, 0.\n\n history:\n - unstable: v2.0.0\n\n @param iterator The iterator to advance.\n @param out_type Receives the token's class, or TOKEN_TYPE_END_OF_INPUT once exhausted.\n @param out_start Receives the token's byte offset into the input; the input length for END_OF_INPUT.\n @param out_length Receives the token's byte length; 0 for END_OF_INPUT.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_token_iterator_next(
        iterator: duckdb_v2_token_iterator_handle,
        out_type: *mut DUCKDB_V2_TOKEN_TYPE,
        out_start: *mut idx_t,
        out_length: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reports whether the input ended before the closing delimiter of its last token.\n\n True when the input ends inside an open string, quoted identifier, block comment or dollar-quoted string, or in a\n line comment with no trailing newline; false otherwise, including for empty or whitespace-only input. Equivalently,\n the last token `duckdb_v2_token_iterator_next()` yields before TOKEN_TYPE_END_OF_INPUT is the open one, so its class\n and lexeme say which delimiter is missing. A property of the input, not of the iterator position: the answer is the\n same before, during and after draining. The only failure is a null argument.\n\n history:\n - unstable: v2.0.0\n\n @param iterator The iterator.\n @param out_ends_unterminated Receives whether the input ended inside an open token.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_token_iterator_ends_unterminated(
        iterator: duckdb_v2_token_iterator_handle,
        out_ends_unterminated: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys a token iterator handle.\n\n history:\n - unstable: v2.0.0\n\n @param iterator The iterator to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_token_iterator_destroy(iterator: *mut duckdb_v2_token_iterator_handle) -> DUCKDB_V2_ERROR;
}
#[doc = " An owned opaque handle to a custom aggregate function being built. Created with\n `duckdb_v2_aggregate_function_create()`, configured with the setter functions (e.g.\n `duckdb_v2_aggregate_function_set_name()`, `duckdb_v2_aggregate_function_set_update_callback()`, etc.) and the\n signature obtained via `duckdb_v2_aggregate_function_get_signature()`, made available with\n `duckdb_v2_connection_register_aggregate_function()` or `duckdb_v2_extension_register_aggregate_function()`, and\n destroyed with `duckdb_v2_aggregate_function_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_aggregate_function {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned opaque handle to a custom aggregate function being built. Created with\n `duckdb_v2_aggregate_function_create()`, configured with the setter functions (e.g.\n `duckdb_v2_aggregate_function_set_name()`, `duckdb_v2_aggregate_function_set_update_callback()`, etc.) and the\n signature obtained via `duckdb_v2_aggregate_function_get_signature()`, made available with\n `duckdb_v2_connection_register_aggregate_function()` or `duckdb_v2_extension_register_aggregate_function()`, and\n destroyed with `duckdb_v2_aggregate_function_destroy()`."]
pub type duckdb_v2_aggregate_function_handle = *mut _duckdb_v2_aggregate_function;
#[doc = " A borrowed opaque handle to the result of an aggregate function's \"bind\" phase. The \"bind\" callback receives this\n handle next to a `duckdb_v2_function_bind_info_handle`, which gives access to the arguments, the user data and the\n bind data, and can use it to set the return type of the call site being bound."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_aggregate_function_bind_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the result of an aggregate function's \"bind\" phase. The \"bind\" callback receives this\n handle next to a `duckdb_v2_function_bind_info_handle`, which gives access to the arguments, the user data and the\n bind data, and can use it to set the return type of the call site being bound."]
pub type duckdb_v2_aggregate_function_bind_info_handle = *mut _duckdb_v2_aggregate_function_bind_info;
#[doc = " A borrowed opaque handle to the arguments supplied to an aggregate function during the state sizing \"size\" phase. The\n \"size\" callback receives this handle and must use it to report the size of a single aggregate state in bytes."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_aggregate_function_size_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to an aggregate function during the state sizing \"size\" phase. The\n \"size\" callback receives this handle and must use it to report the size of a single aggregate state in bytes."]
pub type duckdb_v2_aggregate_function_size_info_handle = *mut _duckdb_v2_aggregate_function_size_info;
#[doc = " A borrowed opaque handle to the arguments supplied to an aggregate function during the state initialization \"init\"\n phase. The \"init\" callback receives this handle and can use it to access the array of aggregate states it must\n initialize in place."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_aggregate_function_init_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to an aggregate function during the state initialization \"init\"\n phase. The \"init\" callback receives this handle and can use it to access the array of aggregate states it must\n initialize in place."]
pub type duckdb_v2_aggregate_function_init_info_handle = *mut _duckdb_v2_aggregate_function_init_info;
#[doc = " A borrowed opaque handle to the arguments supplied to an aggregate function during the \"update\" phase. The \"update\"\n callback receives this handle and can use it to access the input argument vectors, the number of rows to process, and\n the aggregate state each row must be aggregated into."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_aggregate_function_update_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to an aggregate function during the \"update\" phase. The \"update\"\n callback receives this handle and can use it to access the input argument vectors, the number of rows to process, and\n the aggregate state each row must be aggregated into."]
pub type duckdb_v2_aggregate_function_update_info_handle = *mut _duckdb_v2_aggregate_function_update_info;
#[doc = " A borrowed opaque handle to the arguments supplied to an aggregate function during the \"combine\" phase. The \"combine\"\n callback receives this handle and can use it to access the source and target aggregate state arrays to merge."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_aggregate_function_combine_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to an aggregate function during the \"combine\" phase. The \"combine\"\n callback receives this handle and can use it to access the source and target aggregate state arrays to merge."]
pub type duckdb_v2_aggregate_function_combine_info_handle = *mut _duckdb_v2_aggregate_function_combine_info;
#[doc = " A borrowed opaque handle to the arguments supplied to an aggregate function during the \"finalize\" phase. The\n \"finalize\" callback receives this handle and can use it to access the aggregate states and the result vector and\n offset to write their final values to."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_aggregate_function_finalize_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to an aggregate function during the \"finalize\" phase. The\n \"finalize\" callback receives this handle and can use it to access the aggregate states and the result vector and\n offset to write their final values to."]
pub type duckdb_v2_aggregate_function_finalize_info_handle = *mut _duckdb_v2_aggregate_function_finalize_info;
#[doc = " A borrowed opaque handle to the arguments supplied to an aggregate function during the state destruction \"destroy\"\n phase. The \"destroy\" callback receives this handle and can use it to access the array of aggregate states whose\n resources must be released."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_aggregate_function_destroy_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to an aggregate function during the state destruction \"destroy\"\n phase. The \"destroy\" callback receives this handle and can use it to access the array of aggregate states whose\n resources must be released."]
pub type duckdb_v2_aggregate_function_destroy_info_handle = *mut _duckdb_v2_aggregate_function_destroy_info;
pub type duckdb_v2_aggregate_function_bind_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_function_bind_info_handle,
        result: duckdb_v2_aggregate_function_bind_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_aggregate_function_size_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(info: duckdb_v2_aggregate_function_size_info_handle, err: *mut duckdb_v2_error_info_handle),
>;
pub type duckdb_v2_aggregate_function_init_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(info: duckdb_v2_aggregate_function_init_info_handle, err: *mut duckdb_v2_error_info_handle),
>;
pub type duckdb_v2_aggregate_function_update_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(info: duckdb_v2_aggregate_function_update_info_handle, err: *mut duckdb_v2_error_info_handle),
>;
pub type duckdb_v2_aggregate_function_combine_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(info: duckdb_v2_aggregate_function_combine_info_handle, err: *mut duckdb_v2_error_info_handle),
>;
pub type duckdb_v2_aggregate_function_finalize_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_aggregate_function_finalize_info_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_aggregate_function_destroy_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(info: duckdb_v2_aggregate_function_destroy_info_handle, err: *mut duckdb_v2_error_info_handle),
>;
unsafe extern "C" {
    #[doc = " Creates a new aggregate function through a factory.\n\n The function starts out empty: configure it with the setter functions (e.g.\n `duckdb_v2_aggregate_function_set_name()`, `duckdb_v2_aggregate_function_set_update_callback()`, etc.) and the\n signature obtained via `duckdb_v2_aggregate_function_get_signature()`, then make it available with\n `duckdb_v2_connection_register_aggregate_function()` or `duckdb_v2_extension_register_aggregate_function()`. The\n caller owns the returned handle and must destroy it with `duckdb_v2_aggregate_function_destroy()`, also after\n registration.\n\n The aggregate function can only be registered on the database the factory belongs to.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create the aggregate function through.\n @param function On success, receives the newly created aggregate function. Owned by the caller.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_create(
        factory: duckdb_v2_factory_handle,
        function: *mut duckdb_v2_aggregate_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the name of the aggregate function.\n\n The name is borrowed and copied. Calling this again replaces the previous name. A name must be set before\n registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the name of.\n @param name The name to set. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_set_name(
        function: duckdb_v2_aggregate_function_handle,
        name: *const duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the documentation of the function so it can be filled in.\n\n Set a description with `duckdb_v2_function_docs_set_description()`, and add examples and categories with\n `duckdb_v2_function_docs_add_example()` and `duckdb_v2_function_docs_add_category()`. The documentation is modified\n in place, describes this overload only, and is registered with the function. Optional.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to get the documentation of.\n @param docs The returned documentation. Borrowed and valid for the lifetime of the function handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_get_docs(
        function: duckdb_v2_aggregate_function_handle,
        docs: *mut duckdb_v2_function_docs_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the function's signature so it can be configured.\n\n Add parameters with `duckdb_v2_function_signature_add_parameter()` and set the return type with\n `duckdb_v2_function_signature_set_return_type()`. The signature is modified in place; the function must be given a\n signature with a return type before registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to get the signature of.\n @param sig The returned signature. Borrowed and valid for the lifetime of the function handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_get_signature(
        function: duckdb_v2_aggregate_function_handle,
        sig: *mut duckdb_v2_function_signature_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets arbitrary user data on the aggregate function.\n\n Associates an opaque pointer with the function, retrievable from each callback via its user data accessor (e.g.\n `duckdb_v2_function_bind_get_user_data()`, `duckdb_v2_aggregate_function_update_get_user_data()`, etc.). The opaque\n handle bundles the pointer with an optional destructor, invoked when the data is no longer needed.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the user data of.\n @param data Opaque handle bundling the user data pointer plus an optional destructor.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_set_user_data(
        function: duckdb_v2_aggregate_function_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets a property on the aggregate function.\n\n Configures a function property that influences planning and execution, such as stability, NULL handling, fallibility,\n collation handling, or the aggregate-specific order/DISTINCT dependence. The value must be one of the\n `DUCKDB_V2_FUNCTION_PROPERTY_VALUE` entries belonging to `key`; passing a value that does not belong to the key, or a\n key that is not valid for aggregate functions, results in an error.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the property of.\n @param key The property to set.\n @param value The value to set for the property. Must belong to `key`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_set_property(
        function: duckdb_v2_aggregate_function_handle,
        key: DUCKDB_V2_FUNCTION_PROPERTY_KEY,
        value: DUCKDB_V2_FUNCTION_PROPERTY_VALUE,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional bind callback of the aggregate function.\n\n The bind callback is invoked during query planning for each call site of the function. Through its\n `duckdb_v2_function_bind_info_handle` it can inspect the argument types and constant argument values and set \"bind\n data\" that is shared with the other callbacks. Through its `duckdb_v2_aggregate_function_bind_info_handle` it can set\n a concrete return type.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the bind callback of.\n @param callback The bind callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_set_bind_callback(
        function: duckdb_v2_aggregate_function_handle,
        callback: duckdb_v2_aggregate_function_bind_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the size callback of the aggregate function.\n\n The size callback reports the size of a single aggregate state in bytes via\n `duckdb_v2_aggregate_function_size_set_state_size()`; DuckDB uses it to allocate state memory. A size callback must\n be set before registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the size callback of.\n @param callback The size callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_set_size_callback(
        function: duckdb_v2_aggregate_function_handle,
        callback: duckdb_v2_aggregate_function_size_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the init callback of the aggregate function.\n\n The init callback initializes freshly allocated aggregate states in place, obtained via\n `duckdb_v2_aggregate_function_init_get_states()`. An init callback must be set before registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the init callback of.\n @param callback The init callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_set_init_callback(
        function: duckdb_v2_aggregate_function_handle,
        callback: duckdb_v2_aggregate_function_init_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the update callback of the aggregate function.\n\n The update callback is invoked during query execution with a batch of input rows: row i of every argument vector must\n be aggregated into state i of the state array. An update callback must be set before registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the update callback of.\n @param callback The update callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_set_update_callback(
        function: duckdb_v2_aggregate_function_handle,
        callback: duckdb_v2_aggregate_function_update_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the combine callback of the aggregate function.\n\n The combine callback merges partial aggregate states computed in parallel: source state i must be combined into\n target state i. A combine callback must be set before registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the combine callback of.\n @param callback The combine callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_set_combine_callback(
        function: duckdb_v2_aggregate_function_handle,
        callback: duckdb_v2_aggregate_function_combine_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the finalize callback of the aggregate function.\n\n The finalize callback produces the function's result: state i must be finalized into result row offset + i of the\n result vector. A finalize callback must be set before registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the finalize callback of.\n @param callback The finalize callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_set_finalize_callback(
        function: duckdb_v2_aggregate_function_handle,
        callback: duckdb_v2_aggregate_function_finalize_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the destroy callback for the aggregate function. Optional: only needed when aggregate states own resources that\n must be released. The callback runs on states that are discarded without being finalized; it must not fail, an error\n reported through its error slot is ignored.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the destroy callback of.\n @param callback The destroy callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_set_destroy_callback(
        function: duckdb_v2_aggregate_function_handle,
        callback: duckdb_v2_aggregate_function_destroy_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the concrete return type of the call site being bound.\n\n Overrides the return type declared in the signature. Register the function with an ANY return type and set the\n concrete type here, derived from the argument types, to build a function whose result type depends on its input. The\n type is borrowed and copied.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param return_type The return type to set. Borrowed for the call only.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_bind_set_return_type(
        info: duckdb_v2_aggregate_function_bind_info_handle,
        return_type: duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_aggregate_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The size info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_size_get_user_data(
        info: duckdb_v2_aggregate_function_size_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The size info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_size_get_bind_data(
        info: duckdb_v2_aggregate_function_size_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the size of a single aggregate state, in bytes. The size callback must set this; DuckDB uses it to allocate\n state memory.\n\n history:\n - unstable: v2.0.0\n\n @param info The size info handle.\n @param size The size of a single aggregate state, in bytes.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_size_set_state_size(
        info: duckdb_v2_aggregate_function_size_info_handle,
        size: idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_aggregate_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The init info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_init_get_user_data(
        info: duckdb_v2_aggregate_function_init_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The init info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_init_get_bind_data(
        info: duckdb_v2_aggregate_function_init_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns how many aggregate states this invocation must initialize. This is the length of the array returned by\n `duckdb_v2_aggregate_function_init_get_states()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The init info handle.\n @param count Receives the number of states.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_init_get_state_count(
        info: duckdb_v2_aggregate_function_init_info_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the array of aggregate states to initialize, one pointer per state. Each state points to uninitialized memory\n of the size reported by the size callback; the init callback must initialize all of them in place.\n\n history:\n - unstable: v2.0.0\n\n @param info The init info handle.\n @param states Receives the array of aggregate state pointers. Borrowed; valid only for the duration of the callback.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_init_get_states(
        info: duckdb_v2_aggregate_function_init_info_handle,
        states: *mut *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_aggregate_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The update info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_update_get_user_data(
        info: duckdb_v2_aggregate_function_update_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The update info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_update_get_bind_data(
        info: duckdb_v2_aggregate_function_update_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns how many input rows this invocation carries. This is the length of the argument vectors and of the state\n array: row i of every argument vector must be aggregated into state i.\n\n history:\n - unstable: v2.0.0\n\n @param info The update info handle.\n @param count Receives the number of rows.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_update_get_row_count(
        info: duckdb_v2_aggregate_function_update_info_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns how many argument vectors this invocation carries, split into the four parts of the argument list.\n\n The parts and their order are those the bind callback saw through `duckdb_v2_function_bind_get_arg_count()`, and the\n vectors are at the same indices. Valid indices for `duckdb_v2_aggregate_function_update_get_arg()` are [0, the sum of\n the four counts). Every out-parameter may be NULL, in which case nothing is written to it.\n\n history:\n - unstable: v2.0.0\n\n @param info The update info handle.\n @param positional_fixed Optional. Receives the number of positional-only and standard parameters.\n @param positional_variadic Optional. Receives the number of arguments `*args` received, 0 when the signature has\n none.\n @param named_fixed Optional. Receives the number of named-only parameters.\n @param named_variadic Optional. Receives the number of arguments `**kwargs` received, 0 when the signature has none.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_update_get_arg_count(
        info: duckdb_v2_aggregate_function_update_info_handle,
        positional_fixed: *mut idx_t,
        positional_variadic: *mut idx_t,
        named_fixed: *mut idx_t,
        named_variadic: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the argument vector at the given index.\n\n The index is the one the bind callback used for the argument, e.g. the index\n `duckdb_v2_function_bind_get_arg_index()` found for a name. The vector holds the argument's values for the current\n batch; use `duckdb_v2_aggregate_function_update_get_row_count()` for the number of rows. Fails if the index is out of\n bounds. Borrowed; valid only for the duration of the callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The update info handle.\n @param index The index of the argument.\n @param vector Receives the borrowed argument vector.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_update_get_arg(
        info: duckdb_v2_aggregate_function_update_info_handle,
        index: idx_t,
        vector: *mut duckdb_v2_vector_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the array of aggregate states to update, one pointer per input row: row i of every argument vector must be\n aggregated into state i. Different rows may point to the same state.\n\n history:\n - unstable: v2.0.0\n\n @param info The update info handle.\n @param states Receives the array of aggregate state pointers. Borrowed; valid only for the duration of the callback.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_update_get_states(
        info: duckdb_v2_aggregate_function_update_info_handle,
        states: *mut *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_aggregate_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The combine info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_combine_get_user_data(
        info: duckdb_v2_aggregate_function_combine_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The combine info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_combine_get_bind_data(
        info: duckdb_v2_aggregate_function_combine_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns how many source/target state pairs this invocation must combine. This is the length of both the sources and\n the targets array.\n\n history:\n - unstable: v2.0.0\n\n @param info The combine info handle.\n @param count Receives the number of state pairs.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_combine_get_state_count(
        info: duckdb_v2_aggregate_function_combine_info_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the array of source aggregate states, one pointer per pair. Source i must be combined into target i; the\n source must not be modified.\n\n history:\n - unstable: v2.0.0\n\n @param info The combine info handle.\n @param states Receives the array of source aggregate state pointers. Borrowed; valid only for the duration of the\n callback.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_combine_get_sources(
        info: duckdb_v2_aggregate_function_combine_info_handle,
        states: *mut *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the array of target aggregate states, one pointer per pair. Source i must be combined into target i.\n\n history:\n - unstable: v2.0.0\n\n @param info The combine info handle.\n @param states Receives the array of target aggregate state pointers. Borrowed; valid only for the duration of the\n callback.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_combine_get_targets(
        info: duckdb_v2_aggregate_function_combine_info_handle,
        states: *mut *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_aggregate_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The finalize info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_finalize_get_user_data(
        info: duckdb_v2_aggregate_function_finalize_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The finalize info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_finalize_get_bind_data(
        info: duckdb_v2_aggregate_function_finalize_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns how many aggregate states this invocation must finalize. This is the length of the state array and the number\n of rows to write to the result vector.\n\n history:\n - unstable: v2.0.0\n\n @param info The finalize info handle.\n @param count Receives the number of states.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_finalize_get_state_count(
        info: duckdb_v2_aggregate_function_finalize_info_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the array of aggregate states to finalize, one pointer per state. State i must be finalized into result row\n offset + i.\n\n history:\n - unstable: v2.0.0\n\n @param info The finalize info handle.\n @param states Receives the array of aggregate state pointers. Borrowed; valid only for the duration of the callback.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_finalize_get_states(
        info: duckdb_v2_aggregate_function_finalize_info_handle,
        states: *mut *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the result vector the finalize callback must write into.\n\n State i must be finalized into result row offset + i, with the offset from\n `duckdb_v2_aggregate_function_finalize_get_result_offset()`. Borrowed; valid only for the duration of the callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The finalize info handle.\n @param vector Receives the borrowed result vector to write into.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_finalize_get_result(
        info: duckdb_v2_aggregate_function_finalize_info_handle,
        vector: *mut duckdb_v2_vector_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the offset in the result vector at which to start writing: state i must be finalized into result row offset +\n i.\n\n history:\n - unstable: v2.0.0\n\n @param info The finalize info handle.\n @param offset Receives the result offset.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_finalize_get_result_offset(
        info: duckdb_v2_aggregate_function_finalize_info_handle,
        offset: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_aggregate_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The destroy info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_destroy_get_user_data(
        info: duckdb_v2_aggregate_function_destroy_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The destroy info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_destroy_get_bind_data(
        info: duckdb_v2_aggregate_function_destroy_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns how many aggregate states this invocation must destroy. This is the length of the state array.\n\n history:\n - unstable: v2.0.0\n\n @param info The destroy info handle.\n @param count Receives the number of states.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_destroy_get_state_count(
        info: duckdb_v2_aggregate_function_destroy_info_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the array of aggregate states to destroy, one pointer per state. The callback must release any resources the\n states own.\n\n history:\n - unstable: v2.0.0\n\n @param info The destroy info handle.\n @param states Receives the array of aggregate state pointers. Borrowed; valid only for the duration of the callback.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_destroy_get_states(
        info: duckdb_v2_aggregate_function_destroy_info_handle,
        states: *mut *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the aggregate function, making it available for use in SQL queries.\n\n The function is registered on the connection's database, visible to every connection, in the connection's\n transaction: inside an explicit transaction, it is invisible to other connections until the transaction commits, and\n a rollback undoes it. Registration requires a name, the size, init, update, combine and finalize callbacks, and a\n signature with a complete return type; an ANY return type is accepted only together with a bind callback that sets\n the concrete type per call site. The aggregate function must have been created through a factory of the same\n database. The caller still owns the handle after registration and must destroy it with\n `duckdb_v2_aggregate_function_destroy()`, which does not affect the registered function.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection to register on.\n @param function The aggregate function to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_register_aggregate_function(
        conn: duckdb_v2_connection_handle,
        function: duckdb_v2_aggregate_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the aggregate function, making it available for use in SQL queries.\n\n The function is registered on the loading extension's database and attributed to the extension. Use this from the\n extension's load callback. Registration requires a name, the size, init, update, combine and finalize callbacks, and\n a signature with a complete return type; an ANY return type is accepted only together with a bind callback that sets\n the concrete type per call site. The aggregate function must have been created through a factory of the same\n database. The caller still owns the handle after registration and must destroy it with\n `duckdb_v2_aggregate_function_destroy()`, which does not affect the registered function.\n\n history:\n - unstable: v2.0.0\n\n @param extension The loading extension.\n @param function The aggregate function to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_extension_register_aggregate_function(
        extension: duckdb_v2_extension_handle,
        function: duckdb_v2_aggregate_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the aggregate function, releasing its resources.\n\n Null-safe: passing a null pointer or null handle is a no-op. The handle is set to null on return to prevent\n double-destruction. Destroying the handle after registration does not affect the registered function.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_aggregate_function_destroy(function: *mut duckdb_v2_aggregate_function_handle) -> DUCKDB_V2_ERROR;
}
#[doc = " An owned snapshot of one base table taken at creation: where the name resolved, the table's columns, and per-column\n catalog facts. Later DDL does not update it. Create with `duckdb_v2_connection_describe_table()`, read the resolved\n location via `duckdb_v2_table_description_get_qname()`, and the columns via\n `duckdb_v2_table_description_get_column_count()` and `duckdb_v2_table_description_get_column()`. Destroy via\n `duckdb_v2_table_description_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_table_description {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned snapshot of one base table taken at creation: where the name resolved, the table's columns, and per-column\n catalog facts. Later DDL does not update it. Create with `duckdb_v2_connection_describe_table()`, read the resolved\n location via `duckdb_v2_table_description_get_qname()`, and the columns via\n `duckdb_v2_table_description_get_column_count()` and `duckdb_v2_table_description_get_column()`. Destroy via\n `duckdb_v2_table_description_destroy()`."]
pub type duckdb_v2_table_description_handle = *mut _duckdb_v2_table_description;
#[doc = " An owned snapshot of one column of a described table: its name, type, and catalog facts. Obtain with\n `duckdb_v2_table_description_get_column()`, read with `duckdb_v2_column_description_get_name()`,\n `duckdb_v2_column_description_get_type()`, `duckdb_v2_column_description_has_default()` and\n `duckdb_v2_column_description_has_generated()`, and destroy with `duckdb_v2_column_description_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_column_description {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned snapshot of one column of a described table: its name, type, and catalog facts. Obtain with\n `duckdb_v2_table_description_get_column()`, read with `duckdb_v2_column_description_get_name()`,\n `duckdb_v2_column_description_get_type()`, `duckdb_v2_column_description_has_default()` and\n `duckdb_v2_column_description_has_generated()`, and destroy with `duckdb_v2_column_description_destroy()`."]
pub type duckdb_v2_column_description_handle = *mut _duckdb_v2_column_description;
unsafe extern "C" {
    #[doc = " Resolves a table name and snapshots its description.\n\n Resolves name in the connection's catalogs and returns an owned description of the table it names. name may be\n partial: an unqualified or schema-qualified name resolves through the connection's search path, exactly as the same\n name resolves in SQL. A two-part name tries the first part as a schema and as an attached database, as SQL does, and\n is rejected when both readings exist. A name that resolves to nothing is rejected with the engine's missing-table\n error; a name that resolves to a view is rejected with the engine's not-a-table error, since a description snapshots\n a base table.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection whose catalogs and search path resolve the name.\n @param name The possibly partial table name to resolve. Borrowed for the call only.\n @param desc On success, receives the owned description. Destroy via `duckdb_v2_table_description_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_describe_table(
        conn: duckdb_v2_connection_handle,
        name: duckdb_v2_qname_handle,
        desc: *mut duckdb_v2_table_description_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the resolved qualified name of the described table.\n\n Returns an owned copy of the fully resolved name: the catalog, schema, and table the lookup landed on, with the\n casing the table was created with, never an echo of the requested name. Rendering it produces SQL that pins the\n described table regardless of search path.\n\n history:\n - unstable: v2.0.0\n\n @param desc The description.\n @param name Receives the owned resolved name. Destroy via `duckdb_v2_qname_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_description_get_qname(
        desc: duckdb_v2_table_description_handle,
        name: *mut duckdb_v2_qname_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns whether the described table's catalog is read-only.\n\n True when the catalog the name resolved into was attached read-only, in which case no write to the table can succeed.\n False does not by itself prove a write will succeed; it clears the catalog-level check only.\n\n history:\n - unstable: v2.0.0\n\n @param desc The description.\n @param readonly Receives whether the catalog is read-only.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_description_is_readonly(
        desc: duckdb_v2_table_description_handle,
        readonly: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of columns of the described table.\n\n Counts every column in declared order, generated columns included. Valid indices for\n `duckdb_v2_table_description_get_column()` are [0, count).\n\n history:\n - unstable: v2.0.0\n\n @param desc The description.\n @param count Receives the column count.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_description_get_column_count(
        desc: duckdb_v2_table_description_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns an owned description of the column at index.\n\n Columns are numbered in declared order, generated columns included. An out-of-range index is rejected with\n `ERROR_INPUT_OUT_OF_RANGE`.\n\n history:\n - unstable: v2.0.0\n\n @param desc The description.\n @param index Zero-based column index.\n @param column Receives the owned column description. Destroy via `duckdb_v2_column_description_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_description_get_column(
        desc: duckdb_v2_table_description_handle,
        index: idx_t,
        column: *mut duckdb_v2_column_description_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the table description, releasing its resources.\n\n Null-safe: passing a null pointer or null handle is a no-op. The handle is set to null on return to prevent\n double-destruction. Column descriptions obtained from it are independent and stay valid.\n\n history:\n - unstable: v2.0.0\n\n @param desc The description to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_description_destroy(desc: *mut duckdb_v2_table_description_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the name of the column.\n\n The name carries the casing the column was declared with.\n\n history:\n - unstable: v2.0.0\n\n @param column The column description.\n @param name Receives a borrowed view of the column name. Valid until the column description is destroyed.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_description_get_name(
        column: duckdb_v2_column_description_handle,
        name: *mut duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the type of the column.\n\n history:\n - unstable: v2.0.0\n\n @param column The column description.\n @param type Receives the borrowed column type. Valid until the column description is destroyed; do not destroy it.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_description_get_type(
        column: duckdb_v2_column_description_handle,
        type_: *mut duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns whether the column has a default value.\n\n True when the column declares a default expression; the engine evaluates it for rows that omit the column. Generated\n columns report false.\n\n history:\n - unstable: v2.0.0\n\n @param column The column description.\n @param has_default Receives whether the column has a default value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_description_has_default(
        column: duckdb_v2_column_description_handle,
        has_default: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns whether the column is generated.\n\n True when the column is a generated column, computed by the engine from a generation expression and not writable.\n\n history:\n - unstable: v2.0.0\n\n @param column The column description.\n @param has_generated Receives whether the column is generated.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_description_has_generated(
        column: duckdb_v2_column_description_handle,
        has_generated: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the column description, releasing its resources.\n\n Null-safe: passing a null pointer or null handle is a no-op. The handle is set to null on return to prevent\n double-destruction. Any name or type borrowed from it becomes dangling.\n\n history:\n - unstable: v2.0.0\n\n @param column The column description to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_column_description_destroy(column: *mut duckdb_v2_column_description_handle) -> DUCKDB_V2_ERROR;
}
#[doc = " An owned opaque handle to a custom copy function being built: an output format for `COPY ... TO`, an input format for\n `COPY ... FROM`, or both. Created with `duckdb_v2_copy_function_create()`, configured with the setter functions (e.g.\n `duckdb_v2_copy_function_set_name()`, `duckdb_v2_copy_to_set_batch_callback()`,\n `duckdb_v2_copy_from_set_exec_callback()`, etc.), made available with `duckdb_v2_connection_register_copy_function()`\n or `duckdb_v2_extension_register_copy_function()`, and destroyed with `duckdb_v2_copy_function_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_copy_function {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned opaque handle to a custom copy function being built: an output format for `COPY ... TO`, an input format for\n `COPY ... FROM`, or both. Created with `duckdb_v2_copy_function_create()`, configured with the setter functions (e.g.\n `duckdb_v2_copy_function_set_name()`, `duckdb_v2_copy_to_set_batch_callback()`,\n `duckdb_v2_copy_from_set_exec_callback()`, etc.), made available with `duckdb_v2_connection_register_copy_function()`\n or `duckdb_v2_extension_register_copy_function()`, and destroyed with `duckdb_v2_copy_function_destroy()`."]
pub type duckdb_v2_copy_function_handle = *mut _duckdb_v2_copy_function;
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the query preparation \"bind\" phase of a\n `COPY ... TO` statement. The \"bind\" callback receives this handle and can use it to e.g. inspect the names and types\n of the columns being written, read the statement's options and initialize some constant state."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_copy_to_bind_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the query preparation \"bind\" phase of a\n `COPY ... TO` statement. The \"bind\" callback receives this handle and can use it to e.g. inspect the names and types\n of the columns being written, read the statement's options and initialize some constant state."]
pub type duckdb_v2_copy_to_bind_info_handle = *mut _duckdb_v2_copy_to_bind_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the \"batch size\" phase of a `COPY ...\n TO` statement. The \"batch size\" callback receives this handle and must use it to report how many rows a batch should\n carry."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_copy_to_batch_size_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the \"batch size\" phase of a `COPY ...\n TO` statement. The \"batch size\" callback receives this handle and must use it to report how many rows a batch should\n carry."]
pub type duckdb_v2_copy_to_batch_size_info_handle = *mut _duckdb_v2_copy_to_batch_size_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the per-file \"init\" phase of a `COPY ...\n TO` statement. The \"init\" callback receives this handle and can use it to e.g. read the path of the file being\n written and set up the state shared by every batch written to that file."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_copy_to_init_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the per-file \"init\" phase of a `COPY ...\n TO` statement. The \"init\" callback receives this handle and can use it to e.g. read the path of the file being\n written and set up the state shared by every batch written to that file."]
pub type duckdb_v2_copy_to_init_info_handle = *mut _duckdb_v2_copy_to_init_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the \"batch\" phase of a `COPY ... TO`\n statement. The \"batch\" callback receives this handle and can use it to take ownership of the rows of the batch and to\n set the prepared form of the batch handed to the \"flush\" callback."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_copy_to_batch_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the \"batch\" phase of a `COPY ... TO`\n statement. The \"batch\" callback receives this handle and can use it to take ownership of the rows of the batch and to\n set the prepared form of the batch handed to the \"flush\" callback."]
pub type duckdb_v2_copy_to_batch_info_handle = *mut _duckdb_v2_copy_to_batch_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the \"flush\" phase of a `COPY ... TO`\n statement. The \"flush\" callback receives this handle and can use it to access the prepared batch and write it to the\n output."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_copy_to_flush_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the \"flush\" phase of a `COPY ... TO`\n statement. The \"flush\" callback receives this handle and can use it to access the prepared batch and write it to the\n output."]
pub type duckdb_v2_copy_to_flush_info_handle = *mut _duckdb_v2_copy_to_flush_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the per-file \"finalize\" phase of a `COPY\n ... TO` statement. The \"finalize\" callback receives this handle and can use it to e.g. close the file after every\n batch has been flushed to it."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_copy_to_finalize_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the per-file \"finalize\" phase of a `COPY\n ... TO` statement. The \"finalize\" callback receives this handle and can use it to e.g. close the file after every\n batch has been flushed to it."]
pub type duckdb_v2_copy_to_finalize_info_handle = *mut _duckdb_v2_copy_to_finalize_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function when a `COPY ... TO` statement reports\n statistics about the files it wrote (e.g. with `RETURN_STATS`). The \"statistics\" callback receives this handle and\n uses it to report the statistics of one written file."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_copy_to_statistics_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function when a `COPY ... TO` statement reports\n statistics about the files it wrote (e.g. with `RETURN_STATS`). The \"statistics\" callback receives this handle and\n uses it to report the statistics of one written file."]
pub type duckdb_v2_copy_to_statistics_info_handle = *mut _duckdb_v2_copy_to_statistics_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the query preparation \"bind\" phase of a\n `COPY ... FROM` statement. The \"bind\" callback receives this handle and can use it to e.g. read the path of the file\n to read, inspect the names and types of the columns the target table expects, read the statement's options, hint at\n the number of rows the read will produce and initialize some constant state."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_copy_from_bind_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the query preparation \"bind\" phase of a\n `COPY ... FROM` statement. The \"bind\" callback receives this handle and can use it to e.g. read the path of the file\n to read, inspect the names and types of the columns the target table expects, read the statement's options, hint at\n the number of rows the read will produce and initialize some constant state."]
pub type duckdb_v2_copy_from_bind_info_handle = *mut _duckdb_v2_copy_from_bind_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the global state initialization \"init\n global\" phase of a `COPY ... FROM` statement. The \"init global\" callback receives this handle and can use it to e.g.\n set up the state shared by every thread reading the file, and to declare how many threads may read it."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_copy_from_init_global_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the global state initialization \"init\n global\" phase of a `COPY ... FROM` statement. The \"init global\" callback receives this handle and can use it to e.g.\n set up the state shared by every thread reading the file, and to declare how many threads may read it."]
pub type duckdb_v2_copy_from_init_global_info_handle = *mut _duckdb_v2_copy_from_init_global_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the local state initialization \"init\n local\" phase of a `COPY ... FROM` statement. The \"init local\" callback receives this handle and can use it to e.g.\n set up worker-local state, typically by claiming work from the shared global state."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_copy_from_init_local_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the local state initialization \"init\n local\" phase of a `COPY ... FROM` statement. The \"init local\" callback receives this handle and can use it to e.g.\n set up worker-local state, typically by claiming work from the shared global state."]
pub type duckdb_v2_copy_from_init_local_info_handle = *mut _duckdb_v2_copy_from_init_local_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the execution \"exec\" phase of a `COPY\n ... FROM` statement. The \"exec\" callback receives this handle and can use it to e.g. access the global and local\n state and write the next batch of rows to the output chunk."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_copy_from_exec_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the execution \"exec\" phase of a `COPY\n ... FROM` statement. The \"exec\" callback receives this handle and can use it to e.g. access the global and local\n state and write the next batch of rows to the output chunk."]
pub type duckdb_v2_copy_from_exec_info_handle = *mut _duckdb_v2_copy_from_exec_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the \"progress\" phase of a `COPY ...\n FROM` statement. The \"progress\" callback receives this handle and can use it to report how far the read has advanced."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_copy_from_progress_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a copy function during the \"progress\" phase of a `COPY ...\n FROM` statement. The \"progress\" callback receives this handle and can use it to report how far the read has advanced."]
pub type duckdb_v2_copy_from_progress_info_handle = *mut _duckdb_v2_copy_from_progress_info;
pub type duckdb_v2_copy_to_bind_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_copy_to_bind_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_copy_to_batch_size_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_copy_to_batch_size_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_copy_to_init_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_copy_to_init_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_copy_to_batch_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_copy_to_batch_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_copy_to_flush_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_copy_to_flush_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_copy_to_finalize_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_copy_to_finalize_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_copy_to_statistics_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_copy_to_statistics_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_copy_from_bind_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_copy_from_bind_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_copy_from_init_global_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_copy_from_init_global_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_copy_from_init_local_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_copy_from_init_local_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_copy_from_exec_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_copy_from_exec_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_copy_from_progress_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_copy_from_progress_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
unsafe extern "C" {
    #[doc = " Creates a new copy function through a factory.\n\n A copy function implements a file format for `COPY`: once registered, SQL reaches it with `COPY ... TO 'path' (FORMAT\n name)` and `COPY table FROM 'path' (FORMAT name)`. The function starts out empty: configure it with the setter\n functions (e.g. `duckdb_v2_copy_function_set_name()`, the `copy_to_set_*` callbacks for writing, the\n `copy_from_set_*` callbacks for reading, or both), then make it available with\n `duckdb_v2_connection_register_copy_function()` or `duckdb_v2_extension_register_copy_function()`. The caller owns\n the returned handle and must destroy it with `duckdb_v2_copy_function_destroy()`, also after registration.\n\n The copy function can only be registered on the database the factory belongs to.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create the copy function through.\n @param function On success, receives the newly created copy function. Owned by the caller.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_function_create(
        factory: duckdb_v2_factory_handle,
        function: *mut duckdb_v2_copy_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the name of the copy function.\n\n The name is the format SQL selects the function with: `COPY ... TO 'path' (FORMAT name)` or `COPY table FROM 'path'\n (FORMAT name)`. It is borrowed and copied. Calling this again replaces the previous name. A name must be set before\n registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the name of.\n @param name The name to set. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_function_set_name(
        function: duckdb_v2_copy_function_handle,
        name: *const duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the file extension of the files the copy function writes, without the leading dot, e.g. `parquet`.\n\n DuckDB uses it when it names files itself, e.g. the files of `COPY ... TO 'dir' (PARTITION_BY ...)` or\n `(PER_THREAD_OUTPUT)`. A statement can override it with the `FILE_EXTENSION` option. An extension starting with a dot\n is rejected. The extension is borrowed and copied. Calling this again replaces the previous extension. Optional, but\n without it the names DuckDB gives files end in a bare dot, e.g. `data_0.`.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the file extension of.\n @param extension The extension to set, without the leading dot. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_function_set_file_extension(
        function: duckdb_v2_copy_function_handle,
        extension: *const duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets arbitrary user data on the copy function.\n\n Associates an opaque pointer with the function, retrievable from each callback of either side via its user data\n accessor (e.g. `duckdb_v2_copy_to_bind_get_user_data()`, `duckdb_v2_copy_from_exec_get_user_data()`, etc.). The\n opaque handle bundles the pointer with an optional destructor, invoked when the data is no longer needed.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the user data of.\n @param data Opaque handle bundling the user data pointer plus an optional destructor.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_function_set_user_data(
        function: duckdb_v2_copy_function_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional bind callback of the `COPY ... TO` side.\n\n The bind callback is invoked during query planning for each `COPY ... TO` statement that uses the function. It can\n inspect the names and types of the columns being written, read the statement's options and set \"bind data\" that is\n shared with the other `COPY ... TO` callbacks.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the callback of.\n @param callback The callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_set_bind_callback(
        function: duckdb_v2_copy_function_handle,
        callback: duckdb_v2_copy_to_bind_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional batch size callback of the `COPY ... TO` side.\n\n The batch size callback is invoked during query planning, after the bind callback, for each `COPY ... TO` statement\n that does not set `BATCH_SIZE` itself. It should report how many rows a batch should carry via\n `duckdb_v2_copy_to_batch_size_set_target()`; the engine then cuts the rows being written into batches of that size\n and hands each to the batch callback. Without a batch size from either the statement or the callback, a batch is cut\n for every chunk of rows sunk, i.e. a vector at a time. A batch may still be smaller than the reported size (the last\n one of a file, or when `BATCH_SIZE_BYTES` cuts it first).\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the callback of.\n @param callback The callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_set_batch_size_callback(
        function: duckdb_v2_copy_function_handle,
        callback: duckdb_v2_copy_to_batch_size_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional init callback of the `COPY ... TO` side.\n\n The init callback is invoked once per output file, before any batch destined for that file is prepared. It can read\n the path of the file via `duckdb_v2_copy_to_init_get_file_path()` and set \"init data\" that is shared with the batch,\n flush and finalize callbacks of that file. A statement may write several files, e.g. when its output is partitioned;\n each gets its own init data.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the callback of.\n @param callback The callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_set_init_callback(
        function: duckdb_v2_copy_function_handle,
        callback: duckdb_v2_copy_to_init_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the batch callback of the `COPY ... TO` side.\n\n The batch callback is invoked during query execution with a batch of the rows being written, taken via\n `duckdb_v2_copy_to_batch_take_input()`. It prepares the batch for writing, e.g. by encoding it into the output\n format, and sets \"batch data\" via `duckdb_v2_copy_to_batch_set_batch_data()` that is handed to the flush callback.\n Batches may be prepared by several threads at once, so the callback must synchronize its own access to the init data.\n A batch callback must be set for the `COPY ... TO` side to be registered.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the callback of.\n @param callback The callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_set_batch_callback(
        function: duckdb_v2_copy_function_handle,
        callback: duckdb_v2_copy_to_batch_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the flush callback of the `COPY ... TO` side.\n\n The flush callback is invoked once per prepared batch to write its batch data, available via\n `duckdb_v2_copy_to_flush_get_batch_data()`, to the output. Flushes of the same file never run concurrently. A flush\n callback must be set for the `COPY ... TO` side to be registered.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the callback of.\n @param callback The callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_set_flush_callback(
        function: duckdb_v2_copy_function_handle,
        callback: duckdb_v2_copy_to_flush_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional finalize callback of the `COPY ... TO` side.\n\n The finalize callback is invoked once per output file after the last batch destined for that file has been flushed.\n It can e.g. write a footer and close the file.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the callback of.\n @param callback The callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_set_finalize_callback(
        function: duckdb_v2_copy_function_handle,
        callback: duckdb_v2_copy_to_finalize_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_copy_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_bind_get_user_data(
        info: duckdb_v2_copy_to_bind_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the function's \"bind data\" from the bind callback.\n\n The bind data is stored with the bound statement and retrievable from the other callbacks of the same side. The\n opaque handle bundles the pointer with an optional destructor, invoked when the bind data is no longer needed, and an\n optional equality callback used when comparing two bound statements; without one, pointer equality is used.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param data Opaque handle bundling the bind data pointer plus optional destructor and equality callbacks.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_bind_set_bind_data(
        info: duckdb_v2_copy_to_bind_info_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the path the `COPY ... TO` statement writes to, as written in the statement.\n\n This is the target before the engine's own rewrites: the path of each file actually being written, e.g. a temporary\n name or a per-partition path, is only known to the init callback via `duckdb_v2_copy_to_init_get_file_path()`. The\n path is borrowed and valid only for the duration of the callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param path Receives a borrowed view of the file path. Valid only for the duration of the callback.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_bind_get_file_path(
        info: duckdb_v2_copy_to_bind_info_handle,
        path: *mut duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of columns being written, i.e. the columns of the rows every batch carries.\n\n Valid indices for `duckdb_v2_copy_to_bind_get_column_type()` and `duckdb_v2_copy_to_bind_get_column_name()` are [0,\n count).\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param count Receives the number of columns.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_bind_get_column_count(
        info: duckdb_v2_copy_to_bind_info_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the type of the column at the given index.\n\n Fails if the index is out of bounds. The returned type is owned by the caller and must be destroyed via\n `duckdb_v2_logical_type_destroy()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param index The index of the column to get the type of.\n @param type Receives the column type. Owned by the caller; destroy via `duckdb_v2_logical_type_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_bind_get_column_type(
        info: duckdb_v2_copy_to_bind_info_handle,
        index: idx_t,
        type_: *mut duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the name of the column at the given index.\n\n Fails if the index is out of bounds. The name is borrowed and valid only for the duration of the callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param index The index of the column to get the name of.\n @param name Receives a borrowed view of the column name. Valid only for the duration of the callback.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_bind_get_column_name(
        info: duckdb_v2_copy_to_bind_info_handle,
        index: idx_t,
        name: *mut duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of options the `COPY` statement passed to the function.\n\n The engine's own options (e.g. `USE_TMP_FILE` or `BATCH_SIZE`) are handled before the function sees the statement and\n are not included. Valid indices for `duckdb_v2_copy_to_bind_get_option_name()` and\n `duckdb_v2_copy_to_bind_get_option_value()` are [0, count). The options are ordered by name.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param count Receives the number of options.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_bind_get_option_count(
        info: duckdb_v2_copy_to_bind_info_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the name of the option at the given index.\n\n Option names are SQL identifiers, matched case-insensitively. Fails if the index is out of bounds. The name is\n borrowed and valid only for the duration of the callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param index The index of the option to get the name of.\n @param name Receives a borrowed view of the option name. Valid only for the duration of the callback.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_bind_get_option_name(
        info: duckdb_v2_copy_to_bind_info_handle,
        index: idx_t,
        name: *mut duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the value of the option at the given index.\n\n An option written with a single value (e.g. `DELIM ','`) yields that value. An option written as a bare name (e.g.\n `HEADER`) yields the BOOLEAN `true`. An option written with a parenthesized list (e.g. `KEYS (a, b)`) yields a tuple:\n an unnamed STRUCT with one field per element, in order. Fails if the index is out of bounds. The returned value is\n owned by the caller and must be destroyed via `duckdb_v2_value_destroy()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param index The index of the option.\n @param value Receives the option's value. Owned by the caller; destroy via `duckdb_v2_value_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_bind_get_option_value(
        info: duckdb_v2_copy_to_bind_info_handle,
        index: idx_t,
        value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_copy_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The batch size info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_batch_size_get_user_data(
        info: duckdb_v2_copy_to_batch_size_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's `COPY ... TO` bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The batch size info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_batch_size_get_bind_data(
        info: duckdb_v2_copy_to_batch_size_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the number of rows a batch should carry, as the target the engine cuts batches at. The batch size callback must\n set this to a value greater than 0; the statement fails otherwise. DuckDB defines the `BATCH_SIZE` on omission of\n calling the function.\n\n history:\n - unstable: v2.0.0\n\n @param info The batch size info handle.\n @param rows The number of rows a batch should carry. Must be greater than 0.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_batch_size_set_target(
        info: duckdb_v2_copy_to_batch_size_info_handle,
        rows: idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_copy_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The init info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_init_get_user_data(
        info: duckdb_v2_copy_to_init_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's `COPY ... TO` bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The init info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_init_get_bind_data(
        info: duckdb_v2_copy_to_init_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the path of the file the init callback is preparing.\n\n This is the path the batches of this file are to be written to, after the engine has applied its own rewrites (e.g. a\n temporary name while the file is being written, or a per-partition path). The path is borrowed and valid only for the\n duration of the callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The init info handle.\n @param path Receives a borrowed view of the file path. Valid only for the duration of the callback.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_init_get_file_path(
        info: duckdb_v2_copy_to_init_info_handle,
        path: *mut duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the function's \"init data\" from the init callback.\n\n The init data lives for the duration of the file being written and is retrievable from the batch, flush and finalize\n callbacks of that file. Batches may be prepared by several threads at once, so the function must synchronize its own\n access to it from the batch callback. The opaque handle bundles the pointer with an optional destructor, invoked when\n the file is done with the data.\n\n history:\n - unstable: v2.0.0\n\n @param info The init info handle.\n @param data Opaque handle bundling the init data pointer plus an optional destructor.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_init_set_init_data(
        info: duckdb_v2_copy_to_init_info_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_copy_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The batch info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_batch_get_user_data(
        info: duckdb_v2_copy_to_batch_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's `COPY ... TO` bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The batch info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_batch_get_bind_data(
        info: duckdb_v2_copy_to_batch_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the init data set by the function's `COPY ... TO` init callback for the file this batch belongs to.\n\n history:\n - unstable: v2.0.0\n\n @param info The batch info handle.\n @param data Receives the init data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_batch_get_init_data(
        info: duckdb_v2_copy_to_batch_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Takes ownership of the rows of the batch to prepare.\n\n The collection holds one column per column reported by `duckdb_v2_copy_to_bind_get_column_count()`, in the same\n order, and can be scanned with `duckdb_v2_column_data_collection_scan()`. The batch can only be taken once: a second\n call fails. Once taken, the caller owns the collection and must destroy it via\n `duckdb_v2_column_data_collection_destroy()`, e.g. by keeping it as the batch data with that destructor. A batch that\n is never taken is destroyed when the callback returns.\n\n history:\n - unstable: v2.0.0\n\n @param info The batch info handle.\n @param collection Receives the collection holding the rows of the batch. Owned by the caller; destroy via\n `duckdb_v2_column_data_collection_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_batch_take_input(
        info: duckdb_v2_copy_to_batch_info_handle,
        collection: *mut duckdb_v2_column_data_collection_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the prepared \"batch data\" from the batch callback.\n\n The batch data is the prepared form of the batch and is handed to the flush callback via\n `duckdb_v2_copy_to_flush_get_batch_data()`. The opaque handle bundles the pointer with an optional destructor,\n invoked once the batch has been flushed.\n\n history:\n - unstable: v2.0.0\n\n @param info The batch info handle.\n @param data Opaque handle bundling the batch data pointer plus an optional destructor.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_batch_set_batch_data(
        info: duckdb_v2_copy_to_batch_info_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_copy_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The flush info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_flush_get_user_data(
        info: duckdb_v2_copy_to_flush_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's `COPY ... TO` bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The flush info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_flush_get_bind_data(
        info: duckdb_v2_copy_to_flush_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the init data set by the function's `COPY ... TO` init callback for the file this batch belongs to.\n\n history:\n - unstable: v2.0.0\n\n @param info The flush info handle.\n @param data Receives the init data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_flush_get_init_data(
        info: duckdb_v2_copy_to_flush_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the batch data set by the function's batch callback for the batch being flushed.\n\n history:\n - unstable: v2.0.0\n\n @param info The flush info handle.\n @param data Receives the batch data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_flush_get_batch_data(
        info: duckdb_v2_copy_to_flush_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_copy_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The finalize info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_finalize_get_user_data(
        info: duckdb_v2_copy_to_finalize_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's `COPY ... TO` bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The finalize info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_finalize_get_bind_data(
        info: duckdb_v2_copy_to_finalize_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the init data set by the function's `COPY ... TO` init callback for the file being finalized.\n\n history:\n - unstable: v2.0.0\n\n @param info The finalize info handle.\n @param data Receives the init data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_finalize_get_init_data(
        info: duckdb_v2_copy_to_finalize_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the bind callback of the `COPY ... FROM` side.\n\n The bind callback is invoked during query planning for each `COPY ... FROM` statement that uses the function. It can\n read the path of the file to read and the statement's options, inspect the names and types of the columns the target\n table expects, hint at the number of rows the read will produce, and set \"bind data\" that is shared with the other\n `COPY ... FROM` callbacks. The columns are fixed by the target table: the function must produce them as they are. A\n bind callback must be set for the `COPY ... FROM` side to be registered.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the callback of.\n @param callback The callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_set_bind_callback(
        function: duckdb_v2_copy_function_handle,
        callback: duckdb_v2_copy_from_bind_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional global init callback of the `COPY ... FROM` side.\n\n The global init callback is invoked once per statement, at the start of execution. It can set \"global state\" shared\n by every thread reading the file, and declare how many threads may read it in parallel via\n `duckdb_v2_copy_from_init_global_set_max_threads()`.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the callback of.\n @param callback The callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_set_init_global_callback(
        function: duckdb_v2_copy_function_handle,
        callback: duckdb_v2_copy_from_init_global_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional local init callback of the `COPY ... FROM` side.\n\n The local init callback is invoked once per thread that will read the file. It can set worker-local \"local state\",\n retrievable from the exec callback, typically derived from the shared global state.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the callback of.\n @param callback The callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_set_init_local_callback(
        function: duckdb_v2_copy_function_handle,
        callback: duckdb_v2_copy_from_init_local_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the exec callback of the `COPY ... FROM` side.\n\n The exec callback implements the read: it is invoked repeatedly during query execution and writes the next batch of\n rows to the output chunk, until it produces an empty batch to signal the end of the read. An exec callback must be\n set for the `COPY ... FROM` side to be registered.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the callback of.\n @param callback The callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_set_exec_callback(
        function: duckdb_v2_copy_function_handle,
        callback: duckdb_v2_copy_from_exec_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional progress callback of the `COPY ... FROM` side.\n\n The progress callback is invoked on demand during execution to report how far the read has advanced, which the engine\n surfaces as the query's progress. It is invoked concurrently with the exec callback, so it must read the global state\n in a thread-safe way.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the callback of.\n @param callback The callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_set_progress_callback(
        function: duckdb_v2_copy_function_handle,
        callback: duckdb_v2_copy_from_progress_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_copy_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_bind_get_user_data(
        info: duckdb_v2_copy_from_bind_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the function's \"bind data\" from the bind callback.\n\n The bind data is stored with the bound statement and retrievable from the other callbacks of the same side. The\n opaque handle bundles the pointer with an optional destructor, invoked when the bind data is no longer needed, and an\n optional equality callback used when comparing two bound statements; without one, pointer equality is used.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param data Opaque handle bundling the bind data pointer plus optional destructor and equality callbacks.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_bind_set_bind_data(
        info: duckdb_v2_copy_from_bind_info_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the path the `COPY ... FROM` statement reads from, as written in the statement.\n\n The engine does not expand globs or check that the file exists; both are left to the function. The path is borrowed\n and valid only for the duration of the callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param path Receives a borrowed view of the file path. Valid only for the duration of the callback.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_bind_get_file_path(
        info: duckdb_v2_copy_from_bind_info_handle,
        path: *mut duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of columns the target table expects, i.e. the columns every batch the exec callback produces must\n carry, in this order.\n\n Valid indices for `duckdb_v2_copy_from_bind_get_column_type()` and `duckdb_v2_copy_from_bind_get_column_name()` are\n [0, count).\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param count Receives the number of columns.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_bind_get_column_count(
        info: duckdb_v2_copy_from_bind_info_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the type of the column at the given index.\n\n Fails if the index is out of bounds. The returned type is owned by the caller and must be destroyed via\n `duckdb_v2_logical_type_destroy()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param index The index of the column to get the type of.\n @param type Receives the column type. Owned by the caller; destroy via `duckdb_v2_logical_type_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_bind_get_column_type(
        info: duckdb_v2_copy_from_bind_info_handle,
        index: idx_t,
        type_: *mut duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the name of the column at the given index.\n\n Fails if the index is out of bounds. The name is borrowed and valid only for the duration of the callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param index The index of the column to get the name of.\n @param name Receives a borrowed view of the column name. Valid only for the duration of the callback.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_bind_get_column_name(
        info: duckdb_v2_copy_from_bind_info_handle,
        index: idx_t,
        name: *mut duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of options the `COPY` statement passed to the function.\n\n Every option other than `FORMAT` is included. Valid indices for `duckdb_v2_copy_from_bind_get_option_name()` and\n `duckdb_v2_copy_from_bind_get_option_value()` are [0, count). The options are ordered by name.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param count Receives the number of options.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_bind_get_option_count(
        info: duckdb_v2_copy_from_bind_info_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the name of the option at the given index.\n\n Option names are SQL identifiers, matched case-insensitively. Fails if the index is out of bounds. The name is\n borrowed and valid only for the duration of the callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param index The index of the option to get the name of.\n @param name Receives a borrowed view of the option name. Valid only for the duration of the callback.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_bind_get_option_name(
        info: duckdb_v2_copy_from_bind_info_handle,
        index: idx_t,
        name: *mut duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the value of the option at the given index.\n\n An option written with a single value (e.g. `DELIM ','`) yields that value. An option written as a bare name (e.g.\n `HEADER`) yields the BOOLEAN `true`. An option written with a parenthesized list (e.g. `KEYS (a, b)`) yields a tuple:\n an unnamed STRUCT with one field per element, in order. Fails if the index is out of bounds. The returned value is\n owned by the caller and must be destroyed via `duckdb_v2_value_destroy()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param index The index of the option.\n @param value Receives the option's value. Owned by the caller; destroy via `duckdb_v2_value_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_bind_get_option_value(
        info: duckdb_v2_copy_from_bind_info_handle,
        index: idx_t,
        value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reports the estimated number of rows the read will produce.\n\n The estimate is a hint for the optimizer, not a limit: producing a different number of rows is not an error. Without\n it, the optimizer falls back on its own defaults.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param cardinality The estimated number of rows.\n @param is_exact Whether the estimate is exact, which also makes it an upper bound on the row count.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_bind_set_cardinality(
        info: duckdb_v2_copy_from_bind_info_handle,
        cardinality: idx_t,
        is_exact: bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_copy_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The global init info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_init_global_get_user_data(
        info: duckdb_v2_copy_from_init_global_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's `COPY ... FROM` bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The global init info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_init_global_get_bind_data(
        info: duckdb_v2_copy_from_init_global_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the function's \"global state\" from the global init callback.\n\n The global state lives for the duration of the read and is retrievable from the local init, exec and progress\n callbacks. Every thread reading the file shares it, so the function must synchronize its own access to it. The opaque\n handle bundles the pointer with an optional destructor, invoked when the read is done with the state.\n\n history:\n - unstable: v2.0.0\n\n @param info The global init info handle.\n @param data Opaque handle bundling the global state pointer plus an optional destructor.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_init_global_set_global_state(
        info: duckdb_v2_copy_from_init_global_info_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets how many threads may read the file in parallel.\n\n Defaults to 1, a single-threaded read. The engine creates at most this many local states, and therefore runs at most\n this many exec callbacks concurrently. It is an upper bound, not a request: the engine may use fewer threads.\n\n history:\n - unstable: v2.0.0\n\n @param info The global init info handle.\n @param max_threads The maximum number of threads. Must be at least 1.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_init_global_set_max_threads(
        info: duckdb_v2_copy_from_init_global_info_handle,
        max_threads: idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_copy_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The local init info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_init_local_get_user_data(
        info: duckdb_v2_copy_from_init_local_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's `COPY ... FROM` bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The local init info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_init_local_get_bind_data(
        info: duckdb_v2_copy_from_init_local_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the global state set by the function's global init callback.\n\n Shared with every other thread reading the file; access to it must be synchronized by the function.\n\n history:\n - unstable: v2.0.0\n\n @param info The local init info handle.\n @param data Receives the global state pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_init_local_get_global_state(
        info: duckdb_v2_copy_from_init_local_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the function's worker-local \"local state\" from the local init callback.\n\n The local state is associated with the executing thread for the duration of the read and retrievable from the exec\n callback via `duckdb_v2_copy_from_exec_get_local_state()`. No other thread observes it, so it needs no\n synchronization. The opaque handle bundles the pointer with an optional destructor, invoked when the local state is\n no longer needed.\n\n history:\n - unstable: v2.0.0\n\n @param info The local init info handle.\n @param data Opaque handle bundling the local state pointer plus an optional destructor.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_init_local_set_local_state(
        info: duckdb_v2_copy_from_init_local_info_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_copy_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_exec_get_user_data(
        info: duckdb_v2_copy_from_exec_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's `COPY ... FROM` bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_exec_get_bind_data(
        info: duckdb_v2_copy_from_exec_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the global state set by the function's global init callback.\n\n Shared with every other thread reading the file; access to it must be synchronized by the function.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param data Receives the global state pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_exec_get_global_state(
        info: duckdb_v2_copy_from_exec_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the worker-local local state set by the function's local init callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param data Receives the local state pointer for the executing thread, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_exec_get_local_state(
        info: duckdb_v2_copy_from_exec_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the output chunk the exec callback must write the next batch of rows into.\n\n The chunk holds one vector per column reported by `duckdb_v2_copy_from_bind_get_column_count()`, in the same order;\n reach them with `duckdb_v2_data_chunk_get_vector()`. The chunk starts out empty on every invocation: write the rows,\n then declare how many there are with `duckdb_v2_vector_set_size()` on the first vector, which the engine takes as the\n batch's row count and propagates to the other vectors. Producing an empty batch signals the end of the read, after\n which the callback is not invoked again on that thread. Borrowed; valid only for the duration of the callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param chunk Receives the borrowed output chunk to write into.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_exec_get_output_chunk(
        info: duckdb_v2_copy_from_exec_info_handle,
        chunk: *mut duckdb_v2_data_chunk_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_copy_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The progress info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_progress_get_user_data(
        info: duckdb_v2_copy_from_progress_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's `COPY ... FROM` bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The progress info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_progress_get_bind_data(
        info: duckdb_v2_copy_from_progress_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the global state set by the function's global init callback.\n\n The progress callback runs concurrently with the exec callbacks reading the file, so it must read the global state in\n a thread-safe way.\n\n history:\n - unstable: v2.0.0\n\n @param info The progress info handle.\n @param data Receives the global state pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_progress_get_global_state(
        info: duckdb_v2_copy_from_progress_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reports how far the read has advanced.\n\n A fraction between 0.0 (nothing read yet) and 1.0 (done); values outside that range are clamped. A progress callback\n that returns without calling this reports no progress.\n\n history:\n - unstable: v2.0.0\n\n @param info The progress info handle.\n @param progress The fraction of the read that is complete, in [0.0, 1.0].\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_from_progress_set_progress(
        info: duckdb_v2_copy_from_progress_info_handle,
        progress: f64,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the copy function, making it available as a `COPY` format.\n\n The function is registered on the connection's database, visible to every connection, in the connection's\n transaction: inside an explicit transaction, it is invisible to other connections until the transaction commits, and\n a rollback undoes it. Registration requires a name and at least one configured side: a `COPY ... TO` side needs its\n batch and flush callbacks, a `COPY ... FROM` side needs its bind and exec callbacks. A statement in a direction the\n function does not implement fails with an error. The copy function must have been created through a factory of the\n same database. The caller still owns the handle after registration and must destroy it with\n `duckdb_v2_copy_function_destroy()`, which does not affect the registered function.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection to register on.\n @param function The copy function to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_register_copy_function(
        conn: duckdb_v2_connection_handle,
        function: duckdb_v2_copy_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the copy function, making it available as a `COPY` format.\n\n The function is registered on the loading extension's database and attributed to the extension. Use this from the\n extension's load callback. Registration requires a name and at least one configured side: a `COPY ... TO` side needs\n its batch and flush callbacks, a `COPY ... FROM` side needs its bind and exec callbacks. A statement in a direction\n the function does not implement fails with an error. The copy function must have been created through a factory of\n the same database. The caller still owns the handle after registration and must destroy it with\n `duckdb_v2_copy_function_destroy()`, which does not affect the registered function.\n\n history:\n - unstable: v2.0.0\n\n @param extension The loading extension.\n @param function The copy function to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_extension_register_copy_function(
        extension: duckdb_v2_extension_handle,
        function: duckdb_v2_copy_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the copy function, releasing its resources.\n\n Null-safe: passing a null pointer or null handle is a no-op. The handle is set to null on return to prevent\n double-destruction. Destroying the handle after registration does not affect the registered function.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_function_destroy(function: *mut duckdb_v2_copy_function_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional statistics callback of the `COPY ... TO` side.\n\n The statistics callback reports statistics about a written file, such as the number of rows and bytes it holds, which\n `COPY ... TO` returns when the statement asks for them with `RETURN_STATS`. It is invoked once per output file, after\n the finalize callback of that file, and only when the statement asks for the statistics. Without a statistics\n callback, `RETURN_STATS` is rejected for the function.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the callback of.\n @param callback The callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_set_statistics_callback(
        function: duckdb_v2_copy_function_handle,
        callback: duckdb_v2_copy_to_statistics_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set on the copy function via `duckdb_v2_copy_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The statistics info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_statistics_get_user_data(
        info: duckdb_v2_copy_to_statistics_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's `COPY ... TO` bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The statistics info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_statistics_get_bind_data(
        info: duckdb_v2_copy_to_statistics_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the init data set by the function's `COPY ... TO` init callback for the file being reported.\n\n history:\n - unstable: v2.0.0\n\n @param info The statistics info handle.\n @param data Receives the init data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_statistics_get_init_data(
        info: duckdb_v2_copy_to_statistics_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reports how many rows were written to the file. Reported as 0 when the callback does not set it.\n\n history:\n - unstable: v2.0.0\n\n @param info The statistics info handle.\n @param row_count The number of rows written to the file.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_statistics_set_row_count(
        info: duckdb_v2_copy_to_statistics_info_handle,
        row_count: idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reports the size of the written file in bytes. Reported as 0 when the callback does not set it.\n\n history:\n - unstable: v2.0.0\n\n @param info The statistics info handle.\n @param file_size_bytes The size of the file in bytes.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_copy_to_statistics_set_file_size(
        info: duckdb_v2_copy_to_statistics_info_handle,
        file_size_bytes: idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
#[doc = " An owned opaque handle to a custom option being built. Created with `duckdb_v2_custom_option_create()`, configured\n with the setter functions (e.g. `duckdb_v2_custom_option_set_name()`, `duckdb_v2_custom_option_set_type()`, etc.),\n made available with `duckdb_v2_connection_register_custom_option()` or\n `duckdb_v2_extension_register_custom_option()`, and destroyed with `duckdb_v2_custom_option_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_custom_option {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned opaque handle to a custom option being built. Created with `duckdb_v2_custom_option_create()`, configured\n with the setter functions (e.g. `duckdb_v2_custom_option_set_name()`, `duckdb_v2_custom_option_set_type()`, etc.),\n made available with `duckdb_v2_connection_register_custom_option()` or\n `duckdb_v2_extension_register_custom_option()`, and destroyed with `duckdb_v2_custom_option_destroy()`."]
pub type duckdb_v2_custom_option_handle = *mut _duckdb_v2_custom_option;
#[doc = " A borrowed opaque handle to an update of a custom option, received by its update callback. It gives access to the new\n value, the scope it is written at and the user data, and can replace the value."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_custom_option_update_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to an update of a custom option, received by its update callback. It gives access to the new\n value, the scope it is written at and the user data, and can replace the value."]
pub type duckdb_v2_custom_option_update_info_handle = *mut _duckdb_v2_custom_option_update_info;
pub type duckdb_v2_custom_option_update_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_custom_option_update_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
unsafe extern "C" {
    #[doc = " Creates a new custom option through a factory.\n\n The option starts out empty: configure it with the setter functions, then make it available with\n `duckdb_v2_connection_register_custom_option()` or `duckdb_v2_extension_register_custom_option()`. The caller owns\n the returned handle and must destroy it with `duckdb_v2_custom_option_destroy()`, also after registration.\n\n The custom option can only be registered on the instance the factory belongs to.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create the custom option through.\n @param option On success, receives the newly created custom option. Owned by the caller.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_option_create(
        factory: duckdb_v2_factory_handle,
        option: *mut duckdb_v2_custom_option_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the name of the custom option, as `SET` and the config functions refer to it.\n\n The name is borrowed and copied. Calling this again replaces the previous name. A name must be set before\n registration.\n\n history:\n - unstable: v2.0.0\n\n @param option The option to set the name of.\n @param name The name to set. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_option_set_name(
        option: duckdb_v2_custom_option_handle,
        name: *const duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the type of the custom option. Every value written to the option is cast to it, as SQL `SET` does.\n\n The type is borrowed and copied. Optional when a default value is set, whose type the option then takes.\n\n history:\n - unstable: v2.0.0\n\n @param option The option to set the type of.\n @param type The type to set. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_option_set_type(
        option: duckdb_v2_custom_option_handle,
        type_: duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the default value of the custom option: its value until it is set, and the value `RESET` restores.\n\n The value is borrowed and copied, and cast to the option's type at registration, which fails when the cast does.\n Without a default value the option reads as NULL until it is set.\n\n history:\n - unstable: v2.0.0\n\n @param option The option to set the default value of.\n @param value The default value. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_option_set_default_value(
        option: duckdb_v2_custom_option_handle,
        value: duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the description of the custom option, as `duckdb_v2_option_get_description()` and `duckdb_settings()` report it.\n\n The description is borrowed and copied. Calling this again replaces the previous description.\n\n history:\n - unstable: v2.0.0\n\n @param option The option to set the description of.\n @param description The description to set. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_option_set_description(
        option: duckdb_v2_custom_option_handle,
        description: *const duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the scope a write at `SETTING_SCOPE_DEFAULT` goes to, like SQL `SET name = value`.\n\n Must be GLOBAL or SESSION, and a scope the option supports. Defaults to SESSION, or to GLOBAL when the option does\n not support SESSION.\n\n history:\n - unstable: v2.0.0\n\n @param option The option to set the default scope of.\n @param scope The default scope, GLOBAL or SESSION.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_option_set_default_scope(
        option: duckdb_v2_custom_option_handle,
        scope: DUCKDB_V2_SETTING_SCOPE,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets whether the custom option can be written at a scope, as `duckdb_v2_option_supports_scope()` reports it.\n\n A custom option supports both GLOBAL and SESSION unless told otherwise. A write at a scope it does not support fails,\n from SQL as from `duckdb_v2_config_set_option_value()`. Registration fails when the option supports neither scope.\n\n history:\n - unstable: v2.0.0\n\n @param option The option to configure.\n @param scope The scope, GLOBAL or SESSION.\n @param supported Whether the option can be written at the scope.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_option_set_supports_scope(
        option: duckdb_v2_custom_option_handle,
        scope: DUCKDB_V2_SETTING_SCOPE,
        supported: bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets arbitrary user data on the custom option.\n\n Associates an opaque pointer with the option, retrievable from the update callback via\n `duckdb_v2_custom_option_update_get_user_data()`. The opaque handle bundles the pointer with an optional destructor,\n invoked when the data is no longer needed: once the custom option handle is destroyed and, if it was registered, the\n instance is too.\n\n history:\n - unstable: v2.0.0\n\n @param option The option to set the user data of.\n @param data Opaque handle bundling the user data pointer plus an optional destructor.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_option_set_user_data(
        option: duckdb_v2_custom_option_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional update callback of the custom option.\n\n The callback is invoked whenever the option is set or reset, from SQL as from `duckdb_v2_config_set_option_value()`,\n after the new value is cast to the option's type and before it is stored. It may replace the value with\n `duckdb_v2_custom_option_update_set_value()`, or refuse it by reporting an error. It is not invoked for the default\n value at registration, nor for a value given to the instance at startup. The callback must not write options itself.\n\n history:\n - unstable: v2.0.0\n\n @param option The option to set the update callback of.\n @param callback The update callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_option_set_update_callback(
        option: duckdb_v2_custom_option_handle,
        callback: duckdb_v2_custom_option_update_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_custom_option_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The update info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_option_update_get_user_data(
        info: duckdb_v2_custom_option_update_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the value the option is updated to, already cast to the option's type. On a reset this is the default\n value, which may be NULL. The returned value is owned by the caller and must be destroyed via\n `duckdb_v2_value_destroy()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The update info handle.\n @param value Receives the new value. Owned by the caller; destroy via `duckdb_v2_value_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_option_update_get_value(
        info: duckdb_v2_custom_option_update_info_handle,
        value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Replaces the value the option is updated to, e.g. to normalize it. The value is borrowed and copied, and cast to the\n option's type, which fails when the cast does.\n\n history:\n - unstable: v2.0.0\n\n @param info The update info handle.\n @param value The value to store instead. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_option_update_set_value(
        info: duckdb_v2_custom_option_update_info_handle,
        value: duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the scope the value is written at: GLOBAL or SESSION, a DEFAULT write already resolved to the option's\n default scope.\n\n history:\n - unstable: v2.0.0\n\n @param info The update info handle.\n @param scope Receives the scope.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_option_update_get_scope(
        info: duckdb_v2_custom_option_update_info_handle,
        scope: *mut DUCKDB_V2_SETTING_SCOPE,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves whether the update is a reset to the default value, like SQL `RESET`.\n\n history:\n - unstable: v2.0.0\n\n @param info The update info handle.\n @param is_reset Receives whether the update is a reset.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_option_update_is_reset(
        info: duckdb_v2_custom_option_update_info_handle,
        is_reset: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the custom option on the connection's instance, visible to every connection.\n\n Registration is not transactional: it takes effect at once, also inside an explicit transaction, and a rollback does\n not undo it. Registration requires a name and a type, or a default value to take the type from, and fails when an\n option of the same name already exists. A value given for the option at startup is picked up. The custom option must\n have been created through a factory of the same instance. The caller still owns the handle after registration and\n must destroy it with `duckdb_v2_custom_option_destroy()`, which does not affect the registered option.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection to register on.\n @param option The custom option to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_register_custom_option(
        conn: duckdb_v2_connection_handle,
        option: duckdb_v2_custom_option_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the custom option on the loading extension's instance, visible to every connection.\n\n Use this from the extension's load callback. Registration is not transactional, requires a name and a type, or a\n default value to take the type from, and fails when an option of the same name already exists. A value given for the\n option at startup is picked up. The custom option must have been created through a factory of the same instance. The\n caller still owns the handle after registration and must destroy it with `duckdb_v2_custom_option_destroy()`, which\n does not affect the registered option.\n\n history:\n - unstable: v2.0.0\n\n @param extension The loading extension.\n @param option The custom option to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_extension_register_custom_option(
        extension: duckdb_v2_extension_handle,
        option: duckdb_v2_custom_option_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the custom option, releasing its resources.\n\n Null-safe: passing a null pointer or null handle is a no-op. The handle is set to null on return to prevent\n double-destruction. Destroying the handle after registration does not affect the registered option.\n\n history:\n - unstable: v2.0.0\n\n @param option The option to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_custom_option_destroy(option: *mut duckdb_v2_custom_option_handle) -> DUCKDB_V2_ERROR;
}
#[repr(u32)]
#[non_exhaustive]
#[doc = " The type of a bound expression node. The values mirror the engine's own expression types, restricted to the node\n types a filter predicate can contain; every other node type is reported as `EXPRESSION_TYPE_INVALID`.\n\n Comparisons, `BETWEEN` and casts are regular scalar function calls once bound: they have the function's children and\n name, and only their type tells them apart from any other function. A `CAST` therefore has one child, the value being\n cast, and its target type is the node's return type."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_EXPRESSION_TYPE {
    #[doc = "! A node type this API does not model. Its children can still be walked."]
    DUCKDB_V2_EXPRESSION_TYPE_INVALID = 0,
    #[doc = " A cast. One child; the target type is the node's return type and `duckdb_v2_expression_cast_get_mode()` tells a\n `TRY_CAST` apart."]
    DUCKDB_V2_EXPRESSION_TYPE_OPERATOR_CAST = 12,
    #[doc = "! Logical `NOT`. One child."]
    DUCKDB_V2_EXPRESSION_TYPE_OPERATOR_NOT = 13,
    #[doc = "! `IS NULL`. One child."]
    DUCKDB_V2_EXPRESSION_TYPE_OPERATOR_IS_NULL = 14,
    #[doc = "! `IS NOT NULL`. One child."]
    DUCKDB_V2_EXPRESSION_TYPE_OPERATOR_IS_NOT_NULL = 15,
    #[doc = "! `=`. Two children."]
    DUCKDB_V2_EXPRESSION_TYPE_COMPARE_EQUAL = 25,
    #[doc = "! `<>`. Two children."]
    DUCKDB_V2_EXPRESSION_TYPE_COMPARE_NOTEQUAL = 26,
    #[doc = "! `<`. Two children."]
    DUCKDB_V2_EXPRESSION_TYPE_COMPARE_LESSTHAN = 27,
    #[doc = "! `>`. Two children."]
    DUCKDB_V2_EXPRESSION_TYPE_COMPARE_GREATERTHAN = 28,
    #[doc = "! `<=`. Two children."]
    DUCKDB_V2_EXPRESSION_TYPE_COMPARE_LESSTHANOREQUALTO = 29,
    #[doc = "! `>=`. Two children."]
    DUCKDB_V2_EXPRESSION_TYPE_COMPARE_GREATERTHANOREQUALTO = 30,
    #[doc = "! `IN`. The first child is the value tested, the remaining children are the candidates."]
    DUCKDB_V2_EXPRESSION_TYPE_COMPARE_IN = 35,
    #[doc = "! `NOT IN`. The first child is the value tested, the remaining children are the candidates."]
    DUCKDB_V2_EXPRESSION_TYPE_COMPARE_NOT_IN = 36,
    #[doc = "! `IS DISTINCT FROM`. Two children."]
    DUCKDB_V2_EXPRESSION_TYPE_COMPARE_DISTINCT_FROM = 37,
    #[doc = "! `BETWEEN`. Three children: the value tested, the lower bound and the upper bound."]
    DUCKDB_V2_EXPRESSION_TYPE_COMPARE_BETWEEN = 38,
    #[doc = "! `IS NOT DISTINCT FROM`. Two children."]
    DUCKDB_V2_EXPRESSION_TYPE_COMPARE_NOT_DISTINCT_FROM = 40,
    #[doc = "! Logical `AND`. Two or more children."]
    DUCKDB_V2_EXPRESSION_TYPE_CONJUNCTION_AND = 50,
    #[doc = "! Logical `OR`. Two or more children."]
    DUCKDB_V2_EXPRESSION_TYPE_CONJUNCTION_OR = 51,
    #[doc = "! A constant. No children; read it with `duckdb_v2_expression_constant_get_value()`."]
    DUCKDB_V2_EXPRESSION_TYPE_VALUE_CONSTANT = 75,
    #[doc = "! A prepared statement parameter whose value is not known yet. No children."]
    DUCKDB_V2_EXPRESSION_TYPE_VALUE_PARAMETER = 76,
    #[doc = " A call to a scalar function other than the ones listed above. The children are its arguments; read the name with\n `duckdb_v2_expression_function_get_name()`."]
    DUCKDB_V2_EXPRESSION_TYPE_BOUND_FUNCTION = 141,
    #[doc = "! A `CASE` expression. The children are each `WHEN` condition followed by its `THEN` result, then the `ELSE`\n! result."]
    DUCKDB_V2_EXPRESSION_TYPE_CASE_EXPR = 150,
    #[doc = "! `COALESCE`. One or more children."]
    DUCKDB_V2_EXPRESSION_TYPE_OPERATOR_COALESCE = 152,
    #[doc = "! A reference to a column. No children; read it with `duckdb_v2_expression_column_ref_get_index()`."]
    DUCKDB_V2_EXPRESSION_TYPE_BOUND_COLUMN_REF = 228,
    #[doc = "! A reference to a column. No children; read it with `duckdb_v2_expression_column_ref_get_index()`."]
    DUCKDB_V2_EXPRESSION_TYPE_MAX_ENUM = 2147483647,
}
#[doc = " A borrowed opaque handle to a node of a bound expression tree. Read-only and owned by the engine: valid only for the\n duration of the callback that handed it out, and never destroyed by the caller. Child nodes borrowed via\n `duckdb_v2_expression_get_child()` share their parent's lifetime."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_expression {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to a node of a bound expression tree. Read-only and owned by the engine: valid only for the\n duration of the callback that handed it out, and never destroyed by the caller. Child nodes borrowed via\n `duckdb_v2_expression_get_child()` share their parent's lifetime."]
pub type duckdb_v2_expression_handle = *mut _duckdb_v2_expression;
unsafe extern "C" {
    #[doc = " Returns the type of an expression node.\n\n The type decides which of the type-specific accessors apply, and what the node's children mean; see\n `EXPRESSION_TYPE`. A node of a type this API does not model reports `EXPRESSION_TYPE_INVALID`.\n\n history:\n - unstable: v2.0.0\n\n @param expression The expression node.\n @param type Receives the node type.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_expression_get_type(
        expression: duckdb_v2_expression_handle,
        type_: *mut DUCKDB_V2_EXPRESSION_TYPE,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the logical type the expression node evaluates to.\n\n For a cast this is the target type. The returned type is owned by the caller and must be destroyed via\n `duckdb_v2_logical_type_destroy()`.\n\n history:\n - unstable: v2.0.0\n\n @param expression The expression node.\n @param type Receives the owned logical type.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_expression_get_return_type(
        expression: duckdb_v2_expression_handle,
        type_: *mut duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of child nodes of an expression node.\n\n Works for every node type, including `EXPRESSION_TYPE_INVALID`. Constants, parameters and column references have no\n children.\n\n history:\n - unstable: v2.0.0\n\n @param expression The expression node.\n @param count Receives the number of children.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_expression_get_child_count(
        expression: duckdb_v2_expression_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves a child node of an expression node by index.\n\n Fails if the index is out of bounds. Children are ordered as the node type describes (see `EXPRESSION_TYPE`). The\n child is borrowed and shares the lifetime of its parent.\n\n history:\n - unstable: v2.0.0\n\n @param expression The expression node.\n @param index The index of the child to retrieve.\n @param child Receives the borrowed child node.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_expression_get_child(
        expression: duckdb_v2_expression_handle,
        index: idx_t,
        child: *mut duckdb_v2_expression_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value of a constant node.\n\n Fails if the node is not of type `EXPRESSION_TYPE_VALUE_CONSTANT`. The returned value is owned by the caller and must\n be destroyed via `duckdb_v2_value_destroy()`.\n\n history:\n - unstable: v2.0.0\n\n @param expression The constant node.\n @param value Receives the owned constant value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_expression_constant_get_value(
        expression: duckdb_v2_expression_handle,
        value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the column a column reference node points at.\n\n Fails if the node is not of type `EXPRESSION_TYPE_BOUND_COLUMN_REF`. The index counts the columns of the operator the\n predicate is evaluated against, which is not necessarily the full set of columns that operator can produce: a\n callback resolves it through whatever handed it the expression, e.g.\n `duckdb_v2_table_function_filter_pushdown_get_column_index()` for a filter offered to a table function.\n\n history:\n - unstable: v2.0.0\n\n @param expression The column reference node.\n @param index Receives the column index.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_expression_column_ref_get_index(
        expression: duckdb_v2_expression_handle,
        index: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the name of the scalar function a function node calls.\n\n Applies to `EXPRESSION_TYPE_BOUND_FUNCTION` and to the node types that are function calls underneath: the\n comparisons, `EXPRESSION_TYPE_COMPARE_BETWEEN` and `EXPRESSION_TYPE_OPERATOR_CAST`. Fails for any other node type.\n For a comparison the name is its operator, e.g. `<`; for `BETWEEN` and casts it is an internal name, so dispatch on\n the type rather than the name for those. The name is borrowed and shares the lifetime of the node.\n\n history:\n - unstable: v2.0.0\n\n @param expression The function node.\n @param name Receives a borrowed view of the function name.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_expression_function_get_name(
        expression: duckdb_v2_expression_handle,
        name: *mut duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the qualified name of the scalar function a function node calls.\n\n Applies to the same node types as `duckdb_v2_expression_function_get_name()`, and fails for any other. The name is\n qualified with the catalog and schema the function was resolved in, where known. The returned name is owned by the\n caller and must be destroyed via `duckdb_v2_qname_destroy()`.\n\n history:\n - unstable: v2.0.0\n\n @param expression The function node.\n @param name Receives the owned qualified name.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_expression_function_get_qname(
        expression: duckdb_v2_expression_handle,
        name: *mut duckdb_v2_qname_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns whether a cast node is a regular `CAST` or a `TRY_CAST`.\n\n Fails if the node is not of type `EXPRESSION_TYPE_OPERATOR_CAST`. A `TRY_CAST` yields NULL for a value it cannot\n convert where a regular `CAST` would fail the query.\n\n history:\n - unstable: v2.0.0\n\n @param expression The cast node.\n @param mode Receives the cast mode.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_expression_cast_get_mode(
        expression: duckdb_v2_expression_handle,
        mode: *mut DUCKDB_V2_CAST_MODE,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
#[repr(u32)]
#[non_exhaustive]
#[doc = "! The scope a log entry was written in, which decides which of its ids are present."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_LOG_SCOPE {
    #[doc = "! Written for the database as a whole, carrying no connection, transaction or query id."]
    DUCKDB_V2_LOG_SCOPE_DATABASE = 10,
    #[doc = "! Written by a connection, carrying its connection id and, inside one, the transaction and query ids."]
    DUCKDB_V2_LOG_SCOPE_CONNECTION = 20,
    #[doc = "! Written by a thread executing a query, carrying the thread id next to the connection's ids."]
    DUCKDB_V2_LOG_SCOPE_THREAD = 30,
    #[doc = "! Written by a thread executing a query, carrying the thread id next to the connection's ids."]
    DUCKDB_V2_LOG_SCOPE_MAX_ENUM = 2147483647,
}
#[doc = " An owned opaque handle to a log sink being built. Created with `duckdb_v2_log_sink_create()`, configured with\n `duckdb_v2_log_sink_set_name()`, `duckdb_v2_log_sink_set_write_callback()` and the other setters, made available with\n `duckdb_v2_instance_register_log_sink()` or `duckdb_v2_extension_register_log_sink()`, and destroyed with\n `duckdb_v2_log_sink_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_log_sink {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned opaque handle to a log sink being built. Created with `duckdb_v2_log_sink_create()`, configured with\n `duckdb_v2_log_sink_set_name()`, `duckdb_v2_log_sink_set_write_callback()` and the other setters, made available with\n `duckdb_v2_instance_register_log_sink()` or `duckdb_v2_extension_register_log_sink()`, and destroyed with\n `duckdb_v2_log_sink_destroy()`."]
pub type duckdb_v2_log_sink_handle = *mut _duckdb_v2_log_sink;
#[doc = " A borrowed opaque handle to the context of a log entry, received by a log sink's write callback next to the entry\n itself, and valid only for the duration of that call. Read the ids `duckdb_logs` reports for the entry through its\n getters, e.g. `duckdb_v2_log_sink_write_info_get_connection_id()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_log_sink_write_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the context of a log entry, received by a log sink's write callback next to the entry\n itself, and valid only for the duration of that call. Read the ids `duckdb_logs` reports for the entry through its\n getters, e.g. `duckdb_v2_log_sink_write_info_get_connection_id()`."]
pub type duckdb_v2_log_sink_write_info_handle = *mut _duckdb_v2_log_sink_write_info;
#[doc = " A borrowed opaque handle received by a log sink's flush callback, and valid only for the duration of that call. It\n carries nothing yet."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_log_sink_flush_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle received by a log sink's flush callback, and valid only for the duration of that call. It\n carries nothing yet."]
pub type duckdb_v2_log_sink_flush_info_handle = *mut _duckdb_v2_log_sink_flush_info;
pub type duckdb_v2_log_sink_write_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_log_sink_write_info_handle,
        user_data: *mut ::std::os::raw::c_void,
        timestamp: i64,
        level: DUCKDB_V2_LOG_LEVEL,
        scope: DUCKDB_V2_LOG_SCOPE,
        type_: *const duckdb_v2_str,
        message: *const duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_log_sink_flush_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_log_sink_flush_info_handle,
        user_data: *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
unsafe extern "C" {
    #[doc = " Creates a new log sink through a factory.\n\n The log sink starts out empty: configure it with the setter functions, then make it available with\n `duckdb_v2_instance_register_log_sink()` or `duckdb_v2_extension_register_log_sink()`. The caller owns the returned\n handle and must destroy it with `duckdb_v2_log_sink_destroy()`, also after registration.\n\n The log sink can only be registered on the instance the factory belongs to.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create the log sink through.\n @param sink On success, receives the newly created log sink. Owned by the caller.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_log_sink_create(
        factory: duckdb_v2_factory_handle,
        sink: *mut duckdb_v2_log_sink_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the name the logging configuration refers to the log sink by.\n\n Names are matched case-insensitively. The name is borrowed and copied. Calling this again replaces the previous name.\n A name must be set before registration.\n\n history:\n - unstable: v2.0.0\n\n @param sink The log sink to set the name of.\n @param name The name to set. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_log_sink_set_name(
        sink: duckdb_v2_log_sink_handle,
        name: *const duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets arbitrary user data on the log sink.\n\n Associates an opaque pointer with the sink, handed to its write and flush callbacks. The opaque handle bundles the\n pointer with an optional destructor, invoked when the data is no longer needed: when the instance is destroyed if the\n sink was registered, else when the log sink handle is.\n\n history:\n - unstable: v2.0.0\n\n @param sink The log sink to set the user data of.\n @param data Opaque handle bundling the user data pointer plus an optional destructor.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_log_sink_set_user_data(
        sink: duckdb_v2_log_sink_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the write callback of the log sink, invoked for every entry the logging configuration directs to the sink.\n\n The callback must return quickly, must be safe to run concurrently and on any thread, and must not log or change the\n logging configuration. A write callback must be set before registration.\n\n history:\n - unstable: v2.0.0\n\n @param sink The log sink to set the write callback of.\n @param callback The write callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_log_sink_set_write_callback(
        sink: duckdb_v2_log_sink_handle,
        callback: duckdb_v2_log_sink_write_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional flush callback of the log sink, invoked when DuckDB flushes its log, so entries the sink holds on\n to can be written out. When DuckDB flushes is up to DuckDB; entries still held when the instance is destroyed are for\n the user data's destructor to write out.\n\n Like the write callback, it must be safe to run on any thread, and must not log or change the logging configuration.\n\n history:\n - unstable: v2.0.0\n\n @param sink The log sink to set the flush callback of.\n @param callback The flush callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_log_sink_set_flush_callback(
        sink: duckdb_v2_log_sink_handle,
        callback: duckdb_v2_log_sink_flush_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the id of the connection that wrote the entry, as `duckdb_logs` reports it. An entry written for the\n database as a whole has none: `present` then receives false and `id` is left untouched.\n\n history:\n - unstable: v2.0.0\n\n @param info The write info handle of the entry.\n @param id Receives the connection id, if present.\n @param present Receives whether the entry has a connection id.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_log_sink_write_info_get_connection_id(
        info: duckdb_v2_log_sink_write_info_handle,
        id: *mut idx_t,
        present: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the id of the transaction the entry was written in, as `duckdb_logs` reports it. An entry written outside a\n transaction has none: `present` then receives false and `id` is left untouched.\n\n history:\n - unstable: v2.0.0\n\n @param info The write info handle of the entry.\n @param id Receives the transaction id, if present.\n @param present Receives whether the entry has a transaction id.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_log_sink_write_info_get_transaction_id(
        info: duckdb_v2_log_sink_write_info_handle,
        id: *mut idx_t,
        present: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the id of the query the entry was written for, as `duckdb_logs` reports it. An entry written outside a\n query has none: `present` then receives false and `id` is left untouched.\n\n history:\n - unstable: v2.0.0\n\n @param info The write info handle of the entry.\n @param id Receives the query id, if present.\n @param present Receives whether the entry has a query id.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_log_sink_write_info_get_query_id(
        info: duckdb_v2_log_sink_write_info_handle,
        id: *mut idx_t,
        present: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the id of the thread that wrote the entry, as `duckdb_logs` reports it. Only an entry written in the thread\n scope has one: otherwise `present` receives false and `id` is left untouched. The id identifies the thread that\n logged, which need not be the thread the write callback runs on.\n\n history:\n - unstable: v2.0.0\n\n @param info The write info handle of the entry.\n @param id Receives the thread id, if present.\n @param present Receives whether the entry has a thread id.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_log_sink_write_info_get_thread_id(
        info: duckdb_v2_log_sink_write_info_handle,
        id: *mut idx_t,
        present: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the log sink on the instance, making it available to the logging configuration under its name.\n\n Registering does not direct any entries to the sink by itself; the logging configuration does. Registration is not\n transactional, requires a name and a write callback, and fails when the name is taken: by a sink DuckDB provides\n itself, such as `memory`, `stdout` or `file`, or by a sink registered before. The log sink must have been created\n through a factory of the same instance. Its user data passes to the registered sink. The caller still owns the handle\n after registration and must destroy it with `duckdb_v2_log_sink_destroy()`, which does not affect the registered\n sink.\n\n history:\n - unstable: v2.0.0\n\n @param instance The instance to register on.\n @param sink The log sink to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_instance_register_log_sink(
        instance: duckdb_v2_instance_handle,
        sink: duckdb_v2_log_sink_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the log sink on the loading extension's instance, making it available to the logging configuration under\n its name.\n\n Use this from the extension's load callback. Registration follows the rules of\n `duckdb_v2_instance_register_log_sink()`.\n\n history:\n - unstable: v2.0.0\n\n @param extension The loading extension.\n @param sink The log sink to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_extension_register_log_sink(
        extension: duckdb_v2_extension_handle,
        sink: duckdb_v2_log_sink_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the log sink, releasing its resources.\n\n Null-safe: passing a null pointer or null handle is a no-op. The handle is set to null on return to prevent\n double-destruction. Destroying the handle after registration does not affect the registered sink.\n\n history:\n - unstable: v2.0.0\n\n @param sink The log sink to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_log_sink_destroy(sink: *mut duckdb_v2_log_sink_handle) -> DUCKDB_V2_ERROR;
}
#[repr(u32)]
#[non_exhaustive]
#[doc = " Logical type identifier. The values are the same integers DuckDB uses internally, so round-tripping is lossless. The\n bind- and UDF-only ids (UNKNOWN, ANY, TEMPLATE) appear here for completeness; they do not show up in result column\n types in practice."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_LOGICAL_TYPE_ID {
    #[doc = "! Invalid / unset."]
    DUCKDB_V2_LOGICAL_TYPE_ID_INVALID = 0,
    #[doc = "! NULL constant type."]
    DUCKDB_V2_LOGICAL_TYPE_ID_SQLNULL = 1,
    #[doc = "! Unknown — used for unresolved parameter expressions."]
    DUCKDB_V2_LOGICAL_TYPE_ID_UNKNOWN = 2,
    #[doc = "! ANY — used for functions that accept any type."]
    DUCKDB_V2_LOGICAL_TYPE_ID_ANY = 3,
    #[doc = "! A type carried as a value (type parameters). Values of this type are built via value_create_type."]
    DUCKDB_V2_LOGICAL_TYPE_ID_TYPE = 6,
    #[doc = "! A type carried as a value (type parameters). Values of this type are built via value_create_type."]
    DUCKDB_V2_LOGICAL_TYPE_ID_BOOLEAN = 10,
    #[doc = "! A type carried as a value (type parameters). Values of this type are built via value_create_type."]
    DUCKDB_V2_LOGICAL_TYPE_ID_TINYINT = 11,
    #[doc = "! A type carried as a value (type parameters). Values of this type are built via value_create_type."]
    DUCKDB_V2_LOGICAL_TYPE_ID_SMALLINT = 12,
    #[doc = "! A type carried as a value (type parameters). Values of this type are built via value_create_type."]
    DUCKDB_V2_LOGICAL_TYPE_ID_INTEGER = 13,
    #[doc = "! A type carried as a value (type parameters). Values of this type are built via value_create_type."]
    DUCKDB_V2_LOGICAL_TYPE_ID_BIGINT = 14,
    #[doc = "! 32-bit days since epoch."]
    DUCKDB_V2_LOGICAL_TYPE_ID_DATE = 15,
    #[doc = "! 64-bit microseconds since midnight."]
    DUCKDB_V2_LOGICAL_TYPE_ID_TIME = 16,
    #[doc = "! 64-bit seconds since epoch."]
    DUCKDB_V2_LOGICAL_TYPE_ID_TIMESTAMP_SEC = 17,
    #[doc = "! 64-bit milliseconds since epoch."]
    DUCKDB_V2_LOGICAL_TYPE_ID_TIMESTAMP_MS = 18,
    #[doc = "! 64-bit microseconds since epoch."]
    DUCKDB_V2_LOGICAL_TYPE_ID_TIMESTAMP = 19,
    #[doc = "! 64-bit nanoseconds since epoch."]
    DUCKDB_V2_LOGICAL_TYPE_ID_TIMESTAMP_NS = 20,
    #[doc = "! Decimal with width and scale parameters."]
    DUCKDB_V2_LOGICAL_TYPE_ID_DECIMAL = 21,
    #[doc = "! Decimal with width and scale parameters."]
    DUCKDB_V2_LOGICAL_TYPE_ID_FLOAT = 22,
    #[doc = "! Decimal with width and scale parameters."]
    DUCKDB_V2_LOGICAL_TYPE_ID_DOUBLE = 23,
    #[doc = "! Decimal with width and scale parameters."]
    DUCKDB_V2_LOGICAL_TYPE_ID_VARCHAR = 25,
    #[doc = "! Decimal with width and scale parameters."]
    DUCKDB_V2_LOGICAL_TYPE_ID_BLOB = 26,
    #[doc = "! Decimal with width and scale parameters."]
    DUCKDB_V2_LOGICAL_TYPE_ID_INTERVAL = 27,
    #[doc = "! Decimal with width and scale parameters."]
    DUCKDB_V2_LOGICAL_TYPE_ID_UTINYINT = 28,
    #[doc = "! Decimal with width and scale parameters."]
    DUCKDB_V2_LOGICAL_TYPE_ID_USMALLINT = 29,
    #[doc = "! Decimal with width and scale parameters."]
    DUCKDB_V2_LOGICAL_TYPE_ID_UINTEGER = 30,
    #[doc = "! Decimal with width and scale parameters."]
    DUCKDB_V2_LOGICAL_TYPE_ID_UBIGINT = 31,
    #[doc = "! 64-bit microseconds since epoch, timezone-aware."]
    DUCKDB_V2_LOGICAL_TYPE_ID_TIMESTAMP_TZ = 32,
    #[doc = "! 64-bit nanoseconds since epoch, timezone-aware."]
    DUCKDB_V2_LOGICAL_TYPE_ID_TIMESTAMP_TZ_NS = 33,
    #[doc = "! 64-bit microseconds since midnight + 32-bit offset."]
    DUCKDB_V2_LOGICAL_TYPE_ID_TIME_TZ = 34,
    #[doc = "! 64-bit nanoseconds since midnight."]
    DUCKDB_V2_LOGICAL_TYPE_ID_TIME_NS = 35,
    #[doc = "! 64-bit nanoseconds since midnight."]
    DUCKDB_V2_LOGICAL_TYPE_ID_BIT = 36,
    #[doc = "! Arbitrary-precision integer (VARINT-encoded)."]
    DUCKDB_V2_LOGICAL_TYPE_ID_BIGNUM = 39,
    #[doc = "! Arbitrary-precision integer (VARINT-encoded)."]
    DUCKDB_V2_LOGICAL_TYPE_ID_UHUGEINT = 49,
    #[doc = "! Arbitrary-precision integer (VARINT-encoded)."]
    DUCKDB_V2_LOGICAL_TYPE_ID_HUGEINT = 50,
    #[doc = "! Arbitrary-precision integer (VARINT-encoded)."]
    DUCKDB_V2_LOGICAL_TYPE_ID_UUID = 54,
    #[doc = "! Geometry (spatial extension)."]
    DUCKDB_V2_LOGICAL_TYPE_ID_GEOMETRY = 60,
    #[doc = "! Geometry (spatial extension)."]
    DUCKDB_V2_LOGICAL_TYPE_ID_STRUCT = 100,
    #[doc = "! Geometry (spatial extension)."]
    DUCKDB_V2_LOGICAL_TYPE_ID_LIST = 101,
    #[doc = "! Geometry (spatial extension)."]
    DUCKDB_V2_LOGICAL_TYPE_ID_MAP = 102,
    #[doc = "! Geometry (spatial extension)."]
    DUCKDB_V2_LOGICAL_TYPE_ID_ENUM = 104,
    #[doc = "! Geometry (spatial extension)."]
    DUCKDB_V2_LOGICAL_TYPE_ID_UNION = 107,
    #[doc = "! Geometry (spatial extension)."]
    DUCKDB_V2_LOGICAL_TYPE_ID_ARRAY = 108,
    #[doc = "! Geometry (spatial extension)."]
    DUCKDB_V2_LOGICAL_TYPE_ID_VARIANT = 109,
    #[doc = "! Unnamed struct; shares the physical representation of STRUCT."]
    DUCKDB_V2_LOGICAL_TYPE_ID_TUPLE = 110,
    #[doc = "! Unnamed struct; shares the physical representation of STRUCT."]
    DUCKDB_V2_LOGICAL_TYPE_ID_MAX_ENUM = 2147483647,
}
unsafe extern "C" {
    #[doc = " Creates a logical type from a type id plus value parameters.\n\n The id-keyed twin of factory_create_type_from_name: the type id names the kind, and the parameters bind it. With\n param_count 0 it instantiates a primitive directly, without touching the catalog: BOOLEAN, TINYINT..BIGINT,\n UTINYINT..UBIGINT, HUGEINT, UHUGEINT, FLOAT, DOUBLE, DATE, every TIME and TIMESTAMP variant, INTERVAL, VARCHAR, BLOB,\n BIT, BIGNUM, and UUID. ANY is accepted as well.\n\n ANY is a function-signature wildcard, constructible here so it can be passed to the function parameter and varargs\n setters, as a fixed-arity ANY parameter or an ANY varargs type. Data-creating surfaces reject it: value and data\n chunk creation, scalar and aggregate return types, table function result columns, cast source and target types, and\n custom type registration.\n\n With parameters, the id resolves to its canonical built-in type and binds through the same constructors as\n factory_create_type_from_name, so the parameterized kinds construct here too: decimal(width, scale); list(T);\n array(T, size); map(K, V); struct(fields); union(members); enum(entries); and varchar with a named \"collation\"\n parameter. Parameters are (name, value) pairs in two parallel arrays, exactly as for factory_create_type_from_name.\n\n Returns ERROR_INPUT_INVALID when param_count is 0 and the id needs parameters (DECIMAL, LIST, STRUCT, TUPLE, MAP,\n ARRAY, UNION, ENUM, VARIANT, GEOMETRY), for the bind-time-only ids (SQLNULL, UNKNOWN), for TYPE — construct that via\n factory_create_type_from_text — and for INVALID.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to resolve the type in.\n @param type_id The type id to instantiate.\n @param param_names Optional. An array of param_count parameter names; a {NULL, 0} entry is positional. Pass NULL for\n all-positional parameters.\n @param param_values An array of param_count parameter values. Borrowed (copied in). Pass NULL when param_count is 0.\n @param param_count The number of parameters. 0 instantiates a parameterless primitive.\n @param out_type Receives the new logical type handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_factory_create_type_from_id(
        factory: duckdb_v2_factory_handle,
        type_id: DUCKDB_V2_LOGICAL_TYPE_ID,
        param_names: *const duckdb_v2_identifier_t,
        param_values: *const duckdb_v2_value_handle,
        param_count: idx_t,
        out_type: *mut duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a logical type from a type name plus value parameters.\n\n The generic constructor: resolves the name in the factory's catalog and binds it with the given parameters, exactly\n as SQL binds a type expression. Built-in parameterized kinds and registered extension types construct through this\n same call.\n\n An unqualified name is resolved along the search path first and then in the system catalog, which is where the\n built-in kinds live. A qualified name is resolved exactly as written, with no system-catalog fallback, so it names\n the type in that catalog or schema or fails.\n\n Parameters are (name, value) pairs in two parallel arrays. param_names may be NULL to make every parameter\n positional, and a {NULL, 0} entry makes that one parameter positional. Child types cross as TYPE values, built with\n value_create_type. The built-in shapes are: decimal(width, scale); list(T); array(T, size); map(K, V); struct(fields,\n as named or all-positional TYPE values); union(members, as named TYPE values); enum(entries, as VARCHAR values); and\n varchar with a named \"collation\" VARCHAR parameter.\n\n A name that resolves to a type with no bind function takes no parameters, and passing any fails. Bind errors —\n unknown name, wrong parameter count or types — surface from the call.\n\n Resolves in the scope of the factory: a connection's or callback's factory reaches the catalog, an instance's factory\n knows only the built-in types. A connection's factory looks up catalog types in the connection's transaction, or in\n one of its own when none is open. Through an instance's factory, only an unqualified built-in name resolves.\n\n The returned logical type is caller-owned and must be destroyed via logical_type_destroy. A type resolved from the\n catalog shares database-owned storage, such as an ENUM dictionary, so destroy it before closing the database. This is\n the inverse of logical_type_get_param_count / logical_type_get_param.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to resolve the type in.\n @param name The type name to resolve. Parts are matched case-insensitively; qualify it to name a type in a particular\n catalog or schema.\n @param param_names Optional. An array of param_count parameter names; a {NULL, 0} entry is positional. Pass NULL for\n all-positional parameters.\n @param param_values An array of param_count parameter values. Borrowed (copied in). Pass NULL when param_count is 0.\n @param param_count The number of parameters.\n @param out_type Receives the new logical type handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_factory_create_type_from_name(
        factory: duckdb_v2_factory_handle,
        name: duckdb_v2_qname_handle,
        param_names: *const duckdb_v2_identifier_t,
        param_values: *const duckdb_v2_value_handle,
        param_count: idx_t,
        out_type: *mut duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a logical type by parsing SQL text.\n\n Parses a SQL type expression and returns the bound logical type. It accepts primitives (\"INTEGER\"), parameterized\n kinds (\"DECIMAL(18,3)\", \"INTEGER[]\", \"STRUCT(a INTEGER, b VARCHAR)\", \"MAP(VARCHAR, INTEGER)\", \"INTEGER[3]\", \"UNION(i\n INTEGER, s VARCHAR)\", \"ENUM('a', 'b')\"), and catalog-registered type names, both user-defined and from extensions. A\n catalog type name binds to its structural type, and the name is not preserved as an alias. Names are\n case-insensitive. Parse and bind errors surface from the call.\n\n Resolves in the scope of the factory: a connection's or callback's factory reaches the catalog, an instance's factory\n knows only the built-in types. A connection's factory looks up catalog types in the connection's transaction, or in\n one of its own when none is open. Text naming only built-in types never touches the catalog.\n\n The returned logical type is caller-owned and must be destroyed via logical_type_destroy. A type resolved from the\n catalog shares database-owned storage, such as an ENUM dictionary, so destroy it before closing the database. This is\n the inverse of logical_type_to_text for every constructible kind.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to resolve the type in.\n @param text View of the SQL type expression to parse.\n @param out_type Receives the new logical type handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_factory_create_type_from_text(
        factory: duckdb_v2_factory_handle,
        text: *const duckdb_v2_str,
        out_type: *mut duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a copy of a logical type.\n\n On success, writes the new caller-owned handle into *out_type; destroy it via logical_type_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param type The logical type to copy.\n @param out_type Receives the new logical type handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_logical_type_copy(
        type_: duckdb_v2_logical_type_handle,
        out_type: *mut duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys a logical type handle.\n\n Null-safe: passing nullptr or a slot already set to nullptr is a no-op. On success the slot is set to nullptr.\n\n history:\n - unstable: v2.0.0\n\n @param type The logical type to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_logical_type_destroy(type_: *mut duckdb_v2_logical_type_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Compares two logical types for deep equality.\n\n Two types are equal when they agree in kind and in every parameter, recursively. DECIMAL(10, 2) equals DECIMAL(10,\n 2), but not DECIMAL(10, 3) and not FLOAT; two STRUCTs are equal when they have the same field names in the same order\n and equal field types.\n\n history:\n - unstable: v2.0.0\n\n @param left The first logical type.\n @param right The second logical type.\n @param result Receives the result of the comparison.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_logical_type_is_equal(
        left: duckdb_v2_logical_type_handle,
        right: duckdb_v2_logical_type_handle,
        result: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the logical type id.\n\n history:\n - unstable: v2.0.0\n\n @param type The logical type.\n @param out_id Receives the type id.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_logical_type_get_id(
        type_: duckdb_v2_logical_type_handle,
        out_id: *mut DUCKDB_V2_LOGICAL_TYPE_ID,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the logical type's name.\n\n The alias when one is set — an extension or user-defined name such as \"POINT_2D\" — otherwise the canonical name of\n the type id, such as \"INTEGER\", \"DECIMAL\", or \"TIMESTAMP WITH TIME ZONE\". Never the empty view. This is exactly the\n name vocabulary create_type_from_name accepts. The view is valid until the logical type is destroyed; a canonical\n name points at static storage.\n\n history:\n - unstable: v2.0.0\n\n @param type The logical type.\n @param out_name Receives a borrowed view of the name (alias when set, else the id's canonical name).\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_logical_type_get_name(
        type_: duckdb_v2_logical_type_handle,
        out_name: *mut duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Renders a logical type as SQL text.\n\n An aliased type renders as its alias, and create_type_from_text resolves that spelling only when the name is\n registered in the factory's catalog. The text round-trips through create_type_from_text for every constructible kind,\n with one exception: ANY renders as \"ANY\", but create_type_from_text cannot parse it back, since ANY is a signature\n wildcard rather than a parseable SQL type.\n\n Writes into a caller-supplied buffer, so nothing is allocated on the caller's behalf and nothing has to be freed.\n Pass out_text = NULL to size the buffer without rendering into it: out_length then receives the length, and\n out_capacity is ignored. With out_text != NULL, out_capacity must be at least out_length + 1, or the call returns\n ERROR_INPUT_OBJECT_SIZE with out_length set to the required length and out_text left untouched.\n\n out_length never counts the terminator, but a successful write always appends one, so the buffer is usable as a C\n string.\n\n history:\n - unstable: v2.0.0\n\n @param type The logical type.\n @param out_text Caller-owned buffer receiving the text plus a null terminator, or NULL to only report the required\n length in out_length.\n @param out_capacity Bytes available in out_text, terminator included. Ignored when out_text is NULL.\n @param out_length Receives the text length excluding the null terminator — written on success and on\n ERROR_INPUT_OBJECT_SIZE.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_logical_type_to_text(
        type_: duckdb_v2_logical_type_handle,
        out_text: *mut ::std::os::raw::c_char,
        out_capacity: idx_t,
        out_length: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of value parameters of a logical type.\n\n The inspection dual of create_type_from_name: these are the parameters that reconstruct the type through it. Per\n kind: DECIMAL 2 (width, scale); LIST 1 (element type); ARRAY 2 (element type, size); MAP 2 (key type, value type);\n STRUCT and TUPLE one per field; UNION one per member; ENUM one per dictionary entry; VARCHAR 1 when a collation is\n set, else 0; GEOMETRY 1 when a coordinate system is set, else 0; everything else 0. A bound type reports only what it\n actually carries, so a bind-time modifier that is not retained — an ignored VARCHAR length, say — does not reappear.\n\n history:\n - unstable: v2.0.0\n\n @param type The logical type.\n @param out_count Receives the number of parameters.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_logical_type_get_param_count(
        type_: duckdb_v2_logical_type_handle,
        out_count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns one value parameter of a logical type.\n\n out_name receives a borrowed view of the parameter name — a STRUCT field name, a UNION member name, \"collation\" — or\n the empty view {NULL, 0} for a positional parameter. A non-empty view is valid until the logical type is destroyed.\n out_value receives an owned value, destroyed via value_destroy: child types come back as TYPE values (unwrap them\n with value_get_type), DECIMAL width and scale as UTINYINT, ARRAY size as BIGINT, and ENUM dictionary entries and\n collations as VARCHAR. An out-of-range index returns ERROR_INPUT_INVALID. Each call allocates one owned value.\n\n history:\n - unstable: v2.0.0\n\n @param type The logical type.\n @param index The parameter index, in [0, param_count).\n @param out_name Receives a borrowed view of the parameter name, or the empty view {NULL, 0} for a positional\n parameter.\n @param out_value Receives the owned parameter value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_logical_type_get_param(
        type_: duckdb_v2_logical_type_handle,
        index: idx_t,
        out_name: *mut duckdb_v2_identifier_t,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a logical type that is an alias of another logical type.\n\n The alias keeps the base type's internal representation, so executing against it needs no special handling, while\n remaining logically distinct from the base type. Intended for custom type bind callbacks, where both the base type\n and the name come from the bind info.\n\n The alias is not registered anywhere, so this works through any factory. An empty alias name returns\n ERROR_INPUT_INVALID.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to resolve the type in.\n @param base_type The logical type to alias. Typically the base type supplied in the custom type bind info.\n @param alias_name The name for the resulting type. Typically the name of the custom type being constructed, also\n available from the bind info.\n @param out_type Receives the new type: the base type's internal representation under the given alias name.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_factory_create_type_with_alias(
        factory: duckdb_v2_factory_handle,
        base_type: duckdb_v2_logical_type_handle,
        alias_name: *const duckdb_v2_identifier_t,
        out_type: *mut duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates the common type of a set of logical types.\n\n The common type is the type every input implicitly casts to, resolved by the same rule a SQL list literal and\n value_create_list follow: INTEGER and BIGINT resolve to BIGINT, and DECIMAL(4,1) and DECIMAL(5,4) to DECIMAL(7,4).\n The types are combined pairwise from left to right, and the result is not guaranteed to be independent of their\n order.\n\n A connection's or a callback's factory also applies the casts that extensions registered, while an instance's factory\n knows only the built-in ones, so the two can resolve the same set differently. A single type resolves to a copy of\n itself.\n\n Returns ERROR_INPUT_INVALID for an empty set, for a NULL entry and for ANY, and ERROR_QUERY_NOT_IMPLEMENTED when the\n types have no common type.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to resolve the type in.\n @param types An array of type_count logical types. Borrowed.\n @param type_count The number of types. Must be at least 1.\n @param out_type Receives the new logical type handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_factory_create_common_type(
        factory: duckdb_v2_factory_handle,
        types: *const duckdb_v2_logical_type_handle,
        type_count: idx_t,
        out_type: *mut duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
#[repr(u32)]
#[non_exhaustive]
#[doc = "! The kind of a macro function, deciding how its body is read. Pass one to `duckdb_v2_macro_function_create()`."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_MACRO_FUNCTION_TYPE {
    #[doc = "! A scalar macro. The body is a single expression, and the macro is called like a scalar function."]
    DUCKDB_V2_MACRO_FUNCTION_TYPE_SCALAR = 0,
    #[doc = "! A table macro. The body is a single SELECT query, and the macro is called like a table function."]
    DUCKDB_V2_MACRO_FUNCTION_TYPE_TABLE = 1,
    #[doc = "! A table macro. The body is a single SELECT query, and the macro is called like a table function."]
    DUCKDB_V2_MACRO_FUNCTION_TYPE_MAX_ENUM = 2147483647,
}
#[doc = " An owned opaque handle to a macro function being built. Created with `duckdb_v2_macro_function_create()`, configured\n with `duckdb_v2_macro_function_set_name()`, `duckdb_v2_macro_function_set_body()` and the signature obtained via\n `duckdb_v2_macro_function_get_signature()`, made available with `duckdb_v2_extension_register_macro_function()`, and\n destroyed with `duckdb_v2_macro_function_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_macro_function {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned opaque handle to a macro function being built. Created with `duckdb_v2_macro_function_create()`, configured\n with `duckdb_v2_macro_function_set_name()`, `duckdb_v2_macro_function_set_body()` and the signature obtained via\n `duckdb_v2_macro_function_get_signature()`, made available with `duckdb_v2_extension_register_macro_function()`, and\n destroyed with `duckdb_v2_macro_function_destroy()`."]
pub type duckdb_v2_macro_function_handle = *mut _duckdb_v2_macro_function;
unsafe extern "C" {
    #[doc = " Creates a new macro function through a factory.\n\n The macro function starts out empty: configure it with the setter functions and the signature obtained via\n `duckdb_v2_macro_function_get_signature()`, then make it available with\n `duckdb_v2_extension_register_macro_function()`. The caller owns the returned handle and must destroy it with\n `duckdb_v2_macro_function_destroy()`, also after registration.\n\n The macro function can only be registered on the database the factory belongs to.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create the macro function through.\n @param type Whether the macro is a scalar or a table macro.\n @param function On success, receives the newly created macro function. Owned by the caller.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_macro_function_create(
        factory: duckdb_v2_factory_handle,
        type_: DUCKDB_V2_MACRO_FUNCTION_TYPE,
        function: *mut duckdb_v2_macro_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the name of the macro function, as SQL calls it.\n\n The name is borrowed and copied. Calling this again replaces the previous name. A name must be set before\n registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The macro function to set the name of.\n @param name The name to set. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_macro_function_set_name(
        function: duckdb_v2_macro_function_handle,
        name: *const duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the body of the macro function, as SQL text.\n\n For a scalar macro the body is a single expression, for a table macro a single SELECT query. It refers to the\n parameters by name. The body is parsed at registration, which fails on a syntax error; names in it are resolved only\n when the macro is called, as with SQL `CREATE MACRO`. The body is borrowed and copied. Calling this again replaces\n the previous body. A body must be set before registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The macro function to set the body of.\n @param body The SQL text of the body. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_macro_function_set_body(
        function: duckdb_v2_macro_function_handle,
        body: *const duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the macro function's signature so its parameters can be declared.\n\n Add parameters with `duckdb_v2_function_signature_add_parameter()`. A macro's parameters can always be passed by\n position or by name, so only `FUNCTION_PARAMETER_KIND_STANDARD` parameters are accepted; a macro has no variadic\n parameters. A parameter of type ANY is untyped, and a parameter with a default value can be omitted by a caller. A\n macro's result is decided by its body, so the signature cannot set a return type. Registration fails on a signature\n that does not follow these rules. The signature is modified in place.\n\n history:\n - unstable: v2.0.0\n\n @param function The macro function to get the signature of.\n @param sig The returned signature. Borrowed and valid for the lifetime of the macro function handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_macro_function_get_signature(
        function: duckdb_v2_macro_function_handle,
        sig: *mut duckdb_v2_function_signature_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the documentation of the macro function so it can be filled in.\n\n Set a description with `duckdb_v2_function_docs_set_description()`, and add examples and categories with\n `duckdb_v2_function_docs_add_example()` and `duckdb_v2_function_docs_add_category()`. The documentation is modified\n in place and registered with the macro function. Optional.\n\n history:\n - unstable: v2.0.0\n\n @param function The macro function to get the documentation of.\n @param docs The returned documentation. Borrowed and valid for the lifetime of the macro function handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_macro_function_get_docs(
        function: duckdb_v2_macro_function_handle,
        docs: *mut duckdb_v2_function_docs_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the macro function, making it available for use in SQL queries.\n\n The macro function is registered on the loading extension's database and attributed to the extension. Use this from\n the extension's load callback. Registration requires a name and a body that parses, and a signature that follows the\n rules of `duckdb_v2_macro_function_get_signature()`. It fails when a function of the same name already exists: a\n macro function has a single overload. The macro function must have been created through a factory of the same\n database. The caller still owns the handle after registration and must destroy it with\n `duckdb_v2_macro_function_destroy()`, which does not affect the registered macro function.\n\n history:\n - unstable: v2.0.0\n\n @param extension The loading extension.\n @param function The macro function to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_extension_register_macro_function(
        extension: duckdb_v2_extension_handle,
        function: duckdb_v2_macro_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the macro function, releasing its resources.\n\n Null-safe: passing a null pointer or null handle is a no-op. The handle is set to null on return to prevent\n double-destruction. Destroying the handle after registration does not affect the registered macro function.\n\n history:\n - unstable: v2.0.0\n\n @param function The macro function to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_macro_function_destroy(function: *mut duckdb_v2_macro_function_handle) -> DUCKDB_V2_ERROR;
}
#[doc = " An owned opaque handle to a custom pragma function being built. Created with `duckdb_v2_pragma_function_create()`,\n configured with the setter functions (e.g. `duckdb_v2_pragma_function_set_name()`,\n `duckdb_v2_pragma_function_set_query_callback()`, etc.) and the signature obtained via\n `duckdb_v2_pragma_function_get_signature()`, made available with `duckdb_v2_connection_register_pragma_function()` or\n `duckdb_v2_extension_register_pragma_function()`, and destroyed with `duckdb_v2_pragma_function_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_pragma_function {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned opaque handle to a custom pragma function being built. Created with `duckdb_v2_pragma_function_create()`,\n configured with the setter functions (e.g. `duckdb_v2_pragma_function_set_name()`,\n `duckdb_v2_pragma_function_set_query_callback()`, etc.) and the signature obtained via\n `duckdb_v2_pragma_function_get_signature()`, made available with `duckdb_v2_connection_register_pragma_function()` or\n `duckdb_v2_extension_register_pragma_function()`, and destroyed with `duckdb_v2_pragma_function_destroy()`."]
pub type duckdb_v2_pragma_function_handle = *mut _duckdb_v2_pragma_function;
#[doc = " A borrowed opaque handle to the result of a pragma function's \"query\" callback. The query callback receives this\n handle next to a `duckdb_v2_function_bind_info_handle`, which gives access to the arguments and the user data, and\n uses it to set the query to run in place of the `PRAGMA` statement."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_pragma_function_query_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the result of a pragma function's \"query\" callback. The query callback receives this\n handle next to a `duckdb_v2_function_bind_info_handle`, which gives access to the arguments and the user data, and\n uses it to set the query to run in place of the `PRAGMA` statement."]
pub type duckdb_v2_pragma_function_query_info_handle = *mut _duckdb_v2_pragma_function_query_info;
pub type duckdb_v2_pragma_function_query_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_function_bind_info_handle,
        result: duckdb_v2_pragma_function_query_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_pragma_function_exec_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_function_bind_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
unsafe extern "C" {
    #[doc = " Creates a new pragma function through a factory.\n\n The function starts out empty: configure it with the setter functions (e.g. `duckdb_v2_pragma_function_set_name()`,\n `duckdb_v2_pragma_function_set_query_callback()`, etc.) and the signature obtained via\n `duckdb_v2_pragma_function_get_signature()`, then make it available with\n `duckdb_v2_connection_register_pragma_function()` or `duckdb_v2_extension_register_pragma_function()`. The caller\n owns the returned handle and must destroy it with `duckdb_v2_pragma_function_destroy()`, also after registration.\n\n The pragma function can only be registered on the database the factory belongs to.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create the pragma function through.\n @param function On success, receives the newly created pragma function. Owned by the caller.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_pragma_function_create(
        factory: duckdb_v2_factory_handle,
        function: *mut duckdb_v2_pragma_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the name of the pragma function, as the `PRAGMA` statement calls it.\n\n The name is borrowed and copied. Calling this again replaces the previous name. A name must be set before\n registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the name of.\n @param name The name to set. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_pragma_function_set_name(
        function: duckdb_v2_pragma_function_handle,
        name: *const duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the documentation of the function so it can be filled in.\n\n Set a description with `duckdb_v2_function_docs_set_description()`, and add examples and categories with\n `duckdb_v2_function_docs_add_example()` and `duckdb_v2_function_docs_add_category()`. The documentation is modified\n in place and registered with the function. Optional.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to get the documentation of.\n @param docs The returned documentation. Borrowed and valid for the lifetime of the function handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_pragma_function_get_docs(
        function: duckdb_v2_pragma_function_handle,
        docs: *mut duckdb_v2_function_docs_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the function's signature so it can be configured.\n\n Add parameters with `duckdb_v2_function_signature_add_parameter()`. A pragma produces no value, so its signature\n cannot set a return type. A signature without parameters makes a pragma called as `PRAGMA name`. The signature is\n modified in place.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to get the signature of.\n @param sig The returned signature. Borrowed and valid for the lifetime of the function handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_pragma_function_get_signature(
        function: duckdb_v2_pragma_function_handle,
        sig: *mut duckdb_v2_function_signature_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets arbitrary user data on the pragma function.\n\n Associates an opaque pointer with the function, retrievable from the callbacks via\n `duckdb_v2_function_bind_get_user_data()`. The opaque handle bundles the pointer with an optional destructor, invoked\n when the data is no longer needed.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the user data of.\n @param data Opaque handle bundling the user data pointer plus an optional destructor.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_pragma_function_set_user_data(
        function: duckdb_v2_pragma_function_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the query callback of the pragma function, making it a query pragma.\n\n The query callback is invoked before the `PRAGMA` statement is bound, and must set a SQL string through\n `duckdb_v2_pragma_function_query_set_query()`. The string is parsed and its statements run in place of the `PRAGMA`\n statement. A pragma function has either a query callback or an exec callback; registration fails when both or neither\n are set.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the query callback of.\n @param callback The query callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_pragma_function_set_query_callback(
        function: duckdb_v2_pragma_function_handle,
        callback: duckdb_v2_pragma_function_query_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the exec callback of the pragma function, making it an exec pragma.\n\n The exec callback is invoked when the `PRAGMA` statement executes, and runs for its side effects: the statement\n produces no rows. A pragma function has either a query callback or an exec callback; registration fails when both or\n neither are set.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the exec callback of.\n @param callback The exec callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_pragma_function_set_exec_callback(
        function: duckdb_v2_pragma_function_handle,
        callback: duckdb_v2_pragma_function_exec_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the SQL to run in place of the `PRAGMA` statement.\n\n The query may hold several statements, separated by semicolons. It is borrowed and copied. Calling this again\n replaces the previous query. The query callback must set a query.\n\n history:\n - unstable: v2.0.0\n\n @param info The query info handle.\n @param query The SQL to run. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_pragma_function_query_set_query(
        info: duckdb_v2_pragma_function_query_info_handle,
        query: *const duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the pragma function, making it available to the `PRAGMA` statement.\n\n The function is registered on the connection's database, visible to every connection, in the connection's\n transaction: inside an explicit transaction, it is invisible to other connections until the transaction commits, and\n a rollback undoes it. Registration requires a name and exactly one of a query callback or an exec callback, and fails\n when a pragma of the same name already exists. The pragma function must have been created through a factory of the\n same database. The caller still owns the handle after registration and must destroy it with\n `duckdb_v2_pragma_function_destroy()`, which does not affect the registered function.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection to register on.\n @param function The pragma function to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_register_pragma_function(
        conn: duckdb_v2_connection_handle,
        function: duckdb_v2_pragma_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the pragma function, making it available to the `PRAGMA` statement.\n\n The function is registered on the loading extension's database and attributed to the extension. Use this from the\n extension's load callback. Registration requires a name and exactly one of a query callback or an exec callback, and\n fails when a pragma of the same name already exists. The pragma function must have been created through a factory of\n the same database. The caller still owns the handle after registration and must destroy it with\n `duckdb_v2_pragma_function_destroy()`, which does not affect the registered function.\n\n history:\n - unstable: v2.0.0\n\n @param extension The loading extension.\n @param function The pragma function to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_extension_register_pragma_function(
        extension: duckdb_v2_extension_handle,
        function: duckdb_v2_pragma_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the pragma function, releasing its resources.\n\n Null-safe: passing a null pointer or null handle is a no-op. The handle is set to null on return to prevent\n double-destruction. Destroying the handle after registration does not affect the registered function.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_pragma_function_destroy(function: *mut duckdb_v2_pragma_function_handle) -> DUCKDB_V2_ERROR;
}
#[doc = " An owned opaque handle to a replacement scan being built. Created with `duckdb_v2_replacement_scan_create()`,\n configured with `duckdb_v2_replacement_scan_set_callback()` and `duckdb_v2_replacement_scan_set_user_data()`, made\n available with `duckdb_v2_connection_register_replacement_scan()`, `duckdb_v2_instance_register_replacement_scan()`\n or `duckdb_v2_extension_register_replacement_scan()`, and destroyed with `duckdb_v2_replacement_scan_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_replacement_scan {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned opaque handle to a replacement scan being built. Created with `duckdb_v2_replacement_scan_create()`,\n configured with `duckdb_v2_replacement_scan_set_callback()` and `duckdb_v2_replacement_scan_set_user_data()`, made\n available with `duckdb_v2_connection_register_replacement_scan()`, `duckdb_v2_instance_register_replacement_scan()`\n or `duckdb_v2_extension_register_replacement_scan()`, and destroyed with `duckdb_v2_replacement_scan_destroy()`."]
pub type duckdb_v2_replacement_scan_handle = *mut _duckdb_v2_replacement_scan;
#[doc = " A borrowed opaque handle to the arguments supplied to a replacement scan when the binder consults it. The callback\n receives this handle and can use it to inspect the unresolved name and to claim it by naming what to read instead.\n Valid only for the duration of the callback; the name it hands out is owned separately and outlives it."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_replacement_scan_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a replacement scan when the binder consults it. The callback\n receives this handle and can use it to inspect the unresolved name and to claim it by naming what to read instead.\n Valid only for the duration of the callback; the name it hands out is owned separately and outlives it."]
pub type duckdb_v2_replacement_scan_info_handle = *mut _duckdb_v2_replacement_scan_info;
pub type duckdb_v2_replacement_scan_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_replacement_scan_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
unsafe extern "C" {
    #[doc = " Creates a new replacement scan through a factory.\n\n The scan starts out empty: configure it with `duckdb_v2_replacement_scan_set_callback()` and optionally\n `duckdb_v2_replacement_scan_set_user_data()`, then make it available with\n `duckdb_v2_connection_register_replacement_scan()`, `duckdb_v2_instance_register_replacement_scan()` or\n `duckdb_v2_extension_register_replacement_scan()`. The caller owns the returned handle and must destroy it with\n `duckdb_v2_replacement_scan_destroy()`, also after registration.\n\n The scan can only be registered on the database the factory belongs to.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create the scan through.\n @param scan On success, receives the newly created replacement scan. Owned by the caller.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_replacement_scan_create(
        factory: duckdb_v2_factory_handle,
        scan: *mut duckdb_v2_replacement_scan_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the callback of the replacement scan.\n\n The callback is invoked during query planning for each table reference the catalog could not resolve. It can inspect\n the unresolved name via `duckdb_v2_replacement_scan_get_name()`, and claim the reference via\n `duckdb_v2_replacement_scan_set_function_name()`, `duckdb_v2_replacement_scan_set_collection()` or\n `duckdb_v2_replacement_scan_set_subquery()`; returning without claiming declines it. The context passed to the\n callback may be used to read settings, but not to run queries. A callback must be set before registration.\n\n history:\n - unstable: v2.0.0\n\n @param scan The scan to set the callback of.\n @param callback The callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_replacement_scan_set_callback(
        scan: duckdb_v2_replacement_scan_handle,
        callback: duckdb_v2_replacement_scan_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets arbitrary user data on the replacement scan.\n\n Associates an opaque pointer with the scan, retrievable from the callback via\n `duckdb_v2_replacement_scan_get_user_data()`. The opaque handle bundles the pointer with an optional destructor,\n invoked when the data is no longer needed, at the latest when the scan's scope ends. The callback may be invoked from\n several connections at once, so the data must be safe to read concurrently.\n\n history:\n - unstable: v2.0.0\n\n @param scan The scan to set the user data of.\n @param data Opaque handle bundling the user data pointer plus an optional destructor.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_replacement_scan_set_user_data(
        scan: duckdb_v2_replacement_scan_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_replacement_scan_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_replacement_scan_get_user_data(
        info: duckdb_v2_replacement_scan_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the name the catalog could not resolve.\n\n The name as written in the query, as a path: an unqualified reference has a single part, and a qualified one carries\n its catalog and schema before it -- see `duckdb_v2_qname_get_part()`. For a file-backed reference the single part is\n the path with the quotes stripped. The returned name is owned by the caller and must be destroyed via\n `duckdb_v2_qname_destroy()`; being owned, it may outlive the callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The info handle.\n @param name Receives the unresolved name. Owned by the caller; destroy via `duckdb_v2_qname_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_replacement_scan_get_name(
        info: duckdb_v2_replacement_scan_info_handle,
        name: *mut duckdb_v2_qname_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Claims the reference by naming a table function to read instead.\n\n Arguments to the function are added with `duckdb_v2_replacement_scan_add_argument()` and\n `duckdb_v2_replacement_scan_add_named_argument()`. The name is borrowed and copied, and its parts are matched\n case-insensitively. A qualified name targets a function in a particular schema or catalog, exactly as writing it out\n in SQL would. The name is not resolved here: an unknown function fails later, when the replacement is bound. Calling\n this again replaces the previous name and keeps the arguments added so far.\n\n The three claim forms, `duckdb_v2_replacement_scan_set_function_name()`,\n `duckdb_v2_replacement_scan_set_collection()` and `duckdb_v2_replacement_scan_set_subquery()`, are mutually\n exclusive: claiming the reference through a second, different form results in an error.\n\n history:\n - unstable: v2.0.0\n\n @param info The info handle.\n @param name The table function to read instead. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_replacement_scan_set_function_name(
        info: duckdb_v2_replacement_scan_info_handle,
        name: duckdb_v2_qname_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Appends a positional argument to the claimed table function.\n\n Positional arguments are passed in the order they are added, before any named ones. The value is borrowed and copied,\n so the caller may destroy it after the call. Requires `duckdb_v2_replacement_scan_set_function_name()` to have been\n called first; otherwise the call results in an error.\n\n history:\n - unstable: v2.0.0\n\n @param info The info handle.\n @param value The argument value. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_replacement_scan_add_argument(
        info: duckdb_v2_replacement_scan_info_handle,
        value: duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Appends a named argument to the claimed table function.\n\n Equivalent to writing `name := value` at the call site. The name and the value are borrowed and copied, so the caller\n may destroy the value after the call. Requires `duckdb_v2_replacement_scan_set_function_name()` to have been called\n first; otherwise the call results in an error.\n\n history:\n - unstable: v2.0.0\n\n @param info The info handle.\n @param name The name of the parameter to bind the value to. Borrowed and copied.\n @param value The argument value. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_replacement_scan_add_named_argument(
        info: duckdb_v2_replacement_scan_info_handle,
        name: *const duckdb_v2_identifier_t,
        value: duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Claims the reference by naming a column data collection to read instead.\n\n The collection is borrowed, not copied: the caller keeps ownership and must keep it alive, and must not clear, reset\n or destroy it, for as long as any result reading it is live, since the result scans its buffers directly.\n\n A prepared statement extends that lifetime well beyond its own results. Preparing a statement over a claimed name\n captures the borrow in the plan, and since a collection claim reads no database there is nothing to invalidate that\n plan: `duckdb_v2_prepared_statement_reuses_plan()` reports true, and every later execution reuses the captured borrow\n without consulting the callback again. So dropping the name from whatever the callback resolves against does not\n release the collection, and releasing it while such a statement is live leaves the next execution reading freed\n memory. Destroy every prepared statement over a claimed name before clearing, resetting or destroying the collection\n behind it.\n\n By default the collection's columns are named col1..colN. Pass `column_names` to name them instead. When supplied,\n `column_count` must equal the collection's column count and no name may be empty; pass NULL and 0 for the default\n names.\n\n The three claim forms, `duckdb_v2_replacement_scan_set_function_name()`,\n `duckdb_v2_replacement_scan_set_collection()` and `duckdb_v2_replacement_scan_set_subquery()`, are mutually\n exclusive: claiming the reference through a second, different form results in an error.\n\n history:\n - unstable: v2.0.0\n\n @param info The info handle.\n @param collection The collection to read instead. Borrowed; the caller keeps ownership and must keep it alive.\n @param column_names Optional. An array of `column_count` column names, in order. Pass NULL for the default names\n col1..colN.\n @param column_count The number of names in `column_names`. Must equal the collection's column count, or 0 for the\n default names.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_replacement_scan_set_collection(
        info: duckdb_v2_replacement_scan_info_handle,
        collection: duckdb_v2_column_data_collection_handle,
        column_names: *const duckdb_v2_identifier_t,
        column_count: idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Claims the reference by naming a query to read instead.\n\n The text is parsed at the call and must contain exactly one SELECT statement: a syntax error, several statements or a\n statement of another kind results in an error. The text is borrowed for the call only. Prefer\n `duckdb_v2_replacement_scan_set_function_name()` when a single table function call suffices, as it avoids the parse\n and keeps the plan flatter.\n\n The three claim forms, `duckdb_v2_replacement_scan_set_function_name()`,\n `duckdb_v2_replacement_scan_set_collection()` and `duckdb_v2_replacement_scan_set_subquery()`, are mutually\n exclusive: claiming the reference through a second, different form results in an error.\n\n history:\n - unstable: v2.0.0\n\n @param info The info handle.\n @param sql The SELECT statement to read instead. Borrowed for the call only.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_replacement_scan_set_subquery(
        info: duckdb_v2_replacement_scan_info_handle,
        sql: *const duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the alias the claimed replacement is bound under.\n\n Optional, and independent of the claim form. An alias written in the query takes precedence over this one; without\n either, the table name of the reference is used, which for a file-backed reference is the path. The alias is borrowed\n and copied.\n\n history:\n - unstable: v2.0.0\n\n @param info The info handle.\n @param alias The alias to bind the replacement under. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_replacement_scan_set_alias(
        info: duckdb_v2_replacement_scan_info_handle,
        alias: *const duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the replacement scan, making it consulted for names the catalog cannot resolve.\n\n The scan is visible only to queries on this connection and is released when the connection is destroyed. It is\n consulted before every instance-wide scan, so it can claim a name that a built-in scan would otherwise take.\n Registration requires a callback. Scans are consulted in registration order within their scope, connection-scoped\n ones before instance-wide ones, and the first to claim a name wins. A scan cannot be registered twice, and a\n registered scan cannot be unregistered: it lives until its scope ends. The scan must have been created through a\n factory of the same database. The caller still owns the handle after registration and must destroy it with\n `duckdb_v2_replacement_scan_destroy()`, which does not affect the registered scan.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection to register on.\n @param scan The replacement scan to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_register_replacement_scan(
        conn: duckdb_v2_connection_handle,
        scan: duckdb_v2_replacement_scan_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the replacement scan, making it consulted for names the catalog cannot resolve.\n\n The scan is visible to every connection to the instance and lives until the instance is destroyed. Registering it\n while queries are binding on other connections is not thread-safe: register before issuing queries. Registration\n requires a callback. Scans are consulted in registration order within their scope, connection-scoped ones before\n instance-wide ones, and the first to claim a name wins. A scan cannot be registered twice, and a registered scan\n cannot be unregistered: it lives until its scope ends. The scan must have been created through a factory of the same\n database. The caller still owns the handle after registration and must destroy it with\n `duckdb_v2_replacement_scan_destroy()`, which does not affect the registered scan.\n\n history:\n - unstable: v2.0.0\n\n @param instance The instance to register on.\n @param scan The replacement scan to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_instance_register_replacement_scan(
        instance: duckdb_v2_instance_handle,
        scan: duckdb_v2_replacement_scan_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the replacement scan, making it consulted for names the catalog cannot resolve.\n\n The scan is visible to every connection to the loading extension's instance and lives until the instance is\n destroyed. Use this from the extension's load callback. Registration requires a callback. Scans are consulted in\n registration order within their scope, connection-scoped ones before instance-wide ones, and the first to claim a\n name wins. A scan cannot be registered twice, and a registered scan cannot be unregistered: it lives until its scope\n ends. The scan must have been created through a factory of the same database. The caller still owns the handle after\n registration and must destroy it with `duckdb_v2_replacement_scan_destroy()`, which does not affect the registered\n scan.\n\n history:\n - unstable: v2.0.0\n\n @param extension The loading extension.\n @param scan The replacement scan to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_extension_register_replacement_scan(
        extension: duckdb_v2_extension_handle,
        scan: duckdb_v2_replacement_scan_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the replacement scan, releasing its resources.\n\n Null-safe: passing a null pointer or null handle is a no-op. The handle is set to null on return to prevent\n double-destruction. Destroying the handle after registration does not affect the registered scan.\n\n history:\n - unstable: v2.0.0\n\n @param scan The scan to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_replacement_scan_destroy(scan: *mut duckdb_v2_replacement_scan_handle) -> DUCKDB_V2_ERROR;
}
#[doc = " An owned opaque handle to a custom scalar function being built. Created with `duckdb_v2_scalar_function_create()`,\n configured with the setter functions (e.g. `duckdb_v2_scalar_function_set_name()`,\n `duckdb_v2_scalar_function_set_exec_callback()`, etc.) and the signature obtained via\n `duckdb_v2_scalar_function_get_signature()`, made available with `duckdb_v2_connection_register_scalar_function()` or\n `duckdb_v2_extension_register_scalar_function()`, and destroyed with `duckdb_v2_scalar_function_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_scalar_function {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned opaque handle to a custom scalar function being built. Created with `duckdb_v2_scalar_function_create()`,\n configured with the setter functions (e.g. `duckdb_v2_scalar_function_set_name()`,\n `duckdb_v2_scalar_function_set_exec_callback()`, etc.) and the signature obtained via\n `duckdb_v2_scalar_function_get_signature()`, made available with `duckdb_v2_connection_register_scalar_function()` or\n `duckdb_v2_extension_register_scalar_function()`, and destroyed with `duckdb_v2_scalar_function_destroy()`."]
pub type duckdb_v2_scalar_function_handle = *mut _duckdb_v2_scalar_function;
#[doc = " A borrowed opaque handle to the result of a scalar function's \"resolve types\" phase. The \"resolve types\" callback\n receives this handle next to a `duckdb_v2_function_bind_info_handle`, which gives access to the arguments and the\n user data, and can use it to set the return type of the call site being bound."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_scalar_function_resolve_types_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the result of a scalar function's \"resolve types\" phase. The \"resolve types\" callback\n receives this handle next to a `duckdb_v2_function_bind_info_handle`, which gives access to the arguments and the\n user data, and can use it to set the return type of the call site being bound."]
pub type duckdb_v2_scalar_function_resolve_types_info_handle = *mut _duckdb_v2_scalar_function_resolve_types_info;
#[doc = " A borrowed opaque handle to the result of a scalar function's \"bind\" phase. The \"bind\" callback receives this handle\n next to a `duckdb_v2_function_bind_info_handle`, which gives access to the arguments and the user data, and can use\n it to set the bind data of the call site being bound."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_scalar_function_bind_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the result of a scalar function's \"bind\" phase. The \"bind\" callback receives this handle\n next to a `duckdb_v2_function_bind_info_handle`, which gives access to the arguments and the user data, and can use\n it to set the bind data of the call site being bound."]
pub type duckdb_v2_scalar_function_bind_info_handle = *mut _duckdb_v2_scalar_function_bind_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a scalar function during the local state initialization \"init\"\n phase. The \"init\" callback receives this handle and can use it to e.g. set up local state reusable across invocations\n of the \"exec\" execution callback."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_scalar_function_init_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a scalar function during the local state initialization \"init\"\n phase. The \"init\" callback receives this handle and can use it to e.g. set up local state reusable across invocations\n of the \"exec\" execution callback."]
pub type duckdb_v2_scalar_function_init_info_handle = *mut _duckdb_v2_scalar_function_init_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a scalar function during the execution \"exec\" phase. The \"exec\"\n callback receives this handle and can use it to e.g. access the input argument vectors, retrieve the number of rows\n to process, and write results to the output vector."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_scalar_function_exec_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a scalar function during the execution \"exec\" phase. The \"exec\"\n callback receives this handle and can use it to e.g. access the input argument vectors, retrieve the number of rows\n to process, and write results to the output vector."]
pub type duckdb_v2_scalar_function_exec_info_handle = *mut _duckdb_v2_scalar_function_exec_info;
pub type duckdb_v2_scalar_function_resolve_types_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_function_bind_info_handle,
        result: duckdb_v2_scalar_function_resolve_types_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_scalar_function_bind_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_function_bind_info_handle,
        result: duckdb_v2_scalar_function_bind_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_scalar_function_init_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_scalar_function_init_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_scalar_function_exec_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_scalar_function_exec_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
unsafe extern "C" {
    #[doc = " Creates a new scalar function through a factory.\n\n The function starts out empty: configure it with the setter functions (e.g. `duckdb_v2_scalar_function_set_name()`,\n `duckdb_v2_scalar_function_set_exec_callback()`, etc.) and the signature obtained via\n `duckdb_v2_scalar_function_get_signature()`, then make it available with\n `duckdb_v2_connection_register_scalar_function()` or `duckdb_v2_extension_register_scalar_function()`. The caller\n owns the returned handle and must destroy it with `duckdb_v2_scalar_function_destroy()`, also after registration.\n\n The scalar function can only be registered on the database the factory belongs to.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create the scalar function through.\n @param function On success, receives the newly created scalar function. Owned by the caller.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_create(
        factory: duckdb_v2_factory_handle,
        function: *mut duckdb_v2_scalar_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the name of the scalar function.\n\n The name is borrowed and copied. Calling this again replaces the previous name. A name must be set before\n registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the name of.\n @param name The name to set. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_set_name(
        function: duckdb_v2_scalar_function_handle,
        name: *const duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the documentation of the function so it can be filled in.\n\n Set a description with `duckdb_v2_function_docs_set_description()`, and add examples and categories with\n `duckdb_v2_function_docs_add_example()` and `duckdb_v2_function_docs_add_category()`. The documentation is modified\n in place, describes this overload only, and is registered with the function. Optional.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to get the documentation of.\n @param docs The returned documentation. Borrowed and valid for the lifetime of the function handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_get_docs(
        function: duckdb_v2_scalar_function_handle,
        docs: *mut duckdb_v2_function_docs_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the function's signature so it can be configured.\n\n Add parameters with `duckdb_v2_function_signature_add_parameter()` and set the return type with\n `duckdb_v2_function_signature_set_return_type()`. The signature is modified in place; the function must be given a\n signature with a return type before registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to get the signature of.\n @param sig The returned signature. Borrowed and valid for the lifetime of the function handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_get_signature(
        function: duckdb_v2_scalar_function_handle,
        sig: *mut duckdb_v2_function_signature_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets arbitrary user data on the scalar function.\n\n Associates an opaque pointer with the function, retrievable from the callbacks via\n `duckdb_v2_function_bind_get_user_data()`, `duckdb_v2_scalar_function_init_get_user_data()` and\n `duckdb_v2_scalar_function_exec_get_user_data()`. The opaque handle bundles the pointer with an optional destructor,\n invoked when the data is no longer needed.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the user data of.\n @param data Opaque handle bundling the user data pointer plus an optional destructor.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_set_user_data(
        function: duckdb_v2_scalar_function_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets a property on the scalar function.\n\n Configures a function property that influences planning and execution, such as stability, NULL handling, fallibility\n or collation handling. The value must be one of the `DUCKDB_V2_FUNCTION_PROPERTY_VALUE` entries belonging to `key`;\n passing a value that does not belong to the key, or a key that is not valid for scalar functions, results in an\n error.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the property of.\n @param key The property to set.\n @param value The value to set for the property. Must belong to `key`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_set_property(
        function: duckdb_v2_scalar_function_handle,
        key: DUCKDB_V2_FUNCTION_PROPERTY_KEY,
        value: DUCKDB_V2_FUNCTION_PROPERTY_VALUE,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional resolve types callback of the scalar function.\n\n The resolve types callback is invoked during query planning for each call site of the function, before the arguments\n are cast to the parameter types of the signature. Through its `duckdb_v2_function_bind_info_handle` it can inspect\n the argument types as they were passed and constant argument values. Through its\n `duckdb_v2_scalar_function_resolve_types_info_handle` it can set a concrete return type. It cannot set \"bind data\",\n use the bind callback for that.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the resolve types callback of.\n @param callback The resolve types callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_set_resolve_types_callback(
        function: duckdb_v2_scalar_function_handle,
        callback: duckdb_v2_scalar_function_resolve_types_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional bind callback of the scalar function.\n\n The bind callback is invoked during query planning for each call site of the function, after the resolve types\n callback and after the arguments have been cast to the parameter types of the signature. Through its\n `duckdb_v2_function_bind_info_handle` it can inspect the argument types and constant argument values. Through its\n `duckdb_v2_scalar_function_bind_info_handle` it can set \"bind data\" that is shared with the init and exec callbacks.\n It cannot change the types of the call site, use the resolve types callback for that.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the bind callback of.\n @param callback The bind callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_set_bind_callback(
        function: duckdb_v2_scalar_function_handle,
        callback: duckdb_v2_scalar_function_bind_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional init callback of the scalar function.\n\n The init callback is invoked at the start of execution for each thread that will execute the function. It can set\n worker-local \"init data\", retrievable from the exec callback, to keep mutable state across invocations of the\n function.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the init callback of.\n @param callback The init callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_set_init_callback(
        function: duckdb_v2_scalar_function_handle,
        callback: duckdb_v2_scalar_function_init_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the exec callback of the scalar function.\n\n The exec callback implements the function's logic: it is invoked during query execution with a batch of input rows\n and must fill the result vector. An exec callback must be set before registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the exec callback of.\n @param callback The exec callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_set_exec_callback(
        function: duckdb_v2_scalar_function_handle,
        callback: duckdb_v2_scalar_function_exec_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the concrete return type of the call site being bound.\n\n Overrides the return type declared in the signature. Register the function with an ANY return type and set the\n concrete type here, derived from the argument types, to build a function whose result type depends on its input. The\n type is borrowed and copied.\n\n history:\n - unstable: v2.0.0\n\n @param info The resolve types info handle.\n @param return_type The return type to set. Borrowed for the call only.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_resolve_types_set_return_type(
        info: duckdb_v2_scalar_function_resolve_types_info_handle,
        return_type: duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the function's \"bind data\" from the bind callback.\n\n The bind data is stored with the bound call site and retrievable from the init and exec callbacks. The opaque handle\n bundles the pointer with an optional destructor, invoked when the bind data is no longer needed, and an optional\n equality callback used when comparing two bound call sites; without one, pointer equality is used. Scalar functions\n set their bind data through this function, `duckdb_v2_function_bind_set_bind_data()` is not available to them.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param data Opaque handle bundling the bind data pointer plus optional destructor and equality callbacks.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_bind_set_bind_data(
        info: duckdb_v2_scalar_function_bind_info_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_scalar_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The init info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_init_get_user_data(
        info: duckdb_v2_scalar_function_init_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The init info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_init_get_bind_data(
        info: duckdb_v2_scalar_function_init_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the function's worker-local \"init data\" from the init callback.\n\n The init data is associated with the executing thread for the duration of the query and retrievable from the exec\n callback via `duckdb_v2_scalar_function_exec_get_init_data()`. The opaque handle bundles the pointer with an optional\n destructor, invoked when the init data is no longer needed.\n\n history:\n - unstable: v2.0.0\n\n @param info The init info handle.\n @param data Opaque handle bundling the init data pointer plus an optional destructor.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_init_set_init_data(
        info: duckdb_v2_scalar_function_init_info_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_scalar_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_exec_get_user_data(
        info: duckdb_v2_scalar_function_exec_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_exec_get_bind_data(
        info: duckdb_v2_scalar_function_exec_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the worker-local init data set by the function's init callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param data Receives the init data pointer for the executing thread, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_exec_get_init_data(
        info: duckdb_v2_scalar_function_exec_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns how many rows this execution must produce. The exec callback must write exactly this many rows to the result\n vector. Note that this may be less than a full vector: with all-constant arguments the function is invoked for a\n single row and the result is expanded by the engine.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param count Receives the number of rows.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_exec_get_row_count(
        info: duckdb_v2_scalar_function_exec_info_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns how many argument vectors this invocation carries, split into the four parts of the argument list.\n\n The parts and their order are those the bind callback saw through `duckdb_v2_function_bind_get_arg_count()`, and the\n vectors are at the same indices. Valid indices for `duckdb_v2_scalar_function_exec_get_arg()` are [0, the sum of the\n four counts). Every out-parameter may be NULL, in which case nothing is written to it.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param positional_fixed Optional. Receives the number of positional-only and standard parameters.\n @param positional_variadic Optional. Receives the number of arguments `*args` received, 0 when the signature has\n none.\n @param named_fixed Optional. Receives the number of named-only parameters.\n @param named_variadic Optional. Receives the number of arguments `**kwargs` received, 0 when the signature has none.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_exec_get_arg_count(
        info: duckdb_v2_scalar_function_exec_info_handle,
        positional_fixed: *mut idx_t,
        positional_variadic: *mut idx_t,
        named_fixed: *mut idx_t,
        named_variadic: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the argument vector at the given index.\n\n The index is the one the bind callback used for the argument, e.g. the index\n `duckdb_v2_function_bind_get_arg_index()` found for a name. The vector holds the argument's values for the current\n batch; use `duckdb_v2_scalar_function_exec_get_row_count()` for the number of rows. Fails if the index is out of\n bounds. Borrowed; valid only for the duration of the callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param index The index of the argument.\n @param vector Receives the borrowed argument vector.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_exec_get_arg(
        info: duckdb_v2_scalar_function_exec_info_handle,
        index: idx_t,
        vector: *mut duckdb_v2_vector_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the result vector the exec callback must write into.\n\n The callback must write one entry per input row; use `duckdb_v2_scalar_function_exec_get_row_count()` for the number\n of rows. Borrowed; valid only for the duration of the callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param vector Receives the borrowed result vector to write into.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_exec_get_result(
        info: duckdb_v2_scalar_function_exec_info_handle,
        vector: *mut duckdb_v2_vector_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the scalar function, making it available for use in SQL queries.\n\n The function is registered on the connection's database, visible to every connection, in the connection's\n transaction: inside an explicit transaction, it is invisible to other connections until the transaction commits, and\n a rollback undoes it. Registration requires a name, an exec callback, and a signature with a complete return type; an\n ANY return type is accepted only together with a resolve types callback that sets the concrete type per call site.\n The scalar function must have been created through a factory of the same database. The caller still owns the handle\n after registration and must destroy it with `duckdb_v2_scalar_function_destroy()`, which does not affect the\n registered function.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection to register on.\n @param function The scalar function to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_register_scalar_function(
        conn: duckdb_v2_connection_handle,
        function: duckdb_v2_scalar_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the scalar function, making it available for use in SQL queries.\n\n The function is registered on the loading extension's database and attributed to the extension. Use this from the\n extension's load callback. Registration requires a name, an exec callback, and a signature with a complete return\n type; an ANY return type is accepted only together with a resolve types callback that sets the concrete type per call\n site. The scalar function must have been created through a factory of the same database. The caller still owns the\n handle after registration and must destroy it with `duckdb_v2_scalar_function_destroy()`, which does not affect the\n registered function.\n\n history:\n - unstable: v2.0.0\n\n @param extension The loading extension.\n @param function The scalar function to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_extension_register_scalar_function(
        extension: duckdb_v2_extension_handle,
        function: duckdb_v2_scalar_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the scalar function, releasing its resources.\n\n Null-safe: passing a null pointer or null handle is a no-op. The handle is set to null on return to prevent\n double-destruction. Destroying the handle after registration does not affect the registered function.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_scalar_function_destroy(function: *mut duckdb_v2_scalar_function_handle) -> DUCKDB_V2_ERROR;
}
#[repr(u32)]
#[non_exhaustive]
#[doc = "! SQL statement type of a parsed statement or an executed query."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_STATEMENT_TYPE {
    DUCKDB_V2_STATEMENT_TYPE_INVALID = 0,
    DUCKDB_V2_STATEMENT_TYPE_SELECT = 1,
    DUCKDB_V2_STATEMENT_TYPE_INSERT = 2,
    DUCKDB_V2_STATEMENT_TYPE_UPDATE = 3,
    DUCKDB_V2_STATEMENT_TYPE_CREATE = 4,
    DUCKDB_V2_STATEMENT_TYPE_DELETE = 5,
    DUCKDB_V2_STATEMENT_TYPE_PREPARE = 6,
    DUCKDB_V2_STATEMENT_TYPE_EXECUTE = 7,
    DUCKDB_V2_STATEMENT_TYPE_ALTER = 8,
    DUCKDB_V2_STATEMENT_TYPE_TRANSACTION = 9,
    DUCKDB_V2_STATEMENT_TYPE_COPY = 10,
    DUCKDB_V2_STATEMENT_TYPE_ANALYZE = 11,
    DUCKDB_V2_STATEMENT_TYPE_VARIABLE_SET = 12,
    DUCKDB_V2_STATEMENT_TYPE_CREATE_FUNC = 13,
    DUCKDB_V2_STATEMENT_TYPE_EXPLAIN = 14,
    DUCKDB_V2_STATEMENT_TYPE_DROP = 15,
    DUCKDB_V2_STATEMENT_TYPE_EXPORT = 16,
    DUCKDB_V2_STATEMENT_TYPE_PRAGMA = 17,
    DUCKDB_V2_STATEMENT_TYPE_VACUUM = 18,
    DUCKDB_V2_STATEMENT_TYPE_CALL = 19,
    DUCKDB_V2_STATEMENT_TYPE_SET = 20,
    DUCKDB_V2_STATEMENT_TYPE_LOAD = 21,
    DUCKDB_V2_STATEMENT_TYPE_RELATION = 22,
    DUCKDB_V2_STATEMENT_TYPE_EXTENSION = 23,
    DUCKDB_V2_STATEMENT_TYPE_LOGICAL_PLAN = 24,
    DUCKDB_V2_STATEMENT_TYPE_ATTACH = 25,
    DUCKDB_V2_STATEMENT_TYPE_DETACH = 26,
    DUCKDB_V2_STATEMENT_TYPE_MULTI = 27,
    DUCKDB_V2_STATEMENT_TYPE_COPY_DATABASE = 28,
    DUCKDB_V2_STATEMENT_TYPE_UPDATE_EXTENSIONS = 29,
    DUCKDB_V2_STATEMENT_TYPE_MERGE_INTO = 30,
    DUCKDB_V2_STATEMENT_TYPE_CONNECT = 31,
    DUCKDB_V2_STATEMENT_TYPE_DISCONNECT = 32,
    DUCKDB_V2_STATEMENT_TYPE_EXTERNAL_RESOURCE = 33,
    DUCKDB_V2_STATEMENT_TYPE_PASSTHROUGH = 34,
    DUCKDB_V2_STATEMENT_TYPE_MAX_ENUM = 2147483647,
}
#[doc = " An opaque, owned handle to a single parsed SQL statement, produced by statement_iterator_next. statement_execute runs\n it without consuming it; the caller always destroys it via sql_statement_destroy."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_sql_statement {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An opaque, owned handle to a single parsed SQL statement, produced by statement_iterator_next. statement_execute runs\n it without consuming it; the caller always destroys it via sql_statement_destroy."]
pub type duckdb_v2_sql_statement_handle = *mut _duckdb_v2_sql_statement;
#[doc = " An opaque, owned handle to an iterator over the statements of a SQL string, produced by parse_sql. Destroy it via\n statement_iterator_destroy; statements it already yielded are independently owned and unaffected."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_statement_iterator {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An opaque, owned handle to an iterator over the statements of a SQL string, produced by parse_sql. Destroy it via\n statement_iterator_destroy; statements it already yielded are independently owned and unaffected."]
pub type duckdb_v2_statement_iterator_handle = *mut _duckdb_v2_statement_iterator;
unsafe extern "C" {
    #[doc = " Parses a SQL string into an iterator over its statements.\n\n Parses and nothing more: no binding, no catalog access, no transaction. The connection supplies the parser options\n and parser extensions, and is not otherwise touched. Statements are raw parser output; statement-level rewrites\n happen inside statement_execute. The SQL string is copied, so the caller may free it once this call returns. An input\n with no statements — empty, whitespace, or separators only — yields an iterator that is immediately exhausted.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection supplying the parser configuration.\n @param sql Null-terminated SQL string; may contain any number of statements.\n @param out_iterator Receives the new iterator handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_parse_sql(
        conn: duckdb_v2_connection_handle,
        sql: *const ::std::os::raw::c_char,
        out_iterator: *mut duckdb_v2_statement_iterator_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Yields the next statement, or NULL when exhausted.\n\n On success *out_statement receives the next owned statement, or NULL once the iterator is exhausted — repeatedly, so\n calling again is harmless. A parse error within the input surfaces no later than the call that reaches the failing\n statement: an implementation that parses eagerly reports it from parse_sql instead and yields no statements at all,\n while an incremental one yields the statements ahead of the failure first. On failure *out_statement is set to NULL.\n\n history:\n - unstable: v2.0.0\n\n @param iterator The iterator to advance.\n @param out_statement Receives an owned statement, or NULL when the iterator is exhausted.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_statement_iterator_next(
        iterator: duckdb_v2_statement_iterator_handle,
        out_statement: *mut duckdb_v2_sql_statement_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Binds a parsed statement without executing, yielding its schema signature.\n\n Preprocesses and binds the statement exactly as execution would, but runs nothing: the result is the statement's\n signature as two schemas, not a query result. The statement is borrowed, not consumed, so it can be bound as often as\n you like and executed later. out_schema receives the output schema (result columns) and is never empty, since a\n non-SELECT reports a single status column: a BIGINT changed-rows count, or a BOOLEAN success. out_parameters, when\n non-NULL, receives the input schema (parameter types, ordered by binding index). Both are owned; destroy them via\n schema_destroy.\n\n Binding is read-only and does not disturb a live result: it begins no query, claims no cursor, reuses an active\n transaction read-only, and runs alongside a paused stream. It is single-consumer like the stepping functions, so bind\n concurrently only on a second connection. Prepare-time errors — binder, catalog, preprocessing — surface here. A\n statement that expands into a group (a dynamic PIVOT, or statement-expanding DDL such as ALTER ADD COLUMN with a\n non-constant DEFAULT) has a schema known only at execution, and is reported with ERROR_INPUT_METADATA_DEFERRED;\n execute it instead.\n\n *out_schema and *out_parameters are set to NULL on failure.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection supplying the catalog, transaction, and parser configuration.\n @param statement The statement to bind. Borrowed; not consumed.\n @param out_schema Receives the owned output schema (result columns). Destroy via schema_destroy.\n @param out_parameters Optional. When non-NULL, receives the owned input schema (parameter types, ordered by binding\n index). Destroy via schema_destroy.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_statement_bind(
        conn: duckdb_v2_connection_handle,
        statement: duckdb_v2_sql_statement_handle,
        out_schema: *mut duckdb_v2_schema_handle,
        out_parameters: *mut duckdb_v2_schema_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Binds a column data collection to the statement under a name.\n\n Makes the collection visible to the statement as a table named `name`, by adding a common table expression to the\n parsed statement. The statement can then be bound, prepared or executed as usual; each execution reads the\n collection's contents at that moment, so a prepared statement can be executed again after the collection was cleared\n and refilled. Supported statement types are SELECT, INSERT, UPDATE, DELETE and MERGE INTO; any other type is rejected\n with `ERROR_INPUT_INVALID`.\n\n A name the statement already defines as a common table expression, in its SQL text or by a prior call, is rejected\n with `ERROR_INPUT_INVALID`. The binding shadows any catalog table named `name`, as a common table expression does.\n\n By default the collection's columns are named col1..colN. Pass `column_names` to name them instead; when supplied,\n `column_count` must equal the collection's column count. Pass NULL and 0 for the default names.\n\n The collection is borrowed: the caller keeps ownership and must keep it alive, and must not clear, reset or destroy\n it, for as long as the statement, any statement copied or prepared from it, or any result executing it is live. An\n empty collection is a valid binding. Several collections can be bound under distinct names.\n\n history:\n - unstable: v2.0.0\n\n @param statement The statement to bind the collection to. Modified in place.\n @param name The non-empty name the statement refers to the collection by. Borrowed and copied.\n @param collection The collection to bind. Borrowed; the caller keeps ownership and must keep it alive.\n @param column_names Optional. An array of `column_count` names for the collection's columns, in order. Pass NULL for\n col1..colN.\n @param column_count The number of names in `column_names`. 0 for the default names; otherwise the collection's column\n count.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_statement_add_collection(
        statement: duckdb_v2_sql_statement_handle,
        name: *const duckdb_v2_identifier_t,
        collection: duckdb_v2_column_data_collection_handle,
        column_names: *const duckdb_v2_identifier_t,
        column_count: idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the statement's type as classified by the parser.\n\n This gives the type before the statement-level rewrites that `duckdb_v2_statement_execute()` applies, if any. So a\n PRAGMA reports PRAGMA even where execution rewrites it into a SELECT or a CALL.\n `duckdb_v2_result_get_statement_type()` on the executed result reports the rewritten type of a statement that\n rewrites into one. A statement the parser expands into a group reports MULTI, here and on its result. Its parts are\n not visible here, and statement_bind reports ERROR_INPUT_METADATA_DEFERRED for it.\n\n history:\n - unstable: v2.0.0\n\n @param statement The statement.\n @param out_type Receives the statement type.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_sql_statement_get_type(
        statement: duckdb_v2_sql_statement_handle,
        out_type: *mut DUCKDB_V2_STATEMENT_TYPE,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the statement's own SQL text.\n\n The slice of the parsed string that belongs to this statement. A trailing terminator and the whitespace after it are\n included, whitespace and comments before the first token are not. The statement holds its own copy, so the view\n outlives the SQL string passed to parse_sql and the iterator, and stays valid until the statement is destroyed. A\n statement produced by a parser extension that overrides parsing carries whatever text the extension recorded.\n\n history:\n - unstable: v2.0.0\n\n @param statement The statement.\n @param out_text Receives a borrowed view of the statement text, valid until the statement is destroyed.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_sql_statement_get_text(
        statement: duckdb_v2_sql_statement_handle,
        out_text: *mut duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of distinct parameters the statement declares.\n\n This counts the parameters the parser found ($1, ?, $name, ...), so it needs no catalog and no binding; only the\n parameter types wait for `duckdb_v2_statement_bind()`. Repeated uses of one parameter count once.\n\n history:\n - unstable: v2.0.0\n\n @param statement The statement.\n @param out_count Receives the number of distinct parameters.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_sql_statement_get_parameter_count(
        statement: duckdb_v2_sql_statement_handle,
        out_count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows the name of one parameter, in binding order.\n\n Parse-time metadata. Positions follow the parameters' binding indices, the order of `duckdb_v2_statement_bind()`'s\n parameter schema, so position i here names field i there. The name is the binding key that\n `duckdb_v2_statement_execute()` accepts: \"1\", \"2\", ... for a positional parameter ($1 or ?), the identifier for a\n named one ($name). Positional indices may be gapped ($1 and $3 without $2), in which case the names are \"1\" and \"3\"\n at positions 0 and 1. The view is valid until the statement is destroyed. An index outside [0, count) is rejected\n with ERROR_INPUT_OUT_OF_RANGE.\n\n history:\n - unstable: v2.0.0\n\n @param statement The statement.\n @param index Zero-based position in binding order.\n @param out_name Receives a borrowed view of the parameter name, valid until the statement is destroyed.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_sql_statement_get_parameter_name(
        statement: duckdb_v2_sql_statement_handle,
        index: idx_t,
        out_name: *mut duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys a statement handle.\n\n Null-safe: passing nullptr or a slot already set to nullptr is a no-op. statement_execute does not consume a\n statement, so every statement is destroyed here once it is no longer needed. On success the slot is set to nullptr.\n\n history:\n - unstable: v2.0.0\n\n @param statement The statement to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_sql_statement_destroy(statement: *mut duckdb_v2_sql_statement_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys a statement iterator handle.\n\n Null-safe: passing nullptr or a slot already set to nullptr is a no-op. Statements already yielded are independently\n owned and stay valid. On success the slot is set to nullptr.\n\n history:\n - unstable: v2.0.0\n\n @param iterator The iterator to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_statement_iterator_destroy(iterator: *mut duckdb_v2_statement_iterator_handle) -> DUCKDB_V2_ERROR;
}
#[repr(u32)]
#[non_exhaustive]
#[doc = " Internal representation of a vector, with FSST / SEQUENCE / SHREDDED collapsed into OTHER: the view getter rejects\n those and requires an explicit vector_flatten first. OTHER is the 0-value, so a zero-initialized out-param reads as\n \"unspecified, needs flatten\" rather than silently looking like FLAT."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_VECTOR_TYPE {
    #[doc = "! Default for zero-init. Covers FSST / SEQUENCE / SHREDDED — call vector_flatten first."]
    DUCKDB_V2_VECTOR_TYPE_OTHER = 0,
    #[doc = "! Standard per-row storage."]
    DUCKDB_V2_VECTOR_TYPE_FLAT = 1,
    #[doc = "! A single value applies to every row in the vector."]
    DUCKDB_V2_VECTOR_TYPE_CONSTANT = 2,
    #[doc = "! Data + selection vector indirection into another vector."]
    DUCKDB_V2_VECTOR_TYPE_DICTIONARY = 3,
    #[doc = "! Data + selection vector indirection into another vector."]
    DUCKDB_V2_VECTOR_TYPE_MAX_ENUM = 2147483647,
}
unsafe extern "C" {
    #[doc = " Returns the internal representation kind: flat, constant, or dictionary.\n\n Reports VECTOR_TYPE_OTHER for FSST / SEQUENCE / SHREDDED vectors, which must be passed through vector_flatten before\n vector_get_view will read them.\n\n history:\n - unstable: v2.0.0\n\n @param vector The vector.\n @param out_type Receives the representation kind.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_get_vector_type(
        vector: duckdb_v2_vector_handle,
        out_type: *mut DUCKDB_V2_VECTOR_TYPE,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the vector's logical type.\n\n The returned logical type is the same type that was passed to vector_reference, or the type that was set on creation.\n It is caller-owned; destroy it via logical_type_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param vector The vector.\n @param out_type Receives the caller-owned logical type handle. Destroy via logical_type_destroy.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_get_logical_type(
        vector: duckdb_v2_vector_handle,
        out_type: *mut duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reads a vector as a unified view of data, validity, selection, and count.\n\n Populates out_view with borrowed pointers, valid until the owning chunk is destroyed. view.data addresses the\n vector's elements, to be cast to the layout its logical type implies: a typed leaf array for the primitives,\n hugeint_t / uhugeint_t / interval_t for those kinds, bytes for VARCHAR / BLOB / BIT / BIGNUM, list_entry for LIST and\n MAP, and nothing at all for ARRAY / STRUCT / UNION, whose data lives in their children.\n\n DECIMAL and ENUM are typed leaf arrays too, over a storage tier that follows from the type; both mappings are\n contract. A DECIMAL of width <= 4 stores int16, <= 9 int32, <= 18 int64, and <= 38 int128, boundaries inclusive, with\n the width and scale available from logical_type_get_param. An ENUM stores its dictionary indices as uint8 for a\n dictionary of at most 255 entries, uint16 for at most 65535, and uint32 beyond that, boundaries inclusive and an\n empty dictionary uint8; logical_type_get_param resolves an index to its entry.\n\n Rejects VECTOR_TYPE_OTHER; call vector_flatten first.\n\n Reading a DICTIONARY vector has one side effect: the dictionary's underlying child is flattened in place if it is not\n already FLAT. The parent vector stays DICTIONARY, and only the child's storage shape changes, but any pointer\n previously borrowed into that child — from an earlier vector_get_view on a vector aliasing the same buffer, say — is\n invalidated. This is the only mutation vector_get_view performs; compare vector_flatten, which materializes the whole\n vector to FLAT.\n\n history:\n - unstable: v2.0.0\n\n @param vector The vector to read.\n @param out_view Receives the view. Its pointers are borrowed and valid until the owning chunk is destroyed.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_get_view(
        vector: duckdb_v2_vector_handle,
        out_view: *mut duckdb_v2_vector_view,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of elements in the vector.\n\n The size is the number of logical elements the vector represents, which for a nested kind can differ from the size of\n its children. An ARRAY vector of size 10 whose array size is 3, for instance, has 10 logical elements while its\n single child vector has 30.\n\n history:\n - unstable: v2.0.0\n\n @param vector The vector.\n @param out_size Receives the number of elements.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_get_size(
        vector: duckdb_v2_vector_handle,
        out_size: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the number of elements in the vector.\n\n The counterpart of vector_get_size: it declares how many logical elements the vector now holds. It reserves enough\n space for size logical elements.\n\n history:\n - unstable: v2.0.0\n\n @param vector The vector.\n @param size The new number of logical elements.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_set_size(
        vector: duckdb_v2_vector_handle,
        size: idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reads one cell of a vector as an owned value.\n\n The total fallback reader. It reads any logical row of any vector representation without flattening — FLAT, CONSTANT,\n DICTIONARY, and the compressed kinds the view getter rejects — and covers every type kind, including those with no\n committed view layout (today VARIANT and GEOMETRY), where it is the only way to reach a cell.\n\n Each call allocates one owned value, which makes this a single-cell bridge rather than a per-row loop primitive; use\n vector_get_view on hot paths. The row index is logical and bounds-checked against vector_get_size. The returned value\n is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param vector The vector to read from.\n @param row The logical row index, in [0, vector_get_size).\n @param out_value Receives the owned cell value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_get_value(
        vector: duckdb_v2_vector_handle,
        row: idx_t,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Writes one cell of a FLAT vector from a value.\n\n The total fallback writer. It covers every type kind, including those with no committed view layout (today VARIANT\n and GEOMETRY), where it is the only way to write a cell. The value is borrowed and copied in, then cast to the\n vector's type through the non-strict default cast; a cast failure surfaces from the call. A NULL value clears the\n row's validity.\n\n Requires a FLAT vector: constant, dictionary, and compressed representations are not row-addressable, so call\n vector_flatten first. Each call performs one value write, which makes this a single-cell bridge rather than a per-row\n loop primitive; use the typed mutable-data paths on hot paths. The row index is logical and bounds-checked against\n vector_get_size.\n\n history:\n - unstable: v2.0.0\n\n @param vector The vector to write to.\n @param row The logical row index, in [0, vector_get_size).\n @param value The borrowed value to write. Copied in; cast to the vector's type.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_set_value(
        vector: duckdb_v2_vector_handle,
        row: idx_t,
        value: duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns a mutable pointer to the data of a FLAT or CONSTANT vector.\n\n Any other representation returns ERROR_INPUT_INVALID. The pointer is valid until the owning chunk is destroyed, and\n the vector's storage shape must not change — through a flatten, say — while it is in use.\n\n When writing VARCHAR values, the caller must ensure that the bytes contain valid UTF-8.\n\n history:\n - unstable: v2.0.0\n\n @param vector The vector.\n @param out_data Receives a mutable pointer to the data.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_get_data_mutable(
        vector: duckdb_v2_vector_handle,
        out_data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Forces a vector into FLAT representation, in place.\n\n A no-op for a vector that is already FLAT. For a CONSTANT, DICTIONARY, FSST, SEQUENCE, or SHREDDED vector it\n materializes the per-row data and switches the representation to FLAT. Call it before vector_get_view if you would\n rather not handle CONSTANT and DICTIONARY semantics in the view; it is required for any vector reporting\n VECTOR_TYPE_OTHER.\n\n history:\n - unstable: v2.0.0\n\n @param vector The vector to flatten.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_flatten(
        vector: duckdb_v2_vector_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Casts every row of a vector into another vector, using a factory.\n\n The conversion is the one SQL `CAST` / `TRY_CAST` performs, registered custom casts included, from the type of\n `source` to the type of `target`. It covers as many rows as `source` holds (`duckdb_v2_vector_get_size()`), of any\n representation. `target` is replaced by the result, as `duckdb_v2_vector_reference()` would, taking its size: data\n and views taken from it beforehand do not survive the call, and nothing it held before carries over. In\n CAST_MODE_NORMAL a row that does not convert fails the call with the engine's conversion error, and the contents of\n `target` are unspecified. In CAST_MODE_TRY such rows are NULL in `target` instead and the call succeeds; compare the\n validity of `source` and `target` to find them. `cast_err` then receives the conversion error of one of them, e.g. to\n report why the cast did not convert every row.\n\n A connection's or callback's factory casts with that client's cast functions and settings (e.g. TimeZone). An\n instance's factory supports only the built-in casts, with default settings. `source` and `target` must be different\n vectors; `target` is typically a vector of a data chunk created by the caller, or the result vector of a callback.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory supplying the cast functions.\n @param source The vector to cast. Borrowed for the call only.\n @param target The vector to write the cast rows into. Its logical type is the target type.\n @param mode Whether a row that does not convert fails the call, or becomes NULL.\n @param out_converted Optional. Receives whether every row converted. Always true when a CAST_MODE_NORMAL cast\n succeeds.\n @param cast_err Optional. When a CAST_MODE_TRY cast succeeds without converting every row, receives an opaque info\n handle with the conversion error of one row that did not convert, which the caller must destroy via\n error_info_destroy. Otherwise receives NULL.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_cast(
        factory: duckdb_v2_factory_handle,
        source: duckdb_v2_vector_handle,
        target: duckdb_v2_vector_handle,
        mode: DUCKDB_V2_CAST_MODE,
        out_converted: *mut bool,
        cast_err: *mut duckdb_v2_error_info_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Repoints a vector at another vector's data, without copying.\n\n `vector` takes on the storage of `source`: no data moves, and the two alias the same buffers until one of them is\n reset or re-referenced. Works for any type, including nested types. The source's logical type must equal the\n vector's; a mismatch returns ERROR_INPUT_INVALID. The source's data must outlive every read of `vector`. Use it to\n hand an already-materialized vector straight to an output vector without a per-row copy.\n\n history:\n - unstable: v2.0.0\n\n @param vector The vector to repoint at the source's data.\n @param source The vector whose data to reference. Its logical type must equal the vector's.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_reference(
        vector: duckdb_v2_vector_handle,
        source: duckdb_v2_vector_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Turns the vector into a CONSTANT vector holding the given value.\n\n Afterwards the vector holds a single element that applies to every logical row; write it through\n vector_get_data_mutable, which returns a pointer to that one element. For a STRUCT vector the change propagates to\n every child. The value's logical type must equal the vector's; a mismatch returns ERROR_INPUT_INVALID.\n\n history:\n - unstable: v2.0.0\n\n @param vector The vector to make constant.\n @param value The value every row takes. Its logical type must equal the vector's.\n @param count The number of elements in the vector.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_make_constant(
        vector: duckdb_v2_vector_handle,
        value: duckdb_v2_value_handle,
        count: idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets a vector to a SEQUENCE representation.\n\n Afterwards the vector represents the arithmetic sequence start, start+increment, start+2*increment, ... over count\n elements. No data pointer is involved; the three parameters describe the sequence completely.\n\n history:\n - unstable: v2.0.0\n\n @param vector The vector to turn into a sequence.\n @param start The first value of the sequence.\n @param increment The step between consecutive values.\n @param count The number of elements in the sequence.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_make_sequence(
        vector: duckdb_v2_vector_handle,
        start: i64,
        increment: i64,
        count: idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets one row of a FLAT vector to NULL, nested children included.\n\n Clears the row's validity and broadcasts the NULL recursively to every descendant element under that row — STRUCT\n fields, and ARRAY elements strided by the array size — maintaining DuckDB's nested NULL invariant: when a STRUCT or\n ARRAY row is NULL, every descendant element under it must be NULL too. LIST children are left untouched, since their\n consumers gate on the list's own validity. Which kinds propagate is normative DuckDB behavior that evolves with the\n type system, which makes this the total NULL write path: equivalent to vector_set_value with a NULL value, without\n the per-call value allocation.\n\n Requires a FLAT vector: constant, dictionary, and compressed representations are not row-addressable, so call\n vector_flatten first. The row index is logical and bounds-checked against vector_get_size.\n\n history:\n - unstable: v2.0.0\n\n @param vector The vector to write to.\n @param row The logical row index, in [0, vector_get_size).\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_set_null(
        vector: duckdb_v2_vector_handle,
        row: idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns a mutable pointer to the validity mask of a FLAT vector.\n\n Allocates the mask on first use, so the returned pointer is always non-null. Each uint64_t word covers 64 rows: bit N\n of word W is row W*64+N. A set bit means valid; a cleared bit means NULL.\n\n A raw mask write marks only this vector's rows. Clearing a STRUCT or ARRAY parent bit leaves the descendant elements\n untouched, which violates DuckDB's nested NULL invariant — a NULL STRUCT or ARRAY row requires NULL descendants — so\n set nested rows NULL through vector_set_null instead. When writing nested masks raw anyway, invalidate the child\n masks up front and mark elements valid as the values are written.\n\n history:\n - unstable: v2.0.0\n\n @param vector The vector.\n @param out_validity Receives a mutable pointer to the validity mask.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_flat_get_validity_mutable(
        vector: duckdb_v2_vector_handle,
        out_validity: *mut *mut u64,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the validity of a CONSTANT vector.\n\n A constant vector holds a single element, so one flag decides whether every row reads as the value or as NULL.\n\n history:\n - unstable: v2.0.0\n\n @param vector The constant vector.\n @param validity True to mark the vector's single element valid, false to mark it NULL.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_constant_set_valid(
        vector: duckdb_v2_vector_handle,
        validity: bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows a string-backed vector's arena for writing.\n\n Allocates the arena on first use. Valid for VARCHAR, BLOB, BIT, and BIGNUM vectors, and returns ERROR_INPUT_INVALID\n for anything else. This call is the single string-ness check, which is why arena_allocate itself performs none. The\n arena is borrowed — never destroy it — and stays valid until the vector is flattened, reallocated, or destroyed.\n\n history:\n - unstable: v2.0.0\n\n @param vector The string-backed vector whose arena to borrow.\n @param out_arena Receives the borrowed arena handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_get_arena(
        vector: duckdb_v2_vector_handle,
        out_arena: *mut duckdb_v2_arena_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of child vectors a nested vector exposes.\n\n 1 for LIST, MAP and ARRAY; the field count for STRUCT; member_count + 1 for UNION, the tag plus the members; and 0\n for any non-nested kind. vector_get_child documents what each index addresses.\n\n history:\n - unstable: v2.0.0\n\n @param vector The vector.\n @param out_count Receives the number of child vectors.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_get_child_count(
        vector: duckdb_v2_vector_handle,
        out_count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Borrows a child vector by index.\n\n What each index addresses, by kind: LIST and ARRAY expose [0] = the elements; MAP [0] = the entries, a STRUCT(key,\n value) whose children are the keys and the values; STRUCT and TUPLE [i] = field i; and UNION [0] = the tag with\n [1..N] = the members. Note that value_get_child diverges on UNION, exposing only the active member.\n\n The returned child is borrowed and lives as long as the owning chunk. Returns ERROR_INPUT_INVALID if the vector has\n no children, or if the index is out of range.\n\n history:\n - unstable: v2.0.0\n\n @param vector The nested vector to descend into.\n @param index The child index, in [0, vector_get_child_count).\n @param out_child Receives the borrowed child vector.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_vector_get_child(
        vector: duckdb_v2_vector_handle,
        index: idx_t,
        out_child: *mut duckdb_v2_vector_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Decodes BIGNUM storage bytes into a caller-supplied magnitude buffer + sign flag.\n\n in_data and in_length are the value's raw storage bytes, exactly as they sit in a vector's bignum payload or as\n value_get_blob reports them for a BIGNUM value. Those bytes are opaque: the storage encoding is not a committed part\n of this API, and this function is the only thing that interprets them.\n\n Writes the big-endian magnitude bytes into out_data and the sign flag into out_is_negative; reconstruct the integer\n as (-1)**out_is_negative * unsigned_big_endian(out_data[0..out_length]). Materializing the bytes is unavoidable,\n since a negative bignum stores its magnitude bit-inverted, but the buffer belongs to the caller: this function never\n allocates and hands back nothing to free.\n\n Pass out_data = NULL to size the buffer without decoding. out_length then receives the exact number of magnitude\n bytes and out_is_negative the sign, and out_capacity is ignored. The size comes straight out of the storage header,\n so the query is O(1) and exact — a size call followed by a decode call never needs a retry loop.\n\n With out_data != NULL, out_capacity must be at least out_length bytes, or the call returns ERROR_INPUT_OBJECT_SIZE\n with out_length set to the required size and out_data left untouched. On success exactly out_length bytes are\n written, and the rest of the buffer is not modified.\n\n Returns ERROR_INPUT_INVALID if in_data is NULL, or if in_length is too short to hold a bignum header.\n\n history:\n - unstable: v2.0.0\n\n @param in_data The value's raw BIGNUM storage bytes.\n @param in_length Size of in_data in bytes.\n @param out_data Caller-owned buffer receiving the magnitude bytes, or NULL to only report the required size in\n out_length.\n @param out_capacity Bytes available in out_data. Ignored when out_data is NULL.\n @param out_length Receives the magnitude size in bytes, written on success and on ERROR_INPUT_OBJECT_SIZE.\n @param out_is_negative Receives true if the value is negative, false otherwise.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_bignum_decode(
        in_data: *const u8,
        in_length: idx_t,
        out_data: *mut u8,
        out_capacity: idx_t,
        out_length: *mut idx_t,
        out_is_negative: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Encodes a magnitude + sign flag into BIGNUM storage bytes.\n\n The inverse of bignum_decode. in_data and in_length are the big-endian magnitude bytes and is_negative the sign;\n out_data receives the raw storage bytes for that integer, in the form a BIGNUM vector payload expects. Those bytes\n are opaque: the storage encoding is not a committed part of this API.\n\n Pass out_data = NULL to size the buffer without encoding. out_length then receives the exact number of storage bytes,\n and out_capacity is ignored. The size is a fixed function of in_length, so the query is O(1) and exact.\n\n With out_data != NULL, out_capacity must be at least out_length bytes, or the call returns ERROR_INPUT_OBJECT_SIZE\n with out_length set to the required size and out_data left untouched. On success exactly out_length bytes are\n written, and the rest of the buffer is not modified.\n\n The magnitude must be canonical, matching what bignum_decode produces: in_length >= 1 with no leading zero bytes, so\n the value zero is the single byte 0x00 with is_negative = false. A NULL in_data, an in_length of 0, a leading zero\n byte, or a negative zero returns ERROR_INPUT_INVALID; a magnitude beyond the maximum bignum width returns\n ERROR_INPUT_OUT_OF_RANGE.\n\n history:\n - unstable: v2.0.0\n\n @param in_data Big-endian magnitude bytes, with no leading zero bytes.\n @param in_length Size of in_data in bytes. Must be >= 1.\n @param is_negative True to encode a negative value.\n @param out_data Caller-owned buffer receiving the storage bytes, or NULL to only report the required size in\n out_length.\n @param out_capacity Bytes available in out_data. Ignored when out_data is NULL.\n @param out_length Receives the storage size in bytes — written on success and on ERROR_INPUT_OBJECT_SIZE.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_bignum_encode(
        in_data: *const u8,
        in_length: idx_t,
        is_negative: bool,
        out_data: *mut u8,
        out_capacity: idx_t,
        out_length: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Validates all text->len bytes as UTF-8, including bytes after embedded NUL characters.\n\n Returns ERROR_INPUT_INVALID if any of:\n - text is NULL.\n - text->ptr is NULL and text->len is nonzero.\n - The input contains malformed UTF-8.\n\n A view with a NULL ptr and zero length is valid.\n\n history:\n - unstable: v2.0.0\n\n @param text The bytes to validate.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_validate_utf8(
        text: *const duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct duckdb_v2_vector_view {
    pub data: *const ::std::os::raw::c_void,
    pub validity: *const u64,
    pub sel: *const duckdb_v2_sel_t,
    pub count: idx_t,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct duckdb_v2_list_entry {
    pub offset: idx_t,
    pub length: idx_t,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct duckdb_v2_hugeint_t {
    pub lower: u64,
    pub upper: i64,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct duckdb_v2_uhugeint_t {
    pub lower: u64,
    pub upper: u64,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct duckdb_v2_interval_t {
    pub months: i32,
    pub days: i32,
    pub micros: i64,
}
#[doc = " An owned handle to a statement bound and planned once, executable repeatedly via\n `duckdb_v2_prepared_statement_execute()`. Construct with `duckdb_v2_prepared_statement_create()` and destroy with\n `duckdb_v2_prepared_statement_destroy()`. It keeps its connection's session alive, so it stays usable across\n executions and even after the connection is disconnected."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_prepared_statement {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned handle to a statement bound and planned once, executable repeatedly via\n `duckdb_v2_prepared_statement_execute()`. Construct with `duckdb_v2_prepared_statement_create()` and destroy with\n `duckdb_v2_prepared_statement_destroy()`. It keeps its connection's session alive, so it stays usable across\n executions and even after the connection is disconnected."]
pub type duckdb_v2_prepared_statement_handle = *mut _duckdb_v2_prepared_statement;
unsafe extern "C" {
    #[doc = " Prepares a parsed statement into a reusable handle. Non-consuming.\n\n Copies the statement's AST, then binds and plans it once. Binder and catalog errors surface here, exactly as they\n would from `duckdb_v2_statement_execute()`. The statement is borrowed rather than consumed, since a copy is what gets\n prepared, so it can be prepared again or executed directly; the caller destroys it with\n `duckdb_v2_sql_statement_destroy()`.\n\n By default this succeeds for any preparable statement, whether or not its plan will be reused; ask\n `duckdb_v2_prepared_statement_reuses_plan()` which one you got. Setting `require_cacheable` instead fails with\n `ERROR_INPUT_INVALID` when the plan would not be reused, so a caller who wants the handle only for the speedup finds\n out here rather than after silently taking the slow path.\n\n A statement that DuckDB expands into several, such as a dynamic PIVOT, is kept as written and expanded again at each\n execution, in the transaction state of that execution. It runs nothing here, its plan is never reused, and its\n result's metadata is deferred as for `duckdb_v2_statement_execute()`. Parameters on such a statement are refused with\n `ERROR_INPUT_INVALID`.\n\n Refuses with `ERROR_RESOURCE_IN_USE` while a statement on the connection is still running. Drain, destroy, or\n interrupt that result first, or prepare on another connection. `*out_prepared` is set to NULL on failure.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection supplying the catalog, transaction, and parser state. The prepared statement belongs to\n it.\n @param statement The statement to prepare. Borrowed and copied, not consumed; destroy it with\n `duckdb_v2_sql_statement_destroy()`.\n @param require_cacheable When true, fail with `ERROR_INPUT_INVALID` unless the prepared plan will be reused across\n executions, as `duckdb_v2_prepared_statement_reuses_plan()` would report it.\n @param out_prepared On success, receives the new prepared statement. Owned by the caller; destroy via\n `duckdb_v2_prepared_statement_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_prepared_statement_create(
        conn: duckdb_v2_connection_handle,
        statement: duckdb_v2_sql_statement_handle,
        require_cacheable: bool,
        out_prepared: *mut duckdb_v2_prepared_statement_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Executes a prepared statement, streaming its result. Non-consuming.\n\n Returns a result without executing anything: execution happens incrementally as the result is stepped or drained,\n exactly as with `duckdb_v2_statement_execute()`. The handle returned is an ordinary result, with identical behaviour\n throughout -- streaming, draining, the changed-row count of a DML statement, the output schema, the statement type,\n and the result type.\n\n `parameter_values` binds the statement's parameters as constants for this execution. Binding is positional by default\n ($1 = element 0); supply `parameter_names` to bind by name instead, where a non-empty entry binds its value to that\n named parameter ($name, matched case-insensitively) and a {NULL, 0} entry stays positional. Pass NULL for both\n arrays, or a count of 0, for a statement without parameters. Both arrays are borrowed and copied in, so the caller\n still owns and destroys them. A key set that does not match the statement's parameters is rejected with\n `ERROR_INPUT_INVALID`, with one exception: a named parameter left without a value reads the session variable of the\n same name (`SET VARIABLE`) when one exists.\n\n Not consumed: execute the same handle again, with the same values or different ones, as often as you like. Values are\n bound per execution and nothing carries over between them. A catalog change since the statement was prepared, or a\n parameter type that differs from the one the cached plan assumed, triggers a re-bind that is invisible apart from its\n cost.\n\n Refuses with `ERROR_RESOURCE_IN_USE` while a statement on the connection is still running; drain, destroy, or\n interrupt that result first, or execute on another connection. A failed execution, at any stage, leaves the prepared\n statement usable. `*out_result` is set to NULL on failure.\n\n history:\n - unstable: v2.0.0\n\n @param prepared The prepared statement to execute. Borrowed; not consumed.\n @param parameter_names Optional. An array of `parameter_count` parameter names; a non-empty entry binds its value to\n the named parameter ($name, case-insensitive), a {NULL, 0} entry keeps it positional ($1 = element 0). Pass NULL to\n bind everything positionally.\n @param parameter_values Optional. An array of `parameter_count` values. Each binds by name when `parameter_names`\n supplies one, and positionally ($1 = element 0) otherwise. Borrowed and copied in. Pass NULL for a statement without\n parameters.\n @param parameter_count The number of entries in `parameter_names` and `parameter_values`. Pass 0 for a statement\n without parameters.\n @param out_result On success, receives the new result. Owned by the caller; destroy via `duckdb_v2_result_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_prepared_statement_execute(
        prepared: duckdb_v2_prepared_statement_handle,
        parameter_names: *const duckdb_v2_identifier_t,
        parameter_values: *const duckdb_v2_value_handle,
        parameter_count: idx_t,
        out_result: *mut duckdb_v2_result_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reports whether the prepared statement reuses its compiled plan across executions.\n\n True when executions reuse the plan built at prepare time, provided the supplied values match the planned parameter\n types and nothing the plan depends on has changed; false when the statement re-binds on every execution, making it no\n faster than `duckdb_v2_statement_execute()`. A plan is reused only when all parameter types were resolved at prepare\n time and the plan is cacheable: `SELECT 42` reuses, `SELECT $1::INTEGER + 1` reuses, a statement reading a base table\n does not (it re-binds so a catalog change is picked up), and `SELECT $1 + $2` does not (the types are unknown until\n values arrive).\n\n A static property of the built plan, fixed when the statement was prepared and independent of the values later passed\n to `duckdb_v2_prepared_statement_execute()`.\n\n history:\n - unstable: v2.0.0\n\n @param prepared The prepared statement to inspect.\n @param out_reuses Receives true when the compiled plan is reused across executions, false when the statement re-binds\n each time.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_prepared_statement_reuses_plan(
        prepared: duckdb_v2_prepared_statement_handle,
        out_reuses: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys a prepared statement.\n\n Null-safe: passing NULL, or a slot already set to NULL, is a no-op. A result produced by\n `duckdb_v2_prepared_statement_execute()` is independently owned and keeps the session alive itself, so the prepared\n statement may be destroyed while results made from it are still live. On success the slot is set to NULL.\n\n history:\n - unstable: v2.0.0\n\n @param prepared The prepared statement to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_prepared_statement_destroy(prepared: *mut duckdb_v2_prepared_statement_handle) -> DUCKDB_V2_ERROR;
}
#[repr(u32)]
#[non_exhaustive]
#[doc = " Shape of a query result. QUERY_RESULT carries rows and columns; CHANGED_ROWS carries an affected row count, as an\n INSERT, UPDATE, or DELETE without RETURNING produces; NOTHING covers DDL and other statements with no row output."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_RESULT_TYPE {
    DUCKDB_V2_RESULT_TYPE_QUERY_RESULT = 0,
    DUCKDB_V2_RESULT_TYPE_CHANGED_ROWS = 1,
    DUCKDB_V2_RESULT_TYPE_NOTHING = 2,
    DUCKDB_V2_RESULT_TYPE_MAX_ENUM = 2147483647,
}
#[repr(u32)]
#[non_exhaustive]
#[doc = " Outcome of a result_step call. WAITING is the 0-value, so a zero-initialized out-param reads as \"no work product yet\"\n rather than CHUNK, the same convention VECTOR_TYPE_OTHER follows. The four states are the ones a consumer acts on;\n they are deliberately not a projection of any internal enum."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_RESULT_STEP_STATUS {
    #[doc = "! No chunk yet; step again, or block in result_wait."]
    DUCKDB_V2_RESULT_STEP_STATUS_WAITING = 0,
    #[doc = "! A caller-owned chunk was written to *out_chunk, or an array to *out_array."]
    DUCKDB_V2_RESULT_STEP_STATUS_CHUNK = 1,
    #[doc = "! Stream exhausted. Sticky."]
    DUCKDB_V2_RESULT_STEP_STATUS_FINISHED = 2,
    #[doc = "! Query was interrupted. Sticky."]
    DUCKDB_V2_RESULT_STEP_STATUS_CANCELLED = 3,
    #[doc = "! Query was interrupted. Sticky."]
    DUCKDB_V2_RESULT_STEP_STATUS_MAX_ENUM = 2147483647,
}
unsafe extern "C" {
    #[doc = " Executes a parsed statement on the connection, streaming its result. Non-consuming.\n\n Takes a statement produced by the sql_statement module (parse_sql / statement_iterator_next), preprocesses and\n prepares it, and returns a result handle without executing anything: execution happens incrementally as the result is\n stepped (result_step) or drained (result_fetch_chunk). This call reports only the errors detectable at prepare time —\n binder, catalog, pragma preprocessing — while errors raised during execution surface from the stepping functions.\n\n The statement is borrowed, not consumed, since a copy is what executes. It can be executed again, for example with a\n different set of values, and the caller destroys it with sql_statement_destroy.\n\n parameter_values binds the statement's parameters as constants for this execution. Binding is positional by default:\n the i-th value binds $(i+1), matching SQL's own convention, so dense $1..$N and ? placeholders work directly. Supply\n parameter_names to bind by name instead — a non-empty name binds its value to that named parameter ($name, matched\n case-insensitively), while a {NULL, 0} entry leaves that value positional. The parameter schema from statement_bind\n lists the names to use. Both arrays are borrowed and copied in; the caller still owns and destroys them. Pass NULL\n for both, or a count of 0, for an unparameterized statement. A key set that does not match the statement's parameters\n — names for a positional statement, or the reverse — is rejected with ERROR_INPUT_INVALID, and named and positional\n parameters cannot be mixed within one statement. Parameters and statement expansion are mutually exclusive: passing\n values for a statement that preprocesses into a group is rejected with ERROR_INPUT_INVALID.\n\n DuckDB can expand one statement into a group: a dynamic PIVOT, or statement-expanding DDL such as ALTER ... ADD\n COLUMN with a non-constant DEFAULT. The group executes as one result through the same steps, and the stream surfaces\n the rows of the first row-producing statement of the group. A row-producing statement followed by another cannot be\n served as a single result and reports ERROR_QUERY_NOT_IMPLEMENTED; no known expansion produces one.\n\n One running statement per connection: this refuses with ERROR_RESOURCE_IN_USE while a statement on the connection is\n still running. Drain, destroy, or interrupt that result first, or open another connection.\n\n Schema metadata — result type, statement type, column count, names, logical types — is available on the returned\n handle immediately, before the first step.\n\n *out_result is set to nullptr on failure.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection on which to execute the statement.\n @param statement The statement to execute. Borrowed and copied; not consumed. Destroy it with sql_statement_destroy.\n @param parameter_names Optional. An array of parameter_count parameter names; a non-empty entry binds its value to\n the named parameter ($name, case-insensitive), a {NULL, 0} entry keeps it positional ($1 = element 0). Pass NULL for\n all-positional binding. Named and positional parameters cannot be mixed within one statement.\n @param parameter_values Optional. An array of parameter_count value handles. Each binds by name when parameter_names\n supplies one, otherwise positionally ($1 = element 0). Borrowed (copied in). Pass NULL for an unparameterized\n statement.\n @param parameter_count The number of parameters in parameter_names and parameter_values. Pass 0 for an\n unparameterized statement.\n @param out_result Receives the new result handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_statement_execute(
        conn: duckdb_v2_connection_handle,
        statement: duckdb_v2_sql_statement_handle,
        parameter_names: *const duckdb_v2_identifier_t,
        parameter_values: *const duckdb_v2_value_handle,
        parameter_count: idx_t,
        out_result: *mut duckdb_v2_result_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys a result handle.\n\n Null-safe: passing nullptr or a slot already set to nullptr is a no-op. Frees the memory the result owns and releases\n the connection for its next query. Safe at any point in the stream's life. Destroying a result before its statement\n ended (drained, or stepped to FINISHED) aborts the statement. On autocommit, its writes are rolled back. Inside a\n transaction, a statement that may write invalidates the transaction, and a read-only statement just stops. Chunks\n already fetched are caller-owned and stay valid. On success the slot is set to nullptr.\n\n history:\n - unstable: v2.0.0\n\n @param result The result to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_result_destroy(result: *mut duckdb_v2_result_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Runs one bounded unit of query execution and returns without blocking.\n\n The streaming primitive: a step does a bounded amount of execution work, mostly without blocking, and returns control\n to the caller, so an event loop stays responsive and can interleave other work between steps. The conveniences —\n result_wait, result_fetch_chunk, result_drain — block, and are for synchronous callers. out_status reports the\n outcome:\n\n - CHUNK: *out_chunk receives a caller-owned chunk (destroy via data_chunk_destroy). Written only for this status;\n nullptr otherwise.\n - WAITING: no chunk yet, but work was done. Transient: keep stepping and it resolves to CHUNK, FINISHED, CANCELLED,\n or an error. Block in result_wait rather than busy-stepping.\n - FINISHED: stream exhausted. Sticky.\n - CANCELLED: query interrupted via connection_interrupt. Sticky. Cancellation is a status here, not an error;\n result_fetch_chunk, which has no status out-param, reports it as ERROR_RUNTIME_INTERRUPT.\n\n Execution errors come back as the return code plus err, never as a status; out_status is then unspecified and\n *out_chunk is nullptr. Errors are sticky, so later steps report the same code.\n\n history:\n - unstable: v2.0.0\n\n @param result The result to step.\n @param out_chunk Receives an owned chunk if *out_status is CHUNK; set to nullptr otherwise.\n @param out_status Receives the step status.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_result_step(
        result: duckdb_v2_result_handle,
        out_chunk: *mut duckdb_v2_data_chunk_handle,
        out_status: *mut DUCKDB_V2_RESULT_STEP_STATUS,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Blocks until the next chunk is available and returns it.\n\n A convenience over result_step: blocks until a chunk is produced or the stream ends. On success *out_chunk receives a\n caller-owned chunk (destroy via data_chunk_destroy), or nullptr at end-of-stream. End-of-stream is sticky, so later\n calls keep succeeding with *out_chunk set to nullptr.\n\n An interrupted query returns ERROR_RUNTIME_INTERRUPT — the same event result_step reports as status CANCELLED,\n carried on the error channel because this function has no status out-param.\n\n On failure *out_chunk is set to nullptr. Errors are sticky, so later calls report the same code.\n\n history:\n - unstable: v2.0.0\n\n @param result The result to fetch from.\n @param out_chunk Receives an owned chunk, or nullptr at end-of-stream.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_result_fetch_chunk(
        result: duckdb_v2_result_handle,
        out_chunk: *mut duckdb_v2_data_chunk_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Blocks until result_step can make progress.\n\n A convenience over result_step: blocks until a step is worth issuing again, that is, until a unit of execution work\n can run on the calling thread. Never produces or consumes chunks. Waiting on a terminal result — FINISHED, CANCELLED,\n or a sticky error — returns immediately; it is a no-op, never an error.\n\n history:\n - unstable: v2.0.0\n\n @param result The result to wait on.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_result_wait(
        result: duckdb_v2_result_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Renders the result as a box table, consuming it.\n\n Drains the result into a column data collection and renders it with the same renderer the DuckDB CLI uses, so every\n client displays results identically without reimplementing table formatting. The result is consumed by transfer: the\n slot is set to NULL on success and on failure alike. A partially consumed result is accepted, and the remainder is\n what gets rendered.\n\n The whole remaining result materializes in memory before rendering. max_rows bounds what is DISPLAYED, not what is\n read, so with limit 0 the footer's row count is exact. A caller who cannot afford full materialization should bound\n the query itself (e.g. LIMIT n) and pass n as limit; the footer then renders \"? rows\" whenever the result fills that\n bound, since the true total is unknown at that point.\n\n Zero selects the renderer default for each sizing knob: max_rows 20, max_width the probed terminal width or 80 when\n that is unavailable, max_col_width 20. An empty null_value renders NULL cells as the default \"NULL\" text.\n\n The rendered text goes to sink rather than being returned: a box can be large, and this way nothing allocates a\n buffer the caller has to free. The sink is called exactly once with the whole box, so its view carries the full\n length — write it straight to a stream, or copy it into your own string. sink must not be NULL.\n\n history:\n - unstable: v2.0.0\n\n @param result The result to render; consumed and set to NULL. Left intact only when the call rejects null arguments.\n @param max_rows Maximum rows displayed; 0 selects the renderer default (20).\n @param max_width Maximum total width in characters; 0 selects the renderer default.\n @param max_col_width Maximum width of one column; 0 selects the renderer default (20).\n @param null_value Text rendered for NULL cells; empty selects \"NULL\".\n @param render_mode 0 renders rows (records down the page); 1 renders columns; other values are rejected with\n INVALID_INPUT.\n @param limit The row limit the caller applied to the query before rendering; 0 means none. When the materialized\n result holds exactly this many rows the true total is unknown, so the footer renders \"? rows\" instead of an exact\n count.\n @param sink Receives the whole rendered box in a single call. Borrowed for the duration of that call; see text_sink\n for the full contract.\n @param user_data Opaque pointer passed through to sink untouched. May be NULL.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_result_render_box(
        result: *mut duckdb_v2_result_handle,
        max_rows: idx_t,
        max_width: idx_t,
        max_col_width: idx_t,
        null_value: *const duckdb_v2_str,
        render_mode: idx_t,
        limit: idx_t,
        sink: duckdb_v2_text_sink_fn,
        user_data: *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Runs the result to completion and reports the changed-row count.\n\n A convenience over result_step: blocks until the stream is fully consumed, so every side effect is applied. Rows of a\n row-producing result are discarded. For a CHANGED_ROWS result *out_rows_changed receives the affected row count; for\n every other result type, and for a stream whose Count chunk was already consumed, it receives 0.\n\n The result type (result_get_result_type) is prepare-time metadata, so a caller can choose between consuming rows and\n draining without inspecting the SQL. Draining an already FINISHED result succeeds. Cancellation surfaces as\n ERROR_RUNTIME_INTERRUPT; errors are sticky, and on failure *out_rows_changed is unspecified.\n\n history:\n - unstable: v2.0.0\n\n @param result The result to drain.\n @param out_rows_changed Receives the affected row count for CHANGED_ROWS results, 0 otherwise.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_result_drain(
        result: duckdb_v2_result_handle,
        out_rows_changed: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the shape of the result: query, changed rows, or nothing.\n\n QUERY_RESULT for statements that produce rows (SELECT, RETURNING, EXPLAIN), CHANGED_ROWS for an INSERT, UPDATE, or\n DELETE without RETURNING, NOTHING for DDL and other statements with no row output.\n\n Prepare-time metadata: available from statement_execute on, except for a statement that expands into a group, where\n it fails with ERROR_INPUT_METADATA_DEFERRED until stepping has bound the row-producing statement, or the group ended\n without one.\n\n history:\n - unstable: v2.0.0\n\n @param result The result.\n @param out_type Receives the result shape.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_result_get_result_type(
        result: duckdb_v2_result_handle,
        out_type: *mut DUCKDB_V2_RESULT_TYPE,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the SQL statement type that produced the result.\n\n Prepare-time metadata: available from statement_execute on. A statement that expands into a group reports its type as\n written: MULTI, or PRAGMA for a pragma such as IMPORT DATABASE.\n\n history:\n - unstable: v2.0.0\n\n @param result The result.\n @param out_type Receives the statement type.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_result_get_statement_type(
        result: duckdb_v2_result_handle,
        out_type: *mut DUCKDB_V2_STATEMENT_TYPE,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the result's output schema as a single schema handle.\n\n Builds an owned schema of the result's column names and types into *out_schema; destroy it via schema_destroy.\n Prepare-time metadata, available before the first step, or for an expanding statement once stepping has bound the\n row-producing statement (before that it fails with ERROR_INPUT_METADATA_DEFERRED). Never empty: a non-SELECT reports\n a single status column, either a BIGINT changed-rows count or a BOOLEAN success.\n\n This schema is the authoritative source for the column types of the chunks the result produces; vectors do not carry\n their own type.\n\n *out_schema is set to NULL on failure.\n\n history:\n - unstable: v2.0.0\n\n @param result The result.\n @param out_schema Receives the owned output schema. Destroy via schema_destroy.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_result_get_schema(
        result: duckdb_v2_result_handle,
        out_schema: *mut duckdb_v2_schema_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
#[repr(u32)]
#[non_exhaustive]
#[doc = " Whether a table function's scan is partitioned by a given set of columns, and how. Reported by\n `duckdb_v2_table_function_set_partitioning_callback()` via\n `duckdb_v2_table_function_partitioning_set_partition_info()`."]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DUCKDB_V2_TABLE_PARTITION_INFO {
    #[doc = "! The scan is not known to be partitioned by the requested columns."]
    DUCKDB_V2_TABLE_PARTITION_INFO_NOT_PARTITIONED = 0,
    #[doc = "! Each partition the scan produces carries exactly one distinct value for the requested columns."]
    DUCKDB_V2_TABLE_PARTITION_INFO_SINGLE_VALUE_PARTITIONS = 1,
    #[doc = "! The partitions the scan produces overlap only at their boundaries."]
    DUCKDB_V2_TABLE_PARTITION_INFO_OVERLAPPING_PARTITIONS = 2,
    #[doc = "! The partitions the scan produces are disjoint ranges."]
    DUCKDB_V2_TABLE_PARTITION_INFO_DISJOINT_PARTITIONS = 3,
    #[doc = "! The partitions the scan produces are disjoint ranges."]
    DUCKDB_V2_TABLE_PARTITION_INFO_MAX_ENUM = 2147483647,
}
#[doc = " An owned opaque handle to a custom table function being built. Created with `duckdb_v2_table_function_create()`,\n configured with the setter functions (e.g. `duckdb_v2_table_function_set_name()`,\n `duckdb_v2_table_function_set_exec_callback()`, etc.) and the signature obtained via\n `duckdb_v2_table_function_get_signature()`, made available with `duckdb_v2_connection_register_table_function()` or\n `duckdb_v2_extension_register_table_function()`, and destroyed with `duckdb_v2_table_function_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_table_function {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned opaque handle to a custom table function being built. Created with `duckdb_v2_table_function_create()`,\n configured with the setter functions (e.g. `duckdb_v2_table_function_set_name()`,\n `duckdb_v2_table_function_set_exec_callback()`, etc.) and the signature obtained via\n `duckdb_v2_table_function_get_signature()`, made available with `duckdb_v2_connection_register_table_function()` or\n `duckdb_v2_extension_register_table_function()`, and destroyed with `duckdb_v2_table_function_destroy()`."]
pub type duckdb_v2_table_function_handle = *mut _duckdb_v2_table_function;
#[doc = " A borrowed opaque handle to the result of a table function's \"bind\" phase. The \"bind\" callback receives this handle\n next to a `duckdb_v2_function_bind_info_handle`, which gives access to the arguments, the user data and the bind\n data. It must use this handle to declare the columns the function returns, and can use it to hint at the number of\n rows the scan will produce."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_table_function_bind_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the result of a table function's \"bind\" phase. The \"bind\" callback receives this handle\n next to a `duckdb_v2_function_bind_info_handle`, which gives access to the arguments, the user data and the bind\n data. It must use this handle to declare the columns the function returns, and can use it to hint at the number of\n rows the scan will produce."]
pub type duckdb_v2_table_function_bind_info_handle = *mut _duckdb_v2_table_function_bind_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a table function during the global state initialization \"init\n global\" phase. The \"init global\" callback receives this handle and can use it to e.g. set up the state shared by\n every thread scanning the function, and to declare how many threads may scan it."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_table_function_init_global_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a table function during the global state initialization \"init\n global\" phase. The \"init global\" callback receives this handle and can use it to e.g. set up the state shared by\n every thread scanning the function, and to declare how many threads may scan it."]
pub type duckdb_v2_table_function_init_global_info_handle = *mut _duckdb_v2_table_function_init_global_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a table function during the local state initialization \"init\n local\" phase. The \"init local\" callback receives this handle and can use it to e.g. set up worker-local state,\n typically by claiming work from the shared global state."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_table_function_init_local_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a table function during the local state initialization \"init\n local\" phase. The \"init local\" callback receives this handle and can use it to e.g. set up worker-local state,\n typically by claiming work from the shared global state."]
pub type duckdb_v2_table_function_init_local_info_handle = *mut _duckdb_v2_table_function_init_local_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a table function during the execution \"exec\" phase. The \"exec\"\n callback receives this handle and can use it to e.g. access the global and local state and write the next batch of\n rows to the output chunk."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_table_function_exec_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a table function during the execution \"exec\" phase. The \"exec\"\n callback receives this handle and can use it to e.g. access the global and local state and write the next batch of\n rows to the output chunk."]
pub type duckdb_v2_table_function_exec_info_handle = *mut _duckdb_v2_table_function_exec_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a table function during the \"progress\" phase. The \"progress\"\n callback receives this handle and can use it to report how far the scan has advanced."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_table_function_progress_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a table function during the \"progress\" phase. The \"progress\"\n callback receives this handle and can use it to report how far the scan has advanced."]
pub type duckdb_v2_table_function_progress_info_handle = *mut _duckdb_v2_table_function_progress_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a table function during the \"filter pushdown\" phase of query\n optimization. The \"filter pushdown\" callback receives this handle and can use it to inspect the filter predicates the\n query applies to the function's rows, and to accept the ones it will apply itself."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_table_function_filter_pushdown_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a table function during the \"filter pushdown\" phase of query\n optimization. The \"filter pushdown\" callback receives this handle and can use it to inspect the filter predicates the\n query applies to the function's rows, and to accept the ones it will apply itself."]
pub type duckdb_v2_table_function_filter_pushdown_info_handle = *mut _duckdb_v2_table_function_filter_pushdown_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a table function during the \"partition data\" phase. The engine\n invokes the callback on the worker thread that just produced a batch of rows, once per batch, only when a downstream\n operator needs to know the batch's ordering position, the values of a set of partitioning columns, or both; the\n handle reports which of those were actually requested and receives the answer."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_table_function_partition_data_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a table function during the \"partition data\" phase. The engine\n invokes the callback on the worker thread that just produced a batch of rows, once per batch, only when a downstream\n operator needs to know the batch's ordering position, the values of a set of partitioning columns, or both; the\n handle reports which of those were actually requested and receives the answer."]
pub type duckdb_v2_table_function_partition_data_info_handle = *mut _duckdb_v2_table_function_partition_data_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a table function during the \"partitioning\" phase of query\n optimization. The engine invokes the callback once per candidate `GROUP BY` column set, before execution starts, to\n decide whether the scan can feed a partitioned aggregate directly instead of hashing."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_table_function_partitioning_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a table function during the \"partitioning\" phase of query\n optimization. The engine invokes the callback once per candidate `GROUP BY` column set, before execution starts, to\n decide whether the scan can feed a partitioned aggregate directly instead of hashing."]
pub type duckdb_v2_table_function_partitioning_info_handle = *mut _duckdb_v2_table_function_partitioning_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a table function when a scanning thread claims its next batch\n of work. The \"claim batch\" callback receives this handle and can use it to claim the next part of the scan from the\n shared global state for the thread's local state, and to report whether it claimed one."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_table_function_claim_batch_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a table function when a scanning thread claims its next batch\n of work. The \"claim batch\" callback receives this handle and can use it to claim the next part of the scan from the\n shared global state for the thread's local state, and to report whether it claimed one."]
pub type duckdb_v2_table_function_claim_batch_info_handle = *mut _duckdb_v2_table_function_claim_batch_info;
#[doc = " A borrowed opaque handle to the arguments supplied to a table function when the engine asks it to describe a bound\n call. The \"get bind info\" callback receives this handle, and can use it to describe the call in more detail than its\n columns: with identifiers of its columns (e.g. field ids), and with options - key-value facts about what the call\n reads."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_table_function_get_bind_info_info {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A borrowed opaque handle to the arguments supplied to a table function when the engine asks it to describe a bound\n call. The \"get bind info\" callback receives this handle, and can use it to describe the call in more detail than its\n columns: with identifiers of its columns (e.g. field ids), and with options - key-value facts about what the call\n reads."]
pub type duckdb_v2_table_function_get_bind_info_info_handle = *mut _duckdb_v2_table_function_get_bind_info_info;
#[doc = " An owned opaque handle to a multi-file table function being built. A multi-file function wraps an already registered\n table function that reads a single file, and adds everything that is needed to read many files at once on top of it:\n globbing, lists of files, hive partitioning, the `filename` column, `union_by_name` and the like. Created with\n `duckdb_v2_multi_file_function_create()`, configured with the setter functions (e.g.\n `duckdb_v2_multi_file_function_set_name()`, `duckdb_v2_multi_file_function_set_single_file_function()`), made\n available with `duckdb_v2_connection_register_multi_file_function()` or\n `duckdb_v2_extension_register_multi_file_function()`, and destroyed with `duckdb_v2_multi_file_function_destroy()`."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_multi_file_function {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " An owned opaque handle to a multi-file table function being built. A multi-file function wraps an already registered\n table function that reads a single file, and adds everything that is needed to read many files at once on top of it:\n globbing, lists of files, hive partitioning, the `filename` column, `union_by_name` and the like. Created with\n `duckdb_v2_multi_file_function_create()`, configured with the setter functions (e.g.\n `duckdb_v2_multi_file_function_set_name()`, `duckdb_v2_multi_file_function_set_single_file_function()`), made\n available with `duckdb_v2_connection_register_multi_file_function()` or\n `duckdb_v2_extension_register_multi_file_function()`, and destroyed with `duckdb_v2_multi_file_function_destroy()`."]
pub type duckdb_v2_multi_file_function_handle = *mut _duckdb_v2_multi_file_function;
pub type duckdb_v2_table_function_bind_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_function_bind_info_handle,
        result: duckdb_v2_table_function_bind_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_table_function_init_global_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_table_function_init_global_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_table_function_init_local_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_table_function_init_local_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_table_function_exec_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_table_function_exec_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_table_function_progress_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_table_function_progress_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_table_function_filter_pushdown_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_table_function_filter_pushdown_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_table_function_partition_data_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_table_function_partition_data_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_table_function_partitioning_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_table_function_partitioning_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_table_function_claim_batch_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_table_function_claim_batch_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
pub type duckdb_v2_table_function_get_bind_info_callback_fn = ::std::option::Option<
    unsafe extern "C" fn(
        info: duckdb_v2_table_function_get_bind_info_info_handle,
        context: duckdb_v2_context_handle,
        err: *mut duckdb_v2_error_info_handle,
    ),
>;
unsafe extern "C" {
    #[doc = " Creates a new table function through a factory.\n\n The function starts out empty: configure it with the setter functions (e.g. `duckdb_v2_table_function_set_name()`,\n `duckdb_v2_table_function_set_exec_callback()`, etc.) and the signature obtained via\n `duckdb_v2_table_function_get_signature()`, then make it available with\n `duckdb_v2_connection_register_table_function()` or `duckdb_v2_extension_register_table_function()`. The caller owns\n the returned handle and must destroy it with `duckdb_v2_table_function_destroy()`, also after registration.\n\n The table function can only be registered on the database the factory belongs to.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create the table function through.\n @param function On success, receives the newly created table function. Owned by the caller.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_create(
        factory: duckdb_v2_factory_handle,
        function: *mut duckdb_v2_table_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the name of the table function.\n\n The name is borrowed and copied. Calling this again replaces the previous name. A name must be set before\n registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the name of.\n @param name The name to set. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_set_name(
        function: duckdb_v2_table_function_handle,
        name: *const duckdb_v2_identifier_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the documentation of the function so it can be filled in.\n\n Set a description with `duckdb_v2_function_docs_set_description()`, and add examples and categories with\n `duckdb_v2_function_docs_add_example()` and `duckdb_v2_function_docs_add_category()`. The documentation is modified\n in place, describes this overload only, and is registered with the function. Optional.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to get the documentation of.\n @param docs The returned documentation. Borrowed and valid for the lifetime of the function handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_get_docs(
        function: duckdb_v2_table_function_handle,
        docs: *mut duckdb_v2_function_docs_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the function's signature so it can be configured.\n\n Add parameters with `duckdb_v2_function_signature_add_parameter()`. The signature is modified in place. A table\n function declares the columns it returns from its bind callback instead of through a return type, so registration\n rejects a signature whose return type was set with `duckdb_v2_function_signature_set_return_type()`.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to get the signature of.\n @param sig The returned signature. Borrowed and valid for the lifetime of the function handle.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_get_signature(
        function: duckdb_v2_table_function_handle,
        sig: *mut duckdb_v2_function_signature_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets arbitrary user data on the table function.\n\n Associates an opaque pointer with the function, retrievable from the callbacks via\n `duckdb_v2_function_bind_get_user_data()`, `duckdb_v2_table_function_init_global_get_user_data()`,\n `duckdb_v2_table_function_exec_get_user_data()` and their counterparts on the other phases. The opaque handle bundles\n the pointer with an optional destructor, invoked when the data is no longer needed.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the user data of.\n @param data Opaque handle bundling the user data pointer plus an optional destructor.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_set_user_data(
        function: duckdb_v2_table_function_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the bind callback of the table function.\n\n The bind callback is invoked during query planning for each call site of the function. It must declare the columns\n the function returns via `duckdb_v2_table_function_bind_add_result_column()`. Through its\n `duckdb_v2_function_bind_info_handle` it can also inspect the constant argument values and set \"bind data\" that is\n shared with all later callbacks. A bind callback must be set before registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the bind callback of.\n @param callback The bind callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_set_bind_callback(
        function: duckdb_v2_table_function_handle,
        callback: duckdb_v2_table_function_bind_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional global init callback of the table function.\n\n The global init callback is invoked once per scan, at the start of execution. It can set \"global state\" shared by\n every thread scanning the function, and declare how many threads may scan it in parallel via\n `duckdb_v2_table_function_init_global_set_max_threads()`.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the global init callback of.\n @param callback The global init callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_set_init_global_callback(
        function: duckdb_v2_table_function_handle,
        callback: duckdb_v2_table_function_init_global_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional local init callback of the table function.\n\n The local init callback is invoked once per thread that will scan the function. It can set worker-local \"local\n state\", retrievable from the exec callback, typically derived from the shared global state.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the local init callback of.\n @param callback The local init callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_set_init_local_callback(
        function: duckdb_v2_table_function_handle,
        callback: duckdb_v2_table_function_init_local_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the exec callback of the table function.\n\n The exec callback implements the function's logic: it is invoked repeatedly during query execution and writes the\n next batch of rows to the output chunk, until it produces an empty batch to signal the end of the scan. An exec\n callback must be set before registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the exec callback of.\n @param callback The exec callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_set_exec_callback(
        function: duckdb_v2_table_function_handle,
        callback: duckdb_v2_table_function_exec_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional progress callback of the table function.\n\n The progress callback is invoked on demand during execution to report how far the scan has advanced, which the engine\n surfaces as the query's progress. It is invoked concurrently with the exec callback, so it must read the global state\n in a thread-safe way.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the progress callback of.\n @param callback The progress callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_set_progress_callback(
        function: duckdb_v2_table_function_handle,
        callback: duckdb_v2_table_function_progress_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets whether the table function supports projection pushdown. Defaults to false.\n\n With projection pushdown, the engine asks the function for only the columns a query actually uses: the exec\n callback's output chunk holds one vector per requested column rather than one per column declared in bind, and the\n global init, local init and exec callbacks can look up which declared column each vector stands for via e.g.\n `duckdb_v2_table_function_exec_get_column_index()`. Without it the output chunk always holds every declared column,\n and the engine drops the unused ones itself.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to configure.\n @param enable Whether the function supports projection pushdown.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_set_projection_pushdown(
        function: duckdb_v2_table_function_handle,
        enable: bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional filter pushdown callback of the table function.\n\n The filter pushdown callback is invoked while the query is optimized, after the bind callback and before any init\n callback, with the filter predicates the query applies to the function's rows. Each predicate is a bound expression\n the callback can inspect with the `expression` functions; the callback accepts the predicates it will apply itself\n via `duckdb_v2_table_function_filter_pushdown_accept()`, typically after recording what they select in the bind data.\n The engine then stops applying the accepted predicates and keeps applying the rest above the scan, so accepting a\n predicate is a promise to filter the rows exactly as it would have. The optimizer may invoke the callback more than\n once for the same query, each time with the predicates not yet accepted; it is not invoked when there are none.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the filter pushdown callback of.\n @param callback The filter pushdown callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_set_filter_pushdown_callback(
        function: duckdb_v2_table_function_handle,
        callback: duckdb_v2_table_function_filter_pushdown_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional \"partition data\" callback of the table function.\n\n The callback reports, for the batch the exec callback just produced, an ordering batch index, the values of a set of\n partitioning columns, or both, depending on what a downstream operator requires; it runs on the worker thread that\n produced the batch. Set `duckdb_v2_table_function_set_partitioning_callback()` too when the function can answer\n partitioning-column requests, since the engine only asks a scan for those when that callback reports\n `TABLE_PARTITION_INFO_SINGLE_VALUE_PARTITIONS`.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the partition data callback of.\n @param callback The partition data callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_set_partition_data_callback(
        function: duckdb_v2_table_function_handle,
        callback: duckdb_v2_table_function_partition_data_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional \"partitioning\" callback of the table function.\n\n The callback tells the query optimizer, for a candidate `GROUP BY` column set, whether every partition the scan\n produces carries exactly one distinct value for those columns; only `TABLE_PARTITION_INFO_SINGLE_VALUE_PARTITIONS`\n unlocks the partitioned aggregate optimization; any other result, or leaving this callback unset, keeps the regular\n hash aggregate. It runs on the planning thread, before execution starts, and must be deterministic for a given column\n set since it may be called on a plan the optimizer later discards. Registration fails unless\n `duckdb_v2_table_function_set_partition_data_callback()` is set too, since the engine asks that callback for the\n partitioning column values once this one claims single-value partitions.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the partitioning callback of.\n @param callback The partitioning callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_set_partitioning_callback(
        function: duckdb_v2_table_function_handle,
        callback: duckdb_v2_table_function_partitioning_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Declares one of the columns the function returns.\n\n Call this once per column, in order: the columns declared here are the columns of the table the function produces,\n and the vectors of the output chunk the exec callback fills follow the same order. At least one column must be\n declared. The type must be a fully defined concrete type; ANY is rejected, as a result column carries data. The name\n and type are borrowed and copied.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param name The name of the column. Borrowed and copied.\n @param type The type of the column. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_bind_add_result_column(
        info: duckdb_v2_table_function_bind_info_handle,
        name: *const duckdb_v2_identifier_t,
        type_: duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the estimated number of rows the scan will produce.\n\n The estimate is a hint for the optimizer, not a limit: producing a different number of rows is not an error. Without\n it, the optimizer falls back on its own defaults.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param cardinality The estimated number of rows.\n @param is_exact Whether the estimate is exact, which also makes it an upper bound on the row count.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_bind_set_cardinality(
        info: duckdb_v2_table_function_bind_info_handle,
        cardinality: idx_t,
        is_exact: bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the order guarantee of the rows this call of the function produces. Defaults to\n `ORDER_PRESERVATION_INSERTION_ORDER`.\n\n With `ORDER_PRESERVATION_NO_ORDER`, a scan that reports more than one thread via\n `duckdb_v2_table_function_init_global_set_max_threads()` runs in parallel into query results, INSERT and COPY without\n a `duckdb_v2_table_function_set_partition_data_callback()`, and the rows arrive in no particular order. With\n insertion order kept, those consumers need the partition data callback to run in parallel. Fails with\n `ERROR_INPUT_INVALID` when order is not one of the enum's declared values.\n\n history:\n - unstable: v2.0.0\n\n @param info The bind info handle.\n @param order The order guarantee of the produced rows.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_bind_set_order_preservation(
        info: duckdb_v2_table_function_bind_info_handle,
        order: DUCKDB_V2_ORDER_PRESERVATION,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_table_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The global init info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_init_global_get_user_data(
        info: duckdb_v2_table_function_init_global_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The global init info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_init_global_get_bind_data(
        info: duckdb_v2_table_function_init_global_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the function's \"global state\" from the global init callback.\n\n The global state lives for the duration of the scan and is retrievable from the local init, exec and progress\n callbacks. Every thread scanning the function shares it, so the function must synchronize its own access to it. The\n opaque handle bundles the pointer with an optional destructor, invoked when the scan is done with the state.\n\n history:\n - unstable: v2.0.0\n\n @param info The global init info handle.\n @param data Opaque handle bundling the global state pointer plus an optional destructor.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_init_global_set_global_state(
        info: duckdb_v2_table_function_init_global_info_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets how many threads may scan the function in parallel.\n\n Defaults to 1, a single-threaded scan. The engine creates at most this many local states, and therefore runs at most\n this many exec callbacks concurrently. It is an upper bound, not a request: the engine may use fewer threads.\n\n history:\n - unstable: v2.0.0\n\n @param info The global init info handle.\n @param max_threads The maximum number of threads. Must be at least 1.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_init_global_set_max_threads(
        info: duckdb_v2_table_function_init_global_info_handle,
        max_threads: idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of columns the scan produces.\n\n With projection pushdown (see `duckdb_v2_table_function_set_projection_pushdown()`) this is the number of columns the\n query uses, which is the number of vectors in the exec callback's output chunk; without it, it is the number of\n columns declared in bind. Valid indices for `duckdb_v2_table_function_init_global_get_column_index()` are `0` up to\n (but excluding) this count.\n\n history:\n - unstable: v2.0.0\n\n @param info The global init info handle.\n @param count Receives the number of columns the scan produces.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_init_global_get_column_count(
        info: duckdb_v2_table_function_init_global_info_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns which declared column the scan's column at the given index stands for.\n\n The result indexes the columns declared with `duckdb_v2_table_function_bind_add_result_column()`, in declaration\n order: the exec callback fills the output chunk's vector at `index` with that column's data. Without projection\n pushdown the mapping is the identity. Fails if the index is out of bounds.\n\n history:\n - unstable: v2.0.0\n\n @param info The global init info handle.\n @param index The index of the column in the scan's output.\n @param column_index Receives the index of the declared column.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_init_global_get_column_index(
        info: duckdb_v2_table_function_init_global_info_handle,
        index: idx_t,
        column_index: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_table_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The local init info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_init_local_get_user_data(
        info: duckdb_v2_table_function_init_local_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The local init info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_init_local_get_bind_data(
        info: duckdb_v2_table_function_init_local_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the global state set by the function's global init callback.\n\n Shared with every other thread scanning the function; access to it must be synchronized by the function.\n\n history:\n - unstable: v2.0.0\n\n @param info The local init info handle.\n @param data Receives the global state pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_init_local_get_global_state(
        info: duckdb_v2_table_function_init_local_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the function's worker-local \"local state\" from the local init callback.\n\n The local state is associated with the executing thread for the duration of the scan and retrievable from the exec\n callback via `duckdb_v2_table_function_exec_get_local_state()`. No other thread observes it, so it needs no\n synchronization. The opaque handle bundles the pointer with an optional destructor, invoked when the local state is\n no longer needed.\n\n history:\n - unstable: v2.0.0\n\n @param info The local init info handle.\n @param data Opaque handle bundling the local state pointer plus an optional destructor.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_init_local_set_local_state(
        info: duckdb_v2_table_function_init_local_info_handle,
        data: *mut duckdb_v2_opaque,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of columns the scan produces.\n\n With projection pushdown (see `duckdb_v2_table_function_set_projection_pushdown()`) this is the number of columns the\n query uses, which is the number of vectors in the exec callback's output chunk; without it, it is the number of\n columns declared in bind. Valid indices for `duckdb_v2_table_function_init_local_get_column_index()` are `0` up to\n (but excluding) this count.\n\n history:\n - unstable: v2.0.0\n\n @param info The local init info handle.\n @param count Receives the number of columns the scan produces.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_init_local_get_column_count(
        info: duckdb_v2_table_function_init_local_info_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns which declared column the scan's column at the given index stands for.\n\n The result indexes the columns declared with `duckdb_v2_table_function_bind_add_result_column()`, in declaration\n order: the exec callback fills the output chunk's vector at `index` with that column's data. Without projection\n pushdown the mapping is the identity. Fails if the index is out of bounds.\n\n history:\n - unstable: v2.0.0\n\n @param info The local init info handle.\n @param index The index of the column in the scan's output.\n @param column_index Receives the index of the declared column.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_init_local_get_column_index(
        info: duckdb_v2_table_function_init_local_info_handle,
        index: idx_t,
        column_index: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_table_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_exec_get_user_data(
        info: duckdb_v2_table_function_exec_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_exec_get_bind_data(
        info: duckdb_v2_table_function_exec_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the global state set by the function's global init callback.\n\n Shared with every other thread scanning the function; access to it must be synchronized by the function.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param data Receives the global state pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_exec_get_global_state(
        info: duckdb_v2_table_function_exec_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the worker-local local state set by the function's local init callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param data Receives the local state pointer for the executing thread, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_exec_get_local_state(
        info: duckdb_v2_table_function_exec_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the output chunk the exec callback must write the next batch of rows into.\n\n The chunk holds one vector per column declared with `duckdb_v2_table_function_bind_add_result_column()`, in the same\n order; reach them with `duckdb_v2_data_chunk_get_vector()`. The chunk starts out empty on every invocation: write the\n rows, then declare how many there are with `duckdb_v2_vector_set_size()` on the first vector, which the engine takes\n as the batch's row count and propagates to the other vectors. Producing an empty batch signals the end of the scan,\n after which the callback is not invoked again on that thread. Borrowed; valid only for the duration of the callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param chunk Receives the borrowed output chunk to write into.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_exec_get_output_chunk(
        info: duckdb_v2_table_function_exec_info_handle,
        chunk: *mut duckdb_v2_data_chunk_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of columns the scan produces.\n\n With projection pushdown (see `duckdb_v2_table_function_set_projection_pushdown()`) this is the number of columns the\n query uses, which is the number of vectors in the exec callback's output chunk; without it, it is the number of\n columns declared in bind. Valid indices for `duckdb_v2_table_function_exec_get_column_index()` are `0` up to (but\n excluding) this count.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param count Receives the number of columns the scan produces.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_exec_get_column_count(
        info: duckdb_v2_table_function_exec_info_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns which declared column the scan's column at the given index stands for.\n\n The result indexes the columns declared with `duckdb_v2_table_function_bind_add_result_column()`, in declaration\n order: the exec callback fills the output chunk's vector at `index` with that column's data. Without projection\n pushdown the mapping is the identity. Fails if the index is out of bounds.\n\n history:\n - unstable: v2.0.0\n\n @param info The exec info handle.\n @param index The index of the column in the scan's output.\n @param column_index Receives the index of the declared column.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_exec_get_column_index(
        info: duckdb_v2_table_function_exec_info_handle,
        index: idx_t,
        column_index: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_table_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The progress info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_progress_get_user_data(
        info: duckdb_v2_table_function_progress_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The progress info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_progress_get_bind_data(
        info: duckdb_v2_table_function_progress_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the global state set by the function's global init callback.\n\n The progress callback runs concurrently with the exec callbacks scanning the function, so it must read the global\n state in a thread-safe way.\n\n history:\n - unstable: v2.0.0\n\n @param info The progress info handle.\n @param data Receives the global state pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_progress_get_global_state(
        info: duckdb_v2_table_function_progress_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reports how far the scan has advanced.\n\n A fraction between 0.0 (nothing scanned yet) and 1.0 (done); values outside that range are clamped. A progress\n callback that returns without calling this reports no progress.\n\n history:\n - unstable: v2.0.0\n\n @param info The progress info handle.\n @param progress The fraction of the scan that is complete, in [0.0, 1.0].\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_progress_set_progress(
        info: duckdb_v2_table_function_progress_info_handle,
        progress: f64,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_table_function_set_user_data()`, or null if none was set.\n\n history:\n - unstable: v2.0.0\n\n @param info The filter pushdown info handle.\n @param data Receives the user data pointer.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_filter_pushdown_get_user_data(
        info: duckdb_v2_table_function_filter_pushdown_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set via `duckdb_v2_function_bind_set_bind_data()`, or null if none was set.\n\n This is the same object the init and exec callbacks later receive, so a predicate the callback accepts can be\n recorded in it for the scan to apply.\n\n history:\n - unstable: v2.0.0\n\n @param info The filter pushdown info handle.\n @param data Receives the bind data pointer.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_filter_pushdown_get_bind_data(
        info: duckdb_v2_table_function_filter_pushdown_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of filter predicates offered to the function.\n\n The predicates are combined with `AND`: every row the scan produces must satisfy all of them. Valid indices for\n `duckdb_v2_table_function_filter_pushdown_get_filter()` and `duckdb_v2_table_function_filter_pushdown_accept()` are\n `0` up to (but excluding) this count.\n\n history:\n - unstable: v2.0.0\n\n @param info The filter pushdown info handle.\n @param count Receives the number of predicates.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_filter_pushdown_get_filter_count(
        info: duckdb_v2_table_function_filter_pushdown_info_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the filter predicate at the given index.\n\n Fails if the index is out of bounds. The predicate is a bound expression evaluating to `BOOLEAN`; inspect it with\n `duckdb_v2_expression_get_type()` and the other `expression` functions, and resolve the column references it contains\n via `duckdb_v2_table_function_filter_pushdown_get_column_index()`. Borrowed; valid only for the duration of the\n callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The filter pushdown info handle.\n @param index The index of the predicate to retrieve.\n @param filter Receives the borrowed predicate.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_filter_pushdown_get_filter(
        info: duckdb_v2_table_function_filter_pushdown_info_handle,
        index: idx_t,
        filter: *mut duckdb_v2_expression_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Accepts the filter predicate at the given index: the function will apply it itself.\n\n The engine stops applying an accepted predicate, so the scan must produce only rows that satisfy it, or the query\n returns rows it should not. Predicates left unaccepted are applied by the engine as usual, so a callback that\n recognizes nothing can simply return. Fails if the index is out of bounds.\n\n history:\n - unstable: v2.0.0\n\n @param info The filter pushdown info handle.\n @param index The index of the predicate to accept.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_filter_pushdown_accept(
        info: duckdb_v2_table_function_filter_pushdown_info_handle,
        index: idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of columns the predicates can refer to.\n\n A column reference inside a predicate (`duckdb_v2_expression_column_ref_get_index()`) indexes the columns the query\n reads from the function, not the columns declared in bind. Valid indices for\n `duckdb_v2_table_function_filter_pushdown_get_column_index()` are `0` up to (but excluding) this count.\n\n history:\n - unstable: v2.0.0\n\n @param info The filter pushdown info handle.\n @param count Receives the number of referable columns.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_filter_pushdown_get_column_count(
        info: duckdb_v2_table_function_filter_pushdown_info_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Resolves a column reference found in a predicate to the declared column it refers to.\n\n Takes the index a `EXPRESSION_TYPE_BOUND_COLUMN_REF` node reports and returns the index of the column among the ones\n declared with `duckdb_v2_table_function_bind_add_result_column()`, in declaration order. Fails if the index is out of\n bounds.\n\n history:\n - unstable: v2.0.0\n\n @param info The filter pushdown info handle.\n @param index The column index reported by a column reference node.\n @param column_index Receives the index of the declared column.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_filter_pushdown_get_column_index(
        info: duckdb_v2_table_function_filter_pushdown_info_handle,
        index: idx_t,
        column_index: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_table_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The partition data info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_partition_data_get_user_data(
        info: duckdb_v2_table_function_partition_data_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The partition data info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_partition_data_get_bind_data(
        info: duckdb_v2_table_function_partition_data_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the global state set by the function's global init callback.\n\n Shared with every other thread scanning the function; access to it must be synchronized by the function.\n\n history:\n - unstable: v2.0.0\n\n @param info The partition data info handle.\n @param data Receives the global state pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_partition_data_get_global_state(
        info: duckdb_v2_table_function_partition_data_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the worker-local local state set by the function's local init callback, for the thread that produced the\n batch this call reports on. No other thread observes it, so it needs no synchronization.\n\n history:\n - unstable: v2.0.0\n\n @param info The partition data info handle.\n @param data Receives the local state pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_partition_data_get_local_state(
        info: duckdb_v2_table_function_partition_data_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns whether a downstream operator needs this batch's ordering position.\n\n `duckdb_v2_table_function_partition_data_set_batch_index()` must still be called even when this is false: the engine\n validates the reported value regardless of whether it is actually used for ordering, so `0` is always a safe answer\n when this reports false.\n\n history:\n - unstable: v2.0.0\n\n @param info The partition data info handle.\n @param required Receives whether a batch index is required.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_partition_data_requires_batch_index(
        info: duckdb_v2_table_function_partition_data_info_handle,
        required: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns whether a downstream operator needs this batch's values for a set of partitioning columns.\n\n When true, call `duckdb_v2_table_function_partition_data_set_partition_value()` once for every index in `[0, count)`,\n where `count` comes from `duckdb_v2_table_function_partition_data_get_partition_column_count()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The partition data info handle.\n @param required Receives whether partitioning column values are required.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_partition_data_requires_partition_columns(
        info: duckdb_v2_table_function_partition_data_info_handle,
        required: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of partitioning columns a downstream operator is requesting values for.\n\n `0` when `duckdb_v2_table_function_partition_data_requires_partition_columns()` is false. Valid indices for\n `duckdb_v2_table_function_partition_data_get_partition_column_index()` and\n `duckdb_v2_table_function_partition_data_set_partition_value()` are `0` up to (but excluding) this count.\n\n history:\n - unstable: v2.0.0\n\n @param info The partition data info handle.\n @param count Receives the number of requested partitioning columns.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_partition_data_get_partition_column_count(
        info: duckdb_v2_table_function_partition_data_info_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns which declared column the requested partitioning column at the given index stands for.\n\n The result indexes the columns declared with `duckdb_v2_table_function_bind_add_result_column()`, in declaration\n order. Fails if the index is out of bounds.\n\n history:\n - unstable: v2.0.0\n\n @param info The partition data info handle.\n @param index The index of the requested partitioning column.\n @param column_index Receives the index of the declared column.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_partition_data_get_partition_column_index(
        info: duckdb_v2_table_function_partition_data_info_handle,
        index: idx_t,
        column_index: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reports the ordering position of the batch the exec callback just produced.\n\n Required on every call, whether or not `duckdb_v2_table_function_partition_data_requires_batch_index()` is true: the\n engine validates the reported value regardless. Not calling this before the callback returns fails the query; `0` is\n always a safe answer when the batch index is not actually required. Must not decrease across successive calls on the\n same thread, must be unique across threads for the ordering to be meaningful, must be less than roughly `10^13`, and,\n when partitioning column values are also being reported, must change whenever those values change: the engine only\n re-reads them when the batch index changes, so reporting a new value under an unchanged batch index is treated as a\n caller error rather than applied. Fails with `ERROR_INPUT_INVALID` for an out-of-range value; a decreasing value or\n an unchanged value paired with changed partitioning columns fails the query once the callback returns.\n\n history:\n - unstable: v2.0.0\n\n @param info The partition data info handle.\n @param batch_index The batch's ordering position.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_partition_data_set_batch_index(
        info: duckdb_v2_table_function_partition_data_info_handle,
        batch_index: idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reports the single value of the partitioning column at the given index, for the batch the exec callback just\n produced.\n\n Every partition reported this way carries exactly one distinct value for the column, so the value serves as both the\n minimum and maximum of the partition's range. The value is borrowed and copied, and must be of the declared type of\n the corresponding result column. Required once for every index in `[0,\n `duckdb_v2_table_function_partition_data_get_partition_column_count()`)` before the callback returns; calling it\n again for the same index overwrites the previous value. The reported value only takes effect together with a changed\n `duckdb_v2_table_function_partition_data_set_batch_index()`: reporting a different value under an unchanged batch\n index fails the query once the callback returns. Fails with `ERROR_INPUT_INVALID` when the index is out of bounds or\n the value's type does not match.\n\n history:\n - unstable: v2.0.0\n\n @param info The partition data info handle.\n @param index The index of the partitioning column being reported.\n @param value The single value of the partitioning column. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_partition_data_set_partition_value(
        info: duckdb_v2_table_function_partition_data_info_handle,
        index: idx_t,
        value: duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_table_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The partitioning info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_partitioning_get_user_data(
        info: duckdb_v2_table_function_partitioning_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The partitioning info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_partitioning_get_bind_data(
        info: duckdb_v2_table_function_partitioning_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of columns the optimizer is asking about: the candidate `GROUP BY` column set.\n\n Valid indices for `duckdb_v2_table_function_partitioning_get_partition_column_index()` are `0` up to (but excluding)\n this count.\n\n history:\n - unstable: v2.0.0\n\n @param info The partitioning info handle.\n @param count Receives the number of columns in the candidate set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_partitioning_get_partition_column_count(
        info: duckdb_v2_table_function_partitioning_info_handle,
        count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns which declared column the candidate `GROUP BY` column at the given index stands for.\n\n The result indexes the columns declared with `duckdb_v2_table_function_bind_add_result_column()`, in declaration\n order. Fails if the index is out of bounds.\n\n history:\n - unstable: v2.0.0\n\n @param info The partitioning info handle.\n @param index The index of the candidate column.\n @param column_index Receives the index of the declared column.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_partitioning_get_partition_column_index(
        info: duckdb_v2_table_function_partitioning_info_handle,
        index: idx_t,
        column_index: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reports whether every partition the scan produces carries exactly one distinct value for the candidate `GROUP BY`\n column set.\n\n Only `TABLE_PARTITION_INFO_SINGLE_VALUE_PARTITIONS` unlocks the partitioned aggregate optimization; any other value\n keeps the regular hash aggregate. A callback that never calls this is treated as reporting\n `TABLE_PARTITION_INFO_NOT_PARTITIONED`. Fails with `ERROR_INPUT_INVALID` when partition_info is not one of the enum's\n declared values.\n\n history:\n - unstable: v2.0.0\n\n @param info The partitioning info handle.\n @param partition_info Whether, and how, the scan is partitioned by the candidate column set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_partitioning_set_partition_info(
        info: duckdb_v2_table_function_partitioning_info_handle,
        partition_info: DUCKDB_V2_TABLE_PARTITION_INFO,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the table function, making it available for use in SQL queries.\n\n The function is registered on the connection's database, visible to every connection, in the connection's\n transaction: inside an explicit transaction, it is invisible to other connections until the transaction commits, and\n a rollback undoes it. Registration requires a name, a bind callback and an exec callback, and rejects a signature\n that declares a return type, since a table function declares the columns it returns from its bind callback. The table\n function must have been created through a factory of the same database. The caller still owns the handle after\n registration and must destroy it with `duckdb_v2_table_function_destroy()`, which does not affect the registered\n function.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection to register on.\n @param function The table function to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_register_table_function(
        conn: duckdb_v2_connection_handle,
        function: duckdb_v2_table_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the table function, making it available for use in SQL queries.\n\n The function is registered on the loading extension's database and attributed to the extension. Use this from the\n extension's load callback. Registration requires a name, a bind callback and an exec callback, and rejects a\n signature that declares a return type, since a table function declares the columns it returns from its bind callback.\n The table function must have been created through a factory of the same database. The caller still owns the handle\n after registration and must destroy it with `duckdb_v2_table_function_destroy()`, which does not affect the\n registered function.\n\n history:\n - unstable: v2.0.0\n\n @param extension The loading extension.\n @param function The table function to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_extension_register_table_function(
        extension: duckdb_v2_extension_handle,
        function: duckdb_v2_table_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the table function, releasing its resources.\n\n Null-safe: passing a null pointer or null handle is a no-op. The handle is set to null on return to prevent\n double-destruction. Destroying the handle after registration does not affect the registered function.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_destroy(function: *mut duckdb_v2_table_function_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional claim batch callback of the table function.\n\n With a claim batch callback, a scanning thread works through the scan one batch at a time: the callback claims the\n next batch of work (e.g. the next block of a file) for the thread's local state, typically from the shared global\n state, and the exec callback then produces the rows of that batch only, leaving the output chunk empty once the batch\n is exhausted. A batch is claimed before the exec callback first runs on a thread, and again whenever the exec\n callback leaves the output chunk empty; the scan ends for a thread once the claim batch callback does not claim a\n batch.\n\n Telling the batches apart lets a caller that scans several batches in parallel put their rows back in the order of\n the batches, e.g. a multi-file function registered with `duckdb_v2_connection_register_multi_file_function()` or\n `duckdb_v2_extension_register_multi_file_function()` claims the batches of the function itself, so that the rows of a\n file keep their order also when several threads scan it.\n\n The callback runs while the work of the scan is handed out to the threads, possibly while every other scanning thread\n waits for it. It should therefore only claim the work - e.g. reserve the number of the next block - and leave reading\n it to the exec callback.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the claim batch callback of.\n @param callback The claim batch callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_set_claim_batch_callback(
        function: duckdb_v2_table_function_handle,
        callback: duckdb_v2_table_function_claim_batch_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set on the table function via `duckdb_v2_table_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The claim batch info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_claim_batch_get_user_data(
        info: duckdb_v2_table_function_claim_batch_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data set by the function's bind callback.\n\n history:\n - unstable: v2.0.0\n\n @param info The claim batch info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_claim_batch_get_bind_data(
        info: duckdb_v2_table_function_claim_batch_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the global state set by the function's global init callback.\n\n Shared with every other thread scanning the function; access to it must be synchronized by the function.\n\n history:\n - unstable: v2.0.0\n\n @param info The claim batch info handle.\n @param data Receives the global state pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_claim_batch_get_global_state(
        info: duckdb_v2_table_function_claim_batch_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the local state set by the function's local init callback, for the thread claiming a batch.\n\n history:\n - unstable: v2.0.0\n\n @param info The claim batch info handle.\n @param data Receives the local state pointer for the claiming thread, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_claim_batch_get_local_state(
        info: duckdb_v2_table_function_claim_batch_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Reports whether the callback claimed a batch for the thread.\n\n A callback that returns without calling this claimed nothing, which ends the scan for the thread.\n\n history:\n - unstable: v2.0.0\n\n @param info The claim batch info handle.\n @param claimed Whether a batch was claimed.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_claim_batch_set_claimed(
        info: duckdb_v2_table_function_claim_batch_info_handle,
        claimed: bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the optional \"get bind info\" callback of the table function.\n\n The engine invokes the callback with the bind data of a bound call when it needs to know more about the call than its\n columns. E.g. a multi-file function registered with `duckdb_v2_connection_register_multi_file_function()` or\n `duckdb_v2_extension_register_multi_file_function()` asks the function it wraps for every file it binds: it maps the\n columns of the files onto the columns of its scan by the identifiers the callback reports, and exposes the options it\n reports as the metadata of the reader of the file. The callback may be invoked more than once for the same bind data,\n so it should only report what the bind already determined.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the callback of.\n @param callback The \"get bind info\" callback to set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_set_get_bind_info_callback(
        function: duckdb_v2_table_function_handle,
        callback: duckdb_v2_table_function_get_bind_info_callback_fn,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the user data set via `duckdb_v2_table_function_set_user_data()`.\n\n history:\n - unstable: v2.0.0\n\n @param info The get bind info handle.\n @param data Receives the user data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_get_bind_info_get_user_data(
        info: duckdb_v2_table_function_get_bind_info_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Retrieves the bind data the function's bind callback set for the bound call being described.\n\n history:\n - unstable: v2.0.0\n\n @param info The get bind info handle.\n @param data Receives the bind data pointer, or null if none was set.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_get_bind_info_get_bind_data(
        info: duckdb_v2_table_function_get_bind_info_info_handle,
        data: *mut *mut ::std::os::raw::c_void,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Attaches an identifier to a result column of the bound call, or to a field nested inside one.\n\n A multi-file reader can then map the columns of every file onto the columns of its scan by identifier rather than by\n name - e.g. by the field ids of a file format that carries them, so that renamed columns and fields are still found.\n An identifier is an INTEGER field id or a VARCHAR name.\n\n The nested field is addressed by a path of child indexes, starting at the result column at `column_index`: a STRUCT\n field by its index, the elements of a LIST or ARRAY by `0`, the keys of a MAP by `0` and its values by `1`, and a\n UNION member by its index. An empty path addresses the result column itself. Setting an identifier again for the same\n column or field replaces it. Fails with `ERROR_INPUT_INVALID` when the column index is out of range, or the path does\n not address a nested field of the column's type.\n\n history:\n - unstable: v2.0.0\n\n @param info The get bind info handle.\n @param column_index The index of the result column, in the order the bind callback declared the columns.\n @param child_path The path of child indexes addressing the nested field, or null for the column itself.\n @param child_path_length The number of entries in the path, 0 for the column itself.\n @param identifier The identifier, an INTEGER or VARCHAR value. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_get_bind_info_set_column_identifier(
        info: duckdb_v2_table_function_get_bind_info_info_handle,
        column_index: idx_t,
        child_path: *const idx_t,
        child_path_length: idx_t,
        identifier: duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets an option describing the bound call: a key-value fact about what the call reads, e.g. a property of the file it\n reads. Setting a key again replaces its value.\n\n A multi-file function registered with `duckdb_v2_connection_register_multi_file_function()` or\n `duckdb_v2_extension_register_multi_file_function()` exposes the options of the function it wraps as the metadata of\n the reader of each file, e.g. to a custom multi-file reader of another extension.\n\n history:\n - unstable: v2.0.0\n\n @param info The get bind info handle.\n @param key The key of the option. Borrowed and copied.\n @param value The value of the option. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_table_function_get_bind_info_set_option(
        info: duckdb_v2_table_function_get_bind_info_info_handle,
        key: *mut duckdb_v2_str,
        value: duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a new multi-file function through a factory.\n\n The function starts out empty: give it a name with `duckdb_v2_multi_file_function_set_name()` and the single-file\n function it wraps with `duckdb_v2_multi_file_function_set_single_file_function()`, then make it available with\n `duckdb_v2_connection_register_multi_file_function()` or `duckdb_v2_extension_register_multi_file_function()`. The\n caller owns the returned handle and must destroy it with `duckdb_v2_multi_file_function_destroy()`, also after\n registration.\n\n The multi-file function can only be registered on the database the factory belongs to.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create the multi-file function through.\n @param function On success, receives the newly created multi-file function. Owned by the caller.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_multi_file_function_create(
        factory: duckdb_v2_factory_handle,
        function: *mut duckdb_v2_multi_file_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the name of the multi-file function, as SQL will call it.\n\n The name is borrowed and copied. Calling this again replaces the previous name. A name must be set before\n registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the name of.\n @param name The name to set. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_multi_file_function_set_name(
        function: duckdb_v2_multi_file_function_handle,
        name: *mut duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the name of the table function that reads a single file, which the multi-file function wraps.\n\n The single-file function must be registered before the multi-file function is, and must take the file to read as its\n only positional parameter, of type ANY. It is bound once for every file that is read, and receives the file the way a\n multi-file function takes one: as the VARCHAR path of the file when there is nothing more to know about it, and\n otherwise as a STRUCT holding the path in its `filename` field and the options to open the file with in its other\n fields - e.g. the size of the file, as a file system reported it while globbing, or the options a caller passed along\n with the file (`read_x([{'filename': 'f.x', 'file_size': 42}])`). Opening the file with those options, set with\n `duckdb_v2_file_open_options_set_value()`, lets the file system skip work it would otherwise repeat, such as asking a\n remote store for the size of the file. A single-file function that takes a VARCHAR parameter instead is still\n accepted, and only receives the path. Every named parameter the single-file function declares is also a named\n parameter of the multi-file function, forwarded to it as given. Everything that involves several files - globbing,\n lists of files, hive partitioning, the `filename` column, `union_by_name` and the like - is provided by the\n multi-file function on top of it. The name is borrowed and copied. A single-file function must be set before\n registration.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the single-file function of.\n @param name The name of the registered single-file table function. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_multi_file_function_set_single_file_function(
        function: duckdb_v2_multi_file_function_handle,
        name: *mut duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets how the files the function reads are referred to in messages, e.g. \"Avro\" or \"JSON\".\n\n Optional: without it, the files are referred to by the name of the multi-file function. The name is borrowed and\n copied.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the reader type of.\n @param reader_type The reader type. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_multi_file_function_set_reader_type(
        function: duckdb_v2_multi_file_function_handle,
        reader_type: *mut duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Sets the file extension of the files the function reads, e.g. \"avro\".\n\n Optional. With a file extension, a path that names a directory rather than a file reads the files with that extension\n inside it. Without one, the paths passed to the function must match at least one file. The extension is given without\n a leading dot, and is borrowed and copied.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to set the file extension of.\n @param extension The file extension, without a leading dot. Borrowed and copied.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_multi_file_function_set_file_extension(
        function: duckdb_v2_multi_file_function_handle,
        extension: *mut duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the multi-file function, making it available for use in SQL queries.\n\n The function is registered on the connection's database, visible to every connection, in the connection's\n transaction: inside an explicit transaction, it is invisible to other connections until the transaction commits, and\n a rollback undoes it. It can then be called with the path of a single file, a glob pattern, or a list of either, and\n accepts the options every multi-file function accepts (e.g. `filename`, `hive_partitioning`, `union_by_name`) next to\n the named parameters of the single-file function. Registration requires a name and a single-file function, and fails\n when no table function by that name is registered or it does not take the path of the file to read as its only\n positional parameter (see `duckdb_v2_multi_file_function_set_single_file_function()`). The multi-file function must\n have been created through a factory of the same database. The caller still owns the handle after registration and\n must destroy it with `duckdb_v2_multi_file_function_destroy()`, which does not affect the registered function.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection to register on.\n @param function The multi-file function to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_connection_register_multi_file_function(
        conn: duckdb_v2_connection_handle,
        function: duckdb_v2_multi_file_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Registers the multi-file function, making it available for use in SQL queries.\n\n The function is registered on the loading extension's database and attributed to the extension. Use this from the\n extension's load callback. It can then be called with the path of a single file, a glob pattern, or a list of either,\n and accepts the options every multi-file function accepts (e.g. `filename`, `hive_partitioning`, `union_by_name`)\n next to the named parameters of the single-file function. Registration requires a name and a single-file function,\n and fails when no table function by that name is registered or it does not take the path of the file to read as its\n only positional parameter (see `duckdb_v2_multi_file_function_set_single_file_function()`). The multi-file function\n must have been created through a factory of the same database. The caller still owns the handle after registration\n and must destroy it with `duckdb_v2_multi_file_function_destroy()`, which does not affect the registered function.\n\n history:\n - unstable: v2.0.0\n\n @param extension The loading extension.\n @param function The multi-file function to register.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_extension_register_multi_file_function(
        extension: duckdb_v2_extension_handle,
        function: duckdb_v2_multi_file_function_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the multi-file function, releasing its resources.\n\n Null-safe: passing a null pointer or null handle is a no-op. The handle is set to null on return to prevent\n double-destruction. Destroying the handle after registration does not affect the registered function.\n\n history:\n - unstable: v2.0.0\n\n @param function The function to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_multi_file_function_destroy(
        function: *mut duckdb_v2_multi_file_function_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys a value handle.\n\n Null-safe: passing nullptr or a slot already set to nullptr is a no-op. On success the slot is set to nullptr.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_destroy(value: *mut duckdb_v2_value_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a BOOLEAN.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload as a bool.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_bool(
        value: duckdb_v2_value_handle,
        out: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a UTINYINT.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload as a uint8_t.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_utinyint(
        value: duckdb_v2_value_handle,
        out: *mut u8,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a USMALLINT.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload as a uint16_t.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_usmallint(
        value: duckdb_v2_value_handle,
        out: *mut u16,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a UINTEGER.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload as a uint32_t.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_uint(
        value: duckdb_v2_value_handle,
        out: *mut u32,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a UBIGINT.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload as a uint64_t.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_ubigint(
        value: duckdb_v2_value_handle,
        out: *mut u64,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a UHUGEINT.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload as a uint128_t.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_uhugeint(
        value: duckdb_v2_value_handle,
        out: *mut duckdb_v2_uhugeint_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a TINYINT.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload as an int8_t.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_tinyint(
        value: duckdb_v2_value_handle,
        out: *mut i8,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a SMALLINT.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload as an int16_t.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_smallint(
        value: duckdb_v2_value_handle,
        out: *mut i16,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as an INTEGER.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload as an int32_t.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_int(
        value: duckdb_v2_value_handle,
        out: *mut i32,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a BIGINT.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload as an int64_t.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_bigint(
        value: duckdb_v2_value_handle,
        out: *mut i64,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a HUGEINT.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload as an int128_t.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_hugeint(
        value: duckdb_v2_value_handle,
        out: *mut duckdb_v2_hugeint_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a VARCHAR.\n\n The string is borrowed from the value and stays valid until the value is destroyed. That borrow is why this getter\n does not convert: a converted copy would not outlive the call. A value of any other type id, and a NULL value, return\n ERROR_INPUT_INVALID.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload as a UTF-8 string. The returned string is borrowed and valid until the value handle\n is destroyed.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_varchar(
        value: duckdb_v2_value_handle,
        out: *mut duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a byte string: a BLOB, or the storage bytes of a BIT or BIGNUM.\n\n The string is borrowed from the value and stays valid until the value is destroyed. That borrow is why this getter\n does not convert: a converted copy would not outlive the call. A value of any other type id, and a NULL value, return\n ERROR_INPUT_INVALID.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload as a byte string. The returned string is borrowed and valid until the value handle is\n destroyed.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_blob(
        value: duckdb_v2_value_handle,
        out: *mut duckdb_v2_str,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a FLOAT.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload as a float.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_float(
        value: duckdb_v2_value_handle,
        out: *mut f32,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a DOUBLE.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload as a double.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_double(
        value: duckdb_v2_value_handle,
        out: *mut f64,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a DATE.\n\n The payload is days since 1970-01-01, the same unit a vector of this type exposes.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_date(
        value: duckdb_v2_value_handle,
        out: *mut i32,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a TIME.\n\n The payload is microseconds since midnight, the same unit a vector of this type exposes.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_time(
        value: duckdb_v2_value_handle,
        out: *mut i64,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a TIME_NS.\n\n The payload is nanoseconds since midnight, the same unit a vector of this type exposes.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_time_ns(
        value: duckdb_v2_value_handle,
        out: *mut i64,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a TIME_TZ.\n\n The payload packs the time of day and the UTC offset into one integer, in the committed layout: micros in the high 40\n bits, a biased offset in the low 24. The same form a vector of this type exposes.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_time_tz(
        value: duckdb_v2_value_handle,
        out: *mut u64,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a TIMESTAMP.\n\n The payload is microseconds since 1970-01-01, the same unit a vector of this type exposes.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_timestamp(
        value: duckdb_v2_value_handle,
        out: *mut i64,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a TIMESTAMP_SEC.\n\n The payload is seconds since 1970-01-01, the same unit a vector of this type exposes.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_timestamp_sec(
        value: duckdb_v2_value_handle,
        out: *mut i64,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a TIMESTAMP_MS.\n\n The payload is milliseconds since 1970-01-01, the same unit a vector of this type exposes.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_timestamp_ms(
        value: duckdb_v2_value_handle,
        out: *mut i64,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a TIMESTAMP_NS.\n\n The payload is nanoseconds since 1970-01-01, the same unit a vector of this type exposes.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_timestamp_ns(
        value: duckdb_v2_value_handle,
        out: *mut i64,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a TIMESTAMP_TZ.\n\n The payload is microseconds since 1970-01-01, in UTC, the same unit a vector of this type exposes.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_timestamp_tz(
        value: duckdb_v2_value_handle,
        out: *mut i64,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a TIMESTAMP_TZ_NS.\n\n The payload is nanoseconds since 1970-01-01, in UTC, the same unit a vector of this type exposes.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_timestamp_tz_ns(
        value: duckdb_v2_value_handle,
        out: *mut i64,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as an INTERVAL.\n\n The payload is the (months, days, micros) triple, the same unit a vector of this type exposes.\n\n A value of a different type is converted through the default cast set, on a copy, so reading never alters the value.\n An unsupported conversion returns ERROR_INPUT_INVALID, as does a NULL value.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the payload.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_interval(
        value: duckdb_v2_value_handle,
        out: *mut duckdb_v2_interval_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a UUID, in its internal 128-bit form.\n\n The dual of value_create_uuid: the storage form a vector element holds, with the high bit flipped so the integer\n sorts, rather than the canonical byte order. A value of any other type id, and a NULL value, return\n ERROR_INPUT_INVALID.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the internal 128-bit storage form.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_uuid(
        value: duckdb_v2_value_handle,
        out: *mut duckdb_v2_hugeint_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the value as a DECIMAL: its backing integer plus the width and scale of its type.\n\n The integer is the value scaled by 10^scale — the dual of value_create_decimal — widened to 128 bits from whatever\n storage tier the width selects. The integer getters convert, so a DECIMAL read through value_get_bigint is its\n numeric value with the fraction dropped; this one always reports storage instead, together with the scale needed to\n interpret it. A value of any other type id, and a NULL value, return ERROR_INPUT_INVALID.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out Receives the backing integer, scaled by 10^scale.\n @param out_width Receives the total digit count of the value's type.\n @param out_scale Receives the digits after the decimal point.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_decimal(
        value: duckdb_v2_value_handle,
        out: *mut duckdb_v2_hugeint_t,
        out_width: *mut u8,
        out_scale: *mut u8,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Unwraps the logical type carried by a TYPE value.\n\n Returns ERROR_INPUT_INVALID unless the value is a non-NULL TYPE value. The returned logical type is caller-owned and\n must be destroyed via logical_type_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out_type Receives the owned logical type.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_type(
        value: duckdb_v2_value_handle,
        out_type: *mut duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a NULL value of the given logical type.\n\n The logical type is borrowed and copied into the value, so the caller can destroy it independently.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param type The borrowed logical type to attach to the NULL value.\n @param out_value Receives the new NULL value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_null(
        factory: duckdb_v2_factory_handle,
        type_: duckdb_v2_logical_type_handle,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a BOOLEAN value from a bool.\n\n The input is copied in. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The bool to wrap.\n @param out_value Receives the new BOOLEAN value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_bool(
        factory: duckdb_v2_factory_handle,
        in_value: bool,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a UTINYINT value from a uint8_t.\n\n The input is copied in. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The uint8_t to wrap.\n @param out_value Receives the new UTINYINT value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_utinyint(
        factory: duckdb_v2_factory_handle,
        in_value: u8,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a USMALLINT value from a uint16_t.\n\n The input is copied in. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The uint16_t to wrap.\n @param out_value Receives the new USMALLINT value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_usmallint(
        factory: duckdb_v2_factory_handle,
        in_value: u16,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a UINTEGER value from a uint32_t.\n\n The input is copied in. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The uint32_t to wrap.\n @param out_value Receives the new UINTEGER value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_uint(
        factory: duckdb_v2_factory_handle,
        in_value: u32,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a UBIGINT value from a uint64_t.\n\n The input is copied in. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The uint64_t to wrap.\n @param out_value Receives the new UBIGINT value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_ubigint(
        factory: duckdb_v2_factory_handle,
        in_value: u64,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a UHUGEINT value from a uint128_t.\n\n The input is copied in. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The uint128_t to wrap.\n @param out_value Receives the new UHUGEINT value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_uhugeint(
        factory: duckdb_v2_factory_handle,
        in_value: *const duckdb_v2_uhugeint_t,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a TINYINT value from an int8_t.\n\n The input is copied in. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The int8_t to wrap.\n @param out_value Receives the new TINYINT value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_tinyint(
        factory: duckdb_v2_factory_handle,
        in_value: i8,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a SMALLINT value from an int16_t.\n\n The input is copied in. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The int16_t to wrap.\n @param out_value Receives the new SMALLINT value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_smallint(
        factory: duckdb_v2_factory_handle,
        in_value: i16,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates an INTEGER value from an int32_t.\n\n The input is copied in. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The int32_t to wrap.\n @param out_value Receives the new INTEGER value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_int(
        factory: duckdb_v2_factory_handle,
        in_value: i32,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a BIGINT value from an int64_t.\n\n The input is copied in. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The int64_t to wrap.\n @param out_value Receives the new BIGINT value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_bigint(
        factory: duckdb_v2_factory_handle,
        in_value: i64,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a HUGEINT value from an int128_t.\n\n The input is copied in. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The int128_t to wrap.\n @param out_value Receives the new HUGEINT value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_hugeint(
        factory: duckdb_v2_factory_handle,
        in_value: *const duckdb_v2_hugeint_t,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a VARCHAR value from a UTF-8 string.\n\n The input is copied in. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The UTF-8 string to wrap. May be null only when len is 0 (empty string).\n @param out_value Receives the new VARCHAR value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_varchar(
        factory: duckdb_v2_factory_handle,
        in_value: *const duckdb_v2_str,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a BLOB value from a byte string.\n\n The input is copied in. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The byte string to wrap. May be null only when len is 0 (empty string).\n @param out_value Receives the new BLOB value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_blob(
        factory: duckdb_v2_factory_handle,
        in_value: *const duckdb_v2_str,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a FLOAT value from a float.\n\n The input is copied in. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The float to wrap.\n @param out_value Receives the new FLOAT value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_float(
        factory: duckdb_v2_factory_handle,
        in_value: f32,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a DOUBLE value from a double.\n\n The input is copied in. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The double to wrap.\n @param out_value Receives the new DOUBLE value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_double(
        factory: duckdb_v2_factory_handle,
        in_value: f64,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a TYPE value from a logical type.\n\n The logical type is borrowed and copied into the value, so the caller can destroy it independently.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_type The borrowed logical type to wrap.\n @param out_value Receives the new TYPE value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_type(
        factory: duckdb_v2_factory_handle,
        in_type: duckdb_v2_logical_type_handle,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a DATE value.\n\n The payload is days since 1970-01-01, the same unit value_get_date reports. It is not range-checked here; value_cast\n is the validating path. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The payload to wrap.\n @param out_value Receives the new DATE value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_date(
        factory: duckdb_v2_factory_handle,
        in_value: i32,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a TIME value.\n\n The payload is microseconds since midnight, the same unit value_get_time reports. It is not range-checked here;\n value_cast is the validating path. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The payload to wrap.\n @param out_value Receives the new TIME value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_time(
        factory: duckdb_v2_factory_handle,
        in_value: i64,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a TIME_NS value.\n\n The payload is nanoseconds since midnight, the same unit value_get_time_ns reports. It is not range-checked here;\n value_cast is the validating path. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The payload to wrap.\n @param out_value Receives the new TIME_NS value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_time_ns(
        factory: duckdb_v2_factory_handle,
        in_value: i64,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a TIME_TZ value.\n\n The payload packs the time of day and the UTC offset into one integer, in the committed layout: micros in the high 40\n bits, a biased offset in the low 24. The same form value_get_time_tz reports. It is not range-checked here;\n value_cast is the validating path. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The payload to wrap.\n @param out_value Receives the new TIME_TZ value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_time_tz(
        factory: duckdb_v2_factory_handle,
        in_value: u64,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a TIMESTAMP value.\n\n The payload is microseconds since 1970-01-01, the same unit value_get_timestamp reports. It is not range-checked\n here; value_cast is the validating path. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The payload to wrap.\n @param out_value Receives the new TIMESTAMP value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_timestamp(
        factory: duckdb_v2_factory_handle,
        in_value: i64,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a TIMESTAMP_SEC value.\n\n The payload is seconds since 1970-01-01, the same unit value_get_timestamp_sec reports. It is not range-checked here;\n value_cast is the validating path. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The payload to wrap.\n @param out_value Receives the new TIMESTAMP_SEC value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_timestamp_sec(
        factory: duckdb_v2_factory_handle,
        in_value: i64,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a TIMESTAMP_MS value.\n\n The payload is milliseconds since 1970-01-01, the same unit value_get_timestamp_ms reports. It is not range-checked\n here; value_cast is the validating path. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The payload to wrap.\n @param out_value Receives the new TIMESTAMP_MS value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_timestamp_ms(
        factory: duckdb_v2_factory_handle,
        in_value: i64,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a TIMESTAMP_NS value.\n\n The payload is nanoseconds since 1970-01-01, the same unit value_get_timestamp_ns reports. It is not range-checked\n here; value_cast is the validating path. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The payload to wrap.\n @param out_value Receives the new TIMESTAMP_NS value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_timestamp_ns(
        factory: duckdb_v2_factory_handle,
        in_value: i64,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a TIMESTAMP_TZ value.\n\n The payload is microseconds since 1970-01-01, in UTC, the same unit value_get_timestamp_tz reports. It is not\n range-checked here; value_cast is the validating path. The returned value is caller-owned; destroy it via\n value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The payload to wrap.\n @param out_value Receives the new TIMESTAMP_TZ value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_timestamp_tz(
        factory: duckdb_v2_factory_handle,
        in_value: i64,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a TIMESTAMP_TZ_NS value.\n\n The payload is nanoseconds since 1970-01-01, in UTC, the same unit value_get_timestamp_tz_ns reports. It is not\n range-checked here; value_cast is the validating path. The returned value is caller-owned; destroy it via\n value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The payload to wrap.\n @param out_value Receives the new TIMESTAMP_TZ_NS value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_timestamp_tz_ns(
        factory: duckdb_v2_factory_handle,
        in_value: i64,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a INTERVAL value.\n\n The payload is the (months, days, micros) triple, the same unit value_get_interval reports. It is not range-checked\n here; value_cast is the validating path. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The payload to wrap.\n @param out_value Receives the new INTERVAL value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_interval(
        factory: duckdb_v2_factory_handle,
        in_value: *const duckdb_v2_interval_t,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a DECIMAL value from its backing integer.\n\n The value is scaled by 10^scale, so (18500, 18, 3) is 18.500. width is the total digit count and must be 1..38; scale\n is the number of digits after the point and must not exceed width. Violating either returns ERROR_INPUT_INVALID, as\n does a value too wide for the storage tier the width selects. The value itself is not range-checked against the\n width; value_cast is the validating path.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The backing integer, scaled by 10^scale.\n @param width Total digit count, 1..38.\n @param scale Digits after the decimal point; must not exceed width.\n @param out_value Receives the new DECIMAL value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_decimal(
        factory: duckdb_v2_factory_handle,
        in_value: *const duckdb_v2_hugeint_t,
        width: u8,
        scale: u8,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a UUID value from its internal 128-bit form.\n\n The payload is the storage form a vector element holds, not the canonical byte order: the high bit is flipped so the\n integer sorts. To build one from canonical text, cast a VARCHAR with value_cast instead, which is also how a UUID\n renders back.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The internal 128-bit storage form.\n @param out_value Receives the new UUID value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_uuid(
        factory: duckdb_v2_factory_handle,
        in_value: *const duckdb_v2_hugeint_t,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a BIT value from its wire bytes.\n\n The wire form is a mandatory padding-header byte — the count of leading bits in the first data byte that are not part\n of the bit string — followed by the data bytes, so the input must be at least 1 byte. These are the same bytes\n value_get_blob reports back.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The wire bytes, a padding header byte followed by data. Must be at least 1 byte.\n @param out_value Receives the new BIT value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_bit(
        factory: duckdb_v2_factory_handle,
        in_value: *const duckdb_v2_str,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a BIGNUM value from its storage bytes.\n\n The bytes are opaque storage, as produced by bignum_encode from a magnitude and a sign flag; a negative is stored\n bit-inverted behind a header, so these are not the magnitude bytes. The header plus at least one magnitude byte means\n the input must exceed 3 bytes. These are the same bytes value_get_blob reports back, for bignum_decode to translate.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param in_value The opaque storage bytes from bignum_encode. Must exceed 3 bytes.\n @param out_value Receives the new BIGNUM value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_bignum(
        factory: duckdb_v2_factory_handle,
        in_value: *const duckdb_v2_str,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a LIST value from its elements.\n\n The child type is the common type of the elements, resolved by the same rule a SQL list literal follows, and every\n element is cast to it; a set with no common type surfaces the cast error. Pass child_type to name the type instead,\n which is also how an empty list is built: with child_type NULL, an empty element array has no type to resolve and\n returns ERROR_INPUT_INVALID.\n\n The elements are borrowed and copied in, and a NULL element becomes a typed NULL. The type is rebuilt from its child,\n so an alias on the outer LIST type is not preserved; value_cast is the alias-preserving path.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param child_type Optional. The element type. Pass NULL to resolve it from the elements.\n @param children An array of child_count elements. Borrowed (copied in). Pass NULL when child_count is 0.\n @param child_count The number of elements.\n @param out_value Receives the new composite value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_list(
        factory: duckdb_v2_factory_handle,
        child_type: duckdb_v2_logical_type_handle,
        children: *const duckdb_v2_value_handle,
        child_count: idx_t,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates an ARRAY value from its elements, sized by their count.\n\n The child type is resolved exactly as for value_create_list, and child_type names it explicitly the same way. The\n minimum array size is 1, so an empty element array returns ERROR_INPUT_INVALID whether or not child_type is given.\n\n The elements are borrowed and copied in, and a NULL element becomes a typed NULL.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param child_type Optional. The element type. Pass NULL to resolve it from the elements.\n @param children An array of child_count elements. Borrowed (copied in). Pass NULL when child_count is 0.\n @param child_count The number of elements.\n @param out_value Receives the new composite value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_array(
        factory: duckdb_v2_factory_handle,
        child_type: duckdb_v2_logical_type_handle,
        children: *const duckdb_v2_value_handle,
        child_count: idx_t,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a STRUCT value from named fields, in order.\n\n Each field keeps its own child's type, so there is nothing to resolve across them; names and children are parallel\n arrays of field_count entries. An empty field list builds the empty struct, which is a real type.\n\n The names and children are borrowed and copied in, and a NULL child becomes a typed NULL. Duplicate field names are\n rejected.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param names An array of field_count field names. Pass NULL when field_count is 0.\n @param children An array of field_count field values. Borrowed (copied in). Pass NULL when field_count is 0.\n @param field_count The number of fields.\n @param out_value Receives the new composite value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_struct(
        factory: duckdb_v2_factory_handle,
        names: *const duckdb_v2_identifier_t,
        children: *const duckdb_v2_value_handle,
        field_count: idx_t,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a TUPLE value from positional fields.\n\n TUPLE is the unnamed struct: the same positional children as value_create_struct, under a distinct type id and with\n no names. Each field keeps its own child's type. An empty field list builds the empty tuple, which is a real type.\n\n The children are borrowed and copied in, and a NULL child becomes a typed NULL.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param children An array of field_count field values. Borrowed (copied in). Pass NULL when field_count is 0.\n @param field_count The number of fields.\n @param out_value Receives the new composite value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_tuple(
        factory: duckdb_v2_factory_handle,
        children: *const duckdb_v2_value_handle,
        field_count: idx_t,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates a MAP value from parallel key and value arrays.\n\n The key and value types are the common types of the keys and of the values, resolved as for value_create_list, and\n every entry is cast to them. Pass key_type and value_type to name them instead, which is also how an empty map is\n built: with both NULL, empty key and value arrays have no types to resolve and return ERROR_INPUT_INVALID.\n\n Keys and values are borrowed and copied in, and the two arrays must be the same length. Keys must be non-NULL and\n unique; both are enforced.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory to create with.\n @param key_type Optional. The key type. Pass NULL to resolve it from the keys.\n @param value_type Optional. The value type. Pass NULL to resolve it from the values.\n @param keys An array of entry_count keys. Borrowed (copied in). Pass NULL when entry_count is 0.\n @param values An array of entry_count values, parallel to keys. Borrowed (copied in). Pass NULL when entry_count is\n 0.\n @param entry_count The number of entries.\n @param out_value Receives the new composite value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_create_map(
        factory: duckdb_v2_factory_handle,
        key_type: duckdb_v2_logical_type_handle,
        value_type: duckdb_v2_logical_type_handle,
        keys: *const duckdb_v2_value_handle,
        values: *const duckdb_v2_value_handle,
        entry_count: idx_t,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the number of child values of a value.\n\n Per type kind: the element count for LIST and ARRAY; the field count for STRUCT and TUPLE; twice the entry count for\n MAP, whose children alternate key, value; and 2 for UNION, the tag plus the active member. Everything else reports 0,\n NULL values of any nested type included.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out_count Receives the number of children.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_child_count(
        value: duckdb_v2_value_handle,
        out_count: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns one child of a composite value as an owned copy.\n\n LIST and ARRAY children are the elements. STRUCT and TUPLE children are the fields in declared order, and a STRUCT's\n field names come from its type, via logical_type_get_param. MAP children alternate key, value, symmetric with\n value_create_map. UNION children are [0] the tag, as a UTINYINT value, and [1] the active member, because a union\n value holds only that one member.\n\n Note the divergence from vector_get_child, which descends structurally and so exposes [0] = tag and [1..N] = ALL\n members. Code written to descend generically over both must account for that difference.\n\n An out-of-range index returns ERROR_INPUT_INVALID, as does any index on a non-composite or NULL value. The returned\n value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param index The child index, in [0, child_count).\n @param out_child Receives the owned child value.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_child(
        value: duckdb_v2_value_handle,
        index: idx_t,
        out_child: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Casts a value to a target type, using a factory.\n\n The conversion is the SQL-faithful, non-strict one, registered custom casts included, and a cast failure surfaces\n from the call. Together with a VARCHAR built through value_create_varchar, this constructs any value from text,\n extension values included; casting a member value to a union type, or a VARCHAR to an enum type, is the sanctioned\n way to build UNION and ENUM values.\n\n A connection's or callback's factory casts with that client's cast functions and settings (e.g. TimeZone). An\n instance's factory supports only the built-in casts, with default settings.\n\n The input value and target type are borrowed. The returned value is caller-owned; destroy it via value_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param factory The factory supplying the cast functions.\n @param value The borrowed value to cast.\n @param target_type The borrowed target logical type.\n @param out_value Receives the owned cast result.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_cast(
        factory: duckdb_v2_factory_handle,
        value: duckdb_v2_value_handle,
        target_type: duckdb_v2_logical_type_handle,
        out_value: *mut duckdb_v2_value_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns whether the value is NULL.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out_is_null Receives true if the value is NULL, false otherwise.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_is_null(
        value: duckdb_v2_value_handle,
        out_is_null: *mut bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the logical type of the value.\n\n The returned logical type is caller-owned; destroy it via logical_type_destroy.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out_type Receives the owned logical type.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_get_logical_type(
        value: duckdb_v2_value_handle,
        out_type: *mut duckdb_v2_logical_type_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Renders the value as a human-readable string. Diagnostic only.\n\n Writes into a caller-supplied buffer, so nothing is allocated on the caller's behalf and nothing has to be freed.\n\n Pass out_string = NULL to size the buffer without rendering into it: out_length then receives the length, and\n out_capacity is ignored. With out_string != NULL, out_capacity must be at least out_length + 1, or the call returns\n ERROR_INPUT_OBJECT_SIZE with out_length set to the required length and out_string left untouched.\n\n out_length never counts the terminator, but a successful write always appends one, so the buffer is usable as a C\n string.\n\n history:\n - unstable: v2.0.0\n\n @param value The value to read.\n @param out_string Caller-owned buffer receiving the text plus a null terminator, or NULL to only report the required\n length in out_length.\n @param out_capacity Bytes available in out_string, terminator included. Ignored when out_string is NULL.\n @param out_length Receives the text length excluding the null terminator — written on success and on\n ERROR_INPUT_OBJECT_SIZE.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via error_info_destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_value_to_string(
        value: duckdb_v2_value_handle,
        out_string: *mut ::std::os::raw::c_char,
        out_capacity: idx_t,
        out_length: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
#[doc = " Converts Arrow arrays into DuckDB data chunks, against one resolved ArrowSchema. Create it with\n `duckdb_v2_arrow_importer_create()`, which resolves every column's DuckDB type once, so the same importer serves any\n number of arrays of that shape. `duckdb_v2_arrow_importer_get_schema()` reports the resolved DuckDB schema.\n `duckdb_v2_arrow_importer_append()` takes an array, `duckdb_v2_arrow_importer_next_chunk()` produces chunks from it,\n and `duckdb_v2_arrow_importer_destroy()` frees the importer.\n\n The importer borrows the context it was created with and must not outlive it. One array is in flight at a time, and\n an importer must not be used from two threads at once."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_arrow_importer {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " Converts Arrow arrays into DuckDB data chunks, against one resolved ArrowSchema. Create it with\n `duckdb_v2_arrow_importer_create()`, which resolves every column's DuckDB type once, so the same importer serves any\n number of arrays of that shape. `duckdb_v2_arrow_importer_get_schema()` reports the resolved DuckDB schema.\n `duckdb_v2_arrow_importer_append()` takes an array, `duckdb_v2_arrow_importer_next_chunk()` produces chunks from it,\n and `duckdb_v2_arrow_importer_destroy()` frees the importer.\n\n The importer borrows the context it was created with and must not outlive it. One array is in flight at a time, and\n an importer must not be used from two threads at once."]
pub type duckdb_v2_arrow_importer_handle = *mut _duckdb_v2_arrow_importer;
#[doc = " Converts DuckDB data chunks into Arrow arrays, for one fixed list of columns. Create it with\n `duckdb_v2_arrow_exporter_create()`, which captures the session's Arrow settings and resolves the extension types\n once. `duckdb_v2_arrow_exporter_get_schema()` reports the Arrow schema. `duckdb_v2_arrow_exporter_append()` takes a\n chunk, `duckdb_v2_arrow_exporter_next_array()` produces arrays from it, and `duckdb_v2_arrow_exporter_destroy()`\n frees the exporter.\n\n An exporter must not be used from two threads at once."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_arrow_exporter {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " Converts DuckDB data chunks into Arrow arrays, for one fixed list of columns. Create it with\n `duckdb_v2_arrow_exporter_create()`, which captures the session's Arrow settings and resolves the extension types\n once. `duckdb_v2_arrow_exporter_get_schema()` reports the Arrow schema. `duckdb_v2_arrow_exporter_append()` takes a\n chunk, `duckdb_v2_arrow_exporter_next_array()` produces arrays from it, and `duckdb_v2_arrow_exporter_destroy()`\n frees the exporter.\n\n An exporter must not be used from two threads at once."]
pub type duckdb_v2_arrow_exporter_handle = *mut _duckdb_v2_arrow_exporter;
#[doc = " A query result that produces Arrow arrays. Works like a result, which produces data chunks. Create it with\n `duckdb_v2_statement_execute_arrow()` or `duckdb_v2_prepared_statement_execute_arrow()`.\n\n - Use it from one thread at a time.\n - `duckdb_v2_connection_interrupt()` cancels it: `duckdb_v2_arrow_result_step()` reports `CANCELLED`, and\n `duckdb_v2_arrow_result_fetch_array()` and a stream's `get_next` fail.\n - Arrays and schemas it hands out belong to the caller and stay valid after the result is destroyed."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _duckdb_v2_arrow_result {
    pub internal_ptr: *mut ::std::os::raw::c_void,
}
#[doc = " A query result that produces Arrow arrays. Works like a result, which produces data chunks. Create it with\n `duckdb_v2_statement_execute_arrow()` or `duckdb_v2_prepared_statement_execute_arrow()`.\n\n - Use it from one thread at a time.\n - `duckdb_v2_connection_interrupt()` cancels it: `duckdb_v2_arrow_result_step()` reports `CANCELLED`, and\n `duckdb_v2_arrow_result_fetch_array()` and a stream's `get_next` fail.\n - Arrays and schemas it hands out belong to the caller and stay valid after the result is destroyed."]
pub type duckdb_v2_arrow_result_handle = *mut _duckdb_v2_arrow_result;
unsafe extern "C" {
    #[doc = " Resolves an Arrow schema into a reusable importer.\n\n Works out every column's DuckDB logical type and the Arrow type information the conversion needs, once, so any number\n of arrays of that shape can be imported without re-reading the schema. `schema` is read, not consumed: the caller\n keeps ownership and still releases it.\n\n `batch_size` caps the rows per produced chunk. A long array is split across several chunks. Rows left over that do\n not fill a batch are held back and joined with the next array, unless the append asked to flush. Pass 0 for no\n maximum: each array becomes one chunk, however long it is.\n\n Resolving reads the catalog for extension types, so `context` must have an active transaction. The importer keeps\n using that context for every conversion and must not outlive it. Within one connection the context is the same\n throughout, so an importer created in a bind callback is usable from the matching exec callback. `*out_importer` is\n set to NULL on failure.\n\n history:\n - unstable: v2.0.0\n\n @param context The context used to resolve the Arrow types, extension types included.\n @param schema The schema to resolve. Read, not consumed; the caller keeps ownership.\n @param batch_size Maximum rows per produced chunk, or 0 for no maximum.\n @param out_importer On success, receives the new importer. Owned by the caller; destroy via\n `duckdb_v2_arrow_importer_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_importer_create(
        context: duckdb_v2_context_handle,
        schema: *mut ArrowSchema,
        batch_size: idx_t,
        out_importer: *mut duckdb_v2_arrow_importer_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the resolved DuckDB schema.\n\n Writes an owned schema handle with the DuckDB name and logical type of every column the importer resolved. This is\n how a caller learns the DuckDB shape of an ArrowSchema, to declare a table function's result columns for instance,\n without reimplementing the mapping from Arrow format strings to logical types.\n\n The fields were resolved at creation, so this reads no catalog and needs no transaction. `*out_schema` is set to NULL\n on failure.\n\n history:\n - unstable: v2.0.0\n\n @param importer The importer to read.\n @param out_schema On success, receives an owned schema. Destroy via `duckdb_v2_schema_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_importer_get_schema(
        importer: duckdb_v2_arrow_importer_handle,
        out_schema: *mut duckdb_v2_schema_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Gives the importer one array to convert.\n\n Take the chunks with `duckdb_v2_arrow_importer_next_chunk()` until that returns NULL. Appending while the previous\n array still has rows left is rejected with `ERROR_INPUT_INVALID`. An array whose shape does not match the resolved\n schema -- a different child count, a child whose length differs from the array's, a null or already-released child --\n is rejected the same way, before anything is read.\n\n `flush` marks the end of the input: rows that do not fill a batch then come out as a final short chunk instead of\n being held back for the next array. Pass NULL for `array` with `flush` set to release the held rows without supplying\n more input.\n\n `consume` decides what happens to the caller's array.\n\n When true, the importer takes over the array and sets its `release` to NULL; the caller must not release it\n afterwards. The produced chunks reference the Arrow buffers directly, without copying, and keep them alive, so the\n chunks stay valid after the importer is destroyed. Prefer this path.\n\n When false, the caller keeps the array and must keep it valid until the drain finishes. The produced chunks are\n copies, so they do not depend on the array, at the cost of one copy per chunk.\n\n Either way, a chunk that joins rows held back from the previous array is a copy, since it cannot reference two\n arrays.\n\n Only the default, dictionary-encoded and run-end-encoded Arrow layouts are supported. Any other layout reports\n `ERROR_QUERY_NOT_IMPLEMENTED` when the column is converted.\n\n history:\n - unstable: v2.0.0\n\n @param importer The importer to feed.\n @param array The array to convert. Its `release` is set to NULL when `consume` is true.\n @param consume True to hand the array over for a zero-copy import; false to keep it, in which case every produced\n chunk is a copy.\n @param flush True to mark the end of the input, releasing held rows as a final short chunk. Pass NULL for `array`\n with this set to flush without supplying more input.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_importer_append(
        importer: duckdb_v2_arrow_importer_handle,
        array: *mut ArrowArray,
        consume: bool,
        flush: bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Produces the next chunk of the appended array, or NULL once the array is drained.\n\n Call it in a loop until `*out_chunk` is NULL. An importer with no array appended also returns NULL. Each chunk holds\n at most the importer's `batch_size` rows, or the whole array when that is 0. A chunk may start with rows held back\n from the previous array, and rows that do not fill a batch are held back in turn unless the append asked to flush. So\n NULL means the array has been read, not that all of its rows have come out.\n\n The conversion runs under the context the importer was created with, which must still be alive. `*out_chunk` is set\n to NULL on failure.\n\n history:\n - unstable: v2.0.0\n\n @param importer The importer to drain.\n @param out_chunk On success, receives the next chunk, or NULL once the array is drained. Destroy via\n `duckdb_v2_data_chunk_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_importer_next_chunk(
        importer: duckdb_v2_arrow_importer_handle,
        out_chunk: *mut duckdb_v2_data_chunk_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys an importer.\n\n Null-safe: passing NULL, or a slot already set to NULL, is a no-op. Chunks already produced stay valid, including the\n zero-copy ones, which keep the Arrow buffers alive themselves. An array appended with `consume` true and not fully\n drained is released here. Rows held back for a next array are dropped. On success the slot is set to NULL.\n\n history:\n - unstable: v2.0.0\n\n @param importer The importer to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_importer_destroy(importer: *mut duckdb_v2_arrow_importer_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Creates an exporter for one fixed list of columns.\n\n Resolves the extension types and captures the session's Arrow settings, so every array this exporter produces matches\n the schema `duckdb_v2_arrow_exporter_get_schema()` reports, even if a setting changes afterwards.\n\n `batch_size` caps the rows per produced array. A long chunk is split across several arrays. Rows left over that do\n not fill a batch are held back and joined with the next chunk, unless the append asked to flush. Pass 0 for no\n maximum: each chunk becomes one array, however long it is.\n\n `types` and `names` are parallel arrays of `count` entries, borrowed and copied; they may be NULL only when `count`\n is 0. Resolving reads the catalog, so `context` must have an active transaction. `*out_exporter` is set to NULL on\n failure.\n\n history:\n - unstable: v2.0.0\n\n @param context The context whose Arrow settings are captured and whose transaction resolves the types.\n @param types An array of `count` column types. May be NULL only when `count` is 0.\n @param names An array of `count` column names, parallel to `types`. Each name must be valid UTF-8. May be NULL only\n when `count` is 0.\n @param count The number of columns, being the length of both `types` and `names`.\n @param batch_size Maximum rows per produced array, or 0 for no maximum.\n @param out_exporter On success, receives the new exporter. Owned by the caller; destroy via\n `duckdb_v2_arrow_exporter_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_exporter_create(
        context: duckdb_v2_context_handle,
        types: *const duckdb_v2_logical_type_handle,
        names: *const duckdb_v2_str,
        count: idx_t,
        batch_size: idx_t,
        out_exporter: *mut duckdb_v2_arrow_exporter_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the Arrow schema of the arrays this exporter produces.\n\n Fills the caller-allocated `out_schema`. The caller owns the result and releases it with\n `out_schema->release(out_schema)`. Callable at any point, and always returns the same schema, since it is built from\n the settings captured at creation.\n\n history:\n - unstable: v2.0.0\n\n @param exporter The exporter to read.\n @param out_schema Caller-allocated schema the library fills. Release it with `out_schema->release(out_schema)`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_exporter_get_schema(
        exporter: duckdb_v2_arrow_exporter_handle,
        out_schema: *mut ArrowSchema,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Gives the exporter one chunk to convert.\n\n The chunk is converted in full before this returns. The conversion copies into freshly allocated Arrow buffers, so\n nothing of the caller's is retained. Every array completed by this chunk becomes available from\n `duckdb_v2_arrow_exporter_next_array()`; rows that do not complete a batch are held back and finished by the next\n chunk. Completed arrays queue up, so appending again before they are taken is allowed.\n\n `flush` marks the end of the input: the held rows are then finished as a final short array. Pass NULL for `chunk`\n with `flush` set to release the held rows without supplying more input.\n\n The chunk's types must match the ones the exporter was created with, or the call is rejected with\n `ERROR_INPUT_INVALID` before anything is read.\n\n `consume` decides only what happens to the caller's handle, since the data is copied either way. When true the chunk\n is destroyed and the slot set to NULL, saving a `duckdb_v2_data_chunk_destroy()` for a chunk the caller owns. When\n false the chunk is left untouched, which is what a chunk borrowed from a callback needs, such as the output chunk of\n a table function's exec callback, which the caller does not own and must not destroy.\n\n history:\n - unstable: v2.0.0\n\n @param exporter The exporter to feed.\n @param chunk The chunk to convert. Destroyed and set to NULL only when `consume` is true.\n @param consume True to hand the chunk over, destroying it; false to leave the caller's handle untouched.\n @param flush True to mark the end of the input, releasing the held rows as a final short array. Pass NULL for `chunk`\n with this set to flush without supplying more input.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_exporter_append(
        exporter: duckdb_v2_arrow_exporter_handle,
        chunk: *mut duckdb_v2_data_chunk_handle,
        consume: bool,
        flush: bool,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Takes the next completed array, or reports that none is ready.\n\n Call it in a loop after every `duckdb_v2_arrow_exporter_append()` until `out_array->release` is NULL, which is how\n the Arrow C Data Interface signals \"no array\" and what a stream's `get_next` does at end of input. Rows held back\n towards an unfinished batch are not an array yet; they come out after a further append or a flush.\n\n Each array is owned by the caller and released with `out_array->release(out_array)`, independently of the exporter\n and of every other array.\n\n history:\n - unstable: v2.0.0\n\n @param exporter The exporter to drain.\n @param out_array Caller-allocated array the library fills. Left released -- `release` NULL -- when none is ready.\n Release a filled one with `out_array->release(out_array)`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_exporter_next_array(
        exporter: duckdb_v2_arrow_exporter_handle,
        out_array: *mut ArrowArray,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys an exporter.\n\n Null-safe: passing NULL, or a slot already set to NULL, is a no-op. Arrays already taken stay valid. Arrays still\n queued inside are released here, and rows held back towards an unfinished batch are dropped. On success the slot is\n set to NULL.\n\n history:\n - unstable: v2.0.0\n\n @param exporter The exporter to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_exporter_destroy(exporter: *mut duckdb_v2_arrow_exporter_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Executes a parsed statement. The result produces Arrow arrays.\n\n Works like `duckdb_v2_statement_execute()`. `*out_result` is set to NULL on failure.\n\n history:\n - unstable: v2.0.0\n\n @param conn The connection to run the statement on.\n @param statement The statement to execute. Not consumed.\n @param parameter_names Optional. As in `duckdb_v2_statement_execute()`.\n @param parameter_values Optional. As in `duckdb_v2_statement_execute()`.\n @param parameter_count The number of parameters. 0 for none.\n @param batch_size Maximum rows per array. Arrays can be shorter. 0 means 131072.\n @param out_result Receives the new result. Destroy via `duckdb_v2_arrow_result_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_statement_execute_arrow(
        conn: duckdb_v2_connection_handle,
        statement: duckdb_v2_sql_statement_handle,
        parameter_names: *const duckdb_v2_identifier_t,
        parameter_values: *const duckdb_v2_value_handle,
        parameter_count: idx_t,
        batch_size: idx_t,
        out_result: *mut duckdb_v2_arrow_result_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Executes a prepared statement. The result produces Arrow arrays.\n\n Works like `duckdb_v2_prepared_statement_execute()`. `*out_result` is set to NULL on failure.\n\n history:\n - unstable: v2.0.0\n\n @param prepared The prepared statement to execute. Not consumed.\n @param parameter_names Optional. As in `duckdb_v2_prepared_statement_execute()`.\n @param parameter_values Optional. As in `duckdb_v2_prepared_statement_execute()`.\n @param parameter_count The number of parameters. 0 for none.\n @param batch_size Maximum rows per array. Arrays can be shorter. 0 means 131072.\n @param out_result Receives the new result. Destroy via `duckdb_v2_arrow_result_destroy()`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_prepared_statement_execute_arrow(
        prepared: duckdb_v2_prepared_statement_handle,
        parameter_names: *const duckdb_v2_identifier_t,
        parameter_values: *const duckdb_v2_value_handle,
        parameter_count: idx_t,
        batch_size: idx_t,
        out_result: *mut duckdb_v2_arrow_result_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Destroys the result. Works like `duckdb_v2_result_destroy()`.\n\n history:\n - unstable: v2.0.0\n\n @param result The result to destroy.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_result_destroy(result: *mut duckdb_v2_arrow_result_handle) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Runs a bounded amount of the query and returns without blocking.\n\n Works like `duckdb_v2_result_step()`. On status `CHUNK`, `out_array` holds the next array. Otherwise its `release` is\n NULL.\n\n history:\n - unstable: v2.0.0\n\n @param result The result to step.\n @param out_array Caller-allocated array the library fills. Release it with `out_array->release(out_array)`.\n @param out_status Receives the step status.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_result_step(
        result: duckdb_v2_arrow_result_handle,
        out_array: *mut ArrowArray,
        out_status: *mut DUCKDB_V2_RESULT_STEP_STATUS,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Blocks until the next array is ready.\n\n Works like `duckdb_v2_result_fetch_chunk()`. At the end of the result, `out_array->release` is NULL.\n\n history:\n - unstable: v2.0.0\n\n @param result The result to fetch from.\n @param out_array Caller-allocated array the library fills. Release it with `out_array->release(out_array)`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_result_fetch_array(
        result: duckdb_v2_arrow_result_handle,
        out_array: *mut ArrowArray,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Blocks until `duckdb_v2_arrow_result_step()` can make progress. Works like `duckdb_v2_result_wait()`.\n\n history:\n - unstable: v2.0.0\n\n @param result The result to wait on.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_result_wait(
        result: duckdb_v2_arrow_result_handle,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Runs the query to the end and reports the changed-row count. Works like `duckdb_v2_result_drain()`.\n\n history:\n - unstable: v2.0.0\n\n @param result The result to drain.\n @param out_rows_changed Receives the changed-row count for an INSERT, UPDATE or DELETE, 0 otherwise.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_result_drain(
        result: duckdb_v2_arrow_result_handle,
        out_rows_changed: *mut idx_t,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the shape of the result. Works like `duckdb_v2_result_get_result_type()`.\n\n history:\n - unstable: v2.0.0\n\n @param result The result.\n @param out_type Receives the result shape.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_result_get_result_type(
        result: duckdb_v2_arrow_result_handle,
        out_type: *mut DUCKDB_V2_RESULT_TYPE,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the type of statement that produced the result. Works like `duckdb_v2_result_get_statement_type()`.\n\n history:\n - unstable: v2.0.0\n\n @param result The result.\n @param out_type Receives the statement type.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_result_get_statement_type(
        result: duckdb_v2_arrow_result_handle,
        out_type: *mut DUCKDB_V2_STATEMENT_TYPE,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Returns the Arrow schema of the result's arrays.\n\n Available whenever `duckdb_v2_result_get_schema()` would be.\n\n history:\n - unstable: v2.0.0\n\n @param result The result.\n @param out_schema Caller-allocated schema the library fills. Release it with `out_schema->release(out_schema)`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_result_get_schema(
        result: duckdb_v2_arrow_result_handle,
        out_schema: *mut ArrowSchema,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
unsafe extern "C" {
    #[doc = " Turns the result into an ArrowArrayStream.\n\n On success the stream takes over the result and `*result` is set to NULL. Each `get_next` returns the next array.\n Arrays already fetched are not repeated. Releasing the stream destroys the result.\n\n Converting runs no part of the query. The stream's `get_schema` can: for a statement that expands into several\n statements, such as PIVOT, it runs the ones before the statement that returns rows. A failing `get_next` or\n `get_schema` returns `EIO`; `get_last_error` has the message.\n\n history:\n - unstable: v2.0.0\n\n @param result The result to take over. Set to NULL on success.\n @param out_stream Caller-allocated stream the library fills. Release it with `out_stream->release(out_stream)`.\n @param err Optional. On failure, receives an opaque info handle the caller must destroy via\n `duckdb_v2_error_info_destroy()`.\n @return DUCKDB_V2_ERROR"]
    pub fn duckdb_v2_arrow_result_to_arrow_c_stream(
        result: *mut duckdb_v2_arrow_result_handle,
        out_stream: *mut ArrowArrayStream,
        err: *mut duckdb_v2_error_info_handle,
    ) -> DUCKDB_V2_ERROR;
}
#[doc = "! Describes a statically linked extension, or something linked in the same way that is not an extension. DuckDB\n! allocates and zero-fills it, the describe function fills it in."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct duckdb_extension_descriptor {
    #[doc = "! In: the layout DuckDB offers. Out: the layout the describe function filled, never higher than the offer."]
    pub version: u32,
    #[doc = "! Reports why the describe function refused. DuckDB copies the message."]
    pub set_error: ::std::option::Option<
        unsafe extern "C" fn(descriptor: *mut duckdb_extension_descriptor, message: *const ::std::os::raw::c_char),
    >,
    #[doc = "! DuckDB's state for set_error, opaque to the extension."]
    pub internal: *mut ::std::os::raw::c_void,
    pub name: *const ::std::os::raw::c_char,
    pub extension_version: *const ::std::os::raw::c_char,
    #[doc = "! What the entry point was built against: the DuckDB version for entry_cpp, the C API version the extension\n! targets for entry_capi_v1 and entry_capi_v2. The same values the loadable extension metadata carries. DuckDB\n! records it and reports it; it does not refuse a mismatch on it yet."]
    pub api_version: *const ::std::os::raw::c_char,
    #[doc = "! void (duckdb::ExtensionLoader &)"]
    pub entry_cpp: ::std::option::Option<unsafe extern "C" fn()>,
    #[doc = "! bool (duckdb_extension_info, struct duckdb_extension_access *)"]
    pub entry_capi_v1: ::std::option::Option<unsafe extern "C" fn()>,
    #[doc = "! void (struct duckdb_v2_extension_input *)"]
    pub entry_capi_v2: ::std::option::Option<unsafe extern "C" fn()>,
    #[doc = "! Set instead of an entry point by a capability, something linked like an extension that is not one (such as\n! httplib): DuckDB calls it for every database it opens, before loading extensions, and neither lists nor loads\n! it as an extension.\n! void (duckdb::DatabaseInstance &)"]
    pub database_callback: ::std::option::Option<unsafe extern "C" fn()>,
}
#[doc = "! Every statically linkable extension provides duckdb_extension_<name>_describe with this signature. Returns 0 on\n! success."]
pub type duckdb_extension_describe_t =
    ::std::option::Option<unsafe extern "C" fn(descriptor: *mut duckdb_extension_descriptor) -> i32>;
unsafe extern "C" {
    #[doc = "! Calls describe and registers what it describes for every database opened afterwards. Returns 0 on\n! success. Registering the same describe function again is a no-op; a different one under a registered name is an\n! error. A failed registration also makes opening a database fail with the reason."]
    pub fn duckdb_register_static_extension(describe: duckdb_extension_describe_t) -> i32;
}