ruby-oci8 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -206,7 +206,7 @@ static VALUE oci8_bind_get(VALUE self)
206
206
  return vptr->get(obind, (void*)((size_t)obind->valuep + obind->alloc_sz * idx), null_structp);
207
207
  }
208
208
 
209
- VALUE oci8_bind_get_data(VALUE self)
209
+ static VALUE oci8_bind_get_data(VALUE self)
210
210
  {
211
211
  oci8_bind_t *obind = DATA_PTR(self);
212
212
 
@@ -252,7 +252,7 @@ static VALUE oci8_bind_set(VALUE self, VALUE val)
252
252
  return self;
253
253
  }
254
254
 
255
- void oci8_bind_set_data(VALUE self, VALUE val)
255
+ static VALUE oci8_bind_set_data(VALUE self, VALUE val)
256
256
  {
257
257
  oci8_bind_t *obind = DATA_PTR(self);
258
258
 
@@ -274,6 +274,7 @@ void oci8_bind_set_data(VALUE self, VALUE val)
274
274
  }
275
275
  obind->curar_sz = size;
276
276
  }
277
+ return self;
277
278
  }
278
279
 
279
280
  static VALUE oci8_bind_initialize(VALUE self, VALUE svc, VALUE val, VALUE length, VALUE max_array_size)
@@ -349,6 +350,8 @@ void Init_oci8_bind(VALUE klass)
349
350
  rb_define_method(cOCI8BindTypeBase, "initialize", oci8_bind_initialize, 4);
350
351
  rb_define_method(cOCI8BindTypeBase, "get", oci8_bind_get, 0);
351
352
  rb_define_method(cOCI8BindTypeBase, "set", oci8_bind_set, 1);
353
+ rb_define_private_method(cOCI8BindTypeBase, "get_data", oci8_bind_get_data, 0);
354
+ rb_define_private_method(cOCI8BindTypeBase, "set_data", oci8_bind_set_data, 1);
352
355
 
353
356
  /* register primitive data types. */
354
357
  oci8_define_bind_class("String", &bind_string_vtable);
@@ -21,11 +21,11 @@ static void oci8_cpool_mark(oci8_base_t *base)
21
21
  rb_gc_mark(cpool->pool_name);
22
22
  }
23
23
 
24
- static VALUE cpool_free_thread(void *arg)
24
+ static void *cpool_free_thread(void *arg)
25
25
  {
26
26
  OCIConnectionPoolDestroy((OCICPool *)arg, oci8_errhp, OCI_DEFAULT);
27
27
  OCIHandleFree(arg, OCI_HTYPE_CPOOL);
28
- return 0;
28
+ return NULL;
29
29
  }
30
30
 
31
31
  static void oci8_cpool_free(oci8_base_t *base)
@@ -30,8 +30,6 @@ rb_encoding *oci8_encoding;
30
30
  * call-seq:
31
31
  * charset_id2name(charset_id) -> charset_name
32
32
  *
33
- * <b>(new in 2.0.0)</b>
34
- *
35
33
  * Returns the Oracle character set name from the specified
36
34
  * character set ID if it is valid. Otherwise, +nil+ is returned.
37
35
  *
@@ -48,6 +46,9 @@ rb_encoding *oci8_encoding;
48
46
  * :name := nls_charset_name(:csid);
49
47
  * END;
50
48
  *
49
+ * @param [Fixnum] charset_id Oracle character set id
50
+ * @return [String] Oracle character set name or nil
51
+ * @since 2.0.0
51
52
  */
52
53
  VALUE oci8_charset_id2name(VALUE svc, VALUE csid)
53
54
  {
@@ -104,8 +105,6 @@ VALUE oci8_charset_id2name(VALUE svc, VALUE csid)
104
105
  * call-seq:
105
106
  * charset_name2id(charset_name) -> charset_id
106
107
  *
107
- * <b>(new in 2.0.0)</b>
108
- *
109
108
  * Returns the Oracle character set ID for the specified Oracle
110
109
  * character set name if it is valid. Othewise, +nil+ is returned.
111
110
  *
@@ -122,6 +121,9 @@ VALUE oci8_charset_id2name(VALUE svc, VALUE csid)
122
121
  * :csid := nls_charset_id(:name);
123
122
  * END;
124
123
  *
124
+ * @param [String] charset_name Oracle character set name
125
+ * @return [Fixnum] Oracle character set id or nil
126
+ * @since 2.0.0
125
127
  */
126
128
  static VALUE oci8_charset_name2id(VALUE svc, VALUE name)
127
129
  {
@@ -176,12 +178,13 @@ static VALUE oci8_charset_name2id(VALUE svc, VALUE name)
176
178
  * call-seq:
177
179
  * OCI8.nls_ratio -> integer
178
180
  *
179
- * <b>(new in 2.1.0)</b>
180
- *
181
181
  * Gets NLS ratio, maximum number of bytes per one character of the
182
182
  * current NLS chracter set. It is a factor to calculate the
183
183
  * internal buffer size of a string bind variable whose nls length
184
184
  * semantics is char.
185
+ *
186
+ * @return [Fixnum] NLS ratio
187
+ * @since 2.1.0
185
188
  */
186
189
  static VALUE oci8_get_nls_ratio(VALUE klass)
187
190
  {
@@ -192,11 +195,12 @@ static VALUE oci8_get_nls_ratio(VALUE klass)
192
195
  * call-seq:
193
196
  * OCI8.nls_ratio = integer
194
197
  *
195
- * <b>(new in 2.1.0)</b>
196
- *
197
198
  * Sets NLS ratio, maximum number of bytes per one character of the
198
199
  * current NLS chracter set. It is initialized in 'oci8/encoding-init.rb'
199
200
  * when oci8 is required. You have no need to set it explicitly.
201
+ *
202
+ * @param [Fixnum] integer NLS ratio
203
+ * @since 2.1.0
200
204
  */
201
205
  static VALUE oci8_set_nls_ratio(VALUE klass, VALUE val)
202
206
  {
@@ -214,8 +218,6 @@ static VALUE oci8_set_nls_ratio(VALUE klass, VALUE val)
214
218
  * call-seq:
215
219
  * OCI8.encoding -> enc
216
220
  *
217
- * <b>(new in 2.0.0 and ruby 1.9)</b>
218
- *
219
221
  * Returns the Oracle client encoding.
220
222
  *
221
223
  * When string data, such as SQL statements and bind variables,
@@ -238,6 +240,9 @@ static VALUE oci8_set_nls_ratio(VALUE klass, VALUE val)
238
240
  *
239
241
  * If +OCI8.encoding+ is ASCII-8BIT, no encoding conversions
240
242
  * are done.
243
+ *
244
+ * @return [Encoding]
245
+ * @since 2.0.0 and ruby 1.9
241
246
  */
242
247
  static VALUE oci8_get_encoding(VALUE klass)
243
248
  {
@@ -248,11 +253,12 @@ static VALUE oci8_get_encoding(VALUE klass)
248
253
  * call-seq:
249
254
  * OCI8.encoding = enc or nil
250
255
  *
251
- * <b>(new in 2.0.0 and ruby 1.9)</b>
252
- *
253
256
  * Sets Oracle client encoding. You must not use this method.
254
257
  * You should set the environment variable NLS_LANG properly to
255
258
  * change +OCI8.encoding+.
259
+ *
260
+ * @param [Encoding] enc
261
+ * @since 2.0.0 and ruby 1.9
256
262
  */
257
263
  static VALUE oci8_set_encoding(VALUE klass, VALUE encoding)
258
264
  {
@@ -110,7 +110,7 @@ void Init_oci8_env(void)
110
110
  int error;
111
111
  #endif
112
112
 
113
- #if !defined(HAVE_RB_THREAD_BLOCKING_REGION) && !defined(_WIN32)
113
+ #if !defined(NATIVE_THREAD_WITH_GVL) && !defined(_WIN32)
114
114
  /* workaround code.
115
115
  *
116
116
  * Some instant clients set the environment variables
@@ -107,18 +107,20 @@ have_func("localtime_r")
107
107
  # ruby 1.8 headers
108
108
  have_header("intern.h")
109
109
  have_header("util.h")
110
- # ruby 1.9 headers
110
+ # ruby 1.9.1 headers
111
111
  have_header("ruby/util.h")
112
112
  have_type('rb_encoding', ['ruby/ruby.h', 'ruby/encoding.h'])
113
+ # ruby 2.0.0 headers
114
+ have_header("ruby/thread.h")
113
115
 
114
116
  # $! in C API
115
117
  have_var("ruby_errinfo", "ruby.h") # ruby 1.8
116
118
  have_func("rb_errinfo", "ruby.h") # ruby 1.9
117
119
 
118
- have_type("rb_blocking_function_t*", "ruby.h")
119
120
  have_func("rb_set_end_proc", "ruby.h")
120
121
  have_func("rb_class_superclass", "ruby.h")
121
122
  have_func("rb_thread_blocking_region", "ruby.h")
123
+ have_func("rb_thread_call_without_gvl", "ruby/thread.h")
122
124
 
123
125
  # replace files
124
126
  replace = {
@@ -129,22 +131,23 @@ replace = {
129
131
  # make ruby script before running create_makefile.
130
132
  replace_keyword(File.dirname(__FILE__) + '/../../lib/oci8.rb.in', '../../lib/oci8.rb', replace)
131
133
 
134
+ ruby_engine = (defined? RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
135
+
132
136
  so_basename = 'oci8lib_'
133
- if defined? RUBY_ENGINE and RUBY_ENGINE != 'ruby'
134
- so_basename += RUBY_ENGINE
137
+ if ruby_engine == 'ruby'
138
+ # Config::CONFIG["ruby_version"] indicates the ruby API version.
139
+ # 1.8 - ruby 1.8.x
140
+ # 1.9.1 - ruby 1.9.1, 1.9.2
141
+ # 2.0.0 - ruby 2.0.0
142
+ so_basename += RbConfig::CONFIG["ruby_version"].gsub(/\W/, '')
143
+ else
144
+ so_basename += ruby_engine
135
145
  end
136
146
 
137
- # Config::CONFIG["ruby_version"] indicates the ruby API version.
138
- # 1.8 - ruby 1.8.x
139
- # 1.9.1 - ruby 1.9.1, 1.9.2 and 2.0.0-dev at the present time.
140
- so_basename += RbConfig::CONFIG["ruby_version"].gsub(/\W/, '')
141
-
142
147
  $defs << "-DInit_oci8lib=Init_#{so_basename}"
143
148
  $defs << "-Doci8lib=#{so_basename}"
144
149
  $defs << "-DOCI8LIB_VERSION=\\\"#{RUBY_OCI8_VERSION}\\\""
145
- if defined? RUBY_ENGINE and RUBY_ENGINE == 'rbx'
146
- $defs << "-DCHAR_IS_NOT_A_SHORTCUT_TO_ID"
147
- end
150
+ $defs << "-DCHAR_IS_NOT_A_SHORTCUT_TO_ID" if ruby_engine != 'ruby'
148
151
 
149
152
  create_header()
150
153
 
@@ -36,13 +36,19 @@ static VALUE oci8_lob_write(VALUE self, VALUE data);
36
36
  static VALUE oci8_make_lob(VALUE klass, oci8_svcctx_t *svcctx, OCILobLocator *s)
37
37
  {
38
38
  oci8_lob_t *lob;
39
+ boolean is_temp;
39
40
  VALUE lob_obj;
40
41
 
41
42
  lob_obj = rb_funcall(klass, oci8_id_new, 1, svcctx->base.self);
42
43
  lob = DATA_PTR(lob_obj);
43
44
  /* If 's' is a temporary lob, use OCILobLocatorAssign instead. */
44
- chker2(OCILobAssign(oci8_envhp, oci8_errhp, s, &lob->base.hp.lob),
45
- &svcctx->base);
45
+ chker2(OCILobIsTemporary(oci8_envhp, oci8_errhp, s, &is_temp), &svcctx->base);
46
+ if (is_temp)
47
+ chker2(OCILobLocatorAssign_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, s, &lob->base.hp.lob),
48
+ &svcctx->base);
49
+ else
50
+ chker2(OCILobAssign(oci8_envhp, oci8_errhp, s, &lob->base.hp.lob),
51
+ &svcctx->base);
46
52
  return lob_obj;
47
53
  }
48
54
 
@@ -107,8 +113,19 @@ static void oci8_lob_free(oci8_base_t *base)
107
113
  && OCILobIsTemporary(oci8_envhp, oci8_errhp, lob->base.hp.lob, &is_temporary) == OCI_SUCCESS
108
114
  && is_temporary) {
109
115
 
116
+ #ifdef HAVE_RB_THREAD_BLOCKING_REGION
117
+ oci8_svcctx_t *svcctx = oci8_get_svcctx(lob->svc);
118
+ oci8_temp_lob_t *temp_lob = ALLOC(oci8_temp_lob_t);
119
+
120
+ temp_lob->next = svcctx->temp_lobs;
121
+ temp_lob->lob = lob->base.hp.lob;
122
+ svcctx->temp_lobs = temp_lob;
123
+ lob->base.type = 0;
124
+ lob->base.hp.ptr = NULL;
125
+ #else
110
126
  /* FIXME: This may stall the GC. */
111
127
  OCILobFreeTemporary(lob->svchp, oci8_errhp, lob->base.hp.lob);
128
+ #endif
112
129
  }
113
130
  lob->svc = Qnil;
114
131
  lob->svchp = NULL;
@@ -41,6 +41,26 @@ static VALUE cServer;
41
41
  static ID id_at_session_handle;
42
42
  static ID id_at_server_handle;
43
43
 
44
+ static VALUE dummy_env_method_missing(int argc, VALUE *argv, VALUE self)
45
+ {
46
+ VALUE obj = rb_cv_get(cOCI8, "@@environment_handle");
47
+ VALUE method_id, args;
48
+
49
+ if (self == obj) {
50
+ oci8_base_t *base;
51
+ obj = rb_obj_alloc(oci8_cOCIHandle);
52
+ base = DATA_PTR(obj);
53
+ base->type = OCI_HTYPE_ENV;
54
+ base->hp.ptr = oci8_envhp;
55
+ base->self = Qnil;
56
+ rb_cv_set(cOCI8, "@@environment_handle", obj);
57
+ }
58
+
59
+ rb_scan_args(argc, argv, "1*", &method_id, &args);
60
+ Check_Type(method_id, T_SYMBOL);
61
+ return rb_apply(obj, SYM2ID(method_id), args);
62
+ }
63
+
44
64
  typedef struct oci8_svcctx_associate {
45
65
  oci8_base_t base;
46
66
  oci8_svcctx_t *svcctx;
@@ -81,6 +101,18 @@ static void copy_server_handle(oci8_svcctx_t *svcctx)
81
101
  static void oci8_svcctx_free(oci8_base_t *base)
82
102
  {
83
103
  oci8_svcctx_t *svcctx = (oci8_svcctx_t *)base;
104
+ oci8_temp_lob_t *lob;
105
+
106
+ lob = svcctx->temp_lobs;
107
+ while (lob != NULL) {
108
+ oci8_temp_lob_t *lob_next = lob->next;
109
+
110
+ OCIDescriptorFree(lob->lob, OCI_DTYPE_LOB);
111
+ xfree(lob);
112
+ lob = lob_next;
113
+ }
114
+ svcctx->temp_lobs = NULL;
115
+
84
116
  if (svcctx->logoff_strategy != NULL) {
85
117
  const oci8_logoff_strategy_t *strategy = svcctx->logoff_strategy;
86
118
  void *data = strategy->prepare(svcctx);
@@ -117,7 +149,7 @@ static void oci8_svcctx_init(oci8_base_t *base)
117
149
 
118
150
  svcctx->pid = getpid();
119
151
  svcctx->is_autocommit = 0;
120
- #ifdef HAVE_RB_THREAD_BLOCKING_REGION
152
+ #ifdef NATIVE_THREAD_WITH_GVL
121
153
  svcctx->non_blocking = 1;
122
154
  #endif
123
155
  svcctx->long_read_len = INT2FIX(65535);
@@ -176,6 +208,8 @@ static VALUE oci8_s_set_property(VALUE klass, VALUE name, VALUE val)
176
208
  * # When NLS_LANG is FRENCH_FRANCE.AL32UTF8
177
209
  * OCI8.error_message(1) # => "ORA-00001: violation de contrainte unique (%s.%s)"
178
210
  *
211
+ * @param [Fixnum] message_no Oracle error message number
212
+ * @return [String] Oracle error message
179
213
  */
180
214
  static VALUE oci8_s_error_message(VALUE klass, VALUE msgid)
181
215
  {
@@ -252,7 +286,7 @@ static void *simple_logoff_prepare(oci8_svcctx_t *svcctx)
252
286
  return sla;
253
287
  }
254
288
 
255
- static VALUE simple_logoff_execute(void *arg)
289
+ static void *simple_logoff_execute(void *arg)
256
290
  {
257
291
  simple_logoff_arg_t *sla = (simple_logoff_arg_t *)arg;
258
292
  OCIError *errhp = oci8_errhp;
@@ -261,7 +295,7 @@ static VALUE simple_logoff_execute(void *arg)
261
295
  OCITransRollback(sla->svchp, errhp, OCI_DEFAULT);
262
296
  rv = OCILogoff(sla->svchp, errhp);
263
297
  xfree(sla);
264
- return (VALUE)rv;
298
+ return (void*)(VALUE)rv;
265
299
  }
266
300
 
267
301
  static const oci8_logoff_strategy_t simple_logoff = {
@@ -293,7 +327,7 @@ static void *complex_logoff_prepare(oci8_svcctx_t *svcctx)
293
327
  return cla;
294
328
  }
295
329
 
296
- static VALUE complex_logoff_execute(void *arg)
330
+ static void *complex_logoff_execute(void *arg)
297
331
  {
298
332
  complex_logoff_arg_t *cla = (complex_logoff_arg_t *)arg;
299
333
  OCIError *errhp = oci8_errhp;
@@ -319,7 +353,7 @@ static VALUE complex_logoff_execute(void *arg)
319
353
  OCIHandleFree(cla->svchp, OCI_HTYPE_SVCCTX);
320
354
  }
321
355
  xfree(cla);
322
- return (VALUE)rv;
356
+ return (void*)(VALUE)rv;
323
357
  }
324
358
 
325
359
  static const oci8_logoff_strategy_t complex_logoff = {
@@ -419,32 +453,6 @@ static VALUE oci8_allocate_handles(VALUE self)
419
453
  return self;
420
454
  }
421
455
 
422
- /*
423
- * call-seq:
424
- * session_handle -> a session handle
425
- *
426
- * <b>internal use only</b>
427
- *
428
- * Returns a session handle associated with the service context handle.
429
- */
430
- static VALUE oci8_get_session_handle(VALUE self)
431
- {
432
- return rb_ivar_get(self, id_at_session_handle);
433
- }
434
-
435
- /*
436
- * call-seq:
437
- * server_handle -> a server handle
438
- *
439
- * <b>internal use only</b>
440
- *
441
- * Returns a server handle associated with the service context handle.
442
- */
443
- static VALUE oci8_get_server_handle(VALUE self)
444
- {
445
- return rb_ivar_get(self, id_at_server_handle);
446
- }
447
-
448
456
  /*
449
457
  * call-seq:
450
458
  * server_attach(dbname, mode)
@@ -542,7 +550,7 @@ static VALUE oci8_svcctx_logoff(VALUE self)
542
550
  void *data = strategy->prepare(svcctx);
543
551
  svcctx->base.type = 0;
544
552
  svcctx->logoff_strategy = NULL;
545
- chker2(oci8_blocking_region(svcctx, strategy->execute, data), &svcctx->base);
553
+ chker2(oci8_call_without_gvl(svcctx, strategy->execute, data), &svcctx->base);
546
554
  }
547
555
  return Qtrue;
548
556
  }
@@ -585,7 +593,7 @@ static VALUE oci8_rollback(VALUE self)
585
593
  static VALUE oci8_non_blocking_p(VALUE self)
586
594
  {
587
595
  oci8_svcctx_t *svcctx = DATA_PTR(self);
588
- #ifdef HAVE_RB_THREAD_BLOCKING_REGION
596
+ #ifdef NATIVE_THREAD_WITH_GVL
589
597
  return svcctx->non_blocking ? Qtrue : Qfalse;
590
598
  #else
591
599
  sb1 non_blocking;
@@ -635,7 +643,7 @@ static VALUE oci8_non_blocking_p(VALUE self)
635
643
  static VALUE oci8_set_non_blocking(VALUE self, VALUE val)
636
644
  {
637
645
  oci8_svcctx_t *svcctx = DATA_PTR(self);
638
- #ifdef HAVE_RB_THREAD_BLOCKING_REGION
646
+ #ifdef NATIVE_THREAD_WITH_GVL
639
647
  svcctx->non_blocking = RTEST(val);
640
648
  #else
641
649
  sb1 non_blocking;
@@ -729,7 +737,7 @@ static VALUE oci8_break(VALUE self)
729
737
  if (NIL_P(svcctx->executing_thread)) {
730
738
  return Qfalse;
731
739
  }
732
- #ifndef HAVE_RB_THREAD_BLOCKING_REGION
740
+ #ifndef NATIVE_THREAD_WITH_GVL
733
741
  chker2(OCIBreak(svcctx->base.hp.ptr, oci8_errhp), &svcctx->base);
734
742
  #endif
735
743
  rb_thread_wakeup(svcctx->executing_thread);
@@ -757,11 +765,11 @@ static VALUE oci8_set_prefetch_rows(VALUE self, VALUE val)
757
765
  * call-seq:
758
766
  * oracle_server_vernum -> an integer
759
767
  *
760
- * <b>(new in 2.0.1)</b>
761
- *
762
768
  * Returns a numerical format of the Oracle server version.
763
769
  *
764
770
  * See also: #oracle_server_version
771
+ *
772
+ * @since 2.0.1
765
773
  */
766
774
  static VALUE oci8_oracle_server_vernum(VALUE self)
767
775
  {
@@ -777,8 +785,6 @@ static VALUE oci8_oracle_server_vernum(VALUE self)
777
785
  * call-seq:
778
786
  * ping -> true or false
779
787
  *
780
- * <b>(new in 2.0.2)</b>
781
- *
782
788
  * Makes a round trip call to the server to confirm that the connection and
783
789
  * the server are active.
784
790
  *
@@ -791,6 +797,8 @@ static VALUE oci8_oracle_server_vernum(VALUE self)
791
797
  *
792
798
  * === Oracle 10.1 client or lower
793
799
  * A simple PL/SQL block "BEGIN NULL; END;" is executed to make a round trip call.
800
+ *
801
+ * @since 2.0.2
794
802
  */
795
803
  static VALUE oci8_ping(VALUE self)
796
804
  {
@@ -811,8 +819,6 @@ static VALUE oci8_ping(VALUE self)
811
819
  * call-seq:
812
820
  * client_identifier = string or nil
813
821
  *
814
- * <b>(new in 2.0.3)</b>
815
- *
816
822
  * Sets the client ID. This information is stored in the V$SESSION
817
823
  * view.
818
824
  *
@@ -833,6 +839,7 @@ static VALUE oci8_ping(VALUE self)
833
839
  *
834
840
  * See {Oracle Manual: Oracle Database PL/SQL Packages and Types Reference}[http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sessio.htm#i996935]
835
841
  *
842
+ * @since 2.0.3
836
843
  */
837
844
  static VALUE oci8_set_client_identifier(VALUE self, VALUE val)
838
845
  {
@@ -878,8 +885,6 @@ static VALUE oci8_set_client_identifier(VALUE self, VALUE val)
878
885
  * call-seq:
879
886
  * module = string or nil
880
887
  *
881
- * <b>(new in 2.0.3)</b>
882
- *
883
888
  * Sets the name of the current module. This information is
884
889
  * stored in the V$SESSION view and is also stored in the V$SQL view
885
890
  * and the V$SQLAREA view when a SQL statement is executed and the SQL
@@ -907,6 +912,7 @@ static VALUE oci8_set_client_identifier(VALUE self, VALUE val)
907
912
  *
908
913
  * See {Oracle Manual: Oracle Database PL/SQL Packages and Types Reference}[http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_appinf.htm#i999254]
909
914
  *
915
+ * @since 2.0.3
910
916
  */
911
917
  static VALUE oci8_set_module(VALUE self, VALUE val)
912
918
  {
@@ -952,8 +958,6 @@ static VALUE oci8_set_module(VALUE self, VALUE val)
952
958
  * call-seq:
953
959
  * action = string or nil
954
960
  *
955
- * <b>(new in 2.0.3)</b>
956
- *
957
961
  * Sets the name of the current action within the current module.
958
962
  * This information is stored in the V$SESSION view and is also
959
963
  * stored in the V$SQL view and the V$SQLAREA view when a SQL
@@ -977,6 +981,7 @@ static VALUE oci8_set_module(VALUE self, VALUE val)
977
981
  *
978
982
  * See {Oracle Manual: Oracle Database PL/SQL Packages and Types Reference}[http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_appinf.htm#i999254]
979
983
  *
984
+ * @since 2.0.3
980
985
  */
981
986
  static VALUE oci8_set_action(VALUE self, VALUE val)
982
987
  {
@@ -1019,8 +1024,6 @@ static VALUE oci8_set_action(VALUE self, VALUE val)
1019
1024
  * call-seq:
1020
1025
  * client_info = string or nil
1021
1026
  *
1022
- * <b>(new in 2.0.3)</b>
1023
- *
1024
1027
  * Sets additional information about the client application.
1025
1028
  * This information is stored in the V$SESSION view.
1026
1029
  *
@@ -1040,6 +1043,8 @@ static VALUE oci8_set_action(VALUE self, VALUE val)
1040
1043
  * END;
1041
1044
  *
1042
1045
  * See {Oracle Manual: Oracle Database PL/SQL Packages and Types Reference}[http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_appinf.htm#CHEJCFGG]
1046
+ *
1047
+ * @since 2.0.3
1043
1048
  */
1044
1049
  static VALUE oci8_set_client_info(VALUE self, VALUE val)
1045
1050
  {
@@ -1078,9 +1083,11 @@ static VALUE oci8_set_client_info(VALUE self, VALUE val)
1078
1083
  return val;
1079
1084
  }
1080
1085
 
1081
- VALUE Init_oci8(void)
1086
+ void Init_oci8(VALUE *out)
1082
1087
  {
1083
- #if 0
1088
+ VALUE obj;
1089
+ oci8_base_t *base;
1090
+ #if /* for yard */ 0
1084
1091
  oci8_cOCIHandle = rb_define_class("OCIHandle", rb_cObject);
1085
1092
  cOCI8 = rb_define_class("OCI8", oci8_cOCIHandle);
1086
1093
  #endif
@@ -1090,6 +1097,18 @@ VALUE Init_oci8(void)
1090
1097
  id_at_session_handle = rb_intern("@session_handle");
1091
1098
  id_at_server_handle = rb_intern("@server_handle");
1092
1099
 
1100
+ /* setup a dummy environment handle to lazily initialize the environment handle */
1101
+ obj = rb_obj_alloc(rb_cObject);
1102
+ rb_define_singleton_method(obj, "method_missing", dummy_env_method_missing, -1);
1103
+ rb_cv_set(cOCI8, "@@environment_handle", obj);
1104
+
1105
+ /* setup the process handle */
1106
+ obj = rb_obj_alloc(oci8_cOCIHandle);
1107
+ base = DATA_PTR(obj);
1108
+ base->type = OCI_HTYPE_PROC;
1109
+ base->self = Qnil;
1110
+ rb_cv_set(cOCI8, "@@process_handle", obj);
1111
+
1093
1112
  oracle_client_vernum = INT2FIX(oracle_client_version);
1094
1113
  if (have_OCIClientVersion) {
1095
1114
  sword major, minor, update, patch, port_update;
@@ -1107,8 +1126,6 @@ VALUE Init_oci8(void)
1107
1126
  rb_define_private_method(cOCI8, "parse_connect_string", oci8_parse_connect_string, 1);
1108
1127
  rb_define_private_method(cOCI8, "logon2", oci8_logon2, 4);
1109
1128
  rb_define_private_method(cOCI8, "allocate_handles", oci8_allocate_handles, 0);
1110
- rb_define_private_method(cOCI8, "session_handle", oci8_get_session_handle, 0);
1111
- rb_define_private_method(cOCI8, "server_handle", oci8_get_server_handle, 0);
1112
1129
  rb_define_private_method(cOCI8, "server_attach", oci8_server_attach, 2);
1113
1130
  rb_define_private_method(cOCI8, "session_begin", oci8_session_begin, 2);
1114
1131
  rb_define_method(cOCI8, "logoff", oci8_svcctx_logoff, 0);
@@ -1129,7 +1146,7 @@ VALUE Init_oci8(void)
1129
1146
  rb_define_method(cOCI8, "action=", oci8_set_action, 1);
1130
1147
  rb_define_method(cOCI8, "client_info=", oci8_set_client_info, 1);
1131
1148
  rb_define_attr(cOCI8, "last_error", 1, 1);
1132
- return cOCI8;
1149
+ *out = cOCI8;
1133
1150
  }
1134
1151
 
1135
1152
  oci8_svcctx_t *oci8_get_svcctx(VALUE obj)