sedna 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. data/{CHANGES → CHANGES.rdoc} +9 -0
  2. data/{README → README.rdoc} +23 -25
  3. data/Rakefile +32 -9
  4. data/ext/{extconf.rb → sedna/extconf.rb} +33 -21
  5. data/ext/{sedna.c → sedna/sedna.c} +48 -40
  6. data/test/sedna_test.rb +9 -9
  7. data/vendor/sedna/AUTHORS +18 -0
  8. data/vendor/sedna/COPYRIGHT +90 -0
  9. data/vendor/sedna/LICENSE +202 -0
  10. data/vendor/sedna/Makefile.include +423 -0
  11. data/vendor/sedna/Makefile.platform +31 -0
  12. data/vendor/sedna/depend.sed +48 -0
  13. data/vendor/sedna/driver/c/Makefile +98 -0
  14. data/vendor/sedna/driver/c/libsedna.c +1998 -0
  15. data/vendor/sedna/driver/c/libsedna.h +199 -0
  16. data/vendor/sedna/driver/c/sednamt.def +21 -0
  17. data/vendor/sedna/driver/c/sp_defs.h +186 -0
  18. data/vendor/sedna/kernel/common/FastXptrHash.cpp +101 -0
  19. data/vendor/sedna/kernel/common/IntHash.h +314 -0
  20. data/vendor/sedna/kernel/common/IntList.h +224 -0
  21. data/vendor/sedna/kernel/common/Makefile +30 -0
  22. data/vendor/sedna/kernel/common/SSMMsg.cpp +459 -0
  23. data/vendor/sedna/kernel/common/SSMMsg.h +142 -0
  24. data/vendor/sedna/kernel/common/XptrHash.h +435 -0
  25. data/vendor/sedna/kernel/common/argtable.c +972 -0
  26. data/vendor/sedna/kernel/common/argtable.h +896 -0
  27. data/vendor/sedna/kernel/common/base.cpp +339 -0
  28. data/vendor/sedna/kernel/common/base.h +226 -0
  29. data/vendor/sedna/kernel/common/bit_set.cpp +157 -0
  30. data/vendor/sedna/kernel/common/bit_set.h +55 -0
  31. data/vendor/sedna/kernel/common/commutil.h +67 -0
  32. data/vendor/sedna/kernel/common/config.h +62 -0
  33. data/vendor/sedna/kernel/common/counted_ptr.h +74 -0
  34. data/vendor/sedna/kernel/common/errdbg/ErrorCodes.java +1056 -0
  35. data/vendor/sedna/kernel/common/errdbg/Makefile +34 -0
  36. data/vendor/sedna/kernel/common/errdbg/assert.c +133 -0
  37. data/vendor/sedna/kernel/common/errdbg/d_printf.c +150 -0
  38. data/vendor/sedna/kernel/common/errdbg/d_printf.h +91 -0
  39. data/vendor/sedna/kernel/common/errdbg/error.codes +1743 -0
  40. data/vendor/sedna/kernel/common/errdbg/error_codes.c +531 -0
  41. data/vendor/sedna/kernel/common/errdbg/error_codes.h +549 -0
  42. data/vendor/sedna/kernel/common/errdbg/error_codes_scm.scm +527 -0
  43. data/vendor/sedna/kernel/common/errdbg/event_log.c +956 -0
  44. data/vendor/sedna/kernel/common/errdbg/event_log.h +226 -0
  45. data/vendor/sedna/kernel/common/errdbg/exceptions.cpp +155 -0
  46. data/vendor/sedna/kernel/common/errdbg/exceptions.h +559 -0
  47. data/vendor/sedna/kernel/common/errdbg/gen_error_codes +0 -0
  48. data/vendor/sedna/kernel/common/errdbg/gen_error_codes.c +345 -0
  49. data/vendor/sedna/kernel/common/gmm.cpp +192 -0
  50. data/vendor/sedna/kernel/common/gmm.h +29 -0
  51. data/vendor/sedna/kernel/common/ipc_ops.cpp +435 -0
  52. data/vendor/sedna/kernel/common/ipc_ops.h +51 -0
  53. data/vendor/sedna/kernel/common/lfsGlobals.h +12 -0
  54. data/vendor/sedna/kernel/common/lm_base.h +90 -0
  55. data/vendor/sedna/kernel/common/mmgr/Makefile +11 -0
  56. data/vendor/sedna/kernel/common/mmgr/aset.c +1185 -0
  57. data/vendor/sedna/kernel/common/mmgr/mcxt.c +741 -0
  58. data/vendor/sedna/kernel/common/mmgr/memnodes.h +70 -0
  59. data/vendor/sedna/kernel/common/mmgr/memutils.h +145 -0
  60. data/vendor/sedna/kernel/common/mmgr/se_alloc.h +321 -0
  61. data/vendor/sedna/kernel/common/mmgr/track.c +214 -0
  62. data/vendor/sedna/kernel/common/pping.cpp +672 -0
  63. data/vendor/sedna/kernel/common/pping.h +119 -0
  64. data/vendor/sedna/kernel/common/rcv_test.cpp +273 -0
  65. data/vendor/sedna/kernel/common/rcv_test.h +19 -0
  66. data/vendor/sedna/kernel/common/sedna.c +128 -0
  67. data/vendor/sedna/kernel/common/sedna.h +49 -0
  68. data/vendor/sedna/kernel/common/sedna_ef.h +52 -0
  69. data/vendor/sedna/kernel/common/sm_vmm_data.h +144 -0
  70. data/vendor/sedna/kernel/common/sp.c +93 -0
  71. data/vendor/sedna/kernel/common/sp.h +36 -0
  72. data/vendor/sedna/kernel/common/st/Makefile +20 -0
  73. data/vendor/sedna/kernel/common/st/os_linux/stacktrace.c +213 -0
  74. data/vendor/sedna/kernel/common/st/os_nt/stacktrace.c +338 -0
  75. data/vendor/sedna/kernel/common/st/os_other/stacktrace.c +39 -0
  76. data/vendor/sedna/kernel/common/st/stacktrace.h +72 -0
  77. data/vendor/sedna/kernel/common/st/stacktrfmt.c +64 -0
  78. data/vendor/sedna/kernel/common/tr_debug.cpp +112 -0
  79. data/vendor/sedna/kernel/common/tr_debug.h +22 -0
  80. data/vendor/sedna/kernel/common/u/Makefile +14 -0
  81. data/vendor/sedna/kernel/common/u/u.c +268 -0
  82. data/vendor/sedna/kernel/common/u/u.h +715 -0
  83. data/vendor/sedna/kernel/common/u/uatomic.h +12 -0
  84. data/vendor/sedna/kernel/common/u/udl.h +31 -0
  85. data/vendor/sedna/kernel/common/u/uevent.c +406 -0
  86. data/vendor/sedna/kernel/common/u/uevent.h +71 -0
  87. data/vendor/sedna/kernel/common/u/ugnames.cpp +330 -0
  88. data/vendor/sedna/kernel/common/u/ugnames.h +134 -0
  89. data/vendor/sedna/kernel/common/u/uhash_map.h +77 -0
  90. data/vendor/sedna/kernel/common/u/uhdd.c +1018 -0
  91. data/vendor/sedna/kernel/common/u/uhdd.h +206 -0
  92. data/vendor/sedna/kernel/common/u/ummap.cpp +268 -0
  93. data/vendor/sedna/kernel/common/u/ummap.h +60 -0
  94. data/vendor/sedna/kernel/common/u/umutex.c +145 -0
  95. data/vendor/sedna/kernel/common/u/umutex.h +65 -0
  96. data/vendor/sedna/kernel/common/u/upipe.cpp +244 -0
  97. data/vendor/sedna/kernel/common/u/upipe.h +74 -0
  98. data/vendor/sedna/kernel/common/u/uprocess.c +767 -0
  99. data/vendor/sedna/kernel/common/u/uprocess.h +91 -0
  100. data/vendor/sedna/kernel/common/u/usafesync.h +41 -0
  101. data/vendor/sedna/kernel/common/u/usecurity.c +150 -0
  102. data/vendor/sedna/kernel/common/u/usecurity.h +55 -0
  103. data/vendor/sedna/kernel/common/u/usem.c +891 -0
  104. data/vendor/sedna/kernel/common/u/usem.h +83 -0
  105. data/vendor/sedna/kernel/common/u/ushm.c +222 -0
  106. data/vendor/sedna/kernel/common/u/ushm.h +46 -0
  107. data/vendor/sedna/kernel/common/u/usocket.c +541 -0
  108. data/vendor/sedna/kernel/common/u/usocket.h +118 -0
  109. data/vendor/sedna/kernel/common/u/usystem.c +57 -0
  110. data/vendor/sedna/kernel/common/u/usystem.h +46 -0
  111. data/vendor/sedna/kernel/common/u/uthread.c +259 -0
  112. data/vendor/sedna/kernel/common/u/uthread.h +95 -0
  113. data/vendor/sedna/kernel/common/u/utime.c +65 -0
  114. data/vendor/sedna/kernel/common/u/utime.h +40 -0
  115. data/vendor/sedna/kernel/common/u/uutils.c +142 -0
  116. data/vendor/sedna/kernel/common/u/uutils.h +65 -0
  117. data/vendor/sedna/kernel/common/ugc.cpp +156 -0
  118. data/vendor/sedna/kernel/common/ugc.h +15 -0
  119. data/vendor/sedna/kernel/common/utils.cpp +156 -0
  120. data/vendor/sedna/kernel/common/utils.h +133 -0
  121. data/vendor/sedna/kernel/common/version.c +16 -0
  122. data/vendor/sedna/kernel/common/version.h +21 -0
  123. data/vendor/sedna/kernel/common/wustructures.h +18 -0
  124. data/vendor/sedna/kernel/common/wutypes.h +34 -0
  125. data/vendor/sedna/kernel/common/xptr.cpp +17 -0
  126. data/vendor/sedna/kernel/common/xptr.h +211 -0
  127. data/vendor/sedna/ver +1 -0
  128. metadata +142 -14
@@ -1,3 +1,12 @@
1
+ === 0.6.0
2
+
3
+ * Released on May 29th, 2010.
4
+ * Bundled Sedna driver from version 3.3.55 (protocol version 3.0). The bundled
5
+ driver is now used by default to simplify installation.
6
+ * Fixed build errors on Mac OS X 10.6.
7
+ * Unit test compatibility with Sedna 3.3.
8
+ * Fully tested in Ruby 1.8.6+ (including 1.9.2-preview2) and Rubinius 1.0.
9
+
1
10
  === 0.5.1
2
11
 
3
12
  * Released on January 23th, 2010.
@@ -1,18 +1,18 @@
1
- = \Sedna XML database client library
1
+ = S<i></i>edna XML database client library
2
2
 
3
3
  This library provides a Ruby client for <i>Sedna</i>, an open-source, native XML
4
4
  database system. The client is a Ruby extension that uses the official C
5
5
  driver that is shipped as part of the S<i></i>edna distribution.
6
6
 
7
- \Sedna provides a full range of core database services -- persistent storage,
7
+ S<i></i>edna provides a full range of core database services -- persistent storage,
8
8
  ACID transactions, security, indices, hot backup. Flexible XML processing
9
9
  facilities include W3C XQuery implementation, tight integration of XQuery with
10
10
  full-text search facilities and a node-level update language.
11
11
 
12
- For more information about the \Sedna XML database system, see the project page
12
+ For more information about the S<i></i>edna XML database system, see the project page
13
13
  at http://modis.ispras.ru/sedna
14
14
 
15
- === About the client library
15
+ == About the client library
16
16
 
17
17
  Author: Rolf Timmermans (r.timmermans <i>at</i> voormedia.com)
18
18
 
@@ -30,40 +30,38 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30
30
  See the License for the specific language governing permissions and
31
31
  limitations under the License.
32
32
 
33
- === Current version
33
+ == Current version
34
34
 
35
- The current version of this library is 0.5.1. This is a <b>stable release</b>.
36
- For a complete overview all recent and previous changes, see CHANGES.
35
+ The current version of this library is 0.6.0. This is a <b>stable release</b>.
36
+ For a complete overview all recent and previous changes, see CHANGES.rdoc.
37
37
 
38
- === Requirements
38
+ == Requirements
39
39
 
40
- Before installing the \Sedna client library, make sure you have the library and
41
- header files of the C driver. They are shipped and installed as part of the binary
42
- distribution of \Sedna. When installing, choose either <tt>/usr/local/sedna</tt> or
43
- <tt>/opt/sedna</tt> as target locations.
40
+ The S<i></i>edna client library ships with a copy of the official C driver, which
41
+ will be built for your platform automatically when you install it.
44
42
 
45
- The library has been tested with Ruby 1.8.5 and above, including Ruby 1.9.
43
+ The library has been tested with Ruby 1.8.6 and above, including Ruby 1.9.1 and
44
+ Ruby 1.9.2.
46
45
 
47
- === Installation
46
+ == Installation
48
47
 
49
- After installing the \Sedna C driver (see above), simply install the Ruby client
50
- library as a rubygem.
48
+ Install the Ruby client library as a gem.
51
49
 
52
50
  % gem install sedna
53
51
 
54
- If the library or header files of the \Sedna C driver are located at non-default
55
- locations, you can specify these locations by adding the <tt>--with-sedna-bin</tt>
56
- options when installing.
52
+ If you do not wish to use the bundled driver, you have the option to use a
53
+ version installed on your system. You can specify in which location the
54
+ library and header files located by adding the <tt>--with-sedna-dir</tt>
55
+ option when installing.
57
56
 
58
- % gem install sedna -- --with-sedna-bin=/path/to/sedna
57
+ % gem install sedna -- --with-sedna-dir=/path/to/sedna
59
58
 
60
- === Usage
59
+ == Usage
61
60
 
62
- After installation of the gem, +require+ the sedna library in order to start
63
- using it.
61
+ After installation, +require+ the sedna library in order to start using it.
64
62
 
65
- require 'rubygems'
66
- require 'sedna'
63
+ require "rubygems"
64
+ require "sedna"
67
65
 
68
66
  To start querying a database, create a new connection with the Sedna.connect
69
67
  method. When a block is given, the Sedna connection object will be returned
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2008, 2009 Voormedia B.V.
1
+ # Copyright 2008-2010 Voormedia B.V.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -35,16 +35,18 @@ end
35
35
 
36
36
  desc "Build the Ruby extension"
37
37
  task :build do
38
- Dir.chdir "ext"
38
+ Dir.chdir "ext/sedna"
39
39
  ruby "extconf.rb"
40
40
  sh "make"
41
- Dir.chdir ".."
41
+ Dir.chdir "../.."
42
42
  end
43
43
 
44
44
  desc "Remove build products"
45
45
  task :clobber_build do
46
- sh "rm -f ext/*.{so,o,log}"
47
- sh "rm -f ext/Makefile"
46
+ sh "rm -f ext/**/*.{so,o,log,bundle}"
47
+ sh "rm -f ext/**/Makefile"
48
+ sh "rm -rf ext/**/conftest.*"
49
+ system "cd vendor/sedna/driver/c && make clean"
48
50
  end
49
51
 
50
52
  desc "Force a rebuild of the Ruby extension"
@@ -57,7 +59,7 @@ end
57
59
 
58
60
  gem_spec = Gem::Specification.new do |s|
59
61
  s.name = "sedna"
60
- s.version = "0.5.1"
62
+ s.version = "0.6.0"
61
63
 
62
64
  s.summary = "Sedna XML DBMS client library."
63
65
  s.description = %{Ruby extension that provides a client library for the Sedna XML DBMS, making use of the official C driver of the Sedna project.}
@@ -67,13 +69,14 @@ gem_spec = Gem::Specification.new do |s|
67
69
  s.homepage = "http://sedna.rubyforge.org/"
68
70
  s.rubyforge_project = "sedna"
69
71
 
70
- s.extensions << "ext/extconf.rb"
71
- s.files = FileList["Rakefile", "ext/extconf.rb", "ext/**/*.c", "test/**/*.rb"].to_a
72
+ s.extensions << "ext/sedna/extconf.rb"
73
+ s.files = (FileList["Rakefile", "ext/**/extconf.rb", "ext/**/*.c", "test/**/*.rb"] + FileList["vendor/sedna/**/*"] -
74
+ FileList["vendor/sedna/**/{*.exp,*.so,*.o,*.a,*.bb,*.bbg,*.da,*.map,*.pdb,vc*.idb,*.SUP,*.d,*.d.*,generated}"]).to_a
72
75
  s.require_path = "lib"
73
76
 
74
77
  s.has_rdoc = true
75
78
  s.extra_rdoc_files = RDOC_FILES
76
- s.rdoc_options << "--title" << RDOC_TITLE << "--main" << "README"
79
+ s.rdoc_options << "--title" << RDOC_TITLE << "--main" << "README.rdoc"
77
80
 
78
81
  s.test_files = FileList["test/**/*_test.rb"].to_a
79
82
  end
@@ -90,3 +93,23 @@ Rake::RDocTask.new do |rdoc|
90
93
  rdoc.rdoc_files.include *RDOC_FILES
91
94
  rdoc.main = "README"
92
95
  end
96
+
97
+ namespace :driver do
98
+ task :update do
99
+ exit if ENV["SOURCE"].nil?
100
+ source = File.expand_path(File.join(File.dirname(__FILE__), ENV["SOURCE"]))
101
+ target = "vendor/sedna"
102
+ %x(rm -rf #{target} && mkdir -p #{target}/driver && mkdir -p #{target}/kernel)
103
+
104
+ %x(cp -r #{source}/{AUTHORS,COPYRIGHT,LICENSE} #{target})
105
+ %x(cp -r #{source}/{depend.sed,ver,Makefile.include,Makefile.platform} #{target})
106
+ %x(cp -r #{source}/driver/c #{target}/driver/c)
107
+ %x(cp -r #{source}/kernel/common #{target}/kernel/common)
108
+
109
+ u_h = File.read("#{target}/kernel/common/u/u.h")
110
+ u_h.gsub!("#include <ucontext.h>", "")
111
+ File.open("#{target}/kernel/common/u/u.h", "w") do |f|
112
+ f.write u_h
113
+ end
114
+ end
115
+ end
@@ -1,4 +1,4 @@
1
- # Copyright 2008, 2009 Voormedia B.V.
1
+ # Copyright 2008-2010 Voormedia B.V.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -19,25 +19,50 @@
19
19
 
20
20
  require "mkmf"
21
21
 
22
+ # Fail for old Rubies.
22
23
  if RUBY_VERSION < "1.8"
23
24
  puts "This library requires ruby 1.8."
24
25
  exit 1
25
26
  end
26
27
 
27
- driver = "/driver/c"
28
- default_driver_dirs = ["/usr/local/sedna#{driver}", "/opt/sedna#{driver}", File.expand_path("~/sedna#{driver}")]
29
- default_include_dirs = ["/usr/include", "/usr/include/sedna"] + default_driver_dirs
30
- default_lib_dirs = ["/usr/lib", "/usr/lib/sedna"] + default_driver_dirs
28
+ def set_arch(arch)
29
+ flags = "-arch #{arch}"
30
+ $CFLAGS.gsub!(/-arch\s+\S+ /, "")
31
+ $LDFLAGS.gsub!(/-arch\s+\S+ /, "")
32
+ CONFIG['LDSHARED'].gsub!(/-arch\s+\S+ /, "")
33
+
34
+ $CFLAGS << " " << flags
35
+ $LDFLAGS << " " << flags
36
+ CONFIG["LDSHARED"] << " " << flags
37
+ end
38
+
39
+ DRIVER = "/driver/c"
31
40
 
32
- # If user specified directories.
33
41
  idir, ldir = dir_config "sedna", nil, nil
34
42
  if idir.nil? or ldir.nil?
35
- idir, ldir = default_include_dirs, default_lib_dirs
43
+ driver_dir = File.expand_path("#{File.dirname(__FILE__)}/../../vendor/sedna/#{DRIVER}")
44
+
45
+ # Compile bundled driver.
46
+ system "cd #{driver_dir} && make clean && make"
47
+
48
+ # Link to bundled driver.
49
+ idir = ldir = [driver_dir]
36
50
  else
37
- ldir = File.expand_path(ldir.sub("/lib", driver)) unless ldir.nil?
51
+ # Use user-specified driver.
52
+ ldir = File.expand_path(ldir.sub("/lib", DRIVER)) unless ldir.nil?
38
53
  idir = [File.expand_path(idir), ldir] unless idir.nil?
39
54
  end
40
55
 
56
+ # Fix multiple arch flags on Mac OS X.
57
+ if RUBY_PLATFORM.include?("darwin")
58
+ ldir.each do |libdir|
59
+ if File.exists?("#{libdir}/libsedna.a") and %x(which lipo && lipo -info #{libdir}/libsedna.a) =~ /architecture: (.+)$/
60
+ set_arch($1) unless $1 == "i386"
61
+ break
62
+ end
63
+ end
64
+ end
65
+
41
66
  if not find_library "sedna", "SEconnect", *ldir
42
67
  $stderr.write %{
43
68
  ==============================================================================
@@ -74,19 +99,6 @@ Could not find header file(s) for libsedna.
74
99
  exit 3
75
100
  end
76
101
 
77
- if CONFIG["arch"] =~ /x86_64/i and File.exist?(f = $LIBPATH.first + File::Separator + "libsedna.a")
78
- if system "/usr/bin/objdump --reloc \"#{f}\" 2>/dev/null | grep R_X86_64_32S >/dev/null && echo"
79
- $stderr.write %{==============================================================================
80
- Library libsedna.a was statically compiled for a 64-bit platform as position-
81
- dependent code. It will not be possible to create a Ruby shared library with
82
- this Sedna library. Recompile the library as position-independent code by
83
- passing the -fPIC option to gcc.
84
- ==============================================================================
85
- }
86
- exit 4
87
- end
88
- end
89
-
90
102
  have_func "rb_thread_blocking_region"
91
103
  have_func "rb_mutex_synchronize"
92
104
  have_func "rb_enc_str_buf_cat"
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2008, 2009 Voormedia B.V.
2
+ * Copyright 2008-2010 Voormedia B.V.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -70,17 +70,17 @@ typedef struct SednaConnection SC;
70
70
  // Define a struct for database queries.
71
71
  struct SednaQuery {
72
72
  void *conn;
73
- void *query;
73
+ char *query;
74
74
  };
75
75
  typedef struct SednaQuery SQ;
76
76
 
77
77
  // Define a struct for database connection arguments.
78
78
  struct SednaConnArgs {
79
79
  void *conn;
80
- void *host;
81
- void *db;
82
- void *user;
83
- void *pw;
80
+ char *host;
81
+ char *db;
82
+ char *user;
83
+ char *pw;
84
84
  };
85
85
  typedef struct SednaConnArgs SCA;
86
86
 
@@ -153,34 +153,34 @@ static void sedna_err(SC *conn, int res)
153
153
  // SEgetLastErrorCode(conn) is useless, because it varies if the order of
154
154
  // errors changes. The actual code is a string which is defined in error_codes.h
155
155
  // in the Sedna source code.
156
- code = strstr(msg, "ERROR ");
156
+ code = strstr(msg, "ERROR ");
157
157
  err = strstr(msg, "\n");
158
158
  details = strstr(err, "\nDetails: ");
159
159
 
160
- if(code != NULL) {
161
- code += 6; // Advance beyond "ERROR "
162
- if((p = strstr(code, "\n")) != NULL) strncpy(p, "\0", 1);
163
- }
160
+ if(code != NULL) {
161
+ code += 6; // Advance beyond "ERROR "
162
+ if((p = strstr(code, "\n")) != NULL) strncpy(p, "\0", 1);
163
+ }
164
164
 
165
165
  if(err != NULL) {
166
166
  err++; // Advance beyond "\n"
167
167
  if((p = strstr(err, "\n")) != NULL) strncpy(p, "\0", 1);
168
168
  } else {
169
- err = "Unknown error.";
169
+ err = strdup("Unknown error.");
170
170
  }
171
171
 
172
172
  if(details != NULL) {
173
173
  details += 10; // Advance beyond "\nDetails: "
174
174
  while((p = strstr(details, "\n")) != NULL) strncpy(p, " ", 1);
175
- snprintf(exc_message, BUFSIZ, "%s (%s)", err, details);
175
+ snprintf(exc_message, BUFSIZ, "%s (%s)", err, details);
176
176
  } else {
177
- snprintf(exc_message, BUFSIZ, "%s", err);
177
+ snprintf(exc_message, BUFSIZ, "%s", err);
178
+ }
179
+ exc = rb_exc_new2(exc_class, exc_message);
180
+ if(code != NULL) {
181
+ rb_iv_set(exc, IV_EXC_CODE, rb_str_new2(code));
178
182
  }
179
- exc = rb_exc_new2(exc_class, exc_message);
180
- if(code != NULL) {
181
- rb_iv_set(exc, IV_EXC_CODE, rb_str_new2(code));
182
- }
183
- rb_exc_raise(exc);
183
+ rb_exc_raise(exc);
184
184
  }
185
185
 
186
186
  // Retrieve the SednaConnection struct from the Ruby Sedna object obj.
@@ -401,7 +401,8 @@ static VALUE cSedna_s_new(VALUE klass)
401
401
  */
402
402
  static VALUE cSedna_initialize(VALUE self, VALUE options)
403
403
  {
404
- VALUE host_k, db_k, user_k, pw_k, host_v, db_v, user_v, pw_v;
404
+ VALUE host_k, db_k, user_k, pw_k,
405
+ host_v, db_v, user_v, pw_v;
405
406
  char *host, *db, *user, *pw;
406
407
 
407
408
  // Ensure the argument is a Hash.
@@ -409,21 +410,21 @@ static VALUE cSedna_initialize(VALUE self, VALUE options)
409
410
 
410
411
  // Store the symbols of the valid hash keys.
411
412
  host_k = ID2SYM(rb_intern("host"));
412
- db_k = ID2SYM(rb_intern("database"));
413
+ db_k = ID2SYM(rb_intern("database"));
413
414
  user_k = ID2SYM(rb_intern("username"));
414
- pw_k = ID2SYM(rb_intern("password"));
415
+ pw_k = ID2SYM(rb_intern("password"));
415
416
 
416
417
  // Get the connection details or set them to the default values if not given.
417
- if(NIL_P(host_v = rb_hash_aref(options, host_k))) host = DEFAULT_HOST; else host = STR2CSTR(host_v);
418
- if(NIL_P(db_v = rb_hash_aref(options, db_k))) db = DEFAULT_DB; else db = STR2CSTR(db_v);
419
- if(NIL_P(user_v = rb_hash_aref(options, user_k))) user = DEFAULT_USER; else user = STR2CSTR(user_v);
420
- if(NIL_P(pw_v = rb_hash_aref(options, pw_k))) pw = DEFAULT_PW; else pw = STR2CSTR(pw_v);
418
+ if(NIL_P(host_v = rb_hash_aref(options, host_k))) host = strdup(DEFAULT_HOST); else host = StringValuePtr(host_v);
419
+ if(NIL_P(db_v = rb_hash_aref(options, db_k ))) db = strdup(DEFAULT_DB); else db = StringValuePtr(db_v);
420
+ if(NIL_P(user_v = rb_hash_aref(options, user_k))) user = strdup(DEFAULT_USER); else user = StringValuePtr(user_v);
421
+ if(NIL_P(pw_v = rb_hash_aref(options, pw_k ))) pw = strdup(DEFAULT_PW); else pw = StringValuePtr(pw_v);
421
422
 
422
423
  // Save all connection details to instance variables.
423
424
  rb_iv_set(self, IV_HOST, rb_str_new2(host));
424
- rb_iv_set(self, IV_DB, rb_str_new2(db));
425
+ rb_iv_set(self, IV_DB, rb_str_new2(db));
425
426
  rb_iv_set(self, IV_USER, rb_str_new2(user));
426
- rb_iv_set(self, IV_PW, rb_str_new2(pw));
427
+ rb_iv_set(self, IV_PW, rb_str_new2(pw));
427
428
 
428
429
  #ifdef NON_BLOCKING
429
430
  // Create a mutex if this build supports non-blocking queries.
@@ -474,13 +475,19 @@ static VALUE cSedna_close(VALUE self)
474
475
  */
475
476
  static VALUE cSedna_reset(VALUE self)
476
477
  {
478
+ VALUE host_v, db_v, user_v, pw_v;
477
479
  SC *conn = sedna_struct(self);
478
480
 
479
481
  // First ensure the current connection is closed.
480
482
  sedna_close(conn);
481
483
 
482
484
  // Retrieve stored connection details.
483
- SCA c = { conn, STR2CSTR(rb_iv_get(self, IV_HOST)), STR2CSTR(rb_iv_get(self, IV_DB)), STR2CSTR(rb_iv_get(self, IV_USER)), STR2CSTR(rb_iv_get(self, IV_PW)) };
485
+ host_v = rb_iv_get(self, IV_HOST);
486
+ db_v = rb_iv_get(self, IV_DB);
487
+ user_v = rb_iv_get(self, IV_USER);
488
+ pw_v = rb_iv_get(self, IV_PW);
489
+
490
+ SCA c = { conn, StringValuePtr(host_v), StringValuePtr(db_v), StringValuePtr(user_v), StringValuePtr(pw_v) };
484
491
 
485
492
  // Connect to the database.
486
493
  sedna_connect(self, &c);
@@ -646,7 +653,7 @@ static VALUE cSedna_execute(VALUE self, VALUE query)
646
653
  SC *conn = sedna_struct(self);
647
654
 
648
655
  // Prepare query arguments.
649
- SQ q = { conn, STR2CSTR(query) };
656
+ SQ q = { conn, StringValuePtr(query) };
650
657
 
651
658
  // Verify that the connection is OK.
652
659
  if(SEconnectionStatus(conn) != SEDNA_CONNECTION_OK) rb_raise(cSednaConnError, "Connection is closed.");
@@ -709,14 +716,14 @@ static VALUE cSedna_load_document(int argc, VALUE *argv, VALUE self)
709
716
 
710
717
  // 2 mandatory arguments, 1 optional.
711
718
  rb_scan_args(argc, argv, "21", &document, &doc_name, &col_name);
712
- doc_name_c = STR2CSTR(doc_name);
713
- col_name_c = NIL_P(col_name) ? NULL : STR2CSTR(col_name);
719
+ doc_name_c = StringValuePtr(doc_name);
720
+ col_name_c = NIL_P(col_name) ? NULL : StringValuePtr(col_name);
714
721
 
715
722
  if(TYPE(document) == T_FILE) {
716
723
  // If the document is an IO object...
717
724
  while(!NIL_P(buf = rb_funcall(document, rb_intern("read"), 1, INT2NUM(LOAD_BUF_LEN)))) {
718
725
  // ...read from it until we reach EOF and load the data.
719
- res = SEloadData(conn, STR2CSTR(buf), RSTRING_LEN(buf), doc_name_c, col_name_c);
726
+ res = SEloadData(conn, StringValuePtr(buf), RSTRING_LEN(buf), doc_name_c, col_name_c);
720
727
  VERIFY_RES(SEDNA_DATA_CHUNK_LOADED, res, conn);
721
728
  }
722
729
 
@@ -730,7 +737,7 @@ static VALUE cSedna_load_document(int argc, VALUE *argv, VALUE self)
730
737
  if(RSTRING_LEN(document) == 0) rb_raise(cSednaException, "Document is empty.");
731
738
 
732
739
  // Load the data.
733
- res = SEloadData(conn, STR2CSTR(document), RSTRING_LEN(document), doc_name_c, col_name_c);
740
+ res = SEloadData(conn, StringValuePtr(document), RSTRING_LEN(document), doc_name_c, col_name_c);
734
741
  VERIFY_RES(SEDNA_DATA_CHUNK_LOADED, res, conn);
735
742
  }
736
743
 
@@ -1018,13 +1025,14 @@ void Init_sedna()
1018
1025
  * Raised when a transaction could not be committed.
1019
1026
  */
1020
1027
  cSednaException = rb_define_class_under(cSedna, "Exception", rb_eStandardError);
1028
+
1021
1029
  /*
1022
- * Returns the error code associated with this exception. This code is a string
1023
- * that can be used to accurately identify which error has occurred. Some
1024
- * errors are thrown by the Ruby client rather than the C bindings. In these
1025
- * cases, the error code is +nil+.
1026
- */
1027
- rb_define_attr(cSednaException, "code", 1, 0);
1030
+ * Returns the error code associated with this exception. This code is a string
1031
+ * that can be used to accurately identify which error has occurred. Some
1032
+ * errors are thrown by the Ruby client rather than the C bindings. In these
1033
+ * cases, the error code is +nil+.
1034
+ */
1035
+ rb_define_attr(cSednaException, "code", 1, 0);
1028
1036
 
1029
1037
  /*
1030
1038
  * Sedna::AuthenticationError is a subclass of Sedna::Exception, and is
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
3
 
4
- # Copyright 2008, 2009 Voormedia B.V.
4
+ # Copyright 2008-2010 Voormedia B.V.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
21
21
  # This file contains the test suite to verify the client library is working
22
22
  # correctly.
23
23
 
24
- $:.unshift(File.dirname(__FILE__) + '/../ext')
24
+ $:.unshift(File.dirname(__FILE__) + '/../ext/sedna')
25
25
 
26
26
  require 'test/unit'
27
27
  require 'sedna'
@@ -345,7 +345,7 @@ class SednaTest < Test::Unit::TestCase
345
345
  @@sedna.execute "drop document '#{__method__}'" rescue nil
346
346
  begin
347
347
  thread = Thread.new do
348
- @@sedna.execute "create document '#{__method__}'"
348
+ @@sedna.execute "create document '#{__method__}'" rescue nil
349
349
  end
350
350
  thread.raise
351
351
  thread.join
@@ -384,7 +384,7 @@ class SednaTest < Test::Unit::TestCase
384
384
 
385
385
  test "load_document should create document in given collection" do
386
386
  col = "test_collection"
387
- doc = "<?xml version=\"1.0\" standalone=\"yes\"?><document>\n <node/>\n</document>"
387
+ doc = "<?xml version=\"1.0\" standalone=\"yes\"?>\n<document>\n <node/>\n</document>"
388
388
  @@sedna.execute "create collection '#{col}'" rescue nil
389
389
  @@sedna.execute "drop document '#{__method__}' in collection '#{col}'" rescue nil
390
390
  @@sedna.load_document doc, __method__.to_s, col
@@ -394,7 +394,7 @@ class SednaTest < Test::Unit::TestCase
394
394
  end
395
395
 
396
396
  test "load_document should create standalone document if collection is unspecified" do
397
- doc = "<?xml version=\"1.0\" standalone=\"yes\"?><document>\n <node/>\n</document>"
397
+ doc = "<?xml version=\"1.0\" standalone=\"yes\"?>\n<document>\n <node/>\n</document>"
398
398
  @@sedna.execute "drop document '#{__method__}'" rescue nil
399
399
  @@sedna.load_document doc, __method__.to_s
400
400
  assert_equal doc, @@sedna.execute("doc('#{__method__}')").first
@@ -402,7 +402,7 @@ class SednaTest < Test::Unit::TestCase
402
402
  end
403
403
 
404
404
  test "load_document should create standalone document if collection is nil" do
405
- doc = "<?xml version=\"1.0\" standalone=\"yes\"?><document>\n <node/>\n</document>"
405
+ doc = "<?xml version=\"1.0\" standalone=\"yes\"?>\n<document>\n <node/>\n</document>"
406
406
  @@sedna.execute "drop document '#{__method__}'" rescue nil
407
407
  @@sedna.load_document doc, __method__.to_s, nil
408
408
  assert_equal doc, @@sedna.execute("doc('#{__method__}')").first
@@ -448,8 +448,8 @@ class SednaTest < Test::Unit::TestCase
448
448
  end
449
449
  end
450
450
 
451
- test "load_document should create document if given document is IO object" do
452
- doc = "<?xml version=\"1.0\" standalone=\"yes\"?><document>" << ("\n <some_very_often_repeated_node/>" * 800) << "\n</document>"
451
+ test "load_document should create document if given document is io object" do
452
+ doc = "<?xml version=\"1.0\" standalone=\"yes\"?>\n<document>" << ("\n <some_very_often_repeated_node/>" * 800) << "\n</document>"
453
453
  p_out, p_in = IO.pipe
454
454
  p_in.write doc
455
455
  p_in.close
@@ -696,7 +696,7 @@ class SednaTest < Test::Unit::TestCase
696
696
  end
697
697
  rescue Sedna::Exception => exc
698
698
  end
699
- assert_equal "It is a dynamic error if evaluation of an expression relies on some part of the dynamic context that has not been assigned a value.", exc.message
699
+ assert_match /It is a dynamic error if evaluation of an expression relies on some part of the dynamic context that has not been assigned a value/, exc.message
700
700
  end
701
701
 
702
702
  test "transaction should raise Sedna::TransactionError if called from different threads on same connection" do