-
Notifications
You must be signed in to change notification settings - Fork 34
/
oci8.c
4683 lines (3905 loc) · 159 KB
/
oci8.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
/*
vim:sw=4:ts=8
oci8.c
Copyright (c) 1998-2006 Tim Bunce Ireland
Copyright (c) 2006-2008 John Scoles (The Pythian Group), Canada
See the COPYRIGHT section in the Oracle.pm file for terms.
*/
#include "Oracle.h"
#ifdef UTF8_SUPPORT
#include <utf8.h>
#endif
#define sv_set_undef(sv) if (SvROK(sv)) sv_unref(sv); else SvOK_off(sv)
DBISTATE_DECLARE;
int describe_obj_by_tdo(SV *sth,imp_sth_t *imp_sth,fbh_obj_t *obj,ub2 level );
int dump_struct(imp_sth_t *imp_sth,fbh_obj_t *obj,int level);
/*
char *
dbd_yes_no(int yes_no)
{
dTHX;
if (yes_no) {
return "Yes";
}
return "No";
}
*/
void
dbd_init_oci(dbistate_t *dbistate)
{
dTHX;
DBIS = dbistate;
}
void
dbd_init_oci_drh(imp_drh_t * imp_drh)
{
dTHX;
imp_drh->ora_long = perl_get_sv("Oraperl::ora_long", GV_ADDMULTI);
imp_drh->ora_trunc = perl_get_sv("Oraperl::ora_trunc", GV_ADDMULTI);
imp_drh->ora_cache = perl_get_sv("Oraperl::ora_cache", GV_ADDMULTI);
imp_drh->ora_cache_o = perl_get_sv("Oraperl::ora_cache_o", GV_ADDMULTI);
}
/*
char *
oci_sql_function_code_name(int sqlfncode)
{
dTHX;
SV *sv;
switch (sqlfncode) {
case 1 : return "CREATE TABLE";
case 3 : return "INSERT";
case 4 : return "SELECT";
case 5 : return "UPDATE";
case 8 : return "DROP TABLE";
case 9 : return "DELETE";
}
sv = sv_2mortal(newSVpv("",0));
sv_grow(sv, 50);
sprintf(SvPVX(sv),"(UNKNOWN SQL FN Code %d)", sqlfncode);
return SvPVX(sv);
}
*/
/*
char *
oci_ptype_name(int ptype)
{
dTHX;
SV *sv;
switch (ptype) {
case OCI_PTYPE_UNK: return "UNKNOWN";
case OCI_PTYPE_TABLE: return "TABLE";
case OCI_PTYPE_VIEW: return "VIEW";
case OCI_PTYPE_PROC: return "PROCEDURE";
case OCI_PTYPE_FUNC: return "FUNCTION";
case OCI_PTYPE_PKG: return "PACKAGE";
case OCI_PTYPE_TYPE: return "USER DEFINED TYPE";
case OCI_PTYPE_SYN: return "SYNONYM";
case OCI_PTYPE_SEQ: return "SEQUENCE";
case OCI_PTYPE_COL: return "COLUMN";
case OCI_PTYPE_ARG: return "ARGUMENT";
case OCI_PTYPE_LIST: return "LIST";
case OCI_PTYPE_TYPE_ATTR: return "USER-DEFINED TYPE'S ATTRIBUTE";
case OCI_PTYPE_TYPE_COLL: return "COLLECTION TYPE'S ELEMENT";
case OCI_PTYPE_TYPE_METHOD: return "USER-DEFINED TYPE'S METHOD";
case OCI_PTYPE_TYPE_ARG: return "USER-DEFINED TYPE METHOD'S ARGUMENT";
case OCI_PTYPE_TYPE_RESULT: return "USER-DEFINED TYPE METHOD'S RESULT";
case OCI_PTYPE_SCHEMA: return "SCHEMA";
case OCI_PTYPE_DATABASE: return "DATABASE";
}
sv = sv_2mortal(newSVpv("",0));
sv_grow(sv, 50);
sprintf(SvPVX(sv),"(UNKNOWN PTYPE Code %d)", ptype);
return SvPVX(sv);
}
*/
char *
oci_exe_mode(ub4 mode)
{
dTHX;
SV *sv;
switch (mode) {
/*----------------------- Execution Modes -----------------------------------*/
case OCI_DEFAULT: return "DEFAULT";
case OCI_BATCH_MODE: return "BATCH_MODE"; /* batch the oci stmt for exec */
case OCI_EXACT_FETCH: return "EXACT_FETCH"; /* fetch exact rows specified */
case OCI_STMT_SCROLLABLE_READONLY : return "STMT_SCROLLABLE_READONLY";
case OCI_DESCRIBE_ONLY: return "DESCRIBE_ONLY"; /* only describe the statement */
case OCI_COMMIT_ON_SUCCESS: return "COMMIT_ON_SUCCESS"; /* commit, if successful exec */
case OCI_NON_BLOCKING: return "NON_BLOCKING"; /* non-blocking */
case OCI_BATCH_ERRORS: return "BATCH_ERRORS"; /* batch errors in array dmls */
case OCI_PARSE_ONLY: return "PARSE_ONLY"; /* only parse the statement */
case OCI_SHOW_DML_WARNINGS: return "SHOW_DML_WARNINGS";
/* case OCI_RESULT_CACHE: return "RESULT_CACHE"; hint to use query caching only 11 so wait this one out*/
/* case OCI_NO_RESULT_CACHE : return "NO_RESULT_CACHE"; hint to bypass query caching*/
}
sv = sv_2mortal(newSVpv("",0));
sv_grow(sv, 50);
sprintf(SvPVX(sv),"(UNKNOWN OCI EXECUTE MODE %d)", mode);
return SvPVX(sv);
}
/* SQL Types we support for placeholders basically we support types that can be returned as strings */
char *
sql_typecode_name(int dbtype) {
dTHX;
SV *sv;
switch(dbtype) {
case 0: return "DEFAULT (varchar)";
case 1: return "VARCHAR";
case 2: return "NVARCHAR2";
case 5: return "STRING";
case 8: return "LONG";
case 21: return "BINARY FLOAT os-endian";
case 22: return "BINARY DOUBLE os-endian";
case 23: return "RAW";
case 24: return "LONG RAW";
case 96: return "CHAR";
case 97: return "CHARZ";
case 100: return "BINARY FLOAT oracle-endian";
case 101: return "BINARY DOUBLE oracle-endian";
case 106: return "MLSLABEL";
case 102: return "SQLT_CUR OCI 7 cursor variable";
case 112: return "SQLT_CLOB / long";
case 113: return "SQLT_BLOB / long";
case 116: return "SQLT_RSET OCI 8 cursor variable";
case ORA_VARCHAR2_TABLE:return "ORA_VARCHAR2_TABLE";
case ORA_NUMBER_TABLE: return "ORA_NUMBER_TABLE";
case ORA_XMLTYPE: return "ORA_XMLTYPE or SQLT_NTY";/* SQLT_NTY must be carefull here as its value (108) is the same for an embedded object Well realy only XML clobs not embedded objects */
}
sv = sv_2mortal(newSVpv("",0));
sv_grow(sv, 50);
sprintf(SvPVX(sv),"(UNKNOWN SQL TYPECODE %d)", dbtype);
return SvPVX(sv);
}
char *
oci_typecode_name(int typecode){
dTHX;
SV *sv;
switch (typecode) {
case OCI_TYPECODE_INTERVAL_YM: return "INTERVAL_YM";
case OCI_TYPECODE_INTERVAL_DS: return "NTERVAL_DS";
case OCI_TYPECODE_TIMESTAMP_TZ: return "TIMESTAMP_TZ";
case OCI_TYPECODE_TIMESTAMP_LTZ: return "TIMESTAMP_LTZ";
case OCI_TYPECODE_TIMESTAMP: return "TIMESTAMP";
case OCI_TYPECODE_DATE: return "DATE";
case OCI_TYPECODE_CLOB: return "CLOB";
case OCI_TYPECODE_BLOB: return "BLOB";
case OCI_TYPECODE_BFILE: return "BFILE";
case OCI_TYPECODE_RAW: return "RAW";
case OCI_TYPECODE_CHAR: return "CHAR";
case OCI_TYPECODE_VARCHAR: return "VARCHAR";
case OCI_TYPECODE_VARCHAR2: return "VARCHAR2";
case OCI_TYPECODE_SIGNED8: return "SIGNED8";
case OCI_TYPECODE_UNSIGNED8: return "DECLARE";
case OCI_TYPECODE_UNSIGNED16 : return "UNSIGNED8";
case OCI_TYPECODE_UNSIGNED32 : return "UNSIGNED32";
case OCI_TYPECODE_REAL : return "REAL";
case OCI_TYPECODE_DOUBLE : return "DOUBLE";
case OCI_TYPECODE_INTEGER : return "INT";
case OCI_TYPECODE_SIGNED16 : return "SHORT";
case OCI_TYPECODE_SIGNED32 : return "LONG";
case OCI_TYPECODE_DECIMAL : return "DECIMAL";
case OCI_TYPECODE_FLOAT : return "FLOAT";
case OCI_TYPECODE_NUMBER : return "NUMBER";
case OCI_TYPECODE_SMALLINT: return "SMALLINT";
case OCI_TYPECODE_OBJECT: return "OBJECT";
case OCI_TYPECODE_OPAQUE: return "XMLTYPE~OPAQUE";
case OCI_TYPECODE_VARRAY: return "VARRAY";
case OCI_TYPECODE_TABLE: return "TABLE";
case OCI_TYPECODE_NAMEDCOLLECTION: return "NAMEDCOLLECTION";
}
sv = sv_2mortal(newSVpv("",0));
sv_grow(sv, 50);
sprintf(SvPVX(sv),"(UNKNOWN OCI TYPECODE %d)", typecode);
return SvPVX(sv);
}
char *
oci_status_name(sword status)
{
dTHX;
SV *sv;
switch (status) {
case OCI_SUCCESS: return "SUCCESS";
case OCI_SUCCESS_WITH_INFO: return "SUCCESS_WITH_INFO";
case OCI_NEED_DATA: return "NEED_DATA";
case OCI_NO_DATA: return "NO_DATA";
case OCI_ERROR: return "ERROR";
case OCI_INVALID_HANDLE: return "INVALID_HANDLE";
case OCI_STILL_EXECUTING: return "STILL_EXECUTING";
case OCI_CONTINUE: return "CONTINUE";
}
sv = sv_2mortal(newSVpv("",0));
sv_grow(sv, 50);
sprintf(SvPVX(sv),"(UNKNOWN OCI STATUS %d)", status);
return SvPVX(sv);
}
/* the various modes used in OCI */
char *
oci_define_options(ub4 options)
{
dTHX;
SV *sv;
switch (options) {
/*------------------------Bind and Define Options----------------------------*/
case OCI_DEFAULT: return "DEFAULT";
case OCI_DYNAMIC_FETCH: return "DYNAMIC_FETCH"; /* fetch dynamically */
}
sv = sv_2mortal(newSVpv("",0));
sv_grow(sv, 50);
sprintf(SvPVX(sv),"(UNKNOWN OCI DEFINE MODE %d)", options);
return SvPVX(sv);
}
char *
oci_bind_options(ub4 options)
{
dTHX;
SV *sv;
switch (options) {
/*------------------------Bind and Define Options----------------------------*/
case OCI_DEFAULT: return "DEFAULT";
case OCI_SB2_IND_PTR: return "SB2_IND_PTR"; /* unused */
case OCI_DATA_AT_EXEC: return "DATA_AT_EXEC"; /* data at execute time */
case OCI_PIECEWISE: return "PIECEWISE"; /* piecewise DMLs or fetch */
/* case OCI_BIND_SOFT: return "BIND_SOFT"; soft bind or define */
/* case OCI_DEFINE_SOFT: return "DEFINE_SOFT"; soft bind or define */
/* case OCI_IOV: return ""; 11g only release 1.23 me thinks For scatter gather bind/define */
}
sv = sv_2mortal(newSVpv("",0));
sv_grow(sv, 50);
sprintf(SvPVX(sv),"(UNKNOWN BIND MODE %d)", options);
return SvPVX(sv);
}
/* the various modes used in OCI */
char *
oci_mode(ub4 mode)
{
dTHX;
SV *sv;
switch (mode) {
case 3: return "THREADED | OBJECT";
case OCI_DEFAULT: return "DEFAULT";
/* the default value for parameters and attributes */
/*-------------OCIInitialize Modes / OCICreateEnvironment Modes -------------*/
case OCI_THREADED: return "THREADED"; /* appl. in threaded environment */
case OCI_OBJECT: return "OBJECT"; /* application in object environment */
case OCI_EVENTS: return "EVENTS"; /* application is enabled for events */
case OCI_SHARED: return "SHARED"; /* the application is in shared mode */
/* The following *TWO* are only valid for OCICreateEnvironment call */
case OCI_NO_UCB: return "NO_UCB "; /* No user callback called during ini */
case OCI_NO_MUTEX: return "NO_MUTEX"; /* the environment handle will not be
protected by a mutex internally */
case OCI_SHARED_EXT: return "SHARED_EXT"; /* Used for shared forms */
case OCI_ALWAYS_BLOCKING:return "ALWAYS_BLOCKING"; /* all connections always blocking */
case OCI_USE_LDAP: return "USE_LDAP"; /* allow LDAP connections */
case OCI_REG_LDAPONLY: return "REG_LDAPONLY"; /* only register to LDAP */
case OCI_UTF16: return "UTF16"; /* mode for all UTF16 metadata */
case OCI_AFC_PAD_ON: return "AFC_PAD_ON"; /* turn on AFC blank padding when rlenp present */
case OCI_NEW_LENGTH_SEMANTICS: return "NEW_LENGTH_SEMANTICS"; /* adopt new length semantics
the new length semantics, always bytes, is used by OCIEnvNlsCreate */
case OCI_NO_MUTEX_STMT: return "NO_MUTEX_STMT"; /* Do not mutex stmt handle */
case OCI_MUTEX_ENV_ONLY: return "MUTEX_ENV_ONLY"; /* Mutex only the environment handle */
/* case OCI_SUPPRESS_NLS_VALIDATION:return "SUPPRESS_NLS_VALIDATION"; suppress nls validation*/
/* nls validation suppression is on by default;*/
/* use OCI_ENABLE_NLS_VALIDATION to disable it */
/* case OCI_MUTEX_TRY: return "MUTEX_TRY"; try and acquire mutex */
/* case OCI_NCHAR_LITERAL_REPLACE_ON: return "NCHAR_LITERAL_REPLACE_ON"; nchar literal replace on */
/* case OCI_NCHAR_LITERAL_REPLACE_OFF:return "NCHAR_LITERAL_REPLACE_OFF"; nchar literal replace off*/
/* case OCI_ENABLE_NLS_VALIDATION: return "ENABLE_NLS_VALIDATION"; enable nls validation */
/*------------------------OCIConnectionpoolCreate Modes----------------------*/
case OCI_CPOOL_REINITIALIZE: return "CPOOL_REINITIALIZE";
/*--------------------------------- OCILogon2 Modes -------------------------*/
/*case OCI_LOGON2_SPOOL: return "LOGON2_SPOOL"; Use session pool */
case OCI_LOGON2_CPOOL: return "LOGON2_CPOOL"; /* Use connection pool */
/*case OCI_LOGON2_STMTCACHE: return "LOGON2_STMTCACHE"; Use Stmt Caching */
case OCI_LOGON2_PROXY: return "LOGON2_PROXY"; /* Proxy authentiaction */
/*------------------------- OCISessionPoolCreate Modes ----------------------*/
/*case OCI_SPC_REINITIALIZE: return "SPC_REINITIALIZE"; Reinitialize the session pool */
/*case OCI_SPC_HOMOGENEOUS: return "SPC_HOMOGENEOUS"; ""; Session pool is homogeneneous */
/*case OCI_SPC_STMTCACHE: return "SPC_STMTCACHE"; Session pool has stmt cache */
/*case OCI_SPC_NO_RLB: return "SPC_NO_RLB "; Do not enable Runtime load balancing. */
/*--------------------------- OCISessionGet Modes ---------------------------*/
/*case OCI_SESSGET_SPOOL: return "SESSGET_SPOOL"; SessionGet called in SPOOL mode */
/*case OCI_SESSGET_CPOOL: return "SESSGET_CPOOL"; SessionGet called in CPOOL mode */
/*case OCI_SESSGET_STMTCACHE: return "SESSGET_STMTCACHE"; Use statement cache */
/*case OCI_SESSGET_CREDPROXY: return "SESSGET_CREDPROXY"; SessionGet called in proxy mode */
/*case OCI_SESSGET_CREDEXT: return "SESSGET_CREDEXT"; */
case OCI_SESSGET_SPOOL_MATCHANY:return "SESSGET_SPOOL_MATCHANY";
/*case OCI_SESSGET_PURITY_NEW: return "SESSGET_PURITY_NEW";
case OCI_SESSGET_PURITY_SELF: return "SESSGET_PURITY_SELF"; */
}
sv = sv_2mortal(newSVpv("",0));
sv_grow(sv, 50);
sprintf(SvPVX(sv),"(UNKNOWN OCI MODE %d)", mode);
return SvPVX(sv);
}
char *
oci_stmt_type_name(int stmt_type)
{
dTHX;
SV *sv;
switch (stmt_type) {
case OCI_STMT_SELECT: return "SELECT";
case OCI_STMT_UPDATE: return "UPDATE";
case OCI_STMT_DELETE: return "DELETE";
case OCI_STMT_INSERT: return "INSERT";
case OCI_STMT_CREATE: return "CREATE";
case OCI_STMT_DROP: return "DROP";
case OCI_STMT_ALTER: return "ALTER";
case OCI_STMT_BEGIN: return "BEGIN";
case OCI_STMT_DECLARE: return "DECLARE";
}
sv = sv_2mortal(newSVpv("",0));
sv_grow(sv, 50);
sprintf(SvPVX(sv),"(STMT TYPE %d)", stmt_type);
return SvPVX(sv);
}
char *
oci_col_return_codes(int rc)
{
dTHX;
SV *sv;
switch (rc) {
case 1406: return "TRUNCATED";
case 0: return "OK";
case 1405: return "NULL";
case 1403: return "NO DATA";
}
sv = sv_2mortal(newSVpv("",0));
sv_grow(sv, 50);
sprintf(SvPVX(sv),"UNKNOWN RC=%d)", rc);
return SvPVX(sv);
}
char *
oci_hdtype_name(ub4 hdtype)
{
dTHX;
SV *sv;
switch (hdtype) {
/* Handles */
case OCI_HTYPE_ENV: return "OCI_HTYPE_ENV";
case OCI_HTYPE_ERROR: return "OCI_HTYPE_ERROR";
case OCI_HTYPE_SVCCTX: return "OCI_HTYPE_SVCCTX";
case OCI_HTYPE_STMT: return "OCI_HTYPE_STMT";
case OCI_HTYPE_BIND: return "OCI_HTYPE_BIND";
case OCI_HTYPE_DEFINE: return "OCI_HTYPE_DEFINE";
case OCI_HTYPE_DESCRIBE: return "OCI_HTYPE_DESCRIBE";
case OCI_HTYPE_SERVER: return "OCI_HTYPE_SERVER";
case OCI_HTYPE_SESSION: return "OCI_HTYPE_SESSION";
case OCI_HTYPE_CPOOL: return "OCI_HTYPE_CPOOL";
case OCI_HTYPE_SPOOL: return "OCI_HTYPE_SPOOL";
/*case OCI_HTYPE_AUTHINFO: return "OCI_HTYPE_AUTHINFO";*/
/* Descriptors */
case OCI_DTYPE_LOB: return "OCI_DTYPE_LOB";
case OCI_DTYPE_SNAP: return "OCI_DTYPE_SNAP";
case OCI_DTYPE_RSET: return "OCI_DTYPE_RSET";
case OCI_DTYPE_PARAM: return "OCI_DTYPE_PARAM";
case OCI_DTYPE_ROWID: return "OCI_DTYPE_ROWID";
#ifdef OCI_DTYPE_REF
case OCI_DTYPE_REF: return "OCI_DTYPE_REF";
#endif
}
sv = sv_2mortal(newSViv((IV)hdtype));
return SvPV(sv,PL_na);
}
/*used to look up the name of a csform value
used only for debugging */
char *
oci_csform_name(ub4 attr)
{
dTHX;
SV *sv;
switch (attr) {
/* CHAR/NCHAR/VARCHAR2/NVARCHAR2/CLOB/NCLOB char set "form" information */
case SQLCS_IMPLICIT: return "SQLCS_IMPLICIT";/* for CHAR, VARCHAR2, CLOB w/o a specified set */
case SQLCS_NCHAR: return "SQLCS_NCHAR";/* for NCHAR, NCHAR VARYING, NCLOB */
case SQLCS_EXPLICIT: return "SQLCS_EXPLICIT";/* for CHAR, etc, with "CHARACTER SET ..." syntax */
case SQLCS_FLEXIBLE: return "SQLCS_FLEXIBLE";/* for PL/SQL "flexible" parameters */
case SQLCS_LIT_NULL: return "SQLCS_LIT_NULL";/* for typecheck of NULL and empty_clob() lits */
}
sv = sv_2mortal(newSViv((IV)attr));
return SvPV(sv,PL_na);
}
/*used to look up the name of a OCI_DTYPE_PARAM Attribute Types
used only for debugging */
char *
oci_dtype_attr_name(ub4 attr)
{
dTHX;
SV *sv;
switch (attr) {
/*=======================Describe Handle Parameter Attributes ===============*/
case OCI_ATTR_DATA_SIZE: return "OCI_ATTR_DATA_SIZE"; /* maximum size of the data */
case OCI_ATTR_DATA_TYPE: return "OCI_ATTR_DATA_TYPE"; /* the SQL type of the column/argument */
case OCI_ATTR_DISP_SIZE: return "OCI_ATTR_DISP_SIZE"; /* the display size */
case OCI_ATTR_NAME: return "OCI_ATTR_NAME"; /* the name of the column/argument */
case OCI_ATTR_PRECISION: return "OCI_ATTR_PRECISION"; /* precision if number type */
case OCI_ATTR_SCALE: return "OCI_ATTR_SCALE"; /* scale if number type */
case OCI_ATTR_IS_NULL: return "OCI_ATTR_IS_NULL"; /* is it null ? */
case OCI_ATTR_TYPE_NAME: return "OCI_ATTR_TYPE_NAME";
/* name of the named data type or a package name for package private types */
case OCI_ATTR_SCHEMA_NAME: return "OCI_ATTR_SCHEMA_NAME"; /* the schema name */
case OCI_ATTR_SUB_NAME: return "OCI_ATTR_SUB_NAME"; /* type name if package private type */
case OCI_ATTR_POSITION: return "OCI_ATTR_POSITION";
case OCI_ATTR_CHAR_USED: return "OCI_ATTR_CHAR_USED"; /* char length semantics */
case OCI_ATTR_CHAR_SIZE: return "OCI_ATTR_CHAR_SIZE"; /* char length */
case OCI_ATTR_CHARSET_ID: return "OCI_ATTR_CHARSET_ID"; /* Character Set ID */
case OCI_ATTR_CHARSET_FORM: return "OCI_ATTR_CHARSET_FORM"; /* Character Set Form */
}
sv = sv_2mortal(newSViv((IV)attr));
return SvPV(sv,PL_na);
}
/*used to look up the name of non a OCI_DTYPE_PARAM Attribute Types
used only for debugging */
char *
oci_attr_name(ub4 attr)
{
dTHX;
SV *sv;
switch (attr) {
#ifdef ORA_OCI_102
case OCI_ATTR_MODULE: return "OCI_ATTR_MODULE"; /* module for tracing */
case OCI_ATTR_ACTION: return "OCI_ATTR_ACTION"; /* action for tracing */
case OCI_ATTR_CLIENT_INFO: return "OCI_ATTR_CLIENT_INFO"; /* client info */
case OCI_ATTR_COLLECT_CALL_TIME: return "OCI_ATTR_COLLECT_CALL_TIME"; /* collect call time */
case OCI_ATTR_CALL_TIME: return "OCI_ATTR_CALL_TIME"; /* extract call time */
case OCI_ATTR_ECONTEXT_ID: return "OCI_ATTR_ECONTEXT_ID"; /* execution-id context */
case OCI_ATTR_ECONTEXT_SEQ: return "OCI_ATTR_ECONTEXT_SEQ"; /*execution-id sequence num */
/*------------------------------ Session attributes -------------------------*/
case OCI_ATTR_SESSION_STATE: return "OCI_ATTR_SESSION_STATE"; /* session state */
case OCI_ATTR_SESSION_STATETYPE: return "OCI_ATTR_SESSION_STATETYPE"; /* session state type */
case OCI_SESSION_STATELESS_DEF: return "OCI_SESSION_STATELESS_DEF"; /* valid state types */
case OCI_ATTR_SESSION_STATE_CLEARED: return "OCI_ATTR_SESSION_STATE_CLEARED"; /* session state cleared*/
case OCI_ATTR_SESSION_MIGRATED: return "OCI_ATTR_SESSION_MIGRATED"; /* did session migrate*/
case OCI_ATTR_SESSION_PRESERVE_STATE: return "OCI_ATTR_SESSION_PRESERVE_STATE"; /* preserve session state */
#endif
#ifdef ORA_OCI_112
case OCI_ATTR_DRIVER_NAME: return "OCI_ATTR_DRIVER_NAME"; /* Driver Name */
#endif
case OCI_ATTR_CLIENT_IDENTIFIER: return "OCI_ATTR_CLIENT_IDENTIFIER"; /* value of client id to set*/
/*=============================Attribute Types===============================*/
#ifdef ORA_OCI_112
case OCI_ATTR_PURITY: return "OCI_ATTR_PURITY"; /* for DRCP session purity */
case OCI_ATTR_CONNECTION_CLASS: return "OCI_ATTR_CONNECTION_CLASS"; /* for DRCP connection class */
#endif
case OCI_ATTR_FNCODE: return "OCI_ATTR_FNCODE"; /* the OCI function code */
case OCI_ATTR_OBJECT: return "OCI_ATTR_OBJECT"; /* is the environment initialized in object mode */
case OCI_ATTR_NONBLOCKING_MODE: return "OCI_ATTR_NONBLOCKING_MODE"; /* non blocking mode */
case OCI_ATTR_SQLCODE: return "OCI_ATTR_SQLCODE"; /* the SQL verb */
case OCI_ATTR_ENV: return "OCI_ATTR_ENV"; /* the environment handle */
case OCI_ATTR_SERVER: return "OCI_ATTR_SERVER"; /* the server handle*/
case OCI_ATTR_SESSION: return "OCI_ATTR_SESSION"; /* the user session handle*/
case OCI_ATTR_TRANS: return "OCI_ATTR_TRANS"; /* the transaction handle */
case OCI_ATTR_ROW_COUNT: return "OCI_ATTR_ROW_COUNT"; /* the rows processed so far */
case OCI_ATTR_SQLFNCODE: return "OCI_ATTR_SQLFNCODE"; /* the SQL verb of the statement */
case OCI_ATTR_PREFETCH_ROWS: return "OCI_ATTR_PREFETCH_ROWS"; /* sets the number of rows to prefetch */
case OCI_ATTR_NESTED_PREFETCH_ROWS: return "OCI_ATTR_NESTED_PREFETCH_ROWS"; /* the prefetch rows of nested table*/
case OCI_ATTR_PREFETCH_MEMORY: return "OCI_ATTR_PREFETCH_MEMORY"; /* memory limit for rows fetched */
case OCI_ATTR_NESTED_PREFETCH_MEMORY:return "OCI_ATTR_NESTED_PREFETCH_MEMORY"; /* memory limit for nested rows */
case OCI_ATTR_CHAR_COUNT: return "OCI_ATTR_CHAR_COUNT"; /* this specifies the bind and define size in characters */
case OCI_ATTR_PDSCL: return "OCI_ATTR_PDSCL"; /* packed decimal scale*/
/*case OCI_ATTR_FSPRECISION OCI_ATTR_PDSCL:return ""; fs prec for datetime data types */
case OCI_ATTR_PDPRC: return "OCI_ATTR_PDPRC"; /* packed decimal format*/
/*case OCI_ATTR_LFPRECISION OCI_ATTR_PDPRC: return ""; fs prec for datetime data types */
case OCI_ATTR_PARAM_COUNT: return "OCI_ATTR_PARAM_COUNT"; /* number of column in the select list */
case OCI_ATTR_ROWID: return "OCI_ATTR_ROWID"; /* the rowid */
case OCI_ATTR_CHARSET: return "OCI_ATTR_CHARSET"; /* the character set value */
case OCI_ATTR_NCHAR: return "OCI_ATTR_NCHAR"; /* NCHAR type */
case OCI_ATTR_USERNAME: return "OCI_ATTR_USERNAME"; /* username attribute */
case OCI_ATTR_PASSWORD: return "OCI_ATTR_PASSWORD"; /* password attribute */
case OCI_ATTR_STMT_TYPE: return "OCI_ATTR_STMT_TYPE"; /* statement type */
case OCI_ATTR_INTERNAL_NAME: return "OCI_ATTR_INTERNAL_NAME"; /* user friendly global name */
case OCI_ATTR_EXTERNAL_NAME: return "OCI_ATTR_EXTERNAL_NAME"; /* the internal name for global txn */
case OCI_ATTR_XID: return "OCI_ATTR_XID"; /* XOPEN defined global transaction id */
case OCI_ATTR_TRANS_LOCK: return "OCI_ATTR_TRANS_LOCK"; /* */
case OCI_ATTR_TRANS_NAME: return "OCI_ATTR_TRANS_NAME"; /* string to identify a global transaction */
case OCI_ATTR_HEAPALLOC: return "OCI_ATTR_HEAPALLOC"; /* memory allocated on the heap */
case OCI_ATTR_CHARSET_FORM: return "OCI_ATTR_CHARSET_FORM"; /* Character Set Form */
case OCI_ATTR_MAXDATA_SIZE: return "OCI_ATTR_MAXDATA_SIZE"; /* Maximumsize of data on the server */
case OCI_ATTR_CACHE_OPT_SIZE: return "OCI_ATTR_CACHE_OPT_SIZE"; /* object cache optimal size */
case OCI_ATTR_CACHE_MAX_SIZE: return "OCI_ATTR_CACHE_MAX_SIZE"; /* object cache maximum size percentage */
case OCI_ATTR_PINOPTION: return "OCI_ATTR_PINOPTION"; /* object cache default pin option */
case OCI_ATTR_ALLOC_DURATION: return "OCI_ATTR_ALLOC_DURATION"; /* object cache default allocation duration */
case OCI_ATTR_PIN_DURATION: return "OCI_ATTR_PIN_DURATION"; /* object cache default pin duration */
case OCI_ATTR_FDO: return "OCI_ATTR_FDO"; /* Format Descriptor object attribute */
case OCI_ATTR_POSTPROCESSING_CALLBACK: return "OCI_ATTR_POSTPROCESSING_CALLBACK"; /* Callback to process outbind data */
case OCI_ATTR_POSTPROCESSING_CONTEXT: return "OCI_ATTR_POSTPROCESSING_CONTEXT"; /* Callback context to process outbind data */
case OCI_ATTR_ROWS_RETURNED: return "OCI_ATTR_ROWS_RETURNED"; /* Number of rows returned in current iter - for Bind handles */
case OCI_ATTR_FOCBK: return "OCI_ATTR_FOCBK"; /* Failover Callback attribute */
case OCI_ATTR_IN_V8_MODE: return "OCI_ATTR_IN_V8_MODE"; /* is the server/service context in V8 mode */
case OCI_ATTR_LOBEMPTY: return "OCI_ATTR_LOBEMPTY"; /* empty lob ? */
case OCI_ATTR_SESSLANG: return "OCI_ATTR_SESSLANG"; /* session language handle */
case OCI_ATTR_VISIBILITY: return "OCI_ATTR_VISIBILITY"; /* visibility */
case OCI_ATTR_RELATIVE_MSGID: return "OCI_ATTR_RELATIVE_MSGID"; /* relative message id */
case OCI_ATTR_SEQUENCE_DEVIATION: return "OCI_ATTR_SEQUENCE_DEVIATION"; /* sequence deviation */
case OCI_ATTR_CONSUMER_NAME: return "OCI_ATTR_CONSUMER_NAME"; /* consumer name */
case OCI_ATTR_DEQ_MODE: return "OCI_ATTR_DEQ_MODE"; /* dequeue mode */
case OCI_ATTR_NAVIGATION: return "OCI_ATTR_NAVIGATION"; /* navigation */
case OCI_ATTR_WAIT: return "OCI_ATTR_WAIT"; /* wait */
case OCI_ATTR_DEQ_MSGID: return "OCI_ATTR_DEQ_MSGID"; /* dequeue message id */
case OCI_ATTR_PRIORITY: return "OCI_ATTR_PRIORITY"; /* priority */
case OCI_ATTR_DELAY: return "OCI_ATTR_DELAY"; /* delay */
case OCI_ATTR_EXPIRATION: return "OCI_ATTR_EXPIRATION"; /* expiration */
case OCI_ATTR_CORRELATION: return "OCI_ATTR_CORRELATION"; /* correlation id */
case OCI_ATTR_ATTEMPTS: return "OCI_ATTR_ATTEMPTS"; /* # of attempts */
case OCI_ATTR_RECIPIENT_LIST: return "OCI_ATTR_RECIPIENT_LIST"; /* recipient list */
case OCI_ATTR_EXCEPTION_QUEUE: return "OCI_ATTR_EXCEPTION_QUEUE"; /* exception queue name */
case OCI_ATTR_ENQ_TIME: return "OCI_ATTR_ENQ_TIME"; /* enqueue time (only OCIAttrGet) */
case OCI_ATTR_MSG_STATE: return "OCI_ATTR_MSG_STATE"; /* message state (only OCIAttrGet) */
/* NOTE: 64-66 used below */
case OCI_ATTR_AGENT_NAME: return "OCI_ATTR_AGENT_NAME"; /* agent name */
case OCI_ATTR_AGENT_ADDRESS: return "OCI_ATTR_AGENT_ADDRESS"; /* agent address */
case OCI_ATTR_AGENT_PROTOCOL: return "OCI_ATTR_AGENT_PROTOCOL"; /* agent protocol */
case OCI_ATTR_SENDER_ID: return "OCI_ATTR_SENDER_ID"; /* sender id */
case OCI_ATTR_ORIGINAL_MSGID: return "OCI_ATTR_ORIGINAL_MSGID"; /* original message id */
case OCI_ATTR_QUEUE_NAME: return "OCI_ATTR_QUEUE_NAME"; /* queue name */
case OCI_ATTR_NFY_MSGID: return "OCI_ATTR_NFY_MSGID"; /* message id */
case OCI_ATTR_MSG_PROP: return "OCI_ATTR_MSG_PROP"; /* message properties */
case OCI_ATTR_NUM_DML_ERRORS: return "OCI_ATTR_NUM_DML_ERRORS"; /* num of errs in array DML */
case OCI_ATTR_DML_ROW_OFFSET: return "OCI_ATTR_DML_ROW_OFFSET"; /* row offset in the array */
case OCI_ATTR_DATEFORMAT: return "OCI_ATTR_DATEFORMAT"; /* default date format string */
case OCI_ATTR_BUF_ADDR: return "OCI_ATTR_BUF_ADDR"; /* buffer address */
case OCI_ATTR_BUF_SIZE: return "OCI_ATTR_BUF_SIZE"; /* buffer size */
case OCI_ATTR_DIRPATH_MODE: return "OCI_ATTR_DIRPATH_MODE"; /* mode of direct path operation */
case OCI_ATTR_DIRPATH_NOLOG: return "OCI_ATTR_DIRPATH_NOLOG"; /* nologging option */
case OCI_ATTR_DIRPATH_PARALLEL: return "OCI_ATTR_DIRPATH_PARALLEL"; /* parallel (temp seg) option */
case OCI_ATTR_NUM_ROWS: return "OCI_ATTR_NUM_ROWS"; /* number of rows in column array */
/* NOTE that OCI_ATTR_NUM_COLS is a column*/
/* array attribute too.*/
case OCI_ATTR_COL_COUNT: return "OCI_ATTR_COL_COUNT"; /* columns of column array*/
/*processed so far. */
case OCI_ATTR_STREAM_OFFSET: return "OCI_ATTR_STREAM_OFFSET"; /* str off of last row processed*/
/* case OCI_ATTR_SHARED_HEAPALLO: return ""; Shared Heap Allocation Size */
case OCI_ATTR_SERVER_GROUP: return "OCI_ATTR_SERVER_GROUP"; /* server group name */
case OCI_ATTR_MIGSESSION: return "OCI_ATTR_MIGSESSION"; /* migratable session attribute */
case OCI_ATTR_NOCACHE: return "OCI_ATTR_NOCACHE"; /* Temporary LOBs */
case OCI_ATTR_MEMPOOL_SIZE: return "OCI_ATTR_MEMPOOL_SIZE"; /* Pool Size */
case OCI_ATTR_MEMPOOL_INSTNAME: return "OCI_ATTR_MEMPOOL_INSTNAME"; /* Instance name */
case OCI_ATTR_MEMPOOL_APPNAME: return "OCI_ATTR_MEMPOOL_APPNAME"; /* Application name */
case OCI_ATTR_MEMPOOL_HOMENAME: return "OCI_ATTR_MEMPOOL_HOMENAME"; /* Home Directory name */
case OCI_ATTR_MEMPOOL_MODEL: return "OCI_ATTR_MEMPOOL_MODEL"; /* Pool Model (proc,thrd,both)*/
case OCI_ATTR_MODES: return "OCI_ATTR_MODES"; /* Modes */
case OCI_ATTR_SUBSCR_NAME: return "OCI_ATTR_SUBSCR_NAME"; /* name of subscription */
case OCI_ATTR_SUBSCR_CALLBACK: return "OCI_ATTR_SUBSCR_CALLBACK"; /* associated callback */
case OCI_ATTR_SUBSCR_CTX: return "OCI_ATTR_SUBSCR_CTX"; /* associated callback context */
case OCI_ATTR_SUBSCR_PAYLOAD: return "OCI_ATTR_SUBSCR_PAYLOAD"; /* associated payload */
case OCI_ATTR_SUBSCR_NAMESPACE: return "OCI_ATTR_SUBSCR_NAMESPACE"; /* associated namespace */
case OCI_ATTR_PROXY_CREDENTIALS: return "OCI_ATTR_PROXY_CREDENTIALS"; /* Proxy user credentials */
case OCI_ATTR_INITIAL_CLIENT_ROLES: return "OCI_ATTR_INITIAL_CLIENT_ROLES"; /* Initial client role list */
case OCI_ATTR_UNK: return "OCI_ATTR_UNK"; /* unknown attribute */
case OCI_ATTR_NUM_COLS: return "OCI_ATTR_NUM_COLS"; /* number of columns */
case OCI_ATTR_LIST_COLUMNS: return "OCI_ATTR_LIST_COLUMNS"; /* parameter of the column list */
case OCI_ATTR_RDBA: return "OCI_ATTR_RDBA"; /* DBA of the segment header */
case OCI_ATTR_CLUSTERED: return "OCI_ATTR_CLUSTERED"; /* whether the table is clustered */
case OCI_ATTR_PARTITIONED: return "OCI_ATTR_PARTITIONED"; /* whether the table is partitioned */
case OCI_ATTR_INDEX_ONLY: return "OCI_ATTR_INDEX_ONLY"; /* whether the table is index only */
case OCI_ATTR_LIST_ARGUMENTS: return "OCI_ATTR_LIST_ARGUMENTS"; /* parameter of the argument list */
case OCI_ATTR_LIST_SUBPROGRAMS: return "OCI_ATTR_LIST_SUBPROGRAMS"; /* parameter of the subprogram list */
case OCI_ATTR_REF_TDO: return "OCI_ATTR_REF_TDO"; /* REF to the type descriptor */
case OCI_ATTR_LINK: return "OCI_ATTR_LINK"; /* the database link name */
case OCI_ATTR_MIN: return "OCI_ATTR_MIN"; /* minimum value */
case OCI_ATTR_MAX: return "OCI_ATTR_MAX"; /* maximum value */
case OCI_ATTR_INCR: return "OCI_ATTR_INCR"; /* increment value */
case OCI_ATTR_CACHE: return "OCI_ATTR_CACHE"; /* number of sequence numbers cached */
case OCI_ATTR_ORDER: return "OCI_ATTR_ORDER"; /* whether the sequence is ordered */
case OCI_ATTR_HW_MARK: return "OCI_ATTR_HW_MARK"; /* high-water mark */
case OCI_ATTR_TYPE_SCHEMA: return "OCI_ATTR_TYPE_SCHEMA"; /* type's schema name */
case OCI_ATTR_TIMESTAMP: return "OCI_ATTR_TIMESTAMP"; /* timestamp of the object */
case OCI_ATTR_NUM_ATTRS: return "OCI_ATTR_NUM_ATTRS"; /* number of sttributes */
case OCI_ATTR_NUM_PARAMS: return "OCI_ATTR_NUM_PARAMS"; /* number of parameters */
case OCI_ATTR_OBJID: return "OCI_ATTR_OBJID"; /* object id for a table or view */
case OCI_ATTR_PTYPE: return "OCI_ATTR_PTYPE"; /* type of info described by */
case OCI_ATTR_PARAM: return "OCI_ATTR_PARAM"; /* parameter descriptor */
case OCI_ATTR_OVERLOAD_ID: return "OCI_ATTR_OVERLOAD_ID"; /* overload ID for funcs and procs */
case OCI_ATTR_TABLESPACE: return "OCI_ATTR_TABLESPACE"; /* table name space */
case OCI_ATTR_TDO: return "OCI_ATTR_TDO"; /* TDO of a type */
case OCI_ATTR_LTYPE: return "OCI_ATTR_LTYPE"; /* list type */
case OCI_ATTR_PARSE_ERROR_OFFSET: return "OCI_ATTR_PARSE_ERROR_OFFSET";/* Parse Error offset */
case OCI_ATTR_IS_TEMPORARY: return "OCI_ATTR_IS_TEMPORARY"; /* whether table is temporary */
case OCI_ATTR_IS_TYPED: return "OCI_ATTR_IS_TYPED"; /* whether table is typed */
case OCI_ATTR_DURATION: return "OCI_ATTR_DURATION"; /* duration of temporary table */
case OCI_ATTR_IS_INVOKER_RIGHTS: return "OCI_ATTR_IS_INVOKER_RIGHTS";/* is invoker rights */
case OCI_ATTR_OBJ_NAME: return "OCI_ATTR_OBJ_NAME"; /* top level schema obj name */
case OCI_ATTR_OBJ_SCHEMA: return "OCI_ATTR_OBJ_SCHEMA"; /* schema name */
case OCI_ATTR_OBJ_ID: return "OCI_ATTR_OBJ_ID"; /* top level schema object id */
case OCI_ATTR_DIRPATH_SORTED_INDEX: return "OCI_ATTR_DIRPATH_SORTED_INDEX";/* index that data is sorted on */
/* direct path index maint method (see oci8dp.h) */
case OCI_ATTR_DIRPATH_INDEX_MAINT_METHOD: return "OCI_ATTR_DIRPATH_INDEX_MAINT_METHOD";/* parallel load: db file, initial and next extent sizes */
case OCI_ATTR_DIRPATH_FILE: return "OCI_ATTR_DIRPATH_FILE"; /* DB file to load into */
case OCI_ATTR_DIRPATH_STORAGE_INITIAL: return "OCI_ATTR_DIRPATH_STORAGE_INITIAL"; /* initial extent size */
case OCI_ATTR_DIRPATH_STORAGE_NEXT: return "OCI_ATTR_DIRPATH_STORAGE_NEXT"; /* next extent size */
case OCI_ATTR_TRANS_TIMEOUT: return "OCI_ATTR_TRANS_TIMEOUT"; /* transaction timeout */
case OCI_ATTR_SERVER_STATUS: return "OCI_ATTR_SERVER_STATUS"; /* state of the server handle */
case OCI_ATTR_STATEMENT: return "OCI_ATTR_STATEMENT"; /* statement txt in stmt hdl */
/* statement should not be executed in cache*/
/*case OCI_ATTR_NO_CACHE: return "";*/
case OCI_ATTR_DEQCOND: return "OCI_ATTR_DEQCOND"; /* dequeue condition */
case OCI_ATTR_RESERVED_2: return "OCI_ATTR_RESERVED_2"; /* reserved */
case OCI_ATTR_SUBSCR_RECPT: return "OCI_ATTR_SUBSCR_RECPT"; /* recepient of subscription */
case OCI_ATTR_SUBSCR_RECPTPROTO: return "OCI_ATTR_SUBSCR_RECPTPROTO";/* protocol for recepient */
/* 8.2 dpapi support of ADTs */
case OCI_ATTR_DIRPATH_EXPR_TYPE: return "OCI_ATTR_DIRPATH_EXPR_TYPE"; /* expr type of OCI_ATTR_NAME */
case OCI_ATTR_DIRPATH_INPUT: return "OCI_ATTR_DIRPATH_INPUT"; /* input in text or stream format*/
/* case OCI_DIRPATH_INPUT_TEXT: return "";
case OCI_DIRPATH_INPUT_STREAM: return "";
case OCI_DIRPATH_INPUT_UNKNOWN: return ""; */
case OCI_ATTR_LDAP_HOST: return "OCI_ATTR_LDAP_HOST"; /* LDAP host to connect to */
case OCI_ATTR_LDAP_PORT: return "OCI_ATTR_LDAP_PORT"; /* LDAP port to connect to */
case OCI_ATTR_BIND_DN: return "OCI_ATTR_BIND_DN"; /* bind DN */
case OCI_ATTR_LDAP_CRED: return "OCI_ATTR_LDAP_CRED"; /* credentials to connect to LDAP */
case OCI_ATTR_WALL_LOC: return "OCI_ATTR_WALL_LOC"; /* client wallet location */
case OCI_ATTR_LDAP_AUTH: return "OCI_ATTR_LDAP_AUTH"; /* LDAP authentication method */
case OCI_ATTR_LDAP_CTX: return "OCI_ATTR_LDAP_CTX"; /* LDAP adminstration context DN */
case OCI_ATTR_SERVER_DNS: return "OCI_ATTR_SERVER_DNS"; /* list of registration server DNs */
case OCI_ATTR_DN_COUNT: return "OCI_ATTR_DN_COUNT"; /* the number of server DNs */
case OCI_ATTR_SERVER_DN: return "OCI_ATTR_SERVER_DN"; /* server DN attribute */
case OCI_ATTR_MAXCHAR_SIZE: return "OCI_ATTR_MAXCHAR_SIZE"; /* max char size of data */
case OCI_ATTR_CURRENT_POSITION: return "OCI_ATTR_CURRENT_POSITION"; /* for scrollable result sets*/
/* Added to get attributes for ref cursor to statement handle */
case OCI_ATTR_RESERVED_3: return "OCI_ATTR_RESERVED_3"; /* reserved */
case OCI_ATTR_RESERVED_4: return "OCI_ATTR_RESERVED_4"; /* reserved */
case OCI_ATTR_DIRPATH_FN_CTX: return ""; /* fn ctx ADT attrs or args */
case OCI_ATTR_DIGEST_ALGO: return "OCI_ATTR_DIRPATH_FN_CTX"; /* digest algorithm */
case OCI_ATTR_CERTIFICATE: return "OCI_ATTR_CERTIFICATE"; /* certificate */
case OCI_ATTR_SIGNATURE_ALGO: return "OCI_ATTR_SIGNATURE_ALGO"; /* signature algorithm */
case OCI_ATTR_CANONICAL_ALGO: return "OCI_ATTR_CANONICAL_ALGO"; /* canonicalization algo. */
case OCI_ATTR_PRIVATE_KEY: return "OCI_ATTR_PRIVATE_KEY"; /* private key */
case OCI_ATTR_DIGEST_VALUE: return "OCI_ATTR_DIGEST_VALUE"; /* digest value */
case OCI_ATTR_SIGNATURE_VAL: return "OCI_ATTR_SIGNATURE_VAL"; /* signature value */
case OCI_ATTR_SIGNATURE: return "OCI_ATTR_SIGNATURE"; /* signature */
/* attributes for setting OCI stmt caching specifics in svchp */
case OCI_ATTR_STMTCACHESIZE : return "OCI_ATTR_STMTCACHESIZE"; /* size of the stm cache */
/* --------------------------- Connection Pool Attributes ------------------ */
case OCI_ATTR_CONN_NOWAIT: return "OCI_ATTR_CONN_NOWAIT";
case OCI_ATTR_CONN_BUSY_COUNT: return "OCI_ATTR_CONN_BUSY_COUNT";
case OCI_ATTR_CONN_OPEN_COUNT: return "OCI_ATTR_CONN_OPEN_COUNT";
case OCI_ATTR_CONN_TIMEOUT: return "OCI_ATTR_CONN_TIMEOUT";
case OCI_ATTR_STMT_STATE: return "OCI_ATTR_STMT_STATE";
case OCI_ATTR_CONN_MIN: return "OCI_ATTR_CONN_MIN";
case OCI_ATTR_CONN_MAX: return "OCI_ATTR_CONN_MAX";
case OCI_ATTR_CONN_INCR: return "OCI_ATTR_CONN_INCR";
case OCI_ATTR_DIRPATH_OID: return "OCI_ATTR_DIRPATH_OID"; /* loading into an OID col */
case OCI_ATTR_NUM_OPEN_STMTS: return "OCI_ATTR_NUM_OPEN_STMTS"; /* open stmts in session */
case OCI_ATTR_DESCRIBE_NATIVE: return "OCI_ATTR_DESCRIBE_NATIVE"; /* get native info via desc */
case OCI_ATTR_BIND_COUNT: return "OCI_ATTR_BIND_COUNT"; /* number of bind postions */
case OCI_ATTR_HANDLE_POSITION: return "OCI_ATTR_HANDLE_POSITION"; /* pos of bind/define handle */
case OCI_ATTR_RESERVED_5: return "OCI_ATTR_RESERVED_5"; /* reserverd */
case OCI_ATTR_SERVER_BUSY: return "OCI_ATTR_SERVER_BUSY"; /* call in progress on server*/
case OCI_ATTR_DIRPATH_SID: return "OCI_ATTR_DIRPATH_SID"; /* loading into an SID col */
/* notification presentation for recipient */
case OCI_ATTR_SUBSCR_RECPTPRES: return "OCI_ATTR_SUBSCR_RECPTPRES";
case OCI_ATTR_TRANSFORMATION: return "OCI_ATTR_TRANSFORMATION"; /* AQ message transformation */
case OCI_ATTR_ROWS_FETCHED: return "OCI_ATTR_ROWS_FETCHED"; /* rows fetched in last call */
/* --------------------------- Snapshot attributes ------------------------- */
case OCI_ATTR_SCN_BASE: return "OCI_ATTR_SCN_BASE"; /* snapshot base */
case OCI_ATTR_SCN_WRAP: return "OCI_ATTR_SCN_WRAP"; /* snapshot wrap */
/* --------------------------- Miscellanous attributes --------------------- */
case OCI_ATTR_RESERVED_6: return "OCI_ATTR_RESERVED_6"; /* reserved */
case OCI_ATTR_READONLY_TXN: return "OCI_ATTR_READONLY_TXN"; /* txn is readonly */
case OCI_ATTR_RESERVED_7: return "OCI_ATTR_RESERVED_7"; /* reserved */
case OCI_ATTR_ERRONEOUS_COLUMN: return "OCI_ATTR_ERRONEOUS_COLUMN"; /* position of erroneous col */
case OCI_ATTR_RESERVED_8: return "OCI_ATTR_RESERVED_8"; /* reserved */
/* -------------------- 8.2 dpapi support of ADTs continued ---------------- */
case OCI_ATTR_DIRPATH_OBJ_CONSTR: return "OCI_ATTR_DIRPATH_OBJ_CONSTR"; /* obj type of subst obj tbl */
/************************FREE attribute 207 *************************/
/************************FREE attribute 208 *************************/
case OCI_ATTR_ENV_UTF16: return "OCI_ATTR_ENV_UTF16"; /* is env in utf16 mode? */
case OCI_ATTR_RESERVED_9: return "OCI_ATTR_RESERVED_9"; /* reserved for TMZ */
case OCI_ATTR_RESERVED_10: return "OCI_ATTR_RESERVED_10"; /* reserved */
/* Attr to allow setting of the stream version PRIOR to calling Prepare */
case OCI_ATTR_DIRPATH_STREAM_VERSION: return "OCI_ATTR_DIRPATH_STREAM_VERSION"; /* version of the stream*/
/* case OCI_ATTR_RESERVED_11: return "OCI_ATTR_RESERVED_11"; reserved */
case OCI_ATTR_RESERVED_12: return "OCI_ATTR_RESERVED_12"; /* reserved */
case OCI_ATTR_RESERVED_13: return "OCI_ATTR_RESERVED_13"; /* reserved */
/* OCI_ATTR_RESERVED_14 */
case OCI_ATTR_RESERVED_15: return "OCI_ATTR_RESERVED_15"; /* reserved */
case OCI_ATTR_RESERVED_16: return "OCI_ATTR_RESERVED_16"; /* reserved */
}
sv = sv_2mortal(newSViv((IV)attr));
return SvPV(sv,PL_na);
}
/*used to look up the name of a fetchtype constant
used only for debugging */
char *
oci_fetch_options(ub4 fetchtype)
{
dTHX;
SV *sv;
switch (fetchtype) {
/* fetch options */
case OCI_FETCH_CURRENT: return "OCI_FETCH_CURRENT";
case OCI_FETCH_NEXT: return "OCI_FETCH_NEXT";
case OCI_FETCH_FIRST: return "OCI_FETCH_FIRST";
case OCI_FETCH_LAST: return "OCI_FETCH_LAST";
case OCI_FETCH_PRIOR: return "OCI_FETCH_PRIOR";
case OCI_FETCH_ABSOLUTE: return "OCI_FETCH_ABSOLUTE";
case OCI_FETCH_RELATIVE: return "OCI_FETCH_RELATIVE";
}
sv = sv_2mortal(newSViv((IV)fetchtype));
return SvPV(sv,PL_na);
}
static sb4
oci_error_get(OCIError *errhp, sword status, char *what, SV *errstr, int debug)
{
dTHX;
text errbuf[1024];
ub4 recno = 0;
sb4 errcode = 0;
sb4 eg_errcode = 0;
sword eg_status;
if (!SvOK(errstr))
sv_setpv(errstr,"");
if (!errhp) {
sv_catpv(errstr, oci_status_name(status));
if (what) {
sv_catpv(errstr, " ");
sv_catpv(errstr, what);
}
return status;
}
while( ++recno
&& OCIErrorGet_log_stat(errhp, recno, (text*)NULL, &eg_errcode, errbuf,
(ub4)sizeof(errbuf), OCI_HTYPE_ERROR, eg_status) != OCI_NO_DATA
&& eg_status != OCI_INVALID_HANDLE
&& recno < 100) {
if (debug >= 4 || recno>1/*XXX temp*/)
PerlIO_printf(DBILOGFP, " OCIErrorGet after %s (er%ld:%s): %d, %ld: %s\n",
what ? what : "<NULL>", (long)recno,
(eg_status==OCI_SUCCESS) ? "ok" : oci_status_name(eg_status),
status, (long)eg_errcode, errbuf);
errcode = eg_errcode;
sv_catpv(errstr, (char*)errbuf);
if (*(SvEND(errstr)-1) == '\n')
--SvCUR(errstr);
}
if (what || status != OCI_ERROR) {
sv_catpv(errstr, (debug<0) ? " (" : " (DBD ");
sv_catpv(errstr, oci_status_name(status));
if (what) {
sv_catpv(errstr, ": ");
sv_catpv(errstr, what);
}
sv_catpv(errstr, ")");
}
return errcode;
}
int
oci_error_err(SV *h, OCIError *errhp, sword status, char *what, sb4 force_err)
{
dTHX;
D_imp_xxh(h);
sb4 errcode;
SV *errstr_sv = sv_newmortal();
SV *errcode_sv = sv_newmortal();
errcode = oci_error_get(errhp, status, what, errstr_sv, DBIS->debug);
if (CSFORM_IMPLIES_UTF8(SQLCS_IMPLICIT)) {
#ifdef sv_utf8_decode
sv_utf8_decode(errstr_sv);
#else
SvUTF8_on(errstr_sv);
#endif
}
/* DBIc_ERR *must* be SvTRUE (for RaiseError etc), some */
/* errors, like OCI_INVALID_HANDLE, don't set errcode. */
if (force_err)
errcode = force_err;
if (status == OCI_SUCCESS_WITH_INFO)
errcode = 0; /* record as a "warning" for DBI>=1.43 */
else if (errcode == 0)
errcode = (status != 0) ? status : -10000;
sv_setiv(errcode_sv, errcode);
DBIh_SET_ERR_SV(h, imp_xxh, errcode_sv, errstr_sv, &PL_sv_undef, &PL_sv_undef);
return 0; /* always returns 0 */
}
char *
ora_sql_error(imp_sth_t *imp_sth, char *msg)
{
dTHX;
#ifdef OCI_ATTR_PARSE_ERROR_OFFSET
D_imp_dbh_from_sth;
SV *msgsv, *sqlsv;
char buf[99];
sword status = 0;
ub2 parse_error_offset = 0;
OCIAttrGet_stmhp_stat(imp_sth, &parse_error_offset, 0,
OCI_ATTR_PARSE_ERROR_OFFSET, status);
imp_dbh->parse_error_offset = parse_error_offset;
if (!parse_error_offset)
return msg;
sprintf(buf,"error possibly near <*> indicator at char %d in '",
parse_error_offset);
msgsv = sv_2mortal(newSVpv(buf,0));
sqlsv = sv_2mortal(newSVpv(imp_sth->statement,0));
sv_insert(sqlsv, parse_error_offset, 0, "<*>", 3);
sv_catsv(msgsv, sqlsv);
sv_catpv(msgsv, "'");
return SvPV(msgsv,PL_na);
#else
imp_sth = imp_sth; /* not unused */
return msg;
#endif
}
void *
oci_db_handle(imp_dbh_t *imp_dbh, int handle_type, int flags)
{
dTHX;
switch(handle_type) {
case OCI_HTYPE_ENV: return imp_dbh->envhp;
case OCI_HTYPE_ERROR: return imp_dbh->errhp;
case OCI_HTYPE_SERVER: return imp_dbh->srvhp;
case OCI_HTYPE_SVCCTX: return imp_dbh->svchp;
case OCI_HTYPE_SESSION: return imp_dbh->seshp;
/*case OCI_HTYPE_AUTHINFO:return imp_dbh->authp;*/
}
croak("Can't get OCI handle type %d from DBI database handle", handle_type);
if( flags ) {/* For GCC not to warn on unused parameter */}
/* satisfy compiler warning, even though croak will never return */
return 0;
}
void *
oci_st_handle(imp_sth_t *imp_sth, int handle_type, int flags)
{
dTHX;
switch(handle_type) {
case OCI_HTYPE_ENV: return imp_sth->envhp;
case OCI_HTYPE_ERROR: return imp_sth->errhp;
case OCI_HTYPE_SERVER: return imp_sth->srvhp;
case OCI_HTYPE_SVCCTX: return imp_sth->svchp;
case OCI_HTYPE_STMT: return imp_sth->stmhp;
}
croak("Can't get OCI handle type %d from DBI statement handle", handle_type);
if( flags ) {/* For GCC not to warn on unused parameter */}
/* satisfy compiler warning, even though croak will never return */
return 0;
}
int
dbd_st_prepare(SV *sth, imp_sth_t *imp_sth, char *statement, SV *attribs)
{
dTHX;
D_imp_dbh_from_sth;
sword status = 0;
IV ora_piece_size = 0;
IV ora_pers_lob = 0;
IV ora_piece_lob = 0;
IV ora_clbk_lob = 0;
int ora_check_sql = 1; /* to force a describe to check SQL */
IV ora_placeholders = 1; /* find and handle placeholders */
/* XXX we set ora_check_sql on for now to force setup of the */
/* row cache. Change later to set up row cache using just a */
/* a memory size, perhaps also default $RowCacheSize to a */
/* negative value. OCI_ATTR_PREFETCH_MEMORY */
if (!DBIc_ACTIVE(imp_dbh)) {
oci_error(sth, NULL, OCI_ERROR, "Database disconnected");
return 0;
}
imp_dbh->parse_error_offset = 0;
imp_sth->done_desc = 0;
imp_sth->get_oci_handle = oci_st_handle;
if (DBIc_COMPAT(imp_sth)) {
static SV *ora_pad_empty;
if (!ora_pad_empty) {
ora_pad_empty= perl_get_sv("Oraperl::ora_pad_empty", GV_ADDMULTI);
if (!SvOK(ora_pad_empty) && getenv("ORAPERL_PAD_EMPTY"))
sv_setiv(ora_pad_empty, atoi(getenv("ORAPERL_PAD_EMPTY")));