ruby-pg
ruby-pg copied to clipboard
Jruby pg
I thought I should open a pr to get the ball rolling. This still needs some work, there are currently 9 failures that I need to fix. Feedback is welcome, specially with the changes to the Rakefile, etc.
Do you have any insight on how to get the specs running? I've got a fresh JRuby installed via RVM and it won't build the gem. Here are the outputs from the newb, gem, and compile Rake tasks:
➜ ruby-pg git:(jruby-pg) rake newb
rm -rf doc
/Users/jamie/.rvm/gems/jruby-1.7.12@pg/bin/jrdoc --title pg-0.17.0 Documentation -o doc -f fivefish -t pg: The Ruby Interface to PostgreSQL -m README.rdoc lib Contributors.rdoc History.rdoc Manifest.txt README-OS_X.rdoc README-Windows.rdoc README.ja.rdoc README.rdoc ext/errorcodes.txt Contributors.rdoc History.rdoc README-OS_X.rdoc README-Windows.rdoc README.ja.rdoc README.rdoc POSTGRES LICENSE ext/gvl_wrappers.c ext/pg.c ext/pg_connection.c ext/pg_errors.c ext/pg_result.c
rake aborted!
Command failed with status (127): [/Users/jamie/.rvm/gems/jruby-1.7.12@pg/bin...]
/Users/jamie/.rvm/gems/jruby-1.7.12@pg/gems/hoe-3.5.3/lib/hoe/publish.rb:116:in `define_publish_tasks'
/Users/jamie/.rvm/gems/jruby-1.7.12@pg/bin/jruby_executable_hooks:15:in `(root)'
Tasks: TOP => newb => docs
(See full trace by running task with --trace)
➜ ruby-pg git:(jruby-pg) rake gem
rake aborted!
Don't know how to build task 'ext/errorcodes.def'
/Users/jamie/.rvm/gems/jruby-1.7.12@pg/bin/jruby_executable_hooks:15:in `(root)'
Tasks: TOP => gem => pkg/pg-0.17.0-java.gem
(See full trace by running task with --trace)
➜ ruby-pg git:(jruby-pg) rake compile
# ... massive javac command omitted ...
ext/java/PgExtService.java:60: error: cannot find symbol
Errors.initializeError(ruby);
^
symbol: variable Errors
location: class PgExtService
ext/java/PgExtService.java:86: error: cannot find symbol
pg.getSingletonClass().defineAnnotatedMethods(Postgresql.class);
^
symbol: class Postgresql
location: class PgExtService
Note: ext/java/org/jruby/pg/Connection.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
1 warning
rake aborted!
Command failed with status (1): [javac -extdirs "/Users/jamie/Library/Java/...]
/Users/jamie/.rvm/gems/jruby-1.7.12@pg/gems/rake-compiler-0.9.2/lib/rake/javaextensiontask.rb:98:in `define_compile_tasks'
/Users/jamie/.rvm/gems/jruby-1.7.12@pg/bin/jruby_executable_hooks:15:in `(root)'
Tasks: TOP => compile => compile:java => compile:pg_ext:java => copy:pg_ext:java => tmp/java/pg_ext/pg_ext.jar => tmp/java/pg_ext/.build
(See full trace by running task with --trace)
Seems like the Rakefile dependencies is broken. You should be able to run rake ext/java/org/jruby/pg/Errors.java to generate the missing errors file. I'll get this fixed asap.
@jvshahid Great work! Unfortunatelly there is currently something wrong with the Errors.java file, so I got the same error as @jgaskins . I hacked it so that it compiles and the specs run, but it's probably better when you fix it yourself.
2) PG::Connection trace and untrace client-server communication is libpq specific. The other 8 failures are probably not too hard to fix.
You added PG::Constants::OID_* values to the jruby part. This is something that is also part of the type casting branch I experiment since a while, but the OIDs are fetched from the database there. Possibly we could add PG::Constants::OID_* to the C extension nevertheless.
I still have to inspect the Rakefile changes. In any case it's a good way to take the path for initdb and pg_ctl from pg_config.
The error file generator is possibly better placed in task :update_error_codes. This is something I have on my agenda. That would allow us to provide a gemspec for the repository.
All in all I don't have an objection to integrate this. The only thing I worry about is how we should go forward with the type casting in pg. It is probably a bunch of work to implement it equally in Java.
Any updates on this? I'm looking to switch a rails application from MRI 2.1 to JRuby, but we need decent postgresql support. If it would help, we could provide some funds for someone to work on this.
It's a bunch of work incorporated into this PR, but I think the approach to add a JRuby extension to ruby-pg is no longer followed and it can be closed.
@jvshahid I read about better PostgreSQL support for rails-7 on JRuby, but didn't find a link to any code. What is it about? Should I add a pointer to the README of ruby-pg?