Menu

[r8314]: / trunk / src / plain / ZPlainDbLibDriver.pas  Maximize  Restore  History

Download this file

3506 lines (3228 with data), 148.7 kB

   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
{*********************************************************}
{ }
{ Zeos Database Objects }
{ Delphi plain driver interface to DBLibrary }
{ }
{ Originally written by Janos Fegyverneki }
{ FreeTDS supportd by Bogdan Dragulin }
{ }
{*********************************************************}
{@********************************************************}
{ Copyright (c) 1999-2020 Zeos Development Group }
{ }
{ License Agreement: }
{ }
{ This library is distributed in the hope that it will be }
{ useful, but WITHOUT ANY WARRANTY; without even the }
{ implied warranty of MERCHANTABILITY or FITNESS FOR }
{ A PARTICULAR PURPOSE. See the GNU Lesser General }
{ Public License for more details. }
{ }
{ The source code of the ZEOS Libraries and packages are }
{ distributed under the Library GNU General Public }
{ License (see the file COPYING / COPYING.ZEOS) }
{ with the following modification: }
{ As a special exception, the copyright holders of this }
{ library give you permission to link this library with }
{ independent modules to produce an executable, }
{ regardless of the license terms of these independent }
{ modules, and to copy and distribute the resulting }
{ executable under terms of your choice, provided that }
{ you also meet, for each linked independent module, }
{ the terms and conditions of the license of that module. }
{ An independent module is a module which is not derived }
{ from or based on this library. If you modify this }
{ library, you may extend this exception to your version }
{ of the library, but you are not obligated to do so. }
{ If you do not wish to do so, delete this exception }
{ statement from your version. }
{ }
{ }
{ The project web site is located on: }
{ https://zeoslib.sourceforge.io/ (FORUM) }
{ http://sourceforge.net/p/zeoslib/tickets/ (BUGTRACKER)}
{ svn://svn.code.sf.net/p/zeoslib/code-0/trunk (SVN) }
{ }
{ http://www.sourceforge.net/projects/zeoslib. }
{ }
{ }
{ Zeos Development Group. }
{********************************************************@}
unit ZPlainDbLibDriver;
interface
{$I ZPlain.inc}
{$IFNDEF ZEOS_DISABLE_DBLIB}
uses Classes, {$IFDEF FPC}syncobjs{$ELSE}SyncObjs{$ENDIF},
ZCompatibility, ZPlainDriver, ZClasses;
{***************** Plain API Constants definition ****************}
const
{ General #define }
TIMEOUT_IGNORE = Cardinal(-1);
TIMEOUT_INFINITE = 0;
TIMEOUT_MAXIMUM = 1200*1000; { 20 minutes maximum timeout value in ms}
{ Used for ServerType in dbgetprocinfo }
SERVTYPE_UNKNOWN = 0;
SERVTYPE_MICROSOFT = 1;
{ Used by dbcolinfo }
{enum CI_TYPES }
CI_REGULAR = 1;
CI_ALTERNATE = 2;
CI_CURSOR = 3;
{ Bulk Copy Definitions (bcp) }
DB_IN = 1; { Transfer from client to server }
DB_OUT = 2; { Transfer from server to client }
BCPMAXERRS = 1; { bcp_control parameter }
BCPFIRST = 2; { bcp_control parameter }
BCPLAST = 3; { bcp_control parameter }
BCPBATCH = 4; { bcp_control parameter }
BCPKEEPNULLS = 5; { bcp_control parameter }
BCPABORT = 6; { bcp_control parameter }
BCPKEEPIDENTITY = 8; { bcp_control parameter }
BCPLABELED = 5; { bcp_control parameter }
BCPHINTS = 6; { bcp_control parameter }
DBCMDNONE = 0; { bcp_control parameter }
DBCMDPEND = 1; { bcp_control parameter }
DBCMDSENT = 2; { bcp_control parameter }
TINYBIND = 1;
SMALLBIND = 2;
INTBIND = 3;
CHARBIND = 4;
BINARYBIND = 5;
BITBIND = 6;
DATETIMEBIND = 7;
MONEYBIND = 8;
FLT8BIND = 9;
STRINGBIND = 10;
NTBSTRINGBIND = 11;
VARYCHARBIND = 12;
VARYBINBIND = 13;
FLT4BIND = 14;
SMALLMONEYBIND = 15;
SMALLDATETIBIND = 16;
DECIMALBIND = 17;
NUMERICBIND = 18;
SRCDECIMALBIND = 19;
SRCNUMERICBIND = 20;
MAXBIND = SRCNUMERICBIND;
DBSAVE = 1;
DBNOSAVE = 0;
DBNOERR = -1;
DBFAIL = 0;
DBSUCCEED = 1;
DBFINDONE = $04; { Definately done }
DBMORE = $10; { Maybe more commands waiting }
DBMORE_ROWS = $20; { This command returned rows }
MAXNAME = 31;
DBTXTSLEN = 8; { Timestamp length }
DBTXPLEN = 16; { Text pointer length }
{ Error code returns }
INT_EXIT = 0;
INT_CONTINUE = 1;
INT_CANCEL = 2;
//from FreeTDS sybdb.h:
{ DBVERSION_xxx are used with dbsetlversion() }
DBVERSION_100= 2; // Sybase TDS 5.0
DBVERSION_42 = 3; // This can be used for old Microsoft and Sybase servers
DBVERSION_70 = 4;
DBVERSION_71 = 5;
DBVERSION_72 = 6;
DBVERSION_73 = 7;
{Zeos dbsetversion placeholders}
ZVersion_UNKNOWN = 0;
ZVersion_2_0 = 1; { pre 4.0 SQL Server }
ZVersion_3_4 = 2; { Microsoft SQL Server (3.0) }
ZVersion_4_0 = 3; { 4.0 SQL Server }
ZVersion_4_2 = 4; { 4.2 SQL Server }
ZVersion_4_6 = 5; { 2.0 OpenServer and 4.6 SQL Server. }
ZVersion_4_9_5 = 6; { 4.9.5 (NCR) SQL Server }
ZVersion_5_0 = 7; { 5.0 SQL Server }
ZVersion_7_0 = 8; { Microsoft SQL Server 7.0 }
ZVersion_8_0 = 9; { Microsoft SQL Server 2000 }
ZVersion_9_0 = 10; { Microsoft SQL Server 2005 }
ZVersion_7_1 = 9; { Microsoft SQL Server 2000 }
ZVersion_7_2 = 10; { Microsoft SQL Server 2005 }
ZVersion_7_3 = 11; { Microsoft SQL Server 2008 }
ZVersionMax = 13; { known count of available versions }
ZVersionEmpty = -1; { placeholder for unsuported version }
{ DB-Library datatypes }
const
{Zeos DBOption placeholders}
{ a large list of options, DBTEXTSIZE is needed by sybtcl }
Z_PARSEONLY = 0;
Z_ESTIMATE = 1;
Z_SHOWPLAN = 2;
Z_NOEXEC = 3;
Z_ARITHIGNORE = 4;
Z_NOCOUNT = 5;
Z_ARITHABORT = 6;
Z_TEXTLIMIT = 7;
Z_BROWSE = 8;
Z_OFFSET = 9;
Z_STAT = 10;
Z_ERRLVL = 11;
Z_CONFIRM = 12;
Z_STORPROCID = 13;
Z_BUFFER = 14;
Z_NOAUTOFREE = 15;
Z_ROWCOUNT = 16;
Z_TEXTSIZE = 17;
Z_NATLANG = 18;
Z_DATEFORMAT = 19;
Z_PRPAD = 20;
Z_PRCOLSEP = 21;
Z_PRLINELEN = 22;
Z_PRLINESEP = 23;
Z_LFCONVERT = 24;
Z_DATEFIRST = 25;
Z_CHAINXACTS = 26;
Z_FIPSFLAG = 27;
Z_ISOLATION = 28;
Z_AUTH = 29;
Z_IDENTITY = 30;
Z_NOIDCOL = 31;
Z_DATESHORT = 32;
Z_CLIENTCURSORS = 33;
Z_SETTIME = 34;
Z_QUOTEDIDENT = 35;
Z_NUMOPTIONS = 36;
Z_PADOFF = 37;
Z_PADON = 38;
Z_OFF = 39;
Z_ON = 40;
Z_NOSUCHOPTION = 41;
Z_MAXOPTTEXT = 42;
Z_ANSITOOEM = 43;
Z_OEMTOANSI = 44;
type TdbOption = ({Zeos DBOption placeholders}
{ a large list of options, DBTEXTSIZE is needed by sybtcl }
dboptPARSEONLY = 0,
dboptESTIMATE = 1,
dboptSHOWPLAN = 2,
dboptNOEXEC = 3,
dboptARITHIGNORE = 4,
dboptNOCOUNT = 5,
dboptARITHABORT = 6,
dboptTEXTLIMIT = 7,
dboptBROWSE = 8,
dboptOFFSET = 9,
dboptSTAT = 10,
dboptERRLVL = 11,
dboptCONFIRM = 12,
dboptSTORPROCID = 13,
dboptBUFFER = 14,
dboptNOAUTOFREE = 15,
dboptROWCOUNT = 16,
dboptTEXTSIZE = 17,
dboptNATLANG = 18,
dboptDATEFORMAT = 19,
dboptPRPAD = 20,
dboptPRCOLSEP = 21,
dboptPRLINELEN = 22,
dboptPRLINESEP = 23,
dboptLFCONVERT = 24,
dboptDATEFIRST = 25,
dboptCHAINXACTS = 26,
dboptFIPSFLAG = 27,
dboptISOLATION = 28,
dboptAUTH = 29,
dboptIDENTITY = 30,
dboptNOIDCOL = 31,
dboptDATESHORT = 32,
dboptCLIENTCURSORS = 33,
dboptSETTIME = 34,
dboptQUOTEDIDENT = 35,
dboptANSITOOEM = 36,
dboptOEMTOANSI = 37
);
const
{ loginrec manipulation Placeholders}
Z_SETHOST = 0;
Z_SETUSER = 1;
Z_SETPWD = 2;
Z_SETHID = 3;
Z_SETAPP = 4;
Z_SETBCP = 5;
Z_SETSECURE = 6;
Z_SETLANG = 7;
Z_SETNOSHORT = 8;
Z_SETHIER = 9;
Z_SETCHARSET = 10;
Z_SETPACKET = 11;
Z_SETENCRYPT = 12;
Z_SETLABELED = 13;
Z_SETDBNAME = 14;
Z_SETLOGINTIME = 15;
Z_SETFALLBACK = 16;
{ DBLib options }
const
DBLIBDBBUFFER = 0;
DBLIBDBOFFSET = 1;
DBLIBDBROWCOUNT = 2;
DBLIBDBSTAT = 3;
DBLIBDBTEXTLIMIT = 4;
DBLIBDBTEXTSIZE = 5;
DBLIBDBARITHABORT = 6;
DBLIBDBARITHIGNORE = 7;
DBLIBDBNOAUTOFREE = 8;
DBLIBDBNOCOUNT = 9;
DBLIBDBNOEXEC = 10;
DBLIBDBPARSEONLY = 11;
DBLIBDBSHOWPLAN = 12;
DBLIBDBSTORPROCID = 13;
DBLIBDBANSITOOEM = 14;
DBLIBDBOEMTOANSI = 15;
DBLIBDBCLIENTCURSORS = 16;
DBLIBDBSET_TIME = 17;
DBLIBDBQUOTEDIDENT = 18;
{ FreeTDS options, a large list of options, DBTEXTSIZE is needed by sybtcl }
TDSPARSEONLY = 0;
TDSESTIMATE = 1;
TDSSHOWPLAN = 2;
TDSNOEXEC = 3;
TDSARITHIGNORE = 4;
TDSNOCOUNT = 5;
TDSARITHABORT = 6;
TDSTEXTLIMIT = 7;
TDSBROWSE = 8;
TDSOFFSET = 9;
TDSSTAT = 10;
TDSERRLVL = 11;
TDSCONFIRM = 12;
TDSSTORPROCID = 13;
TDSBUFFER = 14;
TDSNOAUTOFREE = 15;
TDSROWCOUNT = 16;
TDSTEXTSIZE = 17;
TDSNATLANG = 18;
TDSDATEFORMAT = 19;
TDSPRPAD = 20;
TDSPRCOLSEP = 21;
TDSPRLINELEN = 22;
TDSPRLINESEP = 23;
TDSLFCONVERT = 24;
TDSDATEFIRST = 25;
TDSCHAINXACTS = 26;
TDSFIPSFLAG = 27;
TDSISOLATION = 28;
TDSAUTH = 29;
TDSIDENTITY = 30;
TDSNOIDCOL = 31;
TDSDATESHORT = 32;
TDSCLIENTCURSORS = 33;
TDSSETTIME = 34;
TDSQUOTEDIDENT = 35;
TDSNUMOPTIONS = 36;
TDSPADOFF = 0;
TDSPADON = 1;
TDSOFF = 0;
TDSON = 1;
NOSUCHOPTION = 2;
MAXOPTTEXT = 32;
{ common Login manipulations }
DBSETHOST = 1;
DBSETUSER = 2;
DBSETPWD = 3;
{ Sybase Login manipulations }
const
SYBDBSETHOST = DBSETHOST;
SYBDBSETUSER = DBSETUSER;
SYBDBSETPWD = DBSETPWD;
SYBDBSETHID = 4;
SYBDBSETAPP = 5;
SYBDBSETBCP = 6;
SYBDBSETLANG = 7;
SYBDBSETNOSHORT = 8;
SYBDBSETHIER = 9;
SYBDBSETCHARSET = 10;
SYBDBSETPACKET = 11;
SYBDBSETENCRYPT = 12;
SYBDBSETLABELED = 13;
{ MsSQL Login manipulations }
const
MSDBSETHOST = DBSETHOST;
MSDBSETUSER = DBSETUSER;
MSDBSETPWD = DBSETPWD;
MSDBSETAPP = 4;
MSDBSETID = 5;
MSDBSETLANG = 6;
MSDBSETSECURE = 7;
MSDBSET_LOGIN_TIME = 10;
MSDBSETFALLBACK = 12;
{TDS Loginrec manipulations}
TDSDBSETHOST = DBSETHOST;
TDSDBSETUSER = DBSETUSER;
TDSDBSETPWD = DBSETPWD;
TDSDBSETHID = 4;
TDSDBSETAPP = 5;
TDSDBSETBCP = 6;
TDSDBSETSECURE = 6;
TDSDBSETLANG = 7;
TDSDBSETNOSHORT = 8;
TDSDBSETHIER = 9;
TDSDBSETCHARSET = 10;
TDSDBSETPACKET = 11;
TDSDBSETENCRYPT = 12;
TDSDBSETLABELED = 13;
TDSDBSETDBNAME = 14;
{ TDS_DBVERSION_xxx are used with dbsetversion() }
TDSDBVERSION_UNKNOWN = 0;
TDSDBVERSION_46 = 1; // Sybase <= 10
TDSDBVERSION_100 = 2; // Sybase TDS 5.0 Ver >= 10
TDSDBVERSION_42 = 3; // This can be used for old Microsoft(<=6.5)
TDSDBVERSION_70 = 4; // MSSQL v7..2000
TDSDBVERSION_71 = 5;
TDSDBVERSION_80 = TDSDBVERSION_71;
TDSDBVERSION_72 = 6; //MSSQL >= 2005... ?
TDSDBVERSION_73 = 7;
{ these two are defined by Microsoft for dbsetlname() }
DBVER42 = 8;
DBVER60 = 9;
(**
* DBTDS_xxx are returned by DBTDS()
* The integer values of the constants are poorly chosen.
*)
DBTDS_UNKNOWN = 0;
DBTDS_2_0 = 1; { pre 4.0 SQL Server }
DBTDS_3_4 = 2; { Microsoft SQL Server (3.0) }
DBTDS_4_0 = 3; { 4.0 SQL Server }
DBTDS_4_2 = 4; { 4.2 SQL Server }
DBTDS_4_6 = 5; { 2.0 OpenServer and 4.6 SQL Server. }
DBTDS_4_9_5 = 6; { 4.9.5 (NCR) SQL Server }
DBTDS_5_0 = 7; { 5.0 SQL Server }
DBTDS_7_0 = 8; { Microsoft SQL Server 7.0 }
DBTDS_8_0 = 9; { Microsoft SQL Server 2000 }
DBTDS_9_0 = 10; { Microsoft SQL Server 2005 }
DBTDS_7_1 = 9; { Microsoft SQL Server 2000 }
DBTDS_7_2 = 10; { Microsoft SQL Server 2005 }
DBTDS_7_3 = 11; { Microsoft SQL Server 2008 }
{ Data stream tokens }
SQLCOLFMT = $a1;
OLD_SQLCOLFMT = $2a;
SQLPROCID = $7c;
SQLCOLNAME = $a0;
SQLTABNAME = $a4;
SQLCOLINFO = $a5;
SQLALTNAME = $a7;
SQLALTFMT = $a8;
SQLERROR = $aa;
SQLINFO = $ab;
SQLRETURNVALUE = $ac;
SQLRETURNSTATUS = $79;
SQLRETURN = $db;
SQLCONTROL = $ae;
SQLALTCONTROL = $af;
SQLROW = $d1;
SQLALTROW = $d3;
SQLDONE = $fd;
SQLDONEPROC = $fe;
SQLDONEINPROC = $ff;
SQLOFFSET = $78;
SQLORDER = $a9;
SQLLOGINACK = $ad; { NOTICE: change to real value }
{ Ag op tokens }
SQLAOPCNT = $4b;
SQLAOPSUM = $4d;
SQLAOPAVG = $4f;
SQLAOPMIN = $51;
SQLAOPMAX = $52;
SQLAOPANY = $53;
SQLAOPNOOP = $56;
{ Error numbers (dberrs) DB-Library error codes }
SQLEMEM = 10000;
SQLENULL = 10001;
SQLENLOG = 10002;
SQLEPWD = 10003;
SQLECONN = 10004;
SQLEDDNE = 10005;
SQLENULLO = 10006;
SQLESMSG = 10007;
SQLEBTOK = 10008;
SQLENSPE = 10009;
SQLEREAD = 10010;
SQLECNOR = 10011;
SQLETSIT = 10012;
SQLEPARM = 10013;
SQLEAUTN = 10014;
SQLECOFL = 10015;
SQLERDCN = 10016;
SQLEICN = 10017;
SQLECLOS = 10018;
SQLENTXT = 10019;
SQLEDNTI = 10020;
SQLETMTD = 10021;
SQLEASEC = 10022;
SQLENTLL = 10023;
SQLETIME = 10024;
SQLEWRIT = 10025;
SQLEMODE = 10026;
SQLEOOB = 10027;
SQLEITIM = 10028;
SQLEDBPS = 10029;
SQLEIOPT = 10030;
SQLEASNL = 10031;
SQLEASUL = 10032;
SQLENPRM = 10033;
SQLEDBOP = 10034;
SQLENSIP = 10035;
SQLECNULL = 10036;
SQLESEOF = 10037;
SQLERPND = 10038;
SQLECSYN = 10039;
SQLENONET = 10040;
SQLEBTYP = 10041;
SQLEABNC = 10042;
SQLEABMT = 10043;
SQLEABNP = 10044;
SQLEBNCR = 10045;
SQLEAAMT = 10046;
SQLENXID = 10047;
SQLEIFNB = 10048;
SQLEKBCO = 10049;
SQLEBBCI = 10050;
SQLEKBCI = 10051;
SQLEBCWE = 10052;
SQLEBCNN = 10053;
SQLEBCOR = 10054;
SQLEBCPI = 10055;
SQLEBCPN = 10056;
SQLEBCPB = 10057;
SQLEVDPT = 10058;
SQLEBIVI = 10059;
SQLEBCBC = 10060;
SQLEBCFO = 10061;
SQLEBCVH = 10062;
SQLEBCUO = 10063;
SQLEBUOE = 10064;
SQLEBWEF = 10065;
SQLEBTMT = 10066;
SQLEBEOF = 10067;
SQLEBCSI = 10068;
SQLEPNUL = 10069;
SQLEBSKERR = 10070;
SQLEBDIO = 10071;
SQLEBCNT = 10072;
SQLEMDBP = 10073;
SQLINIT = 10074;
SQLCRSINV = 10075;
SQLCRSCMD = 10076;
SQLCRSNOIND = 10077;
SQLCRSDIS = 10078;
SQLCRSAGR = 10079;
SQLCRSORD = 10080;
SQLCRSMEM = 10081;
SQLCRSBSKEY = 10082;
SQLCRSNORES = 10083;
SQLCRSVIEW = 10084;
SQLCRSBUFR = 10085;
SQLCRSFROWN = 10086;
SQLCRSBROL = 10087;
SQLCRSFRAND = 10088;
SQLCRSFLAST = 10089;
SQLCRSRO = 10090;
SQLCRSTAB = 10091;
SQLCRSUPDTAB = 10092;
SQLCRSUPDNB = 10093;
SQLCRSVIIND = 10094;
SQLCRSNOUPD = 10095;
SQLCRSOS2 = 10096;
SQLEBCSA = 10097;
SQLEBCRO = 10098;
SQLEBCNE = 10099;
SQLEBCSK = 10100;
SQLEUVBF = 10101;
SQLEBIHC = 10102;
SQLEBWFF = 10103;
SQLNUMVAL = 10104;
SQLEOLDVR = 10105;
SQLEBCPS = 10106;
SQLEDTC = 10107;
SQLENOTIMPL = 10108;
SQLENONFLOAT = 10109;
SQLECONNFB = 10110;
{ The severity levels are defined here }
EXINFO = 1; { Informational, non-error }
EXUSER = 2; { User error }
EXNONFATAL = 3; { Non-fatal error }
EXCONVERSION = 4; { Error in DB-LIBRARY data conversion }
EXSERVER = 5; { The Server has returned an error flag }
EXTIME = 6; { We have exceeded our timeout period while }
{ waiting for a response from the Server - the }
{ DBPROCESS is still alive }
EXPROGRAM = 7; { Coding error in user program }
EXRESOURCE = 8; { Running out of resources - the DBPROCESS may be dead }
EXCOMM = 9; { Failure in communication with Server - the DBPROCESS is dead }
EXFATAL = 10; { Fatal error - the DBPROCESS is dead }
EXCONSISTENCY = 11; { Internal software error - notify MS Technical Support }
{ Offset identifiers }
OFF_SELECT = $16d;
OFF_FROM = $14f;
OFF_ORDER = $165;
OFF_COMPUTE = $139;
OFF_TABLE = $173;
OFF_PROCEDURE = $16a;
OFF_STATEMENT = $1cb;
OFF_PARAM = $1c4;
OFF_EXEC = $12c;
{ Decimal constants }
MAXNUMERICLEN = 16;
MAXNUMERICDIG = 38;
DEFAULTPRECISION = 18;
DEFAULTSCALE = 0;
{ DB-Table constants}
{ Pack the following structures on a word boundary }
TDSMAXTABLENAME = 512;
TDSMAXCOLNAMELEN = 512;
{ DB-Table constants}
{ Pack the following structures on a word boundary }
MAXTABLENAME = 30;
MAXCOLNAMELEN= 30;
{ DB-Library datatype definitions }
DBMAXCHAR=256; // Max length of DBVARBINARY and DBVARCHAR, etc.
{ Print lengths for certain fixed length data types }
PRINT4 = 11;
PRINT2 = 6;
PRINT1 = 3;
PRFLT8 = 20;
PRMONEY = 26;
PRBIT = 3;
PRDATETIME = 27;
PRDECIMAL = (MAXNUMERICDIG + 2);
PRNUMERIC = (MAXNUMERICDIG + 2);
SUCCEED = 1;
FAIL = 0;
SUCCEED_ABORT = 2;
DBUNKNOWN = 2; { FALSE = 0, TRUE = 1 }
MORE_ROWS = -1;
NO_MORE_ROWS = -2;
REG_ROW = MORE_ROWS;
BUF_FULL = -3; { only if buffering is turned on }
{ Status code for dbresults(). Possible return values are }
{ SUCCEED, FAIL, and NO_MORE_RESULTS. }
NO_MORE_RESULTS = 2;
NO_MORE_RPC_RESULTS = 3;
{ Standard exit and error values }
STDEXIT = 0;
ERREXIT = -1;
{ dbrpcinit flags }
DBRPCRECOMPILE = $0001;
DBRPCRESET = $0004;
DBRPCCURSOR = $0008;
{ dbrpcparam flags }
DBRPCRETURN = $1;
DBRPCDEFAULT = $2;
{ Cursor related constants }
{ Following flags are used in the concuropt parameter in the dbcursoropen function }
CUR_READONLY = 1; { Read only cursor, no data modifications }
CUR_LOCKCC = 2; { Intent to update, all fetched data locked when }
{ dbcursorfetch is called inside a transaction block }
CUR_OPTCC = 3; { Optimistic concurrency control, data modifications }
{ succeed only if the row hasn't been updated since }
{ the last fetch. }
CUR_OPTCCVAL = 4; { Optimistic concurrency control based on selected column values }
{ Following flags are used in the scrollopt parameter in dbcursoropen }
CUR_FORWARD = 0; { Forward only scrolling }
CUR_KEYSET = -1; { Keyset driven scrolling }
CUR_DYNAMIC = 1; { Fully dynamic }
CUR_INSENSITIVE = -2; { Server-side cursors only }
{ Following flags define the fetchtype in the dbcursorfetch function }
FETCH_FIRST = 1; { Fetch first n rows }
FETCH_NEXT = 2; { Fetch next n rows }
FETCH_PREV = 3; { Fetch previous n rows }
FETCH_RANDOM = 4; { Fetch n rows beginning with given row # }
FETCH_RELATIVE = 5; { Fetch relative to previous fetch row # }
FETCH_LAST = 6; { Fetch the last n rows }
{ Following flags define the per row status as filled by dbcursorfetch and/or dbcursorfetchex }
FTC_EMPTY = $00; { No row available }
FTC_SUCCEED = $01; { Fetch succeeded, (failed if not set) }
FTC_MISSING = $02; { The row is missing }
FTC_ENDOFKEYSET = $04; { End of the keyset reached }
FTC_ENDOFRESULTS = $08; { End of results set reached }
{ Following flags define the operator types for the dbcursor function }
CRS_UPDATE = 1; { Update operation }
CRS_DELETE = 2; { Delete operation }
CRS_INSERT = 3; { Insert operation }
CRS_REFRESH = 4; { Refetch given row }
CRS_LOCKCC = 5; { Lock given row }
{ Following value can be passed to the dbcursorbind function for NOBIND type }
NOBIND = -2; { Return length and pointer to data }
{ Following are values used by DBCURSORINFO's Type parameter }
CU_CLIENT = $00000001;
CU_SERVER = $00000002;
CU_KEYSET = $00000004;
CU_MIXED = $00000008;
CU_DYNAMIC = $00000010;
CU_FORWARD = $00000020;
CU_INSENSITIVE = $00000040;
CU_READONLY = $00000080;
CU_LOCKCC = $00000100;
CU_OPTCC = $00000200;
CU_OPTCCVAL = $00000400;
{ Following are values used by DBCURSORINFO's Status parameter }
CU_FILLING = $00000001;
CU_FILLED = $00000002;
{ Following are values used by dbupdatetext's type parameter }
UT_TEXTPTR = $0001;
UT_TEXT = $0002;
UT_MORETEXT = $0004;
UT_DELETEONLY = $0008;
UT_LOG = $0010;
{ The following values are passed to dbserverenum for searching criteria. }
NET_SEARCH = $0001;
LOC_SEARCH = $0002;
{ These constants are the possible return values from dbserverenum. }
ENUM_SUCCESS = $0000;
MORE_DATA = $0001;
NET_NOT_AVAIL = $0002;
OUT_OF_MEMORY = $0004;
NOT_SUPPORTED = $0008;
ENUM_INVALID_PARAM = $0010;
{ Netlib Error problem codes. ConnectionError() should return one of }
{ these as the dblib-mapped problem code, so the corresponding string }
{ is sent to the dblib app's error handler as dberrstr. Return NE_E_NOMAP }
{ for a generic DB-Library error string (as in prior versions of dblib). }
NE_E_NOMAP = 0; { No string; uses dblib default. }
NE_E_NOMEMORY = 1; { Insufficient memory. }
NE_E_NOACCESS = 2; { Access denied. }
NE_E_CONNBUSY = 3; { Connection is busy. }
NE_E_CONNBROKEN = 4; { Connection broken. }
NE_E_TOOMANYCONN = 5; { Connection limit exceeded. }
NE_E_SERVERNOTFOUND = 6; { Specified SQL server not found. }
NE_E_NETNOTSTARTED = 7; { The network has not been started. }
NE_E_NORESOURCE = 8; { Insufficient network resources. }
NE_E_NETBUSY = 9; { Network is busy. }
NE_E_NONETACCESS = 10; { Network access denied. }
NE_E_GENERAL = 11; { General network error. Check your documentation. }
NE_E_CONNMODE = 12; { Incorrect connection mode. }
NE_E_NAMENOTFOUND = 13; { Name not found in directory service. }
NE_E_INVALIDCONN = 14; { Invalid connection. }
NE_E_NETDATAERR = 15; { Error reading or writing network data. }
NE_E_TOOMANYFILES = 16; { Too many open file handles. }
NE_E_CANTCONNECT = 17; { SQL Server does not exist or access denied. }
NE_MAX_NETERROR = 17;
const
MAXSERVERNAME = 30;
MAXNETLIBNAME = 255;
MAXNETLIBCONNSTR = 255;
const
INVALID_UROWNUM = Cardinal(-1);
{ common TDS protocol Data Type mapping of ntwdblib, dblib, freeTDS }
type
{ tabular data stream protocol types }
//Enum ordinal-value
TTDSType = (
tdsVoid = 31,
tdsImage = 34,
tdsText = 35,
tdsUnique = 36, //Unique identifier type
tdsVarBinary = 37,
tdsIntN = 38,
tdsVarchar = 39,
tdsMsDate = 40, // FreeTDS calls this SYBMSDATE, but it doesn't fit into the names nicely...
tdsMsTime = 41, // FreeTDS calls this SYBMSTIME, but it doesn't fit into the names nicely...
tdsMsDateTime2 = 42, // FreeTDS calls this SYBMSDATETIME", but it doesn't fit into the names nicely...
tdsMsDateTimeOffset = 43, // FreeTDS calls this SYBMSDATETIMEOFFSET, but it doesn't fit into the names nicely...
tdsBinary = 45,
tdsChar = 47,
tdsInt1 = 48,
tdsBit = 50,
tdsInt2 = 52,
tdsInt4 = 56,
tdsDateTime4 = 58,
tdsFlt4 = 59,
tdsMoney = 60,
tdsDateTime = 61,
tdsFlt8 = 62,
tdsVariant = 98, {from tds.h -> sybase only}
tdsNText = 99, {from tds.h -> sybase only}
tdsNVarChar = 103, {from tds.h -> sybase only}
tdsBitN = 104, {from tds.h -> sybase only}
tdsDecimal = 106,
tdsNumeric = 108,
tdsFltN = 109,
tdsMoneyN = 110,
tdsDateTimeN = 111,
tdsMoney4 = 122,
{from tds.h -> sade, sybase only}
tdsInt8 = 127,
tdsBigVarBinary = 165,
tdsBigVarChar = 167,
tdsBigBinary = 173,
tdsBigChar = 175,
tdsSybaseLongBinary = 225,
tdsBigNVarChar = 231,
tdsBigNChar = 239,
tdsUDT = 240,
tdsMSXML = 241
);
const
{ different type mappings / copied from tds.h -> sybase only!}
SYBAOPCNT = $4b;
SYBAOPCNTU = $4c;
SYBAOPSUM = $4d;
SYBAOPSUMU = $4e;
SYBAOPAVG = $4f;
SYBAOPAVGU = $50;
SYBAOPMIN = $51;
SYBAOPMAX = $52;
{ mssql2k compute operator }
SYBAOPCNT_BIG = $09;
SYBAOPSTDEV = $30;
SYBAOPSTDEVP = $31;
SYBAOPVAR = $32;
SYBAOPVARP = $33;
SYBAOPCHECKSUM_AGG = $72;
{****************** Plain API Types definition *****************}
type
{ DBPROCESS, LOGINREC and DBCURSOR }
PDBPROCESS = Pointer;
PLOGINREC = Pointer;
PDBCURSOR = Pointer;
PDBHANDLE = Pointer;
DBXLATE = Pointer;
DBSORTORDER = Pointer;
DBLOGINFO = Pointer;
DBVOIDPTR = PPointer;
type
{ DB-Library datatypes }
DBBOOL = Byte;
DBCHAR = AnsiChar;
DBBIT = Byte;
DBTINYINT = Byte;
DBSMALLINT = SmallInt; { int16_type }
DBINT = LongInt; { int32_type }
DBBIGINT = Int64; { int64_type }
DBBINARY = Byte;
DBFLT4 = Single; { real32_type }
DBFLT8 = Double; { real64_type }
DBSHORT = SmallInt;
DBUSMALLINT = Word;
DBMONEY4 = LongInt;
PDBMONEY4 = ^DBMONEY4;
RETCODE = Integer;
PRETCODE = ^RETCODE;
STATUS = Integer;
type
tdsVARYCHAR=packed record
len: DBINT;
str: array[0..DBMAXCHAR-1] of DBCHAR;
end;
dblibVARYCHAR=packed record
len: DBSMALLINT;
str: array[0..DBMAXCHAR-1] of DBCHAR;
end;
DBREAL = DBFLT4;
DBUBOOL = Cardinal;
DBDATETIM4 = packed record
numdays: Word; { No of days since Jan-1-1900 }
nummins: Word; { No. of minutes since midnight }
end;
PDBDATETIM4 = ^DBDATETIM4;
{$IFDEF FPC}
{$PACKRECORDS C}
{$ENDIF}
type
TDBNUMERIC = packed record
Precision: Byte;
Scale: Byte;
Sign: Byte; { 1 = Positive, 0 = Negative }
Val: array[0..MAXNUMERICLEN-1] of Byte;
end;
TDBDECIMAL = TDBNUMERIC;
PTDSDBNUMERIC = ^TTDSDBNUMERIC;
TTDSDBNUMERIC = packed record
Precision: Byte;
Scale: Byte;
Val: array[0..32] of Byte;
end;
TTDSDBDECIMAL = TTDSDBNUMERIC;
DBVARYCHAR = packed record
Len: DBSMALLINT;
Str: array[0..DBMAXCHAR-1] of DBCHAR;
end;
DBVARYBIN = packed record
Len: DBSMALLINT;
Bytes: array[0..DBMAXCHAR-1] of Byte;
end;
TDBMONEY = packed record
mnyhigh: DBINT;
mnylow: LongWord;
end;
PDBMONEY = ^TDBMONEY;
PDBDATETIME = ^TDBDATETIME;
TDBDATETIME = packed record
dtdays: DBINT; // Days since Jan 1, 1900
dttime: LongWord; // 300ths of a second since midnight, 25920000 unit is 1 day
end;
PTDSDBDATETIME = ^TTDSDBDATETIME;
TTDSDBDATETIME = packed record
dtdays: DBINT; // Days since Jan 1, 1900
dttime: DBINT; // 300ths of a second since midnight, 25920000 unit is 1 day
end;
TDBDATETIMEALL = packed record
time: UInt64;
date: DBINT;
offset: DBSMALLINT;
flags: Word;
end;
PDBDATETIMEALL = ^TDBDATETIMEALL;
const
DbDateTimeAllTimePrecMask = $0007;
DbDateTimeAllHasTimeMask = $2000;
DbDateTimeAllHasDateMask = $4000;
DbDatetimeAllHasOffsetMask = $8000;
(*
* Sybase & Microsoft use different names for the dbdaterec members.
* Keep these two structures physically identical in memory.
* dbdatecrack() casts one to the other for ease of implementation.
*
* Giving credit where credit is due, we can acknowledge that
* Microsoft chose the better names here, hands down. ("datedmonth"?!)
*)
type
{ FreeTDS sybdb.h }
PTDS_DBDATEREC = ^Ttds_dbdaterec;
Ttds_dbdaterec = packed record
{ fields } {microsoft} {sybase}
year: DBINT; { 1753 - 9999 } { 1900 and counting }
quarter: DBINT; { 1 - 4 } { 0 - 3 (Microsoft only) }
month: DBINT; { 1 - 12 } { 0 - 11 }
dayofmonth: DBINT; { 1 - 31 } { 1 - 31 }
dayofyear: DBINT; { 1 - 366 } { 1 - 366 (in Sybase.sybdb.h dayofyear and day are changed around!) }
week: DBINT; { 1 - 54 (for leap years) } { 1 - 54 (Microsoft only) }
weekday: DBINT; { 1 - 7 (Mon - Sun) } { 0 - 6 (Mon - Sun) }
hour: DBINT; { 0 - 23 } { 0 - 23 }
minute: DBINT; { 0 - 59 } { 0 - 59 }
second: DBINT; { 0 - 59 } { 0 - 59 }
millisecond: DBINT; { 0 - 999 } { 0 - 997 }
tzone: DBINT; { 0 - 127 (Sybase only!) } { 0 - 127 }
end;
{ DBDATEREC structure used by dbdatecrack }
DBDATEREC = packed record
year: DBINT; { 1753 - 9999 }
quarter: DBINT; { 1 - 4 }
month: DBINT; { 1 - 12 }
dayofyear: DBINT; { 1 - 366 }
day: DBINT; { 1 - 31 }
week: DBINT; { 1 - 54 (for leap years) }
weekday: DBINT; { 1 - 7 (Mon - Sun) }
hour: DBINT; { 0 - 23 }
minute: DBINT; { 0 - 59 }
second: DBINT; { 0 - 59 }
millisecond: DBINT; { 0 - 999 }
end;
PDBDATEREC = ^DBDATEREC;
type
//EH: We need a size of 122 Bytes!
{$IFDEF FPC}
{$PACKRECORDS 1}
{$ELSE}
{$A1} //JBau: Does this really make sense? I didn't find documentation for anything besides $A+ and $A- about this.
{$ENDIF}
PZDBCOL = ^ZDBCOL;
ZDBCOL = packed record
Typ: DBSHORT;
UserType: DBINT;
MaxLength: DBINT;
Precision: BYTE;
Scale: BYTE;
PAD1: BYTE; // JBau: These pads are necessary because otherwise we cannot get the sams memory layout as C uses :o(
PAD2: BYTE; // JBau: These pads are necessary because otherwise we cannot get the sams memory layout as C uses :o(
VarLength: LongBool; { TRUE, FALSE }
Null: BYTE; { TRUE, FALSE or DBUNKNOWN }
CaseSensitive: BYTE; { TRUE, FALSE or DBUNKNOWN }
Updatable: BYTE; { TRUE, FALSE or DBUNKNOWN }
PAD3: BYTE; // JBau: These pads are necessary because otherwise we cannot get the sams memory layout as C uses :o(
Identity: LongBool; { TRUE, FALSE or DBUNKNOWN }
end;
PDBCOL = ^DBCOL;
DBCOL = packed record
SizeOfStruct: DBINT;
Name: array[0..MAXCOLNAMELEN] of DBCHAR;
ActualName: array[0..MAXCOLNAMELEN] of DBCHAR;
TableName: array[0..MAXTABLENAME] of DBCHAR;
ColInfo: ZDBCOL;
(*Typ: DBSHORT;
UserType: DBINT;
MaxLength: DBINT;
Precision: BYTE;
Scale: BYTE;
VarLength: LongBool; { TRUE, FALSE }
Null: BYTE; { TRUE, FALSE or DBUNKNOWN }
CaseSensitive: BYTE; { TRUE, FALSE or DBUNKNOWN }
Updatable: BYTE; { TRUE, FALSE or DBUNKNOWN }
Identity: LongBool; { TRUE, FALSE or DBUNKNOWN }*)
end;
PTDSDBCOL = ^TTDSDBCOL;
TTDSDBCOL = packed record
SizeOfStruct: DBINT;
Name: array[0..TDSMAXCOLNAMELEN+1] of DBCHAR;
ActualName: array[0..TDSMAXCOLNAMELEN+1] of DBCHAR;
TableName: array[0..TDSMAXCOLNAMELEN+1] of DBCHAR;
ColInfo: ZDBCOL;
(*Typ: SmallInt;
UserType: DBINT;
MaxLength: DBINT;
Precision: Byte;
Scale: Byte;
VarLength: LongBool;{ TRUE, FALSE }
Null: Byte; { TRUE, FALSE or DBUNKNOWN }
CaseSensitive: Byte; { TRUE, FALSE or DBUNKNOWN }
Updatable: Byte; { TRUE, FALSE or DBUNKNOWN }
Identity: LongBool;{ TRUE, FALSE }*)
end;
PTDSDBCOL2 = ^TTDSDBCOL;
TTDSDBCOL2 = packed record
SizeOfStruct: DBINT;
Name: array[0..TDSMAXCOLNAMELEN+1] of DBCHAR;
ActualName: array[0..TDSMAXCOLNAMELEN+1] of DBCHAR;
TableName: array[0..TDSMAXCOLNAMELEN+1] of DBCHAR;
Typ: SmallInt;
UserType: DBINT;
MaxLength: DBINT;
Precision: Byte;
Scale: Byte;
VarLength: LongBool;{ TRUE, FALSE }
Null: Byte; { TRUE, FALSE or DBUNKNOWN }
CaseSensitive: Byte; { TRUE, FALSE or DBUNKNOWN }
Updatable: Byte; { TRUE, FALSE or DBUNKNOWN }
Identity: LongBool;{ TRUE, FALSE }
ServerType: DBSHORT;
ServerMaxLength:DBINT;
ServerTypeDeclaration:array[Byte] of AnsiChar;
end;
{$IFDEF FPC}
{$PACKRECORDS DEFAULT}
{$ELSE}
{$A+}
{$ENDIF}
type
PDBTYPEINFO = ^TDBTYPEINFO;
TDBTYPEINFO = packed record
Precision: DBINT;
Scale: DBINT;
end;
DBPROC_INFO = packed record
SizeOfStruct: DBINT;
ServerType: Byte;
ServerMajor: Word;
ServerMinor: Word;
ServerRevision: Word;
ServerName: array[0..MAXSERVERNAME] of AnsiChar;
NetLibName: array[0..MAXNETLIBNAME] of AnsiChar;
NetLibConnStr: array[0..MAXNETLIBCONNSTR] of AnsiChar;
end;
PDBPROCINFO = ^DBPROC_INFO;
DBCURSOR_INFO = packed record
SizeOfStruct: DBINT; { Use sizeof(DBCURSORINFO) }
TotCols: Cardinal; { Total Columns in cursor }
TotRows: Cardinal; { Total Rows in cursor }
CurRow: Cardinal; { Current actual row in server }
TotRowsFetched: Cardinal; { Total rows actually fetched }
CurType: Cardinal; { See CU_... }
Status: Cardinal; { See CU_... }
end;
PDBCURSORINFO = ^DBCURSOR_INFO;
type
{ Pointer Datatypes }
PDBINT = ^DBINT;
PDBBINARY = ^DBBINARY;
type
PDBLibError = ^TDBLibError;
TDBLibError = record
dbProc: PDBPROCESS;
Severity: DBINT;
DbErr: DBINT;
OsErr: DBINT;
DbErrStr: RawByteString;
OsErrStr: RawByteString;
end;
PDBLibMessage = ^TDBLibMessage;
TDBLibMessage = record
dbProc: PDBPROCESS;
MsgNo: DBINT;
MsgState: DBINT;
Severity: DBINT;
MsgText: RawByteString;
SrvName: RawByteString;
ProcName: RawByteString;
Line: DBUSMALLINT;
end;
{** Represents a generic interface to DBLIB native API. }
IZDBLibPlainDriver = interface (IZPlainDriver)
['{7731C3B4-0608-4B6B-B089-240AC43A3463}']
end;
TDBERRHANDLE_PROC_cdecl = function(Proc: PDBPROCESS; Severity, DbErr, OsErr: Integer;
DbErrStr, OsErrStr: PAnsiChar): Integer; cdecl;
TDBMSGHANDLE_PROC_cdecl = function(Proc: PDBPROCESS; MsgNo: DBINT; MsgState,
Severity: Integer; MsgText, SrvName, ProcName: PAnsiChar; Line: DBUSMALLINT):
Integer; cdecl;
{$IFDEF MSWINDOWS}
TDBERRHANDLE_PROC_stdcall = function(Proc: PDBPROCESS; Severity, DbErr, OsErr: Integer;
DbErrStr, OsErrStr: PAnsiChar): Integer; stdcall;
TDBMSGHANDLE_PROC_stdcall = function(Proc: PDBPROCESS; MsgNo: DBINT; MsgState,
Severity: Integer; MsgText, SrvName, ProcName: PAnsiChar; Line: DBUSMALLINT):
Integer; stdcall;
{$ENDIF}
TZDBLibErrorList = Class(TZCustomElementList)
protected
/// <summary>Notify about an action which will or was performed.
/// if ElementNeedsFinalize is False the method will never be called.
/// Otherwise you may finalize managed types beeing part of each element,
/// such as Strings, Objects etc.</summary>
/// <param>"Ptr" the address of the element an action happens for.</param>
/// <param>"Index" the index of the element.</param>
/// <returns>The address or raises an EListError if the Index is invalid.</returns>
procedure Notify(Ptr: Pointer; Action: TListNotification); override;
public
constructor Create;
End;
TZDBLibMessageList = Class(TZCustomElementList)
protected
/// <summary>Notify about an action which will or was performed.
/// if ElementNeedsFinalize is False the method will never be called.
/// Otherwise you may finalize managed types beeing part of each element,
/// such as Strings, Objects etc.</summary>
/// <param>"Ptr" the address of the element an action happens for.</param>
/// <param>"Index" the index of the element.</param>
/// <returns>The address or raises an EListError if the Index is invalid.</returns>
procedure Notify(Ptr: Pointer; Action: TListNotification); override;
public
constructor Create;
End;
{$IFDEF TEST_CALLBACK}
TDBERRHANDLE_PROC = function(Proc: PDBPROCESS; Severity, DbErr, OsErr: Integer;
DbErrStr, OsErrStr: PAnsiChar): Integer of Object;
TDBMSGHANDLE_PROC = function(Proc: PDBPROCESS; MsgNo: DBINT; MsgState,
Severity: Integer; MsgText, SrvName, ProcName: PAnsiChar; Line: DBUSMALLINT): Integer of Object;
IZDBLibErrorHandler = interface(IZInterface)
['{E853EAE4-3E13-45FD-9483-726D25A7930E}']
end;
IZDBLibMessageHandler = interface(IZInterface)
['{2B0CB89E-7C17-4C38-B5C4-677C483672AF}']
end;
TDbLibErrorHandler = class; //forward
TDbLibMessageHandler = class; //forward
{$ENDIF TEST_CALLBACK}
TDBLibraryVendorType = (lvtFreeTDS, lvtMS, lvtSybase);
TZDBLIBPLainDriver = class(TZAbstractPlainDriver, IZPlainDriver)
private
{$IFDEF TEST_CALLBACK}
FSQLErrorHandlerList: TZDBLibErrorList;
FSQLMessageHandlerList: TZDBLibMessageList;
FCS: TCriticalSection;
{$ENDIF TEST_CALLBACK}
{$IFDEF MSWINDOWS}FClientVersion: String;{$ENDIF}
private
{ core }
{$IFDEF MSWINDOWS}
Fdbadata: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): PByte; cdecl;
Fdbadata_stdcall: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): PByte; stdcall;
Fdbadlen: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): DBINT; cdecl;
Fdbadlen_stdcall: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): DBINT; stdcall;
Fdbaltbind: function(dbproc: PDBPROCESS; ComputeId, Column, VarType: Integer; VarLen: DBINT; VarAddr: PByte): RETCODE; cdecl;
Fdbaltbind_stdcall: function(dbproc: PDBPROCESS; ComputeId, Column, VarType: Integer; VarLen: DBINT; VarAddr: PByte): RETCODE; stdcall;
Fdbaltbind_ps: function(dbproc: PDBPROCESS; ComputeId, Column: Integer; VarType: Integer; VarLen: DBINT; VarAddr: PByte; typinfo: PDBTYPEINFO): RETCODE; cdecl;
Fdbaltbind_ps_stdcall: function(dbproc: PDBPROCESS; ComputeId, Column: Integer; VarType: Integer; VarLen: DBINT; VarAddr: PByte; typinfo: PDBTYPEINFO): RETCODE; stdcall;
Fdbaltcolid: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): Integer; cdecl;
Fdbaltcolid_stdcall: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): Integer; stdcall;
Fdbaltlen: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): DBINT; cdecl;
Fdbaltlen_stdcall: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): DBINT; stdcall;
Fdbaltop: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): Integer; cdecl;
Fdbaltop_stdcall: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): Integer; stdcall;
Fdbalttype: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): Integer; cdecl;
Fdbalttype_stdcall: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): Integer; stdcall;
Fdbaltutype: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): DBINT; cdecl;
Fdbaltutype_stdcall: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): DBINT; stdcall;
Fdbanullbind: function(dbproc: PDBPROCESS; ComputeId, Column: Integer; Indicator: PDBINT): RETCODE; cdecl;
Fdbanullbind_stdcall: function(dbproc: PDBPROCESS; ComputeId, Column: Integer; Indicator: PDBINT): RETCODE; stdcall;
Fdbbind: function(dbproc: PDBPROCESS; Column, VarType, VarLen: Integer; VarAddr: PByte): RETCODE; cdecl;
Fdbbind_stdcall: function(dbproc: PDBPROCESS; Column, VarType, VarLen: Integer; VarAddr: PByte): RETCODE; stdcall;
Fdbbind_ps: function (dbproc: PDBPROCESS; Column, VarType, VarLen: Integer; VarAddr: PByte; typinfo: PDBTYPEINFO): RETCODE; cdecl;
Fdbbind_ps_stdcall: function (dbproc: PDBPROCESS; Column, VarType, VarLen: Integer; VarAddr: PByte; typinfo: PDBTYPEINFO): RETCODE; stdcall;
Fdbbufsize: function(dbproc: PDBPROCESS): Integer; cdecl;
Fdbbufsize_stdcall: function(dbproc: PDBPROCESS): Integer; stdcall;
Fdbbylist: function(dbproc: PDBPROCESS; ComputeId: Integer; Size: PInteger): PByte; cdecl;
Fdbbylist_stdcall: function(dbproc: PDBPROCESS; ComputeId: Integer; Size: PInteger): PByte; stdcall;
Fdbcancel: function(dbproc: PDBPROCESS): RETCODE; cdecl;
Fdbcancel_stdcall: function(dbproc: PDBPROCESS): RETCODE; stdcall;
Fdbcanquery: function(dbproc: PDBPROCESS): RETCODE; cdecl;
Fdbcanquery_stdcall: function(dbproc: PDBPROCESS): RETCODE; stdcall;
Fdbchange: function(dbproc: PDBPROCESS): PAnsiChar; cdecl;
Fdbchange_stdcall: function(dbroc: PDBPROCESS): PAnsiChar; stdcall;
//dbcharsetconv
{EH: Attention -> call convention and ms version returns a RETCODE}
Fdbclose_SYB: procedure(dbproc: PDBPROCESS); cdecl;
Fdbclose_MS: function(dbproc: PDBPROCESS): RETCODE; cdecl;
Fdbclose_stdcall: procedure(dbproc: PDBPROCESS); stdcall;
Fdbclrbuf: procedure(dbproc: PDBPROCESS; N: DBINT); cdecl;
Fdbclrbuf_stdcall: procedure(dbproc: PDBPROCESS; N: DBINT); stdcall;
Fdbclropt: function(dbproc: PDBPROCESS; Option: Integer; Param: PAnsiChar): RETCODE; cdecl;
Fdbclropt_stdcall: function(dbproc: PDBPROCESS; Option: Integer; Param: PAnsiChar): RETCODE; stdcall;
Fdbcmd: function(dbproc: PDBPROCESS; Cmd: PAnsiChar): RETCODE; cdecl;
Fdbcmd_stdcall: function(dbproc: PDBPROCESS; Cmd: PAnsiChar): RETCODE; stdcall;
Fdbcmdrow: function(dbproc: PDBPROCESS): RETCODE; cdecl;
Fdbcmdrow_stdcall: function(dbproc: PDBPROCESS): RETCODE; stdcall;
//result type(MS vs Syb) size is different
Fdbcolbrowse_MS: function(dbproc: PDBPROCESS; Column: Integer): LongBool; cdecl;
Fdbcolbrowse_SYB: function(dbproc: PDBPROCESS; Column: Integer): DBBOOL; cdecl; //no FreeTDS?
Fdbcolbrowse_stdcall: function(dbproc: PDBPROCESS; Column: Integer): DBBOOL; stdcall;
Fdbcollen: function(dbproc: PDBPROCESS; Column: Integer): DBINT; cdecl;
Fdbcollen_stdcall: function(dbproc: PDBPROCESS; Column: Integer): DBINT; stdcall;
Fdbcolname: function(dbproc: PDBPROCESS; Column: Integer): PAnsiChar; cdecl;
Fdbcolname_stdcall: function(dbproc: PDBPROCESS; Column: Integer): PAnsiChar; stdcall;
Fdbcolsource: function(dbproc: PDBPROCESS; Column: Integer): PAnsiChar; cdecl; //no FreeTDS?
Fdbcolsource_stdcall: function(dbproc: PDBPROCESS; Column: Integer): PAnsiChar; stdcall;
Fdbcoltype: function(dbproc: PDBPROCESS; Column: Integer): Integer; cdecl;
Fdbcoltype_stdcall: function(dbproc: PDBPROCESS; Column: Integer): Integer; stdcall;
Fdbcoltypeinfo: function(dbproc: PDBPROCESS; Column: Integer): PDBTYPEINFO; cdecl; //no MS
Fdbcoltypeinfo_stdcall: function(dbproc: PDBPROCESS; Column: Integer): PDBTYPEINFO; stdcall;
Fdbcolutype: function(dbproc: PDBPROCESS; Column: Integer): DBINT; cdecl;
Fdbcolutype_stdcall: function(dbproc: PDBPROCESS; Column: Integer): DBINT; stdcall;
Fdbconvert: function(dbproc: PDBPROCESS; SrcType: Integer; Src: PByte;
SrcLen: DBINT; DestType: Integer; Dest: PByte; DestLen: DBINT): Integer; cdecl;
Fdbconvert_stdcall: function(dbproc: PDBPROCESS; SrcType: Integer; Src: PByte;
SrcLen: DBINT; DestType: Integer; Dest: PByte; DestLen: DBINT): Integer; stdcall;
Fdbconvert_ps: function(dbproc: PDBPROCESS; SrcType: Integer; Src: PByte;
SrcLen: DBINT; DestType: Integer; Dest: PByte; DestLen: DBINT; typinfo: PDBTYPEINFO): Integer; cdecl; //NO MS
Fdbconvert_ps_stdcall: function(dbproc: PDBPROCESS; SrcType: Integer; Src: PByte;
SrcLen: DBINT; DestType: Integer; Dest: PByte; DestLen: DBINT; typinfo: PDBTYPEINFO): Integer; stdcall;
Fdbcount: function(dbproc: PDBPROCESS): DBINT; cdecl;
Fdbcount_stdcall: function(dbproc: PDBPROCESS): DBINT; stdcall;
Fdbcurcmd_MS: function(dbproc: PDBPROCESS): Integer; cdecl;
Fdbcurcmd_SYB: function(dbproc: PDBPROCESS): DBINT; cdecl;
Fdbcurcmd_stdcall: function(dbproc: PDBPROCESS): DBINT; stdcall;
Fdbcurrow: function(dbproc: PDBPROCESS): DBINT; cdecl;
Fdbcurrow_stdcall: function(dbproc: PDBPROCESS): DBINT; stdcall;
Fdbdata: function(dbproc: PDBPROCESS; Column: Integer): PByte; cdecl;
Fdbdata_stdcall: function(dbproc: PDBPROCESS; Column: Integer): PByte; stdcall;
//Fdbdatecrack: function(Proc: PDBPROCESS; DateInfo: PDBDATEREC; DateType: PDBDATETIME): RETCODE; cdecl;
//Fdbdatecrack_stdcall: function(Proc: PDBPROCESS; DateInfo: PDBDATEREC; DateType: PDBDATETIME): RETCODE; cdecl;
//Fdbdatecrack_TDS: function(dbproc: PDBPROCESS; DateInfo: PTDS_DBDATEREC; DateType: PTDSDBDATETIME): RETCODE; cdecl;
Fdbdatlen: function(dbproc: PDBPROCESS; Column: Integer): DBINT; cdecl;
Fdbdatlen_stdcall: function(dbproc: PDBPROCESS; Column: Integer): DBINT; stdcall;
Fdbdead_MS: function(dbroc: PDBPROCESS): LongBool; cdecl;
Fdbdead: function(dbroc: PDBPROCESS): DBBOOL; cdecl;
Fdbdead_stdcall: function(dbproc: PDBPROCESS): DBBOOL; stdcall;
Fdbexit: procedure; cdecl;
Fdbexit_stdcall: procedure; stdcall;
FdbHasRetStat_MS: function(dbProc: PDBPROCESS): LongBool; cdecl;
FdbHasRetStat_SYB: function(dbProc: PDBPROCESS): DBBOOL; cdecl;
FdbHasRetStat_stdcall: function(dbProc: PDBPROCESS): DBBOOL; stdcall;
{Fdbfcmd: function(Proc: PDBPROCESS; CmdString: PAnsiChar; var Params): RETCODE; cdecl;
Fdbfcmd_stdcall: function(Proc: PDBPROCESS; CmdString: PAnsiChar; var Params): RETCODE; stdcall;}
Fdbfirstrow: function(Proc: PDBPROCESS): DBINT; cdecl;
Fdbfirstrow_stdcall: function(Proc: PDBPROCESS): DBINT; stdcall;
Fdbfreebuf: procedure(Proc: PDBPROCESS); cdecl;
Fdbfreebuf_stdcall: procedure(Proc: PDBPROCESS); stdcall;
Fdbfreequal: procedure(Ptr: PAnsiChar); cdecl;
Fdbfreequal_stdcall: procedure(Ptr: PAnsiChar); stdcall;
Fdbgetchar: function(Proc: PDBPROCESS; N: Integer): PAnsiChar; cdecl;
Fdbgetchar_stdcall: function(Proc: PDBPROCESS; N: Integer): PAnsiChar; stdcall;
Fdbgetcharset: function(dbproc: PDBPROCESS): PAnsiChar; cdecl; //NO MS
Fdbgetcharset_stdcall: function(dbproc: PDBPROCESS): PAnsiChar; stdcall;
FdbGetRow: function(dbProc: PDBPROCESS; Row: DBINT): STATUS; cdecl;
FdbGetRow_stdcall: function(dbProc: PDBPROCESS; Row: DBINT): STATUS; stdcall;
FdbInit_MS: function: PAnsiChar; cdecl; //returns the librayversion
FdbInit: function: RETCODE; cdecl;
FdbInit_stdcall: function: RETCODE; stdcall; //SYBASE returns SUCCEED or FAIL
FdbLogin_stdcall: function: PLOGINREC; stdcall;
Fdbloginfree: procedure(loginptr: PLOGINREC); cdecl;
Fdbloginfree_stdcall: procedure(loginptr: PLOGINREC); stdcall;
FdbMoreCmds: function(dbProc: PDBPROCESS): RETCODE; cdecl;
FdbMoreCmds_stdcall: function(dbProc: PDBPROCESS): RETCODE; stdcall;
FdbName: function(dbProc: PDBPROCESS): PAnsiChar; cdecl;
FdbName_stdcall: function(dbProc: PDBPROCESS): PAnsiChar; stdcall;
FdbNextRow: function(dbProc: PDBPROCESS): STATUS; cdecl;
FdbNextRow_stdcall: function(dbProc: PDBPROCESS): STATUS; stdcall;
FdbNumCols: function(dbProc: PDBPROCESS): DBINT; cdecl;
FdbNumCols_stdcall: function(dbProc: PDBPROCESS): DBINT; stdcall;
FdbOpen: function(Login: PLOGINREC; server: PAnsiChar): PDBPROCESS; cdecl;
FdbOpen_stdcall: function(Login: PLOGINREC; server: PAnsiChar): PDBPROCESS; stdcall;
FtdsDbOpen: function(Login: PLOGINREC; server: PAnsiChar; msdblib: Integer): PDBPROCESS; cdecl;
FdbResults: function(dbProc: PDBPROCESS): RETCODE; cdecl;
FdbResults_stdcall: function(dbProc: PDBPROCESS): RETCODE; stdcall;
FdbRetData: function(dbProc: PDBPROCESS; RetNum: Integer): Pointer; cdecl;
FdbRetData_stdcall: function(dbProc: PDBPROCESS; RetNum: Integer): Pointer; stdcall;
FdbRetStatus: function(dbProc: PDBPROCESS): DBINT; cdecl;
FdbRetStatus_stdcall: function(dbProc: PDBPROCESS): DBINT; stdcall;
FdbRetType: function(dbProc: PDBPROCESS; RetNum: DBINT): DBINT; cdecl;
FdbRetType_stdcall: function(dbProc: PDBPROCESS; RetNum: DBINT): DBINT; stdcall;
{rpc i.e remote procedure calls }
FdbRpcInit: function(dbProc: PDBPROCESS; RpcName: PAnsiChar; Options: DBSMALLINT): RETCODE; cdecl;
FdbRpcInit_stdcall: function(dbProc: PDBPROCESS; RpcName: PAnsiChar; Options: DBSMALLINT): RETCODE; stdcall;
FdbRpcParam: function(dbProc: PDBPROCESS; ParamName: PAnsiChar; Status: Byte;
Type_: DBINT; MaxLen: DBINT; DataLen: DBINT; Value: Pointer): RETCODE; cdecl;
FdbRpcParam_stdcall: function(dbProc: PDBPROCESS; ParamName: PAnsiChar; Status: Byte;
Type_: DBINT; MaxLen: DBINT; DataLen: DBINT; Value: Pointer): RETCODE; stdcall;
FdbRpcSend: function(dbProc: PDBPROCESS): RETCODE; cdecl;
FdbRpcSend_stdcall: function(dbProc: PDBPROCESS): RETCODE; cdecl;
FdbRpcExec: function(dbProc: PDBPROCESS): RETCODE; cdecl; //MS only
FdbRetLen: function(dbProc: PDBPROCESS; RetNum: Integer): DBINT; cdecl;
FdbRetLen_stdcall: function(dbProc: PDBPROCESS; RetNum: Integer): DBINT; stdcall;
FdbRetName: function(dbProc: PDBPROCESS; RetNum: Integer): PAnsiChar; cdecl;
FdbRetName_stdcall: function(dbProc: PDBPROCESS; RetNum: Integer): PAnsiChar; stdcall;
FdbSqlExec: function(dbProc: PDBPROCESS): RETCODE; cdecl;
FdbSqlExec_stdcall: function(dbProc: PDBPROCESS): RETCODE; stdcall;
FdbSqlOk: function(dbProc: PDBPROCESS): RETCODE; cdecl;
FdbSqlOk_stdcall: function(dbProc: PDBPROCESS): RETCODE; stdcall;
Fdbsqlsend: function(dbProc: PDBPROCESS): RETCODE; cdecl;
Fdbsqlsend_stdcall: function(dbProc: PDBPROCESS): RETCODE; stdcall;
FdbSetLName: function(Login: PLOGINREC; Value: PAnsiChar; Item: Integer): RETCODE; cdecl;
FdbSetLName_stdcall: function(Login: PLOGINREC; Value: PAnsiChar; Item: Integer): RETCODE; stdcall;
FdbSetLoginTime: function(Seconds: Integer): RETCODE; cdecl;
FdbSetLoginTime_stdcall: function(Seconds: Integer): RETCODE; stdcall;
FdbSetOpt_MS: function(dbProc: PDBPROCESS; Option: Integer; Char_Param: PAnsiChar): RETCODE; cdecl;
FdbSetOpt_SYB: function(dbProc: PDBPROCESS; Option: Integer; Char_Param: PAnsiChar; Int_Param: Integer): RETCODE; cdecl;
FdbSetOpt_stdcall: function(dbProc: PDBPROCESS; Option: Integer; Char_Param: PAnsiChar; Int_Param: Integer): RETCODE; stdcall;
Fdbsetlpacket: function(Login: PLOGINREC; PacketSize: Word): RETCODE; cdecl; //MS only others use dbsetlname
FdbSetMaxprocs_S: function(MaxProcs: SmallInt): RETCODE; cdecl;
FdbSetMaxprocs_I: function(MaxProcs: DBINT): RETCODE; cdecl;
FdbSetMaxprocs_stdcall: function(MaxProcs: DBINT): RETCODE; stdcall; //sybase has widened the type!
FdbSetTime: function(Seconds: Integer): RETCODE; cdecl;
FdbSetTime_stdcall: function(Seconds: Integer): RETCODE; stdcall;
FdbUse: function(dbProc: PDBPROCESS; dbName: PAnsiChar): RETCODE; cdecl;
FdbUse_stdcall: function(dbProc: PDBPROCESS; dbName: PAnsiChar): RETCODE; stdcall;
Fdbvarylen_MS: function(Proc: PDBPROCESS; Column: Integer): LongBool; cdecl;
Fdbvarylen_SYB: function(Proc: PDBPROCESS; Column: Integer): DBBOOL; cdecl;
Fdbvarylen_stdcall: function(Proc: PDBPROCESS; Column: Integer): DBBOOL; stdcall;
Fdbversion: function(): PAnsiChar; cdecl;
Fdbversion_stdcall: function(): PAnsiChar; stdcall;
//Fdb12hour: function(dbproc: PDBPROCESS; Language: PAnsiChar): DBBOOL; cdecl; //no MS
//Fdb12hour_stdcall: function(dbproc: PDBPROCESS; Language: PAnsiChar): DBBOOL; stdcall; //no MS
dberrhandle_stdcall: function(Handler: TDBERRHANDLE_PROC_stdcall): TDBERRHANDLE_PROC_stdcall; stdcall;
dbmsghandle_stdcall: function(Handler: TDBMSGHANDLE_PROC_stdcall): TDBMSGHANDLE_PROC_stdcall; stdcall;
FdbSetVersion_stdcall: function(Version: DBINT): RETCODE; stdcall;
fdbWinexit: procedure; cdecl; // MS only
{$ENDIF}
//Fdbtds: function(dbproc: PDBPROCESS): DBINT; cdecl;
FdbLogin: function: PLOGINREC; cdecl;
private
FDBLibraryVendorType: TDBLibraryVendorType;
FdbSetVersion: function(Version: DBINT): RETCODE; cdecl;
protected
procedure LoadApi; override;
procedure LoadCodePages; override;
public
procedure AfterConstruction; override;
{$IFDEF TEST_CALLBACK}
procedure BeforeDestruction; override;
{$ENDIF TEST_CALLBACK}
destructor Destroy; override;
public //core
dberrhandle: function(Handler: TDBERRHANDLE_PROC_cdecl): TDBERRHANDLE_PROC_cdecl; cdecl;
dbmsghandle: function(Handler: TDBMSGHANDLE_PROC_cdecl): TDBMSGHANDLE_PROC_cdecl; cdecl;
dbsetlversion: function(Login: PLOGINREC; Version: Byte): RETCODE; cdecl; //just FreeTDS
tdsdump_on: procedure; cdecl;
tdsdump_off: procedure; cdecl;
tdsdump_open: function (FileName : PAnsiChar): Integer; cdecl;
tdsdump_close: procedure; cdecl;
//_tds_socket_init: procedure ; cdecl;
//_tds_socket_done: procedure ; cdecl;
{$IFDEF MSWINDOWS}
function dbadata(dbproc: PDBPROCESS; ComputeId, Column: Integer): PByte; {$IFDEF WITH_INLINE}inline;{$ENDIF}
function dbadlen(dbproc: PDBPROCESS; ComputeId, Column: Integer): DBINT; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbaltbind(dbproc: PDBPROCESS; ComputeId, Column, VarType: Integer;
VarLen: DBINT; VarAddr: PByte): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbaltbind_ps(dbproc: PDBPROCESS; ComputeId, Column: Integer; VarType: Integer;
VarLen: DBINT; VarAddr: PByte; typinfo: PDBTYPEINFO): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbaltcolid(dbproc: PDBPROCESS; ComputeId, Column: Integer): Integer; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbaltlen(dbproc: PDBPROCESS; ComputeId, Column: Integer): DBINT; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbaltop(dbproc: PDBPROCESS; ComputeId, Column: Integer): Integer; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbalttype(dbproc: PDBPROCESS; ComputeId, Column: Integer): Integer; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbaltutype(dbproc: PDBPROCESS; ComputeId, Column: Integer): DBINT; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbanullbind(dbproc: PDBPROCESS; ComputeId, Column: Integer; Indicator: PDBINT): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbbind(dbproc: PDBPROCESS; Column, VarType, VarLen: Integer; VarAddr: PByte): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbbind_ps(dbproc: PDBPROCESS; Column, VarType, VarLen: Integer; VarAddr: PByte; typinfo: PDBTYPEINFO): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}//no MS
function dbbufsize(dbproc: PDBPROCESS): Integer; {$IFDEF WITH_INLINE}inline; {$ENDIF}//no MS
function dbbylist(dbproc: PDBPROCESS; ComputeId: Integer; Size: PInteger): PByte; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbcancel(dbproc: PDBPROCESS): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbcanquery(dbproc: PDBPROCESS): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbchange(dbproc: PDBPROCESS): PAnsiChar; {$IFDEF WITH_INLINE}inline; {$ENDIF}
procedure dbclose(dbproc: PDBPROCESS); {$IFDEF WITH_INLINE}inline; {$ENDIF}
procedure dbclrbuf(dbproc: PDBPROCESS; N: DBINT); {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbclropt(dbproc: PDBPROCESS; Option: Integer; Param: PAnsiChar): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbcmd(dbproc: PDBPROCESS; Cmd: PAnsiChar): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbcmdrow(dbproc: PDBPROCESS): RETCODE;{$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbcolbrowse(dbproc: PDBPROCESS; Column: Integer): DBBOOL; {$IFDEF WITH_INLINE}inline; {$ENDIF}
public dbcolinfo: function(pdbhandle: PDBHANDLE; _Type: Integer; Column: DBINT; ComputeId: DBINT; lpdbcol: PDBCOL): RETCODE; cdecl;//no SYB but FreeTDS
public dbtablecolinfo: function(pdbhandle: PDBHANDLE; Column: DBINT; lpdbcol: PDBCOL): RETCODE; cdecl;//FreeTDS only!
function dbcollen(dbproc: PDBPROCESS; Column: Integer): DBINT; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbcolname(dbproc: PDBPROCESS; Column: Integer): PAnsiChar; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbcolsource(dbproc: PDBPROCESS; Column: Integer): PAnsiChar; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbcoltype(dbproc: PDBPROCESS; Column: Integer): Integer; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbcolutype(dbproc: PDBPROCESS; Column: Integer): DBINT; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbcoltypeinfo(dbproc: PDBPROCESS; Column: Integer): PDBTYPEINFO; {$IFDEF WITH_INLINE}inline; {$ENDIF}//no MS
function dbconvert(dbproc: PDBPROCESS; SrcType: Integer; Src: PByte;
SrcLen: DBINT; DestType: Integer; Dest: PByte; DestLen: DBINT): Integer; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbconvert_ps(dbproc: PDBPROCESS; SrcType: Integer; Src: PByte;
SrcLen: DBINT; DestType: Integer; Dest: PByte; DestLen: DBINT; typinfo: PDBTYPEINFO): Integer; {$IFDEF WITH_INLINE}inline; {$ENDIF}//no MS
function dbcount(dbproc: PDBPROCESS): DBINT; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbcurcmd(dbproc: PDBPROCESS): DBINT; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbcurrow(dbproc: PDBPROCESS): DBINT; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbdata(dbproc: PDBPROCESS; Column: Integer): PByte; {$IFDEF WITH_INLINE}inline; {$ENDIF}
public dbdataready: function(Proc: PDBPROCESS): LongBool; cdecl; //MS only
function dbdatlen(dbproc: PDBPROCESS; Column: Integer): DBINT; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbdead(dbproc: PDBPROCESS): DBBOOL; {$IFDEF WITH_INLINE}inline; {$ENDIF}
//public dbenlisttrans: function(Proc: PDBPROCESS; PurposeUnkonwn: Longbool): RETCODE; cdecl; //MS only purpose is unknown
procedure dbexit; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbSqlExec(dbProc: PDBPROCESS): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbSqlOk(dbProc: PDBPROCESS): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbsqlsend(dbProc: PDBPROCESS): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
//function dbfcmd(Proc: PDBPROCESS; CmdString: PAnsiChar; var Params): RETCODE;
function dbfirstrow(Proc: PDBPROCESS): DBINT; {$IFDEF WITH_INLINE}inline; {$ENDIF}
procedure dbfreebuf(Proc: PDBPROCESS); {$IFDEF WITH_INLINE}inline; {$ENDIF}
procedure dbfreequal(Ptr: PAnsiChar); {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbgetchar(Proc: PDBPROCESS; N: Integer): PAnsiChar; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbgetcharset(dbproc: PDBPROCESS): PAnsiChar;{$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbGetRow(dbProc: PDBPROCESS; Row: DBINT): STATUS; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbHasRetStat(dbProc: PDBPROCESS): DBBOOL; {$IFDEF WITH_INLINE}inline; {$ENDIF}
{$ENDIF}
function dbOpen(Login: PLOGINREC; server: PAnsiChar): PDBPROCESS; {$IFDEF WITH_INLINE}inline; {$ENDIF}
{$IFDEF MSWINDOWS}
procedure dbloginfree(loginptr: PLOGINREC); {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbMoreCmds(dbProc: PDBPROCESS): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbname(dbProc: PDBPROCESS): PAnsiChar; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbNextRow(dbProc: PDBPROCESS): STATUS; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbNumCols(dbProc: PDBPROCESS): DBINT; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbResults(dbProc: PDBPROCESS): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbRetData(dbProc: PDBPROCESS; RetNum: Integer): Pointer; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbRetStatus(dbProc: PDBPROCESS): DBINT; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbRetType(dbProc: PDBPROCESS; RetNum: DBINT): DBINT; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbRpcInit(dbProc: PDBPROCESS; RpcName: PAnsiChar; Options: DBSMALLINT): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbRpcParam(dbProc: PDBPROCESS; ParamName: PAnsiChar; Status: Byte;
Type_: DBINT; MaxLen: DBINT; DataLen: DBINT; Value: Pointer): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbRpcSend(dbProc: PDBPROCESS): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbRetLen(dbProc: PDBPROCESS; RetNum: Integer): DBINT; cdecl; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbRetName(dbProc: PDBPROCESS; RetNum: Integer): PAnsiChar; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbSetLoginTime(Seconds: Integer): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbSetLName(Login: PLOGINREC; Value: PAnsiChar; Item: Integer): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbSetMaxprocs(MaxProcs: SmallInt): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbSetTime(Seconds: Integer): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbSetOpt(dbProc: PDBPROCESS; Option: Integer; Char_Param: PAnsiChar; Int_Param: Integer): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbUse(dbProc: PDBPROCESS; dbName: PAnsiChar): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbVaryLen(dbProc: PDBPROCESS; Column: Integer): DBBOOL; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbVersion(): PAnsiChar; {$IFDEF WITH_INLINE}inline; {$ENDIF}
{$ENDIF}
public
{$IFNDEF MSWINDOWS}
dbadata: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): PByte; cdecl;
dbadlen: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): DBINT; cdecl;
dbaltbind: function(dbproc: PDBPROCESS; ComputeId, Column, VarType: Integer;
VarLen: DBINT; VarAddr: PByte): RETCODE; cdecl;
dbaltbind_ps: function(dbproc: PDBPROCESS; ComputeId, Column: Integer; VarType: Integer;
VarLen: DBINT; VarAddr: PByte; typinfo: PDBTYPEINFO): RETCODE; cdecl;
dbaltcolid: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): Integer; cdecl;
dbaltlen: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): DBINT; cdecl;
dbaltop: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): Integer; cdecl;
dbalttype: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): Integer; cdecl;
dbaltutype: function(dbproc: PDBPROCESS; ComputeId, Column: Integer): DBINT; cdecl;
dbanullbind: function(dbproc: PDBPROCESS; ComputeId, Column: Integer; Indicator: PDBINT): RETCODE; cdecl;
dbbind: function(dbproc: PDBPROCESS; Column, VarType, VarLen: Integer; VarAddr: PByte): RETCODE; cdecl;
dbbind_ps: function(dbproc: PDBPROCESS; Column, VarType, VarLen: Integer; VarAddr: PByte; typinfo: PDBTYPEINFO): RETCODE; cdecl;//no MS
dbbufsize: function(dbproc: PDBPROCESS): Integer; cdecl;//no MS
dbbylist: function(dbproc: PDBPROCESS; ComputeId: Integer; Size: PInteger): PByte; cdecl;
dbcancel: function(dbproc: PDBPROCESS): RETCODE; cdecl;
dbcanquery: function(dbproc: PDBPROCESS): RETCODE; cdecl;
dbchange: function(dbproc: PDBPROCESS): PAnsiChar; cdecl;
dbclose: procedure(dbproc: PDBPROCESS); cdecl;
dbclrbuf: procedure(dbproc: PDBPROCESS; N: DBINT); cdecl;
dbclropt: function(dbproc: PDBPROCESS; Option: Integer; Param: PAnsiChar): RETCODE; cdecl;
dbcmd: function(dbproc: PDBPROCESS; Cmd: PAnsiChar): RETCODE; cdecl;
dbcmdrow: function(dbproc: PDBPROCESS): RETCODE;cdecl;
dbcolbrowse: function(dbproc: PDBPROCESS; Column: Integer): DBBOOL; cdecl;
dbcolinfo: function(pdbhandle: PDBHANDLE; _Type: Integer; Column: DBINT; ComputeId: DBINT; lpdbcol: PDBCOL): RETCODE; cdecl;//no SYB but FreeTDS
dbtablecolinfo: function(pdbhandle: PDBHANDLE; Column: DBINT; lpdbcol: PDBCOL): RETCODE; cdecl;//FreeTDS only!!!
dbcollen: function(dbproc: PDBPROCESS; Column: Integer): DBINT; cdecl;
dbcolname: function(dbproc: PDBPROCESS; Column: Integer): PAnsiChar; cdecl;
dbcolsource: function(dbproc: PDBPROCESS; Column: Integer): PAnsiChar; cdecl;
dbcoltype: function(dbproc: PDBPROCESS; Column: Integer): Integer; cdecl;
dbcolutype: function(dbproc: PDBPROCESS; Column: Integer): DBINT; cdecl;
dbcoltypeinfo: function(dbproc: PDBPROCESS; Column: Integer): PDBTYPEINFO; cdecl;//no MS
dbconvert: function(dbproc: PDBPROCESS; SrcType: Integer; Src: PByte;
SrcLen: DBINT; DestType: Integer; Dest: PByte; DestLen: DBINT): Integer; cdecl;
dbconvert_ps: function(dbproc: PDBPROCESS; SrcType: Integer; Src: PByte;
SrcLen: DBINT; DestType: Integer; Dest: PByte; DestLen: DBINT; typinfo: PDBTYPEINFO): Integer; cdecl;//no MS
dbcount: function(dbproc: PDBPROCESS): DBINT; cdecl;
dbcurcmd: function(dbproc: PDBPROCESS): DBINT; cdecl;
dbcurrow: function(dbproc: PDBPROCESS): DBINT; cdecl;
dbdata: function(dbproc: PDBPROCESS; Column: Integer): PByte; cdecl;
dbdatlen: function(dbproc: PDBPROCESS; Column: Integer): DBINT; cdecl;
dbdead: function(dbproc: PDBPROCESS): DBBOOL; cdecl;
dbexit: procedure; cdecl;
dbHasRetStat: function(dbProc: PDBPROCESS): DBBOOL; cdecl;
dbSqlExec: function(dbProc: PDBPROCESS): RETCODE; cdecl;
dbSqlOk: function(dbProc: PDBPROCESS): RETCODE; cdecl;
dbsqlsend: function(dbProc: PDBPROCESS): RETCODE; cdecl;
//dbfcmd: function(Proc: PDBPROCESS; CmdString: PAnsiChar; var Params): RETCODE; cdecl;
dbfirstrow: function(Proc: PDBPROCESS): DBINT; cdecl;
dbfreebuf: procedure(Proc: PDBPROCESS); cdecl;
dbfreequal: procedure(Ptr: PAnsiChar); cdecl;
dbgetchar: function(Proc: PDBPROCESS; N: Integer): PAnsiChar; cdecl;
dbgetcharset: function(dbproc: PDBPROCESS): PAnsiChar; cdecl;
dbGetRow: function(dbProc: PDBPROCESS; Row: DBINT): STATUS; cdecl;
FdbInit: function: RETCODE; cdecl;
// Jan: renamed this to FdbOpen. I don't know how wo decide between calling
// tdsdbopen and dbopen otherwise.?
FdbOpen: function(Login: PLOGINREC; server: PAnsiChar): PDBPROCESS; cdecl;
FtdsDbOpen: function(Login: PLOGINREC; server: PAnsiChar; msdblib: Integer): PDBPROCESS; cdecl;
dbloginfree: procedure(loginptr: PLOGINREC); cdecl;
dbMoreCmds: function(dbProc: PDBPROCESS): RETCODE; cdecl;
dbname: function(dbProc: PDBPROCESS): PAnsiChar; cdecl;
dbNextRow: function(dbProc: PDBPROCESS): STATUS; cdecl;
dbNumCols: function(dbProc: PDBPROCESS): DBINT; cdecl;
dbResults: function(dbProc: PDBPROCESS): RETCODE; cdecl;
dbRetStatus: function(dbProc: PDBPROCESS): DBINT; cdecl;
dbRpcInit: function(dbProc: PDBPROCESS; RpcName: PAnsiChar; Options: DBSMALLINT): RETCODE; cdecl;
dbRpcParam: function(dbProc: PDBPROCESS; ParamName: PAnsiChar; Status: Byte;
Type_: DBINT; MaxLen: DBINT; DataLen: DBINT; Value: Pointer): RETCODE; cdecl;
dbRpcSend: function(dbProc: PDBPROCESS): RETCODE; cdecl;
dbRetData: function(dbProc: PDBPROCESS; RetNum: Integer): Pointer; cdecl;
dbRetLen: function(dbProc: PDBPROCESS; RetNum: Integer): DBINT; cdecl;
dbRetName: function(dbProc: PDBPROCESS; RetNum: Integer): PAnsiChar; cdecl;
dbRetType: function(dbProc: PDBPROCESS; RetNum: Integer): DBINT; cdecl;
dbSetLoginTime: function(Seconds: Integer): RETCODE; cdecl;
dbSetLName: function(Login: PLOGINREC; Value: PAnsiChar; Item: Integer): RETCODE; cdecl;
dbSetMaxprocs: function(MaxProcs: DBINT): RETCODE; cdecl;
dbSetTime: function(Seconds: DBINT): RETCODE; cdecl;
dbSetOpt: function(dbProc: PDBPROCESS; Option: Integer; Char_Param: PAnsiChar; Int_Param: Integer): RETCODE; cdecl;
dbUse: function(dbProc: PDBPROCESS; dbName: PAnsiChar): RETCODE; cdecl;
dbvarylen: function(Proc: PDBPROCESS; Column: Integer): DBBOOL; cdecl;
dbversion: function: PAnsiChar; cdecl;
{$ENDIF}
public { macros }
function dbSetLApp(Login: PLOGINREC; AppName: PAnsiChar): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbSetLHost(Login: PLOGINREC; HostName: PAnsiChar): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbSetLCharSet(Login: PLOGINREC; CharsetName: PAnsiChar): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbSetLNatLang(Login: PLOGINREC; NatLangName: PAnsiChar): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbSetLSecure(Login: PLOGINREC): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbSetLPacket(Login: PLOGINREC; packet_size: Word): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbSetLPwd(Login: PLOGINREC; Password: PAnsiChar): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbSetLUser(Login: PLOGINREC; UserName: PAnsiChar): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
public { incompatibility workarounds }
function dbRpcExec(dbProc: PDBPROCESS): RETCODE; {$IFDEF WITH_INLINE}inline; {$ENDIF}
function dbIntit: RETCODE;
function dbsetversion(Version: DBINT): RETCODE;
function dbLogin: PLOGINREC; virtual;
public //mapings from zeos to provider enums
function GetDBOption(AOption: TdbOption): DBINT;
public
{$IFDEF TEST_CALLBACK}
function GetErrorHandler(dbProc: PDBPROCESS; ADBERRHANDLE_PROC: TDBERRHANDLE_PROC): IZDBLibErrorHandler;
function GetMessageHandler(dbProc: PDBPROCESS; ADBMSGHANDLE_PROC: TDBMSGHANDLE_PROC): IZDBLibMessageHandler;
procedure DeRegisterErrorHandler(Const Handler: TDbLibErrorHandler);
procedure DeRegisterMessageHandler(Const Handler: TDbLibMessageHandler);
{$ELSE}
procedure AssignErrorMessages(dbProc: PDBPROCESS; DestErrors: TZDBLibErrorList; DestMessages: TZDBLibMessageList);
{$ENDIF TEST_CALLBACK}
public
property DBLibraryVendorType: TDBLibraryVendorType read fDBLibraryVendorType;
end;
TMSSQLDBLibPLainDriver = class(TZDBLIBPLainDriver, IZPlainDriver)
protected
procedure LoadCodePages; override;
function Clone: IZPlainDriver; override;
public
procedure AfterConstruction; override;
function GetProtocol: string; override;
function GetDescription: string; override;
end;
TSybaseDBLibPLainDriver = class(TZDBLIBPLainDriver, IZPlainDriver)
protected
procedure LoadCodePages; override;
function Clone: IZPlainDriver; override;
procedure LoadApi; override;
public
procedure AfterConstruction; override;
function GetProtocol: string; override;
function GetDescription: string; override;
end;
{$IFDEF TEST_CALLBACK}
//see: https://www.experts-exchange.com/questions/10414716/How-to-make-a-Callback-Procedure-Function-to-Procedure-Function-of-Object.html
//http://delphi.cjcsoft.net/viewthread.php?tid=45566
//https://entwickler-forum.de/forum/archiv/andere-sprachen-aa/delphi-aa/dll/25575-objekte-aus-callback-funktionen-ansprechen
TZMethodToDllCallbackProcedure = class(TZMethodToDllCallbackDispatcher)
private
{$IFDEF AUTOREFCOUNT}[weak]{$ENDIF}FManager: TZDBLIBPLainDriver;
public
constructor Create(const Instance: TObject; methodAddr: pointer;
const CallBackManager: TZDBLIBPLainDriver);
end;
TDbLibErrorHandler = class(TZMethodToDllCallbackProcedure, IZDBLibErrorHandler)
private
FHandle: PDBPROCESS;
{$IFDEF MSWINDOWS}
FOlddberrhandle_stdcall: TDBERRHANDLE_PROC_stdcall;
{$ENDIF MSWINDOWS}
FOlddberrhandle_cdecl: TDBERRHANDLE_PROC_cdecl;
FMydberrhandle: TDBERRHANDLE_PROC; //fastcall convention
{$IFDEF MSWINDOWS}
function dberrhandle_stdcall(Proc: PDBPROCESS; Severity, DbErr, OsErr: Integer;
DbErrStr, OsErrStr: PAnsiChar): Integer; stdcall;
{$ENDIF MSWINDOWS}
function dberrhandle_cdecl(Proc: PDBPROCESS; Severity, DbErr, OsErr: Integer;
DbErrStr, OsErrStr: PAnsiChar): Integer; cdecl;
public
Constructor Create(Handle: PDBPROCESS; DBERRHANDLE_PROC: TDBERRHANDLE_PROC;
const Manager: TZDBLIBPLainDriver);
procedure BeforeDestruction; override;
end;
TDbLibMessageHandler = class(TZMethodToDllCallbackProcedure, IZDBLibMessageHandler)
private
FHandle: PDBPROCESS;
{$IFDEF MSWINDOWS}
FOlddbmsghandle_stdcall: TDBMSGHANDLE_PROC_stdcall;
{$ENDIF MSWINDOWS}
FOlddbmsghandle_cdecl: TDBMSGHANDLE_PROC_cdecl;
FMydbmsghandle: TDBMSGHANDLE_PROC; //fastcall convention
{$IFDEF MSWINDOWS}
function dbmsghandle_stdcall(Proc: PDBPROCESS; MsgNo: DBINT; MsgState, Severity: Integer;
MsgText, SrvName, ProcName: PAnsiChar; Line: DBUSMALLINT): Integer; stdcall;
{$ENDIF MSWINDOWS}
function dbmsghandle_cdecl(Proc: PDBPROCESS; MsgNo: DBINT; MsgState, Severity: Integer;
MsgText, SrvName, ProcName: PAnsiChar; Line: DBUSMALLINT): Integer; cdecl;
public
Constructor Create(Handle: PDBPROCESS; DBMSGHANDLE_PROC: TDBMSGHANDLE_PROC;
const Manager: TZDBLIBPLainDriver);
procedure BeforeDestruction; override;
end;
{$ENDIF TEST_CALLBACK}
function TdsDateTimeAllGetPrecision(const Value: TDBDATETIMEALL): Integer;
function TdsDateTimeAllHasDate(const Value: TDBDATETIMEALL): Boolean;
function TdsDateTimeAllHasTime(const Value: TDBDATETIMEALL): Boolean;
function TdsDateTimeAllHasOffset(const Value: TDBDATETIMEALL): Boolean;
{$ENDIF ZEOS_DISABLE_DBLIB}
implementation
{$IFNDEF ZEOS_DISABLE_DBLIB}
uses SysUtils, ZPlainLoader, ZEncoding, ZFastCode;
var
OldFreeTDSErrorHandle: TDBERRHANDLE_PROC_cdecl = nil;
OldFreeTDSMessageHandle: TDBMSGHANDLE_PROC_cdecl = nil;
OldSybaseErrorHandle: {$IFDEF MSWINDOWS}TDBERRHANDLE_PROC_stdcall{$ELSE}TDBERRHANDLE_PROC_cdecl{$ENDIF} = nil;
OldSybaseMessageHandle: {$IFDEF MSWINDOWS}TDBMSGHANDLE_PROC_stdcall{$ELSE}TDBMSGHANDLE_PROC_cdecl{$ENDIF} = nil;
{$IFDEF MSWINDOWS}
OldMsSQLErrorHandle: TDBERRHANDLE_PROC_cdecl = nil;
OldMsSQLMessageHandle: TDBMSGHANDLE_PROC_cdecl = nil;
{$ENDIF MSWINDOWS}
ErrorCS: TCriticalSection;
SQLErrors: TZDBLibErrorList;
SQLMessages: TZDBLibMessageList;
procedure AddSybaseCodePages(PlainDriver: TZAbstractPlainDriver);
begin
// codepages as found in "SAP Adaptive Server Enterprise 16.0 > Configuration Guide for UNIX Adaptive Server Enterprise 16.0 > Localization Support"
PlainDriver.AddCodePage('ascii_8', 1, ceAnsi, zCP_us_ascii);
PlainDriver.AddCodePage('big5', 2, ceAnsi, zCP_Big5);
PlainDriver.AddCodePage('cp437', 3, ceAnsi, zCP_DOS437);
PlainDriver.AddCodePage('cp850', 4, ceAnsi, zCP_DOS850);
PlainDriver.AddCodePage('cp852', 5, ceAnsi, zCP_DOS852);
PlainDriver.AddCodePage('cp855', 6, ceAnsi, zCP_DOS855);
PlainDriver.AddCodePage('cp857', 7, ceAnsi, zCP_DOS857);
PlainDriver.AddCodePage('cp858', 8, ceAnsi, zCP_DOS858);
PlainDriver.AddCodePage('cp860', 9, ceAnsi, zCP_DOS860);
PlainDriver.AddCodePage('cp864', 10, ceAnsi, zCP_DOS864);
PlainDriver.AddCodePage('cp866', 11, ceAnsi, zCP_DOS866);
PlainDriver.AddCodePage('cp869', 12, ceAnsi, zCP_DOS869);
PlainDriver.AddCodePage('cp874', 13, ceAnsi, zCP_WIN874);
PlainDriver.AddCodePage('cp932', 14, ceAnsi, zCP_SHIFTJS);
PlainDriver.AddCodePage('cp936', 15, ceAnsi, zCP_GB2312);
PlainDriver.AddCodePage('cp950', 16, ceAnsi, zCP_Big5);
PlainDriver.AddCodePage('cp1250', 17, ceAnsi, zCP_WIN1250);
PlainDriver.AddCodePage('cp1251', 18, ceAnsi, zCP_WIN1251);
PlainDriver.AddCodePage('cp1252', 19, ceAnsi, zCP_WIN1252);
PlainDriver.AddCodePage('cp1253', 20, ceAnsi, zCP_WIN1253);
PlainDriver.AddCodePage('cp1254', 21, ceAnsi, zCP_WIN1254);
PlainDriver.AddCodePage('cp1255', 22, ceAnsi, zCP_WIN1255);
PlainDriver.AddCodePage('cp1256', 23, ceAnsi, zCP_WIN1256);
PlainDriver.AddCodePage('cp1257', 24, ceAnsi, zCP_WIN1257);
PlainDriver.AddCodePage('cp1258', 25, ceAnsi, zCP_WIN1258);
PlainDriver.AddCodePage('gb18030', 26, ceAnsi, zCP_GB18030);
PlainDriver.AddCodePage('iso_1', 27, ceAnsi, zCP_L1_ISO_8859_1);
PlainDriver.AddCodePage('iso88592', 28, ceAnsi, zCP_L2_ISO_8859_2);
PlainDriver.AddCodePage('iso88595', 29, ceAnsi, zCP_L5_ISO_8859_5);
PlainDriver.AddCodePage('iso88596', 30, ceAnsi, zCP_L6_ISO_8859_6);
PlainDriver.AddCodePage('iso88597', 31, ceAnsi, zCP_L7_ISO_8859_7);
PlainDriver.AddCodePage('iso88598', 32, ceAnsi, zCP_L8_ISO_8859_8);
PlainDriver.AddCodePage('iso88599', 33, ceAnsi, zCP_L5_ISO_8859_9);
PlainDriver.AddCodePage('iso15', 34, ceAnsi, zCP_L9_ISO_8859_15);
PlainDriver.AddCodePage('sjis', 35, ceAnsi, zCP_SHIFTJS);
PlainDriver.AddCodePage('utf8', 36, ceUTF8, zCP_UTF8);
end;
procedure AddmMSCodePages(PlainDriver: TZAbstractPlainDriver);
begin
{ SingleByte }
PlainDriver.AddCodePage('WINDOWS-1250', 1, ceAnsi, zCP_WIN1250, '', 1, False); {Microsoft Windows Codepage 1250 (East European)}
PlainDriver.AddCodePage('WINDOWS-1251', 2, ceAnsi, zCP_WIN1251, '', 1, False); {Microsoft Windows Codepage 1251 (Cyrl)}
PlainDriver.AddCodePage('WINDOWS-1252', 3, ceAnsi, zCP_WIN1252, '', 1, False); {Microsoft Windows Codepage 1252 (ANSI), USASCCI}
PlainDriver.AddCodePage('WINDOWS-1253', 4, ceAnsi, zCP_WIN1253, '', 1, False); {Microsoft Windows Codepage 1253 (Greek)}
PlainDriver.AddCodePage('WINDOWS-1254', 5, ceAnsi, zCP_WIN1254, '', 1, False); {Microsoft Windows Codepage 1254 (Turk)}
PlainDriver.AddCodePage('WINDOWS-1255', 6, ceAnsi, zCP_WIN1255, '', 1, False); {Microsoft Windows Codepage 1255 (Hebrew)}
PlainDriver.AddCodePage('WINDOWS-1256', 7, ceAnsi, zCP_WIN1256, '', 1, False); {Microsoft Windows Codepage 1256 (Arab)}
PlainDriver.AddCodePage('WINDOWS-1257', 8, ceAnsi, zCP_WIN1257, '', 1, False); {Microsoft Windows Codepage 1257 (BaltRim)}
PlainDriver.AddCodePage('WINDOWS-1258', 9, ceAnsi, zCP_WIN1258, '', 1, False); {Microsoft Windows Codepage 1258 (Viet), TCVN-5712}
end;
{ Handle sql server error messages }
function SybaseErrorHandle(dbproc: PDBPROCESS; Severity, DbErr, OsErr: Integer;
DbErrStr, OsErrStr: PAnsiChar): Integer;
{$IFDEF MSWINDOWS} stdcall {$ELSE} cdecl {$ENDIF};
var
SqlError: PDBLibError;
Index: NativeInt;
begin
ErrorCS.Enter;
try
SqlError := SQLErrors.Add(Index);
SqlError.dbProc := dbproc;
SqlError.Severity := Severity;
SqlError.DbErr := DbErr;
SqlError.OsErr := OsErr;
if DbErrStr <> nil then
ZSetString(DbErrStr, StrLen(DbErrStr), SqlError.DbErrStr);
if OsErrStr <> nil then
ZSetString(OsErrStr, StrLen(OsErrStr), SqlError.OsErrStr);
finally
Result := INT_CANCEL;
ErrorCS.Leave;
end;
end;
{ Handle sql server messages }
function SybaseMessageHandle(dbproc: PDBPROCESS; MsgNo: DBINT; MsgState,
Severity: Integer; MsgText, SrvName, ProcName: PAnsiChar; Line: DBUSMALLINT):
Integer; {$IFDEF MSWINDOWS} stdcall {$ELSE} cdecl {$ENDIF};
var
SQLMessage: PDBLibMessage;
Index: NativeInt;
begin
ErrorCS.Enter;
try
SQLMessage := SQLMessages.Add(Index);
SQLMessage.dbProc := dbproc;
SQLMessage.MsgNo := MsgNo;
SQLMessage.MsgState := MsgState;
SQLMessage.Severity := Severity;
if MsgText <> nil then
ZSetString(MsgText, StrLen(MsgText), SQLMessage.MsgText);
if SrvName <> nil then
ZSetString(SrvName, StrLen(SrvName), SQLMessage.SrvName);
if ProcName <> nil then
ZSetString(ProcName, StrLen(ProcName), SQLMessage.ProcName);
SQLMessage.Line := Line;
finally
Result := 0;
ErrorCS.Leave;
end;
end;
{ Handle sql server error messages }
function DbLibErrorHandle(dbproc: PDBPROCESS; Severity, DbErr, OsErr: Integer;
DbErrStr, OsErrStr: PAnsiChar): Integer; cdecl;
var
SqlError: PDBLibError;
Index: NativeInt;
begin
ErrorCS.Enter;
try
SqlError := SQLErrors.Add(Index);
SqlError.dbProc := dbproc;
SqlError.Severity := Severity;
SqlError.DbErr := DbErr;
SqlError.OsErr := OsErr;
if DbErrStr <> nil then
ZSetString(DbErrStr, StrLen(DbErrStr),SqlError.DbErrStr);
if OsErrStr <> nil then
ZSetString(OsErrStr, StrLen(OsErrStr),SqlError.OsErrStr);
finally
Result := INT_CANCEL;
ErrorCS.Leave;
end;
end;
{ Handle sql server messages }
function DbLibMessageHandle(dbproc: PDBPROCESS; MsgNo: DBINT; MsgState, Severity: Integer;
MsgText, SrvName, ProcName: PAnsiChar; Line: DBUSMALLINT): Integer; cdecl;
var
SQLMessage: PDBLibMessage;
Index: NativeInt;
begin
ErrorCS.Enter;
try
SQLMessage := SQLMessages.Add(Index);
SQLMessage.dbProc := dbproc;
SQLMessage.MsgNo := MsgNo;
SQLMessage.MsgState := MsgState;
SQLMessage.Severity := Severity;
if MsgText <> nil then
ZSetString(MsgText, StrLen(MsgText), SQLMessage.MsgText);
if SrvName <> nil then
ZSetString(SrvName, StrLen(SrvName), SQLMessage.SrvName);
if ProcName <> nil then
ZSetString(ProcName, StrLen(ProcName), SQLMessage.ProcName);
SQLMessage.Line := Line;
finally
Result := 0;
ErrorCS.Leave;
end;
end;
{ Handle sql server error messages }
function FreeTDSErrorHandle(dbproc: PDBPROCESS; Severity, DbErr, OsErr: Integer;
DbErrStr, OsErrStr: PAnsiChar): Integer; cdecl;
var
SqlError: PDBLibError;
Index: NativeInt;
begin
ErrorCS.Enter;
try
SqlError := SQLErrors.Add(Index);
SqlError.dbProc := dbproc;
SqlError.Severity := Severity;
SqlError.DbErr := DbErr;
SqlError.OsErr := OsErr;
if DbErrStr <> nil then
ZSetString(DbErrStr, StrLen(DbErrStr),SqlError.DbErrStr);
if OsErrStr <> nil then
ZSetString(OsErrStr, StrLen(OsErrStr),SqlError.OsErrStr);
finally
Result := INT_CANCEL;
ErrorCS.Leave;
end;
end;
{ Handle sql server messages }
function FreeTDSMessageHandle(dbproc: PDBPROCESS; MsgNo: DBINT; MsgState, Severity: Integer;
MsgText, SrvName, ProcName: PAnsiChar; Line: DBUSMALLINT): Integer; cdecl;
var
SQLMessage: PDBLibMessage;
Index: NativeInt;
begin
ErrorCS.Enter;
try
SQLMessage := SQLMessages.Add(Index);
SQLMessage.dbProc := dbproc;
SQLMessage.MsgNo := MsgNo;
SQLMessage.MsgState := MsgState;
SQLMessage.Severity := Severity;
if MsgText <> nil then
ZSetString(MsgText, StrLen(MsgText), SQLMessage.MsgText);
if SrvName <> nil then
ZSetString(SrvName, StrLen(SrvName), SQLMessage.SrvName);
if ProcName <> nil then
ZSetString(ProcName, StrLen(ProcName), SQLMessage.ProcName);
SQLMessage.Line := Line;
finally
Result := 0;
ErrorCS.Leave;
end;
end;
{ TZDBLIBPLainDriver }
(** Return a pointer to the data for a compute column *)
procedure TZDBLIBPLainDriver.AfterConstruction;
begin
inherited;
FLoader := TZNativeLibraryLoader.Create([]);
{$IFDEF TEST_CALLBACK}
FSQLErrorHandlerList := TZDBLibErrorList.Create;
FSQLMessageHandlerList := TZDBLibMessageList.Create;
FCS := TCriticalSection.Create;
{$ENDIF}
FLoader.AddLocation('sybdb'+SharedSuffix);
LoadCodePages;
end;
{$IFDEF TEST_CALLBACK}
procedure TZDBLIBPLainDriver.BeforeDestruction;
var I: Integer;
begin
inherited;
for i := FSQLErrorHandlerList.Count-1 downto 0 do
Dispose(PDBLibError(FSQLErrorHandlerList[i]));
FreeAndNil(FSQLErrorHandlerList);
for i := FSQLMessageHandlerList.Count-1 downto 0 do
Dispose(PDBLibMessage(FSQLMessageHandlerList[i]));
FreeAndNil(FSQLMessageHandlerList);
FCS.Free;
end;
{$ELSE TEST_CALLBACK}
procedure TZDBLIBPLainDriver.AssignErrorMessages(dbProc: PDBPROCESS;
DestErrors: TZDBLibErrorList; DestMessages: TZDBLibMessageList);
var I: Integer;
Src, Dest: Pointer;
Index: NativeInt;
begin
ErrorCS.Enter;
try
for i := SQLErrors.Count -1 downto 0 do
if (dbProc = nil) or (PDBLibError(SQLErrors[i]).dbProc = dbProc) then begin
Dest := DestErrors.Add(Index);
Src := SQLErrors[i];
Move(Src^, Dest^, SizeOf(TDBLibError));
FillChar(Src^, SizeOf(TDBLibError), #0);
SQLErrors.Delete(i);
end;
for i := SQLMessages.Count -1 downto 0 do
if (dbProc = nil) or (PDBLibMessage(SQLMessages[i]).dbProc = dbProc) then begin
Dest := DestMessages.Add(Index);
Src := SQLMessages[i];
Move(Src^, Dest^, SizeOf(TDBLibMessage));
FillChar(Src^, SizeOf(TDBLibMessage), #0);
SQLMessages.Delete(i);
end;
finally
ErrorCS.Leave;
end;
end;
{$ENDIF TEST_CALLBACK}
{$IFDEF MSWINDOWS}
function TZDBLIBPLainDriver.dbadata(dbproc: PDBPROCESS; ComputeId,
Column: Integer): PByte;
begin
if Assigned(Fdbadata)
then Result := Fdbadata(dbproc, ComputeID, Column)
else Result := Fdbadata_stdcall(dbproc, ComputeID, Column)
end;
(** Return the actual length of the data for a compute column *)
function TZDBLIBPLainDriver.dbadlen(dbproc: PDBPROCESS; ComputeId,
Column: Integer): DBINT;
begin
if Assigned(Fdbadlen)
then Result := Fdbadlen(dbproc, ComputeID, Column)
else Result := Fdbadlen_stdcall(dbproc, ComputeID, Column);
end;
(** Bind a compute column to a program variable *)
function TZDBLIBPLainDriver.dbaltbind(dbproc: PDBPROCESS; ComputeId,
Column, VarType: Integer; VarLen: DBINT; VarAddr: PByte): RETCODE;
begin
if Assigned(Fdbaltbind)
then Result := Fdbaltbind(dbproc, ComputeID, Column, VarType, VarLen, VarAddr)
else Result := Fdbaltbind_stdcall(dbproc, ComputeID, Column, VarType, VarLen, VarAddr)
end;
(** Bind a compute column to a program variable,
with precision and scale support for numeric and decimal datatypes *)
function TZDBLIBPLainDriver.dbaltbind_ps(dbproc: PDBPROCESS; ComputeId,
Column, VarType: Integer; VarLen: DBINT; VarAddr: PByte;
typinfo: PDBTYPEINFO): RETCODE;
begin
if Assigned(Fdbaltbind_ps)
then Result := Fdbaltbind_ps(dbproc, ComputeID, Column, VarType, VarLen, VarAddr, typinfo)
else Result := Fdbaltbind_ps_stdcall(dbproc, ComputeID, Column, VarType, VarLen, VarAddr, typinfo)
end;
(** Return the column ID for a compute column *)
function TZDBLIBPLainDriver.dbaltcolid(dbproc: PDBPROCESS; ComputeId,
Column: Integer): Integer;
begin
if Assigned(Fdbaltcolid)
then Result := Fdbaltcolid(dbproc, ComputeID, Column)
else Result := Fdbaltcolid_stdcall(dbproc, ComputeID, Column)
end;
(** Return the maximum length of the data for a particular compute column *)
function TZDBLIBPLainDriver.dbaltlen(dbproc: PDBPROCESS; ComputeId,
Column: Integer): DBINT;
begin
if Assigned(Fdbaltlen)
then Result := Fdbaltlen(dbproc, ComputeID, Column)
else Result := Fdbaltlen_stdcall(dbproc, ComputeID, Column)
end;
(** Return the type of aggregate operator for a particular compute column *)
function TZDBLIBPLainDriver.dbaltop(dbproc: PDBPROCESS; ComputeId,
Column: Integer): Integer;
begin
if Assigned(Fdbaltop)
then Result := Fdbaltop(dbproc, ComputeID, Column)
else Result := Fdbaltop_stdcall(dbproc, ComputeID, Column)
end;
(** Return the datatype for a compute column *)
function TZDBLIBPLainDriver.dbalttype(dbproc: PDBPROCESS; ComputeId,
Column: Integer): Integer;
begin
if Assigned(Fdbalttype)
then Result := Fdbalttype(dbproc, ComputeID, Column)
else Result := Fdbalttype_stdcall(dbproc, ComputeID, Column)
end;
(** Return the user-defined datatype for a compute column *)
function TZDBLIBPLainDriver.dbaltutype(dbproc: PDBPROCESS; ComputeId,
Column: Integer): DBINT;
begin
if Assigned(Fdbaltutype)
then Result := Fdbaltutype(dbproc, ComputeID, Column)
else Result := Fdbaltutype_stdcall(dbproc, ComputeID, Column)
end;
(** Associate an indicator variable with a compute-row column *)
function TZDBLIBPLainDriver.dbanullbind(dbproc: PDBPROCESS; ComputeId,
Column: Integer; Indicator: PDBINT): RETCODE;
begin
if Assigned(Fdbanullbind)
then Result := Fdbanullbind(dbproc, ComputeID, Column, Indicator)
else Result := Fdbanullbind_stdcall(dbproc, ComputeID, Column, Indicator)
end;
(** Bind a regular result column to a program variable *)
function TZDBLIBPLainDriver.dbbind(dbproc: PDBPROCESS; Column, VarType,
VarLen: Integer; VarAddr: PByte): RETCODE;
begin
if Assigned(Fdbbind)
then Result := Fdbbind(dbproc, Column, VarType, VarLen, VarAddr)
else Result := Fdbbind_stdcall(dbproc, Column, VarType, VarLen, VarAddr)
end;
(** Bind a regular result column to a program variable,
with precision and scale support for numeric and decimal datatypes *)
function TZDBLIBPLainDriver.dbbind_ps(dbproc: PDBPROCESS; Column,
VarType, VarLen: Integer; VarAddr: PByte; typinfo: PDBTYPEINFO): RETCODE;
begin
if Assigned(Fdbbind_ps)
then Result := Fdbbind_ps(dbproc, Column, VarType, VarLen, VarAddr, typinfo)
else Result := Fdbbind_ps_stdcall(dbproc, Column, VarType, VarLen, VarAddr, typinfo)
end;
(** Return the size of a DBPROCESS row buffer *)
function TZDBLIBPLainDriver.dbbufsize(dbproc: PDBPROCESS): Integer;
begin
if Assigned(Fdbbufsize)
then Result := Fdbbufsize(dbproc)
else Result := Fdbbufsize_stdcall(dbproc)
end;
(** Return the bylist for a compute row *)
function TZDBLIBPLainDriver.dbbylist(dbproc: PDBPROCESS;
ComputeId: Integer; Size: PInteger): PByte;
begin
if Assigned(Fdbbylist)
then Result := Fdbbylist(dbproc, ComputeId, Size)
else Result := Fdbbylist_stdcall(dbproc, ComputeId, Size)
end;
(** Cancel the current command batch *)
function TZDBLIBPLainDriver.dbcancel(dbproc: PDBPROCESS): RETCODE;
begin
if Assigned(Fdbcancel)
then Result := Fdbcancel(dbproc)
else Result := Fdbcancel_stdcall(dbproc)
end;
(** Cancel any rows pending from the most recently executed query *)
function TZDBLIBPLainDriver.dbcanquery(dbproc: PDBPROCESS): RETCODE;
begin
if Assigned(Fdbcanquery)
then Result := Fdbcanquery(dbproc)
else Result := Fdbcanquery_stdcall(dbproc)
end;
(** Determine whether a command batch has changed the current database *)
function TZDBLIBPLainDriver.dbchange(dbproc: PDBPROCESS): PAnsiChar;
begin
if Assigned(Fdbchange)
then Result := Fdbchange(dbproc)
else Result := Fdbchange_stdcall(dbproc)
end;
(** Close and deallocate a single DBPROCESS structure *)
procedure TZDBLIBPLainDriver.dbclose(dbproc: PDBPROCESS);
begin
if Assigned(Fdbclose_ms) then
Fdbclose_ms(dbproc)
else if Assigned(Fdbclose_stdcall) then
Fdbclose_stdcall(dbproc)
else Fdbclose_SYB(dbproc);
end;
(** Drop rows from the row buffer *)
procedure TZDBLIBPLainDriver.dbclrbuf(dbproc: PDBPROCESS; N: DBINT);
begin
if Assigned(Fdbclrbuf)
then Fdbclrbuf(dbproc, N)
else Fdbclrbuf_stdcall(dbproc, n)
end;
(** Clear an option set by dbsetopt *)
function TZDBLIBPLainDriver.dbclropt(dbproc: PDBPROCESS; Option: Integer;
Param: PAnsiChar): RETCODE;
begin
if Assigned(Fdbclropt)
then Result := Fdbclropt(dbproc, Option, Param)
else Result := Fdbclropt_stdcall(dbproc, Option, Param)
end;
(** Add text to the DBPROCESS command buffer *)
function TZDBLIBPLainDriver.dbcmd(dbproc: PDBPROCESS;
Cmd: PAnsiChar): RETCODE;
begin
if Assigned(Fdbcmd)
then Result := Fdbcmd(dbproc, Cmd)
else Result := Fdbcmd_stdcall(dbproc, Cmd)
end;
(** Determine whether the current command can return rows *)
function TZDBLIBPLainDriver.dbcmdrow(dbproc: PDBPROCESS): RETCODE;
begin
if Assigned(Fdbcmdrow)
then Result := Fdbcmdrow(dbproc)
else Result := Fdbcmdrow_stdcall(dbproc)
end;
(** Determine whether the source of a regular result column is updatable
through the DB-Library browse-mode facilities *)
function TZDBLIBPLainDriver.dbcolbrowse(dbproc: PDBPROCESS;
Column: Integer): DBBOOL;
begin
if Assigned(Fdbcolbrowse_SYB) then
Result := Fdbcolbrowse_SYB(dbproc, Column)
else if Assigned(Fdbcolbrowse_MS) then
Result := Ord(Fdbcolbrowse_MS(dbproc, Column))
else
Result := Fdbcolbrowse_stdcall(dbproc, Column)
end;
(** Return the maximum length of the data in a regular result column *)
function TZDBLIBPLainDriver.dbcollen(dbproc: PDBPROCESS;
Column: Integer): DBINT;
begin
if Assigned(Fdbcollen)
then Result := Fdbcollen(dbproc, Column)
else Result := Fdbcollen_stdcall(dbproc, Column)
end;
(** Return the name of a regular result column *)
function TZDBLIBPLainDriver.dbcolname(dbproc: PDBPROCESS;
Column: Integer): PAnsiChar;
begin
if Assigned(Fdbcolname)
then Result := Fdbcolname(dbproc, Column)
else Result := Fdbcolname_stdcall(dbproc, Column)
end;
(** Return a pointer to the name of the database column from which the
specified regular result column was derived *)
function TZDBLIBPLainDriver.dbcolsource(dbproc: PDBPROCESS;
Column: Integer): PAnsiChar;
begin
if Assigned(Fdbcolsource)
then Result := Fdbcolsource(dbproc, Column)
else Result := Fdbcolsource_stdcall(dbproc, Column)
end;
(** Return the datatype for a regular result column *)
function TZDBLIBPLainDriver.dbcoltype(dbproc: PDBPROCESS;
Column: Integer): Integer;
begin
if Assigned(Fdbcoltype)
then Result := Fdbcoltype(dbproc, Column)
else Result := Fdbcoltype_stdcall(dbproc, Column)
end;
(** Return precision and scale information for a regular
result column of type numeric or decimal. *)
function TZDBLIBPLainDriver.dbcoltypeinfo(dbproc: PDBPROCESS;
Column: Integer): PDBTYPEINFO;
begin
if Assigned(Fdbcoltypeinfo)
then Result := Fdbcoltypeinfo(dbproc, Column)
else Result := Fdbcoltypeinfo_stdcall(dbproc, Column)
end;
(** Return the user-defined datatype for a regular result column *)
function TZDBLIBPLainDriver.dbcolutype(dbproc: PDBPROCESS;
Column: Integer): DBINT;
begin
if Assigned(Fdbcolutype)
then Result := Fdbcolutype(dbproc, Column)
else Result := Fdbcolutype_stdcall(dbproc, Column)
end;
(** Convert data from one datatype to another *)
function TZDBLIBPLainDriver.dbconvert(dbproc: PDBPROCESS; SrcType: Integer;
Src: PByte; SrcLen: DBINT; DestType: Integer; Dest: PByte;
DestLen: DBINT): Integer;
begin
if Assigned(Fdbconvert)
then Result := Fdbconvert(dbproc, SrcType, Src, SrcLen, DestType, Dest, DestLen)
else Result := Fdbconvert_stdcall(dbproc, SrcType, Src, SrcLen, DestType, Dest, DestLen)
end;
(** Convert data from one datatype to another, with precision and scale
support for numeric and decimal datatypes *)
function TZDBLIBPLainDriver.dbconvert_ps(dbproc: PDBPROCESS;
SrcType: Integer; Src: PByte; SrcLen: DBINT; DestType: Integer; Dest: PByte;
DestLen: DBINT; typinfo: PDBTYPEINFO): Integer;
begin
if Assigned(Fdbconvert_ps)
then Result := Fdbconvert_ps(dbproc, SrcType, Src, SrcLen, DestType, Dest, DestLen, typinfo)
else Result := Fdbconvert_ps_stdcall(dbproc, SrcType, Src, SrcLen, DestType, Dest, DestLen, typinfo)
end;
(** Returns the number of rows affected by a Transact-SQL command *)
function TZDBLIBPLainDriver.dbcount(dbproc: PDBPROCESS): DBINT;
begin
if Assigned(Fdbcount)
then Result := Fdbcount(dbproc)
else Result := Fdbcount_stdcall(dbproc);
end;
(** Return the number of the current command *)
function TZDBLIBPLainDriver.dbcurcmd(dbproc: PDBPROCESS): DBINT;
begin
if Assigned(Fdbcurcmd_SYB) then
Result := Fdbcurcmd_SYB(dbproc)
else if Assigned(Fdbcurcmd_MS) then
Result := Fdbcurcmd_MS(dbproc)
else Result := Fdbcurcmd_stdcall(dbproc)
end;
(** Return the number of the row currently being read *)
function TZDBLIBPLainDriver.dbcurrow(dbproc: PDBPROCESS): DBINT;
begin
if Assigned(Fdbcurrow)
then Result := Fdbcurrow(dbproc)
else Result := Fdbcurrow_stdcall(dbproc)
end;
(** Return a pointer to the data in a regular result column *)
function TZDBLIBPLainDriver.dbdata(dbproc: PDBPROCESS;
Column: Integer): PByte;
begin
if Assigned(Fdbdata)
then Result := Fdbdata(dbproc, Column)
else Result := Fdbdata_stdcall(dbproc, Column)
end;
(** Return the length of the data in a regular result column *)
function TZDBLIBPLainDriver.dbdatlen(dbproc: PDBPROCESS;
Column: Integer): DBINT;
begin
if Assigned(Fdbdatlen)
then Result := Fdbdatlen(dbproc, Column)
else Result := Fdbdatlen_stdcall(dbproc, Column)
end;
(** Determine whether a particular DBPROCESS is dead *)
function TZDBLIBPLainDriver.dbdead(dbproc: PDBPROCESS): DBBOOL;
begin
if Assigned(Fdbdead)
then Result := Fdbdead(dbproc)
else if Assigned(Fdbdead_MS)
then Result := Ord(Fdbdead_MS(dbproc))
else Result := Fdbdead_stdcall(dbproc);
end;
(** Close and deallocate all DBPROCESS structures,
and clean up any structures initialized by dbinit. *)
procedure TZDBLIBPLainDriver.dbexit;
begin
if Assigned(Fdbexit)
then Fdbexit
else Fdbexit_stdcall;
end;
(** Return the number of the first row in the row buffer *)
function TZDBLIBPLainDriver.dbfirstrow(Proc: PDBPROCESS): DBINT;
begin
if Assigned(Fdbfirstrow)
then Result := Fdbfirstrow(Proc)
else Result := Fdbfirstrow_stdcall(Proc);
end;
(** Clear the command buffer *)
procedure TZDBLIBPLainDriver.dbfreebuf(Proc: PDBPROCESS);
begin
if Assigned(Fdbfreebuf)
then Fdbfreebuf(Proc)
else Fdbfreebuf_stdcall(Proc);
end;
(** Free the memory allocated by dbqual *)
procedure TZDBLIBPLainDriver.dbfreequal(Ptr: PAnsiChar);
begin
if Assigned(Fdbfreequal)
then Fdbfreequal(Ptr)
else Fdbfreequal_stdcall(Ptr);
end;
(** Return a pointer to a character in the command buffer. *)
function TZDBLIBPLainDriver.dbgetchar(Proc: PDBPROCESS;
N: Integer): PAnsiChar;
begin
if Assigned(Fdbgetchar)
then Result := Fdbgetchar(Proc, N)
else Result := Fdbgetchar_stdcall(Proc, N);
end;
(** Get the name of the client character set from the DBPROCESS structure *)
function TZDBLIBPLainDriver.dbgetcharset(dbproc: PDBPROCESS): PAnsiChar;
begin
if Assigned(Fdbgetcharset)
then Result := Fdbgetcharset(dbproc)
else Result := Fdbgetcharset_stdcall(dbproc);
end;
{** Read the specified row in the row buffer. *}
function TZDBLIBPLainDriver.dbGetRow(dbProc: PDBPROCESS; Row: DBINT): STATUS;
begin
if Assigned(FdbGetRow)
then Result := FdbGetRow(dbproc, Row)
else Result := FdbGetRow_stdcall(dbproc, Row);
end;
{** Determine whether the current command or remote procedure call
generated a return status number. *}
function TZDBLIBPLainDriver.dbHasRetStat(dbProc: PDBPROCESS): DBBOOL;
begin
if Assigned(FdbHasRetStat_MS)
then Result := Ord(FdbHasRetStat_MS(dbproc))
else if Assigned(FdbHasRetStat_SYB)
then Result := FdbHasRetStat_SYB(dbproc)
else Result := FdbHasRetStat_stdcall(dbproc);
end;
{$ENDIF MSWINDOWS}
{** Initialize DB-Library. }
function TZDBLIBPLainDriver.dbIntit: RETCODE;
{$IFDEF MSWINDOWS}var P: PAnsiChar;{$ENDIF}
begin
{$IFDEF MSWINDOWS}
if Assigned(FdbInit_MS) then begin
P := FdbInit_MS;
if P <> nil then begin
Result := DBSUCCEED;
{$IFDEF UNICODE}
FClientVersion := ZEncoding.PRawToUnicode(P, StrLen(P), zCP_us_ascii);
{$ELSE}
SetString(FClientVersion, P, StrLen(P));
{$ENDIF}
end else Result := DBFail
end else if Assigned(FdbInit)
then Result := FdbInit
else Result := FdbInit_stdcall;
{$ELSE MSWINDOWS}
Result := FdbInit;
{$ENDIF MSWINDOWS}
end;
{** Allocates a login record for use in dbopen *}
function TZDBLIBPLainDriver.dbLogin: PLOGINREC;
begin
{$IFDEF MSWINDOWS}
if Assigned(FdbLogin)
then Result := FdbLogin
else Result := FdbLogin_stdcall;
{$ELSE}
Result := FdbLogin;
{$ENDIF}
end;
{$IFDEF MSWINDOWS}
{** Free a login record *}
procedure TZDBLIBPLainDriver.dbloginfree(loginptr: PLOGINREC);
begin
if Assigned(Fdbloginfree)
then Fdbloginfree(loginptr)
else FdbLoginfree_stdcall(loginptr);
end;
{** Indicate whether there are more commands to be processed. *}
function TZDBLIBPLainDriver.dbMoreCmds(dbProc: PDBPROCESS): RETCODE;
begin
if Assigned(FdbMoreCmds)
then Result := FdbMoreCmds(dbProc)
else Result := FdbMoreCmds_stdcall(dbProc);
end;
{** Return the name of the current database. *}
function TZDBLIBPLainDriver.dbname(dbProc: PDBPROCESS): PAnsiChar;
begin
if Assigned(Fdbname)
then Result := Fdbname(dbProc)
else Result := Fdbname_stdcall(dbProc);
end;
{** Read the next result row into the row buffer and into any program variables
that are bound to column data *}
function TZDBLIBPLainDriver.dbNextRow(dbProc: PDBPROCESS): STATUS;
begin
if Assigned(FdbNextRow)
then Result := FdbNextRow(dbProc)
else Result := FdbNextRow_stdcall(dbProc);
end;
{** Determine the number of regular columns for the current set of results *}
function TZDBLIBPLainDriver.dbNumCols(dbProc: PDBPROCESS): DBINT;
begin
if Assigned(FdbNumCols)
then Result := FdbNumCols(dbProc)
else Result := FdbNumCols_stdcall(dbProc);
end;
{$ENDIF}
{** Create and initialize a DBPROCESS structure. *}
function TZDBLIBPLainDriver.dbOpen(Login: PLOGINREC;
server: PAnsiChar): PDBPROCESS;
begin
if Assigned(FTdsDbOpen) then
// the ORD() thing is strange. It makes dblib terminate the program if no
// correct login information is given. This made the test TZTestConnectionCase.TestLoginPromptConnection
// fail when trying to login using 'x' as the user name. When reverting to 1,
// everything works as expected.
Result := FTdsDbOpen(Login, server, 1{Ord(ZFastCode.Pos('Sybase', GetDescription) > 0)})
else
{$IFNDEF MSWINDOWS}
Result := FdbOpen(Login, server);
{$ELSE}
if Assigned(FdbOpen)
then Result := FdbOpen(Login, server)
else Result := FdbOpen_stdcall(Login, server)
{$ENDIF}
end;
{$IFDEF MSWINDOWS}
{** Set up the results of the next query. *}
function TZDBLIBPLainDriver.dbResults(dbProc: PDBPROCESS): RETCODE;
begin
if Assigned(FdbResults)
then Result := FdbResults(dbProc)
else Result := FdbResults_stdcall(dbProc);
end;
{** Return a pointer to a return parameter value generated by a stored procedure. *}
function TZDBLIBPLainDriver.dbRetData(dbProc: PDBPROCESS;
RetNum: Integer): Pointer;
begin
if Assigned(FdbRetData)
then Result := FdbRetData(dbProc, RetNum)
else Result := FdbRetData_stdcall(dbProc, RetNum);
end;
{** Determine the length of a return parameter value
generated by a stored procedure. *}
function TZDBLIBPLainDriver.dbRetLen(dbProc: PDBPROCESS;
RetNum: Integer): DBINT;
begin
if Assigned(FdbRetLen)
then Result := FdbRetLen(dbProc, RetNum)
else Result := FdbRetLen_stdcall(dbProc, RetNum);
end;
{** Determine the name of the stored procedure parameter
associated with a particular return parameter value. *}
function TZDBLIBPLainDriver.dbRetName(dbProc: PDBPROCESS;
RetNum: Integer): PAnsiChar;
begin
if Assigned(FdbRetName)
then Result := FdbRetName(dbProc, RetNum)
else Result := FdbRetName_stdcall(dbProc, RetNum);
end;
{** Determine the stored procedure status number returned by the
current command or remote procedure call. *}
function TZDBLIBPLainDriver.dbRetStatus(dbProc: PDBPROCESS): DBINT;
begin
if Assigned(FdbRetStatus)
then Result := FdbRetStatus(dbProc)
else Result := FdbRetStatus_stdcall(dbProc);
end;
{** Determine the datatype of a return parameter value
generated by a stored procedure. *}
function TZDBLIBPLainDriver.dbRetType(dbProc: PDBPROCESS; RetNum: DBINT): DBINT;
begin
if Assigned(FdbRetType)
then Result := FdbRetType(dbProc, RetNum)
else Result := FdbRetType_stdcall(dbProc, RetNum);
end;
{$ENDIF MSWINDOWS}
{** emmidate exceute the remote procedure call. *}
function TZDBLIBPLainDriver.dbRpcExec(dbProc: PDBPROCESS): RETCODE;
begin
{$IFDEF MSWINDOWS}
if Assigned(FdbRpcExec)
then Result := FdbRpcExec(dbProc)
else if Assigned(FdbRpcSend) then begin
Result := FdbRpcSend(dbProc);
if Result = SUCCEED then
Result := dbSqlOk(dbProc);
end else begin
Result := FdbRpcSend_stdCall(dbProc);
if Result = SUCCEED then
Result := FdbSqlOk_stdcall(dbProc);
end;
{$ELSE}
Result := dbRpcExec(dbProc);
if Result = SUCCEED then
Result := dbSqlOk(dbProc);
{$ENDIF}
end;
{$IFDEF MSWINDOWS}
{** Initialize a remote procedure call *}
function TZDBLIBPLainDriver.dbRpcInit(dbProc: PDBPROCESS; RpcName: PAnsiChar;
Options: DBSMALLINT): RETCODE;
begin
if Assigned(FdbRpcInit)
then Result := FdbRpcInit(dbProc, RpcName, Options)
else Result := FdbRpcInit_stdcall(dbProc, RpcName, Options);
end;
{** Add a parameter to a remote procedure call. *}
function TZDBLIBPLainDriver.dbRpcParam(dbProc: PDBPROCESS; ParamName: PAnsiChar;
Status: Byte; Type_, MaxLen, DataLen: DBINT; Value: Pointer): RETCODE;
begin
if Assigned(FdbRpcParam)
then Result := FdbRpcParam(dbProc, ParamName, Status, Type_, MaxLen, DataLen, Value)
else Result := FdbRpcParam_stdcall(dbProc, ParamName, Status, Type_, MaxLen, DataLen, Value);
end;
{** Signal the end of a remote procedure call. *}
function TZDBLIBPLainDriver.dbRpcSend(dbProc: PDBPROCESS): RETCODE;
begin
if Assigned(FdbRpcSend)
then Result := FdbRpcSend(dbProc)
else Result := FdbRpcSend_stdcall(dbProc)
end;
{$ENDIF MSWINDOWS}
{** Set the application name in the LOGINREC structure *}
function TZDBLIBPLainDriver.dbSetLApp(Login: PLOGINREC;
AppName: PAnsiChar): RETCODE;
var Item: DBINT;
begin
case FDBLibraryVendorType of
lvtFreeTDS: Item := TDSDBSETAPP;
lvtSybase: Item := SYBDBSETAPP;
else Item := MSDBSETAPP;
end;
Result := dbsetLName(login, AppName, Item)
end;
{** Set the character set in the LOGINREC structure. *}
function TZDBLIBPLainDriver.dbSetLCharSet(Login: PLOGINREC;
CharsetName: PAnsiChar): RETCODE;
begin
case FDBLibraryVendorType of
lvtFreeTDS: Result := dbsetLName(login, CharsetName, TDSDBSETCHARSET);
lvtSybase: Result := dbsetLName(login, CharsetName, SYBDBSETCHARSET);
else Result := DBFAIL;
end;
end;
{** Set the host name in the LOGINREC structure *}
function TZDBLIBPLainDriver.dbSetLHost(Login: PLOGINREC;
HostName: PAnsiChar): RETCODE;
begin
Result := dbsetLName(login, HostName, DBSETHOST)
end;
{$IFDEF MSWINDOWS}
{** Set a value in the LOGINREC structure. *}
function TZDBLIBPLainDriver.dbsetLName(Login: PLOGINREC; Value: PAnsiChar;
Item: Integer): RETCODE;
begin
if Assigned(FdbsetLName)
then Result := FdbsetLName(login, Value, Item)
else Result := FdbsetLName_stdcall(login, Value, Item);
end;
{$ENDIF MSWINDOWS}
(** Set the national language name in the LOGINREC structure. *)
function TZDBLIBPLainDriver.dbSetLNatLang(Login: PLOGINREC;
NatLangName: PAnsiChar): RETCODE;
var Item: DBINT;
begin
case FDBLibraryVendorType of
lvtFreeTDS: Item := TDSDBSETLANG;
lvtSybase: Item := SYBDBSETLANG;
else Item := MSDBSETLANG;
end;
Result := dbsetLName(login, NatLangName, Item)
end;
{$IFDEF MSWINDOWS}
{** Set the number of seconds that DB-Library waits for a server response to
a request for a DBPROCESS connection. *}
function TZDBLIBPLainDriver.dbSetLoginTime(Seconds: Integer): RETCODE;
begin
if Assigned(FdbSetLoginTime)
then Result := FdbSetLoginTime(Seconds)
else Result := FdbSetLoginTime_stdcall(Seconds);
end;
{$ENDIF MSWINDOWS}
{** Set the TDS packet size in an application's LOGINREC structure. *}
function TZDBLIBPLainDriver.dbSetLPacket(Login: PLOGINREC;
packet_size: Word): RETCODE;
begin
case FDBLibraryVendorType of
lvtFreeTDS: Result := dbsetLName(login, @packet_size, TDSDBSETPACKET);
lvtSybase: Result := dbsetLName(login, @packet_size, SYBDBSETPACKET);
else Result := {$IFDEF MSWINDOWS}Fdbsetlpacket{$ELSE}dbsetlpacket{$ENDIF}(Login, packet_size)
end;
end;
{** Set the user server password in the LOGINREC structure. *}
function TZDBLIBPLainDriver.dbSetLPwd(Login: PLOGINREC;
Password: PAnsiChar): RETCODE;
begin
Result := dbsetLName(login, Password, DBSETPWD);
end;
{** Set the TDS packet size in an application's LOGINREC structure. *}
function TZDBLIBPLainDriver.dbSetLSecure(Login: PLOGINREC): RETCODE;
begin
if FDBLibraryVendorType = lvtMS
then Result := dbsetLName(login, nil, MSDBSETSECURE)
else Result := DBFail;
end;
{** Set the user name in the LOGINREC structure. *}
function TZDBLIBPLainDriver.dbSetLUser(Login: PLOGINREC;
UserName: PAnsiChar): RETCODE;
begin
Result := dbsetLName(login, UserName, DBSETUSER);
end;
{$IFDEF MSWINDOWS}
{** Set the maximum number of simultaneously open DBPROCESS structures. *}
function TZDBLIBPLainDriver.dbSetMaxprocs(MaxProcs: SmallInt): RETCODE;
begin
if Assigned(FdbSetMaxprocs_s)
then Result := FdbSetMaxprocs_s(MaxProcs)
else if Assigned(FdbSetMaxprocs_i)
then Result := FdbSetMaxprocs_i(MaxProcs)
else Result := FdbSetMaxprocs_stdcall(MaxProcs);
end;
{** Set a server or DB-Library option. *}
function TZDBLIBPLainDriver.dbSetOpt(dbProc: PDBPROCESS; Option: Integer;
Char_Param: PAnsiChar; Int_Param: Integer): RETCODE;
begin
case FDBLibraryVendorType of
lvtFreeTDS: Result := FdbSetOpt_SYB(dbProc, Option, Char_Param, Int_Param);
lvtSybase: Result := FdbSetOpt_stdcall(dbProc, Option, Char_Param, Int_Param);
else Result := FdbSetOpt_MS(dbProc, Option, Char_Param);
end;
end;
function TZDBLIBPLainDriver.dbSetTime(Seconds: Integer): RETCODE;
begin
if Assigned(FdbSetTime)
then Result := FdbSetTime(Seconds)
else Result := FdbSetTime_stdcall(Seconds);
end;
{$ENDIF MSWINDOWS}
function TZDBLIBPLainDriver.dbsetversion(Version: DBINT): RETCODE;
begin
if Assigned(Fdbsetversion)
then Result := Fdbsetversion(Version)
else {$IFDEF MSWINDOWS}if Assigned(Fdbsetversion_stdcall)
then Result := Fdbsetversion_stdcall(Version)
else {$ENDIF}Result := DBFAIL;
end;
{$IFDEF MSWINDOWS}
{** Send a command batch to the server. *}
function TZDBLIBPLainDriver.dbSqlExec(dbProc: PDBPROCESS): RETCODE;
begin
if Assigned(FdbSqlExec)
then Result := FdbSqlExec(dbProc)
else Result := FdbSqlExec_stdcall(dbProc);
end;
{** Wait for results from the server and verify the correctness of the
instructions the server is responding to. *}
function TZDBLIBPLainDriver.dbSqlOk(dbProc: PDBPROCESS): RETCODE;
begin
if Assigned(FdbSqlOk)
then Result := FdbSqlOk(dbProc)
else Result := FdbSqlOk_stdcall(dbProc);
end;
{** Send a command batch to the server and do not wait for a response. *}
function TZDBLIBPLainDriver.dbsqlsend(dbProc: PDBPROCESS): RETCODE;
begin
if Assigned(Fdbsqlsend)
then Result := Fdbsqlsend(dbProc)
else Result := Fdbsqlsend_stdcall(dbProc);
end;
{** Use a particular database. }
function TZDBLIBPLainDriver.dbUse(dbProc: PDBPROCESS;
dbName: PAnsiChar): RETCODE;
begin
if Assigned(FdbUse)
then Result := FdbUse(dbProc, dbName)
else Result := FdbUse_stdcall(dbProc, dbName);
end;
{** Determine whether the specified regular result column's data can vary in length. *}
function TZDBLIBPLainDriver.dbVaryLen(dbProc: PDBPROCESS;
Column: Integer): DBBOOL;
begin
if Assigned(FdbVaryLen_MS)
then Result := Ord(FdbVaryLen_MS(dbProc, Column))
else if Assigned(Fdbvarylen_SYB)
then Result := Fdbvarylen_SYB(dbProc, Column)
else Result := Fdbvarylen_stdcall(dbProc, Column);
end;
{** Returns the DBLIB version in use *}
function TZDBLIBPLainDriver.dbVersion: PAnsiChar;
begin
if Assigned(Fdbversion) then
Result := Fdbversion
else if Assigned(Fdbversion_stdcall) Then
Result := Fdbversion_stdcall
Else
Result := '';
end;
{$ENDIF MSWINDOWS}
destructor TZDBLIBPLainDriver.Destroy;
begin
if Loader.Loaded then
case FDBLibraryVendorType of
{$IFDEF MSWINDOWS}
lvtMS: begin
dberrhandle(OldMsSQLErrorHandle);
dbmsghandle(OldMsSQLMessageHandle);
//fdbWinexit;
fdbExit;
end;
{$ENDIF}
lvtSybase: begin
{$IFDEF MSWINDOWS}
dberrhandle_stdcall(OldSybaseErrorHandle);
dbmsghandle_stdcall(OldSybaseMessageHandle);
fdbExit_stdcall;
{$ELSE}
dberrhandle(OldSybaseErrorHandle);
dbmsghandle(OldSybaseMessageHandle);
{$IFDEF MSWINDOWS}fdbExit{$ELSE}dbExit{$ENDIF};
{$ENDIF}
end;
else begin //FreeTDS
dberrhandle(OldFreeTDSErrorHandle);
dbmsghandle(OldFreeTDSMessageHandle);
{$IFDEF MSWINDOWS}fdbExit{$ELSE}dbExit{$ENDIF};
end;
end;
inherited Destroy;
end;
{$IFDEF TEST_CALLBACK}
procedure TZDBLIBPLainDriver.DeRegisterErrorHandler(
const Handler: TDbLibErrorHandler);
var MyIdx, OldIdx: Integer;
begin
FCS.Enter;
try
MyIdx := FSQLErrorHandlerList.IndexOf(Handler);
Assert(MyIdx <> -1, 'worng DeRegisterErrorHandler behavior');
if (FSQLErrorHandlerList.Count = 1) then //assign given handle back
{$IFDEF MSWINDOWS}
if Assigned(dberrhandle_stdcall)
then dberrhandle_stdcall(TDbLibErrorHandler(FSQLErrorHandlerList[MyIdx]).FOlddberrhandle_stdcall)
else {$ENDIF} dberrhandle(TDbLibErrorHandler(FSQLErrorHandlerList[MyIdx]).FOlddberrhandle_cdecl)
else begin
if MyIdx = 0
then OldIdx := MyIdx+1
else OldIdx := MyIdx-1;
{$IFDEF MSWINDOWS}
if Assigned(dberrhandle_stdcall)
then TDbLibErrorHandler(FSQLErrorHandlerList[OldIdx]).FOlddberrhandle_stdcall := dberrhandle_stdcall(TDbLibErrorHandler(FSQLErrorHandlerList[MyIdx]).FOlddberrhandle_stdcall)
else {$ENDIF} TDbLibErrorHandler(FSQLErrorHandlerList[OldIdx]).FOlddberrhandle_cdecl := dberrhandle(TDbLibErrorHandler(FSQLErrorHandlerList[MyIdx]).FOlddberrhandle_cdecl);
end;
FSQLErrorHandlerList.Delete(MyIdx);
finally
FCS.Leave;
end;
end;
procedure TZDBLIBPLainDriver.DeRegisterMessageHandler(
const Handler: TDbLibMessageHandler);
var MyIdx, OldIdx: Integer;
begin
FCS.Enter;
try
MyIdx := FSQLMessageHandlerList.IndexOf(Handler);
Assert(MyIdx <> -1, 'worng DeRegisterMessageHandler behavior');
if (FSQLMessageHandlerList.Count = 1) then
{$IFDEF MSWINDOWS}
if Assigned(dbmsghandle_stdcall)
then dbmsghandle_stdcall(TDbLibMessageHandler(FSQLMessageHandlerList[MyIdx]).FOlddbmsghandle_stdcall)
else {$ENDIF} dbmsghandle(TDbLibMessageHandler(FSQLMessageHandlerList[MyIdx]).FOlddbmsghandle_cdecl)
else begin
if MyIdx = 0
then OldIdx := MyIdx+1
else OldIdx := MyIdx-1;
{$IFDEF MSWINDOWS}TDbLibMessageHandler(FSQLMessageHandlerList[OldIdx]).FOlddbMSGhandle_stdcall := TDbLibMessageHandler(FSQLMessageHandlerList[MyIdx]).FOlddbMSGhandle_stdcall;{$ENDIF MSWINDOWS}
TDbLibMessageHandler(FSQLMessageHandlerList[OldIdx]).FOlddbMSGhandle_cdecl := TDbLibMessageHandler(FSQLMessageHandlerList[MyIdx]).FOlddbMSGhandle_cdecl;
end;
FSQLMessageHandlerList.Delete(MyIdx);
finally
FCS.Leave;
end;
end;
{$ENDIF TEST_CALLBACK}
function TZDBLIBPLainDriver.GetDBOption(AOption: TdbOption): DBINT;
begin
case FDBLibraryVendorType of
lvtMS: case AOption of
dboptPARSEONLY: Result := DBLIBDBPARSEONLY;
dboptSHOWPLAN: Result := DBLIBDBSHOWPLAN;
dboptNOEXEC: Result := DBLIBDBNOEXEC;
dboptARITHIGNORE: Result := DBLIBDBARITHIGNORE;
dboptNOCOUNT: Result := DBLIBDBNOCOUNT;
dboptARITHABORT: Result := DBLIBDBARITHABORT;
dboptTEXTLIMIT: Result := DBLIBDBTEXTLIMIT;
dboptOFFSET: Result := DBLIBDBOFFSET;
dboptSTAT: Result := DBLIBDBSTAT;
dboptSTORPROCID: Result := DBLIBDBSTORPROCID;
dboptBUFFER: Result := DBLIBDBBUFFER;
dboptNOAUTOFREE: Result := DBLIBDBNOAUTOFREE;
dboptROWCOUNT: Result := DBLIBDBROWCOUNT;
dboptTEXTSIZE: Result := DBLIBDBTEXTSIZE;
dboptCLIENTCURSORS: Result := DBLIBDBCLIENTCURSORS;
dboptSETTIME: Result := DBLIBDBSET_TIME;
dboptQUOTEDIDENT: Result := DBLIBDBQUOTEDIDENT;
dboptANSITOOEM: Result := DBLIBDBANSITOOEM;
dboptOEMTOANSI: Result := DBLIBDBOEMTOANSI;
else Result := DBNOERR;
end;
else case AOption of
dboptPARSEONLY: Result := TDSPARSEONLY;
dboptESTIMATE: Result := TDSESTIMATE;
dboptSHOWPLAN: Result := TDSSHOWPLAN;
dboptNOEXEC: Result := TDSNOEXEC;
dboptARITHIGNORE: Result := TDSARITHIGNORE;
dboptNOCOUNT: Result := TDSNOCOUNT;
dboptARITHABORT: Result := TDSARITHABORT;
dboptTEXTLIMIT: Result := TDSTEXTLIMIT;
dboptBROWSE: Result := TDSBROWSE;
dboptOFFSET: Result := TDSOFFSET;
dboptSTAT: Result := TDSSTAT;
dboptERRLVL: Result := TDSERRLVL;
dboptCONFIRM: Result := TDSCONFIRM;
dboptSTORPROCID: Result := TDSSTORPROCID;
dboptBUFFER: Result := TDSBUFFER;
dboptNOAUTOFREE: Result := TDSNOAUTOFREE;
dboptROWCOUNT: Result := TDSROWCOUNT;
dboptTEXTSIZE: Result := TDSTEXTSIZE;
dboptNATLANG: Result := TDSNATLANG;
dboptDATEFORMAT: Result := TDSDATEFORMAT;
dboptPRPAD: Result := TDSPRPAD;
dboptPRCOLSEP: Result := TDSPRCOLSEP;
dboptPRLINELEN: Result := TDSPRLINELEN;
dboptPRLINESEP: Result := TDSPRLINESEP;
dboptLFCONVERT: Result := TDSLFCONVERT;
dboptDATEFIRST: Result := TDSDATEFIRST;
dboptCHAINXACTS: Result := TDSCHAINXACTS;
dboptFIPSFLAG: Result := TDSFIPSFLAG;
dboptISOLATION: Result := TDSISOLATION;
dboptAUTH: Result := TDSAUTH;
dboptIDENTITY: Result := TDSIDENTITY;
dboptNOIDCOL: Result := TDSNOIDCOL;
dboptDATESHORT: Result := TDSDATESHORT;
dboptCLIENTCURSORS: Result := TDSCLIENTCURSORS;
dboptSETTIME: Result := TDSSETTIME;
dboptQUOTEDIDENT: Result := TDSQUOTEDIDENT;
else Result := DBNOERR;
end;
end;
end;
procedure TZDBLIBPLainDriver.LoadApi;
begin
with FLoader do begin
//test for not exported methods to identify the libs:
if (GetAddress('dbcolbrowse') <> nil) and //not&never exported by FreeTDS see: http://www.freetds.org/userguide/dblib.api.summary.htm
(GetAddress('dbcoltypeinfo') <> nil) //not exported by ntwdblib.dll
//so we link against a sybaselib with stdcall on windows and cdecl for all other Os's
then FDBLibraryVendorType := lvtSybase
else if (GetAddress('dbcoltypeinfo') <> nil) //ntwdblib.dll does not export that function
then FDBLibraryVendorType := lvtFreeTDS
else FDBLibraryVendorType := lvtMS;
// if type sizes or names are different:
case FDBLibraryVendorType of
lvtFreeTDS: begin
@{$IFDEF MSWINDOWS}Fdbdead{$ELSE}dbdead{$ENDIF} := GetAddress('dbdead', True);
@{$IFDEF MSWINDOWS}Fdbcmdrow{$ELSE}dbcmdrow{$ENDIF} := GetAddress('dbcmdrow');
@{$IFDEF MSWINDOWS}Fdbcount{$ELSE}dbcount{$ENDIF} := GetAddress('dbcount');
@{$IFDEF MSWINDOWS}Fdbcurrow{$ELSE}dbcurrow{$ENDIF} := GetAddress('dbcurrow');
@{$IFDEF MSWINDOWS}Fdbfirstrow{$ELSE}dbfirstrow{$ENDIF} := GetAddress('dbfirstrow');
@{$IFDEF MSWINDOWS}Fdbclose_SYB{$ELSE}dbclose{$ENDIF} := GetAddress('dbclose'); //is a procedure
@{$IFDEF MSWINDOWS}Fdbsetmaxprocs_I{$ELSE}dbSetMaxprocs{$ENDIF} := GetAddress('dbsetmaxprocs'); //uses DBINT
@{$IFDEF MSWINDOWS}Fdbloginfree{$ELSE}dbloginfree{$ENDIF} := GetAddress('dbloginfree', True); //name diff to ms
//@{$IFDEF MSWINDOWS}Fdbcolbrowse_SYB{$ELSE}dbcolbrowse{$ENDIF} := GetAddress('dbcolbrowse'); //no FreeTDS
@{$IFDEF MSWINDOWS}FdbMoreCmds{$ELSE}dbMoreCmds{$ENDIF} := GetAddress('dbmorecmds'); //name diff to ms
@{$IFDEF MSWINDOWS}FdbSetOpt_SYB{$ELSE}dbsetopt{$ENDIF} := GetAddress('dbsetopt'); //int_param is available but not computed always
@{$IFDEF MSWINDOWS}FdbHasRetStat_SYB{$ELSE}dbHasRetStat{$ENDIF} := GetAddress('dbhasretstat'); //DBBOOL vs. LongBool
@{$IFDEF MSWINDOWS}Fdbvarylen_SYB{$ELSE}dbvarylen{$ENDIF} := GetAddress('dbvarylen'); //DBBOOL vs. LongBool
@Fdbinit := GetAddress('dbinit'); //Result is a RetCode
@FdbSetVersion := GetAddress('dbsetversion'); //no MS but ms supports dbSetLVersion
@dbsetlversion := GetAddress('dbsetlversion'); //no sybase see: https://lists.ibiblio.org/pipermail/freetds/2011q4/027489.html
@tdsdump_on := GetAddress('tdsdump_on');
@tdsdump_off := GetAddress('tdsdump_off');
@tdsdump_open := GetAddress('tdsdump_open');
@tdsdump_close := GetAddress('tdsdump_close');
end;
lvtSybase: begin //handle lower vs uppercase and the call conventions
@{$IFDEF MSWINDOWS}Fdbdead_stdcall{$ELSE}dbdead{$ENDIF} := GetAddress('DBDEAD'); //as documented: uppercase
if not Assigned({$IFDEF MSWINDOWS}Fdbdead_stdcall{$ELSE}dbdead{$ENDIF}) then
@{$IFDEF MSWINDOWS}Fdbdead_stdcall{$ELSE}dbdead{$ENDIF} := GetAddress('dbdead'); //lowercase since 15+
@{$IFDEF MSWINDOWS}Fdbcmdrow_stdcall{$ELSE}dbcmdrow{$ENDIF} := GetAddress('DBCMDROW'); //as documented: uppercase
if not Assigned({$IFDEF MSWINDOWS}Fdbcmdrow_stdcall{$ELSE}dbcmdrow{$ENDIF}) then
@{$IFDEF MSWINDOWS}Fdbcmdrow_stdcall{$ELSE}dbcmdrow{$ENDIF} := GetAddress('dbcmdrow'); //lowercase since 15+
@{$IFDEF MSWINDOWS}Fdbcount_stdcall{$ELSE}dbcount{$ENDIF} := GetAddress('DBCOUNT'); //as documented: uppercase
if not Assigned({$IFDEF MSWINDOWS}Fdbcount_stdcall{$ELSE}dbcount{$ENDIF}) then
@{$IFDEF MSWINDOWS}Fdbcount_stdcall{$ELSE}dbcount{$ENDIF} := GetAddress('dbcount'); //lowercase since 15+
@{$IFDEF MSWINDOWS}Fdbcurrow_stdcall{$ELSE}dbcurrow{$ENDIF} := GetAddress('DBCURROW'); //as documented: uppercase
if not Assigned({$IFDEF MSWINDOWS}Fdbcurrow_stdcall{$ELSE}dbcurrow{$ENDIF}) then
@{$IFDEF MSWINDOWS}Fdbcurrow_stdcall{$ELSE}dbcurrow{$ENDIF} := GetAddress('dbcurrow'); //lowercase since 15+
@{$IFDEF MSWINDOWS}Fdbfirstrow_stdcall{$ELSE}dbfirstrow{$ENDIF} := GetAddress('DBFIRSTROW'); //as documented: uppercase
if not Assigned({$IFDEF MSWINDOWS}Fdbfirstrow_stdcall{$ELSE}dbfirstrow{$ENDIF}) then
@{$IFDEF MSWINDOWS}Fdbfirstrow_stdcall{$ELSE}dbfirstrow{$ENDIF} := GetAddress('dbfirstrow'); //lowercase since 15+
@{$IFDEF MSWINDOWS}Fdbclose_stdcall{$ELSE}dbclose{$ENDIF} := GetAddress('dbclose');
@{$IFDEF MSWINDOWS}Fdbsetmaxprocs_stdcall{$ELSE}dbSetMaxprocs{$ENDIF} := GetAddress('dbsetmaxprocs');
@{$IFDEF MSWINDOWS}Fdbloginfree_stdcall{$ELSE}dbloginfree{$ENDIF} := GetAddress('dbloginfree', True); //name diff
@{$IFDEF MSWINDOWS}Fdbcolbrowse_stdcall{$ELSE}dbcolbrowse{$ENDIF} := GetAddress('dbcolbrowse'); //no FreeTDS
@{$IFDEF MSWINDOWS}FdbMoreCmds_stdcall{$ELSE}dbMoreCmds{$ENDIF} := GetAddress('DBMORECMDS'); //uppercase
if not Assigned({$IFDEF MSWINDOWS}FdbMoreCmds_stdcall{$ELSE}dbMoreCmds{$ENDIF}) then
@{$IFDEF MSWINDOWS}FdbMoreCmds_stdcall{$ELSE}dbMoreCmds{$ENDIF} := GetAddress('dbmorecmds'); //lowercase since 15+
@{$IFDEF MSWINDOWS}FdbSetOpt_stdcall{$ELSE}dbsetopt{$ENDIF} := GetAddress('dbsetopt'); //int_param is available
@{$IFDEF MSWINDOWS}FdbHasRetStat_stdcall{$ELSE}dbhasretstat{$ENDIF} := GetAddress('dbhasretstat'); //DBBOOL vs. LongBool
@{$IFDEF MSWINDOWS}Fdbvarylen_stdcall{$ELSE}dbvarylen{$ENDIF} := GetAddress('dbvarylen'); //DBBOOL vs. LongBool
@{$IFDEF MSWINDOWS}Fdbinit_stdcall{$ELSE}Fdbinit{$ENDIF} := GetAddress('dbinit'); //Result is a RetCode
@{$IFDEF MSWINDOWS}FdbSetVersion_stdcall{$ELSE}FdbSetVersion{$ENDIF} := GetAddress('dbsetversion'); //no MS
end;
{$IFDEF MSWINDOWS}
lvtMS: begin
@FdbWinexit := GetAddress('dbwinexit');
@Fdbdead_MS := GetAddress('dbdead', True);
@Fdbcmdrow := GetAddress('dbcmdrow');
@Fdbcount := GetAddress('dbcount');
@Fdbcurrow := GetAddress('dbcurrow');
@Fdbfirstrow := GetAddress('dbfirstrow');
@Fdbclose_MS := GetAddress('dbclose'); //is a function
@Fdbsetlpacket := GetAddress('dbsetlpacket'); //does not use the dbsetlname method
@Fdbsetmaxprocs_s := GetAddress('dbsetmaxprocs'); //uses a two byte int
@Fdbloginfree := GetAddress('dbfreelogin', True);//name diff
@Fdbcolbrowse_MS := GetAddress('dbcolbrowse'); //no FreeTDS
@FdbMoreCmds := GetAddress('dbmorecmds'); //name diff to ms
@FdbSetOpt_MS := GetAddress('dbsetopt'); //int_param is not available
@FdbHasRetStat_MS := GetAddress('dbhasretstat'); //DBBOOL vs. LongBool
@Fdbvarylen_MS := GetAddress('dbvarylen'); //DBBOOL vs. LongBool
@Fdbinit_MS := GetAddress('dbinit'); //Result is a PAnsiChar not a RetCode
@dbsetlversion := GetAddress('dbsetlversion') //no sybase see: https://lists.ibiblio.org/pipermail/freetds/2011q4/027489.html
end;
{$ENDIF}
end;
{ type sizes are equal -> call convention! }
{$IFDEF MSWINDOWS}
if FDBLibraryVendorType = lvtSybase then begin
@Fdbadata_stdcall := GetAddress('dbadata');
@Fdbadlen_stdcall := GetAddress('dbadlen');
@Fdbaltbind_stdcall := GetAddress('dbaltbind');
@Fdbaltbind_ps_stdcall := GetAddress('dbaltbind_ps');
@Fdbaltcolid_stdcall := GetAddress('dbaltcolid');
@Fdbaltlen_stdcall := GetAddress('dbaltlen');
@Fdbaltop_stdcall := GetAddress('dbaltop');
@Fdbalttype_stdcall := GetAddress('dbalttype');
@Fdbanullbind_stdcall := GetAddress('dbanullbind');
@Fdbbind_stdcall := GetAddress('dbbind');
@Fdbbind_ps_stdcall := GetAddress('dbbind_ps');
@Fdbbufsize_stdcall := GetAddress('dbbufsize');
@Fdbbylist_stdcall := GetAddress('dbbylist');
@Fdbcancel_stdcall := GetAddress('dbcancel');
@Fdbcanquery_stdcall := GetAddress('dbcanquery');
@Fdbclrbuf_stdcall := GetAddress('dbclrbuf');
@Fdbcmd_stdcall := GetAddress('dbcmd');
@Fdbclropt_stdcall := GetAddress('dbclropt');
@Fdbcollen_stdcall := GetAddress('dbcollen');
@Fdbcolname_stdcall := GetAddress('dbcolname');
@Fdbcolsource_stdcall := GetAddress('dbcolsource');
@Fdbcoltype_stdcall := GetAddress('dbcoltype');
@Fdbcolutype_stdcall := GetAddress('dbcolutype');
@Fdbcoltypeinfo_stdcall := GetAddress('dbcoltypeinfo'); //no MS ?
@Fdbcolutype_stdcall := GetAddress('dbcolutype');
@Fdbconvert_stdcall := GetAddress('dbconvert');
@Fdbconvert_ps_stdcall := GetAddress('bconvert_ps'); //no MS
@Fdbdata_stdcall := GetAddress('dbdata');
@Fdbdatlen_stdcall := GetAddress('dbdatlen');
@Fdbexit_stdcall := GetAddress('dbexit');
@Fdbfreebuf_stdcall := GetAddress('dbfreebuf');
@Fdbfreequal_stdcall := GetAddress('dbfreequal');
@Fdbgetchar_stdcall := GetAddress('dbgetchar');
@Fdbgetcharset_stdcall := GetAddress('dbgetcharset');
@FdbGetRow_stdcall := GetAddress('dbgetrow');
@FdbLogin_stdcall := GetAddress('dblogin');
@Fdbname_stdcall := GetAddress('dbname');
@FdbNextRow_stdcall := GetAddress('dbnextrow');
@FdbNumCols_stdcall := GetAddress('dbnumcols');
@FdbOpen_stdcall := GetAddress('dbopen');
@FdbSetLoginTime_stdcall := GetAddress('dbsetlogintime');
@FdbsetLName_stdcall := GetAddress('dbsetlname');
@FdbSetTime_stdCall := GetAddress('dbsettime');
@FdbSqlExec_stdcall := GetAddress('dbsqlexec');
@FdbSqlOk_stdcall := GetAddress('dbsqlok');
@FdbSqlSend_stdcall := GetAddress('dbsqlsend');
@FdbResults_stdcall := GetAddress('dbresults');
@FdbRetData_stdcall := GetAddress('dbretdata');
@FdbRetLen_stdcall := GetAddress('dbretlen');
@FdbRetName_stdcall := GetAddress('dbretname');
@Fdbretstatus_stdcall := GetAddress('dbretstatus');
@FdbRetType_stdcall := GetAddress('dbrettype');
@Fdbrpcinit_stdcall := GetAddress('dbrpcinit');
@FdbRpcParam_stdcall := GetAddress('dbrpcparam');
@FdbRpcSend_stdcall := GetAddress('dbrpcsend');
@Fdbuse_stdcall := GetAddress('dbuse');
@dberrhandle_stdcall := GetAddress('dberrhandle');
@dbmsghandle_stdcall := GetAddress('dbmsghandle');
{$IFNDEF TEST_CALLBACK}
OldSybaseErrorHandle := dberrhandle_stdcall(SybaseErrorHandle);
OldSybaseMessageHandle := dbmsghandle_stdcall(SybaseMessageHandle);
{$ENDIF}
end else {$ENDIF}begin
@{$IFDEF MSWINDOWS}Fdbadata{$ELSE}dbadata{$ENDIF} := GetAddress('dbadata');
@{$IFDEF MSWINDOWS}Fdbadlen{$ELSE}dbadlen{$ENDIF} := GetAddress('dbadlen');
@{$IFDEF MSWINDOWS}Fdbaltbind{$ELSE}dbaltbind{$ENDIF} := GetAddress('dbaltbind');
@{$IFDEF MSWINDOWS}Fdbaltbind_ps{$ELSE}dbaltbind_ps{$ENDIF} := GetAddress('dbaltbind_ps');
@{$IFDEF MSWINDOWS}Fdbaltcolid{$ELSE}dbaltcolid{$ENDIF} := GetAddress('dbaltcolid');
@{$IFDEF MSWINDOWS}Fdbaltlen{$ELSE}dbaltlen{$ENDIF} := GetAddress('dbaltlen');
@{$IFDEF MSWINDOWS}Fdbaltop{$ELSE}dbaltop{$ENDIF} := GetAddress('dbaltop');
@{$IFDEF MSWINDOWS}Fdbalttype{$ELSE}dbalttype{$ENDIF} := GetAddress('dbalttype');
@{$IFDEF MSWINDOWS}Fdbanullbind{$ELSE}dbanullbind{$ENDIF} := GetAddress('dbanullbind');
@{$IFDEF MSWINDOWS}Fdbbind{$ELSE}dbbind{$ENDIF} := GetAddress('dbbind');
@{$IFDEF MSWINDOWS}Fdbbind_ps{$ELSE}dbbind_ps{$ENDIF} := GetAddress('dbbind_ps');
@{$IFDEF MSWINDOWS}Fdbbufsize{$ELSE}dbbufsize{$ENDIF} := GetAddress('dbbufsize');
@{$IFDEF MSWINDOWS}Fdbbylist{$ELSE}dbbylist{$ENDIF} := GetAddress('dbbylist');
@{$IFDEF MSWINDOWS}Fdbcancel{$ELSE}dbcancel{$ENDIF} := GetAddress('dbcancel');
@{$IFDEF MSWINDOWS}Fdbcanquery{$ELSE}dbcanquery{$ENDIF} := GetAddress('dbcanquery');
@{$IFDEF MSWINDOWS}Fdbclrbuf{$ELSE}dbclrbuf{$ENDIF} := GetAddress('dbclrbuf');
@{$IFDEF MSWINDOWS}Fdbclropt{$ELSE}dbclropt{$ENDIF} := GetAddress('dbclropt');
@{$IFDEF MSWINDOWS}Fdbcmd{$ELSE}dbcmd{$ENDIF} := GetAddress('dbcmd');
@{$IFDEF MSWINDOWS}Fdbcollen{$ELSE}dbcollen{$ENDIF} := GetAddress('dbcollen');
@dbcolinfo := GetAddress('dbcolinfo'); //no sybase but freeTDS and MS
@dbtablecolinfo := GetAddress('dbtablecolinfo'); //FreeTDS only!!!
@{$IFDEF MSWINDOWS}Fdbcolname{$ELSE}dbcolname{$ENDIF} := GetAddress('dbcolname');
@{$IFDEF MSWINDOWS}Fdbcolsource{$ELSE}dbcolsource{$ENDIF} := GetAddress('dbcolsource'); //no FreeTDS?
@{$IFDEF MSWINDOWS}Fdbcoltype{$ELSE}dbcoltype{$ENDIF} := GetAddress('dbcoltype');
@{$IFDEF MSWINDOWS}Fdbcoltypeinfo{$ELSE}dbcoltypeinfo{$ENDIF} := GetAddress('dbcoltypeinfo'); //no MS
@{$IFDEF MSWINDOWS}Fdbcolutype{$ELSE}dbcolutype{$ENDIF} := GetAddress('dbcolutype');
@{$IFDEF MSWINDOWS}Fdbconvert{$ELSE}dbconvert{$ENDIF} := GetAddress('dbconvert');
@{$IFDEF MSWINDOWS}Fdbconvert_ps{$ELSE}dbconvert_ps{$ENDIF} := GetAddress('bconvert_ps'); //no MS
@{$IFDEF MSWINDOWS}Fdbdata{$ELSE}dbdata{$ENDIF} := GetAddress('dbdata');
{$IFDEF MSWINDOWS}@dbdataready := GetAddress('dbdata'); {$ENDIF}
@{$IFDEF MSWINDOWS}Fdbdatlen{$ELSE}dbdatlen{$ENDIF} := GetAddress('dbdatlen');
@{$IFDEF MSWINDOWS}Fdbexit{$ELSE}dbexit{$ENDIF} := GetAddress('dbexit');
@{$IFDEF MSWINDOWS}Fdbfreebuf{$ELSE}dbfreebuf{$ENDIF} := GetAddress('dbfreebuf');
@{$IFDEF MSWINDOWS}Fdbfreequal{$ELSE}dbfreequal{$ENDIF} := GetAddress('dbfreequal');
@{$IFDEF MSWINDOWS}Fdbgetchar{$ELSE}dbgetchar{$ENDIF} := GetAddress('dbgetchar');
@{$IFDEF MSWINDOWS}Fdbgetcharset{$ELSE}dbgetcharset{$ENDIF} := GetAddress('dbgetcharset');
@{$IFDEF MSWINDOWS}FdbGetRow{$ELSE}dbGetRow{$ENDIF} := GetAddress('dbgetrow');
@FdbLogin := GetAddress('dblogin');
@{$IFDEF MSWINDOWS}Fdbname{$ELSE}dbname{$ENDIF} := GetAddress('dbname');
@{$IFDEF MSWINDOWS}FdbNextRow{$ELSE}dbNextRow{$ENDIF} := GetAddress('dbnextrow');
@{$IFDEF MSWINDOWS}FdbNumCols{$ELSE}dbnumcols{$ENDIF} := GetAddress('dbnumcols');
@{$IFDEF MSWINDOWS}FdbResults{$ELSE}dbResults{$ENDIF} := GetAddress('dbresults');
@Fdbopen := GetAddress('dbopen');
@FtdsDbOpen := GetAddress('tdsdbopen');
@{$IFDEF MSWINDOWS}Fdbretdata{$ELSE}dbretdata{$ENDIF} := GetAddress('dbretdata');
@{$IFDEF MSWINDOWS}Fdbretlen{$ELSE}dbretlen{$ENDIF} := GetAddress('dbretlen');
@{$IFDEF MSWINDOWS}Fdbretname{$ELSE}dbretname{$ENDIF} := GetAddress('dbretname');
@{$IFDEF MSWINDOWS}Fdbretstatus{$ELSE}dbretstatus{$ENDIF} := GetAddress('dbretstatus');
@{$IFDEF MSWINDOWS}Fdbrettype{$ELSE}dbrettype{$ENDIF} := GetAddress('dbrettype');
@{$IFDEF MSWINDOWS}Fdbrpcinit{$ELSE}dbrpcinit{$ENDIF} := GetAddress('dbrpcinit');
@{$IFDEF MSWINDOWS}Fdbrpcparam{$ELSE}dbrpcparam{$ENDIF} := GetAddress('dbrpcparam');
@{$IFDEF MSWINDOWS}FdbRpcSend{$ELSE}dbRpcSend{$ENDIF} := GetAddress('dbrpcsend');
@{$IFDEF MSWINDOWS}FdbSetLoginTime{$ELSE}dbSetLoginTime{$ENDIF} := GetAddress('dbsetlogintime');
@{$IFDEF MSWINDOWS}FdbsetLName{$ELSE}dbsetLName{$ENDIF} := GetAddress('dbsetlname');
@{$IFDEF MSWINDOWS}FdbSetTime{$ELSE}dbSetTime{$ENDIF} := GetAddress('dbsettime');
@{$IFDEF MSWINDOWS}FdbSqlExec{$ELSE}dbSqlExec{$ENDIF} := GetAddress('dbsqlexec');
@{$IFDEF MSWINDOWS}FdbSqlOk{$ELSE}dbSqlOk{$ENDIF} := GetAddress('dbsqlok');
@{$IFDEF MSWINDOWS}FdbSqlSend{$ELSE}dbSqlSend{$ENDIF} := GetAddress('dbsqlsend');
@{$IFDEF MSWINDOWS}Fdbuse{$ELSE}dbuse{$ENDIF} := GetAddress('dbuse');
@{$IFDEF MSWINDOWS}Fdbversion{$ELSE}dbversion{$ENDIF} := GetAddress('dbversion');
@dbmsghandle := GetAddress('dbmsghandle');
@dberrhandle := GetAddress('dberrhandle');
if FDBLibraryVendorType = lvtFreeTDS then begin
OldFreeTDSErrorHandle := dberrhandle(FreeTDSErrorHandle);
OldFreeTDSMessageHandle := dbmsghandle(FreeTDSMessageHandle);
end else begin
{$IFDEF MSWINDOWS}OldMsSQLErrorHandle{$ELSE}OldSybaseErrorHandle{$ENDIF} := dberrhandle(DbLibErrorHandle);
{$IFDEF MSWINDOWS}OldMsSQLMessageHandle{$ELSE}OldSybaseMessageHandle{$ENDIF} := dbmsghandle(DbLibMessageHandle);
end;
Assert(dbintit = SUCCEED, 'dbinit failed');
end;
end;
end;
procedure TZDBLIBPLainDriver.LoadCodePages;
begin
//inherited;
{ add FreeTDS supported charactersets }
AddCodePage('UTF-8', 1, ceUTF8, zCP_UTF8, '', 4, True);
AddCodePage('ISO-8859-1', 2, ceAnsi, zCP_L1_ISO_8859_1, '', 1, True);
AddCodePage('ASCII', 3, ceAnsi, zCP_us_ascii, '', 1, False);
end;
{$IFDEF TEST_CALLBACK}
function TZDBLIBPLainDriver.GetErrorHandler(dbProc: PDBPROCESS;
ADBERRHANDLE_PROC: TDBERRHANDLE_PROC): IZDBLibErrorHandler;
var DbLibErrorHandler: TDbLibErrorHandler;
begin
FCS.Enter;
Result := nil;
try
DbLibErrorHandler := TDbLibErrorHandler.Create(dbProc, ADBERRHANDLE_PROC, Self);
Result := DbLibErrorHandler;
FSQLErrorHandlerList.Add(DbLibErrorHandler);
finally
FCS.Leave;
end;
end;
function TZDBLIBPLainDriver.GetMessageHandler(dbProc: PDBPROCESS;
ADBMSGHANDLE_PROC: TDBMSGHANDLE_PROC): IZDBLibMessageHandler;
var DbLibMessageHandler: TDbLibMessageHandler;
begin
FCS.Enter;
Result := nil;
try
DbLibMessageHandler := TDbLibMessageHandler.Create(dbProc, ADBMSGHANDLE_PROC, Self);
Result := DbLibMessageHandler;
FSQLMessageHandlerList.Add(DbLibMessageHandler);
finally
FCS.Leave;
end;
end;
constructor TZMethodToDllCallbackProcedure.Create(const Instance: TObject;
methodAddr: pointer; const CallBackManager: TZDBLIBPLainDriver);
begin
inherited Create(Instance, methodAddr);
FManager := CallBackManager;
end;
{ TDbLibErrorHandler }
procedure TDbLibErrorHandler.BeforeDestruction;
begin
inherited;
FManager.DeRegisterErrorHandler(Self);
end;
constructor TDbLibErrorHandler.Create(Handle: PDBPROCESS;
DBERRHANDLE_PROC: TDBERRHANDLE_PROC; const Manager: TZDBLIBPLainDriver);
var P: Pointer;
begin
P := GetProcedureAddress;
{$IFDEF MSWINDOWS}
if Manager.FDBLibraryVendorType = lvtSybase then begin
inherited Create(Self, @TDbLibErrorHandler.dberrhandle_stdcall, Manager);
FOlddberrhandle_stdcall := Manager.dberrhandle_stdcall(P);
end else {$ENDIF}begin
inherited Create(Self, @TDbLibErrorHandler.dberrhandle_cdecl, Manager);
FOlddberrhandle_cdecl := Manager.dberrhandle(P);
end;
FHandle := Handle;
FMydberrhandle := DBERRHANDLE_PROC;
end;
function TDbLibErrorHandler.dberrhandle_cdecl(Proc: PDBPROCESS;
Severity, DbErr, OsErr: Integer; DbErrStr, OsErrStr: PAnsiChar): Integer;
begin
if FHandle = Proc
then Result := FMydberrhandle(Proc, Severity, DbErr, OsErr, DbErrStr, OsErrStr)
else if Assigned(FOlddberrhandle_cdecl)
then Result := FOlddberrhandle_cdecl(Proc, Severity, DbErr, OsErr, DbErrStr, OsErrStr)
else Result := INT_CANCEL;
end;
{$IFDEF MSWINDOWS}
function TDbLibErrorHandler.dberrhandle_stdcall(Proc: PDBPROCESS;
Severity, DbErr, OsErr: Integer; DbErrStr, OsErrStr: PAnsiChar): Integer;
begin
if FHandle = Proc
then Result := FMydberrhandle(Proc, Severity, DbErr, OsErr, DbErrStr, OsErrStr)
else if Assigned(FOlddberrhandle_stdcall)
then Result := FOlddberrhandle_stdcall(Proc, Severity, DbErr, OsErr, DbErrStr, OsErrStr)
else Result := INT_CANCEL;
end;
{$ENDIF MSWINDOWS}
{ TDbLibMessageHandler }
procedure TDbLibMessageHandler.BeforeDestruction;
begin
inherited;
FManager.DeRegisterMessageHandler(Self);
end;
constructor TDbLibMessageHandler.Create(
Handle: PDBPROCESS; DBMSGHANDLE_PROC: TDBMSGHANDLE_PROC;
const Manager: TZDBLIBPLainDriver);
var P: Pointer;
begin
P := GetProcedureAddress;
{$IFDEF MSWINDOWS}
if Manager.FDBLibraryVendorType = lvtSybase then begin
inherited Create(Self, @TDbLibMessageHandler.dbmsghandle_stdcall, Manager);
FOlddbmsghandle_stdcall := Manager.dbmsghandle_stdcall(P);
end else {$ENDIF}begin
inherited Create(Self, PAnsiChar(@TDbLibMessageHandler.dbmsghandle_cdecl), Manager);
FOlddbmsghandle_cdecl := Manager.dbmsghandle(P);
end;
FMydbmsghandle := DBMSGHANDLE_PROC;
FHandle := Handle;
end;
function TDbLibMessageHandler.dbmsghandle_cdecl(Proc: PDBPROCESS; MsgNo: DBINT;
MsgState, Severity: Integer; MsgText, SrvName, ProcName: PAnsiChar;
Line: DBUSMALLINT): Integer;
begin
if FHandle = Proc
then Result := FMydbmsghandle(Proc, MsgNo, MsgState, Severity, MsgText, SrvName, ProcName, Line)
else if Assigned(FOlddbmsghandle_cdecl)
then Result := FOlddbmsghandle_cdecl(Proc, MsgNo, MsgState, Severity, MsgText, SrvName, ProcName, Line)
else Result := INT_EXIT;
end;
{$IFDEF MSWINDOWS}
function TDbLibMessageHandler.dbmsghandle_stdcall(Proc: PDBPROCESS;
MsgNo: DBINT; MsgState, Severity: Integer; MsgText, SrvName,
ProcName: PAnsiChar; Line: DBUSMALLINT): Integer;
begin
if FHandle = Proc
then Result := FMydbmsghandle(Proc, MsgNo, MsgState, Severity, MsgText, SrvName, ProcName, Line)
else if Assigned(FOlddbmsghandle_stdcall)
then Result := FOlddbmsghandle_stdcall(Proc, MsgNo, MsgState, Severity, MsgText, SrvName, ProcName, Line)
else Result := INT_EXIT;
end;
{$ENDIF}
{$ENDIF TEST_CALLBACK}
{ TMSSQLDBLibPLainDriver }
procedure TMSSQLDBLibPLainDriver.AfterConstruction;
begin
inherited;
{$IFDEF MSWINDOWS}
FLoader.AddLocation('ntwdblib.dll');
{$ENDIF}
end;
function TMSSQLDBLibPLainDriver.Clone: IZPlainDriver;
begin
Result := TMSSQLDBLibPLainDriver.Create;
end;
function TMSSQLDBLibPLainDriver.GetDescription: string;
begin
Result := 'Native dblib driver for SQL Server';
end;
function TMSSQLDBLibPLainDriver.GetProtocol: string;
begin
Result := 'mssql'
end;
procedure TMSSQLDBLibPLainDriver.LoadCodePages;
begin
inherited LoadCodePages;
AddmMSCodePages(Self);
end;
{ TSybaseDBLibPLainDriver }
procedure TSybaseDBLibPLainDriver.AfterConstruction;
begin
inherited AfterConstruction;
FLoader.AddLocation('libsybdb'+SharedSuffix);
end;
function TSybaseDBLibPLainDriver.Clone: IZPlainDriver;
begin
Result := TSybaseDBLibPLainDriver.Create;
end;
function TSybaseDBLibPLainDriver.GetDescription: string;
begin
Result := 'Native dblib driver for Sybase ASE';
end;
function TSybaseDBLibPLainDriver.GetProtocol: string;
begin
Result := 'sybase'
end;
procedure TSybaseDBLibPLainDriver.LoadApi;
var
Success: Boolean;
begin
inherited LoadApi;
{$IFDEF MSWINDOWS}
if assigned(FdbSetVersion) then begin
if FdbSetVersion(TDSDBVERSION_100) = DBFAIL then begin
Success := FdbSetVersion(TDSDBVERSION_46) = DBSUCCEED;
Assert(Success , 'failed to set the TDS version')
end;
end else begin
if FdbSetVersion_stdcall(TDSDBVERSION_100) = DBFAIL then begin
Success := FdbSetVersion_stdcall(TDSDBVERSION_46) = DBSUCCEED;
Assert(Success , 'failed to set the TDS version');
end;
end;
{$ELSE}
if dbSetVersion(TDSDBVERSION_100) = DBFAIL then begin
Success := dbSetVersion(TDSDBVERSION_46) = DBSUCCEED;
Assert(Success , 'failed to set the TDS version')
end;
{$ENDIF}
end;
procedure TSybaseDBLibPLainDriver.LoadCodePages;
begin
inherited;
AddSybaseCodePages(Self);
end;
{ TZDBLibErrorList }
constructor TZDBLibErrorList.Create;
begin
inherited Create(SizeOf(TDBLibError), True);
end;
procedure TZDBLibErrorList.Notify(Ptr: Pointer; Action: TListNotification);
begin
if Action = lnDeleted then begin
PDBLibError(Ptr).DbErrStr := EmptyRaw;
PDBLibError(Ptr).OsErrStr := EmptyRaw;
end;
end;
{ TZDBLibMessageList }
constructor TZDBLibMessageList.Create;
begin
inherited Create(SizeOf(TDBLibMessage), True);
end;
procedure TZDBLibMessageList.Notify(Ptr: Pointer; Action: TListNotification);
begin
if Action = lnDeleted then begin
PDBLibMessage(Ptr).MsgText := EmptyRaw;
PDBLibMessage(Ptr).SrvName := EmptyRaw;
PDBLibMessage(Ptr).ProcName := EmptyRaw;
end;
end;
{ Helper functions for TDS_DATETIMEALL}
function TdsDateTimeAllGetPrecision(const Value: TDBDATETIMEALL): Integer;
begin
Result := Value.flags and DbDateTimeAllTimePrecMask;
end;
function TdsDateTimeAllHasDate(const Value: TDBDATETIMEALL): Boolean;
begin
Result := WordBool(Value.flags and DbDateTimeAllHasDateMask)
end;
function TdsDateTimeAllHasTime(const Value: TDBDATETIMEALL): Boolean;
begin
Result := WordBool(Value.flags and DbDateTimeAllHasTimeMask)
end;
function TdsDateTimeAllHasOffset(const Value: TDBDATETIMEALL): Boolean;
begin
Result := WordBool(Value.flags and DbDatetimeAllHasOffsetMask)
end;
initialization
SQLErrors := TZDBLibErrorList.Create;
SQLMessages := TZDBLibMessageList.Create;
ErrorCS := TCriticalSection.Create;
finalization
FreeAndnil(ErrorCS);
//Free any record in the list if any
FreeAndNil(SQLErrors);
//Free any record in the list if any
FreeAndNil(SQLMessages);
{$ENDIF ZEOS_DISABLE_DBLIB}
end.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.