-
Notifications
You must be signed in to change notification settings - Fork 78
/
dpiImpl.h
2136 lines (1965 loc) · 100 KB
/
dpiImpl.h
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) 2016, 2020, 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)
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// dpiImpl.h
// Include file for implementation of ODPI-C library. The definitions in this
// file are subject to change without warning. Only the definitions in the file
// dpi.h are intended to be used publicly.
//-----------------------------------------------------------------------------
#ifndef DPI_IMPL
#define DPI_IMPL
// for gcc, ensure that GNU extensions are enabled so that dladdr() and
// dlinfo() are available on platforms like Linux
#if defined(__GNUC__) && !defined(_GNU_SOURCE)
#define _GNU_SOURCE
#endif
// Visual Studio 2005 introduced deprecation warnings for "insecure" and POSIX
// functions; silence these warnings
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS 1
#endif
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <ctype.h>
#include <limits.h>
#include <float.h>
#include <math.h>
#include "dpi.h"
#ifdef _WIN32
#include <windows.h>
#ifndef isnan
#define isnan _isnan
#endif
#else
#include <errno.h>
#include <pthread.h>
#include <sys/time.h>
#include <dlfcn.h>
#endif
#ifdef __linux
#include <unistd.h>
#include <sys/syscall.h>
#endif
#ifdef _MSC_VER
#if _MSC_VER < 1900
#define PRId64 "I64d"
#define PRIu64 "I64u"
#define snprintf _snprintf
#endif
#endif
#ifndef PRIu64
#include <inttypes.h>
#endif
#ifdef __GNUC__
#define UNUSED __attribute((unused))
#else
#define UNUSED
#endif
// define debugging level (defined in dpiGlobal.c)
extern unsigned long dpiDebugLevel;
// define max error size
#define DPI_MAX_ERROR_SIZE 3072
// define context name for ping interval
#define DPI_CONTEXT_LAST_TIME_USED "DPI_LAST_TIME_USED"
// define size of buffer used for numbers transferred to/from Oracle as text
#define DPI_NUMBER_AS_TEXT_CHARS 172
// define maximum number of digits possible in an Oracle number
#define DPI_NUMBER_MAX_DIGITS 40
// define maximum size in bytes supported by basic string handling
#define DPI_MAX_BASIC_BUFFER_SIZE 32767
// define internal chunk size used for dynamic binding/fetching
#define DPI_DYNAMIC_BYTES_CHUNK_SIZE 65536
// define maximum buffer size permitted in variables
#define DPI_MAX_VAR_BUFFER_SIZE (1024 * 1024 * 1024 - 2)
// define subscription grouping repeat count
#define DPI_SUBSCR_GROUPING_FOREVER -1
// define number of rows to prefetch
#define DPI_PREFETCH_ROWS_DEFAULT 2
// define default load error URL
#if defined _WIN32 || defined __CYGWIN__
#define DPI_ERR_LOAD_URL_FRAGMENT "#windows"
#elif __APPLE__
#define DPI_ERR_LOAD_URL_FRAGMENT "#macos"
#elif __linux__
#define DPI_ERR_LOAD_URL_FRAGMENT "#linux"
#else
#define DPI_ERR_LOAD_URL_FRAGMENT ""
#endif
#define DPI_DEFAULT_LOAD_ERROR_URL "https://oracle.github.io/odpi/doc/installation.html" DPI_ERR_LOAD_URL_FRAGMENT
// define well-known character sets
#define DPI_CHARSET_ID_ASCII 1
#define DPI_CHARSET_ID_UTF8 873
#define DPI_CHARSET_ID_UTF16 1000
#define DPI_CHARSET_ID_UTF16BE 2000
#define DPI_CHARSET_ID_UTF16LE 2002
#define DPI_CHARSET_NAME_ASCII "ASCII"
#define DPI_CHARSET_NAME_UTF8 "UTF-8"
#define DPI_CHARSET_NAME_UTF16 "UTF-16"
#define DPI_CHARSET_NAME_UTF16BE "UTF-16BE"
#define DPI_CHARSET_NAME_UTF16LE "UTF-16LE"
// define handle types used for allocating OCI handles
#define DPI_OCI_HTYPE_ENV 1
#define DPI_OCI_HTYPE_ERROR 2
#define DPI_OCI_HTYPE_SVCCTX 3
#define DPI_OCI_HTYPE_STMT 4
#define DPI_OCI_HTYPE_BIND 5
#define DPI_OCI_HTYPE_DEFINE 6
#define DPI_OCI_HTYPE_DESCRIBE 7
#define DPI_OCI_HTYPE_SERVER 8
#define DPI_OCI_HTYPE_SESSION 9
#define DPI_OCI_HTYPE_AUTHINFO 9
#define DPI_OCI_HTYPE_TRANS 10
#define DPI_OCI_HTYPE_SUBSCRIPTION 13
#define DPI_OCI_HTYPE_SPOOL 27
#define DPI_OCI_HTYPE_ADMIN 28
#define DPI_OCI_HTYPE_SODA_COLLECTION 30
#define DPI_OCI_HTYPE_SODA_DOCUMENT 31
#define DPI_OCI_HTYPE_SODA_COLL_CURSOR 32
#define DPI_OCI_HTYPE_SODA_OPER_OPTIONS 33
#define DPI_OCI_HTYPE_SODA_OUTPUT_OPTIONS 34
#define DPI_OCI_HTYPE_SODA_DOC_CURSOR 36
// define OCI descriptor types
#define DPI_OCI_DTYPE_LOB 50
#define DPI_OCI_DTYPE_PARAM 53
#define DPI_OCI_DTYPE_ROWID 54
#define DPI_OCI_DTYPE_AQENQ_OPTIONS 57
#define DPI_OCI_DTYPE_AQDEQ_OPTIONS 58
#define DPI_OCI_DTYPE_AQMSG_PROPERTIES 59
#define DPI_OCI_DTYPE_INTERVAL_YM 62
#define DPI_OCI_DTYPE_INTERVAL_DS 63
#define DPI_OCI_DTYPE_AQNFY_DESCRIPTOR 64
#define DPI_OCI_DTYPE_TIMESTAMP 68
#define DPI_OCI_DTYPE_TIMESTAMP_TZ 69
#define DPI_OCI_DTYPE_TIMESTAMP_LTZ 70
#define DPI_OCI_DTYPE_CHDES 77
#define DPI_OCI_DTYPE_TABLE_CHDES 78
#define DPI_OCI_DTYPE_ROW_CHDES 79
#define DPI_OCI_DTYPE_CQDES 80
#define DPI_OCI_DTYPE_SHARDING_KEY 83
#define DPI_OCI_DTYPE_JSON 85
// define values used for getting/setting OCI attributes
#define DPI_OCI_ATTR_DATA_SIZE 1
#define DPI_OCI_ATTR_DATA_TYPE 2
#define DPI_OCI_ATTR_ENV 5
#define DPI_OCI_ATTR_PRECISION 5
#define DPI_OCI_ATTR_SCALE 6
#define DPI_OCI_ATTR_NAME 4
#define DPI_OCI_ATTR_SERVER 6
#define DPI_OCI_ATTR_SESSION 7
#define DPI_OCI_ATTR_IS_NULL 7
#define DPI_OCI_ATTR_TRANS 8
#define DPI_OCI_ATTR_TYPE_NAME 8
#define DPI_OCI_ATTR_SCHEMA_NAME 9
#define DPI_OCI_ATTR_ROW_COUNT 9
#define DPI_OCI_ATTR_PREFETCH_ROWS 11
#define DPI_OCI_ATTR_PARAM_COUNT 18
#define DPI_OCI_ATTR_ROWID 19
#define DPI_OCI_ATTR_USERNAME 22
#define DPI_OCI_ATTR_PASSWORD 23
#define DPI_OCI_ATTR_STMT_TYPE 24
#define DPI_OCI_ATTR_INTERNAL_NAME 25
#define DPI_OCI_ATTR_EXTERNAL_NAME 26
#define DPI_OCI_ATTR_XID 27
#define DPI_OCI_ATTR_CHARSET_ID 31
#define DPI_OCI_ATTR_CHARSET_FORM 32
#define DPI_OCI_ATTR_MAXDATA_SIZE 33
#define DPI_OCI_ATTR_ROWS_RETURNED 42
#define DPI_OCI_ATTR_VISIBILITY 47
#define DPI_OCI_ATTR_CONSUMER_NAME 50
#define DPI_OCI_ATTR_DEQ_MODE 51
#define DPI_OCI_ATTR_NAVIGATION 52
#define DPI_OCI_ATTR_WAIT 53
#define DPI_OCI_ATTR_DEQ_MSGID 54
#define DPI_OCI_ATTR_PRIORITY 55
#define DPI_OCI_ATTR_DELAY 56
#define DPI_OCI_ATTR_EXPIRATION 57
#define DPI_OCI_ATTR_CORRELATION 58
#define DPI_OCI_ATTR_ATTEMPTS 59
#define DPI_OCI_ATTR_EXCEPTION_QUEUE 61
#define DPI_OCI_ATTR_ENQ_TIME 62
#define DPI_OCI_ATTR_MSG_STATE 63
#define DPI_OCI_ATTR_ORIGINAL_MSGID 69
#define DPI_OCI_ATTR_QUEUE_NAME 70
#define DPI_OCI_ATTR_NUM_DML_ERRORS 73
#define DPI_OCI_ATTR_DML_ROW_OFFSET 74
#define DPI_OCI_ATTR_SUBSCR_NAME 94
#define DPI_OCI_ATTR_SUBSCR_CALLBACK 95
#define DPI_OCI_ATTR_SUBSCR_CTX 96
#define DPI_OCI_ATTR_SUBSCR_NAMESPACE 98
#define DPI_OCI_ATTR_REF_TDO 110
#define DPI_OCI_ATTR_PARAM 124
#define DPI_OCI_ATTR_PARSE_ERROR_OFFSET 129
#define DPI_OCI_ATTR_SERVER_STATUS 143
#define DPI_OCI_ATTR_STATEMENT 144
#define DPI_OCI_ATTR_DEQCOND 146
#define DPI_OCI_ATTR_SUBSCR_RECPTPROTO 149
#define DPI_OCI_ATTR_CURRENT_POSITION 164
#define DPI_OCI_ATTR_STMTCACHESIZE 176
#define DPI_OCI_ATTR_BIND_COUNT 190
#define DPI_OCI_ATTR_TRANSFORMATION 196
#define DPI_OCI_ATTR_ROWS_FETCHED 197
#define DPI_OCI_ATTR_SPOOL_STMTCACHESIZE 208
#define DPI_OCI_ATTR_TYPECODE 216
#define DPI_OCI_ATTR_STMT_IS_RETURNING 218
#define DPI_OCI_ATTR_CURRENT_SCHEMA 224
#define DPI_OCI_ATTR_SUBSCR_QOSFLAGS 225
#define DPI_OCI_ATTR_COLLECTION_ELEMENT 227
#define DPI_OCI_ATTR_SUBSCR_TIMEOUT 227
#define DPI_OCI_ATTR_NUM_TYPE_ATTRS 228
#define DPI_OCI_ATTR_SUBSCR_CQ_QOSFLAGS 229
#define DPI_OCI_ATTR_LIST_TYPE_ATTRS 229
#define DPI_OCI_ATTR_SUBSCR_CQ_REGID 230
#define DPI_OCI_ATTR_SUBSCR_NTFN_GROUPING_CLASS 231
#define DPI_OCI_ATTR_SUBSCR_NTFN_GROUPING_VALUE 232
#define DPI_OCI_ATTR_SUBSCR_NTFN_GROUPING_TYPE 233
#define DPI_OCI_ATTR_SUBSCR_NTFN_GROUPING_REPEAT_COUNT 235
#define DPI_OCI_ATTR_NCHARSET_ID 262
#define DPI_OCI_ATTR_APPCTX_SIZE 273
#define DPI_OCI_ATTR_APPCTX_LIST 274
#define DPI_OCI_ATTR_APPCTX_NAME 275
#define DPI_OCI_ATTR_APPCTX_ATTR 276
#define DPI_OCI_ATTR_APPCTX_VALUE 277
#define DPI_OCI_ATTR_CLIENT_IDENTIFIER 278
#define DPI_OCI_ATTR_CHAR_SIZE 286
#define DPI_OCI_ATTR_EDITION 288
#define DPI_OCI_ATTR_CQ_QUERYID 304
#define DPI_OCI_ATTR_SPOOL_TIMEOUT 308
#define DPI_OCI_ATTR_SPOOL_GETMODE 309
#define DPI_OCI_ATTR_SPOOL_BUSY_COUNT 310
#define DPI_OCI_ATTR_SPOOL_OPEN_COUNT 311
#define DPI_OCI_ATTR_MODULE 366
#define DPI_OCI_ATTR_ACTION 367
#define DPI_OCI_ATTR_CLIENT_INFO 368
#define DPI_OCI_ATTR_ADMIN_PFILE 389
#define DPI_OCI_ATTR_SUBSCR_PORTNO 390
#define DPI_OCI_ATTR_CHNF_ROWIDS 402
#define DPI_OCI_ATTR_CHNF_OPERATIONS 403
#define DPI_OCI_ATTR_CHDES_DBNAME 405
#define DPI_OCI_ATTR_CHDES_NFYTYPE 406
#define DPI_OCI_ATTR_NFY_FLAGS 406
#define DPI_OCI_ATTR_CHDES_XID 407
#define DPI_OCI_ATTR_MSG_DELIVERY_MODE 407
#define DPI_OCI_ATTR_CHDES_TABLE_CHANGES 408
#define DPI_OCI_ATTR_CHDES_TABLE_NAME 409
#define DPI_OCI_ATTR_CHDES_TABLE_OPFLAGS 410
#define DPI_OCI_ATTR_CHDES_TABLE_ROW_CHANGES 411
#define DPI_OCI_ATTR_CHDES_ROW_ROWID 412
#define DPI_OCI_ATTR_CHDES_ROW_OPFLAGS 413
#define DPI_OCI_ATTR_CHNF_REGHANDLE 414
#define DPI_OCI_ATTR_CQDES_OPERATION 422
#define DPI_OCI_ATTR_CQDES_TABLE_CHANGES 423
#define DPI_OCI_ATTR_CQDES_QUERYID 424
#define DPI_OCI_ATTR_DRIVER_NAME 424
#define DPI_OCI_ATTR_CHDES_QUERIES 425
#define DPI_OCI_ATTR_CONNECTION_CLASS 425
#define DPI_OCI_ATTR_PURITY 426
#define DPI_OCI_ATTR_RECEIVE_TIMEOUT 436
#define DPI_OCI_ATTR_LOBPREFETCH_LENGTH 440
#define DPI_OCI_ATTR_SUBSCR_IPADDR 452
#define DPI_OCI_ATTR_UB8_ROW_COUNT 457
#define DPI_OCI_ATTR_SPOOL_AUTH 460
#define DPI_OCI_ATTR_LTXID 462
#define DPI_OCI_ATTR_DML_ROW_COUNT_ARRAY 469
#define DPI_OCI_ATTR_ERROR_IS_RECOVERABLE 472
#define DPI_OCI_ATTR_TRANSACTION_IN_PROGRESS 484
#define DPI_OCI_ATTR_DBOP 485
#define DPI_OCI_ATTR_SPOOL_MAX_LIFETIME_SESSION 490
#define DPI_OCI_ATTR_BREAK_ON_NET_TIMEOUT 495
#define DPI_OCI_ATTR_SHARDING_KEY 496
#define DPI_OCI_ATTR_SUPER_SHARDING_KEY 497
#define DPI_OCI_ATTR_FIXUP_CALLBACK 501
#define DPI_OCI_ATTR_SPOOL_WAIT_TIMEOUT 506
#define DPI_OCI_ATTR_CALL_TIMEOUT 531
#define DPI_OCI_ATTR_SODA_COLL_NAME 535
#define DPI_OCI_ATTR_SODA_COLL_DESCRIPTOR 536
#define DPI_OCI_ATTR_SODA_CTNT_SQL_TYPE 549
#define DPI_OCI_ATTR_SODA_KEY 563
#define DPI_OCI_ATTR_SODA_LASTMOD_TIMESTAMP 564
#define DPI_OCI_ATTR_SODA_CREATE_TIMESTAMP 565
#define DPI_OCI_ATTR_SODA_VERSION 566
#define DPI_OCI_ATTR_SODA_CONTENT 567
#define DPI_OCI_ATTR_SODA_JSON_CHARSET_ID 568
#define DPI_OCI_ATTR_SODA_DETECT_JSON_ENC 569
#define DPI_OCI_ATTR_SODA_MEDIA_TYPE 571
#define DPI_OCI_ATTR_SODA_CTNT_FORMAT 572
#define DPI_OCI_ATTR_SODA_FETCH_ARRAY_SIZE 573
#define DPI_OCI_ATTR_SODA_FILTER 576
#define DPI_OCI_ATTR_SODA_SKIP 577
#define DPI_OCI_ATTR_SODA_LIMIT 578
#define DPI_OCI_ATTR_SODA_DOC_COUNT 593
#define DPI_OCI_ATTR_SPOOL_MAX_PER_SHARD 602
#define DPI_OCI_ATTR_JSON_DOM_MUTABLE 609
// define OCI object type constants
#define DPI_OCI_OTYPE_NAME 1
#define DPI_OCI_OTYPE_PTR 3
// define OCI data type constants
#define DPI_SQLT_CHR 1
#define DPI_SQLT_NUM 2
#define DPI_SQLT_INT 3
#define DPI_SQLT_FLT 4
#define DPI_SQLT_VNU 6
#define DPI_SQLT_PDN 7
#define DPI_SQLT_LNG 8
#define DPI_SQLT_VCS 9
#define DPI_SQLT_DAT 12
#define DPI_SQLT_BFLOAT 21
#define DPI_SQLT_BDOUBLE 22
#define DPI_SQLT_BIN 23
#define DPI_SQLT_LBI 24
#define DPI_SQLT_UIN 68
#define DPI_SQLT_LVB 95
#define DPI_SQLT_AFC 96
#define DPI_SQLT_IBFLOAT 100
#define DPI_SQLT_IBDOUBLE 101
#define DPI_SQLT_RDD 104
#define DPI_SQLT_NTY 108
#define DPI_SQLT_CLOB 112
#define DPI_SQLT_BLOB 113
#define DPI_SQLT_BFILE 114
#define DPI_SQLT_RSET 116
#define DPI_SQLT_JSON 119
#define DPI_SQLT_NCO 122
#define DPI_SQLT_ODT 156
#define DPI_SQLT_DATE 184
#define DPI_SQLT_TIMESTAMP 187
#define DPI_SQLT_TIMESTAMP_TZ 188
#define DPI_SQLT_INTERVAL_YM 189
#define DPI_SQLT_INTERVAL_DS 190
#define DPI_SQLT_TIMESTAMP_LTZ 232
#define DPI_OCI_TYPECODE_SMALLINT 246
#define DPI_SQLT_REC 250
#define DPI_SQLT_BOL 252
#define DPI_OCI_TYPECODE_ROWID 262
#define DPI_OCI_TYPECODE_LONG 263
#define DPI_OCI_TYPECODE_LONG_RAW 264
#define DPI_OCI_TYPECODE_BINARY_INTEGER 265
#define DPI_OCI_TYPECODE_PLS_INTEGER 266
// define session pool constants
#define DPI_OCI_SPD_FORCE 0x0001
#define DPI_OCI_SPC_HOMOGENEOUS 0x0002
#define DPI_OCI_SPC_STMTCACHE 0x0004
// define OCI session pool get constants
#define DPI_OCI_SESSGET_SPOOL 0x0001
#define DPI_OCI_SESSGET_STMTCACHE 0x0004
#define DPI_OCI_SESSGET_CREDPROXY 0x0008
#define DPI_OCI_SESSGET_CREDEXT 0x0010
#define DPI_OCI_SESSGET_SPOOL_MATCHANY 0x0020
#define DPI_OCI_SESSGET_SYSDBA 0x0100
#define DPI_OCI_SESSGET_MULTIPROPERTY_TAG 0x0400
// define OCI authentication constants
#define DPI_OCI_CPW_SYSDBA 0x00000010
#define DPI_OCI_CPW_SYSOPER 0x00000020
#define DPI_OCI_CPW_SYSASM 0x00800040
#define DPI_OCI_CPW_SYSBKP 0x00000080
#define DPI_OCI_CPW_SYSDGD 0x00000100
#define DPI_OCI_CPW_SYSKMT 0x00000200
// define NLS constants
#define DPI_OCI_NLS_CS_IANA_TO_ORA 0
#define DPI_OCI_NLS_CS_ORA_TO_IANA 1
#define DPI_OCI_NLS_CHARSET_MAXBYTESZ 91
#define DPI_OCI_NLS_CHARSET_ID 93
#define DPI_OCI_NLS_NCHARSET_ID 94
#define DPI_OCI_NLS_MAXBUFSZ 100
#define DPI_SQLCS_IMPLICIT 1
#define DPI_SQLCS_NCHAR 2
// define XA constants
#define DPI_XA_MAXGTRIDSIZE 64
#define DPI_XA_MAXBQUALSIZE 64
#define DPI_XA_XIDDATASIZE 128
// define null indicator values
#define DPI_OCI_IND_NULL -1
#define DPI_OCI_IND_NOTNULL 0
// define subscription QOS values
#define DPI_OCI_SUBSCR_QOS_RELIABLE 0x01
#define DPI_OCI_SUBSCR_QOS_PURGE_ON_NTFN 0x10
#define DPI_OCI_SUBSCR_CQ_QOS_QUERY 0x01
#define DPI_OCI_SUBSCR_CQ_QOS_BEST_EFFORT 0x02
// define XDK node type constants
#define DPI_JZNDOM_SCALAR 1
#define DPI_JZNDOM_OBJECT 2
#define DPI_JZNDOM_ARRAY 3
// define XDK scalar type constants
#define DPI_JZNVAL_NULL 2
#define DPI_JZNVAL_STRING 3
#define DPI_JZNVAL_FALSE 5
#define DPI_JZNVAL_TRUE 6
#define DPI_JZNVAL_FLOAT 11
#define DPI_JZNVAL_DOUBLE 12
#define DPI_JZNVAL_BINARY 13
#define DPI_JZNVAL_ORA_NUMBER 17
#define DPI_JZNVAL_ORA_DATE 18
#define DPI_JZNVAL_ORA_TIMESTAMP 19
#define DPI_JZNVAL_ORA_TIMESTAMPTZ 20
#define DPI_JZNVAL_ORA_YEARMONTH_DUR 21
#define DPI_JZNVAL_ORA_DAYSECOND_DUR 22
#define DPI_JZNVAL_OCI_NUMBER 32
#define DPI_JZNVAL_OCI_DATE 33
#define DPI_JZNVAL_OCI_DATETIME 34
#define DPI_JZNVAL_OCI_INTERVAL 40
// define XDK miscellaneous constants
#define DPI_JZN_ALLOW_SCALAR_DOCUMENTS 0x00000080
#define DPI_JZN_INPUT_UTF8 1
// define miscellaneous OCI constants
#define DPI_OCI_CONTINUE -24200
#define DPI_OCI_INVALID_HANDLE -2
#define DPI_OCI_ERROR -1
#define DPI_OCI_DEFAULT 0
#define DPI_OCI_SUCCESS 0
#define DPI_OCI_ONE_PIECE 0
#define DPI_OCI_ATTR_PURITY_DEFAULT 0
#define DPI_OCI_NUMBER_UNSIGNED 0
#define DPI_OCI_SUCCESS_WITH_INFO 1
#define DPI_OCI_NTV_SYNTAX 1
#define DPI_OCI_MEMORY_CLEARED 1
#define DPI_OCI_SESSRLS_DROPSESS 1
#define DPI_OCI_SESSRLS_MULTIPROPERTY_TAG 4
#define DPI_OCI_SERVER_NORMAL 1
#define DPI_OCI_TYPEGET_ALL 1
#define DPI_OCI_TRANS_NEW 1
#define DPI_OCI_LOCK_NONE 1
#define DPI_OCI_TEMP_BLOB 1
#define DPI_OCI_CRED_RDBMS 1
#define DPI_OCI_LOB_READONLY 1
#define DPI_OCI_JSON_FORMAT_OSON 1
#define DPI_OCI_TEMP_CLOB 2
#define DPI_OCI_CRED_EXT 2
#define DPI_OCI_LOB_READWRITE 2
#define DPI_OCI_DATA_AT_EXEC 2
#define DPI_OCI_DYNAMIC_FETCH 2
#define DPI_OCI_NUMBER_SIGNED 2
#define DPI_OCI_PIN_ANY 3
#define DPI_OCI_PTYPE_TYPE 6
#define DPI_OCI_AUTH 8
#define DPI_OCI_DURATION_SESSION 10
#define DPI_OCI_NUMBER_SIZE 22
#define DPI_OCI_MAX_VAL_SIZE 22
#define DPI_OCI_NEED_DATA 99
#define DPI_OCI_NO_DATA 100
#define DPI_OCI_SRVRELEASE2_CACHED 0x0001
#define DPI_OCI_STRLS_CACHE_DELETE 0x0010
#define DPI_OCI_THREADED 0x00000001
#define DPI_OCI_OBJECT 0x00000002
#define DPI_OCI_SODA_ATOMIC_COMMIT 0x00000001
#define DPI_OCI_SODA_AS_STORED 0x00000002
#define DPI_OCI_SODA_AS_AL32UTF8 0x00000004
#define DPI_OCI_STMT_SCROLLABLE_READONLY 0x00000008
#define DPI_OCI_STMT_CACHE 0x00000040
#define DPI_OCI_SODA_COLL_CREATE_MAP 0x00010000
#define DPI_OCI_SODA_INDEX_DROP_FORCE 0x00010000
#define DPI_OCI_TRANS_TWOPHASE 0x01000000
#define DPI_OCI_SECURE_NOTIFICATION 0x20000000
//-----------------------------------------------------------------------------
// Macros
//-----------------------------------------------------------------------------
#define DPI_CHECK_PTR_NOT_NULL(handle, parameter) \
if (!parameter) { \
dpiError__set(&error, "check parameter " #parameter, \
DPI_ERR_NULL_POINTER_PARAMETER, #parameter); \
return dpiGen__endPublicFn(handle, DPI_FAILURE, &error); \
}
#define DPI_CHECK_PTR_AND_LENGTH(handle, parameter) \
if (!parameter && parameter ## Length > 0) { \
dpiError__set(&error, "check parameter " #parameter, \
DPI_ERR_PTR_LENGTH_MISMATCH, #parameter); \
return dpiGen__endPublicFn(handle, DPI_FAILURE, &error); \
}
//-----------------------------------------------------------------------------
// Enumerations
//-----------------------------------------------------------------------------
// error numbers
typedef enum {
DPI_ERR_NO_ERR = 1000,
DPI_ERR_NO_MEMORY,
DPI_ERR_INVALID_HANDLE,
DPI_ERR_ERR_NOT_INITIALIZED,
DPI_ERR_GET_FAILED,
DPI_ERR_CREATE_ENV,
DPI_ERR_CONVERT_TEXT,
DPI_ERR_QUERY_NOT_EXECUTED,
DPI_ERR_UNHANDLED_DATA_TYPE,
DPI_ERR_INVALID_ARRAY_POSITION,
DPI_ERR_NOT_CONNECTED,
DPI_ERR_CONN_NOT_IN_POOL,
DPI_ERR_INVALID_PROXY,
DPI_ERR_NOT_SUPPORTED,
DPI_ERR_UNHANDLED_CONVERSION,
DPI_ERR_ARRAY_SIZE_TOO_BIG,
DPI_ERR_INVALID_DATE,
DPI_ERR_VALUE_IS_NULL,
DPI_ERR_ARRAY_SIZE_TOO_SMALL,
DPI_ERR_BUFFER_SIZE_TOO_SMALL,
DPI_ERR_VERSION_NOT_SUPPORTED,
DPI_ERR_INVALID_ORACLE_TYPE,
DPI_ERR_WRONG_ATTR,
DPI_ERR_NOT_COLLECTION,
DPI_ERR_INVALID_INDEX,
DPI_ERR_NO_OBJECT_TYPE,
DPI_ERR_INVALID_CHARSET,
DPI_ERR_SCROLL_OUT_OF_RS,
DPI_ERR_QUERY_POSITION_INVALID,
DPI_ERR_NO_ROW_FETCHED,
DPI_ERR_TLS_ERROR,
DPI_ERR_ARRAY_SIZE_ZERO,
DPI_ERR_EXT_AUTH_WITH_CREDENTIALS,
DPI_ERR_CANNOT_GET_ROW_OFFSET,
DPI_ERR_CONN_IS_EXTERNAL,
DPI_ERR_TRANS_ID_TOO_LARGE,
DPI_ERR_BRANCH_ID_TOO_LARGE,
DPI_ERR_COLUMN_FETCH,
DPI_ERR_STMT_CLOSED,
DPI_ERR_LOB_CLOSED,
DPI_ERR_INVALID_CHARSET_ID,
DPI_ERR_INVALID_OCI_NUMBER,
DPI_ERR_INVALID_NUMBER,
DPI_ERR_NUMBER_NO_REPR,
DPI_ERR_NUMBER_STRING_TOO_LONG,
DPI_ERR_NULL_POINTER_PARAMETER,
DPI_ERR_LOAD_LIBRARY,
DPI_ERR_LOAD_SYMBOL,
DPI_ERR_ORACLE_CLIENT_TOO_OLD,
DPI_ERR_NLS_ENV_VAR_GET,
DPI_ERR_PTR_LENGTH_MISMATCH,
DPI_ERR_NAN,
DPI_ERR_WRONG_TYPE,
DPI_ERR_BUFFER_SIZE_TOO_LARGE,
DPI_ERR_NO_EDITION_WITH_CONN_CLASS,
DPI_ERR_NO_BIND_VARS_IN_DDL,
DPI_ERR_SUBSCR_CLOSED,
DPI_ERR_NO_EDITION_WITH_NEW_PASSWORD,
DPI_ERR_UNEXPECTED_OCI_RETURN_VALUE,
DPI_ERR_EXEC_MODE_ONLY_FOR_DML,
DPI_ERR_ARRAY_VAR_NOT_SUPPORTED,
DPI_ERR_EVENTS_MODE_REQUIRED,
DPI_ERR_ORACLE_DB_TOO_OLD,
DPI_ERR_CALL_TIMEOUT,
DPI_ERR_SODA_CURSOR_CLOSED,
DPI_ERR_EXT_AUTH_INVALID_PROXY,
DPI_ERR_QUEUE_NO_PAYLOAD,
DPI_ERR_QUEUE_WRONG_PAYLOAD_TYPE,
DPI_ERR_ORACLE_CLIENT_UNSUPPORTED,
DPI_ERR_MISSING_SHARDING_KEY,
DPI_ERR_CONTEXT_NOT_CREATED,
DPI_ERR_OS,
DPI_ERR_UNHANDLED_JSON_NODE_TYPE,
DPI_ERR_UNHANDLED_JSON_SCALAR_TYPE,
DPI_ERR_UNHANDLED_CONVERSION_TO_JSON,
DPI_ERR_MAX
} dpiErrorNum;
// handle types
typedef enum {
DPI_HTYPE_NONE = 4000,
DPI_HTYPE_CONN,
DPI_HTYPE_POOL,
DPI_HTYPE_STMT,
DPI_HTYPE_VAR,
DPI_HTYPE_LOB,
DPI_HTYPE_OBJECT,
DPI_HTYPE_OBJECT_TYPE,
DPI_HTYPE_OBJECT_ATTR,
DPI_HTYPE_SUBSCR,
DPI_HTYPE_DEQ_OPTIONS,
DPI_HTYPE_ENQ_OPTIONS,
DPI_HTYPE_MSG_PROPS,
DPI_HTYPE_ROWID,
DPI_HTYPE_CONTEXT,
DPI_HTYPE_SODA_COLL,
DPI_HTYPE_SODA_COLL_CURSOR,
DPI_HTYPE_SODA_DB,
DPI_HTYPE_SODA_DOC,
DPI_HTYPE_SODA_DOC_CURSOR,
DPI_HTYPE_QUEUE,
DPI_HTYPE_JSON,
DPI_HTYPE_MAX
} dpiHandleTypeNum;
//-----------------------------------------------------------------------------
// Mutex definitions
//-----------------------------------------------------------------------------
#ifdef _WIN32
typedef CRITICAL_SECTION dpiMutexType;
#define dpiMutex__initialize(m) InitializeCriticalSection(&m)
#define dpiMutex__destroy(m) DeleteCriticalSection(&m)
#define dpiMutex__acquire(m) EnterCriticalSection(&m)
#define dpiMutex__release(m) LeaveCriticalSection(&m)
#else
typedef pthread_mutex_t dpiMutexType;
#define dpiMutex__initialize(m) pthread_mutex_init(&m, NULL)
#define dpiMutex__destroy(m) pthread_mutex_destroy(&m)
#define dpiMutex__acquire(m) pthread_mutex_lock(&m)
#define dpiMutex__release(m) pthread_mutex_unlock(&m)
#endif
//-----------------------------------------------------------------------------
// old type definitions (to be dropped)
//-----------------------------------------------------------------------------
// structure used for transferring error information from ODPI-C
typedef struct {
int32_t code;
uint16_t offset;
const char *message;
uint32_t messageLength;
const char *encoding;
const char *fnName;
const char *action;
const char *sqlState;
int isRecoverable;
} dpiErrorInfo__v33;
//-----------------------------------------------------------------------------
// forward declarations for recursive OCI JSON type definitions
//-----------------------------------------------------------------------------
typedef union dpiJsonOciVal dpiJsonOciVal;
typedef struct dpiJznDomDoc dpiJznDomDoc;
typedef struct dpiJznDomNameValuePair dpiJznDomNameValuePair;
typedef struct dpiJznDomScalar dpiJznDomScalar;
//-----------------------------------------------------------------------------
// OCI JSON function definitions
//-----------------------------------------------------------------------------
typedef void* (*dpiJznDom__loadFromInputEventSrc)(dpiJznDomDoc *jdoc,
void *evtsrc);
typedef void* (*dpiJznDom__loadFromInputOSON)(dpiJznDomDoc *jdoc,
void *octbsrc);
typedef int (*dpiJznDom__getNodeType)(dpiJznDomDoc *jdoc, void *node);
typedef void (*dpiJznDom__getScalarInfo)(dpiJznDomDoc *jdoc, void *nd,
dpiJznDomScalar *val);
typedef void* (*dpiJznDom__getRootNode)(dpiJznDomDoc *jdoc);
typedef uint32_t (*dpiJznDom__getNumObjField)(dpiJznDomDoc *jdoc, void *obj);
typedef void* (*dpiJznDom__getFieldVal)(dpiJznDomDoc *jdoc, void *obj,
void *nmkey);
typedef void* (*dpiJznDom__getFieldByName)(dpiJznDomDoc *jdoc, void *obj,
const char *nm, uint16_t nmlen);
typedef void (*dpiJznDom__getAllFieldNamesAndVals)(dpiJznDomDoc *jdoc,
void *obj, void **nvps);
typedef uint32_t (*dpiJznDom__getFieldNamesAndValsBatch)(dpiJznDomDoc *jdoc,
void *obj, uint32_t startPos, uint32_t fetchSz,
dpiJznDomNameValuePair *nvps);
typedef uint32_t (*dpiJznDom__getArraySize)(dpiJznDomDoc *jdoc, void *ary);
typedef void* (*dpiJznDom__getArrayElem)(dpiJznDomDoc *jdoc, void *ary,
uint32_t index);
typedef uint32_t (*dpiJznDom__getArrayElemBatch)(dpiJznDomDoc *jdoc, void *ary,
uint32_t startPos, uint32_t fetchSz, void **ndary);
typedef void (*dpiJznDom__setRootNode)(dpiJznDomDoc *jdoc, void *root);
typedef void (*dpiJznDom__putFieldValue)(dpiJznDomDoc *jdoc, void *obj,
const char *name, uint16_t namelen, void *node);
typedef int (*dpiJznDom__putItem)(dpiJznDomDoc *jdoc, void *arr, void *node,
uint32_t pos);
typedef int (*dpiJznDom__appendItem)(dpiJznDomDoc *jdoc, void *arr,
void *node);
typedef int (*dpiJznDom__replaceItem)(dpiJznDomDoc *jdoc, void *arr,
void *node, uint32_t pos);
typedef void (*dpiJznDom__deleteField)(dpiJznDomDoc *jdoc, void *obj,
void *nmkey);
typedef void* (*dpiJznDom__unlinkField)(dpiJznDomDoc *jdoc, void *obj,
void *nmkey);
typedef int (*dpiJznDom__renameField)(dpiJznDomDoc *jdoc, void *obj,
const char *oldName, uint16_t oldNameLen, const char *newName,
uint16_t newNameLen);
typedef int (*dpiJznDom__deleteItem)(dpiJznDomDoc *jdoc, void *arr,
uint32_t idx);
typedef void* (*dpiJznDom__unlinkItem)(dpiJznDomDoc *jdoc, void *arr,
uint32_t idx);
typedef uint32_t (*dpiJznDom__deleteItemBatch)(dpiJznDomDoc *jdoc, void *arr,
uint32_t start, uint32_t deleteSz);
typedef void* (*dpiJznDom__newObject)(dpiJznDomDoc *jdoc, uint32_t sz);
typedef void* (*dpiJznDom__newArray)(dpiJznDomDoc *jdoc, uint32_t sz);
typedef void* (*dpiJznDom__newScalar)(dpiJznDomDoc *jdoc,
dpiJznDomScalar *val);
typedef void (*dpiJznDom__reset)(dpiJznDomDoc *jdoc);
typedef void (*dpiJznDom__free)(dpiJznDomDoc *jdoc);
typedef void* (*dpiJznDom__getOutputEventSrc)(dpiJznDomDoc *jdoc);
typedef int (*dpiJznDom__equals)(dpiJznDomDoc *jdoc1, void *nd1,
dpiJznDomDoc *jdoc2, void *nd2);
typedef void* (*dpiJznDom__copy)(dpiJznDomDoc *srcdoc, void *srcnode,
dpiJznDomDoc *destdoc);
typedef void (*dpiJznDom__validFid)(dpiJznDomDoc *jdoc, void *fnms,
uint16_t fnmsn);
typedef int (*dpiJznDom__storeField)(dpiJznDomDoc *jdoc, const char *fname,
uint32_t fnlen, void *name);
typedef int (*dpiJznDom__printNode)(dpiJznDomDoc *jdoc, void *node,
void *writer);
typedef void (*dpiJznDom__visitorFunc)(void *vinfo, void *appctx);
typedef void (*dpiJznDom__nodeVisitor)(dpiJznDomDoc *jdoc, void *node,
dpiJznDom__visitorFunc func, void *ctx);
typedef void* (*dpiJznDom__newScalarVal)(dpiJznDomDoc *jdoc, int typ, ...);
typedef void (*dpiJznDom__deleteFieldByName)(dpiJznDomDoc *jdoc, void *obj,
const char *name, uint16_t namelen);
typedef void *(*dpiJznDom__unlinkFieldByName)(dpiJznDomDoc *jdoc, void *obj,
const char *name, uint16_t namelen);
typedef int (*dpiJznDom__freeNode)(dpiJznDomDoc *jdoc, void *node);
typedef void (*dpiJznDom__getScalarInfoOci)(dpiJznDomDoc *jdoc, void *nd,
dpiJznDomScalar *val, dpiJsonOciVal *aux);
//-----------------------------------------------------------------------------
// OCI type definitions
//-----------------------------------------------------------------------------
// representation of OCI Number type
typedef struct {
unsigned char value[DPI_OCI_NUMBER_SIZE];
} dpiOciNumber;
// representation of OCI Date type
typedef struct {
int16_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t minute;
uint8_t second;
} dpiOciDate;
// alternative representation of OCI Date type used for sharding
typedef struct {
uint8_t century;
uint8_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t minute;
uint8_t second;
} dpiShardingOciDate;
// representation of OCI XID type (two-phase commit)
typedef struct {
long formatID;
long gtrid_length;
long bqual_length;
char data[DPI_XA_XIDDATASIZE];
} dpiOciXID;
// representation of JSON OCI values
union dpiJsonOciVal {
struct {
int16_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t minute;
uint8_t second;
uint32_t fsecond;
int8_t tzHourOffset;
int8_t tzMinuteOffset;
} asJsonDateTime;
struct {
int32_t days;
int32_t hours;
int32_t minutes;
int32_t seconds;
int32_t fseconds;
} asJsonDayInterval;
struct {
int32_t years;
int32_t months;
} asJsonYearInterval;
uint8_t asJsonNumber[DPI_OCI_NUMBER_SIZE];
};
// representation of JSON DOM API
typedef struct {
dpiJznDom__loadFromInputEventSrc fnLoadFromInputEventSrc;
dpiJznDom__loadFromInputOSON fnLoadFromInputOSON;
dpiJznDom__getNodeType fnGetNodeType;
dpiJznDom__getScalarInfo fnGetScalarInfo;
dpiJznDom__getRootNode fnGetRootNode;
dpiJznDom__getNumObjField fnGetNumObjField;
dpiJznDom__getFieldVal fnGetFieldVal;
dpiJznDom__getFieldByName fnGetFieldByName;
dpiJznDom__getAllFieldNamesAndVals fnGetAllFieldNamesAndVals;
dpiJznDom__getFieldNamesAndValsBatch fnGetFieldNamesAndValsBatch;
dpiJznDom__getArraySize fnGetArraySize;
dpiJznDom__getArrayElem fnGetArrayElem;
dpiJznDom__getArrayElemBatch fnGetArrayElemBatch;
dpiJznDom__setRootNode fnSetRootNode;
dpiJznDom__putFieldValue fnPutFieldValue;
dpiJznDom__putItem fnPutItem;
dpiJznDom__appendItem fnAppendItem;
dpiJznDom__replaceItem fnReplaceItem;
dpiJznDom__deleteField fnDeleteField;
dpiJznDom__unlinkField fnUnlinkField;
dpiJznDom__renameField fnRenameField;
dpiJznDom__deleteItem fnDeleteItem;
dpiJznDom__unlinkItem fnUnlinkItem;
dpiJznDom__deleteItemBatch fnDeleteItemBatch;
dpiJznDom__newObject fnNewObject;
dpiJznDom__newArray fnNewArray;
dpiJznDom__newScalar fnNewScalar;
dpiJznDom__reset fnReset;
dpiJznDom__free fnFree;
dpiJznDom__getOutputEventSrc fnGetOutputEventSrc;
dpiJznDom__equals fnEquals;
dpiJznDom__copy fnCopy;
dpiJznDom__validFid fnValidFid;
dpiJznDom__storeField fnStoreField;
dpiJznDom__printNode fnPrintNode;
dpiJznDom__nodeVisitor fnNodeVisitor;
dpiJznDom__newScalarVal fnNewScalarVal;
dpiJznDom__deleteFieldByName fnDeleteFieldByName;
dpiJznDom__unlinkFieldByName fnUnlinkFieldByName;
dpiJznDom__freeNode fnFreeNode;
dpiJznDom__getScalarInfoOci fnGetScalarInfoOci;
} dpiJznDomMethods;
// representation of JSON DOM
struct dpiJznDomDoc {
dpiJznDomMethods *methods;
void *xmlContext;
int errCode;
uint32_t modCount;
};
// representation of JSON name/value pair
struct dpiJznDomNameValuePair {
struct {
char *ptr;
uint32_t length;
uint32_t hashId;
uint16_t shortId;
uint16_t osonId;
uint8_t flags;
uint8_t hash;
uint32_t id;
} name;
void *value;
};
// representation of JSON DOM Scalar Node
struct dpiJznDomScalar {
int valueType;
union {
struct {
char *value;
uint32_t valueLength;
} asBytes;
struct {
float value;
} asFloat;
struct {
double value;
} asDouble;
struct {
uint8_t *value;
uint32_t valueLength;
} asOciVal;
} value;
};
//-----------------------------------------------------------------------------
// Internal implementation type definitions
//-----------------------------------------------------------------------------
// used to manage a list of shared handles in a thread-safe manner; currently
// used for managing the list of open statements, LOBs and created objects for
// a connection (so that they can be closed before the connection itself is
// closed); the functions for managing this structure can be found in the file
// dpiHandleList.c; empty slots in the array are represented by a NULL handle
typedef struct {
void **handles; // array of handles managed by list
uint32_t numSlots; // length of handles array
uint32_t numUsedSlots; // actual number of managed handles
uint32_t currentPos; // next position to search
dpiMutexType mutex; // enables thread safety
} dpiHandleList;
// used to manage a pool of shared handles in a thread-safe manner; currently
// used for managing the pool of error handles in the dpiEnv structure; the
// functions for managing this structure are found in the file dpiHandlePool.c
typedef struct {
void **handles; // array of handles managed by pool
uint32_t numSlots; // length of handles array
uint32_t numUsedSlots; // actual number of managed handles
uint32_t acquirePos; // position from which to acquire
uint32_t releasePos; // position to place released handles
dpiMutexType mutex; // enables thread safety
} dpiHandlePool;
// used to save error information internally; one of these is stored for each
// thread using OCIThreadKeyGet() and OCIThreadKeySet() with a globally created
// OCI environment handle; it is also used when getting batch error information
// with the function dpiStmt_getBatchErrors()
typedef struct {
int32_t code; // Oracle error code or 0
uint32_t offset; // parse error offset or row offset
dpiErrorNum errorNum; // OCPI-C error number
const char *fnName; // ODPI-C function name
const char *action; // internal action
char encoding[DPI_OCI_NLS_MAXBUFSZ]; // encoding (IANA name)
char message[DPI_MAX_ERROR_SIZE]; // buffer for storing messages
uint32_t messageLength; // length of message in buffer
int isRecoverable; // is recoverable?
int isWarning; // is a warning?
} dpiErrorBuffer;
// represents an OCI environment; a pointer to this structure is stored on each
// handle exposed publicly but it is created only when a pool is created or
// when a standalone connection is created; connections acquired from a pool
// shared the same environment as the pool; the functions for manipulating the
// environment are found in the file dpiEnv.c; all values are read-only after
// initialization of environment is complete
typedef struct {
const dpiContext *context; // context used to create environment
void *handle; // OCI environment handle
dpiMutexType mutex; // for reference count (threaded mode)
char encoding[DPI_OCI_NLS_MAXBUFSZ]; // CHAR encoding (IANA name)
int32_t maxBytesPerCharacter; // max bytes per CHAR character
uint16_t charsetId; // CHAR encoding (Oracle charset ID)
char nencoding[DPI_OCI_NLS_MAXBUFSZ]; // NCHAR encoding (IANA name)
int32_t nmaxBytesPerCharacter; // max bytes per NCHAR character
uint16_t ncharsetId; // NCHAR encoding (Oracle charset ID)
dpiHandlePool *errorHandles; // pool of OCI error handles
dpiVersionInfo *versionInfo; // OCI client version info
void *baseDate; // timestamp
void *baseDateTZ; // timestamp with time zone
void *baseDateLTZ; // timestamp with local time zone
int threaded; // threaded mode enabled?
int events; // events mode enabled?
int externalHandle; // external handle?
} dpiEnv;
// used to manage all errors that take place in the library; the implementation
// for the functions that use this structure are found in dpiError.c; a pointer
// to this structure is passed to all internal functions and the first thing
// that takes place in every public function is a call to this this error
// structure
typedef struct {
dpiErrorBuffer *buffer; // buffer to store error information
void *handle; // OCI error handle or NULL
dpiEnv *env; // env which created OCI error handle
} dpiError;
// function signature for all methods that free publicly exposed handles
typedef void (*dpiTypeFreeProc)(void*, dpiError*);
// strcture used to provide metadata for the different types of handles exposed
// publicly; a list of these structures (defined as constants) can be found in
// the file dpiGen.c; the enumeration dpiHandleTypeNum is used to identify the
// structures instead of being used directly
typedef struct {
const char *name; // name (used in error messages)
size_t size; // size of structure, in bytes
uint32_t checkInt; // check integer (unique)