diff --git a/lib/mysql2psql/mysql_reader.rb b/lib/mysql2psql/mysql_reader.rb index 98dc5e8..c343650 100644 --- a/lib/mysql2psql/mysql_reader.rb +++ b/lib/mysql2psql/mysql_reader.rb @@ -43,7 +43,9 @@ def convert_type(type) "varchar" when /char/ "char" - when /(float|decimal)/ + when /float/ + "real" + when /decimal/ "decimal" when /double/ "double precision" @@ -59,6 +61,7 @@ def load_columns fields = [] @reader.mysql.query("EXPLAIN `#{name}`") do |res| while field = res.fetch_row do + length = -1 length = field[1][/\((\d+)\)/, 1] if field[1] =~ /\((\d+)\)/ length = field[1][/\((\d+),(\d+)\)/, 1] if field[1] =~ /\((\d+),(\d+)\)/ desc = { @@ -188,4 +191,4 @@ def paginated_read(table, page_size) end end -end \ No newline at end of file +end diff --git a/lib/mysql2psql/postgres_db_writer.rb b/lib/mysql2psql/postgres_db_writer.rb index f636c9f..a861e21 100644 --- a/lib/mysql2psql/postgres_db_writer.rb +++ b/lib/mysql2psql/postgres_db_writer.rb @@ -164,16 +164,25 @@ def write_contents(table, reader) if counter % 5000 == 0 @conn.put_copy_end + res = @conn.get_result + if res.cmdtuples != 5000 + puts "\nWARNING: #{table.name} expected 5000 tuple inserts got #{res.cmdtuples} at row #{counter}\n" + end @conn.exec(copy_line) end end - _time2 = Time.now - puts "\n#{_counter} rows loaded in #{((_time2 - _time1) / 60).round}min #{((_time2 - _time1) % 60).round}s" -# @conn.putline(".\n") @conn.put_copy_end + if _counter && (_counter % 5000) > 0 + res = @conn.get_result + if res.cmdtuples != (_counter % 5000) + puts "\nWARNING: table #{table.name} expected #{_counter % 5000} tuple inserts got #{res.cmdtuples}\n" + end + end + _time2 = Time.now + puts "\n#{table.name} #{_counter} rows loaded in #{((_time2 - _time1) / 60).round}min #{((_time2 - _time1) % 60).round}s" end - + end -end \ No newline at end of file +end diff --git a/lib/mysql2psql/postgres_writer.rb b/lib/mysql2psql/postgres_writer.rb index 9609ed4..96da0a4 100644 --- a/lib/mysql2psql/postgres_writer.rb +++ b/lib/mysql2psql/postgres_writer.rb @@ -46,7 +46,7 @@ def column_type_info(column) when "boolean" default = " DEFAULT #{column[:default].to_i == 1 ? 'true' : 'false'}" if default "boolean" - when "float" + when "real" default = " DEFAULT #{column[:default].nil? ? 'NULL' : column[:default].to_f}" if default "real" when "float unsigned" @@ -140,4 +140,4 @@ def truncate(table) end -end \ No newline at end of file +end