# Amalgalite 0.2.1 Released

**URL:** <https://www.ruby-forum.com/t/amalgalite-0-2-1-released/142291>\
**Category:** Ruby\
**Created:** [July 6, 2008, 8:31am UTC](https://www.ruby-forum.com/t/amalgalite-0-2-1-released/142291 "2008-07-06T08:31:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [July 6, 2008, 8:31am UTC](https://www.ruby-forum.com/t/amalgalite-0-2-1-released/142291/1 "2008-07-06T08:31:06Z")

</div>

A quick bugfix release for amalgalite. If you had a bug running  
amalgalite  
with an error similar to:

amalgalite-0.2.0/ext/amalgalite3.so: undefined symbol:  
pthread\_mutexattr\_init

That is now fixed. This has to do with wheter or not your ruby  
installation was  
configured with --enable-pthread.

- 

[http://www.copiousfreetime.org/articles/2008/07/05/amalgalite-pthread-error.html](http://www.copiousfreetime.org/articles/2008/07/05/amalgalite-pthread-error.html)

{{ Release notes for Version 0.2.1 }}

- Bugfixes
  - make sure that the pthread support in sqlite3 matches that of ruby
  - fix schema reloading in the example scripts

---

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [July 6, 2008, 10:40pm UTC](https://www.ruby-forum.com/t/amalgalite-0-2-1-released/142291/2 "2008-07-06T22:40:30Z")

</div>

Jeremy H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> {{ Release notes for Version 0.2.1 }}

now, i’m running this version.  
because i want to switch from ruby-sqlite3 to amalgalite, i’ve tried  
translating a ruby-sqlite3 script to amalgalite.

on the ruby-sqlite3 side i’m using PRAGMA :

#! /usr/bin/env ruby

require ‘rubygems’  
require ‘sqlite3’

file=‘places.sqlite’  
#file=Dir.glob(“#{ENV[‘HOME’]}/Library/Application  
Support/Firefox/Profiles/\*.default/places.sqlite”).last  
db = SQLite3::Database.new( “#{file}” )

tables=[]  
db.execute( “SELECT name FROM sqlite\_master WHERE type=‘table’ ORDER BY  
name;” ) do |row|  
tables\<\<row[0]  
end

tables.each do |table|  
puts table+“:”  
index\_list=[]  
db.execute( “PRAGMA index\_list( #{table} );” ) do |row|  
index\_list\<\<row[1]  
end  
index\_list.each do |index\_name|  
puts " #{index\_name}:"  
columns=nil  
db.execute2( “PRAGMA index\_info( #{index\_name} );” ) do |row|  
if !columns  
columns=row.join(’ ‘)  
puts " "+columns  
else  
puts " "+row.join(’ ')  
end  
end  
end  
puts  
end

and get :

moz\_anno\_attributes:  
sqlite\_autoindex\_moz\_anno\_attributes\_1:  
seqno cid name  
0 1 name

moz\_annos:  
moz\_annos\_placeattributeindex:  
seqno cid name  
0 1 place\_id  
1 2 anno\_attribute\_id  
…

on the amalgalite side, i’ve tried :  
#! /usr/bin/env ruby

require ‘rubygems’  
require ‘amalgalite’

class String  
def underline  
return self+“\n+”+(“-”\*(self.length-2))+“+”  
end  
end

db = Amalgalite::Database.new( “places.sqlite” )  
index\_info=%w[sql]  
max\_width=index\_info.collect { |c| c.length }.sort.last  
pragma\_info=%w[seqno cid name]  
pragma\_max\_width=pragma\_info.collect { |c| c.length }.sort.last

db.schema.tables.keys.sort.each do |table\_name|  
puts “Table: #{table\_name}”.underline  
indexes=db.schema.tables[table\_name].indexes  
indexes.each do |index|  
puts " Index : #{index.name}"  
index\_info.each do |ci|  
puts " |#{ci.rjust( max\_width, “.” )} : #{index.send( ci )}"  
end  
db.pragma(“index\_info( #{index.name} )”) do |index\_field|  
pragma\_info.each do |ci|  
puts " |#{ci.rjust( pragma\_max\_width, “.” )} :  
#{index\_field.send( ci )}"  
end  
end  
puts  
end  
end

db.close

where i get :  
Table: moz\_anno\_attributes  
±-----------------------+  
Index : sqlite\_autoindex\_moz\_anno\_attributes\_1  
|sql :

Table: moz\_annos  
±-------------+  
Index : moz\_annos\_placeattributeindex  
|sql : CREATE UNIQUE INDEX moz\_annos\_placeattributeindex ON  
moz\_annos (place\_id, anno\_attribute\_id)

…

then it seems that db.pragma(“index\_info( #{index.name} )”) returns an  
empty array, although the source code gives:  
# File lib/amalgalite/database.rb, line 440  
440: def pragma( cmd )  
441: execute(“PRAGMA #{cmd}”)  
442: end

showing db.execute2( “PRAGMA index\_info( #{index\_name} );” ) and  
#pragma( cmd ) are equivalent (apart from columns names).

where am i wrong here ?

---

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [July 7, 2008, 2:36am UTC](https://www.ruby-forum.com/t/amalgalite-0-2-1-released/142291/3 "2008-07-07T02:36:14Z")

</div>

Replace this section with

> ```
> db.pragma("index_info( #{index.name} )") do |index_field|
> pragma_info.each do |ci|
> puts " |#{ci.rjust( pragma_max_width, "." )} : #{index_field.send( ci )}"
> end
> end
> 
> ```

```
db.pragma("index_info( #{index.name} )").each do |index_field|
  pragma_info.each do |ci|
    puts " |#{ci.rjust( pragma_max_width, "." )} : 

```

#{index\_field[ci]}"  
end  
end

> then it seems that db.pragma(“index\_info( #{index.name} )”) returns an  
> empty array, although the source code gives:  
> # File lib/amalgalite/database.rb, line 440  
> 440: def pragma( cmd )  
> 441: execute(“PRAGMA #{cmd}”)  
> 442: end

Database#pragma does not accept a block. that is what is going on.  
#execute  
dos and there’s a difference there. The block attached to your #pragma  
call is  
not getting executed.

For now I’ve added a todo to fix this for the next release and also to  
have the  
Amalgalite::Index class do the index\_info() call itself and make the  
seqno, ci  
and name available via some API.

enjoy,

-jeremy

---

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [July 7, 2008, 11:25am UTC](https://www.ruby-forum.com/t/amalgalite-0-2-1-released/142291/4 "2008-07-07T11:25:46Z")

</div>

Jeremy H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Database#pragma does not accept a block. that is what is going on.  
> #execute dos and there’s a difference there. The block attached to your  
> #pragma call is not getting executed.

I should have catched that point, because there is no yield, in the  
source…

> For now I’ve added a todo to fix this for the next release and also to  
> have the Amalgalite::Index class do the index\_info() call itself and make  
> the seqno, ci and name available via some API.

Fine ! thanks a lot !
