ruby-oci8 2.2.0.2 → 2.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +1 -6
  3. data/ChangeLog +600 -0
  4. data/NEWS +426 -35
  5. data/README.md +27 -9
  6. data/dist-files +13 -2
  7. data/docs/bind-array-to-in_cond.md +38 -0
  8. data/docs/conflicts-local-connections-and-processes.md +98 -0
  9. data/docs/hanging-after-inactivity.md +63 -0
  10. data/docs/install-binary-package.md +15 -11
  11. data/docs/install-full-client.md +18 -21
  12. data/docs/install-instant-client.md +45 -27
  13. data/docs/install-on-osx.md +31 -117
  14. data/docs/ldap-auth-and-function-interposition.md +123 -0
  15. data/docs/number-type-mapping.md +79 -0
  16. data/docs/platform-specific-issues.md +17 -50
  17. data/docs/report-installation-issue.md +11 -8
  18. data/docs/timeout-parameters.md +94 -0
  19. data/ext/oci8/apiwrap.c.tmpl +2 -5
  20. data/ext/oci8/apiwrap.rb +6 -1
  21. data/ext/oci8/apiwrap.yml +39 -143
  22. data/ext/oci8/attr.c +4 -2
  23. data/ext/oci8/bind.c +421 -9
  24. data/ext/oci8/connection_pool.c +3 -3
  25. data/ext/oci8/encoding.c +5 -5
  26. data/ext/oci8/env.c +8 -2
  27. data/ext/oci8/error.c +24 -16
  28. data/ext/oci8/extconf.rb +35 -63
  29. data/ext/oci8/hook_funcs.c +274 -61
  30. data/ext/oci8/lob.c +31 -75
  31. data/ext/oci8/metadata.c +8 -6
  32. data/ext/oci8/object.c +119 -29
  33. data/ext/oci8/oci8.c +46 -133
  34. data/ext/oci8/oci8.h +40 -123
  35. data/ext/oci8/oci8lib.c +178 -46
  36. data/ext/oci8/ocihandle.c +37 -37
  37. data/ext/oci8/ocinumber.c +24 -35
  38. data/ext/oci8/oraconf.rb +168 -337
  39. data/ext/oci8/oradate.c +19 -19
  40. data/ext/oci8/plthook.h +10 -0
  41. data/ext/oci8/plthook_elf.c +433 -268
  42. data/ext/oci8/plthook_osx.c +40 -9
  43. data/ext/oci8/plthook_win32.c +16 -1
  44. data/ext/oci8/stmt.c +52 -17
  45. data/ext/oci8/win32.c +4 -22
  46. data/lib/oci8/bindtype.rb +10 -17
  47. data/lib/oci8/check_load_error.rb +57 -10
  48. data/lib/oci8/compat.rb +5 -1
  49. data/lib/oci8/connection_pool.rb +74 -3
  50. data/lib/oci8/cursor.rb +70 -31
  51. data/lib/oci8/metadata.rb +9 -1
  52. data/lib/oci8/object.rb +14 -1
  53. data/lib/oci8/oci8.rb +184 -58
  54. data/lib/oci8/ocihandle.rb +0 -16
  55. data/lib/oci8/oracle_version.rb +11 -1
  56. data/lib/oci8/properties.rb +55 -0
  57. data/lib/oci8/version.rb +1 -1
  58. data/lib/oci8.rb +48 -4
  59. data/lib/ruby-oci8.rb +1 -0
  60. data/pre-distclean.rb +1 -3
  61. data/ruby-oci8.gemspec +4 -9
  62. data/setup.rb +11 -2
  63. data/test/README.md +37 -0
  64. data/test/config.rb +8 -1
  65. data/test/setup_test_object.sql +42 -14
  66. data/test/setup_test_package.sql +59 -0
  67. data/test/test_all.rb +4 -0
  68. data/test/test_bind_array.rb +70 -0
  69. data/test/test_bind_boolean.rb +99 -0
  70. data/test/test_bind_integer.rb +47 -0
  71. data/test/test_break.rb +11 -9
  72. data/test/test_clob.rb +5 -17
  73. data/test/test_connstr.rb +142 -0
  74. data/test/test_datetime.rb +8 -3
  75. data/test/test_metadata.rb +2 -1
  76. data/test/test_object.rb +99 -18
  77. data/test/test_oci8.rb +170 -46
  78. data/test/test_oranumber.rb +12 -6
  79. data/test/test_package_type.rb +17 -3
  80. data/test/test_properties.rb +17 -0
  81. metadata +45 -55
  82. data/docs/osx-install-dev-tools.png +0 -0
  83. data/test/README +0 -42
data/ext/oci8/oci8.c CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * oci8.c - part of ruby-oci8
4
4
  *
5
- * Copyright (C) 2002-2015 Kubo Takehiro <kubo@jiubao.org>
5
+ * Copyright (C) 2002-2019 Kubo Takehiro <kubo@jiubao.org>
6
6
  *
7
7
  */
8
8
  #include "oci8.h"
@@ -286,7 +286,7 @@ static VALUE oci8_s_oracle_client_vernum(VALUE klass)
286
286
  /*
287
287
  * @overload OCI8.__get_prop(key)
288
288
  *
289
- * @param [Fixnum] key 1, 2 or 3
289
+ * @param [Integer] key 1, 2 or 3
290
290
  * @return [Object] depends on +key+.
291
291
  * @private
292
292
  */
@@ -306,16 +306,13 @@ static VALUE oci8_s_get_prop(VALUE klass, VALUE key)
306
306
  /*
307
307
  * @overload OCI8.__set_prop(key, value)
308
308
  *
309
- * @param [Fixnum] key 1, 2 or 3
309
+ * @param [Integer] key 1, 2 or 3
310
310
  * @param [Object] value depends on +key+.
311
311
  *
312
312
  * @private
313
313
  */
314
314
  static VALUE oci8_s_set_prop(VALUE klass, VALUE key, VALUE val)
315
315
  {
316
- #ifdef HAVE_PLTHOOK
317
- static int hook_functions_installed = 0;
318
- #endif
319
316
  switch (NUM2INT(key)) {
320
317
  case 1:
321
318
  oci8_float_conversion_type_is_ruby = RTEST(val) ? 1 : 0;
@@ -331,13 +328,21 @@ static VALUE oci8_s_set_prop(VALUE klass, VALUE key, VALUE val)
331
328
  oci8_env_mode = NUM2UINT(val);
332
329
  break;
333
330
  case 3:
331
+ if (oci8_cancel_read_at_exit == -1) {
332
+ rb_raise(rb_eNotImpError, "OCI8.properties[:cancel_read_at_exit] isn't available.");
333
+ }
334
334
  #ifdef HAVE_PLTHOOK
335
- if (!hook_functions_installed) {
336
- oci8_install_hook_functions();
337
- hook_functions_installed = 1;
335
+ oci8_install_hook_functions();
336
+ oci8_cancel_read_at_exit = RTEST(val) ? 1 : 0;
337
+ #endif
338
+ break;
339
+ case 4:
340
+ if (oci8_tcp_keepalive_time == -1) {
341
+ rb_raise(rb_eNotImpError, "OCI8.properties[:tcp_keepalive_time] isn't available.");
338
342
  }
339
- #else
340
- rb_raise(rb_eNotImpError, ":cancel_read_at_exit isn't implemented on this machine.");
343
+ #ifdef HAVE_PLTHOOK
344
+ oci8_install_hook_functions();
345
+ oci8_tcp_keepalive_time = NIL_P(val) ? 0 : NUM2INT(val);
341
346
  #endif
342
347
  break;
343
348
  default:
@@ -359,7 +364,7 @@ static VALUE oci8_s_set_prop(VALUE klass, VALUE key, VALUE val)
359
364
  * # When NLS_LANG is FRENCH_FRANCE.AL32UTF8
360
365
  * OCI8.error_message(1) # => "ORA-00001: violation de contrainte unique (%s.%s)"
361
366
  *
362
- * @param [Fixnum] message_no Oracle error message number
367
+ * @param [Integer] message_no Oracle error message number
363
368
  * @return [String] Oracle error message
364
369
  */
365
370
  static VALUE oci8_s_error_message(VALUE klass, VALUE msgid)
@@ -372,8 +377,8 @@ void oci8_do_parse_connect_string(VALUE conn_str, VALUE *user, VALUE *pass, VALU
372
377
  {
373
378
  static VALUE re = Qnil;
374
379
  if (NIL_P(re)) {
375
- re = rb_eval_string(CONN_STR_REGEX);
376
380
  rb_global_variable(&re);
381
+ re = rb_eval_string(CONN_STR_REGEX);
377
382
  }
378
383
  OCI8SafeStringValue(conn_str);
379
384
  if (RTEST(rb_reg_match(re, conn_str))) {
@@ -419,49 +424,6 @@ static VALUE oci8_parse_connect_string(VALUE self, VALUE conn_str)
419
424
  return rb_ary_new3(4, user, pass, dbname, mode);
420
425
  }
421
426
 
422
- /*
423
- * Logoff strategy for sessions connected by OCILogon.
424
- */
425
- typedef struct {
426
- OCISvcCtx *svchp;
427
- OCISession *usrhp;
428
- OCIServer *srvhp;
429
- } simple_logoff_arg_t;
430
-
431
- static void *simple_logoff_prepare(oci8_svcctx_t *svcctx)
432
- {
433
- simple_logoff_arg_t *sla = xmalloc(sizeof(simple_logoff_arg_t));
434
- sla->svchp = svcctx->base.hp.svc;
435
- sla->usrhp = svcctx->usrhp;
436
- sla->srvhp = svcctx->srvhp;
437
- svcctx->usrhp = NULL;
438
- svcctx->srvhp = NULL;
439
- return sla;
440
- }
441
-
442
- static void *simple_logoff_execute(void *arg)
443
- {
444
- simple_logoff_arg_t *sla = (simple_logoff_arg_t *)arg;
445
- OCIError *errhp = oci8_errhp;
446
- boolean txn = TRUE;
447
- sword rv;
448
-
449
- if (oracle_client_version >= ORAVER_12_1) {
450
- OCIAttrGet(sla->usrhp, OCI_HTYPE_SESSION, &txn, NULL, OCI_ATTR_TRANSACTION_IN_PROGRESS, errhp);
451
- }
452
- if (txn) {
453
- OCITransRollback(sla->svchp, errhp, OCI_DEFAULT);
454
- }
455
- rv = OCILogoff(sla->svchp, errhp);
456
- xfree(sla);
457
- return (void*)(VALUE)rv;
458
- }
459
-
460
- static const oci8_logoff_strategy_t simple_logoff = {
461
- simple_logoff_prepare,
462
- simple_logoff_execute,
463
- };
464
-
465
427
  /*
466
428
  * Logoff strategy for sessions connected by OCIServerAttach and OCISessionBegin.
467
429
  */
@@ -526,61 +488,6 @@ static const oci8_logoff_strategy_t complex_logoff = {
526
488
  complex_logoff_execute,
527
489
  };
528
490
 
529
- /*
530
- * @overload logon2(username, password, dbname, mode)
531
- *
532
- * Creates a simple logon session by the OCI function OCILogon2().
533
- *
534
- * @param [String] username
535
- * @param [String] password
536
- * @param [String] dbname
537
- * @param [Integer] mode
538
- * @private
539
- */
540
- static VALUE oci8_logon2(VALUE self, VALUE username, VALUE password, VALUE dbname, VALUE mode)
541
- {
542
- oci8_svcctx_t *svcctx = oci8_get_svcctx(self);
543
- ub4 logon2_mode;
544
-
545
- if (svcctx->logoff_strategy != NULL) {
546
- rb_raise(rb_eRuntimeError, "Could not reuse the session.");
547
- }
548
-
549
- /* check arugmnets */
550
- OCI8SafeStringValue(username);
551
- OCI8SafeStringValue(password);
552
- if (!NIL_P(dbname)) {
553
- OCI8SafeStringValue(dbname);
554
- }
555
- logon2_mode = NUM2UINT(mode);
556
-
557
- /* logon */
558
- svcctx->base.type = OCI_HTYPE_SVCCTX;
559
- chker2(OCILogon2_nb(svcctx, oci8_envhp, oci8_errhp, &svcctx->base.hp.svc,
560
- RSTRING_ORATEXT(username), RSTRING_LEN(username),
561
- RSTRING_ORATEXT(password), RSTRING_LEN(password),
562
- NIL_P(dbname) ? NULL : RSTRING_ORATEXT(dbname),
563
- NIL_P(dbname) ? 0 : RSTRING_LEN(dbname), logon2_mode),
564
- &svcctx->base);
565
- svcctx->logoff_strategy = &simple_logoff;
566
-
567
- if (logon2_mode & OCI_LOGON2_CPOOL) {
568
- svcctx->state |= OCI8_STATE_CPOOL;
569
- }
570
-
571
- /* setup the session handle */
572
- chker2(OCIAttrGet(svcctx->base.hp.ptr, OCI_HTYPE_SVCCTX, &svcctx->usrhp, 0, OCI_ATTR_SESSION, oci8_errhp),
573
- &svcctx->base);
574
- copy_session_handle(svcctx);
575
-
576
- /* setup the server handle */
577
- chker2(OCIAttrGet(svcctx->base.hp.ptr, OCI_HTYPE_SVCCTX, &svcctx->srvhp, 0, OCI_ATTR_SERVER, oci8_errhp),
578
- &svcctx->base);
579
- copy_server_handle(svcctx);
580
-
581
- return Qnil;
582
- }
583
-
584
491
  /*
585
492
  * @overload allocate_handles()
586
493
  *
@@ -649,7 +556,7 @@ static VALUE oci8_server_attach(VALUE self, VALUE dbname, VALUE attach_mode)
649
556
  /* attach to the server */
650
557
  chker2(OCIServerAttach_nb(svcctx, svcctx->srvhp, oci8_errhp,
651
558
  NIL_P(dbname) ? NULL : RSTRING_ORATEXT(dbname),
652
- NIL_P(dbname) ? 0 : RSTRING_LEN(dbname),
559
+ NIL_P(dbname) ? 0 : RSTRING_LENINT(dbname),
653
560
  mode),
654
561
  &svcctx->base);
655
562
  chker2(OCIAttrSet(svcctx->base.hp.ptr, OCI_HTYPE_SVCCTX,
@@ -668,13 +575,15 @@ static VALUE oci8_server_attach(VALUE self, VALUE dbname, VALUE attach_mode)
668
575
  *
669
576
  * Begins the session by the OCI function OCISessionBegin().
670
577
  *
671
- * @param [Fixnum] cred
672
- * @param [Fixnum] mode
578
+ * @param [Integer] cred
579
+ * @param [Integer] mode
673
580
  * @private
674
581
  */
675
582
  static VALUE oci8_session_begin(VALUE self, VALUE cred, VALUE mode)
676
583
  {
677
584
  oci8_svcctx_t *svcctx = oci8_get_svcctx(self);
585
+ char buf[100];
586
+ ub4 version;
678
587
 
679
588
  if (svcctx->logoff_strategy != &complex_logoff) {
680
589
  rb_raise(rb_eRuntimeError, "Use this method only for the service context handle created by OCI8#server_handle().");
@@ -697,6 +606,16 @@ static VALUE oci8_session_begin(VALUE self, VALUE cred, VALUE mode)
697
606
  oci8_errhp),
698
607
  &svcctx->base);
699
608
  svcctx->state |= OCI8_STATE_SESSION_BEGIN_WAS_CALLED;
609
+ if (have_OCIServerRelease2) {
610
+ chker2(OCIServerRelease2(svcctx->base.hp.ptr, oci8_errhp, (text*)buf,
611
+ sizeof(buf), (ub1)svcctx->base.type, &version, OCI_DEFAULT),
612
+ &svcctx->base);
613
+ } else {
614
+ chker2(OCIServerRelease(svcctx->base.hp.ptr, oci8_errhp, (text*)buf,
615
+ sizeof(buf), (ub1)svcctx->base.type, &version),
616
+ &svcctx->base);
617
+ }
618
+ svcctx->server_version = version;
700
619
  return Qnil;
701
620
  }
702
621
 
@@ -815,14 +734,9 @@ static VALUE oci8_set_autocommit(VALUE self, VALUE val)
815
734
  /*
816
735
  * @overload long_read_len
817
736
  *
818
- * Gets the maximum length in bytes to fetch a LONG or LONG RAW
819
- * column. The default value is 65535.
820
- *
821
- * If the actual data length is longer than long_read_len,
822
- * the fetched valud is truncated and the value of {OCI8#last_error}
823
- * become {OCISuccessWithInfo} whose message is "ORA-01406: fetched column value was truncated".
824
- *
825
- * Note: long_read_len is also used for maximum length of XMLTYPE data type.
737
+ * @deprecated This has no effect since ruby-oci8 2.2.7.
738
+ * LONG, LONG RAW and XMLTYPE columns are fetched up to 4 gigabytes
739
+ * without this parameter.
826
740
  *
827
741
  * @return [Integer]
828
742
  * @see #long_read_len=
@@ -830,14 +744,16 @@ static VALUE oci8_set_autocommit(VALUE self, VALUE val)
830
744
  static VALUE oci8_long_read_len(VALUE self)
831
745
  {
832
746
  oci8_svcctx_t *svcctx = oci8_get_svcctx(self);
747
+ rb_warning("OCI8.long_read_len has no effect since ruby-oci8 2.2.7");
833
748
  return svcctx->long_read_len;
834
749
  }
835
750
 
836
751
  /*
837
752
  * @overload long_read_len=(length)
838
753
  *
839
- * Sets the maximum length in bytes to fetch a LONG or LONG RAW
840
- * column.
754
+ * @deprecated This has no effect since ruby-oci8 2.2.7.
755
+ * LONG, LONG RAW and XMLTYPE columns are fetched up to 4 gigabytes
756
+ * without this parameter.
841
757
  *
842
758
  * @param [Integer] length
843
759
  * @see #long_read_len
@@ -847,6 +763,7 @@ static VALUE oci8_set_long_read_len(VALUE self, VALUE val)
847
763
  oci8_svcctx_t *svcctx = oci8_get_svcctx(self);
848
764
  Check_Type(val, T_FIXNUM);
849
765
  RB_OBJ_WRITE(self, &svcctx->long_read_len, val);
766
+ rb_warning("OCI8.long_read_len= has no effect since ruby-oci8 2.2.7");
850
767
  return val;
851
768
  }
852
769
 
@@ -889,11 +806,8 @@ static VALUE oci8_break(VALUE self)
889
806
  static VALUE oci8_oracle_server_vernum(VALUE self)
890
807
  {
891
808
  oci8_svcctx_t *svcctx = oci8_get_svcctx(self);
892
- char buf[100];
893
- ub4 version;
894
809
 
895
- chker2(OCIServerRelease(svcctx->base.hp.ptr, oci8_errhp, (text*)buf, sizeof(buf), (ub1)svcctx->base.type, &version), &svcctx->base);
896
- return UINT2NUM(version);
810
+ return UINT2NUM(svcctx->server_version);
897
811
  }
898
812
 
899
813
  /*
@@ -950,7 +864,7 @@ static VALUE oci8_set_client_identifier(VALUE self, VALUE val)
950
864
  if (!NIL_P(val)) {
951
865
  OCI8SafeStringValue(val);
952
866
  ptr = RSTRING_PTR(val);
953
- size = RSTRING_LEN(val);
867
+ size = RSTRING_LENINT(val);
954
868
  } else {
955
869
  ptr = "";
956
870
  size = 0;
@@ -985,7 +899,7 @@ static VALUE oci8_set_module(VALUE self, VALUE val)
985
899
  if (!NIL_P(val)) {
986
900
  OCI8SafeStringValue(val);
987
901
  ptr = RSTRING_PTR(val);
988
- size = RSTRING_LEN(val);
902
+ size = RSTRING_LENINT(val);
989
903
  } else {
990
904
  ptr = "";
991
905
  size = 0;
@@ -1019,7 +933,7 @@ static VALUE oci8_set_action(VALUE self, VALUE val)
1019
933
  if (!NIL_P(val)) {
1020
934
  OCI8SafeStringValue(val);
1021
935
  ptr = RSTRING_PTR(val);
1022
- size = RSTRING_LEN(val);
936
+ size = RSTRING_LENINT(val);
1023
937
  } else {
1024
938
  ptr = "";
1025
939
  size = 0;
@@ -1050,7 +964,7 @@ static VALUE oci8_set_client_info(VALUE self, VALUE val)
1050
964
  if (!NIL_P(val)) {
1051
965
  OCI8SafeStringValue(val);
1052
966
  ptr = RSTRING_PTR(val);
1053
- size = RSTRING_LEN(val);
967
+ size = RSTRING_LENINT(val);
1054
968
  } else {
1055
969
  ptr = "";
1056
970
  size = 0;
@@ -1102,7 +1016,6 @@ void Init_oci8(VALUE *out)
1102
1016
  rb_define_singleton_method_nodoc(cOCI8, "__set_prop", oci8_s_set_prop, 2);
1103
1017
  rb_define_singleton_method(cOCI8, "error_message", oci8_s_error_message, 1);
1104
1018
  rb_define_private_method(cOCI8, "parse_connect_string", oci8_parse_connect_string, 1);
1105
- rb_define_private_method(cOCI8, "logon2", oci8_logon2, 4);
1106
1019
  rb_define_private_method(cOCI8, "allocate_handles", oci8_allocate_handles, 0);
1107
1020
  rb_define_private_method(cOCI8, "server_attach", oci8_server_attach, 2);
1108
1021
  rb_define_private_method(cOCI8, "session_begin", oci8_session_begin, 2);
data/ext/oci8/oci8.h CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * oci8.h - part of ruby-oci8
4
4
  *
5
- * Copyright (C) 2002-2015 Kubo Takehiro <kubo@jiubao.org>
5
+ * Copyright (C) 2002-2016 Kubo Takehiro <kubo@jiubao.org>
6
6
  */
7
7
  #ifndef _RUBY_OCI_H_
8
8
  #define _RUBY_OCI_H_ 1
@@ -21,8 +21,23 @@ extern "C"
21
21
  }
22
22
  #endif
23
23
 
24
+ /*
25
+ * Oracle version number format in 32-bit integer.
26
+ *
27
+ * Oracle 12c or earier Oracle 18c or later
28
+ *
29
+ * hexadecimal -> dotted version number hexadecimal -> dotted version number
30
+ * 0c102304 -> 12.1.2.3.4 12012034 -> 18.1.2.3.4
31
+ * ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
32
+ * 0c ------------' | | | | 2 bytes 12 ------------' | | | | 2 bytes
33
+ * 1 --------------' | | | 1 byte 01 -------------' | | | 2 bytes
34
+ * 02 --------------' | | 2 bytes 2 --------------' | | 1 byte
35
+ * 3 ---------------' | 1 byte 03 --------------' | 2 bytes
36
+ * 04 ---------------' 2 bytes 4 ---------------' 1 byte
37
+ */
24
38
  #define ORAVERNUM(major, minor, update, patch, port_update) \
25
- (((major) << 24) | ((minor) << 20) | ((update) << 12) | ((patch) << 8) | (port_update))
39
+ (((major) >= 18) ? (((major) << 24) | ((minor) << 16) | ((update) << 12) | ((patch) << 4) | (port_update)) \
40
+ : (((major) << 24) | ((minor) << 20) | ((update) << 12) | ((patch) << 8) | (port_update)))
26
41
 
27
42
  #define ORAVER_8_0 ORAVERNUM(8, 0, 0, 0, 0)
28
43
  #define ORAVER_8_1 ORAVERNUM(8, 1, 0, 0, 0)
@@ -32,6 +47,7 @@ extern "C"
32
47
  #define ORAVER_10_2 ORAVERNUM(10, 2, 0, 0, 0)
33
48
  #define ORAVER_11_1 ORAVERNUM(11, 1, 0, 0, 0)
34
49
  #define ORAVER_12_1 ORAVERNUM(12, 1, 0, 0, 0)
50
+ #define ORAVER_18 ORAVERNUM(18, 0, 0, 0, 0)
35
51
 
36
52
  #include "extconf.h"
37
53
  #include <ruby/encoding.h>
@@ -58,38 +74,6 @@ typedef oraub8 ub8;
58
74
  typedef orasb8 sb8;
59
75
  #endif /* ORAXB8_DEFINED */
60
76
 
61
- #ifndef HAVE_TYPE_ORATEXT
62
- typedef unsigned char oratext;
63
- #endif
64
- #if !defined HAVE_TYPE_OCIDATETIME_ && !defined HAVE_TYPE_OCIDATETIMEP
65
- typedef struct OCIDateTime OCIDateTime;
66
- #endif
67
- #if !defined HAVE_TYPE_OCIINTERVAL_ && !defined HAVE_TYPE_OCIINTERVALP
68
- typedef struct OCIInterval OCIInterval;
69
- #endif
70
- #ifndef HAVE_TYPE_OCICALLBACKLOBREAD2
71
- typedef sb4 (*OCICallbackLobRead2)(dvoid *ctxp, CONST dvoid *bufp, oraub8 len,
72
- ub1 piece, dvoid **changed_bufpp,
73
- oraub8 *changed_lenp);
74
- #endif
75
- #ifndef HAVE_TYPE_OCICALLBACKLOBWRITE2
76
- typedef sb4 (*OCICallbackLobWrite2)(dvoid *ctxp, dvoid *bufp, oraub8 *lenp,
77
- ub1 *piece, dvoid **changed_bufpp,
78
- oraub8 *changed_lenp);
79
- #endif
80
- #if !defined HAVE_TYPE_OCIADMIN_ && !defined HAVE_TYPE_OCIADMINP
81
- typedef struct OCIAdmin OCIAdmin;
82
- #endif
83
- #if !defined HAVE_TYPE_OCIAUTHINFO_ && !defined HAVE_TYPE_OCIAUTHINFOP
84
- typedef struct OCIAuthInfo OCIAuthInfo;
85
- #endif
86
- #if !defined HAVE_TYPE_OCIMSG_ && !defined HAVE_TYPE_OCIMSGP
87
- typedef struct OCIMsg OCIMsg;
88
- #endif
89
- #if !defined HAVE_TYPE_OCICPOOL_ && !defined HAVE_TYPE_OCICPOOLP
90
- typedef struct OCICPool OCICPool;
91
- #endif
92
-
93
77
  #if defined RBX_CAPI_RUBY_H
94
78
  /* rubinius 2.0 */
95
79
  #ifndef HAVE_RB_ENC_STR_BUF_CAT
@@ -105,76 +89,9 @@ typedef struct OCICPool OCICPool;
105
89
  #endif
106
90
  #endif
107
91
 
108
- /*
109
- * Use TypedData on ruby 1.9.3 and later.
110
- */
111
- #ifndef HAVE_RB_DATA_TYPE_T_FUNCTION
112
-
113
- /*
114
- * Don't use TypedData even though ruby 1.9.2 has it because the
115
- * definitions are slightly different from ruby 1.9.3 and later.
116
- */
117
- #define rb_data_type_t oci8_data_type_t
118
- #undef TypedData_Make_Struct
119
- #undef TypedData_Wrap_Struct
120
- #undef TypedData_Get_Struct
121
- #undef RTYPEDDATA_DATA
122
- #undef RUBY_DEFAULT_FREE
123
-
124
- /*
125
- * To pass compilation on ruby 1.9.2 and earlier.
126
- */
127
- typedef struct oci8_data_type_struct rb_data_type_t;
128
- struct oci8_data_type_struct {
129
- const char *wrap_struct_name;
130
- struct {
131
- void (*dmark)(void*);
132
- void (*dfree)(void*);
133
- size_t (*dsize)(const void *);
134
- } function;
135
- const rb_data_type_t *parent;
136
- void *data;
137
- };
138
- #define TypedData_Make_Struct(klass, type, data_type, sval) \
139
- Data_Make_Struct((klass), type, (data_type)->function.dmark, (data_type)->function.dfree, (sval))
140
- #define TypedData_Wrap_Struct(klass, data_type, sval) \
141
- Data_Wrap_Struct((klass), (data_type)->function.dmark, (data_type)->function.dfree, (sval))
142
- #define TypedData_Get_Struct(obj, type, data_type, sval) \
143
- Data_Get_Struct((obj), type, (sval))
144
- #define RTYPEDDATA_DATA(obj) DATA_PTR(obj)
145
- #define RUBY_DEFAULT_FREE xfree
146
- #endif
147
-
148
- /* a new function in ruby 1.9.3.
149
- * define a compatible macro for ruby 1.9.2 or lower.
150
- */
151
- #ifndef HAVE_RB_CLASS_SUPERCLASS
152
- #ifdef RCLASS_SUPER
153
- #define rb_class_superclass(cls) RCLASS_SUPER(cls)
154
- #else
155
- #define rb_class_superclass(cls) (RCLASS(cls)->super)
156
- #endif
157
- #endif
158
-
159
- /* new macros in ruby 2.1.0
160
- */
161
- #ifndef RARRAY_AREF
162
- #define RARRAY_AREF(a, i) (RARRAY_PTR(a)[i])
163
- #endif
164
- #ifndef RARRAY_CONST_PTR
165
- #define RARRAY_CONST_PTR(a) RARRAY_PTR(a)
166
- #endif
167
- #ifndef RB_OBJ_WRITE
168
- #define RB_OBJ_WRITE(a, slot, b) do {*(slot) = (b);} while (0)
169
- #endif
170
- #ifndef RB_OBJ_WRITTEN
171
- #define RB_OBJ_WRITTEN(a, oldv, b) do {(void)oldv;} while (0)
172
- #endif
173
-
174
92
  /* macros depends on the compiler.
175
93
  * LIKELY(x) hint for the compiler that 'x' is 1(TRUE) in many cases.
176
94
  * UNLIKELY(x) hint for the compiler that 'x' is 0(FALSE) in many cases.
177
- * ALWAYS_INLINE forcely inline the function.
178
95
  */
179
96
  #if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
180
97
  /* gcc version >= 2.96 */
@@ -185,14 +102,6 @@ struct oci8_data_type_struct {
185
102
  #define LIKELY(x) (x)
186
103
  #define UNLIKELY(x) (x)
187
104
  #endif
188
- #if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
189
- /* gcc version >= 3.1 */
190
- #define ALWAYS_INLINE inline __attribute__((always_inline))
191
- #endif
192
- #ifdef _MSC_VER
193
- /* microsoft c */
194
- #define ALWAYS_INLINE __forceinline
195
- #endif
196
105
 
197
106
  /* macros to access thread-local storage.
198
107
  *
@@ -218,27 +127,24 @@ struct oci8_data_type_struct {
218
127
  /* utility macros
219
128
  */
220
129
  #define IS_OCI_ERROR(v) (((v) != OCI_SUCCESS) && ((v) != OCI_SUCCESS_WITH_INFO))
221
- #ifdef ALWAYS_INLINE
222
130
  #define TO_ORATEXT to_oratext
223
131
  #define TO_CONST_ORATEXT to_const_oratext
224
132
  #define TO_CHARPTR to_charptr
225
- static ALWAYS_INLINE OraText *to_oratext(char *c)
133
+ ALWAYS_INLINE(static OraText *to_oratext(char *c));
134
+ static inline OraText *to_oratext(char *c)
226
135
  {
227
136
  return (OraText*)c;
228
137
  }
229
- static ALWAYS_INLINE const OraText *to_const_oratext(const char *c)
138
+ ALWAYS_INLINE(static const OraText *to_const_oratext(const char *c));
139
+ static inline const OraText *to_const_oratext(const char *c)
230
140
  {
231
141
  return (const OraText*)c;
232
142
  }
233
- static ALWAYS_INLINE char *to_charptr(OraText *c)
143
+ ALWAYS_INLINE(static char *to_charptr(OraText *c));
144
+ static inline char *to_charptr(OraText *c)
234
145
  {
235
146
  return (char*)c;
236
147
  }
237
- #else
238
- #define TO_ORATEXT(c) ((OraText*)(c))
239
- #define TO_CONST_ORATEXT(c) ((const OraText*)(c))
240
- #define TO_CHARPTR(c) ((char*)(c))
241
- #endif
242
148
  #define RSTRING_ORATEXT(obj) TO_ORATEXT(RSTRING_PTR(obj))
243
149
  #define rb_str_new2_ora(str) rb_str_new2(TO_CHARPTR(str))
244
150
 
@@ -344,6 +250,7 @@ typedef struct oci8_svcctx {
344
250
  const oci8_logoff_strategy_t *logoff_strategy;
345
251
  OCISession *usrhp;
346
252
  OCIServer *srvhp;
253
+ ub4 server_version;
347
254
  rb_pid_t pid;
348
255
  unsigned char state;
349
256
  char is_autocommit;
@@ -368,7 +275,8 @@ typedef struct {
368
275
  } oci8_exec_sql_var_t;
369
276
 
370
277
  #define oci8_raise(err, status, stmt) oci8_do_raise(err, status, stmt, __FILE__, __LINE__)
371
- #define oci8_env_raise(err, status) oci8_do_env_raise(err, status, __FILE__, __LINE__)
278
+ #define oci8_env_raise(env, status) oci8_do_env_raise(env, status, 0, __FILE__, __LINE__)
279
+ #define oci8_env_free_and_raise(env, status) oci8_do_env_raise(env, status, 1, __FILE__, __LINE__)
372
280
  #define oci8_raise_init_error() oci8_do_raise_init_error(__FILE__, __LINE__)
373
281
  #define oci8_raise_by_msgno(msgno, default_msg) oci8_do_raise_by_msgno(msgno, default_msg, __FILE__, __LINE__)
374
282
 
@@ -392,7 +300,7 @@ OCIEnv *oci8_make_envhp(void);
392
300
  extern oci8_tls_key_t oci8_tls_key; /* native thread key */
393
301
  OCIError *oci8_make_errhp(void);
394
302
 
395
- static inline OCIError *oci8_get_errhp()
303
+ static inline OCIError *oci8_get_errhp(void)
396
304
  {
397
305
  OCIError *errhp = (OCIError *)oci8_tls_get(oci8_tls_key);
398
306
  return LIKELY(errhp != NULL) ? errhp : oci8_make_errhp();
@@ -434,7 +342,8 @@ void *oci8_check_typeddata(VALUE obj, const oci8_handle_data_type_t *data_type,
434
342
  extern VALUE eOCIException;
435
343
  extern VALUE eOCIBreak;
436
344
  void Init_oci8_error(void);
437
- NORETURN(void oci8_do_env_raise(OCIEnv *, sword status, const char *file, int line));
345
+ NORETURN(void oci8_do_raise(OCIError *errhp, sword status, OCIStmt *stmthp, const char *file, int line));
346
+ NORETURN(void oci8_do_env_raise(OCIEnv *envhp, sword status, int free_envhp, const char *file, int line));
438
347
  NORETURN(void oci8_do_raise_init_error(const char *file, int line));
439
348
  sb4 oci8_get_error_code(OCIError *errhp);
440
349
  VALUE oci8_get_error_message(ub4 msgno, const char *default_msg);
@@ -474,6 +383,7 @@ void Init_oci8_bind(VALUE cOCI8BindTypeBase);
474
383
 
475
384
  /* metadata.c */
476
385
  extern const oci8_handle_data_type_t oci8_metadata_base_data_type;
386
+ VALUE oci8_do_describe(VALUE self, void *objptr, ub4 objlen, ub1 objtype, VALUE klass, VALUE check_public);
477
387
  void Init_oci8_metadata(VALUE cOCI8);
478
388
  VALUE oci8_metadata_create(OCIParam *parmhp, VALUE svc, VALUE parent);
479
389
 
@@ -515,8 +425,8 @@ OCINumber *oci8_dbl_to_onum(OCINumber *result, double dbl, OCIError *errhp);
515
425
  void Init_oci_datetime(void);
516
426
  VALUE oci8_make_ocidate(OCIDate *od);
517
427
  OCIDate *oci8_set_ocidate(OCIDate *od, VALUE val);
518
- VALUE oci8_make_ocidatetime(OCIDateTime *dttm);
519
- OCIDateTime *oci8_set_ocidatetime(OCIDateTime *dttm, VALUE val);
428
+ VALUE oci8_make_ocitimestamp(OCIDateTime *dttm, boolean have_tz);
429
+ OCIDateTime *oci8_set_ocitimestamp_tz(OCIDateTime *dttm, VALUE val, VALUE svc);
520
430
  VALUE oci8_make_interval_ym(OCIInterval *s);
521
431
  VALUE oci8_make_interval_ds(OCIInterval *s);
522
432
 
@@ -541,6 +451,13 @@ void Init_oci8_win32(VALUE cOCI8);
541
451
  /* hook_funcs.c */
542
452
  void oci8_install_hook_functions(void);
543
453
  void oci8_shutdown_sockets(void);
454
+ #ifdef HAVE_PLTHOOK
455
+ extern int oci8_cancel_read_at_exit;
456
+ extern int oci8_tcp_keepalive_time;
457
+ #else
458
+ #define oci8_cancel_read_at_exit (-1)
459
+ #define oci8_tcp_keepalive_time (-1)
460
+ #endif
544
461
 
545
462
  #define OCI8StringValue(v) do { \
546
463
  StringValue(v); \