[ruby-oci8-commit] [466] trunk/ruby-oci8: support sysasm privilege.
nobody at rubyforge.org
nobody at rubyforge.org
Wed Nov 23 08:15:16 EST 2011
Revision: 466
Author: kubo
Date: 2011-11-23 08:15:14 -0500 (Wed, 23 Nov 2011)
Log Message:
-----------
support sysasm privilege.
OCI8.new('username/password as sysasm')
or
OCI8.new('username', 'password', nil, :SYSASM)
Modified Paths:
--------------
trunk/ruby-oci8/ChangeLog
trunk/ruby-oci8/ext/oci8/oci8.c
trunk/ruby-oci8/lib/oci8/oci8.rb
trunk/ruby-oci8/lib/oci8/ocihandle.rb
trunk/ruby-oci8/test/test_connstr.rb
Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog 2011-11-04 12:14:41 UTC (rev 465)
+++ trunk/ruby-oci8/ChangeLog 2011-11-23 13:15:14 UTC (rev 466)
@@ -1,3 +1,10 @@
+2011-11-23 KUBO Takehiro <kubo at jiubao.org>
+ * ext/oci8/oci8.c, lib/oci8/oci8.rb, lib/oci8/ocihandle.rb,
+ test/test_connstr.rb: support sysasm privilege.
+ OCI8.new('username/password as sysasm')
+ or
+ OCI8.new('username', 'password', nil, :SYSASM)
+
2011-11-04 KUBO Takehiro <kubo at jiubao.org>
* lib/oci8/encoding.yml: fix the mapping from Oracle NLS chacacter set
to ruby encoding to use CP950 and CP951, which are new encodings
Modified: trunk/ruby-oci8/ext/oci8/oci8.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8.c 2011-11-04 12:14:41 UTC (rev 465)
+++ trunk/ruby-oci8/ext/oci8/oci8.c 2011-11-23 13:15:14 UTC (rev 466)
@@ -130,8 +130,6 @@
};
static VALUE oracle_client_vernum; /* Oracle client version number */
-static VALUE sym_SYSDBA;
-static VALUE sym_SYSOPER;
static ID id_at_prefetch_rows;
static ID id_set_prefetch_rows;
@@ -203,14 +201,7 @@
*pass = Qnil;
}
if (!NIL_P(*mode)) {
- char *ptr;
- SafeStringValue(*mode);
- ptr = RSTRING_PTR(*mode);
- if (strcasecmp(ptr, "SYSDBA") == 0) {
- *mode = sym_SYSDBA;
- } else if (strcasecmp(ptr, "SYSOPER") == 0) {
- *mode = sym_SYSOPER;
- }
+ *mode = ID2SYM(rb_to_id(rb_funcall(*mode, rb_intern("upcase"), 0)));
}
} else {
rb_raise(rb_eArgError, "invalid connect string \"%s\" (expect \"username/password[@(tns_name|//host[:port]/service_name)][ as (sysdba|sysoper)]\"", RSTRING_PTR(conn_str));
@@ -1093,8 +1084,6 @@
oracle_client_vernum = INT2FIX(ORAVERNUM(major, minor, update, patch, port_update));
}
- sym_SYSDBA = ID2SYM(rb_intern("SYSDBA"));
- sym_SYSOPER = ID2SYM(rb_intern("SYSOPER"));
id_at_prefetch_rows = rb_intern("@prefetch_rows");
id_set_prefetch_rows = rb_intern("prefetch_rows=");
Modified: trunk/ruby-oci8/lib/oci8/oci8.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/oci8.rb 2011-11-04 12:14:41 UTC (rev 465)
+++ trunk/ruby-oci8/lib/oci8/oci8.rb 2011-11-23 13:15:14 UTC (rev 466)
@@ -107,6 +107,11 @@
mode = OCI_SYSDBA
when :SYSOPER
mode = OCI_SYSOPER
+ when :SYSASM
+ if OCI8.oracle_client_version < OCI8::ORAVER_11_1
+ raise "SYSASM is not supported on Oracle version #{OCI8.oracle_client_version}"
+ end
+ mode = OCI_SYSASM
when nil
# do nothing
else
Modified: trunk/ruby-oci8/lib/oci8/ocihandle.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/ocihandle.rb 2011-11-04 12:14:41 UTC (rev 465)
+++ trunk/ruby-oci8/lib/oci8/ocihandle.rb 2011-11-23 13:15:14 UTC (rev 466)
@@ -300,6 +300,8 @@
OCI_SYSDBA = 0x0002
# for SYSOPER authorization
OCI_SYSOPER = 0x0004
+ # for SYSASM authorization
+ OCI_SYSASM = 0x8000
#################################
#
Modified: trunk/ruby-oci8/test/test_connstr.rb
===================================================================
--- trunk/ruby-oci8/test/test_connstr.rb 2011-11-04 12:14:41 UTC (rev 465)
+++ trunk/ruby-oci8/test/test_connstr.rb 2011-11-23 13:15:14 UTC (rev 466)
@@ -17,8 +17,8 @@
["", ArgumentError],
["foo bar/baz", ArgumentError],
["foo at bar/baz", ArgumentError],
- # raise error in connecting but no error in parse_connect_string.
- ["foo/bar as sysdbaaa", ["foo", "bar", nil, "sysdbaaa"]],
+ # parse_connect_string doesn't check validity of privilege.
+ ["foo/bar as foo_bar", ["foo", "bar", nil, :FOO_BAR]],
##
## following test cases are contributed by Shiwei Zhang.
More information about the ruby-oci8-commit
mailing list