Postgres-pr

I've installed the windows version of ruby-1.8.2 with the latest one-click installer. I used gem to install postgres-pr-0.3.2. However, I can't seem to get any of the examples to run. I'm getting a

uninitialized constant StartupMessage (NameError) in client.rb

The require statements are:
$LOAD_PATH.unshift "../lib"
requie 'rubygems'
require 'postgres-pr/message'
require 'socket'

The first two lines of code are

s = UNIXSocket.new(ARGV.shift || "/tmp/.s.PGSQL.5432")

msg = StartupMessage.new(196608, "user" => "mneumann", "database" => "mneumann")

I can't use a UNIXSocket because I'm not running Cygwin. However, I don't see any requirements in postgres-pr/message.rb for (s).
Am I missing something?

Does someone have any experience using postgres-pr in the dbi. If so,
How does one connect to a server?

Ernie

Ernest Ellingson wrote:

I've installed the windows version of ruby-1.8.2 with the latest one-click installer. I used gem to install postgres-pr-0.3.2. However, I can't seem to get any of the examples to run. I'm getting a

uninitialized constant StartupMessage (NameError) in client.rb

I fixed that. put a "include PostgresPR" after the requires and it works. Try postgres-pr-0.3.3.

The require statements are:
$LOAD_PATH.unshift "../lib"
requie 'rubygems'
require 'postgres-pr/message'
require 'socket'

The first two lines of code are

s = UNIXSocket.new(ARGV.shift || "/tmp/.s.PGSQL.5432")

msg = StartupMessage.new(196608, "user" => "mneumann", "database" => "mneumann")

I can't use a UNIXSocket because I'm not running Cygwin. However, I don't see any requirements in postgres-pr/message.rb for (s).
Am I missing something?

I don't understand your question... Maybe... The UNIXSocket is only used in the example, you can use postgres-pr/connection.rb without a UNIXSocket, with a TCPSocket. That's no problem.

Does someone have any experience using postgres-pr in the dbi. If so,
How does one connect to a server?

Just use DBD::Pg. I've not tried it. But I know that it works with ActiveRecord and Og.

Regards,

   Michael

Michael Neumann wrote:

Ernest Ellingson wrote:

I've installed the windows version of ruby-1.8.2 with the latest one-click installer. I used gem to install postgres-pr-0.3.2. However, I can't seem to get any of the examples to run. I'm getting a

uninitialized constant StartupMessage (NameError) in client.rb

I fixed that. put a "include PostgresPR" after the requires and it works. Try postgres-pr-0.3.3.

The require statements are:
$LOAD_PATH.unshift "../lib"
requie 'rubygems'
require 'postgres-pr/message'
require 'socket'

The first two lines of code are

s = UNIXSocket.new(ARGV.shift || "/tmp/.s.PGSQL.5432")

msg = StartupMessage.new(196608, "user" => "mneumann", "database" => "mneumann")

I can't use a UNIXSocket because I'm not running Cygwin. However, I don't see any requirements in postgres-pr/message.rb for (s).
Am I missing something?

I don't understand your question... Maybe... The UNIXSocket is only used in the example, you can use postgres-pr/connection.rb without a UNIXSocket, with a TCPSocket. That's no problem.

Does someone have any experience using postgres-pr in the dbi. If so,
How does one connect to a server?

Just use DBD::Pg. I've not tried it. But I know that it works with ActiveRecord and Og.

Regards,

  Michael

Thanks Michael, I'll give it a whirl and let you know how things worked out.
Ernie

Ernest Ellingson wrote:

Michael Neumann wrote:

Ernest Ellingson wrote:

I've installed the windows version of ruby-1.8.2 with the latest one-click installer. I used gem to install postgres-pr-0.3.2. However, I can't seem to get any of the examples to run. I'm getting a

uninitialized constant StartupMessage (NameError) in client.rb

I fixed that. put a "include PostgresPR" after the requires and it works. Try postgres-pr-0.3.3.

The require statements are:
$LOAD_PATH.unshift "../lib"
requie 'rubygems'
require 'postgres-pr/message'
require 'socket'

The first two lines of code are

s = UNIXSocket.new(ARGV.shift || "/tmp/.s.PGSQL.5432")

msg = StartupMessage.new(196608, "user" => "mneumann", "database" => "mneumann")

I can't use a UNIXSocket because I'm not running Cygwin. However, I don't see any requirements in postgres-pr/message.rb for (s).
Am I missing something?

I don't understand your question... Maybe... The UNIXSocket is only used in the example, you can use postgres-pr/connection.rb without a UNIXSocket, with a TCPSocket. That's no problem.

Does someone have any experience using postgres-pr in the dbi. If so,
How does one connect to a server?

Just use DBD::Pg. I've not tried it. But I know that it works with ActiveRecord and Og.

Regards,

  Michael

Thanks Michael, I'll give it a whirl and let you know how things worked out.
Ernie

Something's still fowled up. I installed postgres-pr.0.3.3 using gem install. I uninstalled postgres-pr-0.3.2 using gem.
There is no Pg driver in the DBD directory.

dbi was installed with the one click windows installer not with gem.
Should I just install postgres-pr.0.3.3 without using gem?
Should I install the dbi using gem?
How do I go about getting the Pg driver installed in the DBD directory.
If I'm running a script from some other directory other than the example directory, what requires do I need? Up to now I've only had to require 'dbi' when using ODBC.

I ran the client.rb program after changing the socket to a TCPsocket. My system started thrashing. Page files jumped to 1.24GB that's right GIGA BYTES. Thrashed for a while and then just hung there. PF dropped back to 144MB. What's that all about?

Running Ruby 1.8.2-14 on WindowsXP service pack 2.

Ernie

Ernest Ellingson wrote:

Ernest Ellingson wrote:

Michael Neumann wrote:

Ernest Ellingson wrote:

I've installed the windows version of ruby-1.8.2 with the latest one-click installer. I used gem to install postgres-pr-0.3.2. However, I can't seem to get any of the examples to run. I'm getting a

uninitialized constant StartupMessage (NameError) in client.rb

I fixed that. put a "include PostgresPR" after the requires and it works. Try postgres-pr-0.3.3.

The require statements are:
$LOAD_PATH.unshift "../lib"
requie 'rubygems'
require 'postgres-pr/message'
require 'socket'

The first two lines of code are

s = UNIXSocket.new(ARGV.shift || "/tmp/.s.PGSQL.5432")

msg = StartupMessage.new(196608, "user" => "mneumann", "database" => "mneumann")

I can't use a UNIXSocket because I'm not running Cygwin. However, I don't see any requirements in postgres-pr/message.rb for (s).
Am I missing something?

I don't understand your question... Maybe... The UNIXSocket is only used in the example, you can use postgres-pr/connection.rb without a UNIXSocket, with a TCPSocket. That's no problem.

Does someone have any experience using postgres-pr in the dbi. If so,
How does one connect to a server?

Just use DBD::Pg. I've not tried it. But I know that it works with ActiveRecord and Og.

Regards,

  Michael

Thanks Michael, I'll give it a whirl and let you know how things worked out.
Ernie

Something's still fowled up. I installed postgres-pr.0.3.3 using gem install. I uninstalled postgres-pr-0.3.2 using gem.
There is no Pg driver in the DBD directory.

dbi was installed with the one click windows installer not with gem.
Should I just install postgres-pr.0.3.3 without using gem?
Should I install the dbi using gem?

DBI via gem is not (yet) available.
And, postgres-pr is NOT a DBD! It has a compatibility layer to postgres.so (the C-interface to Postgres), but that's not 100% compatible as my focus was on getting ActiveRecord and Og working with it. I've not tested postgres-pr with DBD::Pg (DBI). It might fail!

How do I go about getting the Pg driver installed in the DBD directory.

You should not remove the Pg.rb driver!

If I'm running a script from some other directory other than the example directory, what requires do I need? Up to now I've only had to require 'dbi' when using ODBC.

Again, postgres-pr has nothing to do with DBI. If it would be 100% compatible to postgres.so, you should be able to just use the DBD::Pg with a simple require 'dbi' and then DBI.connect("dbi:g:...").

I ran the client.rb program after changing the socket to a TCPsocket. My system started thrashing. Page files jumped to 1.24GB that's right GIGA BYTES. Thrashed for a while and then just hung there. PF dropped back to 144MB. What's that all about?

I don't know. It works fine on my machine. Would you try test_connection.rb? But note, that you should change the connection parameters and make sure, you don't destroy data in your database!
Does it work?

Regards,

    Michael

Michael Neumann wrote:

And, postgres-pr is NOT a DBD! It has a compatibility layer to postgres.so (the C-interface to Postgres), but that's not 100% compatible as my focus was on getting ActiveRecord and Og working with it. I've not tested postgres-pr with DBD::Pg (DBI). It might fail!

I think some code was added to ActiveRecord 1.3 which might break compatibility with postgres-pr. Not sure if this is an issue with the latest postgres-pr but it was in earlier versions.

Michael Neumann wrote:

Ernest Ellingson wrote:

Ernest Ellingson wrote:

Michael Neumann wrote:

Ernest Ellingson wrote:

I've installed the windows version of ruby-1.8.2 with the latest one-click installer. I used gem to install postgres-pr-0.3.2. However, I can't seem to get any of the examples to run. I'm getting a

uninitialized constant StartupMessage (NameError) in client.rb

I fixed that. put a "include PostgresPR" after the requires and it works. Try postgres-pr-0.3.3.

The require statements are:
$LOAD_PATH.unshift "../lib"
requie 'rubygems'
require 'postgres-pr/message'
require 'socket'

The first two lines of code are

s = UNIXSocket.new(ARGV.shift || "/tmp/.s.PGSQL.5432")

msg = StartupMessage.new(196608, "user" => "mneumann", "database" => "mneumann")

I can't use a UNIXSocket because I'm not running Cygwin. However, I don't see any requirements in postgres-pr/message.rb for (s).
Am I missing something?

I don't understand your question... Maybe... The UNIXSocket is only used in the example, you can use postgres-pr/connection.rb without a UNIXSocket, with a TCPSocket. That's no problem.

Does someone have any experience using postgres-pr in the dbi. If so,
How does one connect to a server?

Just use DBD::Pg. I've not tried it. But I know that it works with ActiveRecord and Og.

Regards,

  Michael

Thanks Michael, I'll give it a whirl and let you know how things worked out.
Ernie

Something's still fowled up. I installed postgres-pr.0.3.3 using gem install. I uninstalled postgres-pr-0.3.2 using gem.
There is no Pg driver in the DBD directory.

dbi was installed with the one click windows installer not with gem.
Should I just install postgres-pr.0.3.3 without using gem?
Should I install the dbi using gem?

DBI via gem is not (yet) available.
And, postgres-pr is NOT a DBD! It has a compatibility layer to postgres.so (the C-interface to Postgres), but that's not 100% compatible as my focus was on getting ActiveRecord and Og working with it. I've not tested postgres-pr with DBD::Pg (DBI). It might fail!

How do I go about getting the Pg driver installed in the DBD directory.

You should not remove the Pg.rb driver!

If I'm running a script from some other directory other than the example directory, what requires do I need? Up to now I've only had to require 'dbi' when using ODBC.

Again, postgres-pr has nothing to do with DBI. If it would be 100% compatible to postgres.so, you should be able to just use the DBD::Pg with a simple require 'dbi' and then DBI.connect("dbi:g:...").

I ran the client.rb program after changing the socket to a TCPsocket. My system started thrashing. Page files jumped to 1.24GB that's right GIGA BYTES. Thrashed for a while and then just hung there. PF dropped back to 144MB. What's that all about?

I don't know. It works fine on my machine. Would you try test_connection.rb? But note, that you should change the connection parameters and make sure, you don't destroy data in your database!
Does it work?

Regards,

   Michael

Thanks Michael
I'm still not sure about Pg.rb. Where is it? It's not in the DBI or the DBD directory. Does it exist? How do I get it?

As for postgres-pr I tried the test_connection.rb code changed the uri to 'tcp://ipaddress:5432' and the other parameters to appropriate values. Apparently a connection is being made but the same blow up in page files occurs 1.25 GB's. The program finally errors out with this trace. I should mention the database is on another machine running RH linux 9 and postgresql 7.4.

c:/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.3.3/lib/buffer.rb:64:in `read': failed to allocate memory (NoMemoryError)
         from c:/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.3.3/lib/buffer.rb:64:in `copy_from_stream'
         from c:/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.3.3/lib/postgres-pr/message.rb:41:in `read'
         from c:/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.3.3/lib/postgres-pr/connection.rb:27:in `initialize'
         from c:/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.3.3/lib/postgres-pr/connection.rb:26:in `loop'
         from c:/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.3.3/lib/postgres-pr/connection.rb:26:in `initialize'
         from C:/RubyScripts/postgresql/test_connection.rb:4:in `new'
         from C:/RubyScripts/postgresql/test_connection.rb:4

Thanks again
Ernie

Ernest Ellingson wrote:

Thanks Michael
I'm still not sure about Pg.rb. Where is it? It's not in the DBI or the DBD directory. Does it exist? How do I get it?

Ah, okay. I think it's not bundled with the Windows-Installer, as you need the postgres.so or postgres-pr libraries. And postgres.so is/was not available for Windows AFAIK.

You can download it from here:

http://ntecs.de/viewcvs/viewcvs/dbd-pg/trunk/src/?root=ruby-dbi

Just put the Pg.rb into the DBD/Pg directory (create the Pg directory).

As for postgres-pr I tried the test_connection.rb code changed the uri to 'tcp://ipaddress:5432' and the other parameters to appropriate values. Apparently a connection is being made but the same blow up in page files occurs 1.25 GB's. The program finally errors out with this trace. I should mention the database is on another machine running RH linux 9 and postgresql 7.4.

Hm, very strange. Does using TCPSockets generally work on your platform without problems?

c:/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.3.3/lib/buffer.rb:64:in `read': failed to allocate memory (NoMemoryError)

I should include some debug code. It might be, that there's a negative buffer-length which gets interpreted as an unsigned value... or something like this. You're on a 32-bit machine, right?

Regards,

   Michael

Thursday wrote:

Michael Neumann wrote:

And, postgres-pr is NOT a DBD! It has a compatibility layer to postgres.so (the C-interface to Postgres), but that's not 100% compatible as my focus was on getting ActiveRecord and Og working with it. I've not tested postgres-pr with DBD::Pg (DBI). It might fail!

I think some code was added to ActiveRecord 1.3 which might break compatibility with postgres-pr. Not sure if this is an issue with the latest postgres-pr but it was in earlier versions.

Not sure either. Please report if there are problems.

Regards,

   Michael

Michael Neumann wrote:

Ernest Ellingson wrote:

Thanks Michael
I'm still not sure about Pg.rb. Where is it? It's not in the DBI or the DBD directory. Does it exist? How do I get it?

Ah, okay. I think it's not bundled with the Windows-Installer, as you need the postgres.so or postgres-pr libraries. And postgres.so is/was not available for Windows AFAIK.

You can download it from here:

http://ntecs.de/viewcvs/viewcvs/dbd-pg/trunk/src/?root=ruby-dbi

Just put the Pg.rb into the DBD/Pg directory (create the Pg directory).

As for postgres-pr I tried the test_connection.rb code changed the uri to 'tcp://ipaddress:5432' and the other parameters to appropriate values. Apparently a connection is being made but the same blow up in page files occurs 1.25 GB's. The program finally errors out with this trace. I should mention the database is on another machine running RH linux 9 and postgresql 7.4.

Hm, very strange. Does using TCPSockets generally work on your platform without problems?

c:/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.3.3/lib/buffer.rb:64:in `read': failed to allocate memory (NoMemoryError)

I should include some debug code. It might be, that there's a negative buffer-length which gets interpreted as an unsigned value... or something like this. You're on a 32-bit machine, right?

Regards,

  Michael

I haven't had a problem with smtp or gets or posts with httpAccess2 so I believe that TCPsockets are working fine. I am running a 32 bit machine
WindowsXP svc Pack 2.

Thanks
Ernie

Ernest Ellingson wrote:

Michael Neumann wrote:

Ernest Ellingson wrote:

Thanks Michael
I'm still not sure about Pg.rb. Where is it? It's not in the DBI or the DBD directory. Does it exist? How do I get it?

Ah, okay. I think it's not bundled with the Windows-Installer, as you need the postgres.so or postgres-pr libraries. And postgres.so is/was not available for Windows AFAIK.

You can download it from here:

http://ntecs.de/viewcvs/viewcvs/dbd-pg/trunk/src/?root=ruby-dbi

Just put the Pg.rb into the DBD/Pg directory (create the Pg directory).

As for postgres-pr I tried the test_connection.rb code changed the uri to 'tcp://ipaddress:5432' and the other parameters to appropriate values. Apparently a connection is being made but the same blow up in page files occurs 1.25 GB's. The program finally errors out with this trace. I should mention the database is on another machine running RH linux 9 and postgresql 7.4.

Hm, very strange. Does using TCPSockets generally work on your platform without problems?

c:/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.3.3/lib/buffer.rb:64:in `read': failed to allocate memory (NoMemoryError)

I should include some debug code. It might be, that there's a negative buffer-length which gets interpreted as an unsigned value... or something like this. You're on a 32-bit machine, right?

Regards,

  Michael

I haven't had a problem with smtp or gets or posts with httpAccess2 so I believe that TCPsockets are working fine. I am running a 32 bit machine
WindowsXP svc Pack 2.

Could you patch message.rb of postgres-pr with the following patch, and tell me what you get on STDOUT:

Index: message.rb

···

===================================================================
--- message.rb (revision 475)
+++ message.rb (working copy)
@@ -32,6 +32,8 @@
      type = stream.readbytes(1).unpack('C').first unless startup
      length = stream.readbytes(4).unpack('N').first # FIXME: length should be signed, not unsigned

+ p length
+
      raise ParseError unless length >= 4

      # initialize buffer

Regards,

   Michael

Michael Neumann wrote:

Ernest Ellingson wrote:

Michael Neumann wrote:

Ernest Ellingson wrote:

Thanks Michael
I'm still not sure about Pg.rb. Where is it? It's not in the DBI or the DBD directory. Does it exist? How do I get it?

Ah, okay. I think it's not bundled with the Windows-Installer, as you need the postgres.so or postgres-pr libraries. And postgres.so is/was not available for Windows AFAIK.

You can download it from here:

http://ntecs.de/viewcvs/viewcvs/dbd-pg/trunk/src/?root=ruby-dbi

Just put the Pg.rb into the DBD/Pg directory (create the Pg directory).

As for postgres-pr I tried the test_connection.rb code changed the uri to 'tcp://ipaddress:5432' and the other parameters to appropriate values. Apparently a connection is being made but the same blow up in page files occurs 1.25 GB's. The program finally errors out with this trace. I should mention the database is on another machine running RH linux 9 and postgresql 7.4.

Hm, very strange. Does using TCPSockets generally work on your platform without problems?

c:/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.3.3/lib/buffer.rb:64:in `read': failed to allocate memory (NoMemoryError)

I should include some debug code. It might be, that there's a negative buffer-length which gets interpreted as an unsigned value... or something like this. You're on a 32-bit machine, right?

Regards,

  Michael

I haven't had a problem with smtp or gets or posts with httpAccess2 so I believe that TCPsockets are working fine. I am running a 32 bit machine
WindowsXP svc Pack 2.

Could you patch message.rb of postgres-pr with the following patch, and tell me what you get on STDOUT:

Index: message.rb

--- message.rb (revision 475)
+++ message.rb (working copy)
@@ -32,6 +32,8 @@
     type = stream.readbytes(1).unpack('C').first unless startup
     length = stream.readbytes(4).unpack('N').first # FIXME: length should be signed, not unsigned

+ p length
+
     raise ParseError unless length >= 4

     # initialize buffer

Regards,

  Michael

Hi Michael:
  The p length statement yields

  1178686529

Which is where the page file blow up happens.

I put a p type line in too.
the type is
  69

Ernie

> Could you patch message.rb of postgres-pr with the following patch, and
> tell me what you get on STDOUT:
>
> Index: message.rb
> ===================================================================
> --- message.rb (revision 475)
> +++ message.rb (working copy)
> @@ -32,6 +32,8 @@
> type = stream.readbytes(1).unpack('C').first unless startup
> length = stream.readbytes(4).unpack('N').first # FIXME: length
> should be signed, not unsigned
>
> + p length
> +
> raise ParseError unless length >= 4
>
> # initialize buffer
>
> Regards,
>
> Michael

Hi Michael:
  The p length statement yields

  1178686529

That sure is the problem.

Which version of Postgres do you use?

I put a p type line in too.
the type is
  69

That's the 'E' ErrorResponse message. I guess you're using the 2.0 connection
protocol (< 7.4), whereas postgres-pr only implements the new 3.0.
But the database should IMO close the connection if it sees that you're using
a different connection protocol version....

Regards,

  Michael

···

Am Samstag 08 Januar 2005 20:51 schrieb Ernest Ellingson: