Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jruby pg #1

Closed
wants to merge 4 commits into from
Closed

Jruby pg #1

wants to merge 4 commits into from

Conversation

jvshahid
Copy link

@jvshahid jvshahid commented May 7, 2014

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.

use pg_config to determine postgresql bin directory and use it if
available. Also, if we're running on a no fork system redirect the
output of the commands.  Otherwise pg_ctl won't leave the shell process
group and block the specs from finishing
@jgaskins
Copy link

jgaskins commented May 8, 2014

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)

@jvshahid
Copy link
Author

jvshahid commented May 8, 2014

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.

@larskanis
Copy link
Collaborator

@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.

@joevandyk
Copy link

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.

larskanis added a commit to larskanis/ruby-pg that referenced this pull request Feb 28, 2023
pg_config is usually in the path of many distros, as soon as postgresql-client tools are installed, but server commands are not.
That's why we always had to adjust the PATH accordingly.
Determining the path of these commands automatically makes testing easier.

Extracted from ged#1
@larskanis
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants