/
dpiOci.c
3068 lines (2635 loc) · 125 KB
/
dpiOci.c
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
//-----------------------------------------------------------------------------
// Copyright (c) 2017-2018 Oracle and/or its affiliates. All rights reserved.
// This program is free software: you can modify it and/or redistribute it
// under the terms of:
//
// (i) the Universal Permissive License v 1.0 or at your option, any
// later version (http://oss.oracle.com/licenses/upl); and/or
//
// (ii) the Apache License v 2.0. (http://www.apache.org/licenses/LICENSE-2.0)
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// dpiOci.c
// Link to OCI using dynamic linking. The OCI library (11.2+) is loaded
// dynamically and a function table kept for the functions that are used by
// DPI. This function table is populated as functions are used and permits use
// of all versions of OCI from one driver.
//-----------------------------------------------------------------------------
#include "dpiImpl.h"
// forward declarations of internal functions only used in this file
static void *dpiOci__allocateMem(void *unused, size_t size);
static void dpiOci__freeMem(void *unused, void *ptr);
static int dpiOci__loadLib(dpiError *error);
static int dpiOci__loadLibValidate(dpiError *error);
static int dpiOci__loadSymbol(const char *symbolName, void **symbol,
dpiError *error);
static void *dpiOci__reallocMem(void *unused, void *ptr, size_t newSize);
// macro to simplify code for loading each symbol
#define DPI_OCI_LOAD_SYMBOL(symbolName, symbol) \
if (!symbol && dpiOci__loadSymbol(symbolName, (void**) &symbol, \
error) < 0) \
return DPI_FAILURE;
// typedefs for all OCI functions used by ODPI-C
typedef int (*dpiOciFnType__aqDeq)(void *svchp, void *errhp,
const char *queue_name, void *deqopt, void *msgprop, void *payload_tdo,
void **payload, void **payload_ind, void **msgid, uint32_t flags);
typedef int (*dpiOciFnType__aqEnq)(void *svchp, void *errhp,
const char *queue_name, void *enqopt, void *msgprop, void *payload_tdo,
void **payload, void **payload_ind, void **msgid, uint32_t flags);
typedef int (*dpiOciFnType__arrayDescriptorAlloc)(const void *parenth,
void **descpp, const uint32_t type, uint32_t array_size,
const size_t xtramem_sz, void **usrmempp);
typedef int (*dpiOciFnType__arrayDescriptorFree)(void **descp,
const uint32_t type);
typedef int (*dpiOciFnType__attrGet)(const void *trgthndlp,
uint32_t trghndltyp, void *attributep, uint32_t *sizep,
uint32_t attrtype, void *errhp);
typedef int (*dpiOciFnType__attrSet)(void *trgthndlp, uint32_t trghndltyp,
void *attributep, uint32_t size, uint32_t attrtype, void *errhp);
typedef int (*dpiOciFnType__bindByName)(void *stmtp, void **bindp, void *errhp,
const char *placeholder, int32_t placeh_len, void *valuep,
int32_t value_sz, uint16_t dty, void *indp, uint16_t *alenp,
uint16_t *rcodep, uint32_t maxarr_len, uint32_t *curelep,
uint32_t mode);
typedef int (*dpiOciFnType__bindByName2)(void *stmtp, void **bindp,
void *errhp, const char *placeholder, int32_t placeh_len, void *valuep,
int64_t value_sz, uint16_t dty, void *indp, uint32_t *alenp,
uint16_t *rcodep, uint32_t maxarr_len, uint32_t *curelep,
uint32_t mode);
typedef int (*dpiOciFnType__bindByPos)(void *stmtp, void **bindp, void *errhp,
uint32_t position, void *valuep, int32_t value_sz, uint16_t dty,
void *indp, uint16_t *alenp, uint16_t *rcodep, uint32_t maxarr_len,
uint32_t *curelep, uint32_t mode);
typedef int (*dpiOciFnType__bindByPos2)(void *stmtp, void **bindp, void *errhp,
uint32_t position, void *valuep, int64_t value_sz, uint16_t dty,
void *indp, uint32_t *alenp, uint16_t *rcodep, uint32_t maxarr_len,
uint32_t *curelep, uint32_t mode);
typedef int (*dpiOciFnType__bindDynamic)(void *bindp, void *errhp, void *ictxp,
void *icbfp, void *octxp, void *ocbfp);
typedef int (*dpiOciFnType__bindObject)(void *bindp, void *errhp,
const void *type, void **pgvpp, uint32_t *pvszsp, void **indpp,
uint32_t *indszp);
typedef int (*dpiOciFnType__break)(void *hndlp, void *errhp);
typedef void (*dpiOciFnType__clientVersion)(int *major_version,
int *minor_version, int *update_num, int *patch_num,
int *port_update_num);
typedef int (*dpiOciFnType__collAppend)(void *env, void *err, const void *elem,
const void *elemind, void *coll);
typedef int (*dpiOciFnType__collAssignElem)(void *env, void *err,
int32_t index, const void *elem, const void *elemind, void *coll);
typedef int (*dpiOciFnType__collGetElem)(void *env, void *err,
const void *coll, int32_t index, int *exists, void **elem,
void **elemind);
typedef int (*dpiOciFnType__collSize)(void *env, void *err, const void *coll,
int32_t *size);
typedef int (*dpiOciFnType__collTrim)(void *env, void *err, int32_t trim_num,
void *coll);
typedef int (*dpiOciFnType__contextGetValue)(void *hdl, void *err,
const char *key, uint8_t keylen, void **ctx_value);
typedef int (*dpiOciFnType__contextSetValue)(void *hdl, void *err,
uint16_t duration, const char *key, uint8_t keylen, void *ctx_value);
typedef int (*dpiOciFnType__dateTimeConstruct)(void *hndl, void *err,
void *datetime, int16_t yr, uint8_t mnth, uint8_t dy, uint8_t hr,
uint8_t mm, uint8_t ss, uint32_t fsec, const char *tz,
size_t tzLength);
typedef int (*dpiOciFnType__dateTimeGetDate)(void *hndl, void *err,
const void *date, int16_t *yr, uint8_t *mnth, uint8_t *dy);
typedef int (*dpiOciFnType__dateTimeGetTime)(void *hndl, void *err,
void *datetime, uint8_t *hr, uint8_t *mm, uint8_t *ss, uint32_t *fsec);
typedef int (*dpiOciFnType__dateTimeGetTimeZoneOffset)(void *hndl, void *err,
const void *datetime, int8_t *hr, int8_t *mm);
typedef int (*dpiOciFnType__dateTimeIntervalAdd)(void *hndl, void *err,
void *datetime, void *inter, void *outdatetime);
typedef int (*dpiOciFnType__dateTimeSubtract)(void *hndl, void *err,
void *indate1, void *indate2, void *inter);
typedef int (*dpiOciFnType__dbShutdown)(void *svchp, void *errhp, void *admhp,
uint32_t mode);
typedef int (*dpiOciFnType__dbStartup)(void *svchp, void *errhp, void *admhp,
uint32_t mode, uint32_t flags);
typedef int (*dpiOciFnType__defineByPos)(void *stmtp, void **defnp,
void *errhp, uint32_t position, void *valuep, int32_t value_sz,
uint16_t dty, void *indp, uint16_t *rlenp, uint16_t *rcodep,
uint32_t mode);
typedef int (*dpiOciFnType__defineByPos2)(void *stmtp, void **defnp,
void *errhp, uint32_t position, void *valuep, uint64_t value_sz,
uint16_t dty, void *indp, uint32_t *rlenp, uint16_t *rcodep,
uint32_t mode);
typedef int (*dpiOciFnType__defineDynamic)(void *defnp, void *errhp,
void *octxp, void *ocbfp);
typedef int (*dpiOciFnType__defineObject)(void *defnp, void *errhp,
const void *type, void **pgvpp, uint32_t *pvszsp, void **indpp,
uint32_t *indszp);
typedef int (*dpiOciFnType__describeAny)(void *svchp, void *errhp,
void *objptr, uint32_t objnm_len, uint8_t objptr_typ,
uint8_t info_level, uint8_t objtyp, void *dschp);
typedef int (*dpiOciFnType__descriptorAlloc)(const void *parenth,
void **descpp, const uint32_t type, const size_t xtramem_sz,
void **usrmempp);
typedef int (*dpiOciFnType__descriptorFree)(void *descp, const uint32_t type);
typedef int (*dpiOciFnType__envNlsCreate)(void **envp, uint32_t mode,
void *ctxp, void *malocfp, void *ralocfp, void *mfreefp,
size_t xtramem_sz, void **usrmempp, uint16_t charset,
uint16_t ncharset);
typedef int (*dpiOciFnType__errorGet)(void *hndlp, uint32_t recordno,
char *sqlstate, int32_t *errcodep, char *bufp, uint32_t bufsiz,
uint32_t type);
typedef int (*dpiOciFnType__handleAlloc)(const void *parenth, void **hndlpp,
const uint32_t type, const size_t xtramem_sz, void **usrmempp);
typedef int (*dpiOciFnType__handleFree)(void *hndlp, const uint32_t type);
typedef int (*dpiOciFnType__intervalGetDaySecond)(void *hndl, void *err,
int32_t *dy, int32_t *hr, int32_t *mm, int32_t *ss, int32_t *fsec,
const void *result);
typedef int (*dpiOciFnType__intervalGetYearMonth)(void *hndl, void *err,
int32_t *yr, int32_t *mnth, const void *result);
typedef int (*dpiOciFnType__intervalSetDaySecond)(void *hndl, void *err,
int32_t dy, int32_t hr, int32_t mm, int32_t ss, int32_t fsec,
void *result);
typedef int (*dpiOciFnType__intervalSetYearMonth)(void *hndl, void *err,
int32_t yr, int32_t mnth, void *result);
typedef int (*dpiOciFnType__lobClose)(void *svchp, void *errhp, void *locp);
typedef int (*dpiOciFnType__lobCreateTemporary)(void *svchp, void *errhp,
void *locp, uint16_t csid, uint8_t csfrm, uint8_t lobtype, int cache,
uint16_t duration);
typedef int (*dpiOciFnType__lobFileExists)(void *svchp, void *errhp,
void *filep, int *flag);
typedef int (*dpiOciFnType__lobFileGetName)(void *envhp, void *errhp,
const void *filep, char *dir_alias, uint16_t *d_length, char *filename,
uint16_t *f_length);
typedef int (*dpiOciFnType__lobFileSetName)(void *envhp, void *errhp,
void **filepp, const char *dir_alias, uint16_t d_length,
const char *filename, uint16_t f_length);
typedef int (*dpiOciFnType__lobFreeTemporary)(void *svchp, void *errhp,
void *locp);
typedef int (*dpiOciFnType__lobGetChunkSize)(void *svchp, void *errhp,
void *locp, uint32_t *chunksizep);
typedef int (*dpiOciFnType__lobGetLength2)(void *svchp, void *errhp,
void *locp, uint64_t *lenp);
typedef int (*dpiOciFnType__lobIsOpen)(void *svchp, void *errhp, void *locp,
int *flag);
typedef int (*dpiOciFnType__lobIsTemporary)(void *envp, void *errhp,
void *locp, int *is_temporary);
typedef int (*dpiOciFnType__lobLocatorAssign)(void *svchp, void *errhp,
const void *src_locp, void **dst_locpp);
typedef int (*dpiOciFnType__lobOpen)(void *svchp, void *errhp, void *locp,
uint8_t mode);
typedef int (*dpiOciFnType__lobRead2)(void *svchp, void *errhp, void *locp,
uint64_t *byte_amtp, uint64_t *char_amtp, uint64_t offset, void *bufp,
uint64_t bufl, uint8_t piece, void *ctxp, void *cbfp, uint16_t csid,
uint8_t csfrm);
typedef int (*dpiOciFnType__lobTrim2)(void *svchp, void *errhp, void *locp,
uint64_t newlen);
typedef int (*dpiOciFnType__lobWrite2)(void *svchp, void *errhp, void *locp,
uint64_t *byte_amtp, uint64_t *char_amtp, uint64_t offset, void *bufp,
uint64_t buflen, uint8_t piece, void *ctxp, void *cbfp, uint16_t csid,
uint8_t csfrm);
typedef int (*dpiOciFnType__memoryAlloc)(void *hdl, void *err, void **mem,
uint16_t dur, uint32_t size, uint32_t flags);
typedef int (*dpiOciFnType__memoryFree)(void *hdl, void *err, void *mem);
typedef int (*dpiOciFnType__nlsCharSetConvert)(void *envhp, void *errhp,
uint16_t dstid, void *dstp, size_t dstlen, uint16_t srcid,
const void *srcp, size_t srclen, size_t *rsize);
typedef int (*dpiOciFnType__nlsCharSetIdToName)(void *envhp, char *buf,
size_t buflen, uint16_t id);
typedef uint16_t (*dpiOciFnType__nlsCharSetNameToId)(void *envhp,
const char *name);
typedef int (*dpiOciFnType__nlsEnvironmentVariableGet)(void *val, size_t size,
uint16_t item, uint16_t charset, size_t *rsize);
typedef int (*dpiOciFnType__nlsNameMap)(void *envhp, char *buf, size_t buflen,
const char *srcbuf, uint32_t flag);
typedef int (*dpiOciFnType__nlsNumericInfoGet)(void *envhp, void *errhp,
int32_t *val, uint16_t item);
typedef int (*dpiOciFnType__numberFromInt)(void *err, const void *inum,
unsigned int inum_length, unsigned int inum_s_flag, void *number);
typedef int (*dpiOciFnType__numberFromReal)(void *err, const void *number,
unsigned int rsl_length, void *rsl);
typedef int (*dpiOciFnType__numberToInt)(void *err, const void *number,
unsigned int rsl_length, unsigned int rsl_flag, void *rsl);
typedef int (*dpiOciFnType__numberToReal)(void *err, const void *number,
unsigned int rsl_length, void *rsl);
typedef int (*dpiOciFnType__objectCopy)(void *env, void *err, const void *svc,
void *source, void *null_source, void *target, void *null_target,
void *tdo, uint16_t duration, uint8_t option);
typedef int (*dpiOciFnType__objectFree)(void *env, void *err, void *instance,
uint16_t flags);
typedef int (*dpiOciFnType__objectGetAttr)(void *env, void *err,
void *instance, void *null_struct, void *tdo, const char **names,
const uint32_t *lengths, const uint32_t name_count,
const uint32_t *indexes, const uint32_t index_count,
int16_t *attr_null_status, void **attr_null_struct, void **attr_value,
void **attr_tdo);
typedef int (*dpiOciFnType__objectGetInd)(void *env, void *err, void *instance,
void **null_struct);
typedef int (*dpiOciFnType__objectNew)(void *env, void *err, const void *svc,
uint16_t typecode, void *tdo, void *table, uint16_t duration,
int value, void **instance);
typedef int (*dpiOciFnType__objectPin)(void *env, void *err, void *object_ref,
void *corhdl, int pin_option, uint16_t pin_duration, int lock_option,
void **object);
typedef int (*dpiOciFnType__objectSetAttr)(void *env, void *err,
void *instance, void *null_struct, void *tdo, const char **names,
const uint32_t *lengths, const uint32_t name_count,
const uint32_t *indexes, const uint32_t index_count,
const int16_t null_status, const void *attr_null_struct,
const void *attr_value);
typedef int (*dpiOciFnType__paramGet)(const void *hndlp, uint32_t htype,
void *errhp, void **parmdpp, uint32_t pos);
typedef int (*dpiOciFnType__passwordChange)(void *svchp, void *errhp,
const char *user_name, uint32_t usernm_len, const char *opasswd,
uint32_t opasswd_len, const char *npasswd, uint32_t npasswd_len,
uint32_t mode);
typedef int (*dpiOciFnType__ping)(void *svchp, void *errhp, uint32_t mode);
typedef int (*dpiOciFnType__rawAssignBytes)(void *env, void *err,
const char *rhs, uint32_t rhs_len, void **lhs);
typedef void *(*dpiOciFnType__rawPtr)(void *env, const void *raw);
typedef int (*dpiOciFnType__rawResize)(void *env, void *err, uint32_t new_size,
void **raw);
typedef uint32_t (*dpiOciFnType__rawSize)(void * env, const void *raw);
typedef int (*dpiOciFnType__rowidToChar)(void *rowidDesc, char *outbfp,
uint16_t *outbflp, void *errhp);
typedef int (*dpiOciFnType__serverAttach)(void *srvhp, void *errhp,
const char *dblink, int32_t dblink_len, uint32_t mode);
typedef int (*dpiOciFnType__serverDetach)(void *srvhp, void *errhp,
uint32_t mode);
typedef int (*dpiOciFnType__serverRelease)(void *hndlp, void *errhp,
char *bufp, uint32_t bufsz, uint8_t hndltype, uint32_t *version);
typedef int (*dpiOciFnType__sessionBegin)(void *svchp, void *errhp,
void *usrhp, uint32_t credt, uint32_t mode);
typedef int (*dpiOciFnType__sessionEnd)(void *svchp, void *errhp, void *usrhp,
uint32_t mode);
typedef int (*dpiOciFnType__sessionGet)(void *envhp, void *errhp, void **svchp,
void *authhp, const char *poolName, uint32_t poolName_len,
const char *tagInfo, uint32_t tagInfo_len, const char **retTagInfo,
uint32_t *retTagInfo_len, int *found, uint32_t mode);
typedef int (*dpiOciFnType__sessionPoolCreate)(void *envhp, void *errhp,
void *spoolhp, char **poolName, uint32_t *poolNameLen,
const char *connStr, uint32_t connStrLen, uint32_t sessMin,
uint32_t sessMax, uint32_t sessIncr, const char *userid,
uint32_t useridLen, const char *password, uint32_t passwordLen,
uint32_t mode);
typedef int (*dpiOciFnType__sessionPoolDestroy)(void *spoolhp, void *errhp,
uint32_t mode);
typedef int (*dpiOciFnType__sessionRelease)(void *svchp, void *errhp,
const char *tag, uint32_t tag_len, uint32_t mode);
typedef int (*dpiOciFnType__shardingKeyColumnAdd)(void *shardingKey,
void *errhp, void *col, uint32_t colLen, uint16_t colType,
uint32_t mode);
typedef int (*dpiOciFnType__stmtExecute)(void *svchp, void *stmtp, void *errhp,
uint32_t iters, uint32_t rowoff, const void *snap_in, void *snap_out,
uint32_t mode);
typedef int (*dpiOciFnType__stmtFetch2)(void *stmtp, void *errhp,
uint32_t nrows, uint16_t orientation, int32_t scrollOffset,
uint32_t mode);
typedef int (*dpiOciFnType__stmtGetBindInfo)(void *stmtp, void *errhp,
uint32_t size, uint32_t startloc, int32_t *found, char *bvnp[],
uint8_t bvnl[], char *invp[], uint8_t inpl[], uint8_t dupl[],
void **hndl);
typedef int (*dpiOciFnType__stmtGetNextResult)(void *stmthp, void *errhp,
void **result, uint32_t *rtype, uint32_t mode);
typedef int (*dpiOciFnType__stmtPrepare2)(void *svchp, void **stmtp,
void *errhp, const char *stmt, uint32_t stmt_len, const char *key,
uint32_t key_len, uint32_t language, uint32_t mode);
typedef int (*dpiOciFnType__stmtRelease)(void *stmtp, void *errhp,
const char *key, uint32_t key_len, uint32_t mode);
typedef int (*dpiOciFnType__stringAssignText)(void *env, void *err,
const char *rhs, uint32_t rhs_len, void **lhs);
typedef char *(*dpiOciFnType__stringPtr)(void *env, const void *vs);
typedef int (*dpiOciFnType__stringResize)(void *env, void *err,
uint32_t new_size, void **str);
typedef uint32_t (*dpiOciFnType__stringSize)(void *env, const void *vs);
typedef int (*dpiOciFnType__subscriptionRegister)(void *svchp,
void **subscrhpp, uint16_t count, void *errhp, uint32_t mode);
typedef int (*dpiOciFnType__subscriptionUnRegister)(void *svchp,
void *subscrhp, void *errhp, uint32_t mode);
typedef int (*dpiOciFnType__tableDelete)(void *env, void *err, int32_t index,
void *tbl);
typedef int (*dpiOciFnType__tableExists)(void *env, void *err, const void *tbl,
int32_t index, int *exists);
typedef int (*dpiOciFnType__tableFirst)(void *env, void *err, const void *tbl,
int32_t *index);
typedef int (*dpiOciFnType__tableLast)(void *env, void *err, const void *tbl,
int32_t *index);
typedef int (*dpiOciFnType__tableNext)(void *env, void *err, int32_t index,
const void *tbl, int32_t *next_index, int *exists);
typedef int (*dpiOciFnType__tablePrev)(void *env, void *err, int32_t index,
const void *tbl, int32_t *prev_index, int *exists);
typedef int (*dpiOciFnType__tableSize)(void *env, void *err, const void *tbl,
int32_t *size);
typedef int (*dpiOciFnType__threadKeyDestroy)(void *hndl, void *err,
void **key);
typedef int (*dpiOciFnType__threadKeyGet)(void *hndl, void *err, void *key,
void **pValue);
typedef int (*dpiOciFnType__threadKeyInit)(void *hndl, void *err, void **key,
void *destFn);
typedef int (*dpiOciFnType__threadKeySet)(void *hndl, void *err, void *key,
void *value);
typedef void (*dpiOciFnType__threadProcessInit)(void);
typedef int (*dpiOciFnType__transCommit)(void *svchp, void *errhp,
uint32_t flags);
typedef int (*dpiOciFnType__transPrepare)(void *svchp, void *errhp,
uint32_t flags);
typedef int (*dpiOciFnType__transRollback)(void *svchp, void *errhp,
uint32_t flags);
typedef int (*dpiOciFnType__transStart)(void *svchp, void *errhp,
unsigned int timeout, uint32_t flags);
typedef int (*dpiOciFnType__typeByFullName)(void *env, void *err,
const void *svc, const char *full_type_name,
uint32_t full_type_name_length, const char *version_name,
uint32_t version_name_length, uint16_t pin_duration, int get_option,
void **tdo);
// library handle for dynamically loaded OCI library
static void *dpiOciLibHandle = NULL;
// library names to search
static const char *dpiOciLibNames[] = {
#if defined _WIN32 || defined __CYGWIN__
"oci.dll",
#elif __APPLE__
"libclntsh.dylib",
"libclntsh.dylib.12.1",
"libclntsh.dylib.11.1",
#else
"libclntsh.so",
"libclntsh.so.12.1",
"libclntsh.so.11.1",
#endif
NULL
};
// URL fragment to use in load library exception
#if defined _WIN32 || defined __CYGWIN__
#define DPI_ERR_LOAD_URL_FRAGMENT "windows"
#elif __APPLE__
#define DPI_ERR_LOAD_URL_FRAGMENT "macos"
#else
#define DPI_ERR_LOAD_URL_FRAGMENT "linux"
#endif
// version information for loaded OCI library
static dpiVersionInfo dpiOciLibVersionInfo;
// all OCI symbols used by ODPI-C
static struct {
dpiOciFnType__aqDeq fnAqDeq;
dpiOciFnType__aqEnq fnAqEnq;
dpiOciFnType__arrayDescriptorAlloc fnArrayDescriptorAlloc;
dpiOciFnType__arrayDescriptorFree fnArrayDescriptorFree;
dpiOciFnType__attrGet fnAttrGet;
dpiOciFnType__attrSet fnAttrSet;
dpiOciFnType__bindByName fnBindByName;
dpiOciFnType__bindByName2 fnBindByName2;
dpiOciFnType__bindByPos fnBindByPos;
dpiOciFnType__bindByPos2 fnBindByPos2;
dpiOciFnType__bindDynamic fnBindDynamic;
dpiOciFnType__bindObject fnBindObject;
dpiOciFnType__break fnBreak;
dpiOciFnType__clientVersion fnClientVersion;
dpiOciFnType__collAppend fnCollAppend;
dpiOciFnType__collAssignElem fnCollAssignElem;
dpiOciFnType__collGetElem fnCollGetElem;
dpiOciFnType__collSize fnCollSize;
dpiOciFnType__collTrim fnCollTrim;
dpiOciFnType__contextGetValue fnContextGetValue;
dpiOciFnType__contextSetValue fnContextSetValue;
dpiOciFnType__dateTimeConstruct fnDateTimeConstruct;
dpiOciFnType__dateTimeGetDate fnDateTimeGetDate;
dpiOciFnType__dateTimeGetTime fnDateTimeGetTime;
dpiOciFnType__dateTimeGetTimeZoneOffset fnDateTimeGetTimeZoneOffset;
dpiOciFnType__dateTimeIntervalAdd fnDateTimeIntervalAdd;
dpiOciFnType__dateTimeSubtract fnDateTimeSubtract;
dpiOciFnType__dbShutdown fnDbShutdown;
dpiOciFnType__dbStartup fnDbStartup;
dpiOciFnType__defineByPos fnDefineByPos;
dpiOciFnType__defineByPos2 fnDefineByPos2;
dpiOciFnType__defineDynamic fnDefineDynamic;
dpiOciFnType__defineObject fnDefineObject;
dpiOciFnType__describeAny fnDescribeAny;
dpiOciFnType__descriptorAlloc fnDescriptorAlloc;
dpiOciFnType__descriptorFree fnDescriptorFree;
dpiOciFnType__envNlsCreate fnEnvNlsCreate;
dpiOciFnType__errorGet fnErrorGet;
dpiOciFnType__handleAlloc fnHandleAlloc;
dpiOciFnType__handleFree fnHandleFree;
dpiOciFnType__intervalGetDaySecond fnIntervalGetDaySecond;
dpiOciFnType__intervalGetYearMonth fnIntervalGetYearMonth;
dpiOciFnType__intervalSetDaySecond fnIntervalSetDaySecond;
dpiOciFnType__intervalSetYearMonth fnIntervalSetYearMonth;
dpiOciFnType__lobClose fnLobClose;
dpiOciFnType__lobCreateTemporary fnLobCreateTemporary;
dpiOciFnType__lobFileExists fnLobFileExists;
dpiOciFnType__lobFileGetName fnLobFileGetName;
dpiOciFnType__lobFileSetName fnLobFileSetName;
dpiOciFnType__lobFreeTemporary fnLobFreeTemporary;
dpiOciFnType__lobGetChunkSize fnLobGetChunkSize;
dpiOciFnType__lobGetLength2 fnLobGetLength2;
dpiOciFnType__lobIsOpen fnLobIsOpen;
dpiOciFnType__lobIsTemporary fnLobIsTemporary;
dpiOciFnType__lobLocatorAssign fnLobLocatorAssign;
dpiOciFnType__lobOpen fnLobOpen;
dpiOciFnType__lobRead2 fnLobRead2;
dpiOciFnType__lobTrim2 fnLobTrim2;
dpiOciFnType__lobWrite2 fnLobWrite2;
dpiOciFnType__memoryAlloc fnMemoryAlloc;
dpiOciFnType__memoryFree fnMemoryFree;
dpiOciFnType__nlsCharSetConvert fnNlsCharSetConvert;
dpiOciFnType__nlsCharSetIdToName fnNlsCharSetIdToName;
dpiOciFnType__nlsCharSetNameToId fnNlsCharSetNameToId;
dpiOciFnType__nlsEnvironmentVariableGet fnNlsEnvironmentVariableGet;
dpiOciFnType__nlsNameMap fnNlsNameMap;
dpiOciFnType__nlsNumericInfoGet fnNlsNumericInfoGet;
dpiOciFnType__numberFromInt fnNumberFromInt;
dpiOciFnType__numberFromReal fnNumberFromReal;
dpiOciFnType__numberToInt fnNumberToInt;
dpiOciFnType__numberToReal fnNumberToReal;
dpiOciFnType__objectCopy fnObjectCopy;
dpiOciFnType__objectFree fnObjectFree;
dpiOciFnType__objectGetAttr fnObjectGetAttr;
dpiOciFnType__objectGetInd fnObjectGetInd;
dpiOciFnType__objectNew fnObjectNew;
dpiOciFnType__objectPin fnObjectPin;
dpiOciFnType__objectSetAttr fnObjectSetAttr;
dpiOciFnType__paramGet fnParamGet;
dpiOciFnType__passwordChange fnPasswordChange;
dpiOciFnType__ping fnPing;
dpiOciFnType__rawAssignBytes fnRawAssignBytes;
dpiOciFnType__rawPtr fnRawPtr;
dpiOciFnType__rawResize fnRawResize;
dpiOciFnType__rawSize fnRawSize;
dpiOciFnType__rowidToChar fnRowidToChar;
dpiOciFnType__serverAttach fnServerAttach;
dpiOciFnType__serverDetach fnServerDetach;
dpiOciFnType__serverRelease fnServerRelease;
dpiOciFnType__sessionBegin fnSessionBegin;
dpiOciFnType__sessionEnd fnSessionEnd;
dpiOciFnType__sessionGet fnSessionGet;
dpiOciFnType__sessionPoolCreate fnSessionPoolCreate;
dpiOciFnType__sessionPoolDestroy fnSessionPoolDestroy;
dpiOciFnType__sessionRelease fnSessionRelease;
dpiOciFnType__shardingKeyColumnAdd fnShardingKeyColumnAdd;
dpiOciFnType__stmtExecute fnStmtExecute;
dpiOciFnType__stmtFetch2 fnStmtFetch2;
dpiOciFnType__stmtGetBindInfo fnStmtGetBindInfo;
dpiOciFnType__stmtGetNextResult fnStmtGetNextResult;
dpiOciFnType__stmtPrepare2 fnStmtPrepare2;
dpiOciFnType__stmtRelease fnStmtRelease;
dpiOciFnType__stringAssignText fnStringAssignText;
dpiOciFnType__stringPtr fnStringPtr;
dpiOciFnType__stringResize fnStringResize;
dpiOciFnType__stringSize fnStringSize;
dpiOciFnType__subscriptionRegister fnSubscriptionRegister;
dpiOciFnType__subscriptionUnRegister fnSubscriptionUnRegister;
dpiOciFnType__tableDelete fnTableDelete;
dpiOciFnType__tableExists fnTableExists;
dpiOciFnType__tableFirst fnTableFirst;
dpiOciFnType__tableLast fnTableLast;
dpiOciFnType__tableNext fnTableNext;
dpiOciFnType__tablePrev fnTablePrev;
dpiOciFnType__tableSize fnTableSize;
dpiOciFnType__threadKeyDestroy fnThreadKeyDestroy;
dpiOciFnType__threadKeyGet fnThreadKeyGet;
dpiOciFnType__threadKeyInit fnThreadKeyInit;
dpiOciFnType__threadKeySet fnThreadKeySet;
dpiOciFnType__threadProcessInit fnThreadProcessInit;
dpiOciFnType__transCommit fnTransCommit;
dpiOciFnType__transPrepare fnTransPrepare;
dpiOciFnType__transRollback fnTransRollback;
dpiOciFnType__transStart fnTransStart;
dpiOciFnType__typeByFullName fnTypeByFullName;
} dpiOciSymbols;
//-----------------------------------------------------------------------------
// dpiOci__allocateMem() [INTERNAL]
// Wrapper for OCI allocation of memory, only used when debugging memory
// allocation.
//-----------------------------------------------------------------------------
static void *dpiOci__allocateMem(void *unused, size_t size)
{
void *ptr;
ptr = malloc(size);
dpiDebug__print("OCI allocated %u bytes at %p\n", size, ptr);
return ptr;
}
//-----------------------------------------------------------------------------
// dpiOci__aqDeq() [INTERNAL]
// Wrapper for OCIAQDeq().
//-----------------------------------------------------------------------------
int dpiOci__aqDeq(dpiConn *conn, const char *queueName, void *options,
void *msgProps, void *payloadType, void **payload, void **payloadInd,
void **msgId, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCIAQDeq", dpiOciSymbols.fnAqDeq)
status = (*dpiOciSymbols.fnAqDeq)(conn->handle, error->handle, queueName,
options, msgProps, payloadType, payload, payloadInd, msgId,
DPI_OCI_DEFAULT);
return dpiError__check(error, status, conn, "dequeue message");
}
//-----------------------------------------------------------------------------
// dpiOci__aqEnq() [INTERNAL]
// Wrapper for OCIAQEnq().
//-----------------------------------------------------------------------------
int dpiOci__aqEnq(dpiConn *conn, const char *queueName, void *options,
void *msgProps, void *payloadType, void **payload, void **payloadInd,
void **msgId, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCIAQEnq", dpiOciSymbols.fnAqEnq)
status = (*dpiOciSymbols.fnAqEnq)(conn->handle, error->handle, queueName,
options, msgProps, payloadType, payload, payloadInd, msgId,
DPI_OCI_DEFAULT);
return dpiError__check(error, status, conn, "enqueue message");
}
//-----------------------------------------------------------------------------
// dpiOci__arrayDescriptorAlloc() [INTERNAL]
// Wrapper for OCIArrayDescriptorAlloc().
//-----------------------------------------------------------------------------
int dpiOci__arrayDescriptorAlloc(void *envHandle, void **handle,
uint32_t handleType, uint32_t arraySize, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCIArrayDescriptorAlloc",
dpiOciSymbols.fnArrayDescriptorAlloc)
status = (*dpiOciSymbols.fnArrayDescriptorAlloc)(envHandle, handle,
handleType, arraySize, 0, NULL);
return dpiError__check(error, status, NULL, "allocate descriptors");
}
//-----------------------------------------------------------------------------
// dpiOci__arrayDescriptorFree() [INTERNAL]
// Wrapper for OCIArrayDescriptorFree().
//-----------------------------------------------------------------------------
int dpiOci__arrayDescriptorFree(void **handle, uint32_t handleType)
{
dpiError *error = NULL;
int status;
DPI_OCI_LOAD_SYMBOL("OCIArrayDescriptorFree",
dpiOciSymbols.fnArrayDescriptorFree)
status = (*dpiOciSymbols.fnArrayDescriptorFree)(handle, handleType);
if (status != DPI_OCI_SUCCESS && dpiDebugLevel & DPI_DEBUG_LEVEL_FREES)
dpiDebug__print("free array descriptors %p, handleType %d failed\n",
handle, handleType);
return DPI_SUCCESS;
}
//-----------------------------------------------------------------------------
// dpiOci__attrGet() [INTERNAL]
// Wrapper for OCIAttrGet().
//-----------------------------------------------------------------------------
int dpiOci__attrGet(const void *handle, uint32_t handleType, void *ptr,
uint32_t *size, uint32_t attribute, const char *action,
dpiError *error)
{
int status;
status = (*dpiOciSymbols.fnAttrGet)(handle, handleType, ptr, size,
attribute, error->handle);
if (action)
return dpiError__check(error, status, NULL, action);
return DPI_SUCCESS;
}
//-----------------------------------------------------------------------------
// dpiOci__attrSet() [INTERNAL]
// Wrapper for OCIAttrSet().
//-----------------------------------------------------------------------------
int dpiOci__attrSet(void *handle, uint32_t handleType, void *ptr,
uint32_t size, uint32_t attribute, const char *action, dpiError *error)
{
int status;
status = (*dpiOciSymbols.fnAttrSet)(handle, handleType, ptr, size,
attribute, error->handle);
if (action)
return dpiError__check(error, status, NULL, action);
return DPI_SUCCESS;
}
//-----------------------------------------------------------------------------
// dpiOci__bindByName() [INTERNAL]
// Wrapper for OCIBindByName().
//-----------------------------------------------------------------------------
int dpiOci__bindByName(dpiStmt *stmt, void **bindHandle, const char *name,
int32_t nameLength, int dynamicBind, dpiVar *var, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCIBindByName", dpiOciSymbols.fnBindByName)
status = (*dpiOciSymbols.fnBindByName)(stmt->handle, bindHandle,
error->handle, name, nameLength,
(dynamicBind) ? NULL : var->buffer.data.asRaw,
(var->isDynamic) ? INT_MAX : (int32_t) var->sizeInBytes,
var->type->oracleType, (dynamicBind) ? NULL :
var->buffer.indicator,
(dynamicBind || var->type->sizeInBytes) ? NULL :
var->buffer.actualLength16,
(dynamicBind) ? NULL : var->buffer.returnCode,
(var->isArray) ? var->buffer.maxArraySize : 0,
(var->isArray) ? &var->buffer.actualArraySize : NULL,
(dynamicBind) ? DPI_OCI_DATA_AT_EXEC : DPI_OCI_DEFAULT);
return dpiError__check(error, status, stmt->conn, "bind by name");
}
//-----------------------------------------------------------------------------
// dpiOci__bindByName2() [INTERNAL]
// Wrapper for OCIBindByName2().
//-----------------------------------------------------------------------------
int dpiOci__bindByName2(dpiStmt *stmt, void **bindHandle, const char *name,
int32_t nameLength, int dynamicBind, dpiVar *var, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCIBindByName2", dpiOciSymbols.fnBindByName2)
status = (*dpiOciSymbols.fnBindByName2)(stmt->handle, bindHandle,
error->handle, name, nameLength,
(dynamicBind) ? NULL : var->buffer.data.asRaw,
(var->isDynamic) ? INT_MAX : var->sizeInBytes,
var->type->oracleType, (dynamicBind) ? NULL :
var->buffer.indicator,
(dynamicBind || var->type->sizeInBytes) ? NULL :
var->buffer.actualLength32,
(dynamicBind) ? NULL : var->buffer.returnCode,
(var->isArray) ? var->buffer.maxArraySize : 0,
(var->isArray) ? &var->buffer.actualArraySize : NULL,
(dynamicBind) ? DPI_OCI_DATA_AT_EXEC : DPI_OCI_DEFAULT);
return dpiError__check(error, status, stmt->conn, "bind by name");
}
//-----------------------------------------------------------------------------
// dpiOci__bindByPos() [INTERNAL]
// Wrapper for OCIBindByPos().
//-----------------------------------------------------------------------------
int dpiOci__bindByPos(dpiStmt *stmt, void **bindHandle, uint32_t pos,
int dynamicBind, dpiVar *var, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCIBindByPos", dpiOciSymbols.fnBindByPos)
status = (*dpiOciSymbols.fnBindByPos)(stmt->handle, bindHandle,
error->handle, pos, (dynamicBind) ? NULL : var->buffer.data.asRaw,
(var->isDynamic) ? INT_MAX : (int32_t) var->sizeInBytes,
var->type->oracleType, (dynamicBind) ? NULL :
var->buffer.indicator,
(dynamicBind || var->type->sizeInBytes) ? NULL :
var->buffer.actualLength16,
(dynamicBind) ? NULL : var->buffer.returnCode,
(var->isArray) ? var->buffer.maxArraySize : 0,
(var->isArray) ? &var->buffer.actualArraySize : NULL,
(dynamicBind) ? DPI_OCI_DATA_AT_EXEC : DPI_OCI_DEFAULT);
return dpiError__check(error, status, stmt->conn, "bind by position");
}
//-----------------------------------------------------------------------------
// dpiOci__bindByPos2() [INTERNAL]
// Wrapper for OCIBindByPos2().
//-----------------------------------------------------------------------------
int dpiOci__bindByPos2(dpiStmt *stmt, void **bindHandle, uint32_t pos,
int dynamicBind, dpiVar *var, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCIBindByPos2", dpiOciSymbols.fnBindByPos2)
status = (*dpiOciSymbols.fnBindByPos2)(stmt->handle, bindHandle,
error->handle, pos, (dynamicBind) ? NULL : var->buffer.data.asRaw,
(var->isDynamic) ? INT_MAX : var->sizeInBytes,
var->type->oracleType, (dynamicBind) ? NULL :
var->buffer.indicator,
(dynamicBind || var->type->sizeInBytes) ? NULL :
var->buffer.actualLength32,
(dynamicBind) ? NULL : var->buffer.returnCode,
(var->isArray) ? var->buffer.maxArraySize : 0,
(var->isArray) ? &var->buffer.actualArraySize : NULL,
(dynamicBind) ? DPI_OCI_DATA_AT_EXEC : DPI_OCI_DEFAULT);
return dpiError__check(error, status, stmt->conn, "bind by position");
}
//-----------------------------------------------------------------------------
// dpiOci__bindDynamic() [INTERNAL]
// Wrapper for OCIBindDynamic().
//-----------------------------------------------------------------------------
int dpiOci__bindDynamic(dpiVar *var, void *bindHandle, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCIBindDynamic", dpiOciSymbols.fnBindDynamic)
status = (*dpiOciSymbols.fnBindDynamic)(bindHandle, error->handle, var,
(void*) dpiVar__inBindCallback, var,
(void*) dpiVar__outBindCallback);
return dpiError__check(error, status, var->conn, "bind dynamic");
}
//-----------------------------------------------------------------------------
// dpiOci__bindObject() [INTERNAL]
// Wrapper for OCIBindObject().
//-----------------------------------------------------------------------------
int dpiOci__bindObject(dpiVar *var, void *bindHandle, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCIBindObject", dpiOciSymbols.fnBindObject)
status = (*dpiOciSymbols.fnBindObject)(bindHandle, error->handle,
var->objectType->tdo, (void**) var->buffer.data.asRaw, 0,
var->buffer.objectIndicator, 0);
return dpiError__check(error, status, var->conn, "bind object");
}
//-----------------------------------------------------------------------------
// dpiOci__break() [INTERNAL]
// Wrapper for OCIBreak().
//-----------------------------------------------------------------------------
int dpiOci__break(dpiConn *conn, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCIBreak", dpiOciSymbols.fnBreak)
status = (*dpiOciSymbols.fnBreak)(conn->handle, error->handle);
return dpiError__check(error, status, conn, "break execution");
}
//-----------------------------------------------------------------------------
// dpiOci__clientVersion() [INTERNAL]
// Set the version information in the context to the OCI client version
// information that was discovered when the OCI library was loaded.
//-----------------------------------------------------------------------------
void dpiOci__clientVersion(dpiContext *context)
{
context->versionInfo = &dpiOciLibVersionInfo;
}
//-----------------------------------------------------------------------------
// dpiOci__collAppend() [INTERNAL]
// Wrapper for OCICollAppend().
//-----------------------------------------------------------------------------
int dpiOci__collAppend(dpiConn *conn, const void *elem, const void *elemInd,
void *coll, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCICollAppend", dpiOciSymbols.fnCollAppend)
status = (*dpiOciSymbols.fnCollAppend)(conn->env->handle, error->handle,
elem, elemInd, coll);
return dpiError__check(error, status, conn, "append element");
}
//-----------------------------------------------------------------------------
// dpiOci__collAssignElem() [INTERNAL]
// Wrapper for OCICollAssignElem().
//-----------------------------------------------------------------------------
int dpiOci__collAssignElem(dpiConn *conn, int32_t index, const void *elem,
const void *elemInd, void *coll, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCICollAssignElem", dpiOciSymbols.fnCollAssignElem)
status = (*dpiOciSymbols.fnCollAssignElem)(conn->env->handle,
error->handle, index, elem, elemInd, coll);
return dpiError__check(error, status, conn, "assign element");
}
//-----------------------------------------------------------------------------
// dpiOci__collGetElem() [INTERNAL]
// Wrapper for OCICollGetElem().
//-----------------------------------------------------------------------------
int dpiOci__collGetElem(dpiConn *conn, void *coll, int32_t index, int *exists,
void **elem, void **elemInd, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCICollGetElem", dpiOciSymbols.fnCollGetElem)
status = (*dpiOciSymbols.fnCollGetElem)(conn->env->handle, error->handle,
coll, index, exists, elem, elemInd);
return dpiError__check(error, status, conn, "get element");
}
//-----------------------------------------------------------------------------
// dpiOci__collSize() [INTERNAL]
// Wrapper for OCICollSize().
//-----------------------------------------------------------------------------
int dpiOci__collSize(dpiConn *conn, void *coll, int32_t *size, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCICollSize", dpiOciSymbols.fnCollSize)
status = (*dpiOciSymbols.fnCollSize)(conn->env->handle, error->handle,
coll, size);
return dpiError__check(error, status, conn, "get size");
}
//-----------------------------------------------------------------------------
// dpiOci__collTrim() [INTERNAL]
// Wrapper for OCICollTrim().
//-----------------------------------------------------------------------------
int dpiOci__collTrim(dpiConn *conn, uint32_t numToTrim, void *coll,
dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCICollTrim", dpiOciSymbols.fnCollTrim)
status = (*dpiOciSymbols.fnCollTrim)(conn->env->handle, error->handle,
(int32_t) numToTrim, coll);
return dpiError__check(error, status, conn, "trim");
}
//-----------------------------------------------------------------------------
// dpiOci__contextGetValue() [INTERNAL]
// Wrapper for OCIContextGetValue().
//-----------------------------------------------------------------------------
int dpiOci__contextGetValue(dpiConn *conn, const char *key, uint32_t keyLength,
void **value, int checkError, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCIContextGetValue", dpiOciSymbols.fnContextGetValue)
status = (*dpiOciSymbols.fnContextGetValue)(conn->sessionHandle,
error->handle, key, (uint8_t) keyLength, value);
if (checkError)
return dpiError__check(error, status, conn, "get context value");
*value = NULL;
return DPI_SUCCESS;
}
//-----------------------------------------------------------------------------
// dpiOci__contextSetValue() [INTERNAL]
// Wrapper for OCIContextSetValue().
//-----------------------------------------------------------------------------
int dpiOci__contextSetValue(dpiConn *conn, const char *key, uint32_t keyLength,
void *value, int checkError, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCIContextSetValue", dpiOciSymbols.fnContextSetValue)
status = (*dpiOciSymbols.fnContextSetValue)(conn->sessionHandle,
error->handle, DPI_OCI_DURATION_SESSION, key, (uint8_t) keyLength,
value);
if (checkError)
return dpiError__check(error, status, conn, "set context value");
return DPI_SUCCESS;
}
//-----------------------------------------------------------------------------
// dpiOci__dateTimeConstruct() [INTERNAL]
// Wrapper for OCIDateTimeConstruct().
//-----------------------------------------------------------------------------
int dpiOci__dateTimeConstruct(void *envHandle, void *handle, int16_t year,
uint8_t month, uint8_t day, uint8_t hour, uint8_t minute,
uint8_t second, uint32_t fsecond, const char *tz, size_t tzLength,
dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCIDateTimeConstruct",
dpiOciSymbols.fnDateTimeConstruct)
status = (*dpiOciSymbols.fnDateTimeConstruct)(envHandle, error->handle,
handle, year, month, day, hour, minute, second, fsecond, tz,
tzLength);
return dpiError__check(error, status, NULL, "construct date");
}
//-----------------------------------------------------------------------------
// dpiOci__dateTimeGetDate() [INTERNAL]
// Wrapper for OCIDateTimeGetDate().
//-----------------------------------------------------------------------------
int dpiOci__dateTimeGetDate(void *envHandle, void *handle, int16_t *year,
uint8_t *month, uint8_t *day, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCIDateTimeGetDate", dpiOciSymbols.fnDateTimeGetDate)
status = (*dpiOciSymbols.fnDateTimeGetDate)(envHandle, error->handle,
handle, year, month, day);
return dpiError__check(error, status, NULL, "get date portion");
}
//-----------------------------------------------------------------------------
// dpiOci__dateTimeGetTime() [INTERNAL]
// Wrapper for OCIDateTimeGetTime().
//-----------------------------------------------------------------------------
int dpiOci__dateTimeGetTime(void *envHandle, void *handle, uint8_t *hour,
uint8_t *minute, uint8_t *second, uint32_t *fsecond, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCIDateTimeGetTime", dpiOciSymbols.fnDateTimeGetTime)
status = (*dpiOciSymbols.fnDateTimeGetTime)(envHandle, error->handle,
handle, hour, minute, second, fsecond);
return dpiError__check(error, status, NULL, "get time portion");
}
//-----------------------------------------------------------------------------
// dpiOci__dateTimeGetTimeZoneOffset() [INTERNAL]
// Wrapper for OCIDateTimeGetTimeZoneOffset().
//-----------------------------------------------------------------------------
int dpiOci__dateTimeGetTimeZoneOffset(void *envHandle, void *handle,
int8_t *tzHourOffset, int8_t *tzMinuteOffset, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCIDateTimeGetTimeZoneOffset",
dpiOciSymbols.fnDateTimeGetTimeZoneOffset)
status = (*dpiOciSymbols.fnDateTimeGetTimeZoneOffset)(envHandle,
error->handle, handle, tzHourOffset, tzMinuteOffset);
return dpiError__check(error, status, NULL, "get time zone portion");
}
//-----------------------------------------------------------------------------
// dpiOci__dateTimeIntervalAdd() [INTERNAL]
// Wrapper for OCIDateTimeIntervalAdd().
//-----------------------------------------------------------------------------
int dpiOci__dateTimeIntervalAdd(void *envHandle, void *handle, void *interval,
void *outHandle, dpiError *error)
{
int status;
DPI_OCI_LOAD_SYMBOL("OCIDateTimeIntervalAdd",
dpiOciSymbols.fnDateTimeIntervalAdd)
status = (*dpiOciSymbols.fnDateTimeIntervalAdd)(envHandle, error->handle,
handle, interval, outHandle);
return dpiError__check(error, status, NULL, "add interval to date");
}
//-----------------------------------------------------------------------------
// dpiOci__dateTimeSubtract() [INTERNAL]
// Wrapper for OCIDateTimeSubtract().
//-----------------------------------------------------------------------------
int dpiOci__dateTimeSubtract(void *envHandle, void *handle1, void *handle2,
void *interval, dpiError *error)
{
int status;