sibyl 0.7.1

An OCI-based (synchronous or asynchronous) interface between Rust applications and Oracle databases
Documentation
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
//! Oracle OCI FFI

#![allow(dead_code)]

pub(crate) mod ptr;
pub(crate) mod attr;
pub(crate) mod handle;
pub(crate) mod desc;
pub(crate) mod param;
#[cfg(feature="nonblocking")]
#[cfg_attr(docsrs, doc(cfg(feature="nonblocking")))]
pub mod futures;

pub(crate) use ptr::Ptr;
pub(crate) use handle::Handle;
pub(crate) use desc::Descriptor;

use libc::{size_t, c_void};

use crate::{Error, Result};

#[repr(align(4))]
pub(crate) struct Aligned<T>(T);

impl<T> Aligned<T> {
    pub(crate) fn new(val: T) -> Self {
        Self(val)
    }
    pub(crate) fn as_mut_ptr(&mut self) -> *mut T {
        &mut self.0 as _
    }
}

macro_rules! impl_from_aligned {
    ($($t:ty),+) => {
        $(
            impl From<Aligned<$t>> for $t {
                fn from(aligned: Aligned<$t>) -> Self {
                    aligned.0
                }
            }
        )+
    };
}

impl_from_aligned![i8, u8, i16, u16];

pub(crate) const OCI_DEFAULT                : u32 = 0;

// OCI Error Codes
pub(crate) const OCI_SUCCESS                : i32 = 0;
pub(crate) const OCI_SUCCESS_WITH_INFO      : i32 = 1;
pub(crate) const OCI_NEED_DATA              : i32 = 99;
pub(crate) const OCI_NO_DATA                : i32 = 100;
pub(crate) const OCI_ERROR                  : i32 = -1;
pub(crate) const OCI_INVALID_HANDLE         : i32 = -2;
pub(crate) const OCI_STILL_EXECUTING        : i32 = -3123;
pub(crate) const OCI_CONTINUE               : i32 = -24200;

// Oracle error codes
pub(crate) const NO_DATA_FOUND              : i32 = 1403;

// Attribute Constants
pub(crate) const OCI_ATTR_ROW_COUNT         : u32 = 9;
pub(crate) const OCI_ATTR_PREFETCH_ROWS     : u32 = 11;
pub(crate) const OCI_ATTR_PARAM_COUNT       : u32 = 18;     // number of columns in the select list
pub(crate) const OCI_ATTR_STMT_TYPE         : u32 = 24;
pub(crate) const OCI_ATTR_STMTCACHESIZE     : u32 = 176;    // size of the stm cache
pub(crate) const OCI_ATTR_BIND_COUNT        : u32 = 190;
pub(crate) const OCI_ATTR_ROWS_FETCHED      : u32 = 197;
pub(crate) const OCI_ATTR_STMT_IS_RETURNING : u32 = 218;
pub(crate) const OCI_ATTR_UB8_ROW_COUNT     : u32 = 457;
pub(crate) const OCI_ATTR_INVISIBLE_COL     : u32 = 461;
pub(crate) const OCI_ATTR_FIXUP_CALLBACK    : u32 = 501;
pub(crate) const OCI_ATTR_CALL_TIMEOUT      : u32 = 531;

// Handle Types
pub(crate) const OCI_HTYPE_ENV              : u32 = 1;
pub(crate) const OCI_HTYPE_ERROR            : u32 = 2;
pub(crate) const OCI_HTYPE_SVCCTX           : u32 = 3;
pub(crate) const OCI_HTYPE_STMT             : u32 = 4;
pub(crate) const OCI_HTYPE_BIND             : u32 = 5;
pub(crate) const OCI_HTYPE_DEFINE           : u32 = 6;
pub(crate) const OCI_HTYPE_DESCRIBE         : u32 = 7;
pub(crate) const OCI_HTYPE_SERVER           : u32 = 8;
pub(crate) const OCI_HTYPE_SESSION          : u32 = 9;
pub(crate) const OCI_HTYPE_AUTHINFO         : u32 = OCI_HTYPE_SESSION;
pub(crate) const OCI_HTYPE_CPOOL            : u32 = 26;
pub(crate) const OCI_HTYPE_SPOOL            : u32 = 27;

// Handle Definitions
#[repr(C)] pub        struct OCIEnv         { _private: [u8; 0] }
#[repr(C)] pub        struct OCIError       { _private: [u8; 0] }
#[repr(C)] pub(crate) struct OCISvcCtx      { _private: [u8; 0] }
#[repr(C)] pub        struct OCIStmt        { _private: [u8; 0] }
#[repr(C)] pub(crate) struct OCIBind        { _private: [u8; 0] }
#[repr(C)] pub(crate) struct OCIDefine      { _private: [u8; 0] }
#[repr(C)] pub(crate) struct OCIDescribe    { _private: [u8; 0] }
#[repr(C)] pub(crate) struct OCIServer      { _private: [u8; 0] }
#[repr(C)] pub        struct OCISession     { _private: [u8; 0] }
#[repr(C)] pub(crate) struct OCIRaw         { _private: [u8; 0] }

#[repr(C)] pub(crate) struct OCIAuthInfo    { _private: [u8; 0] }
#[repr(C)] pub(crate) struct OCISPool       { _private: [u8; 0] }
#[repr(C)] pub(crate) struct OCICPool       { _private: [u8; 0] }

/// Trait of handles to have their own type
pub(crate) trait HandleType : OCIStruct {
    fn get_type() -> u32;
}

macro_rules! impl_handle_type {
    ($($oci_handle:ty => $id:ident),+) => {
        $(
            impl HandleType for $oci_handle {
                fn get_type() -> u32 { $id }
            }
        )+
    };
}

impl_handle_type!{
    OCIEnv      => OCI_HTYPE_ENV,
    OCIError    => OCI_HTYPE_ERROR,
    OCISvcCtx   => OCI_HTYPE_SVCCTX,
    OCIStmt     => OCI_HTYPE_STMT,
    OCIBind     => OCI_HTYPE_BIND,
    OCIDefine   => OCI_HTYPE_DEFINE,
    OCIDescribe => OCI_HTYPE_DESCRIBE,
    OCIServer   => OCI_HTYPE_SERVER,
    OCISession  => OCI_HTYPE_SESSION,
    OCIAuthInfo => OCI_HTYPE_AUTHINFO,
    OCICPool    => OCI_HTYPE_CPOOL,
    OCISPool    => OCI_HTYPE_SPOOL
}

// Descriptor Types
pub(crate) const OCI_DTYPE_LOB              : u32 = 50;  // lob locator
pub(crate) const OCI_DTYPE_RSET             : u32 = 52;  // result set descriptor
pub(crate) const OCI_DTYPE_PARAM            : u32 = 53;  // a parameter descriptor obtained from ocigparm
pub(crate) const OCI_DTYPE_ROWID            : u32 = 54;  // rowid descriptor
pub(crate) const OCI_DTYPE_FILE             : u32 = 56;  // File Lob locator
pub(crate) const OCI_DTYPE_LOCATOR          : u32 = 61;  // LOB locator
pub(crate) const OCI_DTYPE_INTERVAL_YM      : u32 = 62;  // Interval year month
pub(crate) const OCI_DTYPE_INTERVAL_DS      : u32 = 63;  // Interval day second
pub(crate) const OCI_DTYPE_TIMESTAMP        : u32 = 68;  // Timestamp
pub(crate) const OCI_DTYPE_TIMESTAMP_TZ     : u32 = 69;  // Timestamp with timezone
pub(crate) const OCI_DTYPE_TIMESTAMP_LTZ    : u32 = 70;  // Timestamp with local tz

// Descriptor Definitions
#[repr(C)] pub(crate) struct OCIResult      { _private: [u8; 0] }
#[repr(C)] pub        struct OCILobLocator  { _private: [u8; 0] }
#[repr(C)] pub(crate) struct OCILobRegion   { _private: [u8; 0] }
#[repr(C)] pub(crate) struct OCIParam       { _private: [u8; 0] }
#[repr(C)] pub(crate) struct OCIRowid       { _private: [u8; 0] }
#[repr(C)] pub        struct OCIDateTime    { _private: [u8; 0] }
#[repr(C)] pub        struct OCIInterval    { _private: [u8; 0] }
#[repr(C)] pub(crate) struct OCIString      { _private: [u8; 0] }

// Virtual descriptors
pub struct OCICLobLocator           {}
pub struct OCIBLobLocator           {}
pub struct OCIBFileLocator          {}
pub struct OCITimestamp             {}
pub struct OCITimestampTZ           {}
pub struct OCITimestampLTZ          {}
pub struct OCIIntervalYearToMonth   {}
pub struct OCIIntervalDayToSecond   {}

/// Trait of (bindable) values to have a type
pub trait SqlType {
    /// Returns SQLT type code
    fn sql_type() -> u16;
    /// Returns SQLT code for the NULL of the type
    /// Some types - `RAW` - are picky about SQLT of the NULL.
    fn sql_null_type() -> u16 {
        Self::sql_type()
    }
}

macro_rules! impl_sql_type {
    ($($t:ty),+ => $sqlt:ident) => {
        $(
            impl SqlType for $t {
                fn sql_type() -> u16 {
                    $sqlt
                }
            }
        )+
    };
}
pub(crate) use impl_sql_type;

/// Trait of descriptors to have a type
pub trait DescriptorType : OCIStruct + SqlType {
    type OCIType;
    fn get_type() -> u32;
}

macro_rules! impl_descr_type {
    ($($oci_desc:ident => $id:ident, $sqlt:ident, $ret:ident),+) => {
        $(
            impl SqlType for $oci_desc {
                fn sql_type() -> u16 { $sqlt }
            }
            impl DescriptorType for $oci_desc {
                type OCIType = $ret;
                fn get_type() -> u32 { $id }
            }
        )+
    };
}

impl_descr_type!{
    OCICLobLocator          => OCI_DTYPE_LOB,           SQLT_CLOB,          OCILobLocator,
    OCIBLobLocator          => OCI_DTYPE_LOB,           SQLT_BLOB,          OCILobLocator,
    OCIBFileLocator         => OCI_DTYPE_FILE,          SQLT_BFILE,         OCILobLocator,
    OCIParam                => OCI_DTYPE_PARAM,         SQLT_NON,           OCIParam,
    OCIRowid                => OCI_DTYPE_ROWID,         SQLT_RDD,           OCIRowid,
    OCITimestamp            => OCI_DTYPE_TIMESTAMP,     SQLT_TIMESTAMP,     OCIDateTime,
    OCITimestampTZ          => OCI_DTYPE_TIMESTAMP_TZ,  SQLT_TIMESTAMP_TZ,  OCIDateTime,
    OCITimestampLTZ         => OCI_DTYPE_TIMESTAMP_LTZ, SQLT_TIMESTAMP_LTZ, OCIDateTime,
    OCIIntervalYearToMonth  => OCI_DTYPE_INTERVAL_YM,   SQLT_INTERVAL_YM,   OCIInterval,
    OCIIntervalDayToSecond  => OCI_DTYPE_INTERVAL_DS,   SQLT_INTERVAL_DS,   OCIInterval
}

/// Marker trait for OCI handles and descriptors
pub trait OCIStruct {}

macro_rules! mark_as_oci {
    ($($t:ty),+) => {
        $(
            impl OCIStruct for $t {}
        )+
    };
}

mark_as_oci!(OCIEnv, OCIError, OCISvcCtx, OCIStmt, OCIBind, OCIDefine, OCIDescribe, OCIServer, OCISession, OCIAuthInfo, OCISPool, OCICPool);
mark_as_oci!(OCIResult, OCILobLocator, OCILobRegion, OCIParam, OCIRowid, OCIDateTime, OCIInterval, OCIString, OCIRaw);
mark_as_oci!(OCICLobLocator, OCIBLobLocator, OCIBFileLocator, OCITimestamp, OCITimestampTZ, OCITimestampLTZ, OCIIntervalYearToMonth, OCIIntervalDayToSecond);

/// C mapping of the Oracle NUMBER
#[repr(C)] pub struct OCINumber {
    pub(crate) bytes: [u8; 22]
}

/// C mapping of the Oracle DATE type (SQLT_ODT)
#[derive(Debug, Clone, Copy)]
#[repr(C)]
pub struct OCIDate {
    pub(crate) year: i16, // gregorian year: range is -4712 <= year <= 9999
    pub(crate) month: u8, // month: range is 1 <= month <= 12
    pub(crate) day:   u8, // day: range is 1 <= day <= 31
    pub(crate) hour:  u8, // hours: range is 0 <= hours <= 23
    pub(crate) min:   u8, // minutes: range is 0 <= minutes <= 59
    pub(crate) sec:   u8, // seconds: range is 0 <= seconds <= 59
}

mark_as_oci!(OCINumber, OCIDate);

// Data types
pub(crate) const SQLT_CHR               : u16 = 1;   // (ORANET TYPE) character string
pub(crate) const SQLT_NUM               : u16 = 2;   // (ORANET TYPE) oracle numeric
pub(crate) const SQLT_INT               : u16 = 3;   // (ORANET TYPE) integer
pub(crate) const SQLT_FLT               : u16 = 4;   // (ORANET TYPE) Floating point number
pub(crate) const SQLT_STR               : u16 = 5;   // zero terminated string
pub(crate) const SQLT_VNU               : u16 = 6;   // NUM with preceding length byte
pub(crate) const SQLT_PDN               : u16 = 7;   // (ORANET TYPE) Packed Decimal Numeric
pub(crate) const SQLT_LNG               : u16 = 8;   // long
pub(crate) const SQLT_VCS               : u16 = 9;   // Variable character string
pub(crate) const SQLT_NON               : u16 = 10;  // Null/empty PCC Descriptor entry
pub(crate) const SQLT_RID               : u16 = 11;  // rowid
pub(crate) const SQLT_DAT               : u16 = 12;  // date in oracle format
pub(crate) const SQLT_VBI               : u16 = 15;  // binary in VCS format
pub(crate) const SQLT_BFLOAT            : u16 = 21;  // Native Binary float
pub(crate) const SQLT_BDOUBLE           : u16 = 22;  // NAtive binary double
pub(crate) const SQLT_BIN               : u16 = 23;  // binary data(DTYBIN)
pub(crate) const SQLT_LBI               : u16 = 24;  // long binary
pub(crate) const SQLT_UIN               : u16 = 68;  // unsigned integer
pub(crate) const SQLT_SLS               : u16 = 91;  // Display sign leading separate
pub(crate) const SQLT_LVC               : u16 = 94;  // Longer longs (char)
pub(crate) const SQLT_LVB               : u16 = 95;  // Longer long binary
pub(crate) const SQLT_AFC               : u16 = 96;  // Ansi fixed char
pub(crate) const SQLT_AVC               : u16 = 97;  // Ansi Var char
pub(crate) const SQLT_IBFLOAT           : u16 = 100; // binary float canonical
pub(crate) const SQLT_IBDOUBLE          : u16 = 101; // binary double canonical
pub(crate) const SQLT_CUR               : u16 = 102; // cursor  type
pub(crate) const SQLT_RDD               : u16 = 104; // rowid descriptor
pub(crate) const SQLT_LAB               : u16 = 105; // label type
pub(crate) const SQLT_OSL               : u16 = 106; // oslabel type

pub(crate) const SQLT_NTY               : u16 = 108; // named object type, a.k.a. user-defined type
pub(crate) const SQLT_REF               : u16 = 110; // ref type
pub(crate) const SQLT_CLOB              : u16 = 112; // character lob
pub(crate) const SQLT_BLOB              : u16 = 113; // binary lob
pub(crate) const SQLT_BFILE             : u16 = 114; // binary file lob
pub(crate) const SQLT_CFILE             : u16 = 115; // character file lob
pub(crate) const SQLT_RSET              : u16 = 116; // result set type
pub(crate) const SQLT_NCO               : u16 = 122; // named collection type (varray or nested table)
pub(crate) const SQLT_VST               : u16 = 155; // OCIString type
pub(crate) const SQLT_ODT               : u16 = 156; // OCIDate type

// datetimes and intervals
pub(crate) const SQLT_DATE              : u16 = 184; // ANSI Date
pub(crate) const SQLT_TIME              : u16 = 185; // TIME
pub(crate) const SQLT_TIME_TZ           : u16 = 186; // TIME WITH TIME ZONE
pub(crate) const SQLT_TIMESTAMP         : u16 = 187; // TIMESTAMP
pub(crate) const SQLT_TIMESTAMP_TZ      : u16 = 188; // TIMESTAMP WITH TIME ZONE
pub(crate) const SQLT_INTERVAL_YM       : u16 = 189; // INTERVAL YEAR TO MONTH
pub(crate) const SQLT_INTERVAL_DS       : u16 = 190; // INTERVAL DAY TO SECOND
pub(crate) const SQLT_TIMESTAMP_LTZ     : u16 = 232; // TIMESTAMP WITH LOCAL TZ

pub(crate) const SQLT_PNTY              : u16 = 241; // pl/sql representation of named types

// some pl/sql specific types
pub(crate) const SQLT_REC               : u16 = 250; // pl/sql 'record' (or %rowtype)
pub(crate) const SQLT_TAB               : u16 = 251; // pl/sql 'indexed table'
pub(crate) const SQLT_BOL               : u16 = 252; // pl/sql 'boolean'

// Null indicator information
pub(crate) const OCI_IND_NOTNULL        : i16 = 0;
pub(crate) const OCI_IND_NULL           : i16 = -1;

// char set "form" information
pub(crate) const SQLCS_IMPLICIT         : u8 = 1;
pub(crate) const SQLCS_NCHAR            : u8 = 2;

// OBJECT Duration
pub(crate) const OCI_DURATION_SESSION   : u16 = 10;
pub(crate) const OCI_DURATION_STATEMENT : u16 = 13;

// Character Sets
pub(crate) const AL32UTF8               : u16 = 873;
pub(crate) const UTF8                   : u16 = 871;

// Initialization Modes
pub(crate) const OCI_THREADED : u32 = 1;
pub(crate) const OCI_OBJECT   : u32 = 2;

pub(crate) const OCI_ATTR_CACHE_OPT_SIZE    : u32 = 34;
pub(crate) const OCI_ATTR_CACHE_MAX_SIZE    : u32 = 35;
pub(crate) const OCI_ATTR_ENV_NLS_LANGUAGE  : u32 = 424;
pub(crate) const OCI_ATTR_ENV_NLS_TERRITORY : u32 = 425;

// Credential Types
pub(crate) const OCI_CRED_RDBMS    : u32 = 1;
pub(crate) const OCI_CRED_EXT      : u32 = 2;

// OCISessionPoolCreate Modes
pub(crate) const OCI_SPC_REINITIALIZE   : u32 = 0x0001; // Reinitialize the session pool
pub(crate) const OCI_SPC_HOMOGENEOUS    : u32 = 0x0002; // Session pool is homogeneneous
pub(crate) const OCI_SPC_STMTCACHE      : u32 = 0x0004; // Session pool has stmt cache
pub(crate) const OCI_SPC_NO_RLB         : u32 = 0x0008; // Do not enable Runtime load balancing

// OCISessionPoolDestroy Modes
pub(crate) const OCI_SPD_FORCE          : u32 = 0x0001; // Force the sessions to terminate. Even if there are some busy sessions close them.

// ATTR Values for Session Pool
pub(crate) const OCI_SPOOL_ATTRVAL_WAIT     : u8 = 0; // block till you get a session
pub(crate) const OCI_SPOOL_ATTRVAL_NOWAIT   : u8 = 1; // error out if no session avaliable
pub(crate) const OCI_SPOOL_ATTRVAL_FORCEGET : u8 = 2; // get session even if max is exceeded
pub(crate) const OCI_SPOOL_ATTRVAL_TIMEDWAIT: u8 = 3; // wait for specified timeout if pool is maxed out

// OCISessionGet Modes
pub(crate) const OCI_SESSGET_SPOOL              : u32 = 0x0001;
pub(crate) const OCI_SESSGET_STMTCACHE          : u32 = 0x0004;
pub(crate) const OCI_SESSGET_SPOOL_MATCHANY     : u32 = 0x0020;
pub(crate) const OCI_SESSGET_PURITY_NEW         : u32 = 0x0040;
pub(crate) const OCI_SESSGET_PURITY_SELF        : u32 = 0x0080;
pub(crate) const OCI_SESSGET_SYSDBA             : u32 = 0x0100;
pub(crate) const OCI_SESSGET_CPOOL              : u32 = 0x0200;
pub(crate) const OCI_SESSGET_MULTIPROPERTY_TAG  : u32 = 0x0400;

// OCISessionReleases Modes
pub(crate) const OCI_SESSRLS_RETAG              : u32 = 0x0002;
pub(crate) const OCI_SESSRLS_MULTIPROPERTY_TAG  : u32 = 0x0004;

// Server Handle Attribute Values
// const OCI_SERVER_NOT_CONNECTED  : u32 = 0;
pub(crate) const OCI_SERVER_NORMAL : u32 = 1;
pub(crate) const OCI_ATTR_NONBLOCKING_MODE  : u32 = 3;
pub(crate) const OCI_ATTR_SERVER            : u32 = 6;
pub(crate) const OCI_ATTR_SESSION           : u32 = 7;
pub(crate) const OCI_ATTR_ROWID             : u32 = 19;
pub(crate) const OCI_ATTR_USERNAME          : u32 = 22;
pub(crate) const OCI_ATTR_PASSWORD          : u32 = 23;
pub(crate) const OCI_ATTR_LOBEMPTY          : u32 = 45;
pub(crate) const OCI_ATTR_SERVER_STATUS     : u32 = 143;
pub(crate) const OCI_ATTR_CURRENT_SCHEMA    : u32 = 224;
pub(crate) const OCI_ATTR_CLIENT_IDENTIFIER : u32 = 278;
pub(crate) const OCI_ATTR_MODULE            : u32 = 366;
pub(crate) const OCI_ATTR_ACTION            : u32 = 367;
pub(crate) const OCI_ATTR_CLIENT_INFO       : u32 = 368;
pub(crate) const OCI_ATTR_COLLECT_CALL_TIME : u32 = 369;
pub(crate) const OCI_ATTR_CALL_TIME         : u32 = 370;
pub(crate) const OCI_ATTR_DRIVER_NAME       : u32 = 424;
pub(crate) const OCI_ATTR_DEFAULT_LOBPREFETCH_SIZE : u32 = 438;
pub(crate) const OCI_ATTR_LOB_REMOTE        : u32 = 520;
pub(crate) const OCI_ATTR_LOB_TYPE          : u32 = 591;

pub(crate) const OCI_ATTR_SPOOL_STMTCACHESIZE           : u32 = 208; // Stmt cache size of pool
pub(crate) const OCI_ATTR_SPOOL_TIMEOUT                 : u32 = 308; // session timeout
pub(crate) const OCI_ATTR_SPOOL_GETMODE                 : u32 = 309; // session get mode
pub(crate) const OCI_ATTR_SPOOL_BUSY_COUNT              : u32 = 310; // busy session count
pub(crate) const OCI_ATTR_SPOOL_OPEN_COUNT              : u32 = 311; // open session count
pub(crate) const OCI_ATTR_SPOOL_AUTH                    : u32 = 460; // Auth handle on pool handle
pub(crate) const OCI_ATTR_SPOOL_MAX_LIFETIME_SESSION    : u32 = 490; // Max Lifetime for session
pub(crate) const OCI_ATTR_SPOOL_WAIT_TIMEOUT            : u32 = 506;
pub(crate) const OCI_ATTR_SPOOL_MAX_USE_SESSION         : u32 = 580;

// Connection Pool Attributes
pub(crate) const OCI_ATTR_CONN_NOWAIT       : u32 = 178;
pub(crate) const OCI_ATTR_CONN_BUSY_COUNT   : u32 = 179;
pub(crate) const OCI_ATTR_CONN_OPEN_COUNT   : u32 = 180;
pub(crate) const OCI_ATTR_CONN_TIMEOUT      : u32 = 181;
pub(crate) const OCI_ATTR_STMT_STATE        : u32 = 182;
pub(crate) const OCI_ATTR_CONN_MIN          : u32 = 183;
pub(crate) const OCI_ATTR_CONN_MAX          : u32 = 184;
pub(crate) const OCI_ATTR_CONN_INCR         : u32 = 185;


pub(crate) const OCI_ERROR_MAXMSG_SIZE      : usize = 3072;

pub(crate) const OCI_FETCH_NEXT             : u16 = 2;

pub(crate) const OCI_TEMP_BLOB              : u8 = 1;
pub(crate) const OCI_TEMP_CLOB              : u8 = 2;

pub(crate) const OCI_FILE_READONLY          : u8 = 1;
pub(crate) const OCI_LOB_READONLY           : u8 = 1;
pub(crate) const OCI_LOB_READWRITE          : u8 = 2;

pub(crate) const OCI_ONE_PIECE              : u8 = 0;
pub(crate) const OCI_FIRST_PIECE            : u8 = 1;
pub(crate) const OCI_NEXT_PIECE             : u8 = 2;
pub(crate) const OCI_LAST_PIECE             : u8 = 3;

pub(crate) const OCI_LOB_CONTENTTYPE_MAXSIZE    : usize = 128;

// Parsing Syntax Types
pub(crate) const OCI_NTV_SYNTAX   : u32 = 1;

// Statement Types
// pub(crate) const OCI_STMT_UNKNOWN : u16 = 0;
pub(crate) const OCI_STMT_SELECT  : u16 = 1;
// pub(crate) const OCI_STMT_UPDATE  : u16 = 2;
// pub(crate) const OCI_STMT_DELETE  : u16 = 3;
// pub(crate) const OCI_STMT_INSERT  : u16 = 4;
// pub(crate) const OCI_STMT_CREATE  : u16 = 5;
// pub(crate) const OCI_STMT_DROP    : u16 = 6;
// pub(crate) const OCI_STMT_ALTER   : u16 = 7;
// pub(crate) const OCI_STMT_BEGIN   : u16 = 8;
// pub(crate) const OCI_STMT_DECLARE : u16 = 9;
// pub(crate) const OCI_STMT_CALL    : u16 = 10;
// pub(crate) const OCI_STMT_MERGE   : u16 = 16;

// Attributes common to Columns and Stored Procs
pub(crate) const OCI_ATTR_DATA_SIZE         : u32 =  1; // maximum size of the data
pub(crate) const OCI_ATTR_DATA_TYPE         : u32 =  2; // the SQL type of the column/argument
// pub(crate) const OCI_ATTR_DISP_SIZE         : u32 =  3; // the display size
pub(crate) const OCI_ATTR_NAME              : u32 =  4; // the name of the column/argument
pub(crate) const OCI_ATTR_PRECISION         : u32 =  5; // precision if number type
pub(crate) const OCI_ATTR_SCALE             : u32 =  6; // scale if number type
pub(crate) const OCI_ATTR_IS_NULL           : u32 =  7; // is it null ?
pub(crate) const OCI_ATTR_TYPE_NAME         : u32 =  8; // name of the named data type or a package name for package private types
pub(crate) const OCI_ATTR_SCHEMA_NAME       : u32 =  9; // the schema name
// pub(crate) const OCI_ATTR_SUB_NAME          : u32 = 10; // type name if package private type
// pub(crate) const OCI_ATTR_POSITION          : u32 = 11; // relative position of col/arg in the list of cols/args
// pub(crate) const OCI_ATTR_PACKAGE_NAME      : u32 = 12; // package name of package type
pub(crate) const OCI_ATTR_CHARSET_FORM      : u32 = 32;
pub(crate) const OCI_ATTR_COL_PROPERTIES    : u32 = 104;
pub(crate) const OCI_ATTR_CHAR_SIZE         : u32 = 286;

// Flags coresponding to the column properties
pub(crate) const OCI_ATTR_COL_PROPERTY_IS_IDENTITY             : u8 = 0x01;
pub(crate) const OCI_ATTR_COL_PROPERTY_IS_GEN_ALWAYS           : u8 = 0x02;
pub(crate) const OCI_ATTR_COL_PROPERTY_IS_GEN_BY_DEF_ON_NULL   : u8 = 0x04;

/// Character set form
#[derive(Debug)]
pub enum CharSetForm {
    Undefined = 0,
    Implicit = 1,
    NChar = 2
}

/// LOB cache control flags
pub enum Cache {
    No  = 0,
    Yes = 1,
}

extern "C" {
    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/handle-and-descriptor-functions.html#GUID-C5BF55F7-A110-4CB5-9663-5056590F12B5
    fn OCIHandleAlloc(
        parenth:    *const OCIEnv,
        hndlpp:     *mut *mut c_void,
        hndl_type:  u32,
        xtramem_sz: size_t,
        usrmempp:   *const c_void
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/handle-and-descriptor-functions.html#GUID-E87E9F91-D3DC-4F35-BE7C-F1EFBFEEBA0A
    fn OCIHandleFree(
        hndlp:      *const c_void,
        hnd_type:   u32
    ) -> i32;
}

extern "C" {
    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/handle-and-descriptor-functions.html#GUID-E9EF2766-E078-49A7-B1D1-738E4BA4814F
    fn OCIDescriptorAlloc(
        parenth:    *const OCIEnv,
        descpp:     *mut *mut c_void,
        desc_type:  u32,
        xtramem_sz: size_t,
        usrmempp:   *const c_void
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/handle-and-descriptor-functions.html#GUID-A32BF051-3DC1-491C-AAFD-A46034DD1629
    fn OCIDescriptorFree(
        descp:      *mut c_void,
        desc_type:  u32
    ) -> i32;
}

extern "C" {
    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/handle-and-descriptor-functions.html#GUID-FA199A99-4D7A-42C2-BB0A-C20047B95DF9
    fn OCIAttrGet(
        trgthndlp:  *const c_void,
        trghndltyp: u32,
        attributep: *mut c_void,
        sizep:      *const u32,
        attrtype:   u32,
        errhp:      *const OCIError
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/handle-and-descriptor-functions.html#GUID-3741D7BD-7652-4D7A-8813-AC2AEA8D3B03
    pub(crate) fn OCIAttrSet(
        trgthndlp:  *const c_void,
        trghndltyp: u32,
        attributep: *const c_void,
        size:       u32,
        attrtype:   u32,
        errhp:      *const OCIError
    ) -> i32;
}

extern "C" {
    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/handle-and-descriptor-functions.html#GUID-35D2FF91-139B-4A5C-97C8-8BC29866CCA4
    fn OCIParamGet(
        hndlp:      *const c_void,
        htype:      u32,
        errhp:      *const OCIError,
        descr:      *mut *mut c_void,
        pos:        u32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/handle-and-descriptor-functions.html#GUID-280CF9E5-3537-4785-9AFA-4E63DE29A266
    // fn OCIParamSet(
    //     hndlp:      *const c_void,
    //     htype:      u32,
    //     errhp:      *const OCIError,
    //     descr:      *const c_void,
    //     dtype:      u32,
    //     pos:        u32
    // ) -> i32;
}

extern "C" {
    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/miscellaneous-functions.html#GUID-83879DA9-768D-4ED6-AFFE-F9D216E4D9B8
    fn OCIClientVersion(
        feature_release:         *mut i32,
        release_update:          *mut i32,
        release_update_revision: *mut i32,
        increment:               *mut i32,
        ext:                     *mut i32,
    );

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/miscellaneous-functions.html#GUID-4B99087C-74F6-498A-8310-D6645172390A
    pub(crate) fn OCIErrorGet(
        hndlp:      *const c_void,
        recordno:   u32,
        sqlstate:   *const c_void,
        errcodep:   *const i32,
        bufp:       *mut u8,
        bufsiz:     u32,
        hnd_type:   u32,
    ) -> i32;
}

extern "C" {
    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/connect-authorize-and-initialize-functions.html#GUID-0B6911A9-4B46-476C-BC5E-B87581666CD9
    pub(crate) fn OCIEnvNlsCreate(
        envhpp:     *mut *mut  OCIEnv,
        mode:       u32,
        ctxp:       *const c_void,
        malocfp:    *const c_void,
        ralocfp:    *const c_void,
        mfreefp:    *const c_void,
        xtramemsz:  size_t,
        usrmempp:   *const c_void,
        charset:    u16,
        ncharset:   u16
    ) -> i32;
}

extern "C" {
    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/connect-authorize-and-initialize-functions.html#GUID-B6291228-DA2F-4CE9-870A-F94243141757
    fn OCIServerAttach(
        srvhp:      *const OCIServer,
        errhp:      *const OCIError,
        dblink:     *const u8,
        dblink_len: u32,
        mode:       u32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/connect-authorize-and-initialize-functions.html#GUID-402B540A-05FF-464B-B9C8-B2E7B4ABD564
    fn OCIServerDetach(
        srvhp:      *const OCIServer,
        errhp:      *const OCIError,
        mode:       u32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/connect-authorize-and-initialize-functions.html#GUID-31B1FDB3-056E-4AF9-9B89-8DA6AA156947
    fn OCISessionBegin(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        userhp:     *const OCISession,
        credt:      u32,
        mode:       u32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/connect-authorize-and-initialize-functions.html#GUID-2AE88BDC-2C44-4958-B26A-434B0407F06F
    fn OCISessionEnd(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        userhp:     *const OCISession,
        mode:       u32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/connect-authorize-and-initialize-functions.html#GUID-7E5A69F2-0268-4655-845D-A7662902FAA2
    fn OCIConnectionPoolCreate (
        envhp:          *const OCIEnv,
        errhp:          *const OCIError,
        cpoolhp:        *const OCICPool,
        pool_name:      *mut *const u8,
        pool_name_len:  *const u32,
        dblink:         *const u8,
        dblink_len:     u32,
        conn_min:       u32,
        conn_max:       u32,
        conn_incr:      u32,
        username:       *const u8,
        username_len:   u32,
        password:       *const u8,
        password_len:   u32,
        mode:           u32,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/connect-authorize-and-initialize-functions.html#GUID-46720C8F-0A9F-4300-B6C4-4E47875A95C2
    fn OCIConnectionPoolDestroy  (
        spoolhp:        *const OCICPool,
        errhp:          *const OCIError,
        mode:           u32,
    ) -> i32;


    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/connect-authorize-and-initialize-functions.html#GUID-1E929CFB-9D96-4E8E-9F24-904AD539E555
    fn OCISessionPoolCreate (
        envhp:          *const OCIEnv,
        errhp:          *const OCIError,
        spoolhp:        *const OCISPool,
        pool_name:      *mut *const u8,
        pool_name_len:  *const u32,
        conn_str:       *const u8,
        conn_str_len:   u32,
        sess_min:       u32,
        sess_max:       u32,
        sess_incr:      u32,
        userid:         *const u8,
        userid_len:     u32,
        password:       *const u8,
        password_len:   u32,
        mode:           u32,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/connect-authorize-and-initialize-functions.html#GUID-2797C90C-C7AC-47FB-B1C2-CE41B743FB5C
    fn OCISessionPoolDestroy  (
        spoolhp:        *const OCISPool,
        errhp:          *const OCIError,
        mode:           u32,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/connect-authorize-and-initialize-functions.html#GUID-890DFBC4-718B-4339-A0EA-6226A25B8241
    fn OCISessionGet(
        envhp:      *const OCIEnv,
        errhp:      *const OCIError,
        svchp:      *mut *mut OCISvcCtx,
        authinfop:  *const OCIAuthInfo,
        dbname:     *const u8,
        dbname_len: u32,
        taginfo:    *const u8,
        taginfolen: u32,
        rettags:    *mut *const u8,
        rettagslen: *mut u32,
        found:      *const u8,
        mode:       u32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/connect-authorize-and-initialize-functions.html#GUID-DAAECC99-A432-48B5-AC33-0868C2FE762D
    pub(crate) fn OCISessionRelease(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        tag:        *const u8,
        taglen:     u32,
        mode:       u32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/transaction-functions.html#GUID-DDAE3122-8769-4A30-8D78-EB2A3CCF77D4
    fn OCITransCommit(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        flags:      u32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/transaction-functions.html#GUID-06EF9A0A-01A3-40CE-A0B7-DF0504A93366
    fn OCITransRollback(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        flags:      u32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/miscellaneous-functions.html#GUID-033BF96D-D88D-4F18-909A-3AB7C2F6C70F
    fn OCIPing(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        mode:       u32
    ) -> i32;
}

extern "C" {
    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/statement-functions.html#GUID-E6C1DC67-D464-4D2A-9F19-737423D31779
    fn OCIStmtPrepare2(
        svchp:      *const OCISvcCtx,
        stmthp:     *mut *mut OCIStmt,
        errhp:      *const OCIError,
        stmttext:   *const u8,
        stmt_len:   u32,
        key:        *const u8,
        keylen:     u32,
        language:   u32,
        mode:       u32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/statement-functions.html#GUID-256034CE-2ADB-4BE5-BC8D-748307F2EA8E
    fn OCIStmtRelease(
        stmtp:      *const OCIStmt,
        errhp:      *const OCIError,
        key:        *const u8,
        keylen:     u32,
        mode:       u32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/bind-define-describe-functions.html#GUID-87D50C09-F18D-45BB-A8AF-1E6AFEC6FE2E
    fn OCIStmtGetBindInfo(
        stmtp:      *const OCIStmt,
        errhp:      *const OCIError,
        size:       u32,
        startloc:   u32,
        found:      *const i32,
        bvnp:       *mut *mut u8,
        bvnl:       *const u8,
        invp:       *mut *mut u8,
        invl:       *const u8,
        dupl:       *const u8,
        hndl:       *mut *mut OCIBind
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/bind-define-describe-functions.html#GUID-CD63DF78-2178-4727-A896-B9673C4A37F0
    // fn OCIBindByName2(
    //     stmtp:      *const OCIStmt,
    //     bindpp:     *mut *mut OCIBind,
    //     errhp:      *const OCIError,
    //     namep:      *const u8,
    //     name_len:   i32,
    //     valuep:     *const c_void,
    //     value_sz:   i64,
    //     dty:        u16,
    //     indp:       *const c_void,
    //     alenp:      *const u32,
    //     rcodep:     *const u16,
    //     maxarr_len: u32,
    //     curelep:    *const u32,
    //     mode:       u32
    // ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/bind-define-describe-functions.html#GUID-5C505821-323D-473D-825B-448C8D9A6702
    fn OCIBindByPos2(
        stmtp:      *const OCIStmt,
        bindpp:     *mut *mut OCIBind,
        errhp:      *const OCIError,
        position:   u32,
        valuep:     *const c_void,
        value_sz:   i64,
        dty:        u16,
        indp:       *const i16,
        alenp:      *const u32,
        rcodep:     *const u16,
        maxarr_len: u32,
        curelep:    *const u32,
        mode:       u32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/bind-define-describe-functions.html#GUID-030270CB-346A-412E-B3B3-556DD6947BE2
    // fn OCIBindDynamic(
    //     bindp:      *const OCIBind,
    //     errhp:      *const OCIError,
    //     ictxp:      *const c_void,
    //     icbfp:      OCICallbackInBind,
    //     octxp:      *const c_void,
    //     ocbfp:      OCICallbackOutBind
    // ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/statement-functions.html#GUID-98B26708-3E02-45C0-8258-5D5544F32BE9
    fn OCIStmtExecute(
        svchp:      *const OCISvcCtx,
        stmtp:      *const OCIStmt,
        errhp:      *const OCIError,
        iters:      u32,
        rowoff:     u32,
        snap_in:    *const c_void,  // *const OCISnapshot
        snap_out:   *const c_void,    // *const OCISnapshot
        mode:       u32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/statement-functions.html#GUID-60B998F9-F213-43BA-AB84-76F1EC6A6687
    pub(crate) fn OCIStmtGetNextResult(
        stmtp:      *const OCIStmt,
        errhp:      *const OCIError,
        result:     *mut *mut OCIStmt,
        rtype:      *mut u32,
        mode:       u32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/statement-functions.html#GUID-DF585B90-58BA-45FC-B7CE-6F7F987C03B9
    pub(crate) fn OCIStmtFetch2(
        stmtp:      *const OCIStmt,
        errhp:      *const OCIError,
        nrows:      u32,
        orient:     u16,
        offset:     i16,
        mode:       u32
    ) -> i32;
}

extern "C" {
    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/bind-define-describe-functions.html#GUID-74939FB5-919E-4D24-B327-AFB532435061
    fn OCIDefineByPos2(
        stmtp:      *const OCIStmt,
        defnpp:     *mut *mut OCIDefine,
        errhp:      *const OCIError,
        position:   u32,
        valuep:     *const c_void,
        value_sz:   i64,
        dty:        u16,
        indp:       *const i16,
        rlenp:      *const u32,
        rcodep:     *const u16,
        mode:       u32
    ) -> i32;
}

extern "C" {
    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/miscellaneous-functions.html#GUID-064F2680-453A-40D1-9C36-518F1E2B31DF
    fn OCIRowidToChar(
        desc:   *const OCIRowid,
        text:   *const u8,
        size:   *const u16,
        err:    *const OCIError,
    ) -> i32;
}

extern "C" {
    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-84EA4A66-27BF-470C-8464-3DE31937702A
    // fn OCIDurationBegin(
    //     envhp:      *const OCIEnv,
    //     errhp:      *const OCIError,
    //     svchp:      *const OCISvcCtx,
    //     parent:     u16,
    //     duration:   *const u16
    // ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-AABC3F29-C91B-45A7-AF1E-D486C12E4962
    // fn OCIDurationEnd(
    //     envhp:      *const OCIEnv,
    //     errhp:      *const OCIError,
    //     svchp:      *const OCISvcCtx,
    //     duration:   u16
    // ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-5B43FC88-A649-4764-8C1E-6D792F05F7CE
    pub(crate) fn OCILobAppend(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        dst:        *const OCILobLocator,
        src:        *const OCILobLocator,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-9B25760D-649E-4B83-A0AA-8C4F3C479BC8
    fn OCILobCharSetForm(
        envhp:      *const OCIEnv,
        errhp:      *const OCIError,
        src:        *const OCILobLocator,
        csform:     *const u8
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-A243691D-8180-4AF6-AA6E-DF9333F8258B
    fn OCILobCharSetId(
        envhp:      *const OCIEnv,
        errhp:      *const OCIError,
        src:        *const OCILobLocator,
        csid:       *const u16
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-CBEB9238-6B47-4A08-8C8D-FC2E5ED56557
    pub(crate) fn OCILobClose(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        loc:        *const OCILobLocator,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-404C8A50-516F-4DFD-939D-646A232AF7DF
    pub(crate) fn OCILobCopy2(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        dst:        *const OCILobLocator,
        src:        *const OCILobLocator,
        amount:     u64,
        dst_off:    u64,
        src_off:    u64,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-63F75EC5-EB14-4E25-B593-270FF814615A
    pub(crate) fn OCILobCreateTemporary(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        loc:        *const OCILobLocator,
        csid:       u16,
        csfrm:      u8,
        lob_type:   u8,
        cache:      u8,
        duration:   u16,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-264797B2-B3EA-4F6D-9A0E-BF8A4DDA13FA
    pub(crate) fn OCILobErase2(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        loc:        *const OCILobLocator,
        amount:     *const u64,
        offset:     u64,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-40AFA7A3-3A24-4DF7-A719-AECA7C1F522A
    pub(crate) fn OCILobFileClose(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        filep:      *const OCILobLocator,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-977F905D-DAFB-4D88-8FE0-7A345837B147
    pub(crate) fn OCILobFileExists(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        filep:      *const OCILobLocator,
        flag:       *const u8
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-BF637A34-B18A-47EE-A060-93C4E79D1813
    fn OCILobFileGetName(
        envhp:      *const OCIEnv,
        errhp:      *const OCIError,
        loc:        *const OCILobLocator,
        dir:        *const u8,
        dir_len:    *const u16,
        filename:   *const u8,
        name_len:   *const u16,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-A662166C-DC74-40B4-9BFA-8D3ED216FDE7
    pub(crate) fn OCILobFileIsOpen(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        filep:      *const OCILobLocator,
        flag:       *const u8
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-2E933BBA-BCE3-41F2-B8A2-4F9485F0BCB0
    pub(crate) fn OCILobFileOpen(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        filep:      *const OCILobLocator,
        mode:       u8
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-507AC0EF-4CAB-437E-BB94-1FD77EDC1B5C
    fn OCILobFileSetName(
        envhp:      *const OCIEnv,
        errhp:      *const OCIError,
        filepp:     *mut *mut OCILobLocator,
        dir:        *const u8,
        dir_len:    u16,
        filename:   *const u8,
        name_len:   u16,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-E0FBF017-1B08-410C-9E53-F6E14008813A
    pub(crate) fn OCILobFreeTemporary(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        loc:        *const OCILobLocator,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-ABB71585-172E-4F3E-A0CF-F70D709F2072
    pub(crate) fn OCILobGetChunkSize(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        loc:        *const OCILobLocator,
        size:       *const u32,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-D62200EF-FA60-4788-950F-0C0686D807FD
    pub(crate) fn OCILobGetContentType(
        envhp:      *const OCIEnv,
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        loc:        *const OCILobLocator,
        ctx_type:   *mut u8,
        len:        *mut u32,
        mode:       u32
    )-> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-9BC0A78A-37CB-432F-AE2B-22C905608C4C
    pub(crate) fn OCILobGetLength2(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        loc:        *const OCILobLocator,
        len:        *const u64,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-5142710F-03AD-43D5-BBAB-6732B874E52E
    fn OCILobIsEqual(
        envhp:      *const OCIEnv,
        loc1:       *const OCILobLocator,
        loc2:       *const OCILobLocator,
        flag:       *const u8,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-FFF883CE-3B99-4319-A81C-A11F8740209E
    pub(crate) fn OCILobIsOpen(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        loc:        *const OCILobLocator,
        flag:       *const u8,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-071D8134-F9E7-4C5A-8E63-E90831FA7AC3
    pub(crate) fn OCILobIsTemporary(
        envhp:      *const OCIEnv,
        errhp:      *const OCIError,
        loc:        *const OCILobLocator,
        flag:       *const u8,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-DA1CD18B-7044-4E40-B1F4-4FCC1FCAB6C4
    pub(crate) fn OCILobLoadFromFile2(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        dst:        *const OCILobLocator,
        src:        *const OCILobLocator,
        amount:     u64,
        dst_off:    u64,
        src_off:    u64,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-F7887376-4B3C-430C-94A3-11FE96E26627
    fn OCILobLocatorAssign(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        src:        *const OCILobLocator,
        dst:        *mut *mut OCILobLocator,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-4CA17A83-795F-43B2-8B76-611B13E4C8DE
    fn OCILobLocatorIsInit(
        envhp:      *const OCIEnv,
        errhp:      *const OCIError,
        src:        *const OCILobLocator,
        flag:       *const u8,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-B007A3C7-999B-4AD7-8BF7-C6D14572F470
    pub(crate) fn OCILobOpen(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        loc:        *const OCILobLocator,
        mode:       u8,
    ) -> i32;

    // https://docs.oracle.com/cd/B19306_01/appdev.102/b14250/oci16msc002.htm#sthref3010
    fn OCILobRead(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        loc:        *const OCILobLocator,
        amtp:       *mut u32,
        offset:     u32,
        buf:        *mut u8,
        buf_len:    u32,
        ctx:        *mut c_void,
        read_cb:    *const c_void,
        csid:       u16,
        csfrm:      u8,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-6AC6E6DA-236B-4BF9-942F-9FCC4178FEDA
    fn OCILobRead2(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        loc:        *const OCILobLocator,
        byte_cnt:   *mut u64,
        char_cnt:   *mut u64,
        offset:     u64,
        buf:        *mut u8,
        buf_len:    u64,
        piece:      u8,
        ctx:        *mut c_void,
        read_cb:    *const c_void,
        csid:       u16,
        csfrm:      u8,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-789C0971-76D5-4439-9379-E3DCE7885528
    pub(crate) fn OCILobSetContentType(
        envhp:      *const OCIEnv,
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        loc:        *const OCILobLocator,
        ctype:      *const u8,
        len:        u32,
        mode:       u32,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-ABDB1543-1782-4216-AD80-55FA82CFF733
    pub(crate) fn OCILobTrim2(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        loc:        *const OCILobLocator,
        len:        u64,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-77F056CA-9EEE-4550-8A8E-0155DF994DBE
    pub(crate) fn OCILobWrite2(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        loc:        *const OCILobLocator,
        byte_cnt:   *mut u64,
        char_cnt:   *mut u64,
        offset:     u64,
        buf:        *const u8,
        buf_len:    u64,
        piece:      u8,
        ctx:        *const c_void,
        write_cb:   *const c_void,
        csid:       u16,
        csfrm:      u8,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/lob-functions.html#GUID-87D3275A-B042-4991-B261-AB531BB83CA2
    pub(crate) fn OCILobWriteAppend2(
        svchp:      *const OCISvcCtx,
        errhp:      *const OCIError,
        loc:        *const OCILobLocator,
        byte_cnt:   *mut u64,
        char_cnt:   *mut u64,
        buf:        *const u8,
        buf_len:    u64,
        piece:      u8,
        ctx:        *const c_void,
        write_cb:   *const c_void,
        csid:       u16,
        csfrm:      u8,
    ) -> i32;
}

extern "C" {
    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-E0890180-8714-4243-A585-0FD21EB05CA9
    fn OCIDateAddDays(
        err:        *const OCIError,
        date:       *const OCIDate,
        num_days:   i32,
        result:     *const OCIDate
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-CE37ECF1-622A-49A9-A9FD-40E1BD67C941
    fn OCIDateAddMonths(
        err:        *const OCIError,
        date:       *const OCIDate,
        num_months: i32,
        result:     *const OCIDate
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-2251373B-4F7B-4680-BB90-F9013216465A
    fn OCIDateAssign(
        err:        *const OCIError,
        date:       *const OCIDate,
        result:     *const OCIDate
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-067F7EB4-419B-4A5B-B1C4-B4C650B874A3
    // fn OCIDateCheck(
    //     err:        *const OCIError,
    //     date:       *const OCIDate,
    //     result:     *const u32
    // ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-282C5B79-64AA-4B34-BFC6-292144B1AD16
    fn OCIDateCompare(
        err:        *const OCIError,
        date1:      *const OCIDate,
        date2:      *const OCIDate,
        result:     *const i32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-42422C47-805F-4EAA-BF44-E6DE6164082E
    fn OCIDateDaysBetween(
        err:        *const OCIError,
        date1:      *const OCIDate,
        date2:      *const OCIDate,
        result:     *const i32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-EA8FEB07-401C-477E-805B-CC9E89FB13F4
    fn OCIDateFromText(
        err:        *const OCIError,
        txt:        *const u8,
        txt_len:    u32,
        fmt:        *const u8,
        fmt_len:    u8,
        lang:       *const u8,
        lang_len:   u32,
        result:     *const OCIDate
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-14FB323E-BAEB-4FC7-81DA-6AF243C0D7D6
    fn OCIDateLastDay(
        err:        *const OCIError,
        date:       *const OCIDate,
        result:     *const OCIDate
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-A16AB88E-A3BF-4B50-8FEF-6427926198F4
    fn OCIDateNextDay(
        err:        *const OCIError,
        date:       *const OCIDate,
        day:        *const u8,
        day_len:    u32,
        result:     *const OCIDate
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-123DD789-48A2-4AD7-8B1E-5E454DFE3F1E
    fn OCIDateToText(
        err:        *const OCIError,
        date:       *const OCIDate,
        fmt:        *const u8,
        fmt_len:    u8,
        lang:       *const u8,
        lang_len:   u32,
        buf_size:   *const u32,
        buf:        *const u8
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-751D4F33-E593-4845-9D5E-8761A19BD243
    fn OCIDateSysDate(
        err:        *const OCIError,
        result:     *const OCIDate
    ) -> i32;
}

extern "C" {
    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-0E4AF4DD-5EEB-434D-BA3A-F4EDE7038FF5
    fn OCIIntervalAdd(
        hndl:       *const c_void,
        err:        *const OCIError,
        addend1:    *const OCIInterval,
        addend2:    *const OCIInterval,
        result:     *mut OCIInterval,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-A218E261-3D40-4B69-AD64-41B697A18C98
    fn OCIIntervalAssign(
        hndl:       *const c_void,
        err:        *const OCIError,
        inpinter:   *const OCIInterval,
        outinter:   *mut OCIInterval,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-90BA159E-79AE-47C6-844C-41BB5ADFEBD3
    // fn OCIIntervalCheck(
    //     hndl:       *const c_void,
    //     err:        *const OCIError,
    //     interval:   *const OCIInterval,
    //     valid:      *const u32,
    // ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-CCE310E5-C75E-4EDD-9B52-9CED37BDFEFF
    fn OCIIntervalCompare(
        hndl:       *const c_void,
        err:        *const OCIError,
        inter1:     *const OCIInterval,
        inter2:     *const OCIInterval,
        result:     *const i32,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-16880D01-45BE-43A3-9CF2-AEAE07B64A6B
    fn OCIIntervalDivide(
        hndl:       *const c_void,
        err:        *const OCIError,
        dividend:   *const OCIInterval,
        divisor:    *const OCINumber,
        result:     *mut OCIInterval,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-1F8A4B39-9EA5-4CEF-9468-079E4203B68D
    fn OCIIntervalFromNumber(
        hndl:       *const c_void,
        err:        *const OCIError,
        interval:   *mut OCIInterval,
        number:     *const OCINumber,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-247BB9B8-307B-4132-A1ED-5CA658B0DAA6
    fn OCIIntervalFromText(
        hndl:       *const c_void,
        err:        *const OCIError,
        inpstring:  *const u8,
        str_len:    size_t,
        result:     *mut OCIInterval,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-12B19818-0001-42F1-8B2C-FD96B7C3231C
    fn OCIIntervalFromTZ(
        hndl:       *const c_void,
        err:        *const OCIError,
        inpstring:  *const u8,
        str_len:    size_t,
        result:     *mut OCIInterval,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-210C4C25-3E8D-4F6D-9502-20B258DACA60
    fn OCIIntervalGetDaySecond(
        hndl:       *const c_void,
        err:        *const OCIError,
        dy:         *const i32,
        hr:         *const i32,
        mm:         *const i32,
        ss:         *const i32,
        fsec:       *const i32,
        interval:   *const OCIInterval,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-665EFBF6-5032-4BD3-B7A3-1C35C2D5A6B7
    fn OCIIntervalGetYearMonth(
        hndl:       *const c_void,
        err:        *const OCIError,
        yr:         *const i32,
        mnth:       *const i32,
        interval:   *const OCIInterval,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-4DBA1745-E675-4774-99AB-DEE2A1FC3788
    fn OCIIntervalMultiply(
        hndl:       *const c_void,
        err:        *const OCIError,
        inter:      *const OCIInterval,
        nfactor:    *const OCINumber,
        result:     *mut OCIInterval,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-303A876B-E1EA-4AF8-8BD1-FC133C5F3F84
    fn OCIIntervalSetDaySecond(
        hndl:       *const c_void,
        err:        *const OCIError,
        dy:         i32,
        hr:         i32,
        mm:         i32,
        ss:         i32,
        fsec:       i32,
        result:     *mut OCIInterval,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-07D8A23E-58E2-420B-B4CA-EF37420F7549
    fn OCIIntervalSetYearMonth(
        hndl:       *const c_void,
        err:        *const OCIError,
        yr:         i32,
        mnth:       i32,
        result:     *mut OCIInterval,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-2D0465BC-B8EA-4F41-B200-587F49D0B2CB
    fn OCIIntervalSubtract(
        hndl:       *const c_void,
        err:        *const OCIError,
        minuend:    *const OCIInterval,
        subtrahend: *const OCIInterval,
        result:     *mut OCIInterval,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-7B403C69-F618-42A6-94F3-41FB17F7F0AD
    fn OCIIntervalToNumber(
        hndl:       *const c_void,
        err:        *const OCIError,
        interval:   *const OCIInterval,
        number:     *const OCINumber,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-DC306081-C4C3-48F5-818D-4C02DD945192
    fn OCIIntervalToText(
        hndl:       *const c_void,
        err:        *const OCIError,
        interval:   *const OCIInterval,
        lfprec:     u8,
        fsprec:     u8,
        buffer:     *const u8,
        buflen:     size_t,
        resultlen:  *const size_t,
    ) -> i32;
}

extern "C" {
    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-61FB0D0F-6EA7-45DD-AF40-310D86FB8BAE
    fn OCINumberAbs(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-F3DC6DF6-9110-4BAC-AB97-DC604CA04BCD
    fn OCINumberAdd(
        err:      *const OCIError,
        number1:  *const OCINumber,
        number2:  *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-E7A8B43C-F8B0-4009-A770-94CD7E13EE75
    fn OCINumberArcCos(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-3956D4AC-62E5-41FD-BA48-2DA89E207259
    fn OCINumberArcSin(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-43E9438C-AA74-4392-889D-171F411EBBE2
    fn OCINumberArcTan(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-62C977EF-DB7E-457F-847A-BF0D46E36CD5
    fn OCINumberArcTan2(
        err:      *const OCIError,
        number1:  *const OCINumber,
        number2:  *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-0C78F351-550E-48F0-8D4C-A9AD8A28DA66
    fn OCINumberAssign(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-48974097-47D4-4757-A627-4E09406AAFD5
    fn OCINumberCeil(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-554A4409-946B-47E9-B239-4140B8F3D1F9
    fn OCINumberCmp(
        err:      *const OCIError,
        number1:  *const OCINumber,
        number2:  *const OCINumber,
        result:   *const i32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-150F3245-ECFC-4352-AA73-AAF29BC6A74C
    fn OCINumberCos(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-370FD18E-47D3-4110-817C-658A2F059361
    fn OCINumberDec(
        err:      *const OCIError,
        number:   *const OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-36A6C0EA-85A4-44EE-8489-FB7DB4257513
    fn OCINumberDiv(
        err:      *const OCIError,
        number1:  *const OCINumber,
        number2:  *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-B56F44FC-158A-420B-830E-FB82894A62C8
    fn OCINumberExp(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-CF35CBDF-DC88-4E86-B586-0EEFD35C0458
    fn OCINumberFloor(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-E8940E06-F4EF-4172-AEE5-AF8E4F6B3AEE
    // fn OCINumberFromInt(
    //     err:      *const OCIError,
    //     inum:     *const c_void,
    //     inum_len: u32,
    //     sign_typ: u32,
    //     number:   *const OCINumber
    // ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-EC8E2C9E-BCD2-4D1E-A052-3E657B552461
    fn OCINumberFromReal(
        err:      *const OCIError,
        rnum:     *const c_void,
        rnum_len: u32,              // sizeof(float | double | long double)
        number:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-F2E458B5-BECC-482E-9223-B92BC696CA17
    fn OCINumberFromText(
        err:      *const OCIError,
        txt:      *const u8,
        txt_len:  u32,
        fmt:      *const u8,
        fmt_len:  u32,
        nls_par:  *const u8,
        nls_len:  u32,
        number:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-08CCC2C4-5AB3-45EB-9E0D-28186A2AA234
    fn OCINumberHypCos(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-E7391F43-2DFB-4146-9AB7-816D009F31E5
    fn OCINumberHypSin(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-4254930A-DCDC-4590-8710-AC46EC4F3473
    fn OCINumberHypTan(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-A3B07A3A-7E18-421E-9085-BE4B3E742C83
    fn OCINumberInc(
        err:      *const OCIError,
        number:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-D5CF4199-D6D2-4D31-A914-FB74F5BC5412
    fn OCINumberIntPower(
        err:      *const OCIError,
        base:     *const OCINumber,
        exp:      i32,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-F1254BAD-7236-4728-A9DA-B8701D8BAA14
    fn OCINumberIsInt(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *const i32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-40F344FC-3ED0-4893-AFB1-0853D02D79C9
    fn OCINumberIsZero(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *const i32          // set to TRUE if equal to zero else FALSE
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-C1E572F2-F68D-4AF4-831A-2095BFEDDBC3
    fn OCINumberLn(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-561769B0-B559-44AA-8012-985EA7ADFB47
    fn OCINumberLog(
        err:      *const OCIError,
        base:     *const OCINumber,
        number:   *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-B5DAB7F2-6AC6-4693-8F04-8C13F9538CE9
    fn OCINumberMod(
        err:      *const OCIError,
        number1:  *const OCINumber,
        number2:  *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-8AAAC840-3776-4283-9DC5-5764CAC2359A
    fn OCINumberMul(
        err:      *const OCIError,
        number1:  *const OCINumber,
        number2:  *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-8810FFCB-51E7-4890-B551-61BE85624764
    fn OCINumberNeg(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-E755AD46-4285-4DAF-B2A5-886333A2395D
    fn OCINumberPower(
        err:      *const OCIError,
        base:     *const OCINumber,
        exp:      *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-BE4B0E6D-75B6-4256-A355-9DFAFEC477C9
    fn OCINumberPrec(
        err:      *const OCIError,
        number:   *const OCINumber,
        num_dig:  i32,              // number of decimal digits desired in the result
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-F3B89623-73E3-428F-A677-5526AC5F4622
    fn OCINumberRound(
        err:      *const OCIError,
        number:   *const OCINumber,
        num_dig:  i32,              // number of decimal digits to the right of the decimal point to round to. Negative values are allowed.
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-FA067559-D0F7-426D-940A-1D24F4C60C70
    pub(crate) fn OCINumberSetPi(
        err:      *const OCIError,
        result:   *mut OCINumber
    );

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-8152D558-61D9-49F4-9113-DA1455BB5C72
    pub(crate) fn OCINumberSetZero(
        err:      *const OCIError,
        result:   *mut OCINumber
    );

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-EA7D0DA0-A154-4A87-8215-E5B5A7D091E3
    fn OCINumberShift(
        err:      *const OCIError,
        number:   *const OCINumber,
        num_dec:  i32,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-A535F6F1-0689-4FE1-9C07-C8D341582622
    fn OCINumberSign(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *const i32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-65293408-5AF2-4A0C-9C51-82C1C929EE54
    fn OCINumberSin(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-9D68D274-B18C-43F4-AB37-BB99C9062B3E
    fn OCINumberSqrt(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-192725C3-8F5C-4D0A-848E-4EE9690F4A4E
    fn OCINumberSub(
        err:      *const OCIError,
        number1:  *const OCINumber,
        number2:  *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-1EB45341-6026-47AD-A2EF-D92A20A46ECF
    fn OCINumberTan(
        err:      *const OCIError,
        number:   *const OCINumber,
        result:   *mut OCINumber
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-067F138E-E689-4922-9ED7-4A7B0E46447E
    // fn OCINumberToInt(
    //     err:      *const OCIError,
    //     number:   *const OCINumber,
    //     res_len:  u32,
    //     sign_typ: u32,
    //     result:   *const c_void
    // ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-76C4BC1E-EC64-4CF6-82A4-94D5DC242649
    fn OCINumberToReal(
        err:      *const OCIError,
        number:   *const OCINumber,
        res_len:  u32,              // sizeof( float | double | long double)
        result:   *const c_void
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-A850D4E3-2B7B-4DFE-A3E9-618515DACA9E
    // fn OCINumberToRealArray(
    //     err:      *const OCIError,
    //     numbers:  &*const OCINumber,
    //     elems:    u32,
    //     res_len:  u32,              // sizeof( float | double | long double)
    //     result:   *const c_void
    // ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-129A5433-6927-43B7-A10F-5FE6AA354232
    fn OCINumberToText(
        err:      *const OCIError,
        number:   *const OCINumber,
        fmt:      *const u8,
        fmt_len:  u32,
        nls_par:  *const u8,
        nls_len:  u32,
        buf_size: *const u32,
        buf:      *const u8
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-NUMBER-functions.html#GUID-FD8D2A9A-222B-4A0E-B4E3-99588FF19BCA
    fn OCINumberTrunc(
        err:      *const OCIError,
        number:   *const OCINumber,
        num_dig:  i32,
        result:   *mut OCINumber
    ) -> i32;
}

extern "C" {
    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-raw-functions.html#GUID-4856A258-8883-4470-9881-51F27FA050F6
    fn OCIRawAllocSize(
        env:        *const OCIEnv,
        err:        *const OCIError,
        raw:        *const OCIRaw,
        size:       *const u32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-raw-functions.html#GUID-3BB4239F-8579-4CC1-B76F-0786BDBAEF9A
    fn OCIRawAssignBytes(
        env:        *const OCIEnv,
        err:        *const OCIError,
        rhs:        *const u8,
        rhs_len:    u32,
        lhs:        *mut *mut OCIRaw
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-raw-functions.html#GUID-27DBFBE0-4511-4B34-8476-B9AC720E3F51
    fn OCIRawAssignRaw(
        env:        *const OCIEnv,
        err:        *const OCIError,
        rhs:        *const OCIRaw,
        lhs:        *mut *mut OCIRaw
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-raw-functions.html#GUID-B05C44C5-7168-438B-AC2A-BD3AD309AAEA
    pub(crate) fn OCIRawPtr(
        env:        *const OCIEnv,
        raw:        *const OCIRaw
    ) -> *const u8;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-raw-functions.html#GUID-7D757B00-DF25-4F61-A3DF-8C72F18FDC9E
    pub(crate) fn OCIRawResize(
        env:        *const OCIEnv,
        err:        *const OCIError,
        size:       u32,
        raw:        *mut *mut OCIRaw
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-raw-functions.html#GUID-D74E75FA-5985-4DDC-BC25-430B415B8837
    pub(crate) fn OCIRawSize(
        env:        *const OCIEnv,
        raw:        *const OCIRaw
    ) -> u32;
}

extern "C" {
    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-3B02C8CC-F35C-422F-B35C-47765C998E57
    fn OCIDateTimeAssign (
        hndl:       *const c_void,
        err:        *const OCIError,
        from:       *const OCIDateTime,
        to:         *mut OCIDateTime
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-5C2A63E3-85EC-4346-A636-33B9B4CCBA41
    // fn OCIDateTimeCheck (
    //     hndl:       *const c_void,
    //     err:        *const OCIError,
    //     date:       *const OCIDateTime,
    //     result:     *const u32
    // ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-5FFD4B08-30E1-461E-8E55-940787D6D8EC
    fn OCIDateTimeCompare (
        hndl:       *const c_void,
        err:        *const OCIError,
        date1:      *const OCIDateTime,
        date2:      *const OCIDateTime,
        result:     *const i32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-FC053036-BE93-42D7-A82C-4DDB6843E167
    fn OCIDateTimeConstruct (
        hndl:       *const c_void,
        err:        *const OCIError,
        datetime:   *mut OCIDateTime,
        year:       i16,
        month:      u8,
        day:        u8,
        hour:       u8,
        min:        u8,
        sec:        u8,
        fsec:       u32,
        timezone:   *const u8,
        tz_len:     size_t
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-744793B2-CD2F-47AC-825A-6FF5BEE12BAB
    fn OCIDateTimeConvert (
        hndl:       *const c_void,
        err:        *const OCIError,
        indate:     *const OCIDateTime,
        outdate:    *mut OCIDateTime
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-16189076-75E9-4B46-B418-89CD8DDB42EA
    // fn OCIDateTimeFromArray(
    //     hndl:       *const c_void,
    //     err:        *const OCIError,
    //     inarray:    *const u8,
    //     len:        u32,
    //     dt_type:    u8,
    //     datetime:   *const OCIDateTime,
    //     reftz:      *const OCIInterval,
    //     fsprec:     u8
    // ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-1A453A79-4EEF-462D-B4B3-45820F9EEA4C
    fn OCIDateTimeFromText(
        hndl:       *const c_void,
        err:        *const OCIError,
        date_str:   *const u8,
        dstr_length: size_t,
        fmt:        *const u8,
        fmt_length: u8,
        lang_name:  *const u8,
        lang_length: size_t,
        datetime:   *mut OCIDateTime,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-FE6F9482-913D-43FD-BE5A-FCD9FA7B83AD
    fn OCIDateTimeGetDate(
        hndl:       *const c_void,
        err:        *const OCIError,
        datetime:   *const OCIDateTime,
        year:       *const i16,
        month:      *const u8,
        day:        *const u8,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-D935ABA2-DEEA-4ABA-AA9C-C27E3E5AC1FD
    fn OCIDateTimeGetTime(
        hndl:       *const c_void,
        err:        *const OCIError,
        datetime:   *const OCIDateTime,
        hour:       *const u8,
        min:        *const u8,
        sec:        *const u8,
        fsec:       *const u32,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-489C51F6-43DB-43DB-980F-2A42AFAFB332
    fn OCIDateTimeGetTimeZoneName(
        hndl:       *const c_void,
        err:        *const OCIError,
        datetime:   *const OCIDateTime,
        buf:        *const u8,
        buflen:     *const u32,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-B8DA860B-FD7D-481B-8347-156969B6EE04
    fn OCIDateTimeGetTimeZoneOffset(
        hndl:       *const c_void,
        err:        *const OCIError,
        datetime:   *const OCIDateTime,
        hour:       *const i8,
        min:        *const i8,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-810C6FB3-9B81-4A7C-9B5B-5D2D93B781FA
    fn OCIDateTimeIntervalAdd(
        hndl:       *const c_void,
        err:        *const OCIError,
        datetime:   *const OCIDateTime,
        inter:      *const OCIInterval,
        result:     *mut OCIDateTime,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-DEDBFEF5-52DD-4036-93FE-C21B6ED4E8A5
    fn OCIDateTimeIntervalSub(
        hndl:       *const c_void,
        err:        *const OCIError,
        datetime:   *const OCIDateTime,
        inter:      *const OCIInterval,
        result:     *mut OCIDateTime,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-BD2F6432-81FF-4CD6-9C3D-85E401894528
    fn OCIDateTimeSubtract(
        hndl:       *const c_void,
        err:        *const OCIError,
        indate1:    *const OCIDateTime,
        indate2:    *const OCIDateTime,
        result:     *mut OCIInterval,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-086776F8-1153-417D-ABC6-A864A2A62788
    fn OCIDateTimeSysTimeStamp(
        hndl:       *const c_void,
        err:        *const OCIError,
        sys_date:   *mut OCIDateTime,
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-DCA1CF9E-AF92-42E1-B784-8BFC0C9FF8BE
    // fn OCIDateTimeToArray(
    //     hndl:       *const c_void,
    //     err:        *const OCIError,
    //     datetime:   *const OCIDateTime,
    //     reftz:      *const OCIInterval,
    //     outarray:   *const u8,
    //     len:        *const u32,
    //     fsprec:     u8
    // ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-date-datetime-and-interval-functions.html#GUID-828401C8-8E88-4C53-A66A-24901CCF93C6
    fn OCIDateTimeToText(
        hndl:       *const c_void,
        err:        *const OCIError,
        date:       *const OCIDateTime,
        fmt:        *const u8,
        fmt_length: u8,
        fsprec:     u8,
        lang_name:  *const u8,
        lang_length: size_t,
        buf_size:   *const u32,
        buf:        *const u8,
    ) -> i32;
}

extern "C" {
    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-string-functions.html#GUID-3F336010-D8C8-4B50-89CB-ABCCA98905DA
    fn OCIStringAllocSize(
        env:        *const OCIEnv,
        err:        *const OCIError,
        txt:        *const OCIString,
        size:       *const u32
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-string-functions.html#GUID-58BC140A-900C-4409-B3D2-C2DC8FB643FF
    fn OCIStringAssign(
        env:        *const OCIEnv,
        err:        *const OCIError,
        rhs:        *const OCIString,
        lhs:        *mut *mut OCIString
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-string-functions.html#GUID-96E8375B-9017-4E06-BF85-09C12DF286F4
    fn OCIStringAssignText(
        env:        *const OCIEnv,
        err:        *const OCIError,
        rhs:        *const u8,
        rhs_len:    u32,
        lhs:        *mut *mut OCIString
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-string-functions.html#GUID-0E1302F7-A32C-46F1-93D7-FB33CF60C24F
    pub(crate) fn OCIStringPtr(
        env:        *const OCIEnv,
        txt:        *const OCIString
    ) -> *const u8;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-string-functions.html#GUID-CA52A8A4-08BA-4F08-A4A3-79F841F6AE9E
    pub(crate) fn OCIStringResize(
        env:        *const OCIEnv,
        err:        *const OCIError,
        size:       u32,
        txt:        *mut *mut OCIString
    ) -> i32;

    // https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/oci-string-functions.html#GUID-DBDAB2D9-4E78-4752-85B6-55D30CA6AF30
    pub(crate) fn OCIStringSize(
        env:        *const OCIEnv,
        txt:        *const OCIString
    ) -> u32;
}

// ================================================================================================

/**
Returns the 5 digit tuple with the Oracle database version number of the client library at run time.

The 5 digits of the version number are:
 - feature release,
 - release update,
 - release update revision,
 - release update increment,
 - extension.
*/
pub fn client_version() -> (i32, i32, i32, i32, i32) {
    let mut release  = std::mem::MaybeUninit::<i32>::uninit();
    let mut update   = std::mem::MaybeUninit::<i32>::uninit();
    let mut revision = std::mem::MaybeUninit::<i32>::uninit();
    let mut incr     = std::mem::MaybeUninit::<i32>::uninit();
    let mut ext      = std::mem::MaybeUninit::<i32>::uninit();
    unsafe {
        OCIClientVersion(
            release.as_mut_ptr(),
            update.as_mut_ptr(),
            revision.as_mut_ptr(),
            incr.as_mut_ptr(),
            ext.as_mut_ptr(),
        );
    }
    unsafe { (
        release.assume_init(),
        update.assume_init(),
        revision.assume_init(),
        incr.assume_init(),
        ext.assume_init(),
    ) }
}

pub(crate) fn oci_connection_pool_destroy(pool: &OCICPool, err: &OCIError) -> i32 {
    unsafe { OCIConnectionPoolDestroy(pool, err, OCI_DEFAULT) }
}

pub(crate) fn oci_session_pool_destroy(pool: &OCISPool, err: &OCIError) -> i32 {
    unsafe { OCISessionPoolDestroy(pool, err, OCI_DEFAULT) }
}

pub(crate) fn oci_stmt_release(stmt: &OCIStmt, err: &OCIError) -> i32 {
    unsafe { OCIStmtRelease(stmt, err, std::ptr::null(), 0, OCI_DEFAULT) }
}

pub(crate) fn oci_trans_rollback(svchp: &OCISvcCtx, errhp: &OCIError) -> i32 {
    unsafe { OCITransRollback(svchp, errhp, OCI_DEFAULT) }
}

// ================================================================================================

macro_rules! ok_or_env_err {
    ( |$env:ident| $stmt:stmt ) => {{
        let res = unsafe { $stmt };
        if res < 0 {
            Err(Error::env($env, res))
        } else {
            Ok(())
        }
    }};
}

pub(crate) fn descriptor_alloc<T>(parenth: &OCIEnv, descpp: *mut *mut T, desctype: u32) -> Result<()>
where T: OCIStruct
{
    ok_or_env_err!(|parenth|
        OCIDescriptorAlloc(parenth, descpp as _, desctype, 0, std::ptr::null())
    )
}

pub(crate) fn handle_alloc<T: HandleType>(
    parenth: &OCIEnv,
    hndlpp:  *mut *mut T,
    hndltype: u32,
) -> Result<()> {
    ok_or_env_err!(|parenth|
        OCIHandleAlloc(parenth, hndlpp as _, hndltype, 0, std::ptr::null())
    )
}

macro_rules! ok_or_oci_err {
    ( |$err:ident| $stmt:stmt ) => {{
        let res = unsafe { $stmt };
        if res < 0 {
            Err(Error::oci($err, res))
        } else {
            Ok(())
        }
    }};
    ( |$err:ident| $block:block ) => {{
        let res = unsafe { $block };
        if res < 0 {
            Err(Error::oci($err, res))
        } else {
            Ok(())
        }
    }};
}

pub(crate) fn attr_get<T>(
    trgthndlp:  &T,
    trghndltyp: u32,
    attributep: *mut c_void,
    sizep:      &mut u32,
    attrtype:   u32,
    errhp:      &OCIError
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCIAttrGet(trgthndlp as *const T as _, trghndltyp, attributep, sizep, attrtype, errhp)
    )
}

pub(crate) fn attr_set<T>(
    // Even though intuitively `trgthndlp` should be `&mut T` some of the handles that
    // use `attr_set` are behind `Arc`. To be pure we should use `Arc<RwLock>` for those.
    // However, that is entirely unnecessary as all those OCI handles already have
    // internal protection from access by multiple threads as OCIEnv is initialized as
    // OCI_THREADED. Thus, we can cheat a little by declaring handle pointer as `*const`.
    trgthndlp:  &T,
    trghndltyp: u32,
    attributep: *const c_void,
    size:       u32,
    attrtype:   u32,
    errhp:      &OCIError
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCIAttrSet(trgthndlp as *const T as _, trghndltyp, attributep, size, attrtype, errhp)
    )
}

pub(crate) fn param_get(
    hndlp:      &OCIStmt,
    htype:      u32,
    errhp:      &OCIError,
    descr:      *mut *mut OCIParam,
    pos:        u32
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCIParamGet(hndlp as *const OCIStmt as _, htype, errhp, descr as _, pos)
    )
}

pub(crate) fn session_get(
    envhp:      &OCIEnv,
    errhp:      &OCIError,
    svchp:      *mut *mut OCISvcCtx,
    authinfop:  &OCIAuthInfo,
    dbname:     *const u8,
    dbname_len: u32,
    mode:       u32
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCISessionGet(envhp, errhp, svchp, authinfop, dbname, dbname_len, std::ptr::null(), 0, std::ptr::null_mut(), std::ptr::null_mut(), std::ptr::null_mut(), mode)
    )
}

pub(crate) fn session_get_tagged(
    envhp:      &OCIEnv,
    errhp:      &OCIError,
    svchp:      *mut *mut OCISvcCtx,
    authinfop:  &OCIAuthInfo,
    dbname:     *const u8,
    dbname_len: u32,
    tag:        *const u8,
    taglen:     u32,
    rettag:     *mut *const u8,
    rettaglen:  *mut u32,
    found:      *mut u8,
    mode:       u32
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCISessionGet(envhp, errhp, svchp, authinfop, dbname, dbname_len, tag, taglen, rettag, rettaglen, found, mode)
    )
}

pub(crate) fn ping(
    svchp: &OCISvcCtx,
    errhp: &OCIError,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCIPing(svchp, errhp, OCI_DEFAULT)
    )
}


pub(crate) fn trans_commit(
    svchp: &OCISvcCtx,
    errhp: &OCIError,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCITransCommit(svchp, errhp, OCI_DEFAULT)
    )
}

pub(crate) fn trans_rollback(
    svchp: &OCISvcCtx,
    errhp: &OCIError,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCITransRollback(svchp, errhp, OCI_DEFAULT)
    )
}


pub(crate) fn connection_pool_create (
    envhp:          &OCIEnv,
    errhp:          &OCIError,
    cpoolhp:        &OCICPool,
    pool_name:      *mut *const u8,
    pool_name_len:  *mut u32,
    dblink:         *const u8,
    dblink_len:     u32,
    conn_min:       u32,
    conn_max:       u32,
    conn_incr:      u32,
    username:       *const u8,
    username_len:   u32,
    password:       *const u8,
    password_len:   u32,
    mode:           u32
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCIConnectionPoolCreate(envhp, errhp, cpoolhp, pool_name, pool_name_len, dblink, dblink_len, conn_min, conn_max, conn_incr, username, username_len, password, password_len, mode)
    )
}

pub(crate) fn session_pool_create (
    envhp:          &OCIEnv,
    errhp:          &OCIError,
    spoolhp:        &OCISPool,
    pool_name:      *mut *const u8,
    pool_name_len:  *mut u32,
    conn_str:       *const u8,
    conn_str_len:   u32,
    sess_min:       u32,
    sess_max:       u32,
    sess_incr:      u32,
    userid:         *const u8,
    userid_len:     u32,
    password:       *const u8,
    password_len:   u32,
    mode:           u32
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCISessionPoolCreate(envhp, errhp, spoolhp, pool_name, pool_name_len, conn_str, conn_str_len, sess_min, sess_max, sess_incr, userid, userid_len, password, password_len, mode)
    )
}

pub(crate) fn stmt_prepare(
    svchp:      &OCISvcCtx,
    stmthp:     *mut *mut OCIStmt,
    errhp:      &OCIError,
    stmttext:   *const u8,
    stmt_len:   u32,
    language:   u32,
    mode:       u32
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCIStmtPrepare2(svchp, stmthp, errhp, stmttext, stmt_len, std::ptr::null(), 0, language, mode)
    )
}

pub(crate) fn stmt_release(
    stmtp:      &OCIStmt,
    errhp:      &OCIError,
    key:        *const u8,
    keylen:     u32,
    mode:       u32
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCIStmtRelease(stmtp, errhp, key, keylen, mode)
    )
}

pub(crate) fn stmt_get_bind_info(
    stmtp:      &OCIStmt,
    errhp:      &OCIError,
    size:       u32,
    startloc:   u32,
    found:      *mut i32,
    bvnp:       *mut *mut u8,
    bvnl:       *mut u8,
    invp:       *mut *mut u8,
    invl:       *mut u8,
    dupl:       *mut u8,
    hndl:       *mut *mut OCIBind,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCIStmtGetBindInfo(stmtp, errhp, size, startloc, found, bvnp, bvnl, invp, invl, dupl, hndl)
    )
}

pub(crate) fn bind_by_pos(
    stmtp:      &OCIStmt,
    bindpp:     *mut *mut OCIBind,
    errhp:      &OCIError,
    position:   u32,
    valuep:     *mut c_void,
    value_sz:   i64,
    dty:        u16,
    indp:       *mut i16,
    alenp:      *mut u32,
    mode:       u32
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCIBindByPos2(stmtp, bindpp, errhp, position, valuep, value_sz, dty, indp, alenp, std::ptr::null_mut::<u16>(), 0, std::ptr::null_mut::<u32>(), mode)
    )
}

pub(crate) fn stmt_execute(
    svchp:      &OCISvcCtx,
    stmtp:      &OCIStmt,
    errhp:      &OCIError,
    iters:      u32,
    rowoff:     u32,
    mode:       u32
) -> Result<i32> {
    let res = unsafe {
        OCIStmtExecute(svchp, stmtp, errhp, iters, rowoff, std::ptr::null(), std::ptr::null(), mode)
    };
    match res {
        OCI_ERROR | OCI_INVALID_HANDLE => { Err(Error::oci(errhp, res)) },
        _ => { Ok(res) }
    }
}

pub(crate) fn stmt_fetch(
    stmtp:      &OCIStmt,
    errhp:      &OCIError,
    nrows:      u32,
    orient:     u16,
    offset:     i16,
    mode:       u32
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCIStmtFetch2(stmtp, errhp, nrows, orient, offset, mode)
    )
}

pub(crate) fn define_by_pos(
    stmtp:      &OCIStmt,
    defnpp:     *mut *mut OCIDefine,
    errhp:      &OCIError,
    position:   u32,
    valuep:     *mut c_void,
    value_sz:   i64,
    dty:        u16,
    indp:       *mut i16,
    rlenp:      *mut u32,
    rcodep:     *mut u16,
    mode:       u32
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCIDefineByPos2(stmtp, defnpp, errhp, position, valuep, value_sz, dty, indp, rlenp, rcodep, mode)
    )
}

pub(crate) fn rowid_to_char(
    desc:   &OCIRowid,
    text:   *mut u8,
    size:   *mut u16,
    errhp:  &OCIError,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCIRowidToChar(desc, text, size, errhp)
    )
}

pub(crate) fn lob_append(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    dst:        &OCILobLocator,
    src:        &OCILobLocator,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobAppend(svchp, errhp, dst, src)
    )
}

pub(crate) fn lob_char_set_form(
    envhp:      &OCIEnv,
    errhp:      &OCIError,
    src:        &OCILobLocator,
    csform:     *mut u8
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobCharSetForm(envhp, errhp, src, csform)
    )
}

pub(crate) fn lob_char_set_id(
    envhp:      &OCIEnv,
    errhp:      &OCIError,
    src:        &OCILobLocator,
    csid:       *mut u16
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobCharSetId(envhp, errhp, src, csid)
    )
}

pub(crate) fn lob_close(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    loc:        &OCILobLocator,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobClose(svchp, errhp, loc)
    )
}

pub(crate) fn lob_copy(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    dst:        &OCILobLocator,
    src:        &OCILobLocator,
    amount:     u64,
    dst_off:    u64,
    src_off:    u64,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobCopy2(svchp, errhp, dst, src, amount, dst_off, src_off)
    )
}

pub(crate) fn lob_create_temporary(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    loc:        &OCILobLocator,
    csid:       u16,
    csfrm:      u8,
    lob_type:   u8,
    cache:      u8,
    duration:   u16,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobCreateTemporary(svchp, errhp, loc, csid, csfrm, lob_type, cache, duration)
    )
}

pub(crate) fn lob_erase(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    loc:        &OCILobLocator,
    amount:     *mut u64,
    offset:     u64,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobErase2(svchp, errhp, loc, amount, offset)
    )
}

pub(crate) fn lob_file_close(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    filep:      &OCILobLocator,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobFileClose(svchp, errhp, filep)
    )
}

pub(crate) fn lob_file_exists(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    filep:      &OCILobLocator,
    flag:       *mut u8
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobFileExists(svchp, errhp, filep, flag)
    )
}

pub(crate) fn lob_file_get_name(
    envhp:      &OCIEnv,
    errhp:      &OCIError,
    loc:        &OCILobLocator,
    dir:        *mut u8,
    dir_len:    *mut u16,
    filename:   *mut u8,
    name_len:   *mut u16,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobFileGetName(envhp, errhp, loc, dir, dir_len, filename, name_len)
    )
}

pub(crate) fn lob_file_is_open(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    filep:      &OCILobLocator,
    flag:       *mut u8
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobFileIsOpen(svchp, errhp, filep, flag)
    )
}

pub(crate) fn lob_file_open(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    filep:      &OCILobLocator,
    mode:       u8
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobFileOpen(svchp, errhp, filep, mode)
    )
}

pub(crate) fn lob_file_set_name(
    envhp:      &OCIEnv,
    errhp:      &OCIError,
    filepp:     *const *mut OCIBFileLocator,
    dir:        *const u8,
    dir_len:    u16,
    filename:   *const u8,
    name_len:   u16,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobFileSetName(envhp, errhp, filepp as _, dir, dir_len, filename, name_len)
    )
}

pub(crate) fn lob_free_temporary(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    loc:        &OCILobLocator,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobFreeTemporary(svchp, errhp, loc)
    )
}

pub(crate) fn lob_get_chunk_size(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    loc:        &OCILobLocator,
    size:       *mut u32,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobGetChunkSize(svchp, errhp, loc, size)
    )
}

pub(crate) fn lob_get_content_type(
    envhp:      &OCIEnv,
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    loc:        &OCILobLocator,
    ctx_type:   *mut u8,
    len:        *mut u32,
    mode:       u32
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobGetContentType(envhp, svchp, errhp, loc, ctx_type, len, mode)
    )
}

pub(crate) fn lob_get_length(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    loc:        &OCILobLocator,
    len:        *mut u64,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobGetLength2(svchp, errhp, loc, len)
    )
}

pub(crate) fn lob_is_equal(
    envhp:      &OCIEnv,
    loc1:       &OCILobLocator,
    loc2:       &OCILobLocator,
    flag:       *mut u8,
) -> Result<()> {
    ok_or_env_err!(|envhp|
        OCILobIsEqual(envhp, loc1, loc2, flag)
    )
}

pub(crate) fn lob_is_open(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    loc:        &OCILobLocator,
    flag:       *mut u8,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobIsOpen(svchp, errhp, loc, flag)
    )
}

pub(crate) fn lob_is_temporary(
    envhp:      &OCIEnv,
    errhp:      &OCIError,
    loc:        &OCILobLocator,
    flag:       *mut u8,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobIsTemporary(envhp, errhp, loc, flag)
    )
}

pub(crate) fn lob_load_from_file(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    dst:        &OCILobLocator,
    src:        &OCILobLocator,
    amount:     u64,
    dst_off:    u64,
    src_off:    u64,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobLoadFromFile2(svchp, errhp, dst, src, amount, dst_off, src_off)
    )
}

pub(crate) fn lob_locator_assign(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    src:        &OCILobLocator,
    dst:        *mut *mut OCILobLocator,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobLocatorAssign(svchp, errhp, src, dst)
    )
}

pub(crate) fn lob_locator_is_init(
    envhp:      &OCIEnv,
    errhp:      &OCIError,
    src:        &OCILobLocator,
    flag:       *mut u8,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobLocatorIsInit(envhp, errhp, src, flag)
    )
}

pub(crate) fn lob_open(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    loc:        &OCILobLocator,
    mode:       u8,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobOpen(svchp, errhp, loc, mode)
    )
}

pub(crate) fn lob_read(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    loc:        &OCILobLocator,
    byte_cnt:   *mut u64,
    char_cnt:   *mut u64,
    offset:     u64,
    buf:        *mut u8,
    buf_len:    u64,
    piece:      u8,
    csid:       u16,
    csfrm:      u8,
) -> Result<i32> {
    let res = unsafe {
        OCILobRead2(svchp, errhp, loc, byte_cnt, char_cnt, offset, buf, buf_len, piece, std::ptr::null_mut::<c_void>(), std::ptr::null::<c_void>(), csid, csfrm)
    };
    if res < 0 {
        Err(Error::oci(errhp, res))
    } else {
        Ok(res)
    }
}

pub(crate) fn lob_read2(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    loc:        &OCILobLocator,
    byte_cnt:   *mut u64,
    char_cnt:   *mut u64,
    offset:     u64,
    buf:        *mut u8,
    buf_len:    u64,
    piece:      u8,
    csid:       u16,
    csfrm:      u8,
) -> i32 {
    unsafe {
        OCILobRead2(svchp, errhp, loc, byte_cnt, char_cnt, offset, buf, buf_len, piece, std::ptr::null_mut::<c_void>(), std::ptr::null::<c_void>(), csid, csfrm)
    }
}

pub(crate) fn lob_set_content_type(
    envhp:      &OCIEnv,
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    loc:        &OCILobLocator,
    ctype:      *const u8,
    len:        u32,
    mode:       u32,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobSetContentType(envhp, svchp, errhp, loc, ctype, len, mode)
    )
}

pub(crate) fn lob_trim(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    loc:        &OCILobLocator,
    len:        u64,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobTrim2(svchp, errhp, loc, len)
    )
}

pub(crate) fn lob_write(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    loc:        &OCILobLocator,
    byte_cnt:   *mut u64,
    char_cnt:   *mut u64,
    offset:     u64,
    buf:        *const u8,
    buf_len:    u64,
    piece:      u8,
    ctx:        *mut c_void,
    write_cb:   *const c_void,
    csid:       u16,
    csfrm:      u8,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobWrite2(svchp, errhp, loc, byte_cnt, char_cnt, offset, buf, buf_len, piece, ctx, write_cb, csid, csfrm)
    )
}

pub(crate) fn lob_write_append(
    svchp:      &OCISvcCtx,
    errhp:      &OCIError,
    loc:        &OCILobLocator,
    byte_cnt:   *mut u64,
    char_cnt:   *mut u64,
    buf:        *const u8,
    buf_len:    u64,
    piece:      u8,
    ctx:        *mut c_void,
    write_cb:   *const c_void,
    csid:       u16,
    csfrm:      u8,
) -> Result<()> {
    ok_or_oci_err!(|errhp|
        OCILobWriteAppend2(svchp, errhp, loc, byte_cnt, char_cnt, buf, buf_len, piece, ctx, write_cb, csid, csfrm)
    )
}

pub(crate) fn date_add_days(
    err:        &OCIError,
    date:       &OCIDate,
    num_days:   i32,
    result:     *mut OCIDate
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateAddDays(err, date, num_days, result)
    )
}

pub(crate) fn date_add_months(
    err:        &OCIError,
    date:       &OCIDate,
    num_months: i32,
    result:     *mut OCIDate
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateAddMonths(err, date, num_months, result)
    )
}

pub(crate) fn date_assign(
    err:        &OCIError,
    date:       &OCIDate,
    result:     *mut OCIDate,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateAssign(err, date, result)
    )
}

pub(crate) fn date_compare(
    err:        &OCIError,
    date1:      &OCIDate,
    date2:      &OCIDate,
    result:     *mut i32
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateCompare(err, date1, date2, result)
    )
}

pub(crate) fn date_days_between(
    err:        &OCIError,
    date1:      &OCIDate,
    date2:      &OCIDate,
    result:     *mut i32
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateDaysBetween(err, date1, date2, result)
    )
}

pub(crate) fn date_from_text(
    err:        &OCIError,
    txt:        *const u8,
    txt_len:    u32,
    fmt:        *const u8,
    fmt_len:    u8,
    result:     *mut OCIDate
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateFromText(err, txt, txt_len, fmt, fmt_len, std::ptr::null(), 0, result)
    )
}

pub(crate) fn date_last_day(
    err:        &OCIError,
    date:       &OCIDate,
    result:     *mut OCIDate
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateLastDay(err, date, result)
    )
}

pub(crate) fn date_next_day(
    err:        &OCIError,
    date:       &OCIDate,
    day:        *const u8,
    day_len:    u32,
    result:     *mut OCIDate
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateNextDay(err, date, day, day_len, result)
    )
}

pub(crate) fn date_to_text(
    err:        &OCIError,
    date:       &OCIDate,
    fmt:        *const u8,
    fmt_len:    u8,
    buf_size:   *mut u32,
    buf:        *mut u8
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateToText(err, date, fmt, fmt_len, std::ptr::null(), 0, buf_size, buf)
    )
}

pub(crate) fn date_sys_date(
    err:        &OCIError,
    result:     *mut OCIDate
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateSysDate(err, result)
    )
}

pub(crate) fn interval_add(
    hndl:       *const c_void,
    err:        &OCIError,
    addend1:    &OCIInterval,
    addend2:    &OCIInterval,
    result:     &mut OCIInterval,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIIntervalAdd(hndl, err, addend1, addend2, result)
    )
}

pub(crate) fn interval_assign(
    hndl:       *const c_void,
    err:        &OCIError,
    inpinter:   &OCIInterval,
    outinter:   &mut OCIInterval,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIIntervalAssign(hndl, err, inpinter, outinter)
    )
}

pub(crate) fn interval_compare(
    hndl:       *const c_void,
    err:        &OCIError,
    inter1:     &OCIInterval,
    inter2:     &OCIInterval,
    result:     *mut i32,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIIntervalCompare(hndl, err, inter1, inter2, result)
    )
}

pub(crate) fn interval_divide(
    hndl:       *const c_void,
    err:        &OCIError,
    dividend:   &OCIInterval,
    divisor:    &OCINumber,
    result:     &mut OCIInterval,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIIntervalDivide(hndl, err, dividend, divisor, result)
    )
}

pub(crate) fn interval_from_number(
    hndl:       *const c_void,
    err:        &OCIError,
    interval:   &mut OCIInterval,
    number:     &OCINumber,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIIntervalFromNumber(hndl, err, interval, number)
    )
}

pub(crate) fn interval_from_text(
    hndl:       *const c_void,
    err:        &OCIError,
    inpstring:  *const u8,
    str_len:    size_t,
    result:     &mut OCIInterval,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIIntervalFromText(hndl, err, inpstring, str_len, result)
    )
}

pub(crate) fn interval_from_tz(
    hndl:       *const c_void,
    err:        &OCIError,
    inpstring:  *const u8,
    str_len:    size_t,
    result:     &mut OCIInterval,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIIntervalFromTZ(hndl, err, inpstring, str_len, result)
    )
}

pub(crate) fn interval_get_day_second(
    hndl:       *const c_void,
    err:        &OCIError,
    dy:         *mut i32,
    hr:         *mut i32,
    mm:         *mut i32,
    ss:         *mut i32,
    fsec:       *mut i32,
    interval:   &OCIInterval,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIIntervalGetDaySecond(hndl, err, dy, hr, mm, ss, fsec, interval)
    )
}

pub(crate) fn interval_get_year_month(
    hndl:       *const c_void,
    err:        &OCIError,
    yr:         *mut i32,
    mnth:       *mut i32,
    interval:   &OCIInterval,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIIntervalGetYearMonth(hndl, err, yr, mnth, interval)
    )
}

pub(crate) fn interval_multiply(
    hndl:       *const c_void,
    err:        &OCIError,
    inter:      &OCIInterval,
    nfactor:    &OCINumber,
    result:     &mut OCIInterval,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIIntervalMultiply(hndl, err, inter, nfactor, result)
    )
}

pub(crate) fn interval_set_day_second(
    hndl:       *const c_void,
    err:        &OCIError,
    dy:         i32,
    hr:         i32,
    mm:         i32,
    ss:         i32,
    fsec:       i32,
    result:     &mut OCIInterval,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIIntervalSetDaySecond(hndl, err, dy, hr, mm, ss, fsec, result)
    )
}

pub(crate) fn interval_set_year_month(
    hndl:       *const c_void,
    err:        &OCIError,
    yr:         i32,
    mnth:       i32,
    result:     &mut OCIInterval,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIIntervalSetYearMonth(hndl, err, yr, mnth, result)
    )
}

pub(crate) fn interval_subtract(
    hndl:       *const c_void,
    err:        &OCIError,
    minuend:    &OCIInterval,
    subtrahend: &OCIInterval,
    result:     &mut OCIInterval,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIIntervalSubtract(hndl, err, minuend, subtrahend, result)
    )
}

pub(crate) fn interval_to_number(
    hndl:       *const c_void,
    err:        &OCIError,
    interval:   &OCIInterval,
    number:     *mut OCINumber,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIIntervalToNumber(hndl, err, interval, number)
    )
}

pub(crate) fn interval_to_text(
    hndl:       *const c_void,
    err:        &OCIError,
    interval:   &OCIInterval,
    lfprec:     u8,
    fsprec:     u8,
    buffer:     *mut u8,
    buflen:     size_t,
    resultlen:  *mut size_t,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIIntervalToText(hndl, err, interval, lfprec, fsprec, buffer, buflen, resultlen)
    )
}

pub(crate) fn raw_alloc_size(
    env:        &OCIEnv,
    err:        &OCIError,
    raw:        *const OCIRaw,
    size:       *mut u32
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIRawAllocSize(env, err, raw, size)
    )
}

pub(crate) fn raw_assign_bytes(
    env:        &OCIEnv,
    err:        &OCIError,
    rhs:        *const u8,
    rhs_len:    u32,
    lhs:        *mut *mut OCIRaw
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIRawAssignBytes(env, err, rhs, rhs_len, lhs)
    )
}

pub(crate) fn raw_assign_raw(
    env:        &OCIEnv,
    err:        &OCIError,
    rhs:        &OCIRaw,
    lhs:        *mut *mut OCIRaw
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIRawAssignRaw(env, err, rhs, lhs)
    )
}

pub(crate) fn raw_resize(
    env:        &OCIEnv,
    err:        &OCIError,
    size:       u32,
    raw:        *mut *mut OCIRaw
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIRawResize(env, err, size, raw)
    )
}

pub(crate) fn string_alloc_size(
    env:        &OCIEnv,
    err:        &OCIError,
    txt:        *const OCIString,
    size:       *mut u32
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIStringAllocSize(env, err, txt, size)
    )
}

pub(crate) fn string_assign(
    env:        &OCIEnv,
    err:        &OCIError,
    rhs:        &OCIString,
    lhs:        *mut *mut OCIString
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIStringAssign(env, err, rhs, lhs)
    )
}

pub(crate) fn string_assign_text(
    env:        &OCIEnv,
    err:        &OCIError,
    rhs:        *const u8,
    rhs_len:    u32,
    lhs:        *mut *mut OCIString
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIStringAssignText(env, err, rhs, rhs_len, lhs)
    )
}

pub(crate) fn string_resize(
    env:        &OCIEnv,
    err:        &OCIError,
    size:       u32,
    txt:        *mut *mut OCIString
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIStringResize(env, err, size, txt)
    )
}

pub(crate) fn date_time_assign (
    hndl:       *const c_void,
    err:        &OCIError,
    from:       &OCIDateTime,
    to:         *mut OCIDateTime
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateTimeAssign(hndl, err, from, to)
    )
}

pub(crate) fn date_time_compare (
    hndl:       *const c_void,
    err:        &OCIError,
    date1:      &OCIDateTime,
    date2:      &OCIDateTime,
    result:     *mut i32
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateTimeCompare(hndl, err, date1, date2, result)
    )
}

pub(crate) fn date_time_construct (
    hndl:       *const c_void,
    err:        &OCIError,
    datetime:   &mut OCIDateTime,
    year:       i16,
    month:      u8,
    day:        u8,
    hour:       u8,
    min:        u8,
    sec:        u8,
    fsec:       u32,
    timezone:   *const u8,
    tz_len:     size_t
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateTimeConstruct(hndl, err, datetime, year, month, day, hour, min, sec, fsec, timezone, tz_len)
    )
}

pub(crate) fn date_time_convert (
    hndl:       *const c_void,
    err:        &OCIError,
    indate:     &OCIDateTime,
    outdate:    &mut OCIDateTime
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateTimeConvert(hndl, err, indate, outdate)
    )
}

pub(crate) fn date_time_from_text(
    hndl:       *const c_void,
    err:        &OCIError,
    date_str:   *const u8,
    dstr_length: size_t,
    fmt:        *const u8,
    fmt_length: u8,
    lang_name:  *const u8,
    lang_length: size_t,
    datetime:   &mut OCIDateTime,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateTimeFromText(hndl, err, date_str, dstr_length, fmt, fmt_length, lang_name, lang_length, datetime)
    )
}

pub(crate) fn date_time_get_date(
    hndl:       *const c_void,
    err:        &OCIError,
    datetime:   &OCIDateTime,
    year:       *mut i16,
    month:      *mut u8,
    day:        *mut u8,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateTimeGetDate(hndl, err, datetime, year, month, day)
    )
}

pub(crate) fn date_time_get_time(
    hndl:       *const c_void,
    err:        &OCIError,
    datetime:   &OCIDateTime,
    hour:       *mut u8,
    min:        *mut u8,
    sec:        *mut u8,
    fsec:       *mut u32,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateTimeGetTime(hndl, err, datetime, hour, min, sec, fsec)
    )
}

pub(crate) fn date_time_get_time_zone_name(
    hndl:       *const c_void,
    err:        &OCIError,
    datetime:   &OCIDateTime,
    buf:        *mut u8,
    buflen:     *mut u32,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateTimeGetTimeZoneName(hndl, err, datetime, buf, buflen)
    )
}

pub(crate) fn date_time_get_time_zone_offset(
    hndl:       *const c_void,
    err:        &OCIError,
    datetime:   &OCIDateTime,
    hour:       *mut i8,
    min:        *mut i8,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateTimeGetTimeZoneOffset(hndl, err, datetime, hour, min)
    )
}

pub(crate) fn date_time_interval_add(
    hndl:       *const c_void,
    err:        &OCIError,
    datetime:   &OCIDateTime,
    inter:      &OCIInterval,
    result:     &mut OCIDateTime,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateTimeIntervalAdd(hndl, err, datetime, inter, result)
    )
}

pub(crate) fn date_time_interval_sub(
    hndl:       *const c_void,
    err:        &OCIError,
    datetime:   &OCIDateTime,
    inter:      &OCIInterval,
    result:     &mut OCIDateTime,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateTimeIntervalSub(hndl, err, datetime, inter, result)
    )
}

pub(crate) fn date_time_subtract(
    hndl:       *const c_void,
    err:        &OCIError,
    indate1:    &OCIDateTime,
    indate2:    &OCIDateTime,
    result:     &mut OCIInterval,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateTimeSubtract(hndl, err, indate1, indate2, result)
    )
}

pub(crate) fn date_time_sys_time_stamp(
    hndl:       *const c_void,
    err:        &OCIError,
    sys_date:   &mut OCIDateTime,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateTimeSysTimeStamp(hndl, err, sys_date)
    )
}

pub(crate) fn date_time_to_text(
    hndl:       *const c_void,
    err:        &OCIError,
    date:       &OCIDateTime,
    fmt:        *const u8,
    fmt_length: u8,
    fsprec:     u8,
    buf_size:   *mut u32,
    buf:        *mut u8,
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCIDateTimeToText(hndl, err, date, fmt, fmt_length, fsprec, std::ptr::null(), 0, buf_size, buf)
    )
}

pub(crate) fn number_abs(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberAbs(err, number, result)
    )
}

pub(crate) fn number_add(
    err:      &OCIError,
    number1:  &OCINumber,
    number2:  &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberAdd(err, number1, number2, result)
    )
}

pub(crate) fn number_arc_cos(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberArcCos(err, number, result)
    )
}

pub(crate) fn number_arc_sin(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberArcSin(err, number, result)
    )
}

pub(crate) fn number_arc_tan(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberArcTan(err, number, result)
    )
}

pub(crate) fn number_arc_tan2(
    err:      &OCIError,
    number1:  &OCINumber,
    number2:  &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberArcTan2(err, number1, number2, result)
    )
}

pub(crate) fn number_assign(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberAssign(err, number, result)
    )
}

pub(crate) fn number_ceil(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberCeil(err, number, result)
    )
}

pub(crate) fn number_cmp(
    err:      &OCIError,
    number1:  &OCINumber,
    number2:  &OCINumber,
    result:   *mut i32
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberCmp(err, number1, number2, result)
    )
}

pub(crate) fn number_cos(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberCos(err, number, result)
    )
}

pub(crate) fn number_dec(
    err:      &OCIError,
    number:   &OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberDec(err, number)
    )
}

pub(crate) fn number_div(
    err:      &OCIError,
    number1:  &OCINumber,
    number2:  &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberDiv(err, number1, number2, result)
    )
}

pub(crate) fn number_exp(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberExp(err, number, result)
    )
}

pub(crate) fn number_floor(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberFloor(err, number, result)
    )
}

pub(crate) fn number_from_real(
    err:      &OCIError,
    rnum:     *const c_void,
    rnum_len: u32,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberFromReal(err, rnum, rnum_len, result)
    )
}

pub(crate) fn number_from_text(
    err:      &OCIError,
    txt:      *const u8,
    txt_len:  u32,
    fmt:      *const u8,
    fmt_len:  u32,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberFromText(err, txt, txt_len, fmt, fmt_len, std::ptr::null(), 0, result)
    )
}

pub(crate) fn number_hyp_cos(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberHypCos(err, number, result)
    )
}

pub(crate) fn number_hyp_sin(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberHypSin(err, number, result)
    )
}

pub(crate) fn number_hyp_tan(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberHypTan(err, number, result)
    )
}

pub(crate) fn number_inc(
    err:      &OCIError,
    number:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberInc(err, number)
    )
}

pub(crate) fn number_int_power(
    err:      &OCIError,
    base:     &OCINumber,
    exp:      i32,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberIntPower(err, base, exp, result)
    )
}

pub(crate) fn number_is_int(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut i32
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberIsInt(err, number, result)
    )
}

pub(crate) fn number_is_zero(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut i32
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberIsZero(err, number, result)
    )
}

pub(crate) fn number_ln(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberLn(err, number, result)
    )
}

pub(crate) fn number_log(
    err:      &OCIError,
    base:     &OCINumber,
    number:   &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberLog(err, base, number, result)
    )
}

pub(crate) fn number_mod(
    err:      &OCIError,
    number1:  &OCINumber,
    number2:  &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberMod(err, number1, number2, result)
    )
}

pub(crate) fn number_mul(
    err:      &OCIError,
    number1:  &OCINumber,
    number2:  &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberMul(err, number1, number2, result)
    )
}

pub(crate) fn number_neg(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberNeg(err, number, result)
    )
}

pub(crate) fn number_power(
    err:      &OCIError,
    base:     &OCINumber,
    exp:      &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberPower(err, base, exp, result)
    )
}

pub(crate) fn number_prec(
    err:      &OCIError,
    number:   &OCINumber,
    num_dig:  i32,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberPrec(err, number, num_dig, result)
    )
}

pub(crate) fn number_round(
    err:      &OCIError,
    number:   &OCINumber,
    num_dig:  i32,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberRound(err, number, num_dig, result)
    )
}

pub(crate) fn number_shift(
    err:      &OCIError,
    number:   &OCINumber,
    num_dec:  i32,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberShift(err, number, num_dec, result)
    )
}

pub(crate) fn number_sign(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut i32
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberSign(err, number, result)
    )
}

pub(crate) fn number_sin(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberSin(err, number, result)
    )
}

pub(crate) fn number_sqrt(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberSqrt(err, number, result)
    )
}

pub(crate) fn number_sub(
    err:      &OCIError,
    number1:  &OCINumber,
    number2:  &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberSub(err, number1, number2, result)
    )
}

pub(crate) fn number_tan(
    err:      &OCIError,
    number:   &OCINumber,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberTan(err, number, result)
    )
}

pub(crate) fn number_to_real(
    err:      &OCIError,
    number:   &OCINumber,
    res_len:  u32,
    result:   *mut c_void
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberToReal(err, number, res_len, result)
    )
}

pub(crate) fn number_to_text(
    err:      &OCIError,
    number:   &OCINumber,
    fmt:      *const u8,
    fmt_len:  u32,
    buf_size: *mut u32,
    buf:      *mut u8
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberToText(err, number, fmt, fmt_len, std::ptr::null(), 0, buf_size, buf)
    )
}

pub(crate) fn number_trunc(
    err:      &OCIError,
    number:   &OCINumber,
    num_dig:  i32,
    result:   *mut OCINumber
) -> Result<()> {
    ok_or_oci_err!(|err|
        OCINumberTrunc(err, number, num_dig, result)
    )
}

// The End.
// `oci.rs` is used as an input in some CLOB tests (thus far it is the largest file).
// The following random supplemental symbols are added to make it not pure ASCII and
// ensure that byte vs char counts are not the same):
// 🤸🥀🥂🥃🥅🥇🥕🥝🥞🥡🥤🥥🥨🧤🧦🧨🧪🧬🧭🧮🧯🧰🧲🧵