From nobody at rubyforge.org Sat Dec 13 10:04:20 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Sat, 13 Dec 2008 10:04:20 -0500 (EST) Subject: [ruby-oci8-commit] [294] web: * hiki_data/en/text/FrontPage, hiki_data/ja/text/FrontPage Message-ID: <20081213150420.41104185859A@rubyforge.org> Revision: 294 Author: kubo Date: 2008-12-13 10:04:19 -0500 (Sat, 13 Dec 2008) Log Message: ----------- * hiki_data/en/text/FrontPage, hiki_data/ja/text/FrontPage add notice that ruby-oci8 doesn't work with ruby-dbi 0.4.x. Modified Paths: -------------- web/ChangeLog web/hiki_data/en/info.db web/hiki_data/en/text/FrontPage web/hiki_data/ja/info.db web/hiki_data/ja/text/FrontPage Modified: web/ChangeLog =================================================================== --- web/ChangeLog 2008-10-19 13:12:44 UTC (rev 293) +++ web/ChangeLog 2008-12-13 15:04:19 UTC (rev 294) @@ -1,3 +1,7 @@ +2008-12-13 KUBO Takehiro + * hiki_data/en/text/FrontPage, hiki_data/ja/text/FrontPage + add notice that ruby-oci8 doesn't work with ruby-dbi 0.4.x. + 2008-10-19 KUBO Takehiro * 01-run_webrick.rb, 02-make_html.rb, 03-copy_html.rb, config.rb: add scripts to make and copy ruby-oci8 web pages. Modified: web/hiki_data/en/info.db =================================================================== --- web/hiki_data/en/info.db 2008-10-19 13:12:44 UTC (rev 293) +++ web/hiki_data/en/info.db 2008-12-13 15:04:19 UTC (rev 294) @@ -64,7 +64,7 @@ :freeze => false, :keyword => [ ], -:last_modified => Time.at(1168180687), +:last_modified => Time.at(1229180402), :references => [ "InstallForInstantClient", ], Modified: web/hiki_data/en/text/FrontPage =================================================================== --- web/hiki_data/en/text/FrontPage 2008-10-19 13:12:44 UTC (rev 293) +++ web/hiki_data/en/text/FrontPage 2008-12-13 15:04:19 UTC (rev 294) @@ -7,6 +7,8 @@ As for Oracle7, use [[Oracle7 Module for Ruby]] by Yoshida Masato. +'''NOTICE -- ruby-oci8 doesn't work with ruby-dbi 0.4.x. ruby-oci8 supports ruby-dbi 0.2.2 or lower.''' + ! Sample one-liner connect to scott/tiger, select emp and print as CSV format. ruby -r oci8 -e "OCI8.new('scott', 'tiger').exec('select * from emp') do |r| puts r.join(','); end" Modified: web/hiki_data/ja/info.db =================================================================== --- web/hiki_data/ja/info.db 2008-10-19 13:12:44 UTC (rev 293) +++ web/hiki_data/ja/info.db 2008-12-13 15:04:19 UTC (rev 294) @@ -63,7 +63,7 @@ :freeze => false, :keyword => [ ], -:last_modified => Time.at(1168180666), +:last_modified => Time.at(1229179773), :references => [ "InstallForInstantClient", ], Modified: web/hiki_data/ja/text/FrontPage =================================================================== --- web/hiki_data/ja/text/FrontPage 2008-10-19 13:12:44 UTC (rev 293) +++ web/hiki_data/ja/text/FrontPage 2008-12-13 15:04:19 UTC (rev 294) @@ -7,6 +7,8 @@ Oracle7 ??????????????????[[Oracle7 Module for Ruby]]????????? +'''??: ruby-oci8 ? ruby-dbi 0.4.x ??????????????dbd ?????? ruby-dbi 0.2.2 ??????????''' + ! One-liner ????? scott/tiger ??????emp ????? select ???CSV ???????? From nobody at rubyforge.org Sun Dec 14 03:03:02 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Sun, 14 Dec 2008 03:03:02 -0500 (EST) Subject: [ruby-oci8-commit] [295] branches/ruby-oci8-1.0: * lib/oci8.rb.in: Message-ID: <20081214080302.DF42018585A2@rubyforge.org> Revision: 295 Author: kubo Date: 2008-12-14 03:03:02 -0500 (Sun, 14 Dec 2008) Log Message: ----------- * lib/oci8.rb.in: 1. fix to fetch a rowid column as s String. 2. change the return type of OCI8#rowid from OCIRowid to String. It is a local call on Oracle 9.0 or upper. But on Oracle 8.x client, it needs one network roundtrip to convert OCIRowid to String on server side. 3. fix OCI8#describe_table to prevent OCIStillExecuting when non-blocking mode is enabled and it needs a time to retrieve table information. * ext/oci8/extconf.rb, ext/oci8/oci8.c: add OCIRowid#to_s when OCIRowidToChar() is available. * test/test_all.rb, test/test_rowid.rb: add a rowid test case. * test/test_dbi_clob.rb: fix to pass tests when the test directory path is too long. Modified Paths: -------------- branches/ruby-oci8-1.0/ChangeLog branches/ruby-oci8-1.0/ext/oci8/extconf.rb branches/ruby-oci8-1.0/ext/oci8/oci8.c branches/ruby-oci8-1.0/lib/oci8.rb.in branches/ruby-oci8-1.0/test/test_all.rb branches/ruby-oci8-1.0/test/test_dbi_clob.rb Added Paths: ----------- branches/ruby-oci8-1.0/test/test_rowid.rb Modified: branches/ruby-oci8-1.0/ChangeLog =================================================================== --- branches/ruby-oci8-1.0/ChangeLog 2008-12-13 15:04:19 UTC (rev 294) +++ branches/ruby-oci8-1.0/ChangeLog 2008-12-14 08:03:02 UTC (rev 295) @@ -1,3 +1,19 @@ +2008-12-14 KUBO Takehiro + * lib/oci8.rb.in: + 1. fix to fetch a rowid column as s String. + 2. change the return type of OCI8#rowid from OCIRowid + to String. It is a local call on Oracle 9.0 or upper. + But on Oracle 8.x client, it needs one network roundtrip + to convert OCIRowid to String on server side. + 3. fix OCI8#describe_table to prevent OCIStillExecuting when + non-blocking mode is enabled and it needs a time to + retrieve table information. + * ext/oci8/extconf.rb, ext/oci8/oci8.c: add OCIRowid#to_s + when OCIRowidToChar() is available. + * test/test_all.rb, test/test_rowid.rb: add a rowid test case. + * test/test_dbi_clob.rb: fix to pass tests when the test directory + path is too long. + 2008-08-10 KUBO Takehiro * NEWS: add changes between 1.0.2 and 1.0.3. * VERSION: change version to 1.0.3. @@ -12,7 +28,7 @@ 2008-08-09 KUBO Takehiro * ext/oci8/lob.c: fix OCILobLocator#getLength for a lob over 1GB, which affect OCI8::LOB#size and OCI8::LOB#read. fix - OCILobLocator#read and OCILobLocator#write to set offset over 2BG, + OCILobLocator#read and OCILobLocator#write to set offset over 2GB, which affect OCI8::LOB#read and OCI8::LOB#write. (This probmem was reported by Jonathan Hadders.) Modified: branches/ruby-oci8-1.0/ext/oci8/extconf.rb =================================================================== --- branches/ruby-oci8-1.0/ext/oci8/extconf.rb 2008-12-13 15:04:19 UTC (rev 294) +++ branches/ruby-oci8-1.0/ext/oci8/extconf.rb 2008-12-14 08:03:02 UTC (rev 295) @@ -77,6 +77,8 @@ have_func("OCILobGetChunkSize") have_func("OCILobLocatorAssign") +have_func("OCIRowidToChar") + $defs.push("-DHAVE_OCIRESET") unless /80./ =~ oraconf.version # Checking gcc or not Modified: branches/ruby-oci8-1.0/ext/oci8/oci8.c =================================================================== --- branches/ruby-oci8-1.0/ext/oci8/oci8.c 2008-12-13 15:04:19 UTC (rev 294) +++ branches/ruby-oci8-1.0/ext/oci8/oci8.c 2008-12-14 08:03:02 UTC (rev 295) @@ -77,6 +77,8 @@ VALUE cOraDate; VALUE cOraNumber; +static void Init_OCIRowid(void); + void Init_oci8lib() { @@ -131,7 +133,46 @@ Init_ora_date(); Init_ora_number(); + Init_OCIRowid(); + #ifdef DEBUG_CORE_FILE signal(SIGSEGV, SIG_DFL); #endif } + +#if defined(WIN32) +typedef sword (*OCIRowidToChar_func_t)(OCIRowid *rowidDesc, OraText *outbfp, ub2 *outbflp, OCIError *errhp); +static OCIRowidToChar_func_t OCIRowidToChar_func; +#define OCIRowidToChar OCIRowidToChar_func +#endif + +#if defined(WIN32) || defined(HAVE_OCIROWIDTOCHAR) +static VALUE oci8_rowid_to_s(VALUE self) +{ + oci8_handle_t *h; + char buf[64]; + ub2 buflen = sizeof(buf); + sword rv; + + Get_Handle(self, h); + rv = OCIRowidToChar(h->hp, (text*)buf, &buflen, h->errhp); + if (rv != OCI_SUCCESS) + oci8_raise(h->errhp, rv, NULL); + return rb_str_new(buf, buflen); +} +#endif + +static void Init_OCIRowid(void) +{ +#if defined(WIN32) + HANDLE hModule = GetModuleHandle("OCI.DLL"); + if (hModule != NULL) { + OCIRowidToChar_func = (OCIRowidToChar_func_t)GetProcAddress(hModule, "OCIRowidToChar"); + } + if (OCIRowidToChar_func != NULL) { + rb_define_method(cOCIRowid, "to_s", oci8_rowid_to_s, 0); + } +#elif defined(HAVE_OCIROWIDTOCHAR) + rb_define_method(cOCIRowid, "to_s", oci8_rowid_to_s, 0); +#endif +} Modified: branches/ruby-oci8-1.0/lib/oci8.rb.in =================================================================== --- branches/ruby-oci8-1.0/lib/oci8.rb.in 2008-12-13 15:04:19 UTC (rev 294) +++ branches/ruby-oci8-1.0/lib/oci8.rb.in 2008-12-14 08:03:02 UTC (rev 295) @@ -351,7 +351,7 @@ def describe_table(table_name) desc = @@env.alloc(OCIDescribe) desc.attrSet(OCI_ATTR_DESC_PUBLIC, -1) - desc.describeAny(@svc, table_name.to_s, OCI_PTYPE_UNK) + do_ocicall(@ctx) { desc.describeAny(@svc, table_name.to_s, OCI_PTYPE_UNK) } param = desc.attrGet(OCI_ATTR_PARAM) case param.attrGet(OCI_ATTR_PTYPE) @@ -811,8 +811,25 @@ @stmttype = nil end # close + # Get the rowid of the last inserted/updated/deleted row. def rowid - @stmt.attrGet(OCI_ATTR_ROWID) + # get the binary rowid + rid = @stmt.attrGet(OCI_ATTR_ROWID) + # convert it to a string rowid. + if rid.respond_to? :to_s + # (Oracle 9.0 or upper) + rid.to_s + else + # (Oracle 8.1 or lower) + stmt = @env.alloc(OCIStmt) + stmt.prepare('begin :1 := :2; end;') + b = stmt.bindByPos(1, OCI8::SQLT_CHR, 64) + stmt.bindByPos(2, OCI8::SQLT_RDD, rid) + do_ocicall(@ctx) { stmt.execute(@svc, 1, OCI_DEFAULT) } + str_rid = b.get() + stmt.free() + str_rid + end end def prefetch_rows=(rows) @@ -899,6 +916,8 @@ datatype = :nclob if p.attrGet(OCI_ATTR_CHARSET_FORM) == SQLCS_NCHAR when SQLT_BIN datasize *= 2 if OCI8::BindType::Mapping[datatype] == OCI8::BindType::String + when SQLT_RDD + datasize = 64 end bind_or_define(:define, i, nil, datatype, datasize, precision, scale, true) @@ -1210,7 +1229,7 @@ # datatype type size prec scale # ------------------------------------------------- # ROWID SQLT_RDD 4 0 0 - BindType::Mapping[OCI8::SQLT_RDD] = BindType::OCIRowid + BindType::Mapping[OCI8::SQLT_RDD] = BindType::String # datatype type size prec scale # ----------------------------------------------------- Modified: branches/ruby-oci8-1.0/test/test_all.rb =================================================================== --- branches/ruby-oci8-1.0/test/test_all.rb 2008-12-13 15:04:19 UTC (rev 294) +++ branches/ruby-oci8-1.0/test/test_all.rb 2008-12-14 08:03:02 UTC (rev 295) @@ -18,6 +18,7 @@ require "#{srcdir}/test_oci8" require "#{srcdir}/test_connstr" require "#{srcdir}/test_metadata" +require "#{srcdir}/test_rowid" # Ruby/DBI begin Modified: branches/ruby-oci8-1.0/test/test_dbi_clob.rb =================================================================== --- branches/ruby-oci8-1.0/test/test_dbi_clob.rb 2008-12-13 15:04:19 UTC (rev 294) +++ branches/ruby-oci8-1.0/test/test_dbi_clob.rb 2008-12-14 08:03:02 UTC (rev 295) @@ -11,13 +11,14 @@ end def test_insert - @dbh.do("DELETE FROM test_clob WHERE filename = :1", $lobfile) + filename = File.basename($lobfile) + @dbh.do("DELETE FROM test_clob WHERE filename = :1", filename) # insert an empty clob and get the rowid. - rowid = @dbh.execute("INSERT INTO test_clob(filename, content) VALUES (:1, EMPTY_CLOB())", $lobfile) do |sth| + rowid = @dbh.execute("INSERT INTO test_clob(filename, content) VALUES (:1, EMPTY_CLOB())", filename) do |sth| sth.func(:rowid) end - lob = @dbh.select_one("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE", $lobfile)[0] + lob = @dbh.select_one("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE", filename)[0] begin open($lobfile) do |f| while f.gets() @@ -30,8 +31,9 @@ end def test_read + filename = File.basename($lobfile) test_insert() # first insert data. - lob = @dbh.select_one("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE", $lobfile)[0] + lob = @dbh.select_one("SELECT content FROM test_clob WHERE filename = :1 FOR UPDATE", filename)[0] begin open($lobfile) do |f| while buf = lob.read($lobreadnum) Added: branches/ruby-oci8-1.0/test/test_rowid.rb =================================================================== --- branches/ruby-oci8-1.0/test/test_rowid.rb (rev 0) +++ branches/ruby-oci8-1.0/test/test_rowid.rb 2008-12-14 08:03:02 UTC (rev 295) @@ -0,0 +1,38 @@ +require 'oci8' +require 'runit/testcase' +require 'runit/cui/testrunner' +require File.dirname(__FILE__) + '/config' + +class TestRowid < RUNIT::TestCase + + def setup + @conn = get_oci_connection() + end + + def teardown + @conn.logoff + end + + def test_rowid + drop_table('test_table') + sql = <<-EOS +CREATE TABLE test_table (N NUMBER(38)) +EOS + @conn.exec(sql) + cursor = @conn.parse("INSERT INTO test_table values(1)"); + cursor.exec + rid1 = cursor.rowid + assert_instance_of(String, rid1) + cursor.close + rid2 = nil + @conn.exec('select rowid from test_table where rowid = :1', rid1) do |row| + rid2 = row[0] + end + assert_equal(rid2, rid1) + drop_table('test_table') + end +end # TestRowid + +if $0 == __FILE__ + RUNIT::CUI::TestRunner.run(TestRowid.suite()) +end From nobody at rubyforge.org Sun Dec 14 03:07:01 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Sun, 14 Dec 2008 03:07:01 -0500 (EST) Subject: [ruby-oci8-commit] [296] trunk/ruby-oci8: * ext/oci8/stmt.c: fix comment. Message-ID: <20081214080701.6792A185859A@rubyforge.org> Revision: 296 Author: kubo Date: 2008-12-14 03:07:01 -0500 (Sun, 14 Dec 2008) Log Message: ----------- * ext/oci8/stmt.c: fix comment. * test/test_rowid.rb: add one assertion as ruby-oci8 1.0 branch does. Modified Paths: -------------- trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/ext/oci8/stmt.c trunk/ruby-oci8/test/test_rowid.rb Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2008-12-14 08:03:02 UTC (rev 295) +++ trunk/ruby-oci8/ChangeLog 2008-12-14 08:07:01 UTC (rev 296) @@ -1,3 +1,7 @@ +2008-12-14 KUBO Takehiro + * ext/oci8/stmt.c: fix comment. + * test/test_rowid.rb: add one assertion as ruby-oci8 1.0 branch does. + 2008-09-10 KUBO Takehiro * ext/oci8/ocidatetime.c: use session time zone when time zone is not specified to set bind objects of timestamp with time Modified: trunk/ruby-oci8/ext/oci8/stmt.c =================================================================== --- trunk/ruby-oci8/ext/oci8/stmt.c 2008-12-14 08:03:02 UTC (rev 295) +++ trunk/ruby-oci8/ext/oci8/stmt.c 2008-12-14 08:07:01 UTC (rev 296) @@ -539,10 +539,10 @@ * cursor.exec * cursor.rowid # => the inserted row's rowid * - * Changes between ruby-oci8 1.0 and 2.0. + * Changes between ruby-oci8 1.0.3 and 1.0.4. * - * [ruby-oci8 2.0] The return value is a String. - * [ruby-oci8 1.0] It returns an OCIRowid object which is available only as a bind value. + * [ruby-oci8 1.0.4 or upper] The return value is a String. + * [ruby-oci8 1.0.3 or lower] It returns an OCIRowid object. */ static VALUE oci8_stmt_get_rowid(VALUE self) { Modified: trunk/ruby-oci8/test/test_rowid.rb =================================================================== --- trunk/ruby-oci8/test/test_rowid.rb 2008-12-14 08:03:02 UTC (rev 295) +++ trunk/ruby-oci8/test/test_rowid.rb 2008-12-14 08:07:01 UTC (rev 296) @@ -17,6 +17,7 @@ cursor = @conn.parse("INSERT INTO test_table values(1)"); cursor.exec rid1 = cursor.rowid + assert_instance_of(String, rid1) cursor.close rid2 = nil @conn.exec('select rowid from test_table where rowid = :1', rid1) do |row| From nobody at rubyforge.org Sun Dec 14 08:26:06 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Sun, 14 Dec 2008 08:26:06 -0500 (EST) Subject: [ruby-oci8-commit] [297] web: * hiki_data/en/text/PlatformSpecificIssue, hiki_data/ja/text/ PlatformSpecificIssue Message-ID: <20081214132606.C695E185859A@rubyforge.org> Revision: 297 Author: kubo Date: 2008-12-14 08:26:05 -0500 (Sun, 14 Dec 2008) Log Message: ----------- * hiki_data/en/text/PlatformSpecificIssue, hiki_data/ja/text/PlatformSpecificIssue update FreeBSD information that oracle8-client port doesn't work with Oracle 10g and it is unstable. Modified Paths: -------------- web/ChangeLog web/hiki_data/en/info.db web/hiki_data/en/text/PlatformSpecificIssue web/hiki_data/ja/info.db web/hiki_data/ja/text/PlatformSpecificIssue Modified: web/ChangeLog =================================================================== --- web/ChangeLog 2008-12-14 08:07:01 UTC (rev 296) +++ web/ChangeLog 2008-12-14 13:26:05 UTC (rev 297) @@ -1,3 +1,8 @@ +2008-12-14 KUBO Takehiro + * hiki_data/en/text/PlatformSpecificIssue, hiki_data/ja/text/PlatformSpecificIssue + update FreeBSD information that oracle8-client port doesn't + work with Oracle 10g and it is unstable. + 2008-12-13 KUBO Takehiro * hiki_data/en/text/FrontPage, hiki_data/ja/text/FrontPage add notice that ruby-oci8 doesn't work with ruby-dbi 0.4.x. Modified: web/hiki_data/en/info.db =================================================================== --- web/hiki_data/en/info.db 2008-12-14 08:07:01 UTC (rev 296) +++ web/hiki_data/en/info.db 2008-12-14 13:26:05 UTC (rev 297) @@ -136,7 +136,7 @@ :freeze => false, :keyword => [ ], -:last_modified => Time.at(1192665604), +:last_modified => Time.at(1229260669), :references => [ "InstallForInstantClient", "InstallForFullClient", Modified: web/hiki_data/en/text/PlatformSpecificIssue =================================================================== --- web/hiki_data/en/text/PlatformSpecificIssue 2008-12-14 08:07:01 UTC (rev 296) +++ web/hiki_data/en/text/PlatformSpecificIssue 2008-12-14 13:26:05 UTC (rev 297) @@ -33,10 +33,14 @@ ! FreeBSD There are two ways. -* use ruby and instantclient on linux emulator -* use oracle8-client port +# use ruby and instantclient on linux emulator (Does anyone write the procedure?) +# use oracle8-client port -In the latter case, compile and install as follows. +I don't recommend the latter because of the following two reasons. +# The oracle8-clint port is made from Oracle 8.1.7.1 static library for Linux. Oracle have not supported the connectability between 8.1.7.1 and Oracle 10g. +# It is very unstable. When it fails to connect to an Oracle server, it is down by segmentation fault on FreeBSD 7.0 not only when using ruby-oci8, but also by a very simple test code written by C. + +If you try to use oracle8-client port, compile and install as follows. * install oracle8-client cd /usr/ports/databases/oracle8-client make @@ -54,10 +58,6 @@ note: You have no need to set LD_LIBRARY_PATH because Oracle libraries in oracle8-client port are static ones. -Not all faculties are available. Some tests in 'make check' -are failed. Some tests cause busy loop. Check and use it -at your own risk. - ! HP-UX You need a ruby which is linked with ''libpthread'' and ''libcl''. Modified: web/hiki_data/ja/info.db =================================================================== --- web/hiki_data/ja/info.db 2008-12-14 08:07:01 UTC (rev 296) +++ web/hiki_data/ja/info.db 2008-12-14 13:26:05 UTC (rev 297) @@ -135,7 +135,7 @@ :freeze => false, :keyword => [ ], -:last_modified => Time.at(1192665989), +:last_modified => Time.at(1229260684), :references => [ "InstallForInstantClient", "InstallForFullClient", Modified: web/hiki_data/ja/text/PlatformSpecificIssue =================================================================== --- web/hiki_data/ja/text/PlatformSpecificIssue 2008-12-14 08:07:01 UTC (rev 296) +++ web/hiki_data/ja/text/PlatformSpecificIssue 2008-12-14 13:26:05 UTC (rev 297) @@ -35,10 +35,14 @@ ! FreeBSD 2?????????? -* instantclient ? linux emulator ?? ruby ????? -* oracle8-client port ???? +# instantclient ? linux emulator ?? ruby ????? +# oracle8-client port ???? -oracle8-client ?????????????????? +??????????? oracle8-client port ????????????? +# oracle8-client port ? Linux ?? Oracle 8.1.7.1 ??????????????????Oracle ? 8.1.7.1 ? Oracle 10g ???????????????????? +# ?????????FreeBSD 7.0 ?? Oracle ?????????? Segmentation fault ??????ruby-oci8 ???????????????C??????????????????????? + +oracle8-client port ?????????????????? * oracle8-client ??????? cd /usr/ports/databases/oracle8-client make @@ -57,10 +61,6 @@ ????????????LD_LIBRARY_PATH ???????? ???? -FreeBSD ??????????????????make check -????????????????????????????? -????????????????????????????? - ! HP-UX libpthread?libcl ???????? ruby ?????? From nobody at rubyforge.org Sun Dec 21 07:49:05 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Sun, 21 Dec 2008 07:49:05 -0500 (EST) Subject: [ruby-oci8-commit] [298] trunk/ruby-oci8: * ext/oci8/apiwrap.yml: add OCINlsCharSetNameToId() Message-ID: <20081221124905.C20591588059@rubyforge.org> Revision: 298 Author: kubo Date: 2008-12-21 07:49:05 -0500 (Sun, 21 Dec 2008) Log Message: ----------- * ext/oci8/apiwrap.yml: add OCINlsCharSetNameToId() * ext/oci8/encoding.c: add OCI8#charset_name2id and OCI8#charset_id2name. * ext/oci8/env.c: include only when ruby 1.8. * ext/oci8/oci8.h: don't include which is not used anywhere. * ext/oci8/ocinumber.c: include to compile ruby-oci8 for ruby 1.9. * lib/oci8/metadata.rb: comment duplicated typecode. * test/test_all.rb: use AutoRunner when it is found. Ruby 1.9's test unit does't has AutoRunner. * test/test_oranumber.rb: explicity convert actual_val, which is passed to before assert_in_delta(), to a Float to prevent SEGV in OCINumberSub(). Modified Paths: -------------- trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/ext/oci8/apiwrap.yml trunk/ruby-oci8/ext/oci8/encoding.c trunk/ruby-oci8/ext/oci8/env.c trunk/ruby-oci8/ext/oci8/oci8.h trunk/ruby-oci8/ext/oci8/ocinumber.c trunk/ruby-oci8/lib/oci8/metadata.rb trunk/ruby-oci8/test/test_all.rb trunk/ruby-oci8/test/test_oranumber.rb Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2008-12-14 13:26:05 UTC (rev 297) +++ trunk/ruby-oci8/ChangeLog 2008-12-21 12:49:05 UTC (rev 298) @@ -1,3 +1,19 @@ +2008-12-21 KUBO Takehiro + * ext/oci8/apiwrap.yml: add OCINlsCharSetNameToId() + * ext/oci8/encoding.c: add OCI8#charset_name2id and + OCI8#charset_id2name. + * ext/oci8/env.c: include only when ruby 1.8. + * ext/oci8/oci8.h: don't include which is not used + anywhere. + * ext/oci8/ocinumber.c: include to compile + ruby-oci8 for ruby 1.9. + * lib/oci8/metadata.rb: comment duplicated typecode. + * test/test_all.rb: use AutoRunner when it is found. + Ruby 1.9's test unit does't has AutoRunner. + * test/test_oranumber.rb: explicity convert actual_val, which is + passed to before assert_in_delta(), to a Float to prevent + SEGV in OCINumberSub(). + 2008-12-14 KUBO Takehiro * ext/oci8/stmt.c: fix comment. * test/test_rowid.rb: add one assertion as ruby-oci8 1.0 branch does. Modified: trunk/ruby-oci8/ext/oci8/apiwrap.yml =================================================================== --- trunk/ruby-oci8/ext/oci8/apiwrap.yml 2008-12-14 13:26:05 UTC (rev 297) +++ trunk/ruby-oci8/ext/oci8/apiwrap.yml 2008-12-21 12:49:05 UTC (rev 298) @@ -1126,6 +1126,12 @@ - size_t buflen - ub2 id +OCINlsCharSetNameToId: + :version: 920 + :ret: ub2 + :args: - dvoid *envhp + - const oratext *name + # # Oracle 10.1 # Modified: trunk/ruby-oci8/ext/oci8/encoding.c =================================================================== --- trunk/ruby-oci8/ext/oci8/encoding.c 2008-12-14 13:26:05 UTC (rev 297) +++ trunk/ruby-oci8/ext/oci8/encoding.c 2008-12-21 12:49:05 UTC (rev 298) @@ -23,14 +23,11 @@ /* Oracle charset id -> Oracle charset name */ static VALUE csid2name; -VALUE oci8_charset_id2name(VALUE svc, VALUE csid); -#ifdef HAVE_TYPE_RB_ENCODING /* Oracle charset name -> Oracle charset id */ static ID id_upcase; static VALUE csname2id; static VALUE oci8_charset_name2id(VALUE svc, VALUE name); -#endif /* HAVE_TYPE_RB_ENCODING */ VALUE oci8_charset_id2name(VALUE svc, VALUE csid) { @@ -79,22 +76,19 @@ } OBJ_FREEZE(name); rb_hash_aset(csid2name, csid, name); -#ifdef HAVE_TYPE_RB_ENCODING rb_hash_aset(csname2id, name, csid); -#endif /* HAVE_TYPE_RB_ENCODING */ return name; } -#ifdef HAVE_TYPE_RB_ENCODING - static VALUE oci8_charset_name2id(VALUE svc, VALUE name) { - VALUE csid = rb_hash_aref(csname2id, StringValue(name)); + VALUE csid; + name = rb_funcall(name, id_upcase, 0); + csid = rb_hash_aref(csname2id, StringValue(name)); if (!NIL_P(csid)) { return csid; } - name = rb_funcall(name, id_upcase, 0); if (have_OCINlsCharSetNameToId) { /* Oracle 9iR2 or upper */ ub2 rv; @@ -124,32 +118,27 @@ bind_vars[1].alenp = NULL; /* convert chaset name to charset id by querying Oracle server. */ - oci8_exec_sql(oci8_get_svcctx(svc), "BEGIN :csid := nls_charset_id(:name); END;", 0, NULL, 2, bind_vars); + oci8_exec_sql(oci8_get_svcctx(svc), "BEGIN :csid := nls_charset_id(:name); END;", 0, NULL, 2, bind_vars, 1); if (ind) { return Qnil; } - csid = INT2FIX(id); + csid = INT2FIX(ival); } rb_hash_aset(csid2name, csid, name); rb_hash_aset(csname2id, name, csid); return csid; } -#endif /* HAVE_TYPE_RB_ENCODING */ void Init_oci8_encoding(VALUE cOCI8) { csid2name = rb_hash_new(); rb_global_variable(&csid2name); -#ifdef HAVE_TYPE_RB_ENCODING id_upcase = rb_intern("upcase"); csname2id = rb_hash_new(); rb_global_variable(&csname2id); -#endif /* HAVE_TYPE_RB_ENCODING */ -#if 0 rb_define_method(cOCI8, "charset_name2id", oci8_charset_name2id, 1); rb_define_method(cOCI8, "charset_id2name", oci8_charset_id2name, 1); -#endif } Modified: trunk/ruby-oci8/ext/oci8/env.c =================================================================== --- trunk/ruby-oci8/ext/oci8/env.c 2008-12-14 13:26:05 UTC (rev 297) +++ trunk/ruby-oci8/ext/oci8/env.c 2008-12-21 12:49:05 UTC (rev 298) @@ -7,11 +7,8 @@ */ #include "oci8.h" -/* ruby_setenv */ -#ifdef HAVE_RUBY_UTIL_H -#include -#endif -#ifdef HAVE_UTIL_H +#if !defined(RUBY_VM) +/* ruby_setenv for workaround ruby 1.8.4 */ #include #endif Modified: trunk/ruby-oci8/ext/oci8/oci8.h =================================================================== --- trunk/ruby-oci8/ext/oci8/oci8.h 2008-12-14 13:26:05 UTC (rev 297) +++ trunk/ruby-oci8/ext/oci8/oci8.h 2008-12-21 12:49:05 UTC (rev 298) @@ -8,7 +8,6 @@ #define _RUBY_OCI_H_ 1 #include "ruby.h" -#include "rubyio.h" #ifdef HAVE_INTERN_H #include "intern.h" #endif Modified: trunk/ruby-oci8/ext/oci8/ocinumber.c =================================================================== --- trunk/ruby-oci8/ext/oci8/ocinumber.c 2008-12-14 13:26:05 UTC (rev 297) +++ trunk/ruby-oci8/ext/oci8/ocinumber.c 2008-12-21 12:49:05 UTC (rev 298) @@ -10,6 +10,7 @@ */ #include "oci8.h" #include +#include #ifndef RUBY_VM /* ruby 1.8 */ Modified: trunk/ruby-oci8/lib/oci8/metadata.rb =================================================================== --- trunk/ruby-oci8/lib/oci8/metadata.rb 2008-12-14 13:26:05 UTC (rev 297) +++ trunk/ruby-oci8/lib/oci8/metadata.rb 2008-12-21 12:49:05 UTC (rev 298) @@ -501,10 +501,10 @@ when 189; :interval_ym # OCI_TYPECODE_INTERVAL_YM when 190; :interval_ds # OCI_TYPECODE_INTERVAL_DS when 104; :urowid # OCI_TYPECODE_UROWID - when 228; :otmfirst # OCI_TYPECODE_OTMFIRST - when 320; :otmlast # OCI_TYPECODE_OTMLAST - when 228; :sysfirst # OCI_TYPECODE_SYSFIRST - when 235; :syslast # OCI_TYPECODE_SYSLAST + #when 228; :otmfirst # OCI_TYPECODE_OTMFIRST + #when 320; :otmlast # OCI_TYPECODE_OTMLAST + #when 228; :sysfirst # OCI_TYPECODE_SYSFIRST + #when 235; :syslast # OCI_TYPECODE_SYSLAST when 266; :pls_integer # OCI_TYPECODE_PLS_INTEGER end end Modified: trunk/ruby-oci8/test/test_all.rb =================================================================== --- trunk/ruby-oci8/test/test_all.rb 2008-12-14 13:26:05 UTC (rev 297) +++ trunk/ruby-oci8/test/test_all.rb 2008-12-21 12:49:05 UTC (rev 298) @@ -35,5 +35,6 @@ end #Test::Unit::AutoRunner.run(true, true) -Test::Unit::AutoRunner.run() - +if defined? Test::Unit::AutoRunner + Test::Unit::AutoRunner.run() +end Modified: trunk/ruby-oci8/test/test_oranumber.rb =================================================================== --- trunk/ruby-oci8/test/test_oranumber.rb 2008-12-14 13:26:05 UTC (rev 297) +++ trunk/ruby-oci8/test/test_oranumber.rb 2008-12-21 12:49:05 UTC (rev 298) @@ -98,6 +98,9 @@ puts '-----------' raise $! end + # explicity convert actual_val to a Float to prevent SEGV + # in OCINumberSub(). + actual_val = actual_val.to_f if defined? ::MiniTest assert_in_delta(expected_val, actual_val, delta, x) end end From nobody at rubyforge.org Tue Dec 30 02:19:44 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Tue, 30 Dec 2008 02:19:44 -0500 (EST) Subject: [ruby-oci8-commit] [299] trunk/ruby-oci8: * ext/oci8/oraconf.rb: add code to check the cpu type of Mac OS X Message-ID: <20081230071944.77ABC158805F@rubyforge.org> Revision: 299 Author: kubo Date: 2008-12-30 02:19:43 -0500 (Tue, 30 Dec 2008) Log Message: ----------- * ext/oci8/oraconf.rb: add code to check the cpu type of Mac OS X libclntsh.dylib. Modified Paths: -------------- trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/ext/oci8/oraconf.rb Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2008-12-21 12:49:05 UTC (rev 298) +++ trunk/ruby-oci8/ChangeLog 2008-12-30 07:19:43 UTC (rev 299) @@ -1,3 +1,7 @@ +2008-12-30 KUBO Takehiro + * ext/oci8/oraconf.rb: add code to check the cpu type of Mac OS X + libclntsh.dylib. + 2008-12-21 KUBO Takehiro * ext/oci8/apiwrap.yml: add OCINlsCharSetNameToId() * ext/oci8/encoding.c: add OCI8#charset_name2id and Modified: trunk/ruby-oci8/ext/oci8/oraconf.rb =================================================================== --- trunk/ruby-oci8/ext/oci8/oraconf.rb 2008-12-21 12:49:05 UTC (rev 298) +++ trunk/ruby-oci8/ext/oci8/oraconf.rb 2008-12-30 07:19:43 UTC (rev 299) @@ -110,8 +110,23 @@ when "MZ" # Windows read_pe(f) + when "\x02\x10" + # HP-UX PA-RISC1.1 + read_parisc(f) + when "\xfe\xed" + # Big-endian Mach-O File + read_mach_o_be(f) + when "\xce\xfa" + # 32-bit Little-endian Mach-O File + read_mach_o_le(f, 32) + when "\xcf\xfa" + # 64-bit Little-endian Mach-O File + read_mach_o_le(f, 64) + when "\xca\xfe" + # Universal binary + read_mach_o_unversal(f) else - # HP-UX(32-bit), AIX, Mac OS X and Tru64 + # AIX and Tru64 raise format("unknown file header: %02x %02x", file_header[0], file_header[1]) end ensure @@ -202,6 +217,79 @@ raise "Invalid coff machine: #{machine}" end end + + # HP-UX PA-RISC(32 bit) + def read_parisc(f) + # 0-1 system_id - CPU_PA_RISC1_1 + @file_format = :pa_risc + # 2-3 a_magic - SHL_MAGIC + raise 'invalid a_magic' if f.read(2).unpack('n')[0] != 0x10e + @bits = 32 + @endian = :big + @cpu = :parisc + end + + # Big-endian Mach-O File + def read_mach_o_be(f) + @file_format = :mach_o + @endian = :big + case f.read(2) + when "\xfa\xce" # feedface + @cpu = :ppc + @bits = 32 + when "\xfa\xcf" # feedfacf + @cpu = :ppc64 + @bits = 64 + else + raise "unknown file format" + end + end + + def read_mach_o_le(f, bits) + @file_format = :mach_o + @endian = :little + raise 'unknown file format' if f.read(2) != "\xed\xfe" + case bits + when 32 + @cpu = :i386 + @bits = 32 + when 64 + @cpu = :x86_64 + @bits = 64 + end + end + + def read_mach_o_unversal(f) + raise 'unknown file format' if f.read(2) != "\xba\xbe" # cafebabe + @file_format = :universal + nfat_arch = f.read(4).unpack('N')[0] + @cpu = [] + @endian = [] + @bits = [] + nfat_arch.times do + case cputype = f.read(4).unpack('N')[0] + when 7 + @cpu << :i386 + @endian << :little + @bits << 32 + when 7 + 0x01000000 + @cpu << :x86_64 + @endian << :little + @bits << 64 + when 18 + @cpu << :ppc + @endian << :big + @bits << 32 + when 18 + 0x01000000 + @cpu << :ppc64 + @endian << :big + @bits << 64 + else + raise "Unknown mach-o cputype: #{cputype}" + end + f.seek(4 * 4, IO::SEEK_CUR) + end + end end class OraConf @@ -335,6 +423,39 @@ when /darwin/ @@ld_envs = %w[DYLD_LIBRARY_PATH] so_ext = 'dylib' + check_proc = Proc.new do |file| + is_32bit = [0].pack('l!').size == 4 + is_big_endian = "\x01\x02".unpack('s') == 0x0102 + if is_32bit + if is_big_endian + this_cpu = :ppc # 32-bit big-endian + else + this_cpu = :i386 # 32-bit little-endian + end + else + if is_big_endian + this_cpu = :ppc64 # 64-bit big-endian + else + this_cpu = :x86_64 # 64-bit little-endian + end + end + so = MiniSOReader.new(file) + if so.file_format == :universal + if so.cpu.include? this_cpu + true + else + puts " skip: #{file} is for #{so.cpu} cpu." + false + end + else + if so.cpu == this_cpu + true + else + puts " skip: #{file} is for #{so.cpu} cpu." + false + end + end + end end glob_name = "#{oci_basename}.#{so_ext}#{oci_glob_postfix}" From nobody at rubyforge.org Tue Dec 30 02:23:14 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Tue, 30 Dec 2008 02:23:14 -0500 (EST) Subject: [ruby-oci8-commit] [300] branches/ruby-oci8-1.0: * ext/oci8/oraconf.rb: add code to check the cpu type of Mac OS X Message-ID: <20081230072314.B422F1588059@rubyforge.org> Revision: 300 Author: kubo Date: 2008-12-30 02:23:14 -0500 (Tue, 30 Dec 2008) Log Message: ----------- * ext/oci8/oraconf.rb: add code to check the cpu type of Mac OS X libclntsh.dylib. Modified Paths: -------------- branches/ruby-oci8-1.0/ChangeLog branches/ruby-oci8-1.0/ext/oci8/oraconf.rb Modified: branches/ruby-oci8-1.0/ChangeLog =================================================================== --- branches/ruby-oci8-1.0/ChangeLog 2008-12-30 07:19:43 UTC (rev 299) +++ branches/ruby-oci8-1.0/ChangeLog 2008-12-30 07:23:14 UTC (rev 300) @@ -1,7 +1,11 @@ +2008-12-30 KUBO Takehiro + * ext/oci8/oraconf.rb: add code to check the cpu type of Mac OS X + libclntsh.dylib. + 2008-12-14 KUBO Takehiro * lib/oci8.rb.in: 1. fix to fetch a rowid column as s String. - 2. change the return type of OCI8#rowid from OCIRowid + 2. change the return type of OCI8::Cursor#rowid from OCIRowid to String. It is a local call on Oracle 9.0 or upper. But on Oracle 8.x client, it needs one network roundtrip to convert OCIRowid to String on server side. Modified: branches/ruby-oci8-1.0/ext/oci8/oraconf.rb =================================================================== --- branches/ruby-oci8-1.0/ext/oci8/oraconf.rb 2008-12-30 07:19:43 UTC (rev 299) +++ branches/ruby-oci8-1.0/ext/oci8/oraconf.rb 2008-12-30 07:23:14 UTC (rev 300) @@ -110,8 +110,23 @@ when "MZ" # Windows read_pe(f) + when "\x02\x10" + # HP-UX PA-RISC1.1 + read_parisc(f) + when "\xfe\xed" + # Big-endian Mach-O File + read_mach_o_be(f) + when "\xce\xfa" + # 32-bit Little-endian Mach-O File + read_mach_o_le(f, 32) + when "\xcf\xfa" + # 64-bit Little-endian Mach-O File + read_mach_o_le(f, 64) + when "\xca\xfe" + # Universal binary + read_mach_o_unversal(f) else - # HP-UX(32-bit), AIX, Mac OS X and Tru64 + # AIX and Tru64 raise format("unknown file header: %02x %02x", file_header[0], file_header[1]) end ensure @@ -202,6 +217,79 @@ raise "Invalid coff machine: #{machine}" end end + + # HP-UX PA-RISC(32 bit) + def read_parisc(f) + # 0-1 system_id - CPU_PA_RISC1_1 + @file_format = :pa_risc + # 2-3 a_magic - SHL_MAGIC + raise 'invalid a_magic' if f.read(2).unpack('n')[0] != 0x10e + @bits = 32 + @endian = :big + @cpu = :parisc + end + + # Big-endian Mach-O File + def read_mach_o_be(f) + @file_format = :mach_o + @endian = :big + case f.read(2) + when "\xfa\xce" # feedface + @cpu = :ppc + @bits = 32 + when "\xfa\xcf" # feedfacf + @cpu = :ppc64 + @bits = 64 + else + raise "unknown file format" + end + end + + def read_mach_o_le(f, bits) + @file_format = :mach_o + @endian = :little + raise 'unknown file format' if f.read(2) != "\xed\xfe" + case bits + when 32 + @cpu = :i386 + @bits = 32 + when 64 + @cpu = :x86_64 + @bits = 64 + end + end + + def read_mach_o_unversal(f) + raise 'unknown file format' if f.read(2) != "\xba\xbe" # cafebabe + @file_format = :universal + nfat_arch = f.read(4).unpack('N')[0] + @cpu = [] + @endian = [] + @bits = [] + nfat_arch.times do + case cputype = f.read(4).unpack('N')[0] + when 7 + @cpu << :i386 + @endian << :little + @bits << 32 + when 7 + 0x01000000 + @cpu << :x86_64 + @endian << :little + @bits << 64 + when 18 + @cpu << :ppc + @endian << :big + @bits << 32 + when 18 + 0x01000000 + @cpu << :ppc64 + @endian << :big + @bits << 64 + else + raise "Unknown mach-o cputype: #{cputype}" + end + f.seek(4 * 4, IO::SEEK_CUR) + end + end end class OraConf @@ -335,6 +423,39 @@ when /darwin/ @@ld_envs = %w[DYLD_LIBRARY_PATH] so_ext = 'dylib' + check_proc = Proc.new do |file| + is_32bit = [0].pack('l!').size == 4 + is_big_endian = "\x01\x02".unpack('s') == 0x0102 + if is_32bit + if is_big_endian + this_cpu = :ppc # 32-bit big-endian + else + this_cpu = :i386 # 32-bit little-endian + end + else + if is_big_endian + this_cpu = :ppc64 # 64-bit big-endian + else + this_cpu = :x86_64 # 64-bit little-endian + end + end + so = MiniSOReader.new(file) + if so.file_format == :universal + if so.cpu.include? this_cpu + true + else + puts " skip: #{file} is for #{so.cpu} cpu." + false + end + else + if so.cpu == this_cpu + true + else + puts " skip: #{file} is for #{so.cpu} cpu." + false + end + end + end end glob_name = "#{oci_basename}.#{so_ext}#{oci_glob_postfix}" From nobody at rubyforge.org Tue Dec 30 04:03:05 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Tue, 30 Dec 2008 04:03:05 -0500 (EST) Subject: [ruby-oci8-commit] [301] branches/ruby-oci8-1.0: * ext/oci8/const.c, ext/oci8/handle.c: suppress compilation warnings. Message-ID: <20081230090305.DA2A0185859A@rubyforge.org> Revision: 301 Author: kubo Date: 2008-12-30 04:03:05 -0500 (Tue, 30 Dec 2008) Log Message: ----------- * ext/oci8/const.c, ext/oci8/handle.c: suppress compilation warnings. (contributed by Daniel Berger) Modified Paths: -------------- branches/ruby-oci8-1.0/ChangeLog branches/ruby-oci8-1.0/ext/oci8/const.c branches/ruby-oci8-1.0/ext/oci8/handle.c Modified: branches/ruby-oci8-1.0/ChangeLog =================================================================== --- branches/ruby-oci8-1.0/ChangeLog 2008-12-30 07:23:14 UTC (rev 300) +++ branches/ruby-oci8-1.0/ChangeLog 2008-12-30 09:03:05 UTC (rev 301) @@ -1,4 +1,8 @@ 2008-12-30 KUBO Takehiro + * ext/oci8/const.c, ext/oci8/handle.c: suppress compilation warnings. + (contributed by Daniel Berger) + +2008-12-30 KUBO Takehiro * ext/oci8/oraconf.rb: add code to check the cpu type of Mac OS X libclntsh.dylib. Modified: branches/ruby-oci8-1.0/ext/oci8/const.c =================================================================== --- branches/ruby-oci8-1.0/ext/oci8/const.c 2008-12-30 07:23:14 UTC (rev 300) +++ branches/ruby-oci8-1.0/ext/oci8/const.c 2008-12-30 09:03:05 UTC (rev 301) @@ -45,7 +45,7 @@ static VALUE oci8_make_names(oci8_names_t *names, size_t size) { volatile VALUE ary; - int i; + unsigned int i; ary = rb_ary_new(); for (i = 0;i < size;i++) @@ -55,7 +55,7 @@ void Init_oci8_const(void) { - int i; + unsigned int i; oci8_id_code = rb_intern("code"); oci8_id_define_array = rb_intern("define_array"); Modified: branches/ruby-oci8-1.0/ext/oci8/handle.c =================================================================== --- branches/ruby-oci8-1.0/ext/oci8/handle.c 2008-12-30 07:23:14 UTC (rev 300) +++ branches/ruby-oci8-1.0/ext/oci8/handle.c 2008-12-30 09:03:05 UTC (rev 301) @@ -13,7 +13,7 @@ static void oci8_handle_do_free(oci8_handle_t *h) { - int i; + unsigned int i; if (h->type == 0) { return; } @@ -104,7 +104,7 @@ static void oci8_handle_mark(oci8_handle_t *h) { oci8_bind_handle_t *bh; - int i; + unsigned int i; switch (h->type) { case OCI_HTYPE_SVCCTX: @@ -221,8 +221,8 @@ void oci8_link(oci8_handle_t *parent, oci8_handle_t *child) { - int i; - int new_size; + unsigned int i; + int new_size, n; if (parent == NULL) return; @@ -238,8 +238,8 @@ new_size = parent->size + CHILDREN_ARRAY_GROW_SIZE; parent->children = xrealloc(parent->children, sizeof(oci8_handle_t *) * new_size); parent->children[parent->size] = child; - for (i = parent->size + 1;i < new_size;i++) { - parent->children[i] = NULL; + for (n = parent->size + 1;n < new_size;n++) { + parent->children[n] = NULL; } parent->size = new_size; return; @@ -248,7 +248,7 @@ void oci8_unlink(oci8_handle_t *self) { oci8_handle_t *parent = self->parent; - int i; + unsigned int i; if (self->parent == NULL) return; From nobody at rubyforge.org Tue Dec 30 06:13:47 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Tue, 30 Dec 2008 06:13:47 -0500 (EST) Subject: [ruby-oci8-commit] [302] branches/ruby-oci8-1.0: * ext/oci8/handle.c, ext/oci8/oci8.h, ext/ oci8/svcctx.c: add Message-ID: <20081230111347.4BB2B1588059@rubyforge.org> Revision: 302 Author: kubo Date: 2008-12-30 06:13:46 -0500 (Tue, 30 Dec 2008) Log Message: ----------- * ext/oci8/handle.c, ext/oci8/oci8.h, ext/oci8/svcctx.c: add OCISvcCtx.pid, which returns id of the process where the OCISvcCtx is created. * lib/oci8.rb.in: add check code to ensure that the process id is not changed. Modified Paths: -------------- branches/ruby-oci8-1.0/ChangeLog branches/ruby-oci8-1.0/ext/oci8/handle.c branches/ruby-oci8-1.0/ext/oci8/oci8.h branches/ruby-oci8-1.0/ext/oci8/svcctx.c branches/ruby-oci8-1.0/lib/oci8.rb.in Modified: branches/ruby-oci8-1.0/ChangeLog =================================================================== --- branches/ruby-oci8-1.0/ChangeLog 2008-12-30 09:03:05 UTC (rev 301) +++ branches/ruby-oci8-1.0/ChangeLog 2008-12-30 11:13:46 UTC (rev 302) @@ -1,4 +1,11 @@ 2008-12-30 KUBO Takehiro + * ext/oci8/handle.c, ext/oci8/oci8.h, ext/oci8/svcctx.c: add + OCISvcCtx.pid, which returns id of the process where the + OCISvcCtx is created. + * lib/oci8.rb.in: add check code to ensure that the process id + is not changed. + +2008-12-30 KUBO Takehiro * ext/oci8/const.c, ext/oci8/handle.c: suppress compilation warnings. (contributed by Daniel Berger) Modified: branches/ruby-oci8-1.0/ext/oci8/handle.c =================================================================== --- branches/ruby-oci8-1.0/ext/oci8/handle.c 2008-12-30 09:03:05 UTC (rev 301) +++ branches/ruby-oci8-1.0/ext/oci8/handle.c 2008-12-30 11:13:46 UTC (rev 302) @@ -10,7 +10,17 @@ =end */ #include "oci8.h" +#ifdef HAVE_UNISTD_H +#include /* getpid() */ +#endif +#ifdef WIN32 +#ifndef getpid +extern rb_pid_t rb_w32_getpid(void); +#define getpid() rb_w32_getpid() +#endif +#endif + static void oci8_handle_do_free(oci8_handle_t *h) { unsigned int i; @@ -149,6 +159,7 @@ break; case OCI_HTYPE_SVCCTX: obj = Data_Make_Struct(cOCISvcCtx, oci8_handle_t, oci8_handle_mark, oci8_handle_cleanup, h); + h->u.svcctx.pid = getpid(); break; case OCI_HTYPE_STMT: obj = Data_Make_Struct(cOCIStmt, oci8_handle_t, oci8_handle_mark, oci8_handle_cleanup, h); Modified: branches/ruby-oci8-1.0/ext/oci8/oci8.h =================================================================== --- branches/ruby-oci8-1.0/ext/oci8/oci8.h 2008-12-30 09:03:05 UTC (rev 301) +++ branches/ruby-oci8-1.0/ext/oci8/oci8.h 2008-12-30 11:13:46 UTC (rev 302) @@ -10,6 +10,14 @@ #include "rubyio.h" #include "intern.h" +#ifndef rb_pid_t +#ifdef WIN32 +#define rb_pid_t int +#else +#define rb_pid_t pid_t +#endif +#endif + #include #include #ifdef __cplusplus @@ -134,6 +142,9 @@ int char_width; } lob_locator; #endif + struct { + rb_pid_t pid; + } svcctx; } u; }; typedef struct oci8_handle oci8_handle_t; Modified: branches/ruby-oci8-1.0/ext/oci8/svcctx.c =================================================================== --- branches/ruby-oci8-1.0/ext/oci8/svcctx.c 2008-12-30 09:03:05 UTC (rev 301) +++ branches/ruby-oci8-1.0/ext/oci8/svcctx.c 2008-12-30 11:13:46 UTC (rev 302) @@ -180,6 +180,14 @@ return self; } +static VALUE oci8_pid(VALUE self) +{ + oci8_handle_t *h; + + Get_Handle(self, h); /* 0 */ + return INT2FIX(h->u.svcctx.pid); +} + void Init_oci8_svcctx(void) { rb_define_method(cOCISvcCtx, "logoff", oci8_svcctx_logoff, 0); @@ -196,6 +204,7 @@ rb_define_method(cOCISvcCtx, "reset", oci8_reset, 0); #endif rb_define_method(cOCISvcCtx, "close_all_files", oci8_close_all_files, 0); + rb_define_method(cOCISvcCtx, "pid", oci8_pid, 0); } /* Modified: branches/ruby-oci8-1.0/lib/oci8.rb.in =================================================================== --- branches/ruby-oci8-1.0/lib/oci8.rb.in 2008-12-30 09:03:05 UTC (rev 301) +++ branches/ruby-oci8-1.0/lib/oci8.rb.in 2008-12-30 11:13:46 UTC (rev 302) @@ -679,6 +679,9 @@ end def initialize(env, svc, ctx, stmt = nil) + if Process.pid != svc.pid + raise "The connection cannot be reused in the forked process." + end @env = env @svc = svc @ctx = ctx From nobody at rubyforge.org Tue Dec 30 08:39:05 2008 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Tue, 30 Dec 2008 08:39:05 -0500 (EST) Subject: [ruby-oci8-commit] [303] trunk/ruby-oci8: * ext/oci8/attr.c: rewrite code converting the rowid descriptor Message-ID: <20081230133905.E4EE118581B0@rubyforge.org> Revision: 303 Author: kubo Date: 2008-12-30 08:39:05 -0500 (Tue, 30 Dec 2008) Log Message: ----------- * ext/oci8/attr.c: rewrite code converting the rowid descriptor to string representation by using oci8_exec_sql(). * ext/oci8/oci8.c, ext/oci8/oci8.h, ext/oci8/oci8lib.c, ext/oci8/stmt.c: add check code to ensure that the process id is not changed. Modified Paths: -------------- trunk/ruby-oci8/ChangeLog trunk/ruby-oci8/ext/oci8/attr.c trunk/ruby-oci8/ext/oci8/oci8.c trunk/ruby-oci8/ext/oci8/oci8.h trunk/ruby-oci8/ext/oci8/oci8lib.c trunk/ruby-oci8/ext/oci8/stmt.c Modified: trunk/ruby-oci8/ChangeLog =================================================================== --- trunk/ruby-oci8/ChangeLog 2008-12-30 11:13:46 UTC (rev 302) +++ trunk/ruby-oci8/ChangeLog 2008-12-30 13:39:05 UTC (rev 303) @@ -1,4 +1,11 @@ 2008-12-30 KUBO Takehiro + * ext/oci8/attr.c: rewrite code converting the rowid descriptor + to string representation by using oci8_exec_sql(). + * ext/oci8/oci8.c, ext/oci8/oci8.h, ext/oci8/oci8lib.c, + ext/oci8/stmt.c: add check code to ensure that the process id + is not changed. + +2008-12-30 KUBO Takehiro * ext/oci8/oraconf.rb: add code to check the cpu type of Mac OS X libclntsh.dylib. Modified: trunk/ruby-oci8/ext/oci8/attr.c =================================================================== --- trunk/ruby-oci8/ext/oci8/attr.c 2008-12-30 11:13:46 UTC (rev 302) +++ trunk/ruby-oci8/ext/oci8/attr.c 2008-12-30 13:39:05 UTC (rev 303) @@ -75,7 +75,6 @@ oci8_base_t *base; ub4 attrtype; OCIRowid *ridp; - OCIStmt *stmtp; } rowid_arg_t; static VALUE get_rowid_attr(rowid_arg_t *arg) @@ -86,7 +85,7 @@ ub2 buflen; sword rv; - /* get a rowid descriptor from OCIHandle */ + /* get a rowid descriptor from OCIHandle */ rv = OCIDescriptorAlloc(oci8_envhp, (dvoid*)&arg->ridp, OCI_DTYPE_ROWID, 0, NULL); if (rv != OCI_SUCCESS) oci8_env_raise(oci8_envhp, rv); @@ -107,9 +106,7 @@ * Oracle Server. */ oci8_base_t *svc; - OCIBind *bind1 = NULL; - OCIBind *bind2 = NULL; - sword rv; + oci8_exec_sql_var_t bind_vars[2]; /* search a connection from the handle */ svc = base; @@ -119,43 +116,29 @@ rb_raise(rb_eRuntimeError, "No connection is found!!"); } } - /* - * equivalent code: - * cursor = conn.parse("BEGIN :1 := :2; END;") - * cursor.bind(1, nil, String, MAX_ROWID_LEN) - * cursor.bind(2, rowid, OCIRowid) - * cursor.exec() - * cursor[1] # => rowid's string representation - */ -#define ROWIDTOCHAR_SQL "BEGIN :1 := :2; END;" - buflen = 0; - rv = OCIHandleAlloc(oci8_envhp, (dvoid*)&arg->stmtp, OCI_HTYPE_STMT, 0, NULL); - if (rv != OCI_SUCCESS) { - oci8_env_raise(oci8_envhp, rv); + /* :strval */ + bind_vars[0].valuep = buf; + bind_vars[0].value_sz = sizeof(buf); + bind_vars[0].dty = SQLT_CHR; + bind_vars[0].indp = NULL; + bind_vars[0].alenp = &buflen; + /* :rowid */ + bind_vars[1].valuep = &arg->ridp; + bind_vars[1].value_sz = sizeof(void *); + bind_vars[1].dty = SQLT_RDD; + bind_vars[1].indp = NULL; + bind_vars[1].alenp = NULL; + /* convert the rowid descriptor to a string value by querying Oracle server. */ + oci8_exec_sql((oci8_svcctx_t*)svc, "BEGIN :strval := :rowid; END;", 0, NULL, 2, bind_vars, 1); + if (buflen == 0) { + return Qnil; } - oci_lc(OCIStmtPrepare(arg->stmtp, oci8_errhp, (text*)ROWIDTOCHAR_SQL, strlen(ROWIDTOCHAR_SQL), OCI_NTV_SYNTAX, OCI_DEFAULT)); - oci_lc(OCIBindByPos(arg->stmtp, &bind1, oci8_errhp, 1, buf, MAX_ROWID_LEN, SQLT_STR, NULL, &buflen, 0, 0, 0, OCI_DEFAULT)); - oci_lc(OCIBindByPos(arg->stmtp, &bind2, oci8_errhp, 2, (dvoid*)&arg->ridp, sizeof(void*), SQLT_RDD, NULL, NULL, 0, 0, 0, OCI_DEFAULT)); - rv = OCIStmtExecute_nb((oci8_svcctx_t*)svc, svc->hp.svc, arg->stmtp, oci8_errhp, 1, 0, NULL, NULL, OCI_DEFAULT); - if (rv == OCI_ERROR) { - if (oci8_get_error_code(oci8_errhp) == 1000) { - /* run GC to close unreferred cursors - * when ORA-01000 (maximum open cursors exceeded). - */ - rb_gc(); - rv = OCIStmtExecute_nb((oci8_svcctx_t*)svc, svc->hp.svc, arg->stmtp, oci8_errhp, 1, 0, NULL, NULL, OCI_DEFAULT); - } - } - oci_lc(rv); } return rb_str_new(buf, buflen); } static VALUE rowid_ensure(rowid_arg_t *arg) { - if (arg->stmtp != NULL) { - OCIHandleFree(arg->stmtp, OCI_HTYPE_STMT); - } if (arg->ridp != NULL) { OCIDescriptorFree(arg->ridp, OCI_DTYPE_ROWID); } @@ -168,6 +151,5 @@ arg.base = base; arg.attrtype = attrtype; arg.ridp = NULL; - arg.stmtp = NULL; return rb_ensure(get_rowid_attr, (VALUE)&arg, rowid_ensure, (VALUE)&arg); } Modified: trunk/ruby-oci8/ext/oci8/oci8.c =================================================================== --- trunk/ruby-oci8/ext/oci8/oci8.c 2008-12-30 11:13:46 UTC (rev 302) +++ trunk/ruby-oci8/ext/oci8/oci8.c 2008-12-30 13:39:05 UTC (rev 303) @@ -6,7 +6,17 @@ * */ #include "oci8.h" +#ifdef HAVE_UNISTD_H +#include /* getpid() */ +#endif +#ifdef WIN32 +#ifndef getpid +extern rb_pid_t rb_w32_getpid(void); +#define getpid() rb_w32_getpid() +#endif +#endif + /* * Document-class: OCI8 * @@ -236,6 +246,7 @@ default: break; } + svcctx->pid = getpid(); svcctx->is_autocommit = 0; #ifdef RUBY_VM svcctx->non_blocking = 0; @@ -565,3 +576,11 @@ } return svcctx->authhp; } + +void oci8_check_pid_consistency(oci8_svcctx_t *svcctx) +{ + if (svcctx->pid != getpid()) { + rb_raise(rb_eRuntimeError, "The connection cannot be reused in the forked process."); + } +} + Modified: trunk/ruby-oci8/ext/oci8/oci8.h =================================================================== --- trunk/ruby-oci8/ext/oci8/oci8.h 2008-12-30 11:13:46 UTC (rev 302) +++ trunk/ruby-oci8/ext/oci8/oci8.h 2008-12-30 13:39:05 UTC (rev 303) @@ -12,9 +12,18 @@ #include "intern.h" #endif +#ifndef rb_pid_t +#ifdef WIN32 +#define rb_pid_t int +#else +#define rb_pid_t pid_t +#endif +#endif + #include #include #include + #ifdef __cplusplus extern "C" { @@ -234,6 +243,7 @@ enum logon_type_t logon_type; OCISession *authhp; OCIServer *srvhp; + rb_pid_t pid; char is_autocommit; #ifdef RUBY_VM char non_blocking; @@ -335,6 +345,7 @@ oci8_svcctx_t *oci8_get_svcctx(VALUE obj); OCISvcCtx *oci8_get_oci_svcctx(VALUE obj); OCISession *oci8_get_oci_session(VALUE obj); +void oci8_check_pid_consistency(oci8_svcctx_t *svcctx); #define TO_SVCCTX oci8_get_oci_svcctx #define TO_SESSION oci8_get_oci_session Modified: trunk/ruby-oci8/ext/oci8/oci8lib.c =================================================================== --- trunk/ruby-oci8/ext/oci8/oci8lib.c 2008-12-30 11:13:46 UTC (rev 302) +++ trunk/ruby-oci8/ext/oci8/oci8lib.c 2008-12-30 13:39:05 UTC (rev 303) @@ -317,6 +317,8 @@ sword oci8_exec_sql(oci8_svcctx_t *svcctx, const char *sql_text, ub4 num_define_vars, oci8_exec_sql_var_t *define_vars, ub4 num_bind_vars, oci8_exec_sql_var_t *bind_vars, int raise_on_error) { cb_arg_t arg; + + oci8_check_pid_consistency(svcctx); arg.svcctx = svcctx; arg.sql_text = sql_text; arg.num_define_vars = num_define_vars; Modified: trunk/ruby-oci8/ext/oci8/stmt.c =================================================================== --- trunk/ruby-oci8/ext/oci8/stmt.c 2008-12-30 11:13:46 UTC (rev 302) +++ trunk/ruby-oci8/ext/oci8/stmt.c 2008-12-30 13:39:05 UTC (rev 303) @@ -67,7 +67,7 @@ rb_scan_args(argc, argv, "11", &svc, &sql); - oci8_get_svcctx(svc); /* check argument */ + oci8_check_pid_consistency(oci8_get_svcctx(svc)); if (argc > 1) StringValue(sql);