SiSU's sqlite module still broken for the time being: inconsistent ruby dbi api
authorRalph Amissah <ralph@amissah.com>
Thu, 18 Dec 2008 01:57:46 +0000 (20:57 -0500)
committerRalph Amissah <ralph@amissah.com>
Sun, 21 Dec 2008 03:54:44 +0000 (22:54 -0500)
for sqlite3, (unable to begin and commit transaction) provide explicit message

problem noted already in v.0.66.2 (2008-04) and last in v.0.66.3 (2008-05)
module (& rb dbi) apparently worked at end 2007 (v.0.62.4) and start of 2008
(v.0.64.0) ... (did not expect broken state to last, sorry)

include maintenance mode info with -M flag

CHANGELOG
lib/sisu/v0/db_dbi.rb
lib/sisu/v0/db_import.rb
lib/sisu/v0/db_load_tuple.rb
lib/sisu/v0/db_remove.rb
lib/sisu/v0/db_select.rb
lib/sisu/v0/dbi.rb
lib/sisu/v0/urls.rb

index 9cb6caf1aed5812fdef5bf3229cae971eb93866a..7b1b22dd4d985af3b1ba3a715f65290a17844511 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -17,6 +17,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_0.70.3.orig.tar.gz
 
   * html and css, cosmetic changes (and the closing of a tag)
 
+  * sqlite module remains broken, inconsistent ruby dbi api - made explicit
+    when run
+
 %% sisu_0.70.2.orig.tar.gz (2008-12-16:50/2)
 http://www.jus.uio.no/sisu/pkg/src/sisu_0.70.2.orig.tar.gz
   c4ec17c3f50b629a33afcb3d343e111172bf56b656fa892d82936f86dfde281a 1545482 sisu_0.70.2.orig.tar.gz
index 3a54fd465660bd25e07effdb7ae980f80bd51dbc..4256efb92700a90887a62325d76188ea6abf855d 100644 (file)
@@ -70,25 +70,25 @@ module  SiSU_DB_DBI
   require "#{SiSU_lib}/db_import"
   class Column_size < SiSU_DB_columns::Column_size
   end
-  class Test < SiSU_DB_tests::Test
+  class Test < SiSU_DB_tests::Test                                            #% db_tests.rb
   end
-  class Create <SiSU_DB_create::Create #<SiSU_DB::Column_size
+  class Create <SiSU_DB_create::Create #<SiSU_DB::Column_size                 #% db_create.rb
   end
-  class Case <SiSU_DB_select::Case
+  class Case <SiSU_DB_select::Case                                            #% db_select.rb
   end
-  class Index <SiSU_DB_index::Index                                           # create documents Indexes def initialize(opt,conn='',sql_type='')
+  class Index <SiSU_DB_index::Index                                           #% db_indexes.rb
   end
-  class Drop <SiSU_DB_drop::Drop
+  class Drop <SiSU_DB_drop::Drop                                              #% db_drop.rb
   end
-  class Remove <SiSU_DB_remove::Remove
+  class Remove <SiSU_DB_remove::Remove                                        #% db_remove.rb
   end
-  class Load_documents <SiSU_DB_tuple::Load_documents                                  #% main database populate/update
+  class Load_documents <SiSU_DB_tuple::Load_documents                         #% db_load_tuple.rb
   end
-  class Load_metadata <SiSU_DB_tuple::Load_metadata                                    #% update metadata
+  class Load_metadata <SiSU_DB_tuple::Load_metadata                           #% db_load_tuple.rb
   end
-  class Load_urls <SiSU_DB_tuple::Load_urls                                            #% update urls
+  class Load_urls <SiSU_DB_tuple::Load_urls                                   #% db_update urls
   end
-  class Import <SiSU_DB_import::Import #<SiSU_DB::Column_size                  #% main
+  class Import <SiSU_DB_import::Import #<SiSU_DB::Column_size                 #% db_import.rb
   end
 end
 __END__
index 1e1e25d7f1cd15720f1a00c171616f9f732d4ad2..bcdfc4979a56a33bcc20f98a30751e23bd1182f4 100644 (file)
@@ -112,7 +112,15 @@ module SiSU_DB_import
       tell.print_grey if @opt.cmd =~/v/
       case @sql_type
       when /sqlite/                                                    #fix logic for sqlite !
+#sqlite watch
+unless @opt.cmd =~/[MVv]/
+  puts "\nSiSU's sqlite module for the time being broken: inconsistent ruby dbi api for sqlite3, (unable to begin and commit transaction)\n".upcase
+  p @conn.methods.sort
+  #p "here #{__FILE__} #{__LINE__}"
+  exit
+else
         #pf_db_import_transaction_open if @opt =~/M/
+        #@conn.begin
         db_import_metadata
         db_import_documents(@dal_array)
         db_import_urls(@dal_array,@fnm)                                #import OID on/off
@@ -120,6 +128,14 @@ module SiSU_DB_import
         #@conn.commit
         #@conn.close
         #@conn.disconnect
+  puts "\nSiSU's sqlite module for the time being broken: inconsistent ruby dbi api for sqlite3, (unable to begin and commit transaction)\n".upcase
+  p @conn.methods.sort
+  if @opt.cmd =~/M/
+    puts "\n" + @conn.inspect
+    puts "\nat #{__FILE__} #{__LINE__}"
+  end
+  exit
+end
 #sqlite watch
       else
         file_exist=@conn.select_one(%{ SELECT metadata.tid FROM metadata WHERE metadata.filename ~ '#{@opt.fns}'; })
@@ -129,6 +145,10 @@ module SiSU_DB_import
           db_import_documents(@dal_array)
           db_import_urls(@dal_array,@fnm)                              #import OID on/off
           @conn.execute('COMMIT')
+          if @opt.cmd =~/[MV]/
+            puts "\n" + @conn.inspect
+            puts "\nat #{__FILE__} #{__LINE__}"
+          end
         else
           @db=SiSU_Env::Info_db.new
           puts "\n#{@cX.grey}file #{@cX.off} #{@cX.blue}#{@opt.fns}#{@cX.off} #{@cX.grey}already exists in database#{@cX.off} #{@cX.blue}#{@db.psql.db}#{@cX.off} #{@cX.brown}update instead?#{@cX.off}"
index aefa10c4eaa8181d911ef8dfb09f6a50f73c64cd..512d59330cc4c1a22a40c141501d0b9a5dbc4487 100644 (file)
@@ -85,6 +85,10 @@ module SiSU_DB_tuple
           "INSERT INTO documents (lid, metadata_tid, lev, clean, body, ocn, ocnd, ocns, seg, lev1, lev2, lev3, lev4, lev5, lev6, digest_clean, digest_all) VALUES (#{@col[:lid]}, #{@col[:tid]}, #{@col[:lev]}, '#{@col[:plaintext]}', '#{@col[:body]}', '#{@col[:ocn]}', '#{@col[:ocnd]}', '#{@col[:ocns]}', '#{@col[:seg]}', '#{@col[:lv1]}', '#{@col[:lv2]}', '#{@col[:lv3]}', '#{@col[:lv4]}', '#{@col[:lv5]}', '#{@col[:lv6]}', '#{@col[:digest_clean]}', '#{@col[:digest_all]}');"
         end
         if @opt.cmd =~/M/
+          if @opt.cmd =~/V/
+            puts @file.inspect
+            puts sql_entry
+          end
           @file.puts sql_entry
         else @conn.execute(sql_entry)
         end
index 93680f2cf05f3fe41f8cc4146f25cab674c5cfae..fef4e797b871303dde7ff6431723bca57f6a69c6 100644 (file)
@@ -79,9 +79,10 @@ DELETE FROM documents WHERE metadata_tid = '#{del_id}';
 DELETE FROM urls WHERE metadata_tid = '#{del_id}';
 DELETE FROM metadata WHERE tid = '#{del_id}';
 SQL
+        @conn.execute(%{#{sql_entry}})
         if @opt.cmd =~/M/
           @file.puts sql_entry if @opt.cmd =~/M/
-        else @conn.execute(%{#{sql_entry}})
+        #else @conn.execute(%{#{sql_entry}})
         end
       else
         tell=SiSU_Screen::Ansi.new(@opt.cmd,"no such file in database #{@db.psql.db}::#{@opt.fns}")
index a596d4e3774b757f24565f5d2c98acfcdd74e8ad..675a89e452c00af76595013310ae1e5a8528f4dd 100644 (file)
@@ -65,9 +65,9 @@ module SiSU_DB_select
 #@conn.execute("BEGIN;")
       #@sdb=Create.new(@conn)
       @file=sql_maintenance_file
-      @sdb=SiSU_DB_DBI::Create.new(@opt,@conn,@file,@sql_type)
-      @sdb_index=SiSU_DB_DBI::Index.new(@opt,@conn,@file,@sql_type)
-      @sdb_no=SiSU_DB_DBI::Drop.new(@opt,@conn,@file,@sql_type)
+      @sdb=SiSU_DB_DBI::Create.new(@opt,@conn,@file,@sql_type)      # db_dbi.rb
+      @sdb_index=SiSU_DB_DBI::Index.new(@opt,@conn,@file,@sql_type) # db_dbi.rb
+      @sdb_no=SiSU_DB_DBI::Drop.new(@opt,@conn,@file,@sql_type)     # db_dbi.rb
       @sdb_import=SiSU_DB_DBI::Import.new(@opt,@conn,@file,@sql_type) if @opt.mod.inspect =~/update|import/
       @sdb_remove_doc=SiSU_DB_DBI::Remove.new(@opt,@conn,@file) if @opt.mod.inspect =~/update|remove/
       @db=SiSU_Env::Info_db.new
@@ -155,13 +155,13 @@ module SiSU_DB_select
           else '???'
           end
           tell.puts_grey if @opt.cmd =~/v/
-        when /^--remove$/
-          @sdb_remove_doc.remove
         when /^--update$/
           @sdb_remove_doc.remove
           @sdb_import.marshal_load
           tell=SiSU_Screen::Ansi.new(@opt.cmd,"pgaccess or psql #{@db.psql.db} database?")
           tell.puts_grey if @opt.cmd =~/v/
+        when /^--remove$/
+          @sdb_remove_doc.remove
         when /^--index$/
           @sdb_index.create_indexes
         when /^droptable(s)?$/
@@ -185,7 +185,11 @@ module SiSU_DB_select
         end
       end
       begin
-      @conn.commit if @sql_type =~/sqlite/
+      #if @sql_type =~/sqlite/
+      #  #p @conn.methods.sort
+      #  @conn.commit
+      #  ##@conn.disconnect
+      #end
       rescue; @sdb.output_dir?
       end
     end
index 1f161724000348885421cc25747e6184a80230f7..9576fa748a48710d8800ea9b204414180d0b8f60 100644 (file)
@@ -64,7 +64,7 @@ module  SiSU_DBI
   include SiSU_Screen
   require "#{SiSU_lib}/param"
   include SiSU_Param
-  require "#{SiSU_lib}/db_dbi"
+  require "#{SiSU_lib}/db_dbi" # db_dbi.rb
   include SiSU_DB_DBI
   require "#{SiSU_lib}/shared_html_lite"
   include SiSU_Format_Shared
@@ -74,23 +74,35 @@ module  SiSU_DBI
       @opt=opt
       @db=SiSU_Env::Info_db.new
       if @opt.cmd =~/d/i \
-      or  @opt.mod.inspect =~/--pg(?:sql)?|(?:sq)?lite/
+      or  @opt.mod.inspect =~/--(pg(?:sql)?|(?:sq)?lite)/
         @sql_type=if @opt.cmd=~/D/ \
         or @opt.mod.inspect =~/--pg(?:sql)?/
+          maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/
           'pg'
         elsif @opt.cmd =~/d/ \
         and @opt.mod.inspect =~/--(?:db[=-])?pg(?:sql)?/
+          maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/
           'pg'
-        elsif @opt.mod.inspect =~/--(?:sq)?lite/
+        elsif @opt.cmd=~/d/ \
+        or @opt.mod.inspect =~/--(?:sq)?lite/
+          maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/
           'sqlite'
         elsif @opt.cmd =~/d/ \
         and @opt.mod.inspect =~/--(?:db[=-])?(?:sq)?lite/
+          maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/
           'sqlite'
         #elsif @opt.cmd =~/d/ and @opt.mod.select =~/--my(?:sql)?/;               'mysql'
-        else 'sqlite'
+        else
+          maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/
+          'sqlite'
         end
       end
     end
+    def maintenance_check(opt,file,line)
+      p opt.mod
+      p opt.cmd
+      p "at #{file} #{line}"
+    end
     def read_psql
       begin
         db,user,dbi,pass=@db.psql.db,@db.psql.user,@db.psql.dbi,@db.psql.password
index 05ffd969e7ed3f9f922519990e8ef76fad7ac37e..6d78d4fe69042bf65458c8ca9a1a088da106aa66 100644 (file)
@@ -109,7 +109,7 @@ module SiSU_urls
         'b (XHTML)'=>@fn[:xhtml],
         #'B (Docbook XML)'=>@fn[:docbook],
         'D[iu] (DBI import/update postgresql)'=>'dbi psql',
-        'd[iu] (DBI import/update sqlite)'=>'dbi sqlite',
+        'd[iu] (DBI import/update sqlite)'=>'dbi sqlite3',
         'e (Plain-text (endnotes))'=>@fn[:plain],
         'E (Plain-text (endnotes) dos)'=>@fn[:plain],
         'h (HTML segmented)'=>@fn[:toc],
@@ -221,7 +221,7 @@ module SiSU_urls
           end
           if x=~/^d/ \
           and @opt.cmd =~/d/
-            tell=SiSU_Screen::Ansi.new(@opt.cmd,"-#{x} DBI sqlite","sqlite #{@env.path.output}/sisu_sqlite.db", "#{y}")
+            tell=SiSU_Screen::Ansi.new(@opt.cmd,"-#{x} DBI sqlite","sqlite3 #{@env.path.output}/sisu_sqlite.db", "#{y}")
             tell.result unless @opt.cmd =~/q/
             @opt.cmd.gsub!(/d[iu]/,'')
           end